| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683 |
- function Jae(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var Hw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rT={exports:{}},Dx={};var iU;function ese(){if(iU)return Dx;iU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var l in i)l!=="key"&&(s[l]=i[l])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:s}}return Dx.Fragment=e,Dx.jsx=n,Dx.jsxs=n,Dx}var aU;function tse(){return aU||(aU=1,rT.exports=ese()),rT.exports}var a=tse(),iT={exports:{}},Nn={};var sU;function nse(){if(sU)return Nn;sU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),p=Symbol.iterator;function m(H){return H===null||typeof H!="object"?null:(H=p&&H[p]||H["@@iterator"],typeof H=="function"?H:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,x={};function v(H,W,J){this.props=H,this.context=W,this.refs=x,this.updater=J||b}v.prototype.isReactComponent={},v.prototype.setState=function(H,W){if(typeof H!="object"&&typeof H!="function"&&H!=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,H,W,"setState")},v.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function S(){}S.prototype=v.prototype;function N(H,W,J){this.props=H,this.context=W,this.refs=x,this.updater=J||b}var T=N.prototype=new S;T.constructor=N,y(T,v.prototype),T.isPureReactComponent=!0;var M=Array.isArray;function A(){}var k={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function C(H,W,J){var ne=J.ref;return{$$typeof:t,type:H,key:W,ref:ne!==void 0?ne:null,props:J}}function P(H,W){return C(H.type,W,H.props)}function U(H){return typeof H=="object"&&H!==null&&H.$$typeof===t}function F(H){var W={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(J){return W[J]})}var B=/\/+/g;function D(H,W){return typeof H=="object"&&H!==null&&H.key!=null?F(""+H.key):W.toString(36)}function $(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(A,A):(H.status="pending",H.then(function(W){H.status==="pending"&&(H.status="fulfilled",H.value=W)},function(W){H.status==="pending"&&(H.status="rejected",H.reason=W)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function G(H,W,J,ne,xe){var ue=typeof H;(ue==="undefined"||ue==="boolean")&&(H=null);var fe=!1;if(H===null)fe=!0;else switch(ue){case"bigint":case"string":case"number":fe=!0;break;case"object":switch(H.$$typeof){case t:case e:fe=!0;break;case d:return fe=H._init,G(fe(H._payload),W,J,ne,xe)}}if(fe)return xe=xe(H),fe=ne===""?"."+D(H,0):ne,M(xe)?(J="",fe!=null&&(J=fe.replace(B,"$&/")+"/"),G(xe,W,J,"",function(Ne){return Ne})):xe!=null&&(U(xe)&&(xe=P(xe,J+(xe.key==null||H&&H.key===xe.key?"":(""+xe.key).replace(B,"$&/")+"/")+fe)),W.push(xe)),1;fe=0;var De=ne===""?".":ne+":";if(M(H))for(var oe=0;oe<H.length;oe++)ne=H[oe],ue=De+D(ne,oe),fe+=G(ne,W,J,ue,xe);else if(oe=m(H),typeof oe=="function")for(H=oe.call(H),oe=0;!(ne=H.next()).done;)ne=ne.value,ue=De+D(ne,oe++),fe+=G(ne,W,J,ue,xe);else if(ue==="object"){if(typeof H.then=="function")return G($(H),W,J,ne,xe);throw W=String(H),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return fe}function I(H,W,J){if(H==null)return H;var ne=[],xe=0;return G(H,ne,"","",function(ue){return W.call(J,ue,xe++)}),ne}function K(H){if(H._status===-1){var W=H._result;W=W(),W.then(function(J){(H._status===0||H._status===-1)&&(H._status=1,H._result=J)},function(J){(H._status===0||H._status===-1)&&(H._status=2,H._result=J)}),H._status===-1&&(H._status=0,H._result=W)}if(H._status===1)return H._result.default;throw H._result}var Q=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=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(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},se={map:I,forEach:function(H,W,J){I(H,function(){W.apply(this,arguments)},J)},count:function(H){var W=0;return I(H,function(){W++}),W},toArray:function(H){return I(H,function(W){return W})||[]},only:function(H){if(!U(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return Nn.Activity=h,Nn.Children=se,Nn.Component=v,Nn.Fragment=n,Nn.Profiler=i,Nn.PureComponent=N,Nn.StrictMode=r,Nn.Suspense=c,Nn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,Nn.__COMPILER_RUNTIME={__proto__:null,c:function(H){return k.H.useMemoCache(H)}},Nn.cache=function(H){return function(){return H.apply(null,arguments)}},Nn.cacheSignal=function(){return null},Nn.cloneElement=function(H,W,J){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var ne=y({},H.props),xe=H.key;if(W!=null)for(ue in W.key!==void 0&&(xe=""+W.key),W)!R.call(W,ue)||ue==="key"||ue==="__self"||ue==="__source"||ue==="ref"&&W.ref===void 0||(ne[ue]=W[ue]);var ue=arguments.length-2;if(ue===1)ne.children=J;else if(1<ue){for(var fe=Array(ue),De=0;De<ue;De++)fe[De]=arguments[De+2];ne.children=fe}return C(H.type,xe,ne)},Nn.createContext=function(H){return H={$$typeof:o,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:s,_context:H},H},Nn.createElement=function(H,W,J){var ne,xe={},ue=null;if(W!=null)for(ne in W.key!==void 0&&(ue=""+W.key),W)R.call(W,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(xe[ne]=W[ne]);var fe=arguments.length-2;if(fe===1)xe.children=J;else if(1<fe){for(var De=Array(fe),oe=0;oe<fe;oe++)De[oe]=arguments[oe+2];xe.children=De}if(H&&H.defaultProps)for(ne in fe=H.defaultProps,fe)xe[ne]===void 0&&(xe[ne]=fe[ne]);return C(H,ue,xe)},Nn.createRef=function(){return{current:null}},Nn.forwardRef=function(H){return{$$typeof:l,render:H}},Nn.isValidElement=U,Nn.lazy=function(H){return{$$typeof:d,_payload:{_status:-1,_result:H},_init:K}},Nn.memo=function(H,W){return{$$typeof:u,type:H,compare:W===void 0?null:W}},Nn.startTransition=function(H){var W=k.T,J={};k.T=J;try{var ne=H(),xe=k.S;xe!==null&&xe(J,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(A,Q)}catch(ue){Q(ue)}finally{W!==null&&J.types!==null&&(W.types=J.types),k.T=W}},Nn.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},Nn.use=function(H){return k.H.use(H)},Nn.useActionState=function(H,W,J){return k.H.useActionState(H,W,J)},Nn.useCallback=function(H,W){return k.H.useCallback(H,W)},Nn.useContext=function(H){return k.H.useContext(H)},Nn.useDebugValue=function(){},Nn.useDeferredValue=function(H,W){return k.H.useDeferredValue(H,W)},Nn.useEffect=function(H,W){return k.H.useEffect(H,W)},Nn.useEffectEvent=function(H){return k.H.useEffectEvent(H)},Nn.useId=function(){return k.H.useId()},Nn.useImperativeHandle=function(H,W,J){return k.H.useImperativeHandle(H,W,J)},Nn.useInsertionEffect=function(H,W){return k.H.useInsertionEffect(H,W)},Nn.useLayoutEffect=function(H,W){return k.H.useLayoutEffect(H,W)},Nn.useMemo=function(H,W){return k.H.useMemo(H,W)},Nn.useOptimistic=function(H,W){return k.H.useOptimistic(H,W)},Nn.useReducer=function(H,W,J){return k.H.useReducer(H,W,J)},Nn.useRef=function(H){return k.H.useRef(H)},Nn.useState=function(H){return k.H.useState(H)},Nn.useSyncExternalStore=function(H,W,J){return k.H.useSyncExternalStore(H,W,J)},Nn.useTransition=function(){return k.H.useTransition()},Nn.version="19.2.0",Nn}var oU;function Sb(){return oU||(oU=1,iT.exports=nse()),iT.exports}var _=Sb();const ri=gl(_),rse=Jae({__proto__:null,default:ri},[_]);var aT={exports:{}},Rx={},sT={exports:{}},oT={};var lU;function ise(){return lU||(lU=1,(function(t){function e(G,I){var K=G.length;G.push(I);e:for(;0<K;){var Q=K-1>>>1,se=G[Q];if(0<i(se,I))G[Q]=I,G[K]=se,K=Q;else break e}}function n(G){return G.length===0?null:G[0]}function r(G){if(G.length===0)return null;var I=G[0],K=G.pop();if(K!==I){G[0]=K;e:for(var Q=0,se=G.length,H=se>>>1;Q<H;){var W=2*(Q+1)-1,J=G[W],ne=W+1,xe=G[ne];if(0>i(J,K))ne<se&&0>i(xe,J)?(G[Q]=xe,G[ne]=K,Q=ne):(G[Q]=J,G[W]=K,Q=W);else if(ne<se&&0>i(xe,K))G[Q]=xe,G[ne]=K,Q=ne;else break e}}return I}function i(G,I){var K=G.sortIndex-I.sortIndex;return K!==0?K:G.id-I.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,h=null,p=3,m=!1,b=!1,y=!1,x=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function T(G){for(var I=n(u);I!==null;){if(I.callback===null)r(u);else if(I.startTime<=G)r(u),I.sortIndex=I.expirationTime,e(c,I);else break;I=n(u)}}function M(G){if(y=!1,T(G),!b)if(n(c)!==null)b=!0,A||(A=!0,F());else{var I=n(u);I!==null&&$(M,I.startTime-G)}}var A=!1,k=-1,R=5,C=-1;function P(){return x?!0:!(t.unstable_now()-C<R)}function U(){if(x=!1,A){var G=t.unstable_now();C=G;var I=!0;try{e:{b=!1,y&&(y=!1,S(k),k=-1),m=!0;var K=p;try{t:{for(T(G),h=n(c);h!==null&&!(h.expirationTime>G&&P());){var Q=h.callback;if(typeof Q=="function"){h.callback=null,p=h.priorityLevel;var se=Q(h.expirationTime<=G);if(G=t.unstable_now(),typeof se=="function"){h.callback=se,T(G),I=!0;break t}h===n(c)&&r(c),T(G)}else r(c);h=n(c)}if(h!==null)I=!0;else{var H=n(u);H!==null&&$(M,H.startTime-G),I=!1}}break e}finally{h=null,p=K,m=!1}I=void 0}}finally{I?F():A=!1}}}var F;if(typeof N=="function")F=function(){N(U)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,D=B.port2;B.port1.onmessage=U,F=function(){D.postMessage(null)}}else F=function(){v(U,0)};function $(G,I){k=v(function(){G(t.unstable_now())},I)}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(G){G.callback=null},t.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<G?Math.floor(1e3/G):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_next=function(G){switch(p){case 1:case 2:case 3:var I=3;break;default:I=p}var K=p;p=I;try{return G()}finally{p=K}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(G,I){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var K=p;p=G;try{return I()}finally{p=K}},t.unstable_scheduleCallback=function(G,I,K){var Q=t.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?Q+K:Q):K=Q,G){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=K+se,G={id:d++,callback:I,priorityLevel:G,startTime:K,expirationTime:se,sortIndex:-1},K>Q?(G.sortIndex=K,e(u,G),n(c)===null&&G===n(u)&&(y?(S(k),k=-1):y=!0,$(M,K-Q))):(G.sortIndex=se,e(c,G),b||m||(b=!0,A||(A=!0,F()))),G},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(G){var I=p;return function(){var K=p;p=I;try{return G.apply(this,arguments)}finally{p=K}}}})(oT)),oT}var cU;function ase(){return cU||(cU=1,sT.exports=ise()),sT.exports}var lT={exports:{}},qa={};var uU;function sse(){if(uU)return qa;uU=1;var t=Sb();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function s(c,u,d){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:h==null?null:""+h,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 qa.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,qa.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return s(c,u,null,d)},qa.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()}},qa.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))},qa.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},qa.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,h=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:h,integrity:p,fetchPriority:m}):d==="script"&&r.d.X(c,{crossOrigin:h,integrity:p,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},qa.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)},qa.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,h=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:h,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})}},qa.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)},qa.requestFormReset=function(c){r.d.r(c)},qa.unstable_batchedUpdates=function(c,u){return c(u)},qa.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},qa.useFormStatus=function(){return o.H.useHostTransitionStatus()},qa.version="19.2.0",qa}var dU;function H9(){if(dU)return lT.exports;dU=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),lT.exports=sse(),lT.exports}var hU;function ose(){if(hU)return Rx;hU=1;var t=ase(),e=Sb(),n=H9();function r(f){var g="https://react.dev/errors/"+f;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 #"+f+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(f){return!(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)}function s(f){var g=f,w=f;if(f.alternate)for(;g.return;)g=g.return;else{f=g;do g=f,(g.flags&4098)!==0&&(w=g.return),f=g.return;while(f)}return g.tag===3?w:null}function o(f){if(f.tag===13){var g=f.memoizedState;if(g===null&&(f=f.alternate,f!==null&&(g=f.memoizedState)),g!==null)return g.dehydrated}return null}function l(f){if(f.tag===31){var g=f.memoizedState;if(g===null&&(f=f.alternate,f!==null&&(g=f.memoizedState)),g!==null)return g.dehydrated}return null}function c(f){if(s(f)!==f)throw Error(r(188))}function u(f){var g=f.alternate;if(!g){if(g=s(f),g===null)throw Error(r(188));return g!==f?null:f}for(var w=f,E=g;;){var j=w.return;if(j===null)break;var L=j.alternate;if(L===null){if(E=j.return,E!==null){w=E;continue}break}if(j.child===L.child){for(L=j.child;L;){if(L===w)return c(j),f;if(L===E)return c(j),g;L=L.sibling}throw Error(r(188))}if(w.return!==E.return)w=j,E=L;else{for(var te=!1,ye=j.child;ye;){if(ye===w){te=!0,w=j,E=L;break}if(ye===E){te=!0,E=j,w=L;break}ye=ye.sibling}if(!te){for(ye=L.child;ye;){if(ye===w){te=!0,w=L,E=j;break}if(ye===E){te=!0,E=L,w=j;break}ye=ye.sibling}if(!te)throw Error(r(189))}}if(w.alternate!==E)throw Error(r(190))}if(w.tag!==3)throw Error(r(188));return w.stateNode.current===w?f:g}function d(f){var g=f.tag;if(g===5||g===26||g===27||g===6)return f;for(f=f.child;f!==null;){if(g=d(f),g!==null)return g;f=f.sibling}return null}var h=Object.assign,p=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),N=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function F(f){return f===null||typeof f!="object"?null:(f=U&&f[U]||f["@@iterator"],typeof f=="function"?f:null)}var B=Symbol.for("react.client.reference");function D(f){if(f==null)return null;if(typeof f=="function")return f.$$typeof===B?null:f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case y:return"Fragment";case v:return"Profiler";case x:return"StrictMode";case M:return"Suspense";case A:return"SuspenseList";case C:return"Activity"}if(typeof f=="object")switch(f.$$typeof){case b:return"Portal";case N:return f.displayName||"Context";case S:return(f._context.displayName||"Context")+".Consumer";case T:var g=f.render;return f=f.displayName,f||(f=g.displayName||g.name||"",f=f!==""?"ForwardRef("+f+")":"ForwardRef"),f;case k:return g=f.displayName||null,g!==null?g:D(f.type)||"Memo";case R:g=f._payload,f=f._init;try{return D(f(g))}catch{}}return null}var $=Array.isArray,G=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K={pending:!1,data:null,method:null,action:null},Q=[],se=-1;function H(f){return{current:f}}function W(f){0>se||(f.current=Q[se],Q[se]=null,se--)}function J(f,g){se++,Q[se]=f.current,f.current=g}var ne=H(null),xe=H(null),ue=H(null),fe=H(null);function De(f,g){switch(J(ue,g),J(xe,f),J(ne,null),g.nodeType){case 9:case 11:f=(f=g.documentElement)&&(f=f.namespaceURI)?Ez(f):0;break;default:if(f=g.tagName,g=g.namespaceURI)g=Ez(g),f=Tz(g,f);else switch(f){case"svg":f=1;break;case"math":f=2;break;default:f=0}}W(ne),J(ne,f)}function oe(){W(ne),W(xe),W(ue)}function Ne(f){f.memoizedState!==null&&J(fe,f);var g=ne.current,w=Tz(g,f.type);g!==w&&(J(xe,f),J(ne,w))}function Fe(f){xe.current===f&&(W(ne),W(xe)),fe.current===f&&(W(fe),Ax._currentValue=K)}var ce,Ve;function V(f){if(ce===void 0)try{throw Error()}catch(w){var g=w.stack.trim().match(/\n( *(at )?)/);ce=g&&g[1]||"",Ve=-1<w.stack.indexOf(`
- at`)?" (<anonymous>)":-1<w.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+ce+f+Ve}var Y=!1;function de(f,g){if(!f||Y)return"";Y=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var E={DetermineComponentFrameRoot:function(){try{if(g){var Nt=function(){throw Error()};if(Object.defineProperty(Nt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Nt,[])}catch(bt){var ft=bt}Reflect.construct(f,[],Nt)}else{try{Nt.call()}catch(bt){ft=bt}f.call(Nt.prototype)}}else{try{throw Error()}catch(bt){ft=bt}(Nt=f())&&typeof Nt.catch=="function"&&Nt.catch(function(){})}}catch(bt){if(bt&&ft&&typeof bt.stack=="string")return[bt.stack,ft.stack]}return[null,null]}};E.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var j=Object.getOwnPropertyDescriptor(E.DetermineComponentFrameRoot,"name");j&&j.configurable&&Object.defineProperty(E.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var L=E.DetermineComponentFrameRoot(),te=L[0],ye=L[1];if(te&&ye){var Be=te.split(`
- `),ct=ye.split(`
- `);for(j=E=0;E<Be.length&&!Be[E].includes("DetermineComponentFrameRoot");)E++;for(;j<ct.length&&!ct[j].includes("DetermineComponentFrameRoot");)j++;if(E===Be.length||j===ct.length)for(E=Be.length-1,j=ct.length-1;1<=E&&0<=j&&Be[E]!==ct[j];)j--;for(;1<=E&&0<=j;E--,j--)if(Be[E]!==ct[j]){if(E!==1||j!==1)do if(E--,j--,0>j||Be[E]!==ct[j]){var vt=`
- `+Be[E].replace(" at new "," at ");return f.displayName&&vt.includes("<anonymous>")&&(vt=vt.replace("<anonymous>",f.displayName)),vt}while(1<=E&&0<=j);break}}}finally{Y=!1,Error.prepareStackTrace=w}return(w=f?f.displayName||f.name:"")?V(w):""}function q(f,g){switch(f.tag){case 26:case 27:case 5:return V(f.type);case 16:return V("Lazy");case 13:return f.child!==g&&g!==null?V("Suspense Fallback"):V("Suspense");case 19:return V("SuspenseList");case 0:case 15:return de(f.type,!1);case 11:return de(f.type.render,!1);case 1:return de(f.type,!0);case 31:return V("Activity");default:return""}}function re(f){try{var g="",w=null;do g+=q(f,w),w=f,f=f.return;while(f);return g}catch(E){return`
- Error generating stack: `+E.message+`
- `+E.stack}}var X=Object.prototype.hasOwnProperty,le=t.unstable_scheduleCallback,pe=t.unstable_cancelCallback,ee=t.unstable_shouldYield,z=t.unstable_requestPaint,O=t.unstable_now,Z=t.unstable_getCurrentPriorityLevel,me=t.unstable_ImmediatePriority,Te=t.unstable_UserBlockingPriority,ke=t.unstable_NormalPriority,Ee=t.unstable_LowPriority,Se=t.unstable_IdlePriority,$e=t.log,Qe=t.unstable_setDisableYieldValue,Ue=null,be=null;function ve(f){if(typeof $e=="function"&&Qe(f),be&&typeof be.setStrictMode=="function")try{be.setStrictMode(Ue,f)}catch{}}var ze=Math.clz32?Math.clz32:_e,Ce=Math.log,Ge=Math.LN2;function _e(f){return f>>>=0,f===0?32:31-(Ce(f)/Ge|0)|0}var Je=256,Ae=262144,Ke=4194304;function je(f){var g=f&42;if(g!==0)return g;switch(f&-f){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 f&261888;case 262144:case 524288:case 1048576:case 2097152:return f&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return f&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return f}}function Re(f,g,w){var E=f.pendingLanes;if(E===0)return 0;var j=0,L=f.suspendedLanes,te=f.pingedLanes;f=f.warmLanes;var ye=E&134217727;return ye!==0?(E=ye&~L,E!==0?j=je(E):(te&=ye,te!==0?j=je(te):w||(w=ye&~f,w!==0&&(j=je(w))))):(ye=E&~L,ye!==0?j=je(ye):te!==0?j=je(te):w||(w=E&~f,w!==0&&(j=je(w)))),j===0?0:g!==0&&g!==j&&(g&L)===0&&(L=j&-j,w=g&-g,L>=w||L===32&&(w&4194048)!==0)?g:j}function we(f,g){return(f.pendingLanes&~(f.suspendedLanes&~f.pingedLanes)&g)===0}function qe(f,g){switch(f){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 f=Ke;return Ke<<=1,(Ke&62914560)===0&&(Ke=4194304),f}function Et(f){for(var g=[],w=0;31>w;w++)g.push(f);return g}function fn(f,g){f.pendingLanes|=g,g!==268435456&&(f.suspendedLanes=0,f.pingedLanes=0,f.warmLanes=0)}function It(f,g,w,E,j,L){var te=f.pendingLanes;f.pendingLanes=w,f.suspendedLanes=0,f.pingedLanes=0,f.warmLanes=0,f.expiredLanes&=w,f.entangledLanes&=w,f.errorRecoveryDisabledLanes&=w,f.shellSuspendCounter=0;var ye=f.entanglements,Be=f.expirationTimes,ct=f.hiddenUpdates;for(w=te&~w;0<w;){var vt=31-ze(w),Nt=1<<vt;ye[vt]=0,Be[vt]=-1;var ft=ct[vt];if(ft!==null)for(ct[vt]=null,vt=0;vt<ft.length;vt++){var bt=ft[vt];bt!==null&&(bt.lane&=-536870913)}w&=~Nt}E!==0&&Oe(f,E,0),L!==0&&j===0&&f.tag!==0&&(f.suspendedLanes|=L&~(te&~g))}function Oe(f,g,w){f.pendingLanes|=g,f.suspendedLanes&=~g;var E=31-ze(g);f.entangledLanes|=g,f.entanglements[E]=f.entanglements[E]|1073741824|w&261930}function yt(f,g){var w=f.entangledLanes|=g;for(f=f.entanglements;w;){var E=31-ze(w),j=1<<E;j&g|f[E]&g&&(f[E]|=g),w&=~j}}function Wt(f,g){var w=g&-g;return w=(w&42)!==0?1:rn(w),(w&(f.suspendedLanes|g))!==0?0:w}function rn(f){switch(f){case 2:f=1;break;case 8:f=4;break;case 32:f=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:f=128;break;case 268435456:f=134217728;break;default:f=0}return f}function Qt(f){return f&=-f,2<f?8<f?(f&134217727)!==0?32:268435456:8:2}function ur(){var f=I.p;return f!==0?f:(f=window.event,f===void 0?32:Qz(f.type))}function Lr(f,g){var w=I.p;try{return I.p=f,g()}finally{I.p=w}}var nr=Math.random().toString(36).slice(2),Xt="__reactFiber$"+nr,Zn="__reactProps$"+nr,oi="__reactContainer$"+nr,da="__reactEvents$"+nr,Pe="__reactListeners$"+nr,tt="__reactHandles$"+nr,ht="__reactResources$"+nr,mt="__reactMarker$"+nr;function at(f){delete f[Xt],delete f[Zn],delete f[da],delete f[Pe],delete f[tt]}function Dt(f){var g=f[Xt];if(g)return g;for(var w=f.parentNode;w;){if(g=w[oi]||w[Xt]){if(w=g.alternate,g.child!==null||w!==null&&w.child!==null)for(f=Oz(f);f!==null;){if(w=f[Xt])return w;f=Oz(f)}return g}f=w,w=f.parentNode}return null}function he(f){if(f=f[Xt]||f[oi]){var g=f.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return f}return null}function Ie(f){var g=f.tag;if(g===5||g===26||g===27||g===6)return f.stateNode;throw Error(r(33))}function Xe(f){var g=f[ht];return g||(g=f[ht]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function He(f){f[mt]=!0}var ge=new Set,rt={};function ut(f,g){it(f,g),it(f+"Capture",g)}function it(f,g){for(rt[f]=g,f=0;f<g.length;f++)ge.add(g[f])}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]*$"),Ut={},jt={};function Ct(f){return X.call(jt,f)?!0:X.call(Ut,f)?!1:Tt.test(f)?jt[f]=!0:(Ut[f]=!0,!1)}function an(f,g,w){if(Ct(g))if(w===null)f.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":f.removeAttribute(g);return;case"boolean":var E=g.toLowerCase().slice(0,5);if(E!=="data-"&&E!=="aria-"){f.removeAttribute(g);return}}f.setAttribute(g,""+w)}}function Vt(f,g,w){if(w===null)f.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":f.removeAttribute(g);return}f.setAttribute(g,""+w)}}function gn(f,g,w,E){if(E===null)f.removeAttribute(w);else{switch(typeof E){case"undefined":case"function":case"symbol":case"boolean":f.removeAttribute(w);return}f.setAttributeNS(g,w,""+E)}}function Mn(f){switch(typeof f){case"bigint":case"boolean":case"number":case"string":case"undefined":return f;case"object":return f;default:return""}}function bn(f){var g=f.type;return(f=f.nodeName)&&f.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function qt(f,g,w){var E=Object.getOwnPropertyDescriptor(f.constructor.prototype,g);if(!f.hasOwnProperty(g)&&typeof E<"u"&&typeof E.get=="function"&&typeof E.set=="function"){var j=E.get,L=E.set;return Object.defineProperty(f,g,{configurable:!0,get:function(){return j.call(this)},set:function(te){w=""+te,L.call(this,te)}}),Object.defineProperty(f,g,{enumerable:E.enumerable}),{getValue:function(){return w},setValue:function(te){w=""+te},stopTracking:function(){f._valueTracker=null,delete f[g]}}}}function sn(f){if(!f._valueTracker){var g=bn(f)?"checked":"value";f._valueTracker=qt(f,g,""+f[g])}}function Jt(f){if(!f)return!1;var g=f._valueTracker;if(!g)return!0;var w=g.getValue(),E="";return f&&(E=bn(f)?f.checked?"true":"false":f.value),f=E,f!==w?(g.setValue(f),!0):!1}function mr(f){if(f=f||(typeof document<"u"?document:void 0),typeof f>"u")return null;try{return f.activeElement||f.body}catch{return f.body}}var Hr=/[\n"\\]/g;function Jn(f){return f.replace(Hr,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function Bn(f,g,w,E,j,L,te,ye){f.name="",te!=null&&typeof te!="function"&&typeof te!="symbol"&&typeof te!="boolean"?f.type=te:f.removeAttribute("type"),g!=null?te==="number"?(g===0&&f.value===""||f.value!=g)&&(f.value=""+Mn(g)):f.value!==""+Mn(g)&&(f.value=""+Mn(g)):te!=="submit"&&te!=="reset"||f.removeAttribute("value"),g!=null?Rt(f,te,Mn(g)):w!=null?Rt(f,te,Mn(w)):E!=null&&f.removeAttribute("value"),j==null&&L!=null&&(f.defaultChecked=!!L),j!=null&&(f.checked=j&&typeof j!="function"&&typeof j!="symbol"),ye!=null&&typeof ye!="function"&&typeof ye!="symbol"&&typeof ye!="boolean"?f.name=""+Mn(ye):f.removeAttribute("name")}function gt(f,g,w,E,j,L,te,ye){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(f.type=L),g!=null||w!=null){if(!(L!=="submit"&&L!=="reset"||g!=null)){sn(f);return}w=w!=null?""+Mn(w):"",g=g!=null?""+Mn(g):w,ye||g===f.value||(f.value=g),f.defaultValue=g}E=E??j,E=typeof E!="function"&&typeof E!="symbol"&&!!E,f.checked=ye?f.checked:!!E,f.defaultChecked=!!E,te!=null&&typeof te!="function"&&typeof te!="symbol"&&typeof te!="boolean"&&(f.name=te),sn(f)}function Rt(f,g,w){g==="number"&&mr(f.ownerDocument)===f||f.defaultValue===""+w||(f.defaultValue=""+w)}function on(f,g,w,E){if(f=f.options,g){g={};for(var j=0;j<w.length;j++)g["$"+w[j]]=!0;for(w=0;w<f.length;w++)j=g.hasOwnProperty("$"+f[w].value),f[w].selected!==j&&(f[w].selected=j),j&&E&&(f[w].defaultSelected=!0)}else{for(w=""+Mn(w),g=null,j=0;j<f.length;j++){if(f[j].value===w){f[j].selected=!0,E&&(f[j].defaultSelected=!0);return}g!==null||f[j].disabled||(g=f[j])}g!==null&&(g.selected=!0)}}function St(f,g,w){if(g!=null&&(g=""+Mn(g),g!==f.value&&(f.value=g),w==null)){f.defaultValue!==g&&(f.defaultValue=g);return}f.defaultValue=w!=null?""+Mn(w):""}function pn(f,g,w,E){if(g==null){if(E!=null){if(w!=null)throw Error(r(92));if($(E)){if(1<E.length)throw Error(r(93));E=E[0]}w=E}w==null&&(w=""),g=w}w=Mn(g),f.defaultValue=w,E=f.textContent,E===w&&E!==""&&E!==null&&(f.value=E),sn(f)}function rr(f,g){if(g){var w=f.firstChild;if(w&&w===f.lastChild&&w.nodeType===3){w.nodeValue=g;return}}f.textContent=g}var ir=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 gr(f,g,w){var E=g.indexOf("--")===0;w==null||typeof w=="boolean"||w===""?E?f.setProperty(g,""):g==="float"?f.cssFloat="":f[g]="":E?f.setProperty(g,w):typeof w!="number"||w===0||ir.has(g)?g==="float"?f.cssFloat=w:f[g]=(""+w).trim():f[g]=w+"px"}function ei(f,g,w){if(g!=null&&typeof g!="object")throw Error(r(62));if(f=f.style,w!=null){for(var E in w)!w.hasOwnProperty(E)||g!=null&&g.hasOwnProperty(E)||(E.indexOf("--")===0?f.setProperty(E,""):E==="float"?f.cssFloat="":f[E]="");for(var j in g)E=g[j],g.hasOwnProperty(j)&&w[j]!==E&&gr(f,j,E)}else for(var L in g)g.hasOwnProperty(L)&&gr(f,L,g[L])}function Zt(f){if(f.indexOf("-")===-1)return!1;switch(f){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 Sn=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"]]),ha=/^[\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 us(f){return ha.test(""+f)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":f}function Ma(){}var Js=null;function yl(f){return f=f.target||f.srcElement||window,f.correspondingUseElement&&(f=f.correspondingUseElement),f.nodeType===3?f.parentNode:f}var Ci=null,ds=null;function Oc(f){var g=he(f);if(g&&(f=g.stateNode)){var w=f[Zn]||null;e:switch(f=g.stateNode,g.type){case"input":if(Bn(f,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name),g=w.name,w.type==="radio"&&g!=null){for(w=f;w.parentNode;)w=w.parentNode;for(w=w.querySelectorAll('input[name="'+Jn(""+g)+'"][type="radio"]'),g=0;g<w.length;g++){var E=w[g];if(E!==f&&E.form===f.form){var j=E[Zn]||null;if(!j)throw Error(r(90));Bn(E,j.value,j.defaultValue,j.defaultValue,j.checked,j.defaultChecked,j.type,j.name)}}for(g=0;g<w.length;g++)E=w[g],E.form===f.form&&Jt(E)}break e;case"textarea":St(f,w.value,w.defaultValue);break e;case"select":g=w.value,g!=null&&on(f,!!w.multiple,g,!1)}}}var $a=!1;function Ps(f,g,w){if($a)return f(g,w);$a=!0;try{var E=f(g);return E}finally{if($a=!1,(Ci!==null||ds!==null)&&(vw(),Ci&&(g=Ci,f=ds,ds=Ci=null,Oc(g),f)))for(g=0;g<f.length;g++)Oc(f[g])}}function Ea(f,g){var w=f.stateNode;if(w===null)return null;var E=w[Zn]||null;if(E===null)return null;w=E[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":(E=!E.disabled)||(f=f.type,E=!(f==="button"||f==="input"||f==="select"||f==="textarea")),f=!E;break e;default:f=!1}if(f)return null;if(w&&typeof w!="function")throw Error(r(231,g,typeof w));return w}var Sr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),eo=!1;if(Sr)try{var to={};Object.defineProperty(to,"passive",{get:function(){eo=!0}}),window.addEventListener("test",to,to),window.removeEventListener("test",to,to)}catch{eo=!1}var Gr=null,Wl=null,Vm=null;function Cv(){if(Vm)return Vm;var f,g=Wl,w=g.length,E,j="value"in Gr?Gr.value:Gr.textContent,L=j.length;for(f=0;f<w&&g[f]===j[f];f++);var te=w-f;for(E=1;E<=te&&g[w-E]===j[L-E];E++);return Vm=j.slice(f,1<E?1-E:void 0)}function Gm(f){var g=f.keyCode;return"charCode"in f?(f=f.charCode,f===0&&g===13&&(f=13)):f=g,f===10&&(f=13),32<=f||f===13?f:0}function qm(){return!0}function Pv(){return!1}function Va(f){function g(w,E,j,L,te){this._reactName=w,this._targetInst=j,this.type=E,this.nativeEvent=L,this.target=te,this.currentTarget=null;for(var ye in f)f.hasOwnProperty(ye)&&(w=f[ye],this[ye]=w?w(L):L[ye]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?qm:Pv,this.isPropagationStopped=Pv,this}return h(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=qm)},stopPropagation:function(){var w=this.nativeEvent;w&&(w.stopPropagation?w.stopPropagation():typeof w.cancelBubble!="unknown"&&(w.cancelBubble=!0),this.isPropagationStopped=qm)},persist:function(){},isPersistent:qm}),g}var vl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(f){return f.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Yh=Va(vl),Lc=h({},vl,{view:0,detail:0}),ld=Va(Lc),Qh,Zh,wl,Kl=h({},Lc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Kn,button:0,buttons:0,relatedTarget:function(f){return f.relatedTarget===void 0?f.fromElement===f.srcElement?f.toElement:f.fromElement:f.relatedTarget},movementX:function(f){return"movementX"in f?f.movementX:(f!==wl&&(wl&&f.type==="mousemove"?(Qh=f.screenX-wl.screenX,Zh=f.screenY-wl.screenY):Zh=Qh=0,wl=f),Qh)},movementY:function(f){return"movementY"in f?f.movementY:Zh}}),Jh=Va(Kl),jv=h({},Kl,{dataTransfer:0}),Dv=Va(jv),Rv=h({},Lc,{relatedTarget:0}),xn=Va(Rv),o2=h({},vl,{animationName:0,elapsedTime:0,pseudoElement:0}),Kb=Va(o2),Ov=h({},vl,{clipboardData:function(f){return"clipboardData"in f?f.clipboardData:window.clipboardData}}),Xb=Va(Ov),Lv=h({},vl,{data:0}),Fv=Va(Lv),Iv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ie={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"},kt={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function In(f){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(f):(f=kt[f])?!!g[f]:!1}function Kn(){return In}var jo=h({},Lc,{key:function(f){if(f.key){var g=Iv[f.key]||f.key;if(g!=="Unidentified")return g}return f.type==="keypress"?(f=Gm(f),f===13?"Enter":String.fromCharCode(f)):f.type==="keydown"||f.type==="keyup"?ie[f.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Kn,charCode:function(f){return f.type==="keypress"?Gm(f):0},keyCode:function(f){return f.type==="keydown"||f.type==="keyup"?f.keyCode:0},which:function(f){return f.type==="keypress"?Gm(f):f.type==="keydown"||f.type==="keyup"?f.keyCode:0}}),cd=Va(jo),hs=h({},Kl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ga=Va(hs),l2=h({},Lc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Kn}),jF=Va(l2),pie=h({},vl,{propertyName:0,elapsedTime:0,pseudoElement:0}),gie=Va(pie),bie=h({},Kl,{deltaX:function(f){return"deltaX"in f?f.deltaX:"wheelDeltaX"in f?-f.wheelDeltaX:0},deltaY:function(f){return"deltaY"in f?f.deltaY:"wheelDeltaY"in f?-f.wheelDeltaY:"wheelDelta"in f?-f.wheelDelta:0},deltaZ:0,deltaMode:0}),xie=Va(bie),yie=h({},vl,{newState:0,oldState:0}),vie=Va(yie),wie=[9,13,27,32],c2=Sr&&"CompositionEvent"in window,Yb=null;Sr&&"documentMode"in document&&(Yb=document.documentMode);var _ie=Sr&&"TextEvent"in window&&!Yb,DF=Sr&&(!c2||Yb&&8<Yb&&11>=Yb),RF=" ",OF=!1;function LF(f,g){switch(f){case"keyup":return wie.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function FF(f){return f=f.detail,typeof f=="object"&&"data"in f?f.data:null}var Wm=!1;function Sie(f,g){switch(f){case"compositionend":return FF(g);case"keypress":return g.which!==32?null:(OF=!0,RF);case"textInput":return f=g.data,f===RF&&OF?null:f;default:return null}}function Nie(f,g){if(Wm)return f==="compositionend"||!c2&&LF(f,g)?(f=Cv(),Vm=Wl=Gr=null,Wm=!1,f):null;switch(f){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 DF&&g.locale!=="ko"?null:g.data;default:return null}}var kie={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 IF(f){var g=f&&f.nodeName&&f.nodeName.toLowerCase();return g==="input"?!!kie[f.type]:g==="textarea"}function zF(f,g,w,E){Ci?ds?ds.push(E):ds=[E]:Ci=E,g=Ew(g,"onChange"),0<g.length&&(w=new Yh("onChange","change",null,w,E),f.push({event:w,listeners:g}))}var Qb=null,Zb=null;function Mie(f){wz(f,0)}function zv(f){var g=Ie(f);if(Jt(g))return f}function UF(f,g){if(f==="change")return g}var BF=!1;if(Sr){var u2;if(Sr){var d2="oninput"in document;if(!d2){var HF=document.createElement("div");HF.setAttribute("oninput","return;"),d2=typeof HF.oninput=="function"}u2=d2}else u2=!1;BF=u2&&(!document.documentMode||9<document.documentMode)}function $F(){Qb&&(Qb.detachEvent("onpropertychange",VF),Zb=Qb=null)}function VF(f){if(f.propertyName==="value"&&zv(Zb)){var g=[];zF(g,Zb,f,yl(f)),Ps(Mie,g)}}function Eie(f,g,w){f==="focusin"?($F(),Qb=g,Zb=w,Qb.attachEvent("onpropertychange",VF)):f==="focusout"&&$F()}function Tie(f){if(f==="selectionchange"||f==="keyup"||f==="keydown")return zv(Zb)}function Aie(f,g){if(f==="click")return zv(g)}function Cie(f,g){if(f==="input"||f==="change")return zv(g)}function Pie(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var no=typeof Object.is=="function"?Object.is:Pie;function Jb(f,g){if(no(f,g))return!0;if(typeof f!="object"||f===null||typeof g!="object"||g===null)return!1;var w=Object.keys(f),E=Object.keys(g);if(w.length!==E.length)return!1;for(E=0;E<w.length;E++){var j=w[E];if(!X.call(g,j)||!no(f[j],g[j]))return!1}return!0}function GF(f){for(;f&&f.firstChild;)f=f.firstChild;return f}function qF(f,g){var w=GF(f);f=0;for(var E;w;){if(w.nodeType===3){if(E=f+w.textContent.length,f<=g&&E>=g)return{node:w,offset:g-f};f=E}e:{for(;w;){if(w.nextSibling){w=w.nextSibling;break e}w=w.parentNode}w=void 0}w=GF(w)}}function WF(f,g){return f&&g?f===g?!0:f&&f.nodeType===3?!1:g&&g.nodeType===3?WF(f,g.parentNode):"contains"in f?f.contains(g):f.compareDocumentPosition?!!(f.compareDocumentPosition(g)&16):!1:!1}function KF(f){f=f!=null&&f.ownerDocument!=null&&f.ownerDocument.defaultView!=null?f.ownerDocument.defaultView:window;for(var g=mr(f.document);g instanceof f.HTMLIFrameElement;){try{var w=typeof g.contentWindow.location.href=="string"}catch{w=!1}if(w)f=g.contentWindow;else break;g=mr(f.document)}return g}function h2(f){var g=f&&f.nodeName&&f.nodeName.toLowerCase();return g&&(g==="input"&&(f.type==="text"||f.type==="search"||f.type==="tel"||f.type==="url"||f.type==="password")||g==="textarea"||f.contentEditable==="true")}var jie=Sr&&"documentMode"in document&&11>=document.documentMode,Km=null,f2=null,ex=null,m2=!1;function XF(f,g,w){var E=w.window===w?w.document:w.nodeType===9?w:w.ownerDocument;m2||Km==null||Km!==mr(E)||(E=Km,"selectionStart"in E&&h2(E)?E={start:E.selectionStart,end:E.selectionEnd}:(E=(E.ownerDocument&&E.ownerDocument.defaultView||window).getSelection(),E={anchorNode:E.anchorNode,anchorOffset:E.anchorOffset,focusNode:E.focusNode,focusOffset:E.focusOffset}),ex&&Jb(ex,E)||(ex=E,E=Ew(f2,"onSelect"),0<E.length&&(g=new Yh("onSelect","select",null,g,w),f.push({event:g,listeners:E}),g.target=Km)))}function ef(f,g){var w={};return w[f.toLowerCase()]=g.toLowerCase(),w["Webkit"+f]="webkit"+g,w["Moz"+f]="moz"+g,w}var Xm={animationend:ef("Animation","AnimationEnd"),animationiteration:ef("Animation","AnimationIteration"),animationstart:ef("Animation","AnimationStart"),transitionrun:ef("Transition","TransitionRun"),transitionstart:ef("Transition","TransitionStart"),transitioncancel:ef("Transition","TransitionCancel"),transitionend:ef("Transition","TransitionEnd")},p2={},YF={};Sr&&(YF=document.createElement("div").style,"AnimationEvent"in window||(delete Xm.animationend.animation,delete Xm.animationiteration.animation,delete Xm.animationstart.animation),"TransitionEvent"in window||delete Xm.transitionend.transition);function tf(f){if(p2[f])return p2[f];if(!Xm[f])return f;var g=Xm[f],w;for(w in g)if(g.hasOwnProperty(w)&&w in YF)return p2[f]=g[w];return f}var QF=tf("animationend"),ZF=tf("animationiteration"),JF=tf("animationstart"),Die=tf("transitionrun"),Rie=tf("transitionstart"),Oie=tf("transitioncancel"),eI=tf("transitionend"),tI=new Map,g2="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(" ");g2.push("scrollEnd");function _l(f,g){tI.set(f,g),ut(g,[f])}var Uv=typeof reportError=="function"?reportError:function(f){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof f=="object"&&f!==null&&typeof f.message=="string"?String(f.message):String(f),error:f});if(!window.dispatchEvent(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",f);return}console.error(f)},Do=[],Ym=0,b2=0;function Bv(){for(var f=Ym,g=b2=Ym=0;g<f;){var w=Do[g];Do[g++]=null;var E=Do[g];Do[g++]=null;var j=Do[g];Do[g++]=null;var L=Do[g];if(Do[g++]=null,E!==null&&j!==null){var te=E.pending;te===null?j.next=j:(j.next=te.next,te.next=j),E.pending=j}L!==0&&nI(w,j,L)}}function Hv(f,g,w,E){Do[Ym++]=f,Do[Ym++]=g,Do[Ym++]=w,Do[Ym++]=E,b2|=E,f.lanes|=E,f=f.alternate,f!==null&&(f.lanes|=E)}function x2(f,g,w,E){return Hv(f,g,w,E),$v(f)}function nf(f,g){return Hv(f,null,null,g),$v(f)}function nI(f,g,w){f.lanes|=w;var E=f.alternate;E!==null&&(E.lanes|=w);for(var j=!1,L=f.return;L!==null;)L.childLanes|=w,E=L.alternate,E!==null&&(E.childLanes|=w),L.tag===22&&(f=L.stateNode,f===null||f._visibility&1||(j=!0)),f=L,L=L.return;return f.tag===3?(L=f.stateNode,j&&g!==null&&(j=31-ze(w),f=L.hiddenUpdates,E=f[j],E===null?f[j]=[g]:E.push(g),g.lane=w|536870912),L):null}function $v(f){if(50<_x)throw _x=0,EE=null,Error(r(185));for(var g=f.return;g!==null;)f=g,g=f.return;return f.tag===3?f.stateNode:null}var Qm={};function Lie(f,g,w,E){this.tag=f,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=E,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ro(f,g,w,E){return new Lie(f,g,w,E)}function y2(f){return f=f.prototype,!(!f||!f.isReactComponent)}function Fc(f,g){var w=f.alternate;return w===null?(w=ro(f.tag,g,f.key,f.mode),w.elementType=f.elementType,w.type=f.type,w.stateNode=f.stateNode,w.alternate=f,f.alternate=w):(w.pendingProps=g,w.type=f.type,w.flags=0,w.subtreeFlags=0,w.deletions=null),w.flags=f.flags&65011712,w.childLanes=f.childLanes,w.lanes=f.lanes,w.child=f.child,w.memoizedProps=f.memoizedProps,w.memoizedState=f.memoizedState,w.updateQueue=f.updateQueue,g=f.dependencies,w.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},w.sibling=f.sibling,w.index=f.index,w.ref=f.ref,w.refCleanup=f.refCleanup,w}function rI(f,g){f.flags&=65011714;var w=f.alternate;return w===null?(f.childLanes=0,f.lanes=g,f.child=null,f.subtreeFlags=0,f.memoizedProps=null,f.memoizedState=null,f.updateQueue=null,f.dependencies=null,f.stateNode=null):(f.childLanes=w.childLanes,f.lanes=w.lanes,f.child=w.child,f.subtreeFlags=0,f.deletions=null,f.memoizedProps=w.memoizedProps,f.memoizedState=w.memoizedState,f.updateQueue=w.updateQueue,f.type=w.type,g=w.dependencies,f.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),f}function Vv(f,g,w,E,j,L){var te=0;if(E=f,typeof f=="function")y2(f)&&(te=1);else if(typeof f=="string")te=Bae(f,w,ne.current)?26:f==="html"||f==="head"||f==="body"?27:5;else e:switch(f){case C:return f=ro(31,w,g,j),f.elementType=C,f.lanes=L,f;case y:return rf(w.children,j,L,g);case x:te=8,j|=24;break;case v:return f=ro(12,w,g,j|2),f.elementType=v,f.lanes=L,f;case M:return f=ro(13,w,g,j),f.elementType=M,f.lanes=L,f;case A:return f=ro(19,w,g,j),f.elementType=A,f.lanes=L,f;default:if(typeof f=="object"&&f!==null)switch(f.$$typeof){case N:te=10;break e;case S:te=9;break e;case T:te=11;break e;case k:te=14;break e;case R:te=16,E=null;break e}te=29,w=Error(r(130,f===null?"null":typeof f,"")),E=null}return g=ro(te,w,g,j),g.elementType=f,g.type=E,g.lanes=L,g}function rf(f,g,w,E){return f=ro(7,f,E,g),f.lanes=w,f}function v2(f,g,w){return f=ro(6,f,null,g),f.lanes=w,f}function iI(f){var g=ro(18,null,null,0);return g.stateNode=f,g}function w2(f,g,w){return g=ro(4,f.children!==null?f.children:[],f.key,g),g.lanes=w,g.stateNode={containerInfo:f.containerInfo,pendingChildren:null,implementation:f.implementation},g}var aI=new WeakMap;function Ro(f,g){if(typeof f=="object"&&f!==null){var w=aI.get(f);return w!==void 0?w:(g={value:f,source:g,stack:re(g)},aI.set(f,g),g)}return{value:f,source:g,stack:re(g)}}var Zm=[],Jm=0,Gv=null,tx=0,Oo=[],Lo=0,ud=null,Xl=1,Yl="";function Ic(f,g){Zm[Jm++]=tx,Zm[Jm++]=Gv,Gv=f,tx=g}function sI(f,g,w){Oo[Lo++]=Xl,Oo[Lo++]=Yl,Oo[Lo++]=ud,ud=f;var E=Xl;f=Yl;var j=32-ze(E)-1;E&=~(1<<j),w+=1;var L=32-ze(g)+j;if(30<L){var te=j-j%5;L=(E&(1<<te)-1).toString(32),E>>=te,j-=te,Xl=1<<32-ze(g)+j|w<<j|E,Yl=L+f}else Xl=1<<L|w<<j|E,Yl=f}function _2(f){f.return!==null&&(Ic(f,1),sI(f,1,0))}function S2(f){for(;f===Gv;)Gv=Zm[--Jm],Zm[Jm]=null,tx=Zm[--Jm],Zm[Jm]=null;for(;f===ud;)ud=Oo[--Lo],Oo[Lo]=null,Yl=Oo[--Lo],Oo[Lo]=null,Xl=Oo[--Lo],Oo[Lo]=null}function oI(f,g){Oo[Lo++]=Xl,Oo[Lo++]=Yl,Oo[Lo++]=ud,Xl=g.id,Yl=g.overflow,ud=f}var Ta=null,qr=null,Xn=!1,dd=null,Fo=!1,N2=Error(r(519));function hd(f){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw nx(Ro(g,f)),N2}function lI(f){var g=f.stateNode,w=f.type,E=f.memoizedProps;switch(g[Xt]=f,g[Zn]=E,w){case"dialog":$n("cancel",g),$n("close",g);break;case"iframe":case"object":case"embed":$n("load",g);break;case"video":case"audio":for(w=0;w<Nx.length;w++)$n(Nx[w],g);break;case"source":$n("error",g);break;case"img":case"image":case"link":$n("error",g),$n("load",g);break;case"details":$n("toggle",g);break;case"input":$n("invalid",g),gt(g,E.value,E.defaultValue,E.checked,E.defaultChecked,E.type,E.name,!0);break;case"select":$n("invalid",g);break;case"textarea":$n("invalid",g),pn(g,E.value,E.defaultValue,E.children)}w=E.children,typeof w!="string"&&typeof w!="number"&&typeof w!="bigint"||g.textContent===""+w||E.suppressHydrationWarning===!0||kz(g.textContent,w)?(E.popover!=null&&($n("beforetoggle",g),$n("toggle",g)),E.onScroll!=null&&$n("scroll",g),E.onScrollEnd!=null&&$n("scrollend",g),E.onClick!=null&&(g.onclick=Ma),g=!0):g=!1,g||hd(f,!0)}function cI(f){for(Ta=f.return;Ta;)switch(Ta.tag){case 5:case 31:case 13:Fo=!1;return;case 27:case 3:Fo=!0;return;default:Ta=Ta.return}}function ep(f){if(f!==Ta)return!1;if(!Xn)return cI(f),Xn=!0,!1;var g=f.tag,w;if((w=g!==3&&g!==27)&&((w=g===5)&&(w=f.type,w=!(w!=="form"&&w!=="button")||HE(f.type,f.memoizedProps)),w=!w),w&&qr&&hd(f),cI(f),g===13){if(f=f.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));qr=Rz(f)}else if(g===31){if(f=f.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));qr=Rz(f)}else g===27?(g=qr,Md(f.type)?(f=WE,WE=null,qr=f):qr=g):qr=Ta?zo(f.stateNode.nextSibling):null;return!0}function af(){qr=Ta=null,Xn=!1}function k2(){var f=dd;return f!==null&&(Os===null?Os=f:Os.push.apply(Os,f),dd=null),f}function nx(f){dd===null?dd=[f]:dd.push(f)}var M2=H(null),sf=null,zc=null;function fd(f,g,w){J(M2,g._currentValue),g._currentValue=w}function Uc(f){f._currentValue=M2.current,W(M2)}function E2(f,g,w){for(;f!==null;){var E=f.alternate;if((f.childLanes&g)!==g?(f.childLanes|=g,E!==null&&(E.childLanes|=g)):E!==null&&(E.childLanes&g)!==g&&(E.childLanes|=g),f===w)break;f=f.return}}function T2(f,g,w,E){var j=f.child;for(j!==null&&(j.return=f);j!==null;){var L=j.dependencies;if(L!==null){var te=j.child;L=L.firstContext;e:for(;L!==null;){var ye=L;L=j;for(var Be=0;Be<g.length;Be++)if(ye.context===g[Be]){L.lanes|=w,ye=L.alternate,ye!==null&&(ye.lanes|=w),E2(L.return,w,f),E||(te=null);break e}L=ye.next}}else if(j.tag===18){if(te=j.return,te===null)throw Error(r(341));te.lanes|=w,L=te.alternate,L!==null&&(L.lanes|=w),E2(te,w,f),te=null}else te=j.child;if(te!==null)te.return=j;else for(te=j;te!==null;){if(te===f){te=null;break}if(j=te.sibling,j!==null){j.return=te.return,te=j;break}te=te.return}j=te}}function tp(f,g,w,E){f=null;for(var j=g,L=!1;j!==null;){if(!L){if((j.flags&524288)!==0)L=!0;else if((j.flags&262144)!==0)break}if(j.tag===10){var te=j.alternate;if(te===null)throw Error(r(387));if(te=te.memoizedProps,te!==null){var ye=j.type;no(j.pendingProps.value,te.value)||(f!==null?f.push(ye):f=[ye])}}else if(j===fe.current){if(te=j.alternate,te===null)throw Error(r(387));te.memoizedState.memoizedState!==j.memoizedState.memoizedState&&(f!==null?f.push(Ax):f=[Ax])}j=j.return}f!==null&&T2(g,f,w,E),g.flags|=262144}function qv(f){for(f=f.firstContext;f!==null;){if(!no(f.context._currentValue,f.memoizedValue))return!0;f=f.next}return!1}function of(f){sf=f,zc=null,f=f.dependencies,f!==null&&(f.firstContext=null)}function Aa(f){return uI(sf,f)}function Wv(f,g){return sf===null&&of(f),uI(f,g)}function uI(f,g){var w=g._currentValue;if(g={context:g,memoizedValue:w,next:null},zc===null){if(f===null)throw Error(r(308));zc=g,f.dependencies={lanes:0,firstContext:g},f.flags|=524288}else zc=zc.next=g;return w}var Fie=typeof AbortController<"u"?AbortController:function(){var f=[],g=this.signal={aborted:!1,addEventListener:function(w,E){f.push(E)}};this.abort=function(){g.aborted=!0,f.forEach(function(w){return w()})}},Iie=t.unstable_scheduleCallback,zie=t.unstable_NormalPriority,Pi={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function A2(){return{controller:new Fie,data:new Map,refCount:0}}function rx(f){f.refCount--,f.refCount===0&&Iie(zie,function(){f.controller.abort()})}var ix=null,C2=0,np=0,rp=null;function Uie(f,g){if(ix===null){var w=ix=[];C2=0,np=DE(),rp={status:"pending",value:void 0,then:function(E){w.push(E)}}}return C2++,g.then(dI,dI),g}function dI(){if(--C2===0&&ix!==null){rp!==null&&(rp.status="fulfilled");var f=ix;ix=null,np=0,rp=null;for(var g=0;g<f.length;g++)(0,f[g])()}}function Bie(f,g){var w=[],E={status:"pending",value:null,reason:null,then:function(j){w.push(j)}};return f.then(function(){E.status="fulfilled",E.value=g;for(var j=0;j<w.length;j++)(0,w[j])(g)},function(j){for(E.status="rejected",E.reason=j,j=0;j<w.length;j++)(0,w[j])(void 0)}),E}var hI=G.S;G.S=function(f,g){X5=O(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&Uie(f,g),hI!==null&&hI(f,g)};var lf=H(null);function P2(){var f=lf.current;return f!==null?f:Fr.pooledCache}function Kv(f,g){g===null?J(lf,lf.current):J(lf,g.pool)}function fI(){var f=P2();return f===null?null:{parent:Pi._currentValue,pool:f}}var ip=Error(r(460)),j2=Error(r(474)),Xv=Error(r(542)),Yv={then:function(){}};function mI(f){return f=f.status,f==="fulfilled"||f==="rejected"}function pI(f,g,w){switch(w=f[w],w===void 0?f.push(g):w!==g&&(g.then(Ma,Ma),g=w),g.status){case"fulfilled":return g.value;case"rejected":throw f=g.reason,bI(f),f;default:if(typeof g.status=="string")g.then(Ma,Ma);else{if(f=Fr,f!==null&&100<f.shellSuspendCounter)throw Error(r(482));f=g,f.status="pending",f.then(function(E){if(g.status==="pending"){var j=g;j.status="fulfilled",j.value=E}},function(E){if(g.status==="pending"){var j=g;j.status="rejected",j.reason=E}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw f=g.reason,bI(f),f}throw uf=g,ip}}function cf(f){try{var g=f._init;return g(f._payload)}catch(w){throw w!==null&&typeof w=="object"&&typeof w.then=="function"?(uf=w,ip):w}}var uf=null;function gI(){if(uf===null)throw Error(r(459));var f=uf;return uf=null,f}function bI(f){if(f===ip||f===Xv)throw Error(r(483))}var ap=null,ax=0;function Qv(f){var g=ax;return ax+=1,ap===null&&(ap=[]),pI(ap,f,g)}function sx(f,g){g=g.props.ref,f.ref=g!==void 0?g:null}function Zv(f,g){throw g.$$typeof===p?Error(r(525)):(f=Object.prototype.toString.call(g),Error(r(31,f==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":f)))}function xI(f){function g(et,We){if(f){var ot=et.deletions;ot===null?(et.deletions=[We],et.flags|=16):ot.push(We)}}function w(et,We){if(!f)return null;for(;We!==null;)g(et,We),We=We.sibling;return null}function E(et){for(var We=new Map;et!==null;)et.key!==null?We.set(et.key,et):We.set(et.index,et),et=et.sibling;return We}function j(et,We){return et=Fc(et,We),et.index=0,et.sibling=null,et}function L(et,We,ot){return et.index=ot,f?(ot=et.alternate,ot!==null?(ot=ot.index,ot<We?(et.flags|=67108866,We):ot):(et.flags|=67108866,We)):(et.flags|=1048576,We)}function te(et){return f&&et.alternate===null&&(et.flags|=67108866),et}function ye(et,We,ot,wt){return We===null||We.tag!==6?(We=v2(ot,et.mode,wt),We.return=et,We):(We=j(We,ot),We.return=et,We)}function Be(et,We,ot,wt){var en=ot.type;return en===y?vt(et,We,ot.props.children,wt,ot.key):We!==null&&(We.elementType===en||typeof en=="object"&&en!==null&&en.$$typeof===R&&cf(en)===We.type)?(We=j(We,ot.props),sx(We,ot),We.return=et,We):(We=Vv(ot.type,ot.key,ot.props,null,et.mode,wt),sx(We,ot),We.return=et,We)}function ct(et,We,ot,wt){return We===null||We.tag!==4||We.stateNode.containerInfo!==ot.containerInfo||We.stateNode.implementation!==ot.implementation?(We=w2(ot,et.mode,wt),We.return=et,We):(We=j(We,ot.children||[]),We.return=et,We)}function vt(et,We,ot,wt,en){return We===null||We.tag!==7?(We=rf(ot,et.mode,wt,en),We.return=et,We):(We=j(We,ot),We.return=et,We)}function Nt(et,We,ot){if(typeof We=="string"&&We!==""||typeof We=="number"||typeof We=="bigint")return We=v2(""+We,et.mode,ot),We.return=et,We;if(typeof We=="object"&&We!==null){switch(We.$$typeof){case m:return ot=Vv(We.type,We.key,We.props,null,et.mode,ot),sx(ot,We),ot.return=et,ot;case b:return We=w2(We,et.mode,ot),We.return=et,We;case R:return We=cf(We),Nt(et,We,ot)}if($(We)||F(We))return We=rf(We,et.mode,ot,null),We.return=et,We;if(typeof We.then=="function")return Nt(et,Qv(We),ot);if(We.$$typeof===N)return Nt(et,Wv(et,We),ot);Zv(et,We)}return null}function ft(et,We,ot,wt){var en=We!==null?We.key:null;if(typeof ot=="string"&&ot!==""||typeof ot=="number"||typeof ot=="bigint")return en!==null?null:ye(et,We,""+ot,wt);if(typeof ot=="object"&&ot!==null){switch(ot.$$typeof){case m:return ot.key===en?Be(et,We,ot,wt):null;case b:return ot.key===en?ct(et,We,ot,wt):null;case R:return ot=cf(ot),ft(et,We,ot,wt)}if($(ot)||F(ot))return en!==null?null:vt(et,We,ot,wt,null);if(typeof ot.then=="function")return ft(et,We,Qv(ot),wt);if(ot.$$typeof===N)return ft(et,We,Wv(et,ot),wt);Zv(et,ot)}return null}function bt(et,We,ot,wt,en){if(typeof wt=="string"&&wt!==""||typeof wt=="number"||typeof wt=="bigint")return et=et.get(ot)||null,ye(We,et,""+wt,en);if(typeof wt=="object"&&wt!==null){switch(wt.$$typeof){case m:return et=et.get(wt.key===null?ot:wt.key)||null,Be(We,et,wt,en);case b:return et=et.get(wt.key===null?ot:wt.key)||null,ct(We,et,wt,en);case R:return wt=cf(wt),bt(et,We,ot,wt,en)}if($(wt)||F(wt))return et=et.get(ot)||null,vt(We,et,wt,en,null);if(typeof wt.then=="function")return bt(et,We,ot,Qv(wt),en);if(wt.$$typeof===N)return bt(et,We,ot,Wv(We,wt),en);Zv(We,wt)}return null}function Gt(et,We,ot,wt){for(var en=null,ar=null,Kt=We,An=We=0,Wn=null;Kt!==null&&An<ot.length;An++){Kt.index>An?(Wn=Kt,Kt=null):Wn=Kt.sibling;var sr=ft(et,Kt,ot[An],wt);if(sr===null){Kt===null&&(Kt=Wn);break}f&&Kt&&sr.alternate===null&&g(et,Kt),We=L(sr,We,An),ar===null?en=sr:ar.sibling=sr,ar=sr,Kt=Wn}if(An===ot.length)return w(et,Kt),Xn&&Ic(et,An),en;if(Kt===null){for(;An<ot.length;An++)Kt=Nt(et,ot[An],wt),Kt!==null&&(We=L(Kt,We,An),ar===null?en=Kt:ar.sibling=Kt,ar=Kt);return Xn&&Ic(et,An),en}for(Kt=E(Kt);An<ot.length;An++)Wn=bt(Kt,et,An,ot[An],wt),Wn!==null&&(f&&Wn.alternate!==null&&Kt.delete(Wn.key===null?An:Wn.key),We=L(Wn,We,An),ar===null?en=Wn:ar.sibling=Wn,ar=Wn);return f&&Kt.forEach(function(Pd){return g(et,Pd)}),Xn&&Ic(et,An),en}function mn(et,We,ot,wt){if(ot==null)throw Error(r(151));for(var en=null,ar=null,Kt=We,An=We=0,Wn=null,sr=ot.next();Kt!==null&&!sr.done;An++,sr=ot.next()){Kt.index>An?(Wn=Kt,Kt=null):Wn=Kt.sibling;var Pd=ft(et,Kt,sr.value,wt);if(Pd===null){Kt===null&&(Kt=Wn);break}f&&Kt&&Pd.alternate===null&&g(et,Kt),We=L(Pd,We,An),ar===null?en=Pd:ar.sibling=Pd,ar=Pd,Kt=Wn}if(sr.done)return w(et,Kt),Xn&&Ic(et,An),en;if(Kt===null){for(;!sr.done;An++,sr=ot.next())sr=Nt(et,sr.value,wt),sr!==null&&(We=L(sr,We,An),ar===null?en=sr:ar.sibling=sr,ar=sr);return Xn&&Ic(et,An),en}for(Kt=E(Kt);!sr.done;An++,sr=ot.next())sr=bt(Kt,et,An,sr.value,wt),sr!==null&&(f&&sr.alternate!==null&&Kt.delete(sr.key===null?An:sr.key),We=L(sr,We,An),ar===null?en=sr:ar.sibling=sr,ar=sr);return f&&Kt.forEach(function(Zae){return g(et,Zae)}),Xn&&Ic(et,An),en}function Mr(et,We,ot,wt){if(typeof ot=="object"&&ot!==null&&ot.type===y&&ot.key===null&&(ot=ot.props.children),typeof ot=="object"&&ot!==null){switch(ot.$$typeof){case m:e:{for(var en=ot.key;We!==null;){if(We.key===en){if(en=ot.type,en===y){if(We.tag===7){w(et,We.sibling),wt=j(We,ot.props.children),wt.return=et,et=wt;break e}}else if(We.elementType===en||typeof en=="object"&&en!==null&&en.$$typeof===R&&cf(en)===We.type){w(et,We.sibling),wt=j(We,ot.props),sx(wt,ot),wt.return=et,et=wt;break e}w(et,We);break}else g(et,We);We=We.sibling}ot.type===y?(wt=rf(ot.props.children,et.mode,wt,ot.key),wt.return=et,et=wt):(wt=Vv(ot.type,ot.key,ot.props,null,et.mode,wt),sx(wt,ot),wt.return=et,et=wt)}return te(et);case b:e:{for(en=ot.key;We!==null;){if(We.key===en)if(We.tag===4&&We.stateNode.containerInfo===ot.containerInfo&&We.stateNode.implementation===ot.implementation){w(et,We.sibling),wt=j(We,ot.children||[]),wt.return=et,et=wt;break e}else{w(et,We);break}else g(et,We);We=We.sibling}wt=w2(ot,et.mode,wt),wt.return=et,et=wt}return te(et);case R:return ot=cf(ot),Mr(et,We,ot,wt)}if($(ot))return Gt(et,We,ot,wt);if(F(ot)){if(en=F(ot),typeof en!="function")throw Error(r(150));return ot=en.call(ot),mn(et,We,ot,wt)}if(typeof ot.then=="function")return Mr(et,We,Qv(ot),wt);if(ot.$$typeof===N)return Mr(et,We,Wv(et,ot),wt);Zv(et,ot)}return typeof ot=="string"&&ot!==""||typeof ot=="number"||typeof ot=="bigint"?(ot=""+ot,We!==null&&We.tag===6?(w(et,We.sibling),wt=j(We,ot),wt.return=et,et=wt):(w(et,We),wt=v2(ot,et.mode,wt),wt.return=et,et=wt),te(et)):w(et,We)}return function(et,We,ot,wt){try{ax=0;var en=Mr(et,We,ot,wt);return ap=null,en}catch(Kt){if(Kt===ip||Kt===Xv)throw Kt;var ar=ro(29,Kt,null,et.mode);return ar.lanes=wt,ar.return=et,ar}finally{}}}var df=xI(!0),yI=xI(!1),md=!1;function D2(f){f.updateQueue={baseState:f.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function R2(f,g){f=f.updateQueue,g.updateQueue===f&&(g.updateQueue={baseState:f.baseState,firstBaseUpdate:f.firstBaseUpdate,lastBaseUpdate:f.lastBaseUpdate,shared:f.shared,callbacks:null})}function pd(f){return{lane:f,tag:0,payload:null,callback:null,next:null}}function gd(f,g,w){var E=f.updateQueue;if(E===null)return null;if(E=E.shared,(dr&2)!==0){var j=E.pending;return j===null?g.next=g:(g.next=j.next,j.next=g),E.pending=g,g=$v(f),nI(f,null,w),g}return Hv(f,E,g,w),$v(f)}function ox(f,g,w){if(g=g.updateQueue,g!==null&&(g=g.shared,(w&4194048)!==0)){var E=g.lanes;E&=f.pendingLanes,w|=E,g.lanes=w,yt(f,w)}}function O2(f,g){var w=f.updateQueue,E=f.alternate;if(E!==null&&(E=E.updateQueue,w===E)){var j=null,L=null;if(w=w.firstBaseUpdate,w!==null){do{var te={lane:w.lane,tag:w.tag,payload:w.payload,callback:null,next:null};L===null?j=L=te:L=L.next=te,w=w.next}while(w!==null);L===null?j=L=g:L=L.next=g}else j=L=g;w={baseState:E.baseState,firstBaseUpdate:j,lastBaseUpdate:L,shared:E.shared,callbacks:E.callbacks},f.updateQueue=w;return}f=w.lastBaseUpdate,f===null?w.firstBaseUpdate=g:f.next=g,w.lastBaseUpdate=g}var L2=!1;function lx(){if(L2){var f=rp;if(f!==null)throw f}}function cx(f,g,w,E){L2=!1;var j=f.updateQueue;md=!1;var L=j.firstBaseUpdate,te=j.lastBaseUpdate,ye=j.shared.pending;if(ye!==null){j.shared.pending=null;var Be=ye,ct=Be.next;Be.next=null,te===null?L=ct:te.next=ct,te=Be;var vt=f.alternate;vt!==null&&(vt=vt.updateQueue,ye=vt.lastBaseUpdate,ye!==te&&(ye===null?vt.firstBaseUpdate=ct:ye.next=ct,vt.lastBaseUpdate=Be))}if(L!==null){var Nt=j.baseState;te=0,vt=ct=Be=null,ye=L;do{var ft=ye.lane&-536870913,bt=ft!==ye.lane;if(bt?(qn&ft)===ft:(E&ft)===ft){ft!==0&&ft===np&&(L2=!0),vt!==null&&(vt=vt.next={lane:0,tag:ye.tag,payload:ye.payload,callback:null,next:null});e:{var Gt=f,mn=ye;ft=g;var Mr=w;switch(mn.tag){case 1:if(Gt=mn.payload,typeof Gt=="function"){Nt=Gt.call(Mr,Nt,ft);break e}Nt=Gt;break e;case 3:Gt.flags=Gt.flags&-65537|128;case 0:if(Gt=mn.payload,ft=typeof Gt=="function"?Gt.call(Mr,Nt,ft):Gt,ft==null)break e;Nt=h({},Nt,ft);break e;case 2:md=!0}}ft=ye.callback,ft!==null&&(f.flags|=64,bt&&(f.flags|=8192),bt=j.callbacks,bt===null?j.callbacks=[ft]:bt.push(ft))}else bt={lane:ft,tag:ye.tag,payload:ye.payload,callback:ye.callback,next:null},vt===null?(ct=vt=bt,Be=Nt):vt=vt.next=bt,te|=ft;if(ye=ye.next,ye===null){if(ye=j.shared.pending,ye===null)break;bt=ye,ye=bt.next,bt.next=null,j.lastBaseUpdate=bt,j.shared.pending=null}}while(!0);vt===null&&(Be=Nt),j.baseState=Be,j.firstBaseUpdate=ct,j.lastBaseUpdate=vt,L===null&&(j.shared.lanes=0),wd|=te,f.lanes=te,f.memoizedState=Nt}}function vI(f,g){if(typeof f!="function")throw Error(r(191,f));f.call(g)}function wI(f,g){var w=f.callbacks;if(w!==null)for(f.callbacks=null,f=0;f<w.length;f++)vI(w[f],g)}var sp=H(null),Jv=H(0);function _I(f,g){f=Xc,J(Jv,f),J(sp,g),Xc=f|g.baseLanes}function F2(){J(Jv,Xc),J(sp,sp.current)}function I2(){Xc=Jv.current,W(sp),W(Jv)}var io=H(null),Io=null;function bd(f){var g=f.alternate;J(Ni,Ni.current&1),J(io,f),Io===null&&(g===null||sp.current!==null||g.memoizedState!==null)&&(Io=f)}function z2(f){J(Ni,Ni.current),J(io,f),Io===null&&(Io=f)}function SI(f){f.tag===22?(J(Ni,Ni.current),J(io,f),Io===null&&(Io=f)):xd()}function xd(){J(Ni,Ni.current),J(io,io.current)}function ao(f){W(io),Io===f&&(Io=null),W(Ni)}var Ni=H(0);function ew(f){for(var g=f;g!==null;){if(g.tag===13){var w=g.memoizedState;if(w!==null&&(w=w.dehydrated,w===null||GE(w)||qE(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===f)break;for(;g.sibling===null;){if(g.return===null||g.return===f)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var Bc=0,Tn=null,Nr=null,ji=null,tw=!1,op=!1,hf=!1,nw=0,ux=0,lp=null,Hie=0;function fi(){throw Error(r(321))}function U2(f,g){if(g===null)return!1;for(var w=0;w<g.length&&w<f.length;w++)if(!no(f[w],g[w]))return!1;return!0}function B2(f,g,w,E,j,L){return Bc=L,Tn=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,G.H=f===null||f.memoizedState===null?s5:nE,hf=!1,L=w(E,j),hf=!1,op&&(L=kI(g,w,E,j)),NI(f),L}function NI(f){G.H=fx;var g=Nr!==null&&Nr.next!==null;if(Bc=0,ji=Nr=Tn=null,tw=!1,ux=0,lp=null,g)throw Error(r(300));f===null||Di||(f=f.dependencies,f!==null&&qv(f)&&(Di=!0))}function kI(f,g,w,E){Tn=f;var j=0;do{if(op&&(lp=null),ux=0,op=!1,25<=j)throw Error(r(301));if(j+=1,ji=Nr=null,f.updateQueue!=null){var L=f.updateQueue;L.lastEffect=null,L.events=null,L.stores=null,L.memoCache!=null&&(L.memoCache.index=0)}G.H=o5,L=g(w,E)}while(op);return L}function $ie(){var f=G.H,g=f.useState()[0];return g=typeof g.then=="function"?dx(g):g,f=f.useState()[0],(Nr!==null?Nr.memoizedState:null)!==f&&(Tn.flags|=1024),g}function H2(){var f=nw!==0;return nw=0,f}function $2(f,g,w){g.updateQueue=f.updateQueue,g.flags&=-2053,f.lanes&=~w}function V2(f){if(tw){for(f=f.memoizedState;f!==null;){var g=f.queue;g!==null&&(g.pending=null),f=f.next}tw=!1}Bc=0,ji=Nr=Tn=null,op=!1,ux=nw=0,lp=null}function fs(){var f={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ji===null?Tn.memoizedState=ji=f:ji=ji.next=f,ji}function ki(){if(Nr===null){var f=Tn.alternate;f=f!==null?f.memoizedState:null}else f=Nr.next;var g=ji===null?Tn.memoizedState:ji.next;if(g!==null)ji=g,Nr=f;else{if(f===null)throw Tn.alternate===null?Error(r(467)):Error(r(310));Nr=f,f={memoizedState:Nr.memoizedState,baseState:Nr.baseState,baseQueue:Nr.baseQueue,queue:Nr.queue,next:null},ji===null?Tn.memoizedState=ji=f:ji=ji.next=f}return ji}function rw(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function dx(f){var g=ux;return ux+=1,lp===null&&(lp=[]),f=pI(lp,f,g),g=Tn,(ji===null?g.memoizedState:ji.next)===null&&(g=g.alternate,G.H=g===null||g.memoizedState===null?s5:nE),f}function iw(f){if(f!==null&&typeof f=="object"){if(typeof f.then=="function")return dx(f);if(f.$$typeof===N)return Aa(f)}throw Error(r(438,String(f)))}function G2(f){var g=null,w=Tn.updateQueue;if(w!==null&&(g=w.memoCache),g==null){var E=Tn.alternate;E!==null&&(E=E.updateQueue,E!==null&&(E=E.memoCache,E!=null&&(g={data:E.data.map(function(j){return j.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),w===null&&(w=rw(),Tn.updateQueue=w),w.memoCache=g,w=g.data[g.index],w===void 0)for(w=g.data[g.index]=Array(f),E=0;E<f;E++)w[E]=P;return g.index++,w}function Hc(f,g){return typeof g=="function"?g(f):g}function aw(f){var g=ki();return q2(g,Nr,f)}function q2(f,g,w){var E=f.queue;if(E===null)throw Error(r(311));E.lastRenderedReducer=w;var j=f.baseQueue,L=E.pending;if(L!==null){if(j!==null){var te=j.next;j.next=L.next,L.next=te}g.baseQueue=j=L,E.pending=null}if(L=f.baseState,j===null)f.memoizedState=L;else{g=j.next;var ye=te=null,Be=null,ct=g,vt=!1;do{var Nt=ct.lane&-536870913;if(Nt!==ct.lane?(qn&Nt)===Nt:(Bc&Nt)===Nt){var ft=ct.revertLane;if(ft===0)Be!==null&&(Be=Be.next={lane:0,revertLane:0,gesture:null,action:ct.action,hasEagerState:ct.hasEagerState,eagerState:ct.eagerState,next:null}),Nt===np&&(vt=!0);else if((Bc&ft)===ft){ct=ct.next,ft===np&&(vt=!0);continue}else Nt={lane:0,revertLane:ct.revertLane,gesture:null,action:ct.action,hasEagerState:ct.hasEagerState,eagerState:ct.eagerState,next:null},Be===null?(ye=Be=Nt,te=L):Be=Be.next=Nt,Tn.lanes|=ft,wd|=ft;Nt=ct.action,hf&&w(L,Nt),L=ct.hasEagerState?ct.eagerState:w(L,Nt)}else ft={lane:Nt,revertLane:ct.revertLane,gesture:ct.gesture,action:ct.action,hasEagerState:ct.hasEagerState,eagerState:ct.eagerState,next:null},Be===null?(ye=Be=ft,te=L):Be=Be.next=ft,Tn.lanes|=Nt,wd|=Nt;ct=ct.next}while(ct!==null&&ct!==g);if(Be===null?te=L:Be.next=ye,!no(L,f.memoizedState)&&(Di=!0,vt&&(w=rp,w!==null)))throw w;f.memoizedState=L,f.baseState=te,f.baseQueue=Be,E.lastRenderedState=L}return j===null&&(E.lanes=0),[f.memoizedState,E.dispatch]}function W2(f){var g=ki(),w=g.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=f;var E=w.dispatch,j=w.pending,L=g.memoizedState;if(j!==null){w.pending=null;var te=j=j.next;do L=f(L,te.action),te=te.next;while(te!==j);no(L,g.memoizedState)||(Di=!0),g.memoizedState=L,g.baseQueue===null&&(g.baseState=L),w.lastRenderedState=L}return[L,E]}function MI(f,g,w){var E=Tn,j=ki(),L=Xn;if(L){if(w===void 0)throw Error(r(407));w=w()}else w=g();var te=!no((Nr||j).memoizedState,w);if(te&&(j.memoizedState=w,Di=!0),j=j.queue,Y2(AI.bind(null,E,j,f),[f]),j.getSnapshot!==g||te||ji!==null&&ji.memoizedState.tag&1){if(E.flags|=2048,cp(9,{destroy:void 0},TI.bind(null,E,j,w,g),null),Fr===null)throw Error(r(349));L||(Bc&127)!==0||EI(E,g,w)}return w}function EI(f,g,w){f.flags|=16384,f={getSnapshot:g,value:w},g=Tn.updateQueue,g===null?(g=rw(),Tn.updateQueue=g,g.stores=[f]):(w=g.stores,w===null?g.stores=[f]:w.push(f))}function TI(f,g,w,E){g.value=w,g.getSnapshot=E,CI(g)&&PI(f)}function AI(f,g,w){return w(function(){CI(g)&&PI(f)})}function CI(f){var g=f.getSnapshot;f=f.value;try{var w=g();return!no(f,w)}catch{return!0}}function PI(f){var g=nf(f,2);g!==null&&Ls(g,f,2)}function K2(f){var g=fs();if(typeof f=="function"){var w=f;if(f=w(),hf){ve(!0);try{w()}finally{ve(!1)}}}return g.memoizedState=g.baseState=f,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hc,lastRenderedState:f},g}function jI(f,g,w,E){return f.baseState=w,q2(f,Nr,typeof E=="function"?E:Hc)}function Vie(f,g,w,E,j){if(lw(f))throw Error(r(485));if(f=g.action,f!==null){var L={payload:j,action:f,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(te){L.listeners.push(te)}};G.T!==null?w(!0):L.isTransition=!1,E(L),w=g.pending,w===null?(L.next=g.pending=L,DI(g,L)):(L.next=w.next,g.pending=w.next=L)}}function DI(f,g){var w=g.action,E=g.payload,j=f.state;if(g.isTransition){var L=G.T,te={};G.T=te;try{var ye=w(j,E),Be=G.S;Be!==null&&Be(te,ye),RI(f,g,ye)}catch(ct){X2(f,g,ct)}finally{L!==null&&te.types!==null&&(L.types=te.types),G.T=L}}else try{L=w(j,E),RI(f,g,L)}catch(ct){X2(f,g,ct)}}function RI(f,g,w){w!==null&&typeof w=="object"&&typeof w.then=="function"?w.then(function(E){OI(f,g,E)},function(E){return X2(f,g,E)}):OI(f,g,w)}function OI(f,g,w){g.status="fulfilled",g.value=w,LI(g),f.state=w,g=f.pending,g!==null&&(w=g.next,w===g?f.pending=null:(w=w.next,g.next=w,DI(f,w)))}function X2(f,g,w){var E=f.pending;if(f.pending=null,E!==null){E=E.next;do g.status="rejected",g.reason=w,LI(g),g=g.next;while(g!==E)}f.action=null}function LI(f){f=f.listeners;for(var g=0;g<f.length;g++)(0,f[g])()}function FI(f,g){return g}function II(f,g){if(Xn){var w=Fr.formState;if(w!==null){e:{var E=Tn;if(Xn){if(qr){t:{for(var j=qr,L=Fo;j.nodeType!==8;){if(!L){j=null;break t}if(j=zo(j.nextSibling),j===null){j=null;break t}}L=j.data,j=L==="F!"||L==="F"?j:null}if(j){qr=zo(j.nextSibling),E=j.data==="F!";break e}}hd(E)}E=!1}E&&(g=w[0])}}return w=fs(),w.memoizedState=w.baseState=g,E={pending:null,lanes:0,dispatch:null,lastRenderedReducer:FI,lastRenderedState:g},w.queue=E,w=r5.bind(null,Tn,E),E.dispatch=w,E=K2(!1),L=tE.bind(null,Tn,!1,E.queue),E=fs(),j={state:g,dispatch:null,action:f,pending:null},E.queue=j,w=Vie.bind(null,Tn,j,L,w),j.dispatch=w,E.memoizedState=f,[g,w,!1]}function zI(f){var g=ki();return UI(g,Nr,f)}function UI(f,g,w){if(g=q2(f,g,FI)[0],f=aw(Hc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var E=dx(g)}catch(te){throw te===ip?Xv:te}else E=g;g=ki();var j=g.queue,L=j.dispatch;return w!==g.memoizedState&&(Tn.flags|=2048,cp(9,{destroy:void 0},Gie.bind(null,j,w),null)),[E,L,f]}function Gie(f,g){f.action=g}function BI(f){var g=ki(),w=Nr;if(w!==null)return UI(g,w,f);ki(),g=g.memoizedState,w=ki();var E=w.queue.dispatch;return w.memoizedState=f,[g,E,!1]}function cp(f,g,w,E){return f={tag:f,create:w,deps:E,inst:g,next:null},g=Tn.updateQueue,g===null&&(g=rw(),Tn.updateQueue=g),w=g.lastEffect,w===null?g.lastEffect=f.next=f:(E=w.next,w.next=f,f.next=E,g.lastEffect=f),f}function HI(){return ki().memoizedState}function sw(f,g,w,E){var j=fs();Tn.flags|=f,j.memoizedState=cp(1|g,{destroy:void 0},w,E===void 0?null:E)}function ow(f,g,w,E){var j=ki();E=E===void 0?null:E;var L=j.memoizedState.inst;Nr!==null&&E!==null&&U2(E,Nr.memoizedState.deps)?j.memoizedState=cp(g,L,w,E):(Tn.flags|=f,j.memoizedState=cp(1|g,L,w,E))}function $I(f,g){sw(8390656,8,f,g)}function Y2(f,g){ow(2048,8,f,g)}function qie(f){Tn.flags|=4;var g=Tn.updateQueue;if(g===null)g=rw(),Tn.updateQueue=g,g.events=[f];else{var w=g.events;w===null?g.events=[f]:w.push(f)}}function VI(f){var g=ki().memoizedState;return qie({ref:g,nextImpl:f}),function(){if((dr&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function GI(f,g){return ow(4,2,f,g)}function qI(f,g){return ow(4,4,f,g)}function WI(f,g){if(typeof g=="function"){f=f();var w=g(f);return function(){typeof w=="function"?w():g(null)}}if(g!=null)return f=f(),g.current=f,function(){g.current=null}}function KI(f,g,w){w=w!=null?w.concat([f]):null,ow(4,4,WI.bind(null,g,f),w)}function Q2(){}function XI(f,g){var w=ki();g=g===void 0?null:g;var E=w.memoizedState;return g!==null&&U2(g,E[1])?E[0]:(w.memoizedState=[f,g],f)}function YI(f,g){var w=ki();g=g===void 0?null:g;var E=w.memoizedState;if(g!==null&&U2(g,E[1]))return E[0];if(E=f(),hf){ve(!0);try{f()}finally{ve(!1)}}return w.memoizedState=[E,g],E}function Z2(f,g,w){return w===void 0||(Bc&1073741824)!==0&&(qn&261930)===0?f.memoizedState=g:(f.memoizedState=w,f=Q5(),Tn.lanes|=f,wd|=f,w)}function QI(f,g,w,E){return no(w,g)?w:sp.current!==null?(f=Z2(f,w,E),no(f,g)||(Di=!0),f):(Bc&42)===0||(Bc&1073741824)!==0&&(qn&261930)===0?(Di=!0,f.memoizedState=w):(f=Q5(),Tn.lanes|=f,wd|=f,g)}function ZI(f,g,w,E,j){var L=I.p;I.p=L!==0&&8>L?L:8;var te=G.T,ye={};G.T=ye,tE(f,!1,g,w);try{var Be=j(),ct=G.S;if(ct!==null&&ct(ye,Be),Be!==null&&typeof Be=="object"&&typeof Be.then=="function"){var vt=Bie(Be,E);hx(f,g,vt,lo(f))}else hx(f,g,E,lo(f))}catch(Nt){hx(f,g,{then:function(){},status:"rejected",reason:Nt},lo())}finally{I.p=L,te!==null&&ye.types!==null&&(te.types=ye.types),G.T=te}}function Wie(){}function J2(f,g,w,E){if(f.tag!==5)throw Error(r(476));var j=JI(f).queue;ZI(f,j,g,K,w===null?Wie:function(){return e5(f),w(E)})}function JI(f){var g=f.memoizedState;if(g!==null)return g;g={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hc,lastRenderedState:K},next:null};var w={};return g.next={memoizedState:w,baseState:w,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hc,lastRenderedState:w},next:null},f.memoizedState=g,f=f.alternate,f!==null&&(f.memoizedState=g),g}function e5(f){var g=JI(f);g.next===null&&(g=f.alternate.memoizedState),hx(f,g.next.queue,{},lo())}function eE(){return Aa(Ax)}function t5(){return ki().memoizedState}function n5(){return ki().memoizedState}function Kie(f){for(var g=f.return;g!==null;){switch(g.tag){case 24:case 3:var w=lo();f=pd(w);var E=gd(g,f,w);E!==null&&(Ls(E,g,w),ox(E,g,w)),g={cache:A2()},f.payload=g;return}g=g.return}}function Xie(f,g,w){var E=lo();w={lane:E,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},lw(f)?i5(g,w):(w=x2(f,g,w,E),w!==null&&(Ls(w,f,E),a5(w,g,E)))}function r5(f,g,w){var E=lo();hx(f,g,w,E)}function hx(f,g,w,E){var j={lane:E,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null};if(lw(f))i5(g,j);else{var L=f.alternate;if(f.lanes===0&&(L===null||L.lanes===0)&&(L=g.lastRenderedReducer,L!==null))try{var te=g.lastRenderedState,ye=L(te,w);if(j.hasEagerState=!0,j.eagerState=ye,no(ye,te))return Hv(f,g,j,0),Fr===null&&Bv(),!1}catch{}finally{}if(w=x2(f,g,j,E),w!==null)return Ls(w,f,E),a5(w,g,E),!0}return!1}function tE(f,g,w,E){if(E={lane:2,revertLane:DE(),gesture:null,action:E,hasEagerState:!1,eagerState:null,next:null},lw(f)){if(g)throw Error(r(479))}else g=x2(f,w,E,2),g!==null&&Ls(g,f,2)}function lw(f){var g=f.alternate;return f===Tn||g!==null&&g===Tn}function i5(f,g){op=tw=!0;var w=f.pending;w===null?g.next=g:(g.next=w.next,w.next=g),f.pending=g}function a5(f,g,w){if((w&4194048)!==0){var E=g.lanes;E&=f.pendingLanes,w|=E,g.lanes=w,yt(f,w)}}var fx={readContext:Aa,use:iw,useCallback:fi,useContext:fi,useEffect:fi,useImperativeHandle:fi,useLayoutEffect:fi,useInsertionEffect:fi,useMemo:fi,useReducer:fi,useRef:fi,useState:fi,useDebugValue:fi,useDeferredValue:fi,useTransition:fi,useSyncExternalStore:fi,useId:fi,useHostTransitionStatus:fi,useFormState:fi,useActionState:fi,useOptimistic:fi,useMemoCache:fi,useCacheRefresh:fi};fx.useEffectEvent=fi;var s5={readContext:Aa,use:iw,useCallback:function(f,g){return fs().memoizedState=[f,g===void 0?null:g],f},useContext:Aa,useEffect:$I,useImperativeHandle:function(f,g,w){w=w!=null?w.concat([f]):null,sw(4194308,4,WI.bind(null,g,f),w)},useLayoutEffect:function(f,g){return sw(4194308,4,f,g)},useInsertionEffect:function(f,g){sw(4,2,f,g)},useMemo:function(f,g){var w=fs();g=g===void 0?null:g;var E=f();if(hf){ve(!0);try{f()}finally{ve(!1)}}return w.memoizedState=[E,g],E},useReducer:function(f,g,w){var E=fs();if(w!==void 0){var j=w(g);if(hf){ve(!0);try{w(g)}finally{ve(!1)}}}else j=g;return E.memoizedState=E.baseState=j,f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:f,lastRenderedState:j},E.queue=f,f=f.dispatch=Xie.bind(null,Tn,f),[E.memoizedState,f]},useRef:function(f){var g=fs();return f={current:f},g.memoizedState=f},useState:function(f){f=K2(f);var g=f.queue,w=r5.bind(null,Tn,g);return g.dispatch=w,[f.memoizedState,w]},useDebugValue:Q2,useDeferredValue:function(f,g){var w=fs();return Z2(w,f,g)},useTransition:function(){var f=K2(!1);return f=ZI.bind(null,Tn,f.queue,!0,!1),fs().memoizedState=f,[!1,f]},useSyncExternalStore:function(f,g,w){var E=Tn,j=fs();if(Xn){if(w===void 0)throw Error(r(407));w=w()}else{if(w=g(),Fr===null)throw Error(r(349));(qn&127)!==0||EI(E,g,w)}j.memoizedState=w;var L={value:w,getSnapshot:g};return j.queue=L,$I(AI.bind(null,E,L,f),[f]),E.flags|=2048,cp(9,{destroy:void 0},TI.bind(null,E,L,w,g),null),w},useId:function(){var f=fs(),g=Fr.identifierPrefix;if(Xn){var w=Yl,E=Xl;w=(E&~(1<<32-ze(E)-1)).toString(32)+w,g="_"+g+"R_"+w,w=nw++,0<w&&(g+="H"+w.toString(32)),g+="_"}else w=Hie++,g="_"+g+"r_"+w.toString(32)+"_";return f.memoizedState=g},useHostTransitionStatus:eE,useFormState:II,useActionState:II,useOptimistic:function(f){var g=fs();g.memoizedState=g.baseState=f;var w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=w,g=tE.bind(null,Tn,!0,w),w.dispatch=g,[f,g]},useMemoCache:G2,useCacheRefresh:function(){return fs().memoizedState=Kie.bind(null,Tn)},useEffectEvent:function(f){var g=fs(),w={impl:f};return g.memoizedState=w,function(){if((dr&2)!==0)throw Error(r(440));return w.impl.apply(void 0,arguments)}}},nE={readContext:Aa,use:iw,useCallback:XI,useContext:Aa,useEffect:Y2,useImperativeHandle:KI,useInsertionEffect:GI,useLayoutEffect:qI,useMemo:YI,useReducer:aw,useRef:HI,useState:function(){return aw(Hc)},useDebugValue:Q2,useDeferredValue:function(f,g){var w=ki();return QI(w,Nr.memoizedState,f,g)},useTransition:function(){var f=aw(Hc)[0],g=ki().memoizedState;return[typeof f=="boolean"?f:dx(f),g]},useSyncExternalStore:MI,useId:t5,useHostTransitionStatus:eE,useFormState:zI,useActionState:zI,useOptimistic:function(f,g){var w=ki();return jI(w,Nr,f,g)},useMemoCache:G2,useCacheRefresh:n5};nE.useEffectEvent=VI;var o5={readContext:Aa,use:iw,useCallback:XI,useContext:Aa,useEffect:Y2,useImperativeHandle:KI,useInsertionEffect:GI,useLayoutEffect:qI,useMemo:YI,useReducer:W2,useRef:HI,useState:function(){return W2(Hc)},useDebugValue:Q2,useDeferredValue:function(f,g){var w=ki();return Nr===null?Z2(w,f,g):QI(w,Nr.memoizedState,f,g)},useTransition:function(){var f=W2(Hc)[0],g=ki().memoizedState;return[typeof f=="boolean"?f:dx(f),g]},useSyncExternalStore:MI,useId:t5,useHostTransitionStatus:eE,useFormState:BI,useActionState:BI,useOptimistic:function(f,g){var w=ki();return Nr!==null?jI(w,Nr,f,g):(w.baseState=f,[f,w.queue.dispatch])},useMemoCache:G2,useCacheRefresh:n5};o5.useEffectEvent=VI;function rE(f,g,w,E){g=f.memoizedState,w=w(E,g),w=w==null?g:h({},g,w),f.memoizedState=w,f.lanes===0&&(f.updateQueue.baseState=w)}var iE={enqueueSetState:function(f,g,w){f=f._reactInternals;var E=lo(),j=pd(E);j.payload=g,w!=null&&(j.callback=w),g=gd(f,j,E),g!==null&&(Ls(g,f,E),ox(g,f,E))},enqueueReplaceState:function(f,g,w){f=f._reactInternals;var E=lo(),j=pd(E);j.tag=1,j.payload=g,w!=null&&(j.callback=w),g=gd(f,j,E),g!==null&&(Ls(g,f,E),ox(g,f,E))},enqueueForceUpdate:function(f,g){f=f._reactInternals;var w=lo(),E=pd(w);E.tag=2,g!=null&&(E.callback=g),g=gd(f,E,w),g!==null&&(Ls(g,f,w),ox(g,f,w))}};function l5(f,g,w,E,j,L,te){return f=f.stateNode,typeof f.shouldComponentUpdate=="function"?f.shouldComponentUpdate(E,L,te):g.prototype&&g.prototype.isPureReactComponent?!Jb(w,E)||!Jb(j,L):!0}function c5(f,g,w,E){f=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(w,E),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(w,E),g.state!==f&&iE.enqueueReplaceState(g,g.state,null)}function ff(f,g){var w=g;if("ref"in g){w={};for(var E in g)E!=="ref"&&(w[E]=g[E])}if(f=f.defaultProps){w===g&&(w=h({},w));for(var j in f)w[j]===void 0&&(w[j]=f[j])}return w}function u5(f){Uv(f)}function d5(f){console.error(f)}function h5(f){Uv(f)}function cw(f,g){try{var w=f.onUncaughtError;w(g.value,{componentStack:g.stack})}catch(E){setTimeout(function(){throw E})}}function f5(f,g,w){try{var E=f.onCaughtError;E(w.value,{componentStack:w.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(j){setTimeout(function(){throw j})}}function aE(f,g,w){return w=pd(w),w.tag=3,w.payload={element:null},w.callback=function(){cw(f,g)},w}function m5(f){return f=pd(f),f.tag=3,f}function p5(f,g,w,E){var j=w.type.getDerivedStateFromError;if(typeof j=="function"){var L=E.value;f.payload=function(){return j(L)},f.callback=function(){f5(g,w,E)}}var te=w.stateNode;te!==null&&typeof te.componentDidCatch=="function"&&(f.callback=function(){f5(g,w,E),typeof j!="function"&&(_d===null?_d=new Set([this]):_d.add(this));var ye=E.stack;this.componentDidCatch(E.value,{componentStack:ye!==null?ye:""})})}function Yie(f,g,w,E,j){if(w.flags|=32768,E!==null&&typeof E=="object"&&typeof E.then=="function"){if(g=w.alternate,g!==null&&tp(g,w,j,!0),w=io.current,w!==null){switch(w.tag){case 31:case 13:return Io===null?ww():w.alternate===null&&mi===0&&(mi=3),w.flags&=-257,w.flags|=65536,w.lanes=j,E===Yv?w.flags|=16384:(g=w.updateQueue,g===null?w.updateQueue=new Set([E]):g.add(E),CE(f,E,j)),!1;case 22:return w.flags|=65536,E===Yv?w.flags|=16384:(g=w.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([E])},w.updateQueue=g):(w=g.retryQueue,w===null?g.retryQueue=new Set([E]):w.add(E)),CE(f,E,j)),!1}throw Error(r(435,w.tag))}return CE(f,E,j),ww(),!1}if(Xn)return g=io.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=j,E!==N2&&(f=Error(r(422),{cause:E}),nx(Ro(f,w)))):(E!==N2&&(g=Error(r(423),{cause:E}),nx(Ro(g,w))),f=f.current.alternate,f.flags|=65536,j&=-j,f.lanes|=j,E=Ro(E,w),j=aE(f.stateNode,E,j),O2(f,j),mi!==4&&(mi=2)),!1;var L=Error(r(520),{cause:E});if(L=Ro(L,w),wx===null?wx=[L]:wx.push(L),mi!==4&&(mi=2),g===null)return!0;E=Ro(E,w),w=g;do{switch(w.tag){case 3:return w.flags|=65536,f=j&-j,w.lanes|=f,f=aE(w.stateNode,E,f),O2(w,f),!1;case 1:if(g=w.type,L=w.stateNode,(w.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(_d===null||!_d.has(L))))return w.flags|=65536,j&=-j,w.lanes|=j,j=m5(j),p5(j,f,w,E),O2(w,j),!1}w=w.return}while(w!==null);return!1}var sE=Error(r(461)),Di=!1;function Ca(f,g,w,E){g.child=f===null?yI(g,null,w,E):df(g,f.child,w,E)}function g5(f,g,w,E,j){w=w.render;var L=g.ref;if("ref"in E){var te={};for(var ye in E)ye!=="ref"&&(te[ye]=E[ye])}else te=E;return of(g),E=B2(f,g,w,te,L,j),ye=H2(),f!==null&&!Di?($2(f,g,j),$c(f,g,j)):(Xn&&ye&&_2(g),g.flags|=1,Ca(f,g,E,j),g.child)}function b5(f,g,w,E,j){if(f===null){var L=w.type;return typeof L=="function"&&!y2(L)&&L.defaultProps===void 0&&w.compare===null?(g.tag=15,g.type=L,x5(f,g,L,E,j)):(f=Vv(w.type,null,E,g,g.mode,j),f.ref=g.ref,f.return=g,g.child=f)}if(L=f.child,!mE(f,j)){var te=L.memoizedProps;if(w=w.compare,w=w!==null?w:Jb,w(te,E)&&f.ref===g.ref)return $c(f,g,j)}return g.flags|=1,f=Fc(L,E),f.ref=g.ref,f.return=g,g.child=f}function x5(f,g,w,E,j){if(f!==null){var L=f.memoizedProps;if(Jb(L,E)&&f.ref===g.ref)if(Di=!1,g.pendingProps=E=L,mE(f,j))(f.flags&131072)!==0&&(Di=!0);else return g.lanes=f.lanes,$c(f,g,j)}return oE(f,g,w,E,j)}function y5(f,g,w,E){var j=E.children,L=f!==null?f.memoizedState:null;if(f===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),E.mode==="hidden"){if((g.flags&128)!==0){if(L=L!==null?L.baseLanes|w:w,f!==null){for(E=g.child=f.child,j=0;E!==null;)j=j|E.lanes|E.childLanes,E=E.sibling;E=j&~L}else E=0,g.child=null;return v5(f,g,L,w,E)}if((w&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},f!==null&&Kv(g,L!==null?L.cachePool:null),L!==null?_I(g,L):F2(),SI(g);else return E=g.lanes=536870912,v5(f,g,L!==null?L.baseLanes|w:w,w,E)}else L!==null?(Kv(g,L.cachePool),_I(g,L),xd(),g.memoizedState=null):(f!==null&&Kv(g,null),F2(),xd());return Ca(f,g,j,w),g.child}function mx(f,g){return f!==null&&f.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function v5(f,g,w,E,j){var L=P2();return L=L===null?null:{parent:Pi._currentValue,pool:L},g.memoizedState={baseLanes:w,cachePool:L},f!==null&&Kv(g,null),F2(),SI(g),f!==null&&tp(f,g,E,!0),g.childLanes=j,null}function uw(f,g){return g=hw({mode:g.mode,children:g.children},f.mode),g.ref=f.ref,f.child=g,g.return=f,g}function w5(f,g,w){return df(g,f.child,null,w),f=uw(g,g.pendingProps),f.flags|=2,ao(g),g.memoizedState=null,f}function Qie(f,g,w){var E=g.pendingProps,j=(g.flags&128)!==0;if(g.flags&=-129,f===null){if(Xn){if(E.mode==="hidden")return f=uw(g,E),g.lanes=536870912,mx(null,f);if(z2(g),(f=qr)?(f=Dz(f,Fo),f=f!==null&&f.data==="&"?f:null,f!==null&&(g.memoizedState={dehydrated:f,treeContext:ud!==null?{id:Xl,overflow:Yl}:null,retryLane:536870912,hydrationErrors:null},w=iI(f),w.return=g,g.child=w,Ta=g,qr=null)):f=null,f===null)throw hd(g);return g.lanes=536870912,null}return uw(g,E)}var L=f.memoizedState;if(L!==null){var te=L.dehydrated;if(z2(g),j)if(g.flags&256)g.flags&=-257,g=w5(f,g,w);else if(g.memoizedState!==null)g.child=f.child,g.flags|=128,g=null;else throw Error(r(558));else if(Di||tp(f,g,w,!1),j=(w&f.childLanes)!==0,Di||j){if(E=Fr,E!==null&&(te=Wt(E,w),te!==0&&te!==L.retryLane))throw L.retryLane=te,nf(f,te),Ls(E,f,te),sE;ww(),g=w5(f,g,w)}else f=L.treeContext,qr=zo(te.nextSibling),Ta=g,Xn=!0,dd=null,Fo=!1,f!==null&&oI(g,f),g=uw(g,E),g.flags|=4096;return g}return f=Fc(f.child,{mode:E.mode,children:E.children}),f.ref=g.ref,g.child=f,f.return=g,f}function dw(f,g){var w=g.ref;if(w===null)f!==null&&f.ref!==null&&(g.flags|=4194816);else{if(typeof w!="function"&&typeof w!="object")throw Error(r(284));(f===null||f.ref!==w)&&(g.flags|=4194816)}}function oE(f,g,w,E,j){return of(g),w=B2(f,g,w,E,void 0,j),E=H2(),f!==null&&!Di?($2(f,g,j),$c(f,g,j)):(Xn&&E&&_2(g),g.flags|=1,Ca(f,g,w,j),g.child)}function _5(f,g,w,E,j,L){return of(g),g.updateQueue=null,w=kI(g,E,w,j),NI(f),E=H2(),f!==null&&!Di?($2(f,g,L),$c(f,g,L)):(Xn&&E&&_2(g),g.flags|=1,Ca(f,g,w,L),g.child)}function S5(f,g,w,E,j){if(of(g),g.stateNode===null){var L=Qm,te=w.contextType;typeof te=="object"&&te!==null&&(L=Aa(te)),L=new w(E,L),g.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,L.updater=iE,g.stateNode=L,L._reactInternals=g,L=g.stateNode,L.props=E,L.state=g.memoizedState,L.refs={},D2(g),te=w.contextType,L.context=typeof te=="object"&&te!==null?Aa(te):Qm,L.state=g.memoizedState,te=w.getDerivedStateFromProps,typeof te=="function"&&(rE(g,w,te,E),L.state=g.memoizedState),typeof w.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(te=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),te!==L.state&&iE.enqueueReplaceState(L,L.state,null),cx(g,E,L,j),lx(),L.state=g.memoizedState),typeof L.componentDidMount=="function"&&(g.flags|=4194308),E=!0}else if(f===null){L=g.stateNode;var ye=g.memoizedProps,Be=ff(w,ye);L.props=Be;var ct=L.context,vt=w.contextType;te=Qm,typeof vt=="object"&&vt!==null&&(te=Aa(vt));var Nt=w.getDerivedStateFromProps;vt=typeof Nt=="function"||typeof L.getSnapshotBeforeUpdate=="function",ye=g.pendingProps!==ye,vt||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(ye||ct!==te)&&c5(g,L,E,te),md=!1;var ft=g.memoizedState;L.state=ft,cx(g,E,L,j),lx(),ct=g.memoizedState,ye||ft!==ct||md?(typeof Nt=="function"&&(rE(g,w,Nt,E),ct=g.memoizedState),(Be=md||l5(g,w,Be,E,ft,ct,te))?(vt||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=E,g.memoizedState=ct),L.props=E,L.state=ct,L.context=te,E=Be):(typeof L.componentDidMount=="function"&&(g.flags|=4194308),E=!1)}else{L=g.stateNode,R2(f,g),te=g.memoizedProps,vt=ff(w,te),L.props=vt,Nt=g.pendingProps,ft=L.context,ct=w.contextType,Be=Qm,typeof ct=="object"&&ct!==null&&(Be=Aa(ct)),ye=w.getDerivedStateFromProps,(ct=typeof ye=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(te!==Nt||ft!==Be)&&c5(g,L,E,Be),md=!1,ft=g.memoizedState,L.state=ft,cx(g,E,L,j),lx();var bt=g.memoizedState;te!==Nt||ft!==bt||md||f!==null&&f.dependencies!==null&&qv(f.dependencies)?(typeof ye=="function"&&(rE(g,w,ye,E),bt=g.memoizedState),(vt=md||l5(g,w,vt,E,ft,bt,Be)||f!==null&&f.dependencies!==null&&qv(f.dependencies))?(ct||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(E,bt,Be),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(E,bt,Be)),typeof L.componentDidUpdate=="function"&&(g.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof L.componentDidUpdate!="function"||te===f.memoizedProps&&ft===f.memoizedState||(g.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||te===f.memoizedProps&&ft===f.memoizedState||(g.flags|=1024),g.memoizedProps=E,g.memoizedState=bt),L.props=E,L.state=bt,L.context=Be,E=vt):(typeof L.componentDidUpdate!="function"||te===f.memoizedProps&&ft===f.memoizedState||(g.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||te===f.memoizedProps&&ft===f.memoizedState||(g.flags|=1024),E=!1)}return L=E,dw(f,g),E=(g.flags&128)!==0,L||E?(L=g.stateNode,w=E&&typeof w.getDerivedStateFromError!="function"?null:L.render(),g.flags|=1,f!==null&&E?(g.child=df(g,f.child,null,j),g.child=df(g,null,w,j)):Ca(f,g,w,j),g.memoizedState=L.state,f=g.child):f=$c(f,g,j),f}function N5(f,g,w,E){return af(),g.flags|=256,Ca(f,g,w,E),g.child}var lE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function cE(f){return{baseLanes:f,cachePool:fI()}}function uE(f,g,w){return f=f!==null?f.childLanes&~w:0,g&&(f|=oo),f}function k5(f,g,w){var E=g.pendingProps,j=!1,L=(g.flags&128)!==0,te;if((te=L)||(te=f!==null&&f.memoizedState===null?!1:(Ni.current&2)!==0),te&&(j=!0,g.flags&=-129),te=(g.flags&32)!==0,g.flags&=-33,f===null){if(Xn){if(j?bd(g):xd(),(f=qr)?(f=Dz(f,Fo),f=f!==null&&f.data!=="&"?f:null,f!==null&&(g.memoizedState={dehydrated:f,treeContext:ud!==null?{id:Xl,overflow:Yl}:null,retryLane:536870912,hydrationErrors:null},w=iI(f),w.return=g,g.child=w,Ta=g,qr=null)):f=null,f===null)throw hd(g);return qE(f)?g.lanes=32:g.lanes=536870912,null}var ye=E.children;return E=E.fallback,j?(xd(),j=g.mode,ye=hw({mode:"hidden",children:ye},j),E=rf(E,j,w,null),ye.return=g,E.return=g,ye.sibling=E,g.child=ye,E=g.child,E.memoizedState=cE(w),E.childLanes=uE(f,te,w),g.memoizedState=lE,mx(null,E)):(bd(g),dE(g,ye))}var Be=f.memoizedState;if(Be!==null&&(ye=Be.dehydrated,ye!==null)){if(L)g.flags&256?(bd(g),g.flags&=-257,g=hE(f,g,w)):g.memoizedState!==null?(xd(),g.child=f.child,g.flags|=128,g=null):(xd(),ye=E.fallback,j=g.mode,E=hw({mode:"visible",children:E.children},j),ye=rf(ye,j,w,null),ye.flags|=2,E.return=g,ye.return=g,E.sibling=ye,g.child=E,df(g,f.child,null,w),E=g.child,E.memoizedState=cE(w),E.childLanes=uE(f,te,w),g.memoizedState=lE,g=mx(null,E));else if(bd(g),qE(ye)){if(te=ye.nextSibling&&ye.nextSibling.dataset,te)var ct=te.dgst;te=ct,E=Error(r(419)),E.stack="",E.digest=te,nx({value:E,source:null,stack:null}),g=hE(f,g,w)}else if(Di||tp(f,g,w,!1),te=(w&f.childLanes)!==0,Di||te){if(te=Fr,te!==null&&(E=Wt(te,w),E!==0&&E!==Be.retryLane))throw Be.retryLane=E,nf(f,E),Ls(te,f,E),sE;GE(ye)||ww(),g=hE(f,g,w)}else GE(ye)?(g.flags|=192,g.child=f.child,g=null):(f=Be.treeContext,qr=zo(ye.nextSibling),Ta=g,Xn=!0,dd=null,Fo=!1,f!==null&&oI(g,f),g=dE(g,E.children),g.flags|=4096);return g}return j?(xd(),ye=E.fallback,j=g.mode,Be=f.child,ct=Be.sibling,E=Fc(Be,{mode:"hidden",children:E.children}),E.subtreeFlags=Be.subtreeFlags&65011712,ct!==null?ye=Fc(ct,ye):(ye=rf(ye,j,w,null),ye.flags|=2),ye.return=g,E.return=g,E.sibling=ye,g.child=E,mx(null,E),E=g.child,ye=f.child.memoizedState,ye===null?ye=cE(w):(j=ye.cachePool,j!==null?(Be=Pi._currentValue,j=j.parent!==Be?{parent:Be,pool:Be}:j):j=fI(),ye={baseLanes:ye.baseLanes|w,cachePool:j}),E.memoizedState=ye,E.childLanes=uE(f,te,w),g.memoizedState=lE,mx(f.child,E)):(bd(g),w=f.child,f=w.sibling,w=Fc(w,{mode:"visible",children:E.children}),w.return=g,w.sibling=null,f!==null&&(te=g.deletions,te===null?(g.deletions=[f],g.flags|=16):te.push(f)),g.child=w,g.memoizedState=null,w)}function dE(f,g){return g=hw({mode:"visible",children:g},f.mode),g.return=f,f.child=g}function hw(f,g){return f=ro(22,f,null,g),f.lanes=0,f}function hE(f,g,w){return df(g,f.child,null,w),f=dE(g,g.pendingProps.children),f.flags|=2,g.memoizedState=null,f}function M5(f,g,w){f.lanes|=g;var E=f.alternate;E!==null&&(E.lanes|=g),E2(f.return,g,w)}function fE(f,g,w,E,j,L){var te=f.memoizedState;te===null?f.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:E,tail:w,tailMode:j,treeForkCount:L}:(te.isBackwards=g,te.rendering=null,te.renderingStartTime=0,te.last=E,te.tail=w,te.tailMode=j,te.treeForkCount=L)}function E5(f,g,w){var E=g.pendingProps,j=E.revealOrder,L=E.tail;E=E.children;var te=Ni.current,ye=(te&2)!==0;if(ye?(te=te&1|2,g.flags|=128):te&=1,J(Ni,te),Ca(f,g,E,w),E=Xn?tx:0,!ye&&f!==null&&(f.flags&128)!==0)e:for(f=g.child;f!==null;){if(f.tag===13)f.memoizedState!==null&&M5(f,w,g);else if(f.tag===19)M5(f,w,g);else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===g)break e;for(;f.sibling===null;){if(f.return===null||f.return===g)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}switch(j){case"forwards":for(w=g.child,j=null;w!==null;)f=w.alternate,f!==null&&ew(f)===null&&(j=w),w=w.sibling;w=j,w===null?(j=g.child,g.child=null):(j=w.sibling,w.sibling=null),fE(g,!1,j,w,L,E);break;case"backwards":case"unstable_legacy-backwards":for(w=null,j=g.child,g.child=null;j!==null;){if(f=j.alternate,f!==null&&ew(f)===null){g.child=j;break}f=j.sibling,j.sibling=w,w=j,j=f}fE(g,!0,w,null,L,E);break;case"together":fE(g,!1,null,null,void 0,E);break;default:g.memoizedState=null}return g.child}function $c(f,g,w){if(f!==null&&(g.dependencies=f.dependencies),wd|=g.lanes,(w&g.childLanes)===0)if(f!==null){if(tp(f,g,w,!1),(w&g.childLanes)===0)return null}else return null;if(f!==null&&g.child!==f.child)throw Error(r(153));if(g.child!==null){for(f=g.child,w=Fc(f,f.pendingProps),g.child=w,w.return=g;f.sibling!==null;)f=f.sibling,w=w.sibling=Fc(f,f.pendingProps),w.return=g;w.sibling=null}return g.child}function mE(f,g){return(f.lanes&g)!==0?!0:(f=f.dependencies,!!(f!==null&&qv(f)))}function Zie(f,g,w){switch(g.tag){case 3:De(g,g.stateNode.containerInfo),fd(g,Pi,f.memoizedState.cache),af();break;case 27:case 5:Ne(g);break;case 4:De(g,g.stateNode.containerInfo);break;case 10:fd(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,z2(g),null;break;case 13:var E=g.memoizedState;if(E!==null)return E.dehydrated!==null?(bd(g),g.flags|=128,null):(w&g.child.childLanes)!==0?k5(f,g,w):(bd(g),f=$c(f,g,w),f!==null?f.sibling:null);bd(g);break;case 19:var j=(f.flags&128)!==0;if(E=(w&g.childLanes)!==0,E||(tp(f,g,w,!1),E=(w&g.childLanes)!==0),j){if(E)return E5(f,g,w);g.flags|=128}if(j=g.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),J(Ni,Ni.current),E)break;return null;case 22:return g.lanes=0,y5(f,g,w,g.pendingProps);case 24:fd(g,Pi,f.memoizedState.cache)}return $c(f,g,w)}function T5(f,g,w){if(f!==null)if(f.memoizedProps!==g.pendingProps)Di=!0;else{if(!mE(f,w)&&(g.flags&128)===0)return Di=!1,Zie(f,g,w);Di=(f.flags&131072)!==0}else Di=!1,Xn&&(g.flags&1048576)!==0&&sI(g,tx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var E=g.pendingProps;if(f=cf(g.elementType),g.type=f,typeof f=="function")y2(f)?(E=ff(f,E),g.tag=1,g=S5(null,g,f,E,w)):(g.tag=0,g=oE(null,g,f,E,w));else{if(f!=null){var j=f.$$typeof;if(j===T){g.tag=11,g=g5(null,g,f,E,w);break e}else if(j===k){g.tag=14,g=b5(null,g,f,E,w);break e}}throw g=D(f)||f,Error(r(306,g,""))}}return g;case 0:return oE(f,g,g.type,g.pendingProps,w);case 1:return E=g.type,j=ff(E,g.pendingProps),S5(f,g,E,j,w);case 3:e:{if(De(g,g.stateNode.containerInfo),f===null)throw Error(r(387));E=g.pendingProps;var L=g.memoizedState;j=L.element,R2(f,g),cx(g,E,null,w);var te=g.memoizedState;if(E=te.cache,fd(g,Pi,E),E!==L.cache&&T2(g,[Pi],w,!0),lx(),E=te.element,L.isDehydrated)if(L={element:E,isDehydrated:!1,cache:te.cache},g.updateQueue.baseState=L,g.memoizedState=L,g.flags&256){g=N5(f,g,E,w);break e}else if(E!==j){j=Ro(Error(r(424)),g),nx(j),g=N5(f,g,E,w);break e}else{switch(f=g.stateNode.containerInfo,f.nodeType){case 9:f=f.body;break;default:f=f.nodeName==="HTML"?f.ownerDocument.body:f}for(qr=zo(f.firstChild),Ta=g,Xn=!0,dd=null,Fo=!0,w=yI(g,null,E,w),g.child=w;w;)w.flags=w.flags&-3|4096,w=w.sibling}else{if(af(),E===j){g=$c(f,g,w);break e}Ca(f,g,E,w)}g=g.child}return g;case 26:return dw(f,g),f===null?(w=zz(g.type,null,g.pendingProps,null))?g.memoizedState=w:Xn||(w=g.type,f=g.pendingProps,E=Tw(ue.current).createElement(w),E[Xt]=g,E[Zn]=f,Pa(E,w,f),He(E),g.stateNode=E):g.memoizedState=zz(g.type,f.memoizedProps,g.pendingProps,f.memoizedState),null;case 27:return Ne(g),f===null&&Xn&&(E=g.stateNode=Lz(g.type,g.pendingProps,ue.current),Ta=g,Fo=!0,j=qr,Md(g.type)?(WE=j,qr=zo(E.firstChild)):qr=j),Ca(f,g,g.pendingProps.children,w),dw(f,g),f===null&&(g.flags|=4194304),g.child;case 5:return f===null&&Xn&&((j=E=qr)&&(E=Tae(E,g.type,g.pendingProps,Fo),E!==null?(g.stateNode=E,Ta=g,qr=zo(E.firstChild),Fo=!1,j=!0):j=!1),j||hd(g)),Ne(g),j=g.type,L=g.pendingProps,te=f!==null?f.memoizedProps:null,E=L.children,HE(j,L)?E=null:te!==null&&HE(j,te)&&(g.flags|=32),g.memoizedState!==null&&(j=B2(f,g,$ie,null,null,w),Ax._currentValue=j),dw(f,g),Ca(f,g,E,w),g.child;case 6:return f===null&&Xn&&((f=w=qr)&&(w=Aae(w,g.pendingProps,Fo),w!==null?(g.stateNode=w,Ta=g,qr=null,f=!0):f=!1),f||hd(g)),null;case 13:return k5(f,g,w);case 4:return De(g,g.stateNode.containerInfo),E=g.pendingProps,f===null?g.child=df(g,null,E,w):Ca(f,g,E,w),g.child;case 11:return g5(f,g,g.type,g.pendingProps,w);case 7:return Ca(f,g,g.pendingProps,w),g.child;case 8:return Ca(f,g,g.pendingProps.children,w),g.child;case 12:return Ca(f,g,g.pendingProps.children,w),g.child;case 10:return E=g.pendingProps,fd(g,g.type,E.value),Ca(f,g,E.children,w),g.child;case 9:return j=g.type._context,E=g.pendingProps.children,of(g),j=Aa(j),E=E(j),g.flags|=1,Ca(f,g,E,w),g.child;case 14:return b5(f,g,g.type,g.pendingProps,w);case 15:return x5(f,g,g.type,g.pendingProps,w);case 19:return E5(f,g,w);case 31:return Qie(f,g,w);case 22:return y5(f,g,w,g.pendingProps);case 24:return of(g),E=Aa(Pi),f===null?(j=P2(),j===null&&(j=Fr,L=A2(),j.pooledCache=L,L.refCount++,L!==null&&(j.pooledCacheLanes|=w),j=L),g.memoizedState={parent:E,cache:j},D2(g),fd(g,Pi,j)):((f.lanes&w)!==0&&(R2(f,g),cx(g,null,null,w),lx()),j=f.memoizedState,L=g.memoizedState,j.parent!==E?(j={parent:E,cache:E},g.memoizedState=j,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=j),fd(g,Pi,E)):(E=L.cache,fd(g,Pi,E),E!==j.cache&&T2(g,[Pi],w,!0))),Ca(f,g,g.pendingProps.children,w),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function Vc(f){f.flags|=4}function pE(f,g,w,E,j){if((g=(f.mode&32)!==0)&&(g=!1),g){if(f.flags|=16777216,(j&335544128)===j)if(f.stateNode.complete)f.flags|=8192;else if(tz())f.flags|=8192;else throw uf=Yv,j2}else f.flags&=-16777217}function A5(f,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)f.flags&=-16777217;else if(f.flags|=16777216,!Vz(g))if(tz())f.flags|=8192;else throw uf=Yv,j2}function fw(f,g){g!==null&&(f.flags|=4),f.flags&16384&&(g=f.tag!==22?xt():536870912,f.lanes|=g,fp|=g)}function px(f,g){if(!Xn)switch(f.tailMode){case"hidden":g=f.tail;for(var w=null;g!==null;)g.alternate!==null&&(w=g),g=g.sibling;w===null?f.tail=null:w.sibling=null;break;case"collapsed":w=f.tail;for(var E=null;w!==null;)w.alternate!==null&&(E=w),w=w.sibling;E===null?g||f.tail===null?f.tail=null:f.tail.sibling=null:E.sibling=null}}function Wr(f){var g=f.alternate!==null&&f.alternate.child===f.child,w=0,E=0;if(g)for(var j=f.child;j!==null;)w|=j.lanes|j.childLanes,E|=j.subtreeFlags&65011712,E|=j.flags&65011712,j.return=f,j=j.sibling;else for(j=f.child;j!==null;)w|=j.lanes|j.childLanes,E|=j.subtreeFlags,E|=j.flags,j.return=f,j=j.sibling;return f.subtreeFlags|=E,f.childLanes=w,g}function Jie(f,g,w){var E=g.pendingProps;switch(S2(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Wr(g),null;case 1:return Wr(g),null;case 3:return w=g.stateNode,E=null,f!==null&&(E=f.memoizedState.cache),g.memoizedState.cache!==E&&(g.flags|=2048),Uc(Pi),oe(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(f===null||f.child===null)&&(ep(g)?Vc(g):f===null||f.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,k2())),Wr(g),null;case 26:var j=g.type,L=g.memoizedState;return f===null?(Vc(g),L!==null?(Wr(g),A5(g,L)):(Wr(g),pE(g,j,null,E,w))):L?L!==f.memoizedState?(Vc(g),Wr(g),A5(g,L)):(Wr(g),g.flags&=-16777217):(f=f.memoizedProps,f!==E&&Vc(g),Wr(g),pE(g,j,f,E,w)),null;case 27:if(Fe(g),w=ue.current,j=g.type,f!==null&&g.stateNode!=null)f.memoizedProps!==E&&Vc(g);else{if(!E){if(g.stateNode===null)throw Error(r(166));return Wr(g),null}f=ne.current,ep(g)?lI(g):(f=Lz(j,E,w),g.stateNode=f,Vc(g))}return Wr(g),null;case 5:if(Fe(g),j=g.type,f!==null&&g.stateNode!=null)f.memoizedProps!==E&&Vc(g);else{if(!E){if(g.stateNode===null)throw Error(r(166));return Wr(g),null}if(L=ne.current,ep(g))lI(g);else{var te=Tw(ue.current);switch(L){case 1:L=te.createElementNS("http://www.w3.org/2000/svg",j);break;case 2:L=te.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;default:switch(j){case"svg":L=te.createElementNS("http://www.w3.org/2000/svg",j);break;case"math":L=te.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;case"script":L=te.createElement("div"),L.innerHTML="<script><\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof E.is=="string"?te.createElement("select",{is:E.is}):te.createElement("select"),E.multiple?L.multiple=!0:E.size&&(L.size=E.size);break;default:L=typeof E.is=="string"?te.createElement(j,{is:E.is}):te.createElement(j)}}L[Xt]=g,L[Zn]=E;e:for(te=g.child;te!==null;){if(te.tag===5||te.tag===6)L.appendChild(te.stateNode);else if(te.tag!==4&&te.tag!==27&&te.child!==null){te.child.return=te,te=te.child;continue}if(te===g)break e;for(;te.sibling===null;){if(te.return===null||te.return===g)break e;te=te.return}te.sibling.return=te.return,te=te.sibling}g.stateNode=L;e:switch(Pa(L,j,E),j){case"button":case"input":case"select":case"textarea":E=!!E.autoFocus;break e;case"img":E=!0;break e;default:E=!1}E&&Vc(g)}}return Wr(g),pE(g,g.type,f===null?null:f.memoizedProps,g.pendingProps,w),null;case 6:if(f&&g.stateNode!=null)f.memoizedProps!==E&&Vc(g);else{if(typeof E!="string"&&g.stateNode===null)throw Error(r(166));if(f=ue.current,ep(g)){if(f=g.stateNode,w=g.memoizedProps,E=null,j=Ta,j!==null)switch(j.tag){case 27:case 5:E=j.memoizedProps}f[Xt]=g,f=!!(f.nodeValue===w||E!==null&&E.suppressHydrationWarning===!0||kz(f.nodeValue,w)),f||hd(g,!0)}else f=Tw(f).createTextNode(E),f[Xt]=g,g.stateNode=f}return Wr(g),null;case 31:if(w=g.memoizedState,f===null||f.memoizedState!==null){if(E=ep(g),w!==null){if(f===null){if(!E)throw Error(r(318));if(f=g.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(557));f[Xt]=g}else af(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Wr(g),f=!1}else w=k2(),f!==null&&f.memoizedState!==null&&(f.memoizedState.hydrationErrors=w),f=!0;if(!f)return g.flags&256?(ao(g),g):(ao(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Wr(g),null;case 13:if(E=g.memoizedState,f===null||f.memoizedState!==null&&f.memoizedState.dehydrated!==null){if(j=ep(g),E!==null&&E.dehydrated!==null){if(f===null){if(!j)throw Error(r(318));if(j=g.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[Xt]=g}else af(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Wr(g),j=!1}else j=k2(),f!==null&&f.memoizedState!==null&&(f.memoizedState.hydrationErrors=j),j=!0;if(!j)return g.flags&256?(ao(g),g):(ao(g),null)}return ao(g),(g.flags&128)!==0?(g.lanes=w,g):(w=E!==null,f=f!==null&&f.memoizedState!==null,w&&(E=g.child,j=null,E.alternate!==null&&E.alternate.memoizedState!==null&&E.alternate.memoizedState.cachePool!==null&&(j=E.alternate.memoizedState.cachePool.pool),L=null,E.memoizedState!==null&&E.memoizedState.cachePool!==null&&(L=E.memoizedState.cachePool.pool),L!==j&&(E.flags|=2048)),w!==f&&w&&(g.child.flags|=8192),fw(g,g.updateQueue),Wr(g),null);case 4:return oe(),f===null&&FE(g.stateNode.containerInfo),Wr(g),null;case 10:return Uc(g.type),Wr(g),null;case 19:if(W(Ni),E=g.memoizedState,E===null)return Wr(g),null;if(j=(g.flags&128)!==0,L=E.rendering,L===null)if(j)px(E,!1);else{if(mi!==0||f!==null&&(f.flags&128)!==0)for(f=g.child;f!==null;){if(L=ew(f),L!==null){for(g.flags|=128,px(E,!1),f=L.updateQueue,g.updateQueue=f,fw(g,f),g.subtreeFlags=0,f=w,w=g.child;w!==null;)rI(w,f),w=w.sibling;return J(Ni,Ni.current&1|2),Xn&&Ic(g,E.treeForkCount),g.child}f=f.sibling}E.tail!==null&&O()>xw&&(g.flags|=128,j=!0,px(E,!1),g.lanes=4194304)}else{if(!j)if(f=ew(L),f!==null){if(g.flags|=128,j=!0,f=f.updateQueue,g.updateQueue=f,fw(g,f),px(E,!0),E.tail===null&&E.tailMode==="hidden"&&!L.alternate&&!Xn)return Wr(g),null}else 2*O()-E.renderingStartTime>xw&&w!==536870912&&(g.flags|=128,j=!0,px(E,!1),g.lanes=4194304);E.isBackwards?(L.sibling=g.child,g.child=L):(f=E.last,f!==null?f.sibling=L:g.child=L,E.last=L)}return E.tail!==null?(f=E.tail,E.rendering=f,E.tail=f.sibling,E.renderingStartTime=O(),f.sibling=null,w=Ni.current,J(Ni,j?w&1|2:w&1),Xn&&Ic(g,E.treeForkCount),f):(Wr(g),null);case 22:case 23:return ao(g),I2(),E=g.memoizedState!==null,f!==null?f.memoizedState!==null!==E&&(g.flags|=8192):E&&(g.flags|=8192),E?(w&536870912)!==0&&(g.flags&128)===0&&(Wr(g),g.subtreeFlags&6&&(g.flags|=8192)):Wr(g),w=g.updateQueue,w!==null&&fw(g,w.retryQueue),w=null,f!==null&&f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(w=f.memoizedState.cachePool.pool),E=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(E=g.memoizedState.cachePool.pool),E!==w&&(g.flags|=2048),f!==null&&W(lf),null;case 24:return w=null,f!==null&&(w=f.memoizedState.cache),g.memoizedState.cache!==w&&(g.flags|=2048),Uc(Pi),Wr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function eae(f,g){switch(S2(g),g.tag){case 1:return f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 3:return Uc(Pi),oe(),f=g.flags,(f&65536)!==0&&(f&128)===0?(g.flags=f&-65537|128,g):null;case 26:case 27:case 5:return Fe(g),null;case 31:if(g.memoizedState!==null){if(ao(g),g.alternate===null)throw Error(r(340));af()}return f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 13:if(ao(g),f=g.memoizedState,f!==null&&f.dehydrated!==null){if(g.alternate===null)throw Error(r(340));af()}return f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 19:return W(Ni),null;case 4:return oe(),null;case 10:return Uc(g.type),null;case 22:case 23:return ao(g),I2(),f!==null&&W(lf),f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 24:return Uc(Pi),null;case 25:return null;default:return null}}function C5(f,g){switch(S2(g),g.tag){case 3:Uc(Pi),oe();break;case 26:case 27:case 5:Fe(g);break;case 4:oe();break;case 31:g.memoizedState!==null&&ao(g);break;case 13:ao(g);break;case 19:W(Ni);break;case 10:Uc(g.type);break;case 22:case 23:ao(g),I2(),f!==null&&W(lf);break;case 24:Uc(Pi)}}function gx(f,g){try{var w=g.updateQueue,E=w!==null?w.lastEffect:null;if(E!==null){var j=E.next;w=j;do{if((w.tag&f)===f){E=void 0;var L=w.create,te=w.inst;E=L(),te.destroy=E}w=w.next}while(w!==j)}}catch(ye){xr(g,g.return,ye)}}function yd(f,g,w){try{var E=g.updateQueue,j=E!==null?E.lastEffect:null;if(j!==null){var L=j.next;E=L;do{if((E.tag&f)===f){var te=E.inst,ye=te.destroy;if(ye!==void 0){te.destroy=void 0,j=g;var Be=w,ct=ye;try{ct()}catch(vt){xr(j,Be,vt)}}}E=E.next}while(E!==L)}}catch(vt){xr(g,g.return,vt)}}function P5(f){var g=f.updateQueue;if(g!==null){var w=f.stateNode;try{wI(g,w)}catch(E){xr(f,f.return,E)}}}function j5(f,g,w){w.props=ff(f.type,f.memoizedProps),w.state=f.memoizedState;try{w.componentWillUnmount()}catch(E){xr(f,g,E)}}function bx(f,g){try{var w=f.ref;if(w!==null){switch(f.tag){case 26:case 27:case 5:var E=f.stateNode;break;case 30:E=f.stateNode;break;default:E=f.stateNode}typeof w=="function"?f.refCleanup=w(E):w.current=E}}catch(j){xr(f,g,j)}}function Ql(f,g){var w=f.ref,E=f.refCleanup;if(w!==null)if(typeof E=="function")try{E()}catch(j){xr(f,g,j)}finally{f.refCleanup=null,f=f.alternate,f!=null&&(f.refCleanup=null)}else if(typeof w=="function")try{w(null)}catch(j){xr(f,g,j)}else w.current=null}function D5(f){var g=f.type,w=f.memoizedProps,E=f.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":w.autoFocus&&E.focus();break e;case"img":w.src?E.src=w.src:w.srcSet&&(E.srcset=w.srcSet)}}catch(j){xr(f,f.return,j)}}function gE(f,g,w){try{var E=f.stateNode;_ae(E,f.type,w,g),E[Zn]=g}catch(j){xr(f,f.return,j)}}function R5(f){return f.tag===5||f.tag===3||f.tag===26||f.tag===27&&Md(f.type)||f.tag===4}function bE(f){e:for(;;){for(;f.sibling===null;){if(f.return===null||R5(f.return))return null;f=f.return}for(f.sibling.return=f.return,f=f.sibling;f.tag!==5&&f.tag!==6&&f.tag!==18;){if(f.tag===27&&Md(f.type)||f.flags&2||f.child===null||f.tag===4)continue e;f.child.return=f,f=f.child}if(!(f.flags&2))return f.stateNode}}function xE(f,g,w){var E=f.tag;if(E===5||E===6)f=f.stateNode,g?(w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w).insertBefore(f,g):(g=w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w,g.appendChild(f),w=w._reactRootContainer,w!=null||g.onclick!==null||(g.onclick=Ma));else if(E!==4&&(E===27&&Md(f.type)&&(w=f.stateNode,g=null),f=f.child,f!==null))for(xE(f,g,w),f=f.sibling;f!==null;)xE(f,g,w),f=f.sibling}function mw(f,g,w){var E=f.tag;if(E===5||E===6)f=f.stateNode,g?w.insertBefore(f,g):w.appendChild(f);else if(E!==4&&(E===27&&Md(f.type)&&(w=f.stateNode),f=f.child,f!==null))for(mw(f,g,w),f=f.sibling;f!==null;)mw(f,g,w),f=f.sibling}function O5(f){var g=f.stateNode,w=f.memoizedProps;try{for(var E=f.type,j=g.attributes;j.length;)g.removeAttributeNode(j[0]);Pa(g,E,w),g[Xt]=f,g[Zn]=w}catch(L){xr(f,f.return,L)}}var Gc=!1,Ri=!1,yE=!1,L5=typeof WeakSet=="function"?WeakSet:Set,fa=null;function tae(f,g){if(f=f.containerInfo,UE=Ow,f=KF(f),h2(f)){if("selectionStart"in f)var w={start:f.selectionStart,end:f.selectionEnd};else e:{w=(w=f.ownerDocument)&&w.defaultView||window;var E=w.getSelection&&w.getSelection();if(E&&E.rangeCount!==0){w=E.anchorNode;var j=E.anchorOffset,L=E.focusNode;E=E.focusOffset;try{w.nodeType,L.nodeType}catch{w=null;break e}var te=0,ye=-1,Be=-1,ct=0,vt=0,Nt=f,ft=null;t:for(;;){for(var bt;Nt!==w||j!==0&&Nt.nodeType!==3||(ye=te+j),Nt!==L||E!==0&&Nt.nodeType!==3||(Be=te+E),Nt.nodeType===3&&(te+=Nt.nodeValue.length),(bt=Nt.firstChild)!==null;)ft=Nt,Nt=bt;for(;;){if(Nt===f)break t;if(ft===w&&++ct===j&&(ye=te),ft===L&&++vt===E&&(Be=te),(bt=Nt.nextSibling)!==null)break;Nt=ft,ft=Nt.parentNode}Nt=bt}w=ye===-1||Be===-1?null:{start:ye,end:Be}}else w=null}w=w||{start:0,end:0}}else w=null;for(BE={focusedElem:f,selectionRange:w},Ow=!1,fa=g;fa!==null;)if(g=fa,f=g.child,(g.subtreeFlags&1028)!==0&&f!==null)f.return=g,fa=f;else for(;fa!==null;){switch(g=fa,L=g.alternate,f=g.flags,g.tag){case 0:if((f&4)!==0&&(f=g.updateQueue,f=f!==null?f.events:null,f!==null))for(w=0;w<f.length;w++)j=f[w],j.ref.impl=j.nextImpl;break;case 11:case 15:break;case 1:if((f&1024)!==0&&L!==null){f=void 0,w=g,j=L.memoizedProps,L=L.memoizedState,E=w.stateNode;try{var Gt=ff(w.type,j);f=E.getSnapshotBeforeUpdate(Gt,L),E.__reactInternalSnapshotBeforeUpdate=f}catch(mn){xr(w,w.return,mn)}}break;case 3:if((f&1024)!==0){if(f=g.stateNode.containerInfo,w=f.nodeType,w===9)VE(f);else if(w===1)switch(f.nodeName){case"HEAD":case"HTML":case"BODY":VE(f);break;default:f.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((f&1024)!==0)throw Error(r(163))}if(f=g.sibling,f!==null){f.return=g.return,fa=f;break}fa=g.return}}function F5(f,g,w){var E=w.flags;switch(w.tag){case 0:case 11:case 15:Wc(f,w),E&4&&gx(5,w);break;case 1:if(Wc(f,w),E&4)if(f=w.stateNode,g===null)try{f.componentDidMount()}catch(te){xr(w,w.return,te)}else{var j=ff(w.type,g.memoizedProps);g=g.memoizedState;try{f.componentDidUpdate(j,g,f.__reactInternalSnapshotBeforeUpdate)}catch(te){xr(w,w.return,te)}}E&64&&P5(w),E&512&&bx(w,w.return);break;case 3:if(Wc(f,w),E&64&&(f=w.updateQueue,f!==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{wI(f,g)}catch(te){xr(w,w.return,te)}}break;case 27:g===null&&E&4&&O5(w);case 26:case 5:Wc(f,w),g===null&&E&4&&D5(w),E&512&&bx(w,w.return);break;case 12:Wc(f,w);break;case 31:Wc(f,w),E&4&&U5(f,w);break;case 13:Wc(f,w),E&4&&B5(f,w),E&64&&(f=w.memoizedState,f!==null&&(f=f.dehydrated,f!==null&&(w=uae.bind(null,w),Cae(f,w))));break;case 22:if(E=w.memoizedState!==null||Gc,!E){g=g!==null&&g.memoizedState!==null||Ri,j=Gc;var L=Ri;Gc=E,(Ri=g)&&!L?Kc(f,w,(w.subtreeFlags&8772)!==0):Wc(f,w),Gc=j,Ri=L}break;case 30:break;default:Wc(f,w)}}function I5(f){var g=f.alternate;g!==null&&(f.alternate=null,I5(g)),f.child=null,f.deletions=null,f.sibling=null,f.tag===5&&(g=f.stateNode,g!==null&&at(g)),f.stateNode=null,f.return=null,f.dependencies=null,f.memoizedProps=null,f.memoizedState=null,f.pendingProps=null,f.stateNode=null,f.updateQueue=null}var ti=null,js=!1;function qc(f,g,w){for(w=w.child;w!==null;)z5(f,g,w),w=w.sibling}function z5(f,g,w){if(be&&typeof be.onCommitFiberUnmount=="function")try{be.onCommitFiberUnmount(Ue,w)}catch{}switch(w.tag){case 26:Ri||Ql(w,g),qc(f,g,w),w.memoizedState?w.memoizedState.count--:w.stateNode&&(w=w.stateNode,w.parentNode.removeChild(w));break;case 27:Ri||Ql(w,g);var E=ti,j=js;Md(w.type)&&(ti=w.stateNode,js=!1),qc(f,g,w),Mx(w.stateNode),ti=E,js=j;break;case 5:Ri||Ql(w,g);case 6:if(E=ti,j=js,ti=null,qc(f,g,w),ti=E,js=j,ti!==null)if(js)try{(ti.nodeType===9?ti.body:ti.nodeName==="HTML"?ti.ownerDocument.body:ti).removeChild(w.stateNode)}catch(L){xr(w,g,L)}else try{ti.removeChild(w.stateNode)}catch(L){xr(w,g,L)}break;case 18:ti!==null&&(js?(f=ti,Pz(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,w.stateNode),wp(f)):Pz(ti,w.stateNode));break;case 4:E=ti,j=js,ti=w.stateNode.containerInfo,js=!0,qc(f,g,w),ti=E,js=j;break;case 0:case 11:case 14:case 15:yd(2,w,g),Ri||yd(4,w,g),qc(f,g,w);break;case 1:Ri||(Ql(w,g),E=w.stateNode,typeof E.componentWillUnmount=="function"&&j5(w,g,E)),qc(f,g,w);break;case 21:qc(f,g,w);break;case 22:Ri=(E=Ri)||w.memoizedState!==null,qc(f,g,w),Ri=E;break;default:qc(f,g,w)}}function U5(f,g){if(g.memoizedState===null&&(f=g.alternate,f!==null&&(f=f.memoizedState,f!==null))){f=f.dehydrated;try{wp(f)}catch(w){xr(g,g.return,w)}}}function B5(f,g){if(g.memoizedState===null&&(f=g.alternate,f!==null&&(f=f.memoizedState,f!==null&&(f=f.dehydrated,f!==null))))try{wp(f)}catch(w){xr(g,g.return,w)}}function nae(f){switch(f.tag){case 31:case 13:case 19:var g=f.stateNode;return g===null&&(g=f.stateNode=new L5),g;case 22:return f=f.stateNode,g=f._retryCache,g===null&&(g=f._retryCache=new L5),g;default:throw Error(r(435,f.tag))}}function pw(f,g){var w=nae(f);g.forEach(function(E){if(!w.has(E)){w.add(E);var j=dae.bind(null,f,E);E.then(j,j)}})}function Ds(f,g){var w=g.deletions;if(w!==null)for(var E=0;E<w.length;E++){var j=w[E],L=f,te=g,ye=te;e:for(;ye!==null;){switch(ye.tag){case 27:if(Md(ye.type)){ti=ye.stateNode,js=!1;break e}break;case 5:ti=ye.stateNode,js=!1;break e;case 3:case 4:ti=ye.stateNode.containerInfo,js=!0;break e}ye=ye.return}if(ti===null)throw Error(r(160));z5(L,te,j),ti=null,js=!1,L=j.alternate,L!==null&&(L.return=null),j.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)H5(g,f),g=g.sibling}var Sl=null;function H5(f,g){var w=f.alternate,E=f.flags;switch(f.tag){case 0:case 11:case 14:case 15:Ds(g,f),Rs(f),E&4&&(yd(3,f,f.return),gx(3,f),yd(5,f,f.return));break;case 1:Ds(g,f),Rs(f),E&512&&(Ri||w===null||Ql(w,w.return)),E&64&&Gc&&(f=f.updateQueue,f!==null&&(E=f.callbacks,E!==null&&(w=f.shared.hiddenCallbacks,f.shared.hiddenCallbacks=w===null?E:w.concat(E))));break;case 26:var j=Sl;if(Ds(g,f),Rs(f),E&512&&(Ri||w===null||Ql(w,w.return)),E&4){var L=w!==null?w.memoizedState:null;if(E=f.memoizedState,w===null)if(E===null)if(f.stateNode===null){e:{E=f.type,w=f.memoizedProps,j=j.ownerDocument||j;t:switch(E){case"title":L=j.getElementsByTagName("title")[0],(!L||L[mt]||L[Xt]||L.namespaceURI==="http://www.w3.org/2000/svg"||L.hasAttribute("itemprop"))&&(L=j.createElement(E),j.head.insertBefore(L,j.querySelector("head > title"))),Pa(L,E,w),L[Xt]=f,He(L),E=L;break e;case"link":var te=Hz("link","href",j).get(E+(w.href||""));if(te){for(var ye=0;ye<te.length;ye++)if(L=te[ye],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)){te.splice(ye,1);break t}}L=j.createElement(E),Pa(L,E,w),j.head.appendChild(L);break;case"meta":if(te=Hz("meta","content",j).get(E+(w.content||""))){for(ye=0;ye<te.length;ye++)if(L=te[ye],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)){te.splice(ye,1);break t}}L=j.createElement(E),Pa(L,E,w),j.head.appendChild(L);break;default:throw Error(r(468,E))}L[Xt]=f,He(L),E=L}f.stateNode=E}else $z(j,f.type,f.stateNode);else f.stateNode=Bz(j,E,f.memoizedProps);else L!==E?(L===null?w.stateNode!==null&&(w=w.stateNode,w.parentNode.removeChild(w)):L.count--,E===null?$z(j,f.type,f.stateNode):Bz(j,E,f.memoizedProps)):E===null&&f.stateNode!==null&&gE(f,f.memoizedProps,w.memoizedProps)}break;case 27:Ds(g,f),Rs(f),E&512&&(Ri||w===null||Ql(w,w.return)),w!==null&&E&4&&gE(f,f.memoizedProps,w.memoizedProps);break;case 5:if(Ds(g,f),Rs(f),E&512&&(Ri||w===null||Ql(w,w.return)),f.flags&32){j=f.stateNode;try{rr(j,"")}catch(Gt){xr(f,f.return,Gt)}}E&4&&f.stateNode!=null&&(j=f.memoizedProps,gE(f,j,w!==null?w.memoizedProps:j)),E&1024&&(yE=!0);break;case 6:if(Ds(g,f),Rs(f),E&4){if(f.stateNode===null)throw Error(r(162));E=f.memoizedProps,w=f.stateNode;try{w.nodeValue=E}catch(Gt){xr(f,f.return,Gt)}}break;case 3:if(Pw=null,j=Sl,Sl=Aw(g.containerInfo),Ds(g,f),Sl=j,Rs(f),E&4&&w!==null&&w.memoizedState.isDehydrated)try{wp(g.containerInfo)}catch(Gt){xr(f,f.return,Gt)}yE&&(yE=!1,$5(f));break;case 4:E=Sl,Sl=Aw(f.stateNode.containerInfo),Ds(g,f),Rs(f),Sl=E;break;case 12:Ds(g,f),Rs(f);break;case 31:Ds(g,f),Rs(f),E&4&&(E=f.updateQueue,E!==null&&(f.updateQueue=null,pw(f,E)));break;case 13:Ds(g,f),Rs(f),f.child.flags&8192&&f.memoizedState!==null!=(w!==null&&w.memoizedState!==null)&&(bw=O()),E&4&&(E=f.updateQueue,E!==null&&(f.updateQueue=null,pw(f,E)));break;case 22:j=f.memoizedState!==null;var Be=w!==null&&w.memoizedState!==null,ct=Gc,vt=Ri;if(Gc=ct||j,Ri=vt||Be,Ds(g,f),Ri=vt,Gc=ct,Rs(f),E&8192)e:for(g=f.stateNode,g._visibility=j?g._visibility&-2:g._visibility|1,j&&(w===null||Be||Gc||Ri||mf(f)),w=null,g=f;;){if(g.tag===5||g.tag===26){if(w===null){Be=w=g;try{if(L=Be.stateNode,j)te=L.style,typeof te.setProperty=="function"?te.setProperty("display","none","important"):te.display="none";else{ye=Be.stateNode;var Nt=Be.memoizedProps.style,ft=Nt!=null&&Nt.hasOwnProperty("display")?Nt.display:null;ye.style.display=ft==null||typeof ft=="boolean"?"":(""+ft).trim()}}catch(Gt){xr(Be,Be.return,Gt)}}}else if(g.tag===6){if(w===null){Be=g;try{Be.stateNode.nodeValue=j?"":Be.memoizedProps}catch(Gt){xr(Be,Be.return,Gt)}}}else if(g.tag===18){if(w===null){Be=g;try{var bt=Be.stateNode;j?jz(bt,!0):jz(Be.stateNode,!1)}catch(Gt){xr(Be,Be.return,Gt)}}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===f)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===f)break e;for(;g.sibling===null;){if(g.return===null||g.return===f)break e;w===g&&(w=null),g=g.return}w===g&&(w=null),g.sibling.return=g.return,g=g.sibling}E&4&&(E=f.updateQueue,E!==null&&(w=E.retryQueue,w!==null&&(E.retryQueue=null,pw(f,w))));break;case 19:Ds(g,f),Rs(f),E&4&&(E=f.updateQueue,E!==null&&(f.updateQueue=null,pw(f,E)));break;case 30:break;case 21:break;default:Ds(g,f),Rs(f)}}function Rs(f){var g=f.flags;if(g&2){try{for(var w,E=f.return;E!==null;){if(R5(E)){w=E;break}E=E.return}if(w==null)throw Error(r(160));switch(w.tag){case 27:var j=w.stateNode,L=bE(f);mw(f,L,j);break;case 5:var te=w.stateNode;w.flags&32&&(rr(te,""),w.flags&=-33);var ye=bE(f);mw(f,ye,te);break;case 3:case 4:var Be=w.stateNode.containerInfo,ct=bE(f);xE(f,ct,Be);break;default:throw Error(r(161))}}catch(vt){xr(f,f.return,vt)}f.flags&=-3}g&4096&&(f.flags&=-4097)}function $5(f){if(f.subtreeFlags&1024)for(f=f.child;f!==null;){var g=f;$5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),f=f.sibling}}function Wc(f,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)F5(f,g.alternate,g),g=g.sibling}function mf(f){for(f=f.child;f!==null;){var g=f;switch(g.tag){case 0:case 11:case 14:case 15:yd(4,g,g.return),mf(g);break;case 1:Ql(g,g.return);var w=g.stateNode;typeof w.componentWillUnmount=="function"&&j5(g,g.return,w),mf(g);break;case 27:Mx(g.stateNode);case 26:case 5:Ql(g,g.return),mf(g);break;case 22:g.memoizedState===null&&mf(g);break;case 30:mf(g);break;default:mf(g)}f=f.sibling}}function Kc(f,g,w){for(w=w&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var E=g.alternate,j=f,L=g,te=L.flags;switch(L.tag){case 0:case 11:case 15:Kc(j,L,w),gx(4,L);break;case 1:if(Kc(j,L,w),E=L,j=E.stateNode,typeof j.componentDidMount=="function")try{j.componentDidMount()}catch(ct){xr(E,E.return,ct)}if(E=L,j=E.updateQueue,j!==null){var ye=E.stateNode;try{var Be=j.shared.hiddenCallbacks;if(Be!==null)for(j.shared.hiddenCallbacks=null,j=0;j<Be.length;j++)vI(Be[j],ye)}catch(ct){xr(E,E.return,ct)}}w&&te&64&&P5(L),bx(L,L.return);break;case 27:O5(L);case 26:case 5:Kc(j,L,w),w&&E===null&&te&4&&D5(L),bx(L,L.return);break;case 12:Kc(j,L,w);break;case 31:Kc(j,L,w),w&&te&4&&U5(j,L);break;case 13:Kc(j,L,w),w&&te&4&&B5(j,L);break;case 22:L.memoizedState===null&&Kc(j,L,w),bx(L,L.return);break;case 30:break;default:Kc(j,L,w)}g=g.sibling}}function vE(f,g){var w=null;f!==null&&f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(w=f.memoizedState.cachePool.pool),f=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(f=g.memoizedState.cachePool.pool),f!==w&&(f!=null&&f.refCount++,w!=null&&rx(w))}function wE(f,g){f=null,g.alternate!==null&&(f=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==f&&(g.refCount++,f!=null&&rx(f))}function Nl(f,g,w,E){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)V5(f,g,w,E),g=g.sibling}function V5(f,g,w,E){var j=g.flags;switch(g.tag){case 0:case 11:case 15:Nl(f,g,w,E),j&2048&&gx(9,g);break;case 1:Nl(f,g,w,E);break;case 3:Nl(f,g,w,E),j&2048&&(f=null,g.alternate!==null&&(f=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==f&&(g.refCount++,f!=null&&rx(f)));break;case 12:if(j&2048){Nl(f,g,w,E),f=g.stateNode;try{var L=g.memoizedProps,te=L.id,ye=L.onPostCommit;typeof ye=="function"&&ye(te,g.alternate===null?"mount":"update",f.passiveEffectDuration,-0)}catch(Be){xr(g,g.return,Be)}}else Nl(f,g,w,E);break;case 31:Nl(f,g,w,E);break;case 13:Nl(f,g,w,E);break;case 23:break;case 22:L=g.stateNode,te=g.alternate,g.memoizedState!==null?L._visibility&2?Nl(f,g,w,E):xx(f,g):L._visibility&2?Nl(f,g,w,E):(L._visibility|=2,up(f,g,w,E,(g.subtreeFlags&10256)!==0||!1)),j&2048&&vE(te,g);break;case 24:Nl(f,g,w,E),j&2048&&wE(g.alternate,g);break;default:Nl(f,g,w,E)}}function up(f,g,w,E,j){for(j=j&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var L=f,te=g,ye=w,Be=E,ct=te.flags;switch(te.tag){case 0:case 11:case 15:up(L,te,ye,Be,j),gx(8,te);break;case 23:break;case 22:var vt=te.stateNode;te.memoizedState!==null?vt._visibility&2?up(L,te,ye,Be,j):xx(L,te):(vt._visibility|=2,up(L,te,ye,Be,j)),j&&ct&2048&&vE(te.alternate,te);break;case 24:up(L,te,ye,Be,j),j&&ct&2048&&wE(te.alternate,te);break;default:up(L,te,ye,Be,j)}g=g.sibling}}function xx(f,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var w=f,E=g,j=E.flags;switch(E.tag){case 22:xx(w,E),j&2048&&vE(E.alternate,E);break;case 24:xx(w,E),j&2048&&wE(E.alternate,E);break;default:xx(w,E)}g=g.sibling}}var yx=8192;function dp(f,g,w){if(f.subtreeFlags&yx)for(f=f.child;f!==null;)G5(f,g,w),f=f.sibling}function G5(f,g,w){switch(f.tag){case 26:dp(f,g,w),f.flags&yx&&f.memoizedState!==null&&Hae(w,Sl,f.memoizedState,f.memoizedProps);break;case 5:dp(f,g,w);break;case 3:case 4:var E=Sl;Sl=Aw(f.stateNode.containerInfo),dp(f,g,w),Sl=E;break;case 22:f.memoizedState===null&&(E=f.alternate,E!==null&&E.memoizedState!==null?(E=yx,yx=16777216,dp(f,g,w),yx=E):dp(f,g,w));break;default:dp(f,g,w)}}function q5(f){var g=f.alternate;if(g!==null&&(f=g.child,f!==null)){g.child=null;do g=f.sibling,f.sibling=null,f=g;while(f!==null)}}function vx(f){var g=f.deletions;if((f.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var E=g[w];fa=E,K5(E,f)}q5(f)}if(f.subtreeFlags&10256)for(f=f.child;f!==null;)W5(f),f=f.sibling}function W5(f){switch(f.tag){case 0:case 11:case 15:vx(f),f.flags&2048&&yd(9,f,f.return);break;case 3:vx(f);break;case 12:vx(f);break;case 22:var g=f.stateNode;f.memoizedState!==null&&g._visibility&2&&(f.return===null||f.return.tag!==13)?(g._visibility&=-3,gw(f)):vx(f);break;default:vx(f)}}function gw(f){var g=f.deletions;if((f.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var E=g[w];fa=E,K5(E,f)}q5(f)}for(f=f.child;f!==null;){switch(g=f,g.tag){case 0:case 11:case 15:yd(8,g,g.return),gw(g);break;case 22:w=g.stateNode,w._visibility&2&&(w._visibility&=-3,gw(g));break;default:gw(g)}f=f.sibling}}function K5(f,g){for(;fa!==null;){var w=fa;switch(w.tag){case 0:case 11:case 15:yd(8,w,g);break;case 23:case 22:if(w.memoizedState!==null&&w.memoizedState.cachePool!==null){var E=w.memoizedState.cachePool.pool;E!=null&&E.refCount++}break;case 24:rx(w.memoizedState.cache)}if(E=w.child,E!==null)E.return=w,fa=E;else e:for(w=f;fa!==null;){E=fa;var j=E.sibling,L=E.return;if(I5(E),E===w){fa=null;break e}if(j!==null){j.return=L,fa=j;break e}fa=L}}}var rae={getCacheForType:function(f){var g=Aa(Pi),w=g.data.get(f);return w===void 0&&(w=f(),g.data.set(f,w)),w},cacheSignal:function(){return Aa(Pi).controller.signal}},iae=typeof WeakMap=="function"?WeakMap:Map,dr=0,Fr=null,Hn=null,qn=0,br=0,so=null,vd=!1,hp=!1,_E=!1,Xc=0,mi=0,wd=0,pf=0,SE=0,oo=0,fp=0,wx=null,Os=null,NE=!1,bw=0,X5=0,xw=1/0,yw=null,_d=null,Ki=0,Sd=null,mp=null,Yc=0,kE=0,ME=null,Y5=null,_x=0,EE=null;function lo(){return(dr&2)!==0&&qn!==0?qn&-qn:G.T!==null?DE():ur()}function Q5(){if(oo===0)if((qn&536870912)===0||Xn){var f=Ae;Ae<<=1,(Ae&3932160)===0&&(Ae=262144),oo=f}else oo=536870912;return f=io.current,f!==null&&(f.flags|=32),oo}function Ls(f,g,w){(f===Fr&&(br===2||br===9)||f.cancelPendingCommit!==null)&&(pp(f,0),Nd(f,qn,oo,!1)),fn(f,w),((dr&2)===0||f!==Fr)&&(f===Fr&&((dr&2)===0&&(pf|=w),mi===4&&Nd(f,qn,oo,!1)),Zl(f))}function Z5(f,g,w){if((dr&6)!==0)throw Error(r(327));var E=!w&&(g&127)===0&&(g&f.expiredLanes)===0||we(f,g),j=E?oae(f,g):AE(f,g,!0),L=E;do{if(j===0){hp&&!E&&Nd(f,g,0,!1);break}else{if(w=f.current.alternate,L&&!aae(w)){j=AE(f,g,!1),L=!1;continue}if(j===2){if(L=g,f.errorRecoveryDisabledLanes&L)var te=0;else te=f.pendingLanes&-536870913,te=te!==0?te:te&536870912?536870912:0;if(te!==0){g=te;e:{var ye=f;j=wx;var Be=ye.current.memoizedState.isDehydrated;if(Be&&(pp(ye,te).flags|=256),te=AE(ye,te,!1),te!==2){if(_E&&!Be){ye.errorRecoveryDisabledLanes|=L,pf|=L,j=4;break e}L=Os,Os=j,L!==null&&(Os===null?Os=L:Os.push.apply(Os,L))}j=te}if(L=!1,j!==2)continue}}if(j===1){pp(f,0),Nd(f,g,0,!0);break}e:{switch(E=f,L=j,L){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:Nd(E,g,oo,!vd);break e;case 2:Os=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(j=bw+300-O(),10<j)){if(Nd(E,g,oo,!vd),Re(E,0,!0)!==0)break e;Yc=g,E.timeoutHandle=Az(J5.bind(null,E,w,Os,yw,NE,g,oo,pf,fp,vd,L,"Throttled",-0,0),j);break e}J5(E,w,Os,yw,NE,g,oo,pf,fp,vd,L,null,-0,0)}}break}while(!0);Zl(f)}function J5(f,g,w,E,j,L,te,ye,Be,ct,vt,Nt,ft,bt){if(f.timeoutHandle=-1,Nt=g.subtreeFlags,Nt&8192||(Nt&16785408)===16785408){Nt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ma},G5(g,L,Nt);var Gt=(L&62914560)===L?bw-O():(L&4194048)===L?X5-O():0;if(Gt=$ae(Nt,Gt),Gt!==null){Yc=L,f.cancelPendingCommit=Gt(oz.bind(null,f,g,L,w,E,j,te,ye,Be,vt,Nt,null,ft,bt)),Nd(f,L,te,!ct);return}}oz(f,g,L,w,E,j,te,ye,Be)}function aae(f){for(var g=f;;){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 E=0;E<w.length;E++){var j=w[E],L=j.getSnapshot;j=j.value;try{if(!no(L(),j))return!1}catch{return!1}}if(w=g.child,g.subtreeFlags&16384&&w!==null)w.return=g,g=w;else{if(g===f)break;for(;g.sibling===null;){if(g.return===null||g.return===f)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function Nd(f,g,w,E){g&=~SE,g&=~pf,f.suspendedLanes|=g,f.pingedLanes&=~g,E&&(f.warmLanes|=g),E=f.expirationTimes;for(var j=g;0<j;){var L=31-ze(j),te=1<<L;E[L]=-1,j&=~te}w!==0&&Oe(f,w,g)}function vw(){return(dr&6)===0?(Sx(0),!1):!0}function TE(){if(Hn!==null){if(br===0)var f=Hn.return;else f=Hn,zc=sf=null,V2(f),ap=null,ax=0,f=Hn;for(;f!==null;)C5(f.alternate,f),f=f.return;Hn=null}}function pp(f,g){var w=f.timeoutHandle;w!==-1&&(f.timeoutHandle=-1,kae(w)),w=f.cancelPendingCommit,w!==null&&(f.cancelPendingCommit=null,w()),Yc=0,TE(),Fr=f,Hn=w=Fc(f.current,null),qn=g,br=0,so=null,vd=!1,hp=we(f,g),_E=!1,fp=oo=SE=pf=wd=mi=0,Os=wx=null,NE=!1,(g&8)!==0&&(g|=g&32);var E=f.entangledLanes;if(E!==0)for(f=f.entanglements,E&=g;0<E;){var j=31-ze(E),L=1<<j;g|=f[j],E&=~L}return Xc=g,Bv(),w}function ez(f,g){Tn=null,G.H=fx,g===ip||g===Xv?(g=gI(),br=3):g===j2?(g=gI(),br=4):br=g===sE?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,so=g,Hn===null&&(mi=1,cw(f,Ro(g,f.current)))}function tz(){var f=io.current;return f===null?!0:(qn&4194048)===qn?Io===null:(qn&62914560)===qn||(qn&536870912)!==0?f===Io:!1}function nz(){var f=G.H;return G.H=fx,f===null?fx:f}function rz(){var f=G.A;return G.A=rae,f}function ww(){mi=4,vd||(qn&4194048)!==qn&&io.current!==null||(hp=!0),(wd&134217727)===0&&(pf&134217727)===0||Fr===null||Nd(Fr,qn,oo,!1)}function AE(f,g,w){var E=dr;dr|=2;var j=nz(),L=rz();(Fr!==f||qn!==g)&&(yw=null,pp(f,g)),g=!1;var te=mi;e:do try{if(br!==0&&Hn!==null){var ye=Hn,Be=so;switch(br){case 8:TE(),te=6;break e;case 3:case 2:case 9:case 6:io.current===null&&(g=!0);var ct=br;if(br=0,so=null,gp(f,ye,Be,ct),w&&hp){te=0;break e}break;default:ct=br,br=0,so=null,gp(f,ye,Be,ct)}}sae(),te=mi;break}catch(vt){ez(f,vt)}while(!0);return g&&f.shellSuspendCounter++,zc=sf=null,dr=E,G.H=j,G.A=L,Hn===null&&(Fr=null,qn=0,Bv()),te}function sae(){for(;Hn!==null;)iz(Hn)}function oae(f,g){var w=dr;dr|=2;var E=nz(),j=rz();Fr!==f||qn!==g?(yw=null,xw=O()+500,pp(f,g)):hp=we(f,g);e:do try{if(br!==0&&Hn!==null){g=Hn;var L=so;t:switch(br){case 1:br=0,so=null,gp(f,g,L,1);break;case 2:case 9:if(mI(L)){br=0,so=null,az(g);break}g=function(){br!==2&&br!==9||Fr!==f||(br=7),Zl(f)},L.then(g,g);break e;case 3:br=7;break e;case 4:br=5;break e;case 7:mI(L)?(br=0,so=null,az(g)):(br=0,so=null,gp(f,g,L,7));break;case 5:var te=null;switch(Hn.tag){case 26:te=Hn.memoizedState;case 5:case 27:var ye=Hn;if(te?Vz(te):ye.stateNode.complete){br=0,so=null;var Be=ye.sibling;if(Be!==null)Hn=Be;else{var ct=ye.return;ct!==null?(Hn=ct,_w(ct)):Hn=null}break t}}br=0,so=null,gp(f,g,L,5);break;case 6:br=0,so=null,gp(f,g,L,6);break;case 8:TE(),mi=6;break e;default:throw Error(r(462))}}lae();break}catch(vt){ez(f,vt)}while(!0);return zc=sf=null,G.H=E,G.A=j,dr=w,Hn!==null?0:(Fr=null,qn=0,Bv(),mi)}function lae(){for(;Hn!==null&&!ee();)iz(Hn)}function iz(f){var g=T5(f.alternate,f,Xc);f.memoizedProps=f.pendingProps,g===null?_w(f):Hn=g}function az(f){var g=f,w=g.alternate;switch(g.tag){case 15:case 0:g=_5(w,g,g.pendingProps,g.type,void 0,qn);break;case 11:g=_5(w,g,g.pendingProps,g.type.render,g.ref,qn);break;case 5:V2(g);default:C5(w,g),g=Hn=rI(g,Xc),g=T5(w,g,Xc)}f.memoizedProps=f.pendingProps,g===null?_w(f):Hn=g}function gp(f,g,w,E){zc=sf=null,V2(g),ap=null,ax=0;var j=g.return;try{if(Yie(f,j,g,w,qn)){mi=1,cw(f,Ro(w,f.current)),Hn=null;return}}catch(L){if(j!==null)throw Hn=j,L;mi=1,cw(f,Ro(w,f.current)),Hn=null;return}g.flags&32768?(Xn||E===1?f=!0:hp||(qn&536870912)!==0?f=!1:(vd=f=!0,(E===2||E===9||E===3||E===6)&&(E=io.current,E!==null&&E.tag===13&&(E.flags|=16384))),sz(g,f)):_w(g)}function _w(f){var g=f;do{if((g.flags&32768)!==0){sz(g,vd);return}f=g.return;var w=Jie(g.alternate,g,Xc);if(w!==null){Hn=w;return}if(g=g.sibling,g!==null){Hn=g;return}Hn=g=f}while(g!==null);mi===0&&(mi=5)}function sz(f,g){do{var w=eae(f.alternate,f);if(w!==null){w.flags&=32767,Hn=w;return}if(w=f.return,w!==null&&(w.flags|=32768,w.subtreeFlags=0,w.deletions=null),!g&&(f=f.sibling,f!==null)){Hn=f;return}Hn=f=w}while(f!==null);mi=6,Hn=null}function oz(f,g,w,E,j,L,te,ye,Be){f.cancelPendingCommit=null;do Sw();while(Ki!==0);if((dr&6)!==0)throw Error(r(327));if(g!==null){if(g===f.current)throw Error(r(177));if(L=g.lanes|g.childLanes,L|=b2,It(f,w,L,te,ye,Be),f===Fr&&(Hn=Fr=null,qn=0),mp=g,Sd=f,Yc=w,kE=L,ME=j,Y5=E,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(f.callbackNode=null,f.callbackPriority=0,hae(ke,function(){return hz(),null})):(f.callbackNode=null,f.callbackPriority=0),E=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||E){E=G.T,G.T=null,j=I.p,I.p=2,te=dr,dr|=4;try{tae(f,g,w)}finally{dr=te,I.p=j,G.T=E}}Ki=1,lz(),cz(),uz()}}function lz(){if(Ki===1){Ki=0;var f=Sd,g=mp,w=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||w){w=G.T,G.T=null;var E=I.p;I.p=2;var j=dr;dr|=4;try{H5(g,f);var L=BE,te=KF(f.containerInfo),ye=L.focusedElem,Be=L.selectionRange;if(te!==ye&&ye&&ye.ownerDocument&&WF(ye.ownerDocument.documentElement,ye)){if(Be!==null&&h2(ye)){var ct=Be.start,vt=Be.end;if(vt===void 0&&(vt=ct),"selectionStart"in ye)ye.selectionStart=ct,ye.selectionEnd=Math.min(vt,ye.value.length);else{var Nt=ye.ownerDocument||document,ft=Nt&&Nt.defaultView||window;if(ft.getSelection){var bt=ft.getSelection(),Gt=ye.textContent.length,mn=Math.min(Be.start,Gt),Mr=Be.end===void 0?mn:Math.min(Be.end,Gt);!bt.extend&&mn>Mr&&(te=Mr,Mr=mn,mn=te);var et=qF(ye,mn),We=qF(ye,Mr);if(et&&We&&(bt.rangeCount!==1||bt.anchorNode!==et.node||bt.anchorOffset!==et.offset||bt.focusNode!==We.node||bt.focusOffset!==We.offset)){var ot=Nt.createRange();ot.setStart(et.node,et.offset),bt.removeAllRanges(),mn>Mr?(bt.addRange(ot),bt.extend(We.node,We.offset)):(ot.setEnd(We.node,We.offset),bt.addRange(ot))}}}}for(Nt=[],bt=ye;bt=bt.parentNode;)bt.nodeType===1&&Nt.push({element:bt,left:bt.scrollLeft,top:bt.scrollTop});for(typeof ye.focus=="function"&&ye.focus(),ye=0;ye<Nt.length;ye++){var wt=Nt[ye];wt.element.scrollLeft=wt.left,wt.element.scrollTop=wt.top}}Ow=!!UE,BE=UE=null}finally{dr=j,I.p=E,G.T=w}}f.current=g,Ki=2}}function cz(){if(Ki===2){Ki=0;var f=Sd,g=mp,w=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||w){w=G.T,G.T=null;var E=I.p;I.p=2;var j=dr;dr|=4;try{F5(f,g.alternate,g)}finally{dr=j,I.p=E,G.T=w}}Ki=3}}function uz(){if(Ki===4||Ki===3){Ki=0,z();var f=Sd,g=mp,w=Yc,E=Y5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?Ki=5:(Ki=0,mp=Sd=null,dz(f,f.pendingLanes));var j=f.pendingLanes;if(j===0&&(_d=null),Qt(w),g=g.stateNode,be&&typeof be.onCommitFiberRoot=="function")try{be.onCommitFiberRoot(Ue,g,void 0,(g.current.flags&128)===128)}catch{}if(E!==null){g=G.T,j=I.p,I.p=2,G.T=null;try{for(var L=f.onRecoverableError,te=0;te<E.length;te++){var ye=E[te];L(ye.value,{componentStack:ye.stack})}}finally{G.T=g,I.p=j}}(Yc&3)!==0&&Sw(),Zl(f),j=f.pendingLanes,(w&261930)!==0&&(j&42)!==0?f===EE?_x++:(_x=0,EE=f):_x=0,Sx(0)}}function dz(f,g){(f.pooledCacheLanes&=g)===0&&(g=f.pooledCache,g!=null&&(f.pooledCache=null,rx(g)))}function Sw(){return lz(),cz(),uz(),hz()}function hz(){if(Ki!==5)return!1;var f=Sd,g=kE;kE=0;var w=Qt(Yc),E=G.T,j=I.p;try{I.p=32>w?32:w,G.T=null,w=ME,ME=null;var L=Sd,te=Yc;if(Ki=0,mp=Sd=null,Yc=0,(dr&6)!==0)throw Error(r(331));var ye=dr;if(dr|=4,W5(L.current),V5(L,L.current,te,w),dr=ye,Sx(0,!1),be&&typeof be.onPostCommitFiberRoot=="function")try{be.onPostCommitFiberRoot(Ue,L)}catch{}return!0}finally{I.p=j,G.T=E,dz(f,g)}}function fz(f,g,w){g=Ro(w,g),g=aE(f.stateNode,g,2),f=gd(f,g,2),f!==null&&(fn(f,2),Zl(f))}function xr(f,g,w){if(f.tag===3)fz(f,f,w);else for(;g!==null;){if(g.tag===3){fz(g,f,w);break}else if(g.tag===1){var E=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof E.componentDidCatch=="function"&&(_d===null||!_d.has(E))){f=Ro(w,f),w=m5(2),E=gd(g,w,2),E!==null&&(p5(w,E,g,f),fn(E,2),Zl(E));break}}g=g.return}}function CE(f,g,w){var E=f.pingCache;if(E===null){E=f.pingCache=new iae;var j=new Set;E.set(g,j)}else j=E.get(g),j===void 0&&(j=new Set,E.set(g,j));j.has(w)||(_E=!0,j.add(w),f=cae.bind(null,f,g,w),g.then(f,f))}function cae(f,g,w){var E=f.pingCache;E!==null&&E.delete(g),f.pingedLanes|=f.suspendedLanes&w,f.warmLanes&=~w,Fr===f&&(qn&w)===w&&(mi===4||mi===3&&(qn&62914560)===qn&&300>O()-bw?(dr&2)===0&&pp(f,0):SE|=w,fp===qn&&(fp=0)),Zl(f)}function mz(f,g){g===0&&(g=xt()),f=nf(f,g),f!==null&&(fn(f,g),Zl(f))}function uae(f){var g=f.memoizedState,w=0;g!==null&&(w=g.retryLane),mz(f,w)}function dae(f,g){var w=0;switch(f.tag){case 31:case 13:var E=f.stateNode,j=f.memoizedState;j!==null&&(w=j.retryLane);break;case 19:E=f.stateNode;break;case 22:E=f.stateNode._retryCache;break;default:throw Error(r(314))}E!==null&&E.delete(g),mz(f,w)}function hae(f,g){return le(f,g)}var Nw=null,bp=null,PE=!1,kw=!1,jE=!1,kd=0;function Zl(f){f!==bp&&f.next===null&&(bp===null?Nw=bp=f:bp=bp.next=f),kw=!0,PE||(PE=!0,mae())}function Sx(f,g){if(!jE&&kw){jE=!0;do for(var w=!1,E=Nw;E!==null;){if(f!==0){var j=E.pendingLanes;if(j===0)var L=0;else{var te=E.suspendedLanes,ye=E.pingedLanes;L=(1<<31-ze(42|f)+1)-1,L&=j&~(te&~ye),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(w=!0,xz(E,L))}else L=qn,L=Re(E,E===Fr?L:0,E.cancelPendingCommit!==null||E.timeoutHandle!==-1),(L&3)===0||we(E,L)||(w=!0,xz(E,L));E=E.next}while(w);jE=!1}}function fae(){pz()}function pz(){kw=PE=!1;var f=0;kd!==0&&Nae()&&(f=kd);for(var g=O(),w=null,E=Nw;E!==null;){var j=E.next,L=gz(E,g);L===0?(E.next=null,w===null?Nw=j:w.next=j,j===null&&(bp=w)):(w=E,(f!==0||(L&3)!==0)&&(kw=!0)),E=j}Ki!==0&&Ki!==5||Sx(f),kd!==0&&(kd=0)}function gz(f,g){for(var w=f.suspendedLanes,E=f.pingedLanes,j=f.expirationTimes,L=f.pendingLanes&-62914561;0<L;){var te=31-ze(L),ye=1<<te,Be=j[te];Be===-1?((ye&w)===0||(ye&E)!==0)&&(j[te]=qe(ye,g)):Be<=g&&(f.expiredLanes|=ye),L&=~ye}if(g=Fr,w=qn,w=Re(f,f===g?w:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),E=f.callbackNode,w===0||f===g&&(br===2||br===9)||f.cancelPendingCommit!==null)return E!==null&&E!==null&&pe(E),f.callbackNode=null,f.callbackPriority=0;if((w&3)===0||we(f,w)){if(g=w&-w,g===f.callbackPriority)return g;switch(E!==null&&pe(E),Qt(w)){case 2:case 8:w=Te;break;case 32:w=ke;break;case 268435456:w=Se;break;default:w=ke}return E=bz.bind(null,f),w=le(w,E),f.callbackPriority=g,f.callbackNode=w,g}return E!==null&&E!==null&&pe(E),f.callbackPriority=2,f.callbackNode=null,2}function bz(f,g){if(Ki!==0&&Ki!==5)return f.callbackNode=null,f.callbackPriority=0,null;var w=f.callbackNode;if(Sw()&&f.callbackNode!==w)return null;var E=qn;return E=Re(f,f===Fr?E:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),E===0?null:(Z5(f,E,g),gz(f,O()),f.callbackNode!=null&&f.callbackNode===w?bz.bind(null,f):null)}function xz(f,g){if(Sw())return null;Z5(f,g,!0)}function mae(){Mae(function(){(dr&6)!==0?le(me,fae):pz()})}function DE(){if(kd===0){var f=np;f===0&&(f=Je,Je<<=1,(Je&261888)===0&&(Je=256)),kd=f}return kd}function yz(f){return f==null||typeof f=="symbol"||typeof f=="boolean"?null:typeof f=="function"?f:us(""+f)}function vz(f,g){var w=g.ownerDocument.createElement("input");return w.name=g.name,w.value=g.value,f.id&&w.setAttribute("form",f.id),g.parentNode.insertBefore(w,g),f=new FormData(f),w.parentNode.removeChild(w),f}function pae(f,g,w,E,j){if(g==="submit"&&w&&w.stateNode===j){var L=yz((j[Zn]||null).action),te=E.submitter;te&&(g=(g=te[Zn]||null)?yz(g.formAction):te.getAttribute("formAction"),g!==null&&(L=g,te=null));var ye=new Yh("action","action",null,E,j);f.push({event:ye,listeners:[{instance:null,listener:function(){if(E.defaultPrevented){if(kd!==0){var Be=te?vz(j,te):new FormData(j);J2(w,{pending:!0,data:Be,method:j.method,action:L},null,Be)}}else typeof L=="function"&&(ye.preventDefault(),Be=te?vz(j,te):new FormData(j),J2(w,{pending:!0,data:Be,method:j.method,action:L},L,Be))},currentTarget:j}]})}}for(var RE=0;RE<g2.length;RE++){var OE=g2[RE],gae=OE.toLowerCase(),bae=OE[0].toUpperCase()+OE.slice(1);_l(gae,"on"+bae)}_l(QF,"onAnimationEnd"),_l(ZF,"onAnimationIteration"),_l(JF,"onAnimationStart"),_l("dblclick","onDoubleClick"),_l("focusin","onFocus"),_l("focusout","onBlur"),_l(Die,"onTransitionRun"),_l(Rie,"onTransitionStart"),_l(Oie,"onTransitionCancel"),_l(eI,"onTransitionEnd"),it("onMouseEnter",["mouseout","mouseover"]),it("onMouseLeave",["mouseout","mouseover"]),it("onPointerEnter",["pointerout","pointerover"]),it("onPointerLeave",["pointerout","pointerover"]),ut("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ut("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ut("onBeforeInput",["compositionend","keypress","textInput","paste"]),ut("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ut("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ut("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Nx="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(" "),xae=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Nx));function wz(f,g){g=(g&4)!==0;for(var w=0;w<f.length;w++){var E=f[w],j=E.event;E=E.listeners;e:{var L=void 0;if(g)for(var te=E.length-1;0<=te;te--){var ye=E[te],Be=ye.instance,ct=ye.currentTarget;if(ye=ye.listener,Be!==L&&j.isPropagationStopped())break e;L=ye,j.currentTarget=ct;try{L(j)}catch(vt){Uv(vt)}j.currentTarget=null,L=Be}else for(te=0;te<E.length;te++){if(ye=E[te],Be=ye.instance,ct=ye.currentTarget,ye=ye.listener,Be!==L&&j.isPropagationStopped())break e;L=ye,j.currentTarget=ct;try{L(j)}catch(vt){Uv(vt)}j.currentTarget=null,L=Be}}}}function $n(f,g){var w=g[da];w===void 0&&(w=g[da]=new Set);var E=f+"__bubble";w.has(E)||(_z(g,f,2,!1),w.add(E))}function LE(f,g,w){var E=0;g&&(E|=4),_z(w,f,E,g)}var Mw="_reactListening"+Math.random().toString(36).slice(2);function FE(f){if(!f[Mw]){f[Mw]=!0,ge.forEach(function(w){w!=="selectionchange"&&(xae.has(w)||LE(w,!1,f),LE(w,!0,f))});var g=f.nodeType===9?f:f.ownerDocument;g===null||g[Mw]||(g[Mw]=!0,LE("selectionchange",!1,g))}}function _z(f,g,w,E){switch(Qz(g)){case 2:var j=qae;break;case 8:j=Wae;break;default:j=ZE}w=j.bind(null,g,w,f),j=void 0,!eo||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(j=!0),E?j!==void 0?f.addEventListener(g,w,{capture:!0,passive:j}):f.addEventListener(g,w,!0):j!==void 0?f.addEventListener(g,w,{passive:j}):f.addEventListener(g,w,!1)}function IE(f,g,w,E,j){var L=E;if((g&1)===0&&(g&2)===0&&E!==null)e:for(;;){if(E===null)return;var te=E.tag;if(te===3||te===4){var ye=E.stateNode.containerInfo;if(ye===j)break;if(te===4)for(te=E.return;te!==null;){var Be=te.tag;if((Be===3||Be===4)&&te.stateNode.containerInfo===j)return;te=te.return}for(;ye!==null;){if(te=Dt(ye),te===null)return;if(Be=te.tag,Be===5||Be===6||Be===26||Be===27){E=L=te;continue e}ye=ye.parentNode}}E=E.return}Ps(function(){var ct=L,vt=yl(w),Nt=[];e:{var ft=tI.get(f);if(ft!==void 0){var bt=Yh,Gt=f;switch(f){case"keypress":if(Gm(w)===0)break e;case"keydown":case"keyup":bt=cd;break;case"focusin":Gt="focus",bt=xn;break;case"focusout":Gt="blur",bt=xn;break;case"beforeblur":case"afterblur":bt=xn;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":bt=Jh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":bt=Dv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":bt=jF;break;case QF:case ZF:case JF:bt=Kb;break;case eI:bt=gie;break;case"scroll":case"scrollend":bt=ld;break;case"wheel":bt=xie;break;case"copy":case"cut":case"paste":bt=Xb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":bt=Ga;break;case"toggle":case"beforetoggle":bt=vie}var mn=(g&4)!==0,Mr=!mn&&(f==="scroll"||f==="scrollend"),et=mn?ft!==null?ft+"Capture":null:ft;mn=[];for(var We=ct,ot;We!==null;){var wt=We;if(ot=wt.stateNode,wt=wt.tag,wt!==5&&wt!==26&&wt!==27||ot===null||et===null||(wt=Ea(We,et),wt!=null&&mn.push(kx(We,wt,ot))),Mr)break;We=We.return}0<mn.length&&(ft=new bt(ft,Gt,null,w,vt),Nt.push({event:ft,listeners:mn}))}}if((g&7)===0){e:{if(ft=f==="mouseover"||f==="pointerover",bt=f==="mouseout"||f==="pointerout",ft&&w!==Js&&(Gt=w.relatedTarget||w.fromElement)&&(Dt(Gt)||Gt[oi]))break e;if((bt||ft)&&(ft=vt.window===vt?vt:(ft=vt.ownerDocument)?ft.defaultView||ft.parentWindow:window,bt?(Gt=w.relatedTarget||w.toElement,bt=ct,Gt=Gt?Dt(Gt):null,Gt!==null&&(Mr=s(Gt),mn=Gt.tag,Gt!==Mr||mn!==5&&mn!==27&&mn!==6)&&(Gt=null)):(bt=null,Gt=ct),bt!==Gt)){if(mn=Jh,wt="onMouseLeave",et="onMouseEnter",We="mouse",(f==="pointerout"||f==="pointerover")&&(mn=Ga,wt="onPointerLeave",et="onPointerEnter",We="pointer"),Mr=bt==null?ft:Ie(bt),ot=Gt==null?ft:Ie(Gt),ft=new mn(wt,We+"leave",bt,w,vt),ft.target=Mr,ft.relatedTarget=ot,wt=null,Dt(vt)===ct&&(mn=new mn(et,We+"enter",Gt,w,vt),mn.target=ot,mn.relatedTarget=Mr,wt=mn),Mr=wt,bt&&Gt)t:{for(mn=yae,et=bt,We=Gt,ot=0,wt=et;wt;wt=mn(wt))ot++;wt=0;for(var en=We;en;en=mn(en))wt++;for(;0<ot-wt;)et=mn(et),ot--;for(;0<wt-ot;)We=mn(We),wt--;for(;ot--;){if(et===We||We!==null&&et===We.alternate){mn=et;break t}et=mn(et),We=mn(We)}mn=null}else mn=null;bt!==null&&Sz(Nt,ft,bt,mn,!1),Gt!==null&&Mr!==null&&Sz(Nt,Mr,Gt,mn,!0)}}e:{if(ft=ct?Ie(ct):window,bt=ft.nodeName&&ft.nodeName.toLowerCase(),bt==="select"||bt==="input"&&ft.type==="file")var ar=UF;else if(IF(ft))if(BF)ar=Cie;else{ar=Tie;var Kt=Eie}else bt=ft.nodeName,!bt||bt.toLowerCase()!=="input"||ft.type!=="checkbox"&&ft.type!=="radio"?ct&&Zt(ct.elementType)&&(ar=UF):ar=Aie;if(ar&&(ar=ar(f,ct))){zF(Nt,ar,w,vt);break e}Kt&&Kt(f,ft,ct),f==="focusout"&&ct&&ft.type==="number"&&ct.memoizedProps.value!=null&&Rt(ft,"number",ft.value)}switch(Kt=ct?Ie(ct):window,f){case"focusin":(IF(Kt)||Kt.contentEditable==="true")&&(Km=Kt,f2=ct,ex=null);break;case"focusout":ex=f2=Km=null;break;case"mousedown":m2=!0;break;case"contextmenu":case"mouseup":case"dragend":m2=!1,XF(Nt,w,vt);break;case"selectionchange":if(jie)break;case"keydown":case"keyup":XF(Nt,w,vt)}var An;if(c2)e:{switch(f){case"compositionstart":var Wn="onCompositionStart";break e;case"compositionend":Wn="onCompositionEnd";break e;case"compositionupdate":Wn="onCompositionUpdate";break e}Wn=void 0}else Wm?LF(f,w)&&(Wn="onCompositionEnd"):f==="keydown"&&w.keyCode===229&&(Wn="onCompositionStart");Wn&&(DF&&w.locale!=="ko"&&(Wm||Wn!=="onCompositionStart"?Wn==="onCompositionEnd"&&Wm&&(An=Cv()):(Gr=vt,Wl="value"in Gr?Gr.value:Gr.textContent,Wm=!0)),Kt=Ew(ct,Wn),0<Kt.length&&(Wn=new Fv(Wn,f,null,w,vt),Nt.push({event:Wn,listeners:Kt}),An?Wn.data=An:(An=FF(w),An!==null&&(Wn.data=An)))),(An=_ie?Sie(f,w):Nie(f,w))&&(Wn=Ew(ct,"onBeforeInput"),0<Wn.length&&(Kt=new Fv("onBeforeInput","beforeinput",null,w,vt),Nt.push({event:Kt,listeners:Wn}),Kt.data=An)),pae(Nt,f,ct,w,vt)}wz(Nt,g)})}function kx(f,g,w){return{instance:f,listener:g,currentTarget:w}}function Ew(f,g){for(var w=g+"Capture",E=[];f!==null;){var j=f,L=j.stateNode;if(j=j.tag,j!==5&&j!==26&&j!==27||L===null||(j=Ea(f,w),j!=null&&E.unshift(kx(f,j,L)),j=Ea(f,g),j!=null&&E.push(kx(f,j,L))),f.tag===3)return E;f=f.return}return[]}function yae(f){if(f===null)return null;do f=f.return;while(f&&f.tag!==5&&f.tag!==27);return f||null}function Sz(f,g,w,E,j){for(var L=g._reactName,te=[];w!==null&&w!==E;){var ye=w,Be=ye.alternate,ct=ye.stateNode;if(ye=ye.tag,Be!==null&&Be===E)break;ye!==5&&ye!==26&&ye!==27||ct===null||(Be=ct,j?(ct=Ea(w,L),ct!=null&&te.unshift(kx(w,ct,Be))):j||(ct=Ea(w,L),ct!=null&&te.push(kx(w,ct,Be)))),w=w.return}te.length!==0&&f.push({event:g,listeners:te})}var vae=/\r\n?/g,wae=/\u0000|\uFFFD/g;function Nz(f){return(typeof f=="string"?f:""+f).replace(vae,`
- `).replace(wae,"")}function kz(f,g){return g=Nz(g),Nz(f)===g}function kr(f,g,w,E,j,L){switch(w){case"children":typeof E=="string"?g==="body"||g==="textarea"&&E===""||rr(f,E):(typeof E=="number"||typeof E=="bigint")&&g!=="body"&&rr(f,""+E);break;case"className":Vt(f,"class",E);break;case"tabIndex":Vt(f,"tabindex",E);break;case"dir":case"role":case"viewBox":case"width":case"height":Vt(f,w,E);break;case"style":ei(f,E,L);break;case"data":if(g!=="object"){Vt(f,"data",E);break}case"src":case"href":if(E===""&&(g!=="a"||w!=="href")){f.removeAttribute(w);break}if(E==null||typeof E=="function"||typeof E=="symbol"||typeof E=="boolean"){f.removeAttribute(w);break}E=us(""+E),f.setAttribute(w,E);break;case"action":case"formAction":if(typeof E=="function"){f.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"&&kr(f,g,"name",j.name,j,null),kr(f,g,"formEncType",j.formEncType,j,null),kr(f,g,"formMethod",j.formMethod,j,null),kr(f,g,"formTarget",j.formTarget,j,null)):(kr(f,g,"encType",j.encType,j,null),kr(f,g,"method",j.method,j,null),kr(f,g,"target",j.target,j,null)));if(E==null||typeof E=="symbol"||typeof E=="boolean"){f.removeAttribute(w);break}E=us(""+E),f.setAttribute(w,E);break;case"onClick":E!=null&&(f.onclick=Ma);break;case"onScroll":E!=null&&$n("scroll",f);break;case"onScrollEnd":E!=null&&$n("scrollend",f);break;case"dangerouslySetInnerHTML":if(E!=null){if(typeof E!="object"||!("__html"in E))throw Error(r(61));if(w=E.__html,w!=null){if(j.children!=null)throw Error(r(60));f.innerHTML=w}}break;case"multiple":f.multiple=E&&typeof E!="function"&&typeof E!="symbol";break;case"muted":f.muted=E&&typeof E!="function"&&typeof E!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(E==null||typeof E=="function"||typeof E=="boolean"||typeof E=="symbol"){f.removeAttribute("xlink:href");break}w=us(""+E),f.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":E!=null&&typeof E!="function"&&typeof E!="symbol"?f.setAttribute(w,""+E):f.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":E&&typeof E!="function"&&typeof E!="symbol"?f.setAttribute(w,""):f.removeAttribute(w);break;case"capture":case"download":E===!0?f.setAttribute(w,""):E!==!1&&E!=null&&typeof E!="function"&&typeof E!="symbol"?f.setAttribute(w,E):f.removeAttribute(w);break;case"cols":case"rows":case"size":case"span":E!=null&&typeof E!="function"&&typeof E!="symbol"&&!isNaN(E)&&1<=E?f.setAttribute(w,E):f.removeAttribute(w);break;case"rowSpan":case"start":E==null||typeof E=="function"||typeof E=="symbol"||isNaN(E)?f.removeAttribute(w):f.setAttribute(w,E);break;case"popover":$n("beforetoggle",f),$n("toggle",f),an(f,"popover",E);break;case"xlinkActuate":gn(f,"http://www.w3.org/1999/xlink","xlink:actuate",E);break;case"xlinkArcrole":gn(f,"http://www.w3.org/1999/xlink","xlink:arcrole",E);break;case"xlinkRole":gn(f,"http://www.w3.org/1999/xlink","xlink:role",E);break;case"xlinkShow":gn(f,"http://www.w3.org/1999/xlink","xlink:show",E);break;case"xlinkTitle":gn(f,"http://www.w3.org/1999/xlink","xlink:title",E);break;case"xlinkType":gn(f,"http://www.w3.org/1999/xlink","xlink:type",E);break;case"xmlBase":gn(f,"http://www.w3.org/XML/1998/namespace","xml:base",E);break;case"xmlLang":gn(f,"http://www.w3.org/XML/1998/namespace","xml:lang",E);break;case"xmlSpace":gn(f,"http://www.w3.org/XML/1998/namespace","xml:space",E);break;case"is":an(f,"is",E);break;case"innerText":case"textContent":break;default:(!(2<w.length)||w[0]!=="o"&&w[0]!=="O"||w[1]!=="n"&&w[1]!=="N")&&(w=Sn.get(w)||w,an(f,w,E))}}function zE(f,g,w,E,j,L){switch(w){case"style":ei(f,E,L);break;case"dangerouslySetInnerHTML":if(E!=null){if(typeof E!="object"||!("__html"in E))throw Error(r(61));if(w=E.__html,w!=null){if(j.children!=null)throw Error(r(60));f.innerHTML=w}}break;case"children":typeof E=="string"?rr(f,E):(typeof E=="number"||typeof E=="bigint")&&rr(f,""+E);break;case"onScroll":E!=null&&$n("scroll",f);break;case"onScrollEnd":E!=null&&$n("scrollend",f);break;case"onClick":E!=null&&(f.onclick=Ma);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!rt.hasOwnProperty(w))e:{if(w[0]==="o"&&w[1]==="n"&&(j=w.endsWith("Capture"),g=w.slice(2,j?w.length-7:void 0),L=f[Zn]||null,L=L!=null?L[w]:null,typeof L=="function"&&f.removeEventListener(g,L,j),typeof E=="function")){typeof L!="function"&&L!==null&&(w in f?f[w]=null:f.hasAttribute(w)&&f.removeAttribute(w)),f.addEventListener(g,E,j);break e}w in f?f[w]=E:E===!0?f.setAttribute(w,""):an(f,w,E)}}}function Pa(f,g,w){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":$n("error",f),$n("load",f);var E=!1,j=!1,L;for(L in w)if(w.hasOwnProperty(L)){var te=w[L];if(te!=null)switch(L){case"src":E=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:kr(f,g,L,te,w,null)}}j&&kr(f,g,"srcSet",w.srcSet,w,null),E&&kr(f,g,"src",w.src,w,null);return;case"input":$n("invalid",f);var ye=L=te=j=null,Be=null,ct=null;for(E in w)if(w.hasOwnProperty(E)){var vt=w[E];if(vt!=null)switch(E){case"name":j=vt;break;case"type":te=vt;break;case"checked":Be=vt;break;case"defaultChecked":ct=vt;break;case"value":L=vt;break;case"defaultValue":ye=vt;break;case"children":case"dangerouslySetInnerHTML":if(vt!=null)throw Error(r(137,g));break;default:kr(f,g,E,vt,w,null)}}gt(f,L,ye,Be,ct,te,j,!1);return;case"select":$n("invalid",f),E=te=L=null;for(j in w)if(w.hasOwnProperty(j)&&(ye=w[j],ye!=null))switch(j){case"value":L=ye;break;case"defaultValue":te=ye;break;case"multiple":E=ye;default:kr(f,g,j,ye,w,null)}g=L,w=te,f.multiple=!!E,g!=null?on(f,!!E,g,!1):w!=null&&on(f,!!E,w,!0);return;case"textarea":$n("invalid",f),L=j=E=null;for(te in w)if(w.hasOwnProperty(te)&&(ye=w[te],ye!=null))switch(te){case"value":E=ye;break;case"defaultValue":j=ye;break;case"children":L=ye;break;case"dangerouslySetInnerHTML":if(ye!=null)throw Error(r(91));break;default:kr(f,g,te,ye,w,null)}pn(f,E,j,L);return;case"option":for(Be in w)if(w.hasOwnProperty(Be)&&(E=w[Be],E!=null))switch(Be){case"selected":f.selected=E&&typeof E!="function"&&typeof E!="symbol";break;default:kr(f,g,Be,E,w,null)}return;case"dialog":$n("beforetoggle",f),$n("toggle",f),$n("cancel",f),$n("close",f);break;case"iframe":case"object":$n("load",f);break;case"video":case"audio":for(E=0;E<Nx.length;E++)$n(Nx[E],f);break;case"image":$n("error",f),$n("load",f);break;case"details":$n("toggle",f);break;case"embed":case"source":case"link":$n("error",f),$n("load",f);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ct in w)if(w.hasOwnProperty(ct)&&(E=w[ct],E!=null))switch(ct){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:kr(f,g,ct,E,w,null)}return;default:if(Zt(g)){for(vt in w)w.hasOwnProperty(vt)&&(E=w[vt],E!==void 0&&zE(f,g,vt,E,w,void 0));return}}for(ye in w)w.hasOwnProperty(ye)&&(E=w[ye],E!=null&&kr(f,g,ye,E,w,null))}function _ae(f,g,w,E){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,L=null,te=null,ye=null,Be=null,ct=null,vt=null;for(bt in w){var Nt=w[bt];if(w.hasOwnProperty(bt)&&Nt!=null)switch(bt){case"checked":break;case"value":break;case"defaultValue":Be=Nt;default:E.hasOwnProperty(bt)||kr(f,g,bt,null,E,Nt)}}for(var ft in E){var bt=E[ft];if(Nt=w[ft],E.hasOwnProperty(ft)&&(bt!=null||Nt!=null))switch(ft){case"type":L=bt;break;case"name":j=bt;break;case"checked":ct=bt;break;case"defaultChecked":vt=bt;break;case"value":te=bt;break;case"defaultValue":ye=bt;break;case"children":case"dangerouslySetInnerHTML":if(bt!=null)throw Error(r(137,g));break;default:bt!==Nt&&kr(f,g,ft,bt,E,Nt)}}Bn(f,te,ye,Be,ct,vt,L,j);return;case"select":bt=te=ye=ft=null;for(L in w)if(Be=w[L],w.hasOwnProperty(L)&&Be!=null)switch(L){case"value":break;case"multiple":bt=Be;default:E.hasOwnProperty(L)||kr(f,g,L,null,E,Be)}for(j in E)if(L=E[j],Be=w[j],E.hasOwnProperty(j)&&(L!=null||Be!=null))switch(j){case"value":ft=L;break;case"defaultValue":ye=L;break;case"multiple":te=L;default:L!==Be&&kr(f,g,j,L,E,Be)}g=ye,w=te,E=bt,ft!=null?on(f,!!w,ft,!1):!!E!=!!w&&(g!=null?on(f,!!w,g,!0):on(f,!!w,w?[]:"",!1));return;case"textarea":bt=ft=null;for(ye in w)if(j=w[ye],w.hasOwnProperty(ye)&&j!=null&&!E.hasOwnProperty(ye))switch(ye){case"value":break;case"children":break;default:kr(f,g,ye,null,E,j)}for(te in E)if(j=E[te],L=w[te],E.hasOwnProperty(te)&&(j!=null||L!=null))switch(te){case"value":ft=j;break;case"defaultValue":bt=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==L&&kr(f,g,te,j,E,L)}St(f,ft,bt);return;case"option":for(var Gt in w)if(ft=w[Gt],w.hasOwnProperty(Gt)&&ft!=null&&!E.hasOwnProperty(Gt))switch(Gt){case"selected":f.selected=!1;break;default:kr(f,g,Gt,null,E,ft)}for(Be in E)if(ft=E[Be],bt=w[Be],E.hasOwnProperty(Be)&&ft!==bt&&(ft!=null||bt!=null))switch(Be){case"selected":f.selected=ft&&typeof ft!="function"&&typeof ft!="symbol";break;default:kr(f,g,Be,ft,E,bt)}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 mn in w)ft=w[mn],w.hasOwnProperty(mn)&&ft!=null&&!E.hasOwnProperty(mn)&&kr(f,g,mn,null,E,ft);for(ct in E)if(ft=E[ct],bt=w[ct],E.hasOwnProperty(ct)&&ft!==bt&&(ft!=null||bt!=null))switch(ct){case"children":case"dangerouslySetInnerHTML":if(ft!=null)throw Error(r(137,g));break;default:kr(f,g,ct,ft,E,bt)}return;default:if(Zt(g)){for(var Mr in w)ft=w[Mr],w.hasOwnProperty(Mr)&&ft!==void 0&&!E.hasOwnProperty(Mr)&&zE(f,g,Mr,void 0,E,ft);for(vt in E)ft=E[vt],bt=w[vt],!E.hasOwnProperty(vt)||ft===bt||ft===void 0&&bt===void 0||zE(f,g,vt,ft,E,bt);return}}for(var et in w)ft=w[et],w.hasOwnProperty(et)&&ft!=null&&!E.hasOwnProperty(et)&&kr(f,g,et,null,E,ft);for(Nt in E)ft=E[Nt],bt=w[Nt],!E.hasOwnProperty(Nt)||ft===bt||ft==null&&bt==null||kr(f,g,Nt,ft,E,bt)}function Mz(f){switch(f){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Sae(){if(typeof performance.getEntriesByType=="function"){for(var f=0,g=0,w=performance.getEntriesByType("resource"),E=0;E<w.length;E++){var j=w[E],L=j.transferSize,te=j.initiatorType,ye=j.duration;if(L&&ye&&Mz(te)){for(te=0,ye=j.responseEnd,E+=1;E<w.length;E++){var Be=w[E],ct=Be.startTime;if(ct>ye)break;var vt=Be.transferSize,Nt=Be.initiatorType;vt&&Mz(Nt)&&(Be=Be.responseEnd,te+=vt*(Be<ye?1:(ye-ct)/(Be-ct)))}if(--E,g+=8*(L+te)/(j.duration/1e3),f++,10<f)break}}if(0<f)return g/f/1e6}return navigator.connection&&(f=navigator.connection.downlink,typeof f=="number")?f:5}var UE=null,BE=null;function Tw(f){return f.nodeType===9?f:f.ownerDocument}function Ez(f){switch(f){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Tz(f,g){if(f===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return f===1&&g==="foreignObject"?0:f}function HE(f,g){return f==="textarea"||f==="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 $E=null;function Nae(){var f=window.event;return f&&f.type==="popstate"?f===$E?!1:($E=f,!0):($E=null,!1)}var Az=typeof setTimeout=="function"?setTimeout:void 0,kae=typeof clearTimeout=="function"?clearTimeout:void 0,Cz=typeof Promise=="function"?Promise:void 0,Mae=typeof queueMicrotask=="function"?queueMicrotask:typeof Cz<"u"?function(f){return Cz.resolve(null).then(f).catch(Eae)}:Az;function Eae(f){setTimeout(function(){throw f})}function Md(f){return f==="head"}function Pz(f,g){var w=g,E=0;do{var j=w.nextSibling;if(f.removeChild(w),j&&j.nodeType===8)if(w=j.data,w==="/$"||w==="/&"){if(E===0){f.removeChild(j),wp(g);return}E--}else if(w==="$"||w==="$?"||w==="$~"||w==="$!"||w==="&")E++;else if(w==="html")Mx(f.ownerDocument.documentElement);else if(w==="head"){w=f.ownerDocument.head,Mx(w);for(var L=w.firstChild;L;){var te=L.nextSibling,ye=L.nodeName;L[mt]||ye==="SCRIPT"||ye==="STYLE"||ye==="LINK"&&L.rel.toLowerCase()==="stylesheet"||w.removeChild(L),L=te}}else w==="body"&&Mx(f.ownerDocument.body);w=j}while(w);wp(g)}function jz(f,g){var w=f;f=0;do{var E=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||""),E&&E.nodeType===8)if(w=E.data,w==="/$"){if(f===0)break;f--}else w!=="$"&&w!=="$?"&&w!=="$~"&&w!=="$!"||f++;w=E}while(w)}function VE(f){var g=f.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":VE(w),at(w);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(w.rel.toLowerCase()==="stylesheet")continue}f.removeChild(w)}}function Tae(f,g,w,E){for(;f.nodeType===1;){var j=w;if(f.nodeName.toLowerCase()!==g.toLowerCase()){if(!E&&(f.nodeName!=="INPUT"||f.type!=="hidden"))break}else if(E){if(!f[mt])switch(g){case"meta":if(!f.hasAttribute("itemprop"))break;return f;case"link":if(L=f.getAttribute("rel"),L==="stylesheet"&&f.hasAttribute("data-precedence"))break;if(L!==j.rel||f.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||f.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||f.getAttribute("title")!==(j.title==null?null:j.title))break;return f;case"style":if(f.hasAttribute("data-precedence"))break;return f;case"script":if(L=f.getAttribute("src"),(L!==(j.src==null?null:j.src)||f.getAttribute("type")!==(j.type==null?null:j.type)||f.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&L&&f.hasAttribute("async")&&!f.hasAttribute("itemprop"))break;return f;default:return f}}else if(g==="input"&&f.type==="hidden"){var L=j.name==null?null:""+j.name;if(j.type==="hidden"&&f.getAttribute("name")===L)return f}else return f;if(f=zo(f.nextSibling),f===null)break}return null}function Aae(f,g,w){if(g==="")return null;for(;f.nodeType!==3;)if((f.nodeType!==1||f.nodeName!=="INPUT"||f.type!=="hidden")&&!w||(f=zo(f.nextSibling),f===null))return null;return f}function Dz(f,g){for(;f.nodeType!==8;)if((f.nodeType!==1||f.nodeName!=="INPUT"||f.type!=="hidden")&&!g||(f=zo(f.nextSibling),f===null))return null;return f}function GE(f){return f.data==="$?"||f.data==="$~"}function qE(f){return f.data==="$!"||f.data==="$?"&&f.ownerDocument.readyState!=="loading"}function Cae(f,g){var w=f.ownerDocument;if(f.data==="$~")f._reactRetry=g;else if(f.data!=="$?"||w.readyState!=="loading")g();else{var E=function(){g(),w.removeEventListener("DOMContentLoaded",E)};w.addEventListener("DOMContentLoaded",E),f._reactRetry=E}}function zo(f){for(;f!=null;f=f.nextSibling){var g=f.nodeType;if(g===1||g===3)break;if(g===8){if(g=f.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return f}var WE=null;function Rz(f){f=f.nextSibling;for(var g=0;f;){if(f.nodeType===8){var w=f.data;if(w==="/$"||w==="/&"){if(g===0)return zo(f.nextSibling);g--}else w!=="$"&&w!=="$!"&&w!=="$?"&&w!=="$~"&&w!=="&"||g++}f=f.nextSibling}return null}function Oz(f){f=f.previousSibling;for(var g=0;f;){if(f.nodeType===8){var w=f.data;if(w==="$"||w==="$!"||w==="$?"||w==="$~"||w==="&"){if(g===0)return f;g--}else w!=="/$"&&w!=="/&"||g++}f=f.previousSibling}return null}function Lz(f,g,w){switch(g=Tw(w),f){case"html":if(f=g.documentElement,!f)throw Error(r(452));return f;case"head":if(f=g.head,!f)throw Error(r(453));return f;case"body":if(f=g.body,!f)throw Error(r(454));return f;default:throw Error(r(451))}}function Mx(f){for(var g=f.attributes;g.length;)f.removeAttributeNode(g[0]);at(f)}var Uo=new Map,Fz=new Set;function Aw(f){return typeof f.getRootNode=="function"?f.getRootNode():f.nodeType===9?f:f.ownerDocument}var Qc=I.d;I.d={f:Pae,r:jae,D:Dae,C:Rae,L:Oae,m:Lae,X:Iae,S:Fae,M:zae};function Pae(){var f=Qc.f(),g=vw();return f||g}function jae(f){var g=he(f);g!==null&&g.tag===5&&g.type==="form"?e5(g):Qc.r(f)}var xp=typeof document>"u"?null:document;function Iz(f,g,w){var E=xp;if(E&&typeof g=="string"&&g){var j=Jn(g);j='link[rel="'+f+'"][href="'+j+'"]',typeof w=="string"&&(j+='[crossorigin="'+w+'"]'),Fz.has(j)||(Fz.add(j),f={rel:f,crossOrigin:w,href:g},E.querySelector(j)===null&&(g=E.createElement("link"),Pa(g,"link",f),He(g),E.head.appendChild(g)))}}function Dae(f){Qc.D(f),Iz("dns-prefetch",f,null)}function Rae(f,g){Qc.C(f,g),Iz("preconnect",f,g)}function Oae(f,g,w){Qc.L(f,g,w);var E=xp;if(E&&f&&g){var j='link[rel="preload"][as="'+Jn(g)+'"]';g==="image"&&w&&w.imageSrcSet?(j+='[imagesrcset="'+Jn(w.imageSrcSet)+'"]',typeof w.imageSizes=="string"&&(j+='[imagesizes="'+Jn(w.imageSizes)+'"]')):j+='[href="'+Jn(f)+'"]';var L=j;switch(g){case"style":L=yp(f);break;case"script":L=vp(f)}Uo.has(L)||(f=h({rel:"preload",href:g==="image"&&w&&w.imageSrcSet?void 0:f,as:g},w),Uo.set(L,f),E.querySelector(j)!==null||g==="style"&&E.querySelector(Ex(L))||g==="script"&&E.querySelector(Tx(L))||(g=E.createElement("link"),Pa(g,"link",f),He(g),E.head.appendChild(g)))}}function Lae(f,g){Qc.m(f,g);var w=xp;if(w&&f){var E=g&&typeof g.as=="string"?g.as:"script",j='link[rel="modulepreload"][as="'+Jn(E)+'"][href="'+Jn(f)+'"]',L=j;switch(E){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=vp(f)}if(!Uo.has(L)&&(f=h({rel:"modulepreload",href:f},g),Uo.set(L,f),w.querySelector(j)===null)){switch(E){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(w.querySelector(Tx(L)))return}E=w.createElement("link"),Pa(E,"link",f),He(E),w.head.appendChild(E)}}}function Fae(f,g,w){Qc.S(f,g,w);var E=xp;if(E&&f){var j=Xe(E).hoistableStyles,L=yp(f);g=g||"default";var te=j.get(L);if(!te){var ye={loading:0,preload:null};if(te=E.querySelector(Ex(L)))ye.loading=5;else{f=h({rel:"stylesheet",href:f,"data-precedence":g},w),(w=Uo.get(L))&&KE(f,w);var Be=te=E.createElement("link");He(Be),Pa(Be,"link",f),Be._p=new Promise(function(ct,vt){Be.onload=ct,Be.onerror=vt}),Be.addEventListener("load",function(){ye.loading|=1}),Be.addEventListener("error",function(){ye.loading|=2}),ye.loading|=4,Cw(te,g,E)}te={type:"stylesheet",instance:te,count:1,state:ye},j.set(L,te)}}}function Iae(f,g){Qc.X(f,g);var w=xp;if(w&&f){var E=Xe(w).hoistableScripts,j=vp(f),L=E.get(j);L||(L=w.querySelector(Tx(j)),L||(f=h({src:f,async:!0},g),(g=Uo.get(j))&&XE(f,g),L=w.createElement("script"),He(L),Pa(L,"link",f),w.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},E.set(j,L))}}function zae(f,g){Qc.M(f,g);var w=xp;if(w&&f){var E=Xe(w).hoistableScripts,j=vp(f),L=E.get(j);L||(L=w.querySelector(Tx(j)),L||(f=h({src:f,async:!0,type:"module"},g),(g=Uo.get(j))&&XE(f,g),L=w.createElement("script"),He(L),Pa(L,"link",f),w.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},E.set(j,L))}}function zz(f,g,w,E){var j=(j=ue.current)?Aw(j):null;if(!j)throw Error(r(446));switch(f){case"meta":case"title":return null;case"style":return typeof w.precedence=="string"&&typeof w.href=="string"?(g=yp(w.href),w=Xe(j).hoistableStyles,E=w.get(g),E||(E={type:"style",instance:null,count:0,state:null},w.set(g,E)),E):{type:"void",instance:null,count:0,state:null};case"link":if(w.rel==="stylesheet"&&typeof w.href=="string"&&typeof w.precedence=="string"){f=yp(w.href);var L=Xe(j).hoistableStyles,te=L.get(f);if(te||(j=j.ownerDocument||j,te={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(f,te),(L=j.querySelector(Ex(f)))&&!L._p&&(te.instance=L,te.state.loading=5),Uo.has(f)||(w={rel:"preload",as:"style",href:w.href,crossOrigin:w.crossOrigin,integrity:w.integrity,media:w.media,hrefLang:w.hrefLang,referrerPolicy:w.referrerPolicy},Uo.set(f,w),L||Uae(j,f,w,te.state))),g&&E===null)throw Error(r(528,""));return te}if(g&&E!==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=vp(w),w=Xe(j).hoistableScripts,E=w.get(g),E||(E={type:"script",instance:null,count:0,state:null},w.set(g,E)),E):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,f))}}function yp(f){return'href="'+Jn(f)+'"'}function Ex(f){return'link[rel="stylesheet"]['+f+"]"}function Uz(f){return h({},f,{"data-precedence":f.precedence,precedence:null})}function Uae(f,g,w,E){f.querySelector('link[rel="preload"][as="style"]['+g+"]")?E.loading=1:(g=f.createElement("link"),E.preload=g,g.addEventListener("load",function(){return E.loading|=1}),g.addEventListener("error",function(){return E.loading|=2}),Pa(g,"link",w),He(g),f.head.appendChild(g))}function vp(f){return'[src="'+Jn(f)+'"]'}function Tx(f){return"script[async]"+f}function Bz(f,g,w){if(g.count++,g.instance===null)switch(g.type){case"style":var E=f.querySelector('style[data-href~="'+Jn(w.href)+'"]');if(E)return g.instance=E,He(E),E;var j=h({},w,{"data-href":w.href,"data-precedence":w.precedence,href:null,precedence:null});return E=(f.ownerDocument||f).createElement("style"),He(E),Pa(E,"style",j),Cw(E,w.precedence,f),g.instance=E;case"stylesheet":j=yp(w.href);var L=f.querySelector(Ex(j));if(L)return g.state.loading|=4,g.instance=L,He(L),L;E=Uz(w),(j=Uo.get(j))&&KE(E,j),L=(f.ownerDocument||f).createElement("link"),He(L);var te=L;return te._p=new Promise(function(ye,Be){te.onload=ye,te.onerror=Be}),Pa(L,"link",E),g.state.loading|=4,Cw(L,w.precedence,f),g.instance=L;case"script":return L=vp(w.src),(j=f.querySelector(Tx(L)))?(g.instance=j,He(j),j):(E=w,(j=Uo.get(L))&&(E=h({},w),XE(E,j)),f=f.ownerDocument||f,j=f.createElement("script"),He(j),Pa(j,"link",E),f.head.appendChild(j),g.instance=j);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(E=g.instance,g.state.loading|=4,Cw(E,w.precedence,f));return g.instance}function Cw(f,g,w){for(var E=w.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=E.length?E[E.length-1]:null,L=j,te=0;te<E.length;te++){var ye=E[te];if(ye.dataset.precedence===g)L=ye;else if(L!==j)break}L?L.parentNode.insertBefore(f,L.nextSibling):(g=w.nodeType===9?w.head:w,g.insertBefore(f,g.firstChild))}function KE(f,g){f.crossOrigin==null&&(f.crossOrigin=g.crossOrigin),f.referrerPolicy==null&&(f.referrerPolicy=g.referrerPolicy),f.title==null&&(f.title=g.title)}function XE(f,g){f.crossOrigin==null&&(f.crossOrigin=g.crossOrigin),f.referrerPolicy==null&&(f.referrerPolicy=g.referrerPolicy),f.integrity==null&&(f.integrity=g.integrity)}var Pw=null;function Hz(f,g,w){if(Pw===null){var E=new Map,j=Pw=new Map;j.set(w,E)}else j=Pw,E=j.get(w),E||(E=new Map,j.set(w,E));if(E.has(f))return E;for(E.set(f,null),w=w.getElementsByTagName(f),j=0;j<w.length;j++){var L=w[j];if(!(L[mt]||L[Xt]||f==="link"&&L.getAttribute("rel")==="stylesheet")&&L.namespaceURI!=="http://www.w3.org/2000/svg"){var te=L.getAttribute(g)||"";te=f+te;var ye=E.get(te);ye?ye.push(L):E.set(te,[L])}}return E}function $z(f,g,w){f=f.ownerDocument||f,f.head.insertBefore(w,g==="title"?f.querySelector("head > title"):null)}function Bae(f,g,w){if(w===1||g.itemProp!=null)return!1;switch(f){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 f=g.disabled,typeof g.precedence=="string"&&f==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 Vz(f){return!(f.type==="stylesheet"&&(f.state.loading&3)===0)}function Hae(f,g,w,E){if(w.type==="stylesheet"&&(typeof E.media!="string"||matchMedia(E.media).matches!==!1)&&(w.state.loading&4)===0){if(w.instance===null){var j=yp(E.href),L=g.querySelector(Ex(j));if(L){g=L._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(f.count++,f=jw.bind(f),g.then(f,f)),w.state.loading|=4,w.instance=L,He(L);return}L=g.ownerDocument||g,E=Uz(E),(j=Uo.get(j))&&KE(E,j),L=L.createElement("link"),He(L);var te=L;te._p=new Promise(function(ye,Be){te.onload=ye,te.onerror=Be}),Pa(L,"link",E),w.instance=L}f.stylesheets===null&&(f.stylesheets=new Map),f.stylesheets.set(w,g),(g=w.state.preload)&&(w.state.loading&3)===0&&(f.count++,w=jw.bind(f),g.addEventListener("load",w),g.addEventListener("error",w))}}var YE=0;function $ae(f,g){return f.stylesheets&&f.count===0&&Rw(f,f.stylesheets),0<f.count||0<f.imgCount?function(w){var E=setTimeout(function(){if(f.stylesheets&&Rw(f,f.stylesheets),f.unsuspend){var L=f.unsuspend;f.unsuspend=null,L()}},6e4+g);0<f.imgBytes&&YE===0&&(YE=62500*Sae());var j=setTimeout(function(){if(f.waitingForImages=!1,f.count===0&&(f.stylesheets&&Rw(f,f.stylesheets),f.unsuspend)){var L=f.unsuspend;f.unsuspend=null,L()}},(f.imgBytes>YE?50:800)+g);return f.unsuspend=w,function(){f.unsuspend=null,clearTimeout(E),clearTimeout(j)}}:null}function jw(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Rw(this,this.stylesheets);else if(this.unsuspend){var f=this.unsuspend;this.unsuspend=null,f()}}}var Dw=null;function Rw(f,g){f.stylesheets=null,f.unsuspend!==null&&(f.count++,Dw=new Map,g.forEach(Vae,f),Dw=null,jw.call(f))}function Vae(f,g){if(!(g.state.loading&4)){var w=Dw.get(f);if(w)var E=w.get(null);else{w=new Map,Dw.set(f,w);for(var j=f.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L<j.length;L++){var te=j[L];(te.nodeName==="LINK"||te.getAttribute("media")!=="not all")&&(w.set(te.dataset.precedence,te),E=te)}E&&w.set(null,E)}j=g.instance,te=j.getAttribute("data-precedence"),L=w.get(te)||E,L===E&&w.set(null,j),w.set(te,j),this.count++,E=jw.bind(this),j.addEventListener("load",E),j.addEventListener("error",E),L?L.parentNode.insertBefore(j,L.nextSibling):(f=f.nodeType===9?f.head:f,f.insertBefore(j,f.firstChild)),g.state.loading|=4}}var Ax={$$typeof:N,Provider:null,Consumer:null,_currentValue:K,_currentValue2:K,_threadCount:0};function Gae(f,g,w,E,j,L,te,ye,Be){this.tag=1,this.containerInfo=f,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=Et(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Et(0),this.hiddenUpdates=Et(null),this.identifierPrefix=E,this.onUncaughtError=j,this.onCaughtError=L,this.onRecoverableError=te,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Be,this.incompleteTransitions=new Map}function Gz(f,g,w,E,j,L,te,ye,Be,ct,vt,Nt){return f=new Gae(f,g,w,te,Be,ct,vt,Nt,ye),g=1,L===!0&&(g|=24),L=ro(3,null,null,g),f.current=L,L.stateNode=f,g=A2(),g.refCount++,f.pooledCache=g,g.refCount++,L.memoizedState={element:E,isDehydrated:w,cache:g},D2(L),f}function qz(f){return f?(f=Qm,f):Qm}function Wz(f,g,w,E,j,L){j=qz(j),E.context===null?E.context=j:E.pendingContext=j,E=pd(g),E.payload={element:w},L=L===void 0?null:L,L!==null&&(E.callback=L),w=gd(f,E,g),w!==null&&(Ls(w,f,g),ox(w,f,g))}function Kz(f,g){if(f=f.memoizedState,f!==null&&f.dehydrated!==null){var w=f.retryLane;f.retryLane=w!==0&&w<g?w:g}}function QE(f,g){Kz(f,g),(f=f.alternate)&&Kz(f,g)}function Xz(f){if(f.tag===13||f.tag===31){var g=nf(f,67108864);g!==null&&Ls(g,f,67108864),QE(f,67108864)}}function Yz(f){if(f.tag===13||f.tag===31){var g=lo();g=rn(g);var w=nf(f,g);w!==null&&Ls(w,f,g),QE(f,g)}}var Ow=!0;function qae(f,g,w,E){var j=G.T;G.T=null;var L=I.p;try{I.p=2,ZE(f,g,w,E)}finally{I.p=L,G.T=j}}function Wae(f,g,w,E){var j=G.T;G.T=null;var L=I.p;try{I.p=8,ZE(f,g,w,E)}finally{I.p=L,G.T=j}}function ZE(f,g,w,E){if(Ow){var j=JE(E);if(j===null)IE(f,g,E,Lw,w),Zz(f,E);else if(Xae(j,f,g,w,E))E.stopPropagation();else if(Zz(f,E),g&4&&-1<Kae.indexOf(f)){for(;j!==null;){var L=he(j);if(L!==null)switch(L.tag){case 3:if(L=L.stateNode,L.current.memoizedState.isDehydrated){var te=je(L.pendingLanes);if(te!==0){var ye=L;for(ye.pendingLanes|=2,ye.entangledLanes|=2;te;){var Be=1<<31-ze(te);ye.entanglements[1]|=Be,te&=~Be}Zl(L),(dr&6)===0&&(xw=O()+500,Sx(0))}}break;case 31:case 13:ye=nf(L,2),ye!==null&&Ls(ye,L,2),vw(),QE(L,2)}if(L=JE(E),L===null&&IE(f,g,E,Lw,w),L===j)break;j=L}j!==null&&E.stopPropagation()}else IE(f,g,E,null,w)}}function JE(f){return f=yl(f),eT(f)}var Lw=null;function eT(f){if(Lw=null,f=Dt(f),f!==null){var g=s(f);if(g===null)f=null;else{var w=g.tag;if(w===13){if(f=o(g),f!==null)return f;f=null}else if(w===31){if(f=l(g),f!==null)return f;f=null}else if(w===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;f=null}else g!==f&&(f=null)}}return Lw=f,null}function Qz(f){switch(f){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(Z()){case me:return 2;case Te:return 8;case ke:case Ee:return 32;case Se:return 268435456;default:return 32}default:return 32}}var tT=!1,Ed=null,Td=null,Ad=null,Cx=new Map,Px=new Map,Cd=[],Kae="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 Zz(f,g){switch(f){case"focusin":case"focusout":Ed=null;break;case"dragenter":case"dragleave":Td=null;break;case"mouseover":case"mouseout":Ad=null;break;case"pointerover":case"pointerout":Cx.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":Px.delete(g.pointerId)}}function jx(f,g,w,E,j,L){return f===null||f.nativeEvent!==L?(f={blockedOn:g,domEventName:w,eventSystemFlags:E,nativeEvent:L,targetContainers:[j]},g!==null&&(g=he(g),g!==null&&Xz(g)),f):(f.eventSystemFlags|=E,g=f.targetContainers,j!==null&&g.indexOf(j)===-1&&g.push(j),f)}function Xae(f,g,w,E,j){switch(g){case"focusin":return Ed=jx(Ed,f,g,w,E,j),!0;case"dragenter":return Td=jx(Td,f,g,w,E,j),!0;case"mouseover":return Ad=jx(Ad,f,g,w,E,j),!0;case"pointerover":var L=j.pointerId;return Cx.set(L,jx(Cx.get(L)||null,f,g,w,E,j)),!0;case"gotpointercapture":return L=j.pointerId,Px.set(L,jx(Px.get(L)||null,f,g,w,E,j)),!0}return!1}function Jz(f){var g=Dt(f.target);if(g!==null){var w=s(g);if(w!==null){if(g=w.tag,g===13){if(g=o(w),g!==null){f.blockedOn=g,Lr(f.priority,function(){Yz(w)});return}}else if(g===31){if(g=l(w),g!==null){f.blockedOn=g,Lr(f.priority,function(){Yz(w)});return}}else if(g===3&&w.stateNode.current.memoizedState.isDehydrated){f.blockedOn=w.tag===3?w.stateNode.containerInfo:null;return}}}f.blockedOn=null}function Fw(f){if(f.blockedOn!==null)return!1;for(var g=f.targetContainers;0<g.length;){var w=JE(f.nativeEvent);if(w===null){w=f.nativeEvent;var E=new w.constructor(w.type,w);Js=E,w.target.dispatchEvent(E),Js=null}else return g=he(w),g!==null&&Xz(g),f.blockedOn=w,!1;g.shift()}return!0}function eU(f,g,w){Fw(f)&&w.delete(g)}function Yae(){tT=!1,Ed!==null&&Fw(Ed)&&(Ed=null),Td!==null&&Fw(Td)&&(Td=null),Ad!==null&&Fw(Ad)&&(Ad=null),Cx.forEach(eU),Px.forEach(eU)}function Iw(f,g){f.blockedOn===g&&(f.blockedOn=null,tT||(tT=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Yae)))}var zw=null;function tU(f){zw!==f&&(zw=f,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){zw===f&&(zw=null);for(var g=0;g<f.length;g+=3){var w=f[g],E=f[g+1],j=f[g+2];if(typeof E!="function"){if(eT(E||w)===null)continue;break}var L=he(w);L!==null&&(f.splice(g,3),g-=3,J2(L,{pending:!0,data:j,method:w.method,action:E},E,j))}}))}function wp(f){function g(Be){return Iw(Be,f)}Ed!==null&&Iw(Ed,f),Td!==null&&Iw(Td,f),Ad!==null&&Iw(Ad,f),Cx.forEach(g),Px.forEach(g);for(var w=0;w<Cd.length;w++){var E=Cd[w];E.blockedOn===f&&(E.blockedOn=null)}for(;0<Cd.length&&(w=Cd[0],w.blockedOn===null);)Jz(w),w.blockedOn===null&&Cd.shift();if(w=(f.ownerDocument||f).$$reactFormReplay,w!=null)for(E=0;E<w.length;E+=3){var j=w[E],L=w[E+1],te=j[Zn]||null;if(typeof L=="function")te||tU(w);else if(te){var ye=null;if(L&&L.hasAttribute("formAction")){if(j=L,te=L[Zn]||null)ye=te.formAction;else if(eT(j)!==null)continue}else ye=te.action;typeof ye=="function"?w[E+1]=ye:(w.splice(E,3),E-=3),tU(w)}}}function nU(){function f(L){L.canIntercept&&L.info==="react-transition"&&L.intercept({handler:function(){return new Promise(function(te){return j=te})},focusReset:"manual",scroll:"manual"})}function g(){j!==null&&(j(),j=null),E||setTimeout(w,20)}function w(){if(!E&&!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 E=!1,j=null;return navigation.addEventListener("navigate",f),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(w,100),function(){E=!0,navigation.removeEventListener("navigate",f),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),j!==null&&(j(),j=null)}}}function nT(f){this._internalRoot=f}Uw.prototype.render=nT.prototype.render=function(f){var g=this._internalRoot;if(g===null)throw Error(r(409));var w=g.current,E=lo();Wz(w,E,f,g,null,null)},Uw.prototype.unmount=nT.prototype.unmount=function(){var f=this._internalRoot;if(f!==null){this._internalRoot=null;var g=f.containerInfo;Wz(f.current,2,null,f,null,null),vw(),g[oi]=null}};function Uw(f){this._internalRoot=f}Uw.prototype.unstable_scheduleHydration=function(f){if(f){var g=ur();f={blockedOn:null,target:f,priority:g};for(var w=0;w<Cd.length&&g!==0&&g<Cd[w].priority;w++);Cd.splice(w,0,f),w===0&&Jz(f)}};var rU=e.version;if(rU!=="19.2.0")throw Error(r(527,rU,"19.2.0"));I.findDOMNode=function(f){var g=f._reactInternals;if(g===void 0)throw typeof f.render=="function"?Error(r(188)):(f=Object.keys(f).join(","),Error(r(268,f)));return f=u(g),f=f!==null?d(f):null,f=f===null?null:f.stateNode,f};var Qae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:G,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Bw=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bw.isDisabled&&Bw.supportsFiber)try{Ue=Bw.inject(Qae),be=Bw}catch{}}return Rx.createRoot=function(f,g){if(!i(f))throw Error(r(299));var w=!1,E="",j=u5,L=d5,te=h5;return g!=null&&(g.unstable_strictMode===!0&&(w=!0),g.identifierPrefix!==void 0&&(E=g.identifierPrefix),g.onUncaughtError!==void 0&&(j=g.onUncaughtError),g.onCaughtError!==void 0&&(L=g.onCaughtError),g.onRecoverableError!==void 0&&(te=g.onRecoverableError)),g=Gz(f,1,!1,null,null,w,E,null,j,L,te,nU),f[oi]=g.current,FE(f),new nT(g)},Rx.hydrateRoot=function(f,g,w){if(!i(f))throw Error(r(299));var E=!1,j="",L=u5,te=d5,ye=h5,Be=null;return w!=null&&(w.unstable_strictMode===!0&&(E=!0),w.identifierPrefix!==void 0&&(j=w.identifierPrefix),w.onUncaughtError!==void 0&&(L=w.onUncaughtError),w.onCaughtError!==void 0&&(te=w.onCaughtError),w.onRecoverableError!==void 0&&(ye=w.onRecoverableError),w.formState!==void 0&&(Be=w.formState)),g=Gz(f,1,!0,g,w??null,E,j,Be,L,te,ye,nU),g.context=qz(null),w=g.current,E=lo(),E=rn(E),j=pd(E),j.callback=null,gd(w,j,E),w=E,g.current.lanes=w,fn(g,w),Zl(g),f[oi]=g.current,FE(f),new Uw(g)},Rx.version="19.2.0",Rx}var fU;function lse(){if(fU)return aT.exports;fU=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(),aT.exports=ose(),aT.exports}var cse=lse();const yn=t=>typeof t=="string",Ox=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},mU=t=>t==null?"":""+t,use=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},dse=/###/g,pU=t=>t&&t.indexOf("###")>-1?t.replace(dse,"."):t,gU=t=>!t||yn(t),_0=(t,e,n)=>{const r=yn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(gU(t))return{};const s=pU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return gU(t)?{}:{obj:t,k:pU(r[i])}},bU=(t,e,n)=>{const{obj:r,k:i}=_0(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),l=_0(t,o,Object);for(;l.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),l=_0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${s}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${s}`]=n},hse=(t,e,n,r)=>{const{obj:i,k:s}=_0(t,e,Object);i[s]=i[s]||[],i[s].push(n)},eS=(t,e)=>{const{obj:n,k:r}=_0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},fse=(t,e,n)=>{const r=eS(t,n);return r!==void 0?r:eS(e,n)},$9=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?yn(t[r])||t[r]instanceof String||yn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):$9(t[r],e[r],n):t[r]=e[r]);return t},_p=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var mse={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const pse=t=>yn(t)?t.replace(/[&<>"'\/]/g,e=>mse[e]):t;class gse{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 bse=[" ",",","?","!",";"],xse=new gse(20),yse=(t,e,n)=>{e=e||"",n=n||"";const r=bse.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=xse.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},fj=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let o,l="";for(let c=s;c<r.length;++c)if(c!==s&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;s+=c-s+1;break}i=o}return i},q0=t=>t?.replace("_","-"),vse={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 tS{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||vse,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:(yn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new tS(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new tS(this.logger,e)}}var dc=new tS;let gk=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i.apply(i,[e,...n])})}};class xU extends gk{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;e.indexOf(".")>-1?l=e.split("."):(l=[e,n],r&&(Array.isArray(r)?l.push(...r):yn(r)&&s?l.push(...r.split(s)):l.push(r)));const c=eS(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!yn(r)?c:fj(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),bU(this.data,l,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(yn(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,o={silent:!1,skipCopy:!1}){let l=[e,n];e.indexOf(".")>-1&&(l=e.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=eS(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?$9(c,r,s):c={...c,...r},bU(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 V9={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const G9=Symbol("i18next/PATH_KEY");function wse(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===G9?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function mj(t,e){const{[G9]:n}=t(wse());return n.join(e?.keySeparator??".")}const yU={},cT=t=>!yn(t)&&typeof t!="boolean"&&typeof t!="number";class nS extends gk{constructor(e,n={}){super(),use(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=dc.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const s=cT(i.res);return!(r.returnObjects===!1&&s)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!yse(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:yn(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:yn(s)?[s]:s}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=mj(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const h=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return p?s?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:s?{res:l,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const m=this.resolve(e,i);let b=m?.res;const y=m?.usedKey||l,x=m?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,T=i.count!==void 0&&!yn(i.count),M=nS.hasDefaultValue(i),A=T?this.pluralResolver.getSuffix(h,i.count,i):"",k=i.ordinal&&T?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",R=T&&!i.ordinal&&i.count===0,C=R&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${A}`]||i[`defaultValue${k}`]||i.defaultValue;let P=b;N&&!b&&M&&(P=C);const U=cT(P),F=Object.prototype.toString.apply(P);if(N&&P&&U&&v.indexOf(F)<0&&!(yn(S)&&Array.isArray(P))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const B=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,P,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return s?(m.res=B,m.usedParams=this.getUsedParamsDetails(i),m):B}if(o){const B=Array.isArray(P),D=B?[]:{},$=B?x:y;for(const G in P)if(Object.prototype.hasOwnProperty.call(P,G)){const I=`${$}${o}${G}`;M&&!b?D[G]=this.translate(I,{...i,defaultValue:cT(C)?C[G]:void 0,joinArrays:!1,ns:c}):D[G]=this.translate(I,{...i,joinArrays:!1,ns:c}),D[G]===I&&(D[G]=P[G])}b=D}}else if(N&&yn(S)&&Array.isArray(b))b=b.join(S),b&&(b=this.extendTranslation(b,e,i,r));else{let B=!1,D=!1;!this.isValidLookup(b)&&M&&(B=!0,b=C),this.isValidLookup(b)||(D=!0,b=l);const G=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&D?void 0:b,I=M&&C!==b&&this.options.updateMissing;if(D||B||I){if(this.logger.log(I?"updateKey":"missingKey",h,u,l,I?C:b),o){const H=this.resolve(l,{...i,keySeparator:!1});H&&H.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 K=[];const Q=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Q&&Q[0])for(let H=0;H<Q.length;H++)K.push(Q[H]);else this.options.saveMissingTo==="all"?K=this.languageUtils.toResolveHierarchy(i.lng||this.language):K.push(i.lng||this.language);const se=(H,W,J)=>{const ne=M&&J!==b?J:G;this.options.missingKeyHandler?this.options.missingKeyHandler(H,u,W,ne,I,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,u,W,ne,I,i),this.emit("missingKey",H,u,W,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?K.forEach(H=>{const W=this.pluralResolver.getSuffixes(H,i);R&&i[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(J=>{se([H],l+J,i[`defaultValue${J}`]||C)})}):se(K,l,C))}b=this.extendTranslation(b,e,i,m,r),D&&b===l&&this.options.appendNamespaceToMissingKey&&(b=`${u}${d}${l}`),(D||B)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,B?b:void 0,i))}return s?(m.res=b,m.usedParams=this.getUsedParamsDetails(i),m):b}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=yn(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const h=e.match(this.interpolator.nestingRegexp);u=h&&h.length}let d=r.replace&&!yn(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 h=e.match(this.interpolator.nestingRegexp),p=h&&h.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,(...h)=>s?.[0]===h[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=yn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=V9.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,s,o,l;return yn(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const p=n.count!==void 0&&!yn(n.count),m=p&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(yn(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(x=>{this.isValidLookup(r)||(l=x,!yU[`${y[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(yU[`${y[0]}-${x}`]=!0,this.logger.warn(`key "${i}" for languages "${y.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!!!")),y.forEach(v=>{if(this.isValidLookup(r))return;o=v;const S=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(S,d,v,x,n);else{let T;p&&(T=this.pluralResolver.getSuffix(v,n.count,n));const M=`${this.options.pluralSeparator}zero`,A=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&T.indexOf(A)===0&&S.push(d+T.replace(A,this.options.pluralSeparator)),S.push(d+T),m&&S.push(d+M)),b){const k=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(k),p&&(n.ordinal&&T.indexOf(A)===0&&S.push(k+T.replace(A,this.options.pluralSeparator)),S.push(k+T),m&&S.push(k+M))}}let N;for(;N=S.pop();)this.isValidLookup(r)||(s=N,r=this.getResource(v,x,N,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:l}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!yn(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class vU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=dc.create("languageUtils")}getScriptPartFromCode(e){if(e=q0(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=q0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(yn(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),yn(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return yn(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):yn(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const wU={zero:0,one:1,two:2,few:3,many:4,other:5},_U={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class _se{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=dc.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=q0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),_U;if(!e.match(/-|_/))return _U;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[s]=o,o}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>wU[i]-wU[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const SU=(t,e,n,r=".",i=!0)=>{let s=fse(t,e,n);return!s&&i&&yn(n)&&(s=fj(t,n,r),s===void 0&&(s=fj(e,n,r))),s},uT=t=>t.replace(/\$/g,"$$$$");class Sse{constructor(e={}){this.logger=dc.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:h,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:b,nestingSuffixEscaped:y,nestingOptionsSeparator:x,maxReplaces:v,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:pse,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?_p(s):o||"{{",this.suffix=l?_p(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?_p(p):m||_p("$t("),this.nestingSuffix=b?_p(b):y||_p(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=v||1e3,this.alwaysFormat=S!==void 0?S:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const v=SU(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:m}):v}const b=m.split(this.formatSeparator),y=b.shift().trim(),x=b.join(this.formatSeparator).trim();return this.format(SU(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>uT(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?uT(this.escape(m)):uT(m)}].forEach(m=>{for(l=0;s=m.regex.exec(e);){const b=s[1].trim();if(o=u(b),o===void 0)if(typeof d=="function"){const x=d(e,s,i);o=yn(x)?x:""}else if(i&&Object.prototype.hasOwnProperty.call(i,b))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),o="";else!yn(o)&&!this.useRawValueToEscape&&(o=mU(o));const y=m.safeValue(o);if(e=e.replace(s[0],y),h?(m.regex.lastIndex+=o.length,m.regex.lastIndex-=s[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const h=c.split(new RegExp(`${d}[ ]*{`));let p=`{${h[1]}`;c=h[0],p=this.interpolate(p,o);const m=p.match(/'/g),b=p.match(/"/g);((m?.length??0)%2===0&&!b||b.length%2!==0)&&(p=p.replace(/'/g,'"'));try{o=JSON.parse(p),u&&(o={...u,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${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&&!yn(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),s=n(l.call(this,i[1].trim(),o),o),s&&i[0]===e&&!yn(s))return s;yn(s)||(s=mU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((d,h)=>this.format(d,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const Nse=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}},NU=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const o=r+JSON.stringify(s);let l=e[o];return l||(l=t(q0(r),i),e[o]=l),l(n)}},kse=t=>(e,n,r)=>t(q0(n),r)(e);class Mse{constructor(e={}){this.logger=dc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?NU:kse;this.formats={number:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s});return l=>o.format(l)}),currency:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s,style:"currency"});return l=>o.format(l)}),datetime:r((i,s)=>{const o=new Intl.DateTimeFormat(i,{...s});return l=>o.format(l)}),relativetime:r((i,s)=>{const o=new Intl.RelativeTimeFormat(i,{...s});return l=>o.format(l,s.range||"day")}),list:r((i,s)=>{const o=new Intl.ListFormat(i,{...s});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=NU(n)}format(e,n,r,i={}){const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(l=>l.indexOf(")")>-1)){const l=s.findIndex(c=>c.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,l)].join(this.formatSeparator)}return s.reduce((l,c)=>{const{formatName:u,formatOptions:d}=Nse(c);if(this.formats[u]){let h=l;try{const p=i?.formatParams?.[i.interpolationkey]||{},m=p.locale||p.lng||i.locale||i.lng||r;h=this.formats[u](l,m,{...d,...i,...p})}catch(p){this.logger.warn(p)}return h}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const Ese=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Tse extends gk{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=dc.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(h=>{const p=`${u}|${h}`;!r.reload&&this.store.hasResourceBundle(u,h)?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),s[p]===void 0&&(s[p]=!0),c[h]===void 0&&(c[h]=!0)))}),d||(l[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{hse(c.loaded,[s],o),Ese(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(h=>{l[u][h]===void 0&&(l[u][h]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,s=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(e,n,l)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();yn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),yn(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,s,o={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:s},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(h=>l(null,h)).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 kU=()=>({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]),yn(t[1])&&(e.defaultValue=t[1]),yn(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}),MU=t=>(yn(t.ns)&&(t.ns=[t.ns]),yn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),yn(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),$w=()=>{},Ase=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class S0 extends gk{constructor(e={},n){if(super(),this.options=MU(e),this.services={},this.logger=dc,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&&(yn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=kU();this.options={...r,...this.options,...MU(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?dc.init(i(this.modules.logger),this.options):dc.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Mse;const d=new vU(this.options);this.store=new xU(this.options.resources,this.options);const h=this.services;h.logger=dc,h.resourceStore=this.store,h.languageUtils=d,h.pluralResolver=new _se(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)&&(h.formatter=i(u),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new Sse(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Tse(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(m,...b)=>{this.emit(m,...b)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new nS(this.services,this.options),this.translator.on("*",(m,...b)=>{this.emit(m,...b)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=$w),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=Ox(),c=()=>{const u=(d,h)=>{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(h),n(d,h)};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=$w){let r=n;const i=yn(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&s.indexOf(u)<0&&s.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(l=>o(l)),this.services.backendConnector.load(s,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=Ox();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=$w),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&V9.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const r=Ox();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},s=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=yn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(yn(l)?[l]:l);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{s(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r){const i=(s,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([s,o].concat(l)):c={...o},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(s)?d=s.map(h=>(typeof h=="function"&&(h=mj(h,{...this.options,...o})),`${c.keyPrefix}${u}${h}`)):(typeof s=="function"&&(s=mj(s,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${s}`:s),this.t(d,c)};return yn(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=Ox();return this.options.ns?(yn(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=Ox();yn(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new vU(kU());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 S0(e,n);return r.createInstance=S0.createInstance,r}cloneInstance(e={},n=$w){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new S0(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(l=>{s[l]=this[l]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,h)=>(d[h]={...c[u][h]},d),c[u]),c),{});s.store=new xU(l,i),s.services.resourceStore=s.store}return s.translator=new nS(s.services,i),s.translator.on("*",(l,...c)=>{s.emit(l,...c)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Cs=S0.createInstance();Cs.createInstance;Cs.dir;Cs.init;Cs.loadResources;Cs.reloadResources;Cs.use;Cs.changeLanguage;Cs.getFixedT;Cs.t;Cs.exists;Cs.setDefaultNamespace;Cs.hasLoadedNamespace;Cs.loadNamespaces;Cs.loadLanguages;const Cse=(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);hm(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},EU={},q9=(t,e,n,r)=>{hm(n)&&EU[n]||(hm(n)&&(EU[n]=new Date),Cse(t,e,n,r))},W9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},pj=(t,e,n)=>{t.loadNamespaces(e,W9(t,n))},TU=(t,e,n,r)=>{if(hm(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return pj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,W9(t,r))},Pse=(t,e,n={})=>!e.languages||!e.languages.length?(q9(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}}),hm=t=>typeof t=="string",jse=t=>typeof t=="object"&&t!==null,Dse=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Rse={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Ose=t=>Rse[t],Lse=t=>t.replace(Dse,Ose);let gj={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Lse};const Fse=(t={})=>{gj={...gj,...t}},Ise=()=>gj;let K9;const zse=t=>{K9=t},Use=()=>K9,Bse={type:"3rdParty",init(t){Fse(t.options.react),zse(t)}},Hse=_.createContext();class $se{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var dT={exports:{}},hT={};var AU;function Vse(){if(AU)return hT;AU=1;var t=Sb();function e(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,o=t.useDebugValue;function l(h,p){var m=p(),b=r({inst:{value:m,getSnapshot:p}}),y=b[0].inst,x=b[1];return s(function(){y.value=m,y.getSnapshot=p,c(y)&&x({inst:y})},[h,m,p]),i(function(){return c(y)&&x({inst:y}),h(function(){c(y)&&x({inst:y})})},[h]),o(m),m}function c(h){var p=h.getSnapshot;h=h.value;try{var m=p();return!n(h,m)}catch{return!0}}function u(h,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return hT.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,hT}var CU;function X9(){return CU||(CU=1,dT.exports=Vse()),dT.exports}var PR=X9();const Gse=(t,e)=>hm(e)?e:jse(e)&&hm(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,qse={t:Gse,ready:!1},Wse=()=>()=>{},Yt=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=_.useContext(Hse)||{},s=n||r||Use();s&&!s.reportNamespaces&&(s.reportNamespaces=new $se),s||q9(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=_.useMemo(()=>({...Ise(),...s?.options?.react,...e}),[s,e]),{useSuspense:l,keyPrefix:c}=o,u=i||s?.options?.defaultNS,d=hm(u)?[u]:u||["translation"],h=_.useMemo(()=>d,d);s?.reportNamespaces?.addUsedNamespaces?.(h);const p=_.useRef(0),m=_.useCallback(C=>{if(!s)return Wse;const{bindI18n:P,bindI18nStore:U}=o,F=()=>{p.current+=1,C()};return P&&s.on(P,F),U&&s.store.on(U,F),()=>{P&&P.split(" ").forEach(B=>s.off(B,F)),U&&U.split(" ").forEach(B=>s.store.off(B,F))}},[s,o]),b=_.useRef(),y=_.useCallback(()=>{if(!s)return qse;const C=!!(s.isInitialized||s.initializedStoreOnce)&&h.every($=>Pse($,s,o)),P=e.lng||s.language,U=p.current,F=b.current;if(F&&F.ready===C&&F.lng===P&&F.keyPrefix===c&&F.revision===U)return F;const D={t:s.getFixedT(P,o.nsMode==="fallback"?h:h[0],c),ready:C,lng:P,keyPrefix:c,revision:U};return b.current=D,D},[s,h,c,o,e.lng]),[x,v]=_.useState(0),{t:S,ready:N}=PR.useSyncExternalStore(m,y,y);_.useEffect(()=>{if(s&&!N&&!l){const C=()=>v(P=>P+1);e.lng?TU(s,e.lng,h,C):pj(s,h,C)}},[s,e.lng,h,N,l,x]);const T=s||{},M=_.useRef(null),A=_.useRef(),k=C=>{const P=Object.getOwnPropertyDescriptors(C);P.__original&&delete P.__original;const U=Object.create(Object.getPrototypeOf(C),P);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:C,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},R=_.useMemo(()=>{const C=T,P=C?.language;let U=C;C&&(M.current&&M.current.__original===C?A.current!==P?(U=k(C),M.current=U,A.current=P):U=M.current:(U=k(C),M.current=U,A.current=P));const F=[S,U,N];return F.t=S,F.i18n=U,F.ready=N,F},[S,T,N,T.resolvedLanguage,T.language,T.languages]);if(s&&l&&!N)throw new Promise(C=>{const P=()=>C();e.lng?TU(s,e.lng,h,P):pj(s,h,P)});return R},{slice:Kse,forEach:Xse}=[];function Yse(t){return Xse.call(Kse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Qse(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 PU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Zse=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let s=`${t}=${i}`;if(r.maxAge>0){const o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!PU.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!PU.test(r.path))throw new TypeError("option path is invalid");s+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(s+="; HttpOnly"),r.secure&&(s+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(s+="; Partitioned"),s},jU={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=Zse(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 Jse={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return jU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&jU.create(n,t,r,i,s)}},eoe={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const s=r.substring(1).split("&");for(let o=0;o<s.length;o++){const l=s[o].indexOf("=");l>0&&s[o].substring(0,l)===e&&(n=s[o].substring(l+1))}}return n}},toe={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const s=i.substring(1);if(e){const o=s.split("&");for(let l=0;l<o.length;l++){const c=o[l].indexOf("=");c>0&&o[l].substring(0,c)===e&&(r=o[l].substring(c+1))}}if(r)return r;if(!r&&n>-1){const o=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(o)?o[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let Sp=null;const DU=()=>{if(Sp!==null)return Sp;try{if(Sp=typeof window<"u"&&window.localStorage!==null,!Sp)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Sp=!1}return Sp};var noe={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&DU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&DU()&&window.localStorage.setItem(n,t)}};let Np=null;const RU=()=>{if(Np!==null)return Np;try{if(Np=typeof window<"u"&&window.sessionStorage!==null,!Np)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Np=!1}return Np};var roe={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&RU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&RU()&&window.sessionStorage.setItem(n,t)}},ioe={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let s=0;s<n.length;s++)e.push(n[s]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},aoe={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}},soe={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}},ooe={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const n=typeof e=="number"?e+1:1,r=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}};let Y9=!1;try{document.cookie,Y9=!0}catch{}const Q9=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Y9||Q9.splice(1,1);const loe=()=>({order:Q9,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Z9{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=Yse(n,this.options||{},loe()),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(Jse),this.addDetector(eoe),this.addDetector(noe),this.addDetector(roe),this.addDetector(ioe),this.addDetector(aoe),this.addDetector(soe),this.addDetector(ooe),this.addDetector(toe)}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&&!Qse(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)}))}}Z9.type="languageDetector";const coe={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 / Hostname",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",nozzleRack:"Nozzle Rack",nozzleDocked:"Docked",nozzleMounted:"Mounted",nozzleActive:"Active",nozzleIdle:"Idle",nozzleDiameter:"Diameter",nozzleType:"Type",nozzleStatus:"Status",nozzleFilament:"Filament",nozzleWear:"Wear",nozzleMaxTemp:"Max Temp",nozzleSerial:"Serial",nozzleHardenedSteel:"Hardened Steel",nozzleStainlessSteel:"Stainless Steel",nozzleTungstenCarbide:"Tungsten Carbide",nozzleFlow:"Flow",nozzleHighFlow:"High Flow",nozzleStandardFlow:"Standard",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}}",firmwareUpToDate:"Firmware {{version}} — Up to date",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",titleUpToDate:"Firmware Info",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",uploadFailed:"Failed to start upload: {{error}}",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 Slicer",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",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 Slicer",openInBambuStudioToSlice:"Open in Slicer 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}}",nextInQueue:"Next in queue",clearPlate:"Clear Plate & Start Next",clearPlateSuccess:"Plate cleared — ready for next print",plateReady:"Plate cleared — ready for next print",sections:{currentlyPrinting:"Currently Printing",queued:"Queued",history:"History"},status:{pending:"Pending",waiting:"Waiting",printing:"Printing",paused:"Paused",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:"Authentication",backup:"Backup",emailAuth:"Email Authentication"},email:{smtpSettings:"SMTP Configuration",smtpHost:"SMTP Server",smtpPort:"SMTP Port",security:"Security",authentication:"Authentication",username:"Username",password:"Password",fromEmail:"From Email",fromName:"From Name",testConnection:"Test SMTP Connection",testRecipient:"Test Recipient Email",sendTest:"Send Test Email",sending:"Sending...",save:"Save Settings",saving:"Saving...",advancedAuth:"Advanced Authentication",advancedAuthEnabled:"Advanced Authentication is enabled",advancedAuthEnabledDesc:"Email-based user management features are active. New users will receive auto-generated passwords via email, and users can reset their passwords through the forgot password feature.",advancedAuthDisabled:"Advanced Authentication is disabled",advancedAuthDisabledDesc:"Enable advanced authentication to activate email-based features for user management.",enable:"Enable",disable:"Disable",feature1:"Passwords are auto-generated and emailed to new users",feature2:"Users can login with username or email",feature3:"Forgot password feature is available",feature4:"Admins can reset user passwords via email",errors:{requiredFields:"Please fill in all required fields",usernameRequired:"Username is required when authentication is enabled",enterTestEmail:"Please enter a test email address",smtpServerAndEmail:"Please fill in SMTP Server and From Email before testing",usernamePasswordRequired:"Username and Password are required when authentication is enabled",configureSmtpFirst:"Please configure and test SMTP settings first"},success:{settingsSaved:"SMTP settings saved successfully"},securityOptions:{starttls:"STARTTLS (Port 587)",ssl:"SSL/TLS (Port 465)",none:"None (Port 25)"},authOptions:{enabled:"Enabled",disabled:"Disabled"}},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",environmentManagedLabel:"(Environment Managed)",autoEnabledViaEnv:"Automatically enabled via environment variables",urlFromEnvReadOnly:"Value set by HA_URL environment variable (read-only)",tokenFromEnvReadOnly:"Value set by HA_TOKEN environment variable (read-only)",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",preferredSlicer:"Preferred Slicer",preferredSlicerDescription:"Choose which slicer application to open files with",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",usernameOrEmail:"Username or Email",usernameOrEmailPlaceholder:"Username or @ Email",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.",forgotPasswordEmailMessage:"Enter your email address and we'll send you a new password.",emailAddress:"Email Address",emailPlaceholder:"your.email@example.com",cancel:"Cancel",sending:"Sending...",sendResetEmail:"Send Reset Email",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",chamberLight:"Toggle chamber light"},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",advancedAuthSubtitle:"with Advanced Authentication"},form:{username:"Username",usernamePlaceholder:"Enter username",email:"Email",emailPlaceholder:"user@example.com",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",optional:"optional",autoGeneratedPassword:"A secure password will be automatically generated and emailed to the user.",passwordManagedByAdvancedAuth:'Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.',resetPassword:"Reset Password",resettingPassword:"Resetting Password..."},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",local:"Local Profiles",kprofiles:"K-Profiles"},localProfiles:{title:"Local Profiles",subtitle:"Import and manage slicer presets from OrcaSlicer",import:"Import Profiles",importDesc:"Drop .bbscfg, .bbsflmt, .orca_filament, .zip, or .json files here",importing:"Importing...",search:"Search local presets...",noPresets:"No local presets yet",badge:"Local",edit:"Edit",delete:"Delete",cancel:"Cancel",deleteConfirmTitle:"Delete Preset",deleteConfirm:"Are you sure you want to delete this preset? This cannot be undone.",source:"Source",inheritsFrom:"Inherits",filamentType:"Type",vendor:"Vendor",compatiblePrinters:"Printers",nozzleTemp:"Nozzle Temp",cost:"Cost",density:"Density",pressureAdvance:"Pressure Advance",filament:"Filament",process:"Process",printer:"Printer",toast:{importSuccess:"{{count}} preset(s) imported",importSkipped:"{{count}} preset(s) skipped (duplicates)",importError:"{{count}} error(s) during import",deleted:"Preset deleted",updated:"Preset updated"}},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",totpCode:"Authenticator Code",checkEmail:"Check your email ({{email}}) for a 6-digit code",enterTotpHint:"Enter the 6-digit code from your authenticator app",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",enterTotp:"Enter code from your authenticator app",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",collectItem7:"Printer connectivity and firmware versions",collectItem8:"Integration status (Spoolman, MQTT, HA)",collectItem9:"Network interfaces (subnets only)",collectItem10:"Python package versions",collectItem11:"Database health checks",collectItem12:"Docker environment details"},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",threemfDetected:"3MF files detected",threemfExtractionInfo:"Printer model, material, color, and print settings will be automatically extracted from 3MF 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",schedulePrint:"Schedule",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",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",fillSourceLabel:"(Spoolman)",weight:"Weight",remaining:"Remaining",disableWeightSync:"Disable AMS Estimated Weight Sync",disableWeightSyncDesc:"Don't update remaining capacity from AMS estimates. Use this if you prefer Spoolman's usage tracking over AMS percentage-based estimates. New spools will still use the AMS estimate as their initial weight.",reportPartialUsage:"Report Partial Usage for Failed Prints",reportPartialUsageDesc:"When a print fails or is cancelled, report the estimated filament used up to that point based on layer progress."},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",sameTypeDifferentColor:"Same type, different color",filamentTypeNotLoaded:"Filament type not loaded",openCalendar:"Open calendar"},backup:{title:"Backup & Restore",createBackup:"Create Backup",restoreBackup:"Restore Backup",restoreDescription:"Replace all data from a backup file",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",restoreNote:"Virtual Printer will be stopped during restore"},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"}},virtualPrinter:{title:"Virtual Printer",running:"Running",stopped:"Stopped",description:{default:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing.",proxy:"Enable a proxy that relays slicer traffic to a real printer, allowing remote printing over any network."},enable:{title:"Enable Virtual Printer",visibleInSlicer:'Visible as "Bambuddy" in slicer discovery',proxyingTo:"Proxying to {{name}}",notActive:"Not active"},model:{title:"Printer Model",description:"Select which printer model to emulate.",restartWarning:"Changing the model will restart the virtual printer"},accessCode:{title:"Access Code",isSet:"Access code is set",notSet:"No access code set - required to enable",placeholder:"Enter 8-char code",placeholderChange:"Enter new code to change",hint:"Must be exactly 8 characters. Used by slicers to authenticate.",charCount:"({{count}}/8)"},targetPrinter:{title:"Target Printer",configured:"Proxy target configured",notConfigured:"No target printer selected - required for proxy mode",placeholder:"Select a printer...",hint:"Select the printer to proxy slicer traffic to. The printer must be in LAN mode.",noPrinters:"No printers configured. Add a printer first to use proxy mode."},remoteInterface:{title:"Network Interface Override",configured:"Interface override active",optional:"Optional - use if auto-detected IP is wrong (e.g. multiple NICs, Docker, VPN)",placeholder:"Auto-detect (default)...",hint:"Override the IP address advertised via SSDP and used in the TLS certificate. Useful when Bambuddy has multiple network interfaces."},mode:{title:"Mode",archive:"Archive",archiveDesc:"Archive files immediately",review:"Review",reviewDesc:"Review before archiving",queue:"Queue",queueDesc:"Archive and add to queue",proxy:"Proxy",proxyDesc:"Relay to real printer"},setupRequired:{title:"Setup Required",description:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings.",readGuide:"Read the setup guide before enabling"},howItWorks:{title:"How it works",titleProxy:"How it works (Proxy Mode)",step1:"Complete the setup guide for your platform",step2:"Enable the virtual printer and set an access code",step3:'In Bambu Studio or OrcaSlicer, go to "Add Printer"',step4:'The "Bambuddy" printer should appear in the discovery list',step5:"Connect using the access code you set",step6:'When you "print" to Bambuddy, the 3MF file is archived instead',proxyStep1:"Select the target printer (must be in LAN mode)",proxyStep2:"For cross-network: select the slicer network interface",proxyStep3:"Enable the proxy - printer appears in slicer discovery via SSDP",proxyStep4:"Connect using the printer's access code",proxyStep5:"Print as normal - traffic is relayed through Bambuddy",proxyStep6:"Camera streaming requires NAT/IP forwarding (see docs)"},status:{title:"Status Details",printerName:"Printer Name",model:"Model",serialNumber:"Serial Number",mode:"Mode",pendingFiles:"Pending Files",targetPrinter:"Target Printer",ftpPort:"FTP Port",mqttPort:"MQTT Port",ftpConnections:"FTP Connections",mqttConnections:"MQTT Connections"},toast:{updated:"Virtual printer settings updated",failedToUpdate:"Failed to update settings",accessCodeRequired:"Please set an access code first",targetPrinterRequired:"Please select a target printer first",accessCodeEmpty:"Access code cannot be empty",accessCodeLength:"Access code must be exactly 8 characters"}},modelViewer:{openInSlicer:"Open in Slicer",tabs:{model:"3D Model",gcode:"G-code Preview"},notAvailable:"not available",notSliced:"not sliced",plates:"Plates",allPlates:"All Plates",plateNumber:"Plate {{number}}",plateCount:"{{count}} plate",plateCount_other:"{{count}} plates",objectCount:"{{count}} object",objectCount_other:"{{count}} objects",filamentCount:"{{count}} filament",filamentCount_other:"{{count}} filaments",eta:"ETA {{minutes}} min",noPreview:"No preview available for this file",pagination:{pageOf:"Page {{current}} of {{total}}",prev:"Prev",next:"Next"},errors:{failedToLoad:"Failed to load file",noMeshes:"No meshes found in 3MF file",unsupportedFormat:"Unsupported file format"}},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)"},smartPlugs:{offline:"Offline",admin:"Admin",openPlugAdminPage:"Open plug admin page",deleteSmartPlug:"Delete Smart Plug",turnOnSmartPlug:"Turn On Smart Plug",turnOffSmartPlug:"Turn Off Smart Plug",turnOn:"Turn On",turnOff:"Turn Off",addSmartPlug:{scanningNetwork:"Scanning network...",chooseEntity:"Choose an entity...",connectionFailed:"Connection failed",searchEntities:"Search entities...",searchPowerSensors:"Search power sensors...",searchEnergySensors:"Search energy sensors...",placeholders:{plugName:"Living Room Plug",mqttStateOnValue:"ON, true, 1",mqttSameAsPower:"Same as power topic, or different"}}},richTextEditor:{bold:"Bold",italic:"Italic",underline:"Underline",bulletList:"Bullet List",numberedList:"Numbered List",alignLeft:"Align Left",alignCenter:"Align Center",alignRight:"Align Right",addLink:"Add Link",removeLink:"Remove Link"},externalLinks:{noLinksConfigured:"No external links configured",deleteLink:"Delete Link",removeCustomIcon:"Remove custom icon",openInNewTab:"Open in new tab",placeholders:{linkName:"My Link"}},keyboardShortcuts:{title:"Keyboard Shortcuts",navigation:"Navigation",archivesSection:"Archives",kProfilesSection:"K-Profiles",generalSection:"General",shortcuts:{goToPrinters:"Go to Printers",goToArchives:"Go to Archives",goToQueue:"Go to Queue",goToStats:"Go to Statistics",goToProfiles:"Go to Cloud Profiles",goToSettings:"Go to Settings",focusSearch:"Focus search",openUploadModal:"Open upload modal",clearSelection:"Clear selection / blur input",contextMenu:"Context menu on cards",refreshProfiles:"Refresh profiles",newProfile:"New profile",exitSelectionMode:"Exit selection mode",showHelp:"Show this help"},footer:"Press Esc or click outside to close"},notificationLog:{title:"Notification Log",events:{printStarted:"Print Started",printComplete:"Print Complete",printFailed:"Print Failed",printStopped:"Print Stopped",progress:"Progress",printerOffline:"Printer Offline",printerError:"Printer Error",lowFilament:"Low Filament",maintenanceDue:"Maintenance Due",test:"Test"},timeAgo:{justNow:"Just now",minutesAgo:"{{minutes}}m ago",hoursAgo:"{{hours}}h ago"}},restoreBackup:{title:"Restore Backup",restoring:"Restoring...",restoreComplete:"Restore Complete",restoreFailed:"Restore Failed",importSettings:"Import settings from a backup file",pleaseWait:"Please wait while your data is being restored",clickToSelect:"Click to select backup file (.json or .zip)",howDuplicateHandling:"How duplicate handling works:",categories:{printers:"Printers",smartPlugs:"Smart Plugs",notificationProviders:"Notification Providers",filaments:"Filaments",archives:"Archives",pendingUploads:"Pending Uploads",settingsTemplates:"Settings & Templates"},matchingInfo:{printers:"matched by serial number",smartPlugs:"matched by IP address",notificationProviders:"matched by name",filaments:"matched by name + type + brand",archives:"matched by content hash",pendingUploads:"matched by filename",settingsTemplates:"always overwritten"},replaceExisting:"Replace existing data",keepExisting:"Keep existing data",replaceDescription:"Overwrite items that already exist with backup data",keepDescription:"Only restore items that don't already exist",caution:"Caution:",cautionText:"Overwriting will replace your current configurations with backup data. Printer access codes are never overwritten for security.",itemsRestored:"Items Restored",itemsSkipped:"Items Skipped",restored:"Restored",skipped:"Skipped (already exist)",filesLabel:"Files (3MF, thumbnails, etc.)",newApiKeysGenerated:"New API Keys Generated",newApiKeysWarning:"These keys are only shown once. Copy them now!",processingBackup:"Processing backup file...",noDataFound:"No data was found to restore in the backup file.",failedToRestore:"Failed to restore backup. Please check the file format."},backupExport:{title:"Export Backup",selectData:"Select data to include",selectAll:"Select All",selectNone:"Select None",categoryDescriptions:{settings:"Language, theme, update preferences",notifications:"ntfy, Pushover, Discord, etc.",templates:"Custom message templates",smartPlugs:"Tasmota plug configurations",externalLinks:"Sidebar links to external services",printers:"Printer info (access codes excluded)",plateDetection:"Empty plate reference images",filaments:"Filament types and costs",maintenance:"Custom maintenance schedules",archives:"All print data + files (3MF, thumbnails, photos)",projects:"Projects, BOM items, and attachments",pendingUploads:"Virtual printer uploads awaiting review",apiKeys:"Webhook API keys (new keys generated on import)"},requiresPrinters:"Requires Printers to be selected",zipFileWarning:"ZIP file will be created.",zipFileDescription:"Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file.",includeAccessCodes:"Include Access Codes",includeAccessCodesDescription:"For transferring to another machine",includeAccessCodesWarning:"Access codes will be included in plain text. Keep this backup file secure!",categoriesSelected:"{{selectedCount}} categories selected"},pendingUploads:{placeholders:{notes:"Add notes about this print..."},discardUpload:"Discard Upload",archiveAllUploads:"Archive All Uploads",discardAllUploads:"Discard All Uploads",archive:"Archive",timeAgo:{justNow:"Just now",minutesAgo:"{{minutes}}m ago",hoursAgo:"{{hours}}h ago",daysAgo:"{{days}}d ago"}},apiBrowser:{placeholders:{requestBody:"JSON request body...",searchEndpoints:"Search endpoints..."}},configureAmsSlot:{searchPresets:"Search presets...",colorPlaceholder:"Color name or hex (e.g., brown, FF8800)",clearCustomColor:"Clear custom color",noCloudPresets:"No cloud presets. Login to Bambu Cloud to sync.",noMatchingPresets:"No matching presets found.",custom:"Custom",settingsSentToPrinter:"Settings sent to printer",filamentProfile:"Filament Profile"},githubBackup:{title:"GitHub Backup",history:"History",downloadBackup:"Download Backup",restoreBackup:"Restore Backup",noBackupsYet:"No backups yet"},emailSettings:{placeholders:{fromName:"BamBuddy"}},tagManagement:{searchTags:"Search tags...",renameTag:"Rename tag",deleteTag:"Delete tag"},notificationTemplates:{placeholders:{title:"Notification title...",body:"Notification body..."}},batchTag:{placeholders:{newTag:"Enter new tag..."}},photoGallery:{deletePhoto:"Delete Photo"},filamentHoverCard:{copySpoolUuid:"Copy spool UUID"},kProfilesView:{hasNote:"Has note",copyProfile:"Copy profile"},layout:{openMenu:"Open menu",noPermissionSystemInfo:"You do not have permission to view system information"},dashboard:{dragToReorder:"Drag to reorder",hideWidget:"Hide widget"},notificationProviderCard:{deleteNotificationProvider:"Delete Notification Provider"},fileManagerModal:{closeFileManager:"Close file manager",sortFiles:"Sort files",goToParentFolder:"Go to parent folder",threeView:"3D View"},embeddedCameraViewer:{refreshStream:"Refresh stream",close:"Close",zoomOut:"Zoom out",resetZoom:"Reset zoom",zoomIn:"Zoom in",dragToResize:"Drag to resize"},timelapseViewer:{skipBack5s:"Skip back 5s",skipForward5s:"Skip forward 5s"},notificationProviders:{descriptions:{email:"SMTP email notifications",telegram:"Notifications via Telegram bot",discord:"Send to Discord channel via webhook",ntfy:"Free, self-hostable push notifications",pushover:"Simple, reliable push notifications",callmebot:"Free WhatsApp notifications via CallMeBot",webhook:"Generic HTTP POST to any URL"}},logViewer:{searchPlaceholder:"Search message or logger name...",noLogEntries:"No log entries found"},switchbarPopover:{noSwitchesInSwitchbar:"No switches in switchbar"},projectPageModal:{placeholders:{title:"Title",designer:"Designer",license:"License",description:"Enter description...",profileTitle:"Profile Title",profileDescription:"Profile description..."}},spoolmanSettings:{}},uoe={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 / Hostname",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",nozzleRack:"Düsenhalter",nozzleDocked:"Angedockt",nozzleMounted:"Montiert",nozzleActive:"Aktiv",nozzleIdle:"Inaktiv",nozzleDiameter:"Durchmesser",nozzleType:"Typ",nozzleStatus:"Status",nozzleFilament:"Filament",nozzleWear:"Verschleiß",nozzleMaxTemp:"Max Temp",nozzleSerial:"Seriennr.",nozzleHardenedSteel:"Gehärteter Stahl",nozzleStainlessSteel:"Edelstahl",nozzleTungstenCarbide:"Wolframkarbid",nozzleFlow:"Durchfluss",nozzleHighFlow:"High Flow",nozzleStandardFlow:"Standard",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}}",firmwareUpToDate:"Firmware {{version}} — Aktuell",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",titleUpToDate:"Firmware-Info",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",uploadFailed:"Upload fehlgeschlagen: {{error}}",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:"Im Slicer ö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",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:"Im Slicer öffnen",openInBambuStudioToSlice:"Im Slicer ö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}}",nextInQueue:"Nächster in der Warteschlange",clearPlate:"Druckplatte freigeben & Nächsten starten",clearPlateSuccess:"Druckplatte freigegeben — bereit für nächsten Druck",plateReady:"Druckplatte freigegeben — bereit für nächsten Druck",sections:{currentlyPrinting:"Aktuell druckend",queued:"In Warteschlange",history:"Verlauf"},status:{pending:"Ausstehend",waiting:"Wartend",printing:"Druckt",paused:"Pausiert",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:"Authentifizierung",backup:"Sicherung",emailAuth:"E-Mail-Authentifizierung"},email:{smtpSettings:"SMTP-Konfiguration",smtpHost:"SMTP-Server",smtpPort:"SMTP-Port",security:"Sicherheit",authentication:"Authentifizierung",username:"Benutzername",password:"Passwort",fromEmail:"Absender-E-Mail",fromName:"Absendername",testConnection:"SMTP-Verbindung testen",testRecipient:"Test-Empfänger-E-Mail",sendTest:"Test-E-Mail senden",sending:"Wird gesendet...",save:"Einstellungen speichern",saving:"Wird gespeichert...",advancedAuth:"Erweiterte Authentifizierung",advancedAuthEnabled:"Erweiterte Authentifizierung ist aktiviert",advancedAuthEnabledDesc:"E-Mail-basierte Benutzerverwaltungsfunktionen sind aktiv. Neue Benutzer erhalten automatisch generierte Passwörter per E-Mail und können ihr Passwort über die Passwort vergessen Funktion zurücksetzen.",advancedAuthDisabled:"Erweiterte Authentifizierung ist deaktiviert",advancedAuthDisabledDesc:"Aktivieren Sie die erweiterte Authentifizierung, um E-Mail-basierte Funktionen für die Benutzerverwaltung zu aktivieren.",enable:"Aktivieren",disable:"Deaktivieren",feature1:"Passwörter werden automatisch generiert und an neue Benutzer gesendet",feature2:"Benutzer können sich mit Benutzername oder E-Mail anmelden",feature3:"Passwort vergessen Funktion ist verfügbar",feature4:"Administratoren können Benutzerpasswörter per E-Mail zurücksetzen",errors:{requiredFields:"Bitte füllen Sie alle Pflichtfelder aus",usernameRequired:"Benutzername ist erforderlich, wenn Authentifizierung aktiviert ist",enterTestEmail:"Bitte geben Sie eine Test-E-Mail-Adresse ein",smtpServerAndEmail:"Bitte füllen Sie SMTP-Server und Absender-E-Mail aus, bevor Sie testen",usernamePasswordRequired:"Benutzername und Passwort sind erforderlich, wenn Authentifizierung aktiviert ist",configureSmtpFirst:"Bitte konfigurieren und testen Sie zuerst die SMTP-Einstellungen"},success:{settingsSaved:"SMTP-Einstellungen erfolgreich gespeichert"},securityOptions:{starttls:"STARTTLS (Port 587)",ssl:"SSL/TLS (Port 465)",none:"Keine (Port 25)"},authOptions:{enabled:"Aktiviert",disabled:"Deaktiviert"}},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",environmentManagedLabel:"(Umgebungsvariable)",autoEnabledViaEnv:"Automatisch über Umgebungsvariablen aktiviert",urlFromEnvReadOnly:"Wert wird über HA_URL Umgebungsvariable gesetzt (schreibgeschützt)",tokenFromEnvReadOnly:"Wert wird über HA_TOKEN Umgebungsvariable gesetzt (schreibgeschützt)",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",preferredSlicer:"Bevorzugter Slicer",preferredSlicerDescription:"Wähle die Slicer-Anwendung zum Öffnen von Dateien",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",usernameOrEmail:"Benutzername oder E-Mail",usernameOrEmailPlaceholder:"Benutzername oder @ E-Mail",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.",forgotPasswordEmailMessage:"Geben Sie Ihre E-Mail-Adresse ein und wir senden Ihnen ein neues Passwort.",emailAddress:"E-Mail-Adresse",emailPlaceholder:"ihre.email@beispiel.de",cancel:"Abbrechen",sending:"Wird gesendet...",sendResetEmail:"Zurücksetzungs-E-Mail senden",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",chamberLight:"Kammerbeleuchtung umschalten"},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",advancedAuthSubtitle:"mit erweiterter Authentifizierung"},form:{username:"Benutzername",usernamePlaceholder:"Benutzernamen eingeben",email:"E-Mail",emailPlaceholder:"benutzer@beispiel.de",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",optional:"optional",autoGeneratedPassword:"Ein sicheres Passwort wird automatisch generiert und per E-Mail an den Benutzer gesendet.",passwordManagedByAdvancedAuth:'Das Passwort wird durch erweiterte Authentifizierung verwaltet. Verwenden Sie "Passwort zurücksetzen", um ein neues Passwort per E-Mail an den Benutzer zu senden.',resetPassword:"Passwort zurücksetzen",resettingPassword:"Passwort wird zurückgesetzt..."},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",local:"Lokale Profile",kprofiles:"K-Profile"},localProfiles:{title:"Lokale Profile",subtitle:"Slicer-Voreinstellungen aus OrcaSlicer importieren und verwalten",import:"Profile importieren",importDesc:".bbscfg-, .bbsflmt-, .orca_filament-, .zip- oder .json-Dateien hier ablegen",importing:"Importiere...",search:"Lokale Voreinstellungen durchsuchen...",noPresets:"Noch keine lokalen Voreinstellungen",badge:"Lokal",edit:"Bearbeiten",delete:"Löschen",cancel:"Abbrechen",deleteConfirmTitle:"Voreinstellung löschen",deleteConfirm:"Möchten Sie diese Voreinstellung wirklich löschen? Dies kann nicht rückgängig gemacht werden.",source:"Quelle",inheritsFrom:"Erbt von",filamentType:"Typ",vendor:"Hersteller",compatiblePrinters:"Drucker",nozzleTemp:"Düsentemperatur",cost:"Kosten",density:"Dichte",pressureAdvance:"Druckvorschub",filament:"Filament",process:"Prozess",printer:"Drucker",toast:{importSuccess:"{{count}} Voreinstellung(en) importiert",importSkipped:"{{count}} Voreinstellung(en) übersprungen (Duplikate)",importError:"{{count}} Fehler beim Import",deleted:"Voreinstellung gelöscht",updated:"Voreinstellung aktualisiert"}},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",totpCode:"Authenticator-Code",checkEmail:"Prüfen Sie Ihre E-Mail ({{email}}) für einen 6-stelligen Code",enterTotpHint:"Geben Sie den 6-stelligen Code aus Ihrer Authenticator-App ein",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",enterTotp:"Geben Sie den Code aus Ihrer Authenticator-App ein",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",collectItem7:"Drucker-Verbindungsstatus und Firmware-Versionen",collectItem8:"Integrationsstatus (Spoolman, MQTT, HA)",collectItem9:"Netzwerkschnittstellen (nur Subnetze)",collectItem10:"Python-Paketversionen",collectItem11:"Datenbankzustandsprüfungen",collectItem12:"Docker-Umgebungsdetails"},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",threemfDetected:"3MF-Dateien erkannt",threemfExtractionInfo:"Druckermodell, Material, Farbe und Druckeinstellungen werden automatisch aus 3MF-Dateien extrahiert.",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",schedulePrint:"Planen",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",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",fillSourceLabel:"(Spoolman)",weight:"Gewicht",remaining:"Verbleibend",disableWeightSync:"AMS-Gewichtsschätzung deaktivieren",disableWeightSyncDesc:"Verbleibende Kapazität nicht aus AMS-Schätzungen aktualisieren. Verwenden Sie dies, wenn Sie die Verbrauchserfassung von Spoolman gegenüber den prozentualen AMS-Schätzungen bevorzugen. Neue Spulen verwenden weiterhin die AMS-Schätzung als Anfangsgewicht.",reportPartialUsage:"Teilverbrauch bei fehlgeschlagenen Drucken melden",reportPartialUsageDesc:"Wenn ein Druck fehlschlägt oder abgebrochen wird, den geschätzten Filamentverbrauch bis zu diesem Zeitpunkt basierend auf dem Schichtfortschritt melden."},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",sameTypeDifferentColor:"Gleicher Typ, andere Farbe",filamentTypeNotLoaded:"Filamenttyp nicht geladen",openCalendar:"Kalender öffnen"},backup:{title:"Sichern & Wiederherstellen",createBackup:"Sicherung erstellen",restoreBackup:"Sicherung wiederherstellen",restoreDescription:"Alle Daten aus einer Sicherungsdatei ersetzen",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",restoreNote:"Virtueller Drucker wird während der Wiederherstellung gestoppt"},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"}},virtualPrinter:{title:"Virtueller Drucker",running:"Läuft",stopped:"Gestoppt",description:{default:"Aktiviere einen virtuellen Drucker, der in Bambu Studio und OrcaSlicer erscheint. Dateien, die an diesen Drucker gesendet werden, werden direkt archiviert ohne zu drucken.",proxy:"Aktiviere einen Proxy, der Slicer-Datenverkehr an einen echten Drucker weiterleitet, um Ferndruck über jedes Netzwerk zu ermöglichen."},enable:{title:"Virtuellen Drucker aktivieren",visibleInSlicer:'Sichtbar als "Bambuddy" in der Slicer-Erkennung',proxyingTo:"Proxy zu {{name}}",notActive:"Nicht aktiv"},model:{title:"Druckermodell",description:"Wähle welches Druckermodell emuliert werden soll.",restartWarning:"Das Ändern des Modells startet den virtuellen Drucker neu"},accessCode:{title:"Zugangscode",isSet:"Zugangscode ist gesetzt",notSet:"Kein Zugangscode gesetzt - erforderlich zum Aktivieren",placeholder:"8-Zeichen-Code eingeben",placeholderChange:"Neuen Code eingeben zum Ändern",hint:"Muss genau 8 Zeichen lang sein. Wird von Slicern zur Authentifizierung verwendet.",charCount:"({{count}}/8)"},targetPrinter:{title:"Zieldrucker",configured:"Proxy-Ziel konfiguriert",notConfigured:"Kein Zieldrucker ausgewählt - erforderlich für Proxy-Modus",placeholder:"Drucker auswählen...",hint:"Wähle den Drucker aus, an den der Slicer-Datenverkehr weitergeleitet werden soll. Der Drucker muss im LAN-Modus sein.",noPrinters:"Keine Drucker konfiguriert. Füge zuerst einen Drucker hinzu, um den Proxy-Modus zu verwenden."},remoteInterface:{title:"Netzwerkschnittstelle überschreiben",configured:"Schnittstellenüberschreibung aktiv",optional:"Optional - verwenden wenn die automatisch erkannte IP falsch ist (z.B. mehrere NICs, Docker, VPN)",placeholder:"Automatisch erkennen (Standard)...",hint:"Überschreibt die per SSDP beworbene und im TLS-Zertifikat verwendete IP-Adresse. Nützlich wenn Bambuddy mehrere Netzwerkschnittstellen hat."},mode:{title:"Modus",archive:"Archivieren",archiveDesc:"Dateien sofort archivieren",review:"Überprüfen",reviewDesc:"Vor dem Archivieren überprüfen",queue:"Warteschlange",queueDesc:"Archivieren und zur Warteschlange hinzufügen",proxy:"Proxy",proxyDesc:"An echten Drucker weiterleiten"},setupRequired:{title:"Einrichtung erforderlich",description:"Die virtuelle Druckerfunktion erfordert zusätzliche Systemkonfiguration, bevor sie funktioniert. Dies beinhaltet Portweiterleitung, Firewall-Regeln und plattformspezifische Einstellungen.",readGuide:"Lese die Einrichtungsanleitung vor dem Aktivieren"},howItWorks:{title:"So funktioniert es",titleProxy:"So funktioniert es (Proxy-Modus)",step1:"Schließe die Einrichtungsanleitung für deine Plattform ab",step2:"Aktiviere den virtuellen Drucker und setze einen Zugangscode",step3:'In Bambu Studio oder OrcaSlicer gehe zu "Drucker hinzufügen"',step4:'Der "Bambuddy"-Drucker sollte in der Erkennungsliste erscheinen',step5:"Verbinde mit dem von dir gesetzten Zugangscode",step6:'Wenn du zu Bambuddy "druckst", wird die 3MF-Datei stattdessen archiviert',proxyStep1:"Wähle den Zieldrucker (muss im LAN-Modus sein)",proxyStep2:"Bei Netzwerkübergreifend: Wähle die Slicer-Netzwerkschnittstelle",proxyStep3:"Aktiviere den Proxy - Drucker erscheint per SSDP in der Slicer-Erkennung",proxyStep4:"Verbinde mit dem Zugangscode des Druckers",proxyStep5:"Drucke wie gewohnt - der Datenverkehr wird über Bambuddy weitergeleitet",proxyStep6:"Kamera-Streaming erfordert NAT/IP-Weiterleitung (siehe Dokumentation)"},status:{title:"Status-Details",printerName:"Druckername",model:"Modell",serialNumber:"Seriennummer",mode:"Modus",pendingFiles:"Ausstehende Dateien",targetPrinter:"Zieldrucker",ftpPort:"FTP-Port",mqttPort:"MQTT-Port",ftpConnections:"FTP-Verbindungen",mqttConnections:"MQTT-Verbindungen"},toast:{updated:"Virtuelle Druckereinstellungen aktualisiert",failedToUpdate:"Einstellungen konnten nicht aktualisiert werden",accessCodeRequired:"Bitte zuerst einen Zugangscode setzen",targetPrinterRequired:"Bitte zuerst einen Zieldrucker auswählen",accessCodeEmpty:"Zugangscode darf nicht leer sein",accessCodeLength:"Zugangscode muss genau 8 Zeichen lang sein"}},modelViewer:{openInSlicer:"Im Slicer öffnen",tabs:{model:"3D-Modell",gcode:"G-Code Vorschau"},notAvailable:"nicht verfügbar",notSliced:"nicht geslicet",plates:"Platten",allPlates:"Alle Platten",plateNumber:"Platte {{number}}",plateCount:"{{count}} Platte",plateCount_other:"{{count}} Platten",objectCount:"{{count}} Objekt",objectCount_other:"{{count}} Objekte",filamentCount:"{{count}} Filament",filamentCount_other:"{{count}} Filamente",eta:"ETA {{minutes}} Min",noPreview:"Keine Vorschau für diese Datei verfügbar",pagination:{pageOf:"Seite {{current}} von {{total}}",prev:"Zurück",next:"Weiter"},errors:{failedToLoad:"Datei konnte nicht geladen werden",noMeshes:"Keine Meshes in 3MF-Datei gefunden",unsupportedFormat:"Nicht unterstütztes Dateiformat"}},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)"},smartPlugs:{offline:"Offline",admin:"Admin",openPlugAdminPage:"Plug-Admin-Seite öffnen",deleteSmartPlug:"Smart Plug löschen",turnOnSmartPlug:"Smart Plug einschalten",turnOffSmartPlug:"Smart Plug ausschalten",turnOn:"Einschalten",turnOff:"Ausschalten",addSmartPlug:{scanningNetwork:"Netzwerk wird durchsucht...",chooseEntity:"Entität auswählen...",connectionFailed:"Verbindung fehlgeschlagen",searchEntities:"Entitäten suchen...",searchPowerSensors:"Leistungssensoren suchen...",searchEnergySensors:"Energiesensoren suchen...",placeholders:{plugName:"Wohnzimmer Steckdose",mqttStateOnValue:"ON, true, 1",mqttSameAsPower:"Gleich wie Leistungs-Topic oder anders"}}},richTextEditor:{bold:"Fett",italic:"Kursiv",underline:"Unterstrichen",bulletList:"Aufzählungsliste",numberedList:"Nummerierte Liste",alignLeft:"Linksbündig",alignCenter:"Zentriert",alignRight:"Rechtsbündig",addLink:"Link hinzufügen",removeLink:"Link entfernen"},externalLinks:{noLinksConfigured:"Keine externen Links konfiguriert",deleteLink:"Link löschen",removeCustomIcon:"Benutzerdefiniertes Symbol entfernen",openInNewTab:"In neuem Tab öffnen",placeholders:{linkName:"Mein Link"}},keyboardShortcuts:{title:"Tastaturkürzel",navigation:"Navigation",archivesSection:"Archive",kProfilesSection:"K-Profile",generalSection:"Allgemein",shortcuts:{goToPrinters:"Zu Drucker gehen",goToArchives:"Zu Archiv gehen",goToQueue:"Zur Warteschlange gehen",goToStats:"Zu Statistiken gehen",goToProfiles:"Zu Cloud-Profilen gehen",goToSettings:"Zu Einstellungen gehen",focusSearch:"Suche fokussieren",openUploadModal:"Upload-Modal öffnen",clearSelection:"Auswahl löschen / Eingabe aufheben",contextMenu:"Kontextmenü auf Karten",refreshProfiles:"Profile aktualisieren",newProfile:"Neues Profil",exitSelectionMode:"Auswahlmodus beenden",showHelp:"Diese Hilfe anzeigen"},footer:"Drücken Sie Esc oder klicken Sie außerhalb, um zu schließen"},notificationLog:{title:"Benachrichtigungsprotokoll",events:{printStarted:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",progress:"Fortschritt",printerOffline:"Drucker offline",printerError:"Druckerfehler",lowFilament:"Wenig Filament",maintenanceDue:"Wartung fällig",test:"Test"},timeAgo:{justNow:"Gerade eben",minutesAgo:"vor {{minutes}}m",hoursAgo:"vor {{hours}}h"}},restoreBackup:{title:"Backup wiederherstellen",restoring:"Wird wiederhergestellt...",restoreComplete:"Wiederherstellung abgeschlossen",restoreFailed:"Wiederherstellung fehlgeschlagen",importSettings:"Einstellungen aus Backup-Datei importieren",pleaseWait:"Bitte warten Sie, während Ihre Daten wiederhergestellt werden",clickToSelect:"Klicken Sie, um Backup-Datei auszuwählen (.json oder .zip)",howDuplicateHandling:"So funktioniert die Duplikatbehandlung:",categories:{printers:"Drucker",smartPlugs:"Smart Plugs",notificationProviders:"Benachrichtigungsanbieter",filaments:"Filamente",archives:"Archive",pendingUploads:"Ausstehende Uploads",settingsTemplates:"Einstellungen & Vorlagen"},matchingInfo:{printers:"abgeglichen nach Seriennummer",smartPlugs:"abgeglichen nach IP-Adresse",notificationProviders:"abgeglichen nach Name",filaments:"abgeglichen nach Name + Typ + Marke",archives:"abgeglichen nach Inhalts-Hash",pendingUploads:"abgeglichen nach Dateiname",settingsTemplates:"immer überschrieben"},replaceExisting:"Vorhandene Daten ersetzen",keepExisting:"Vorhandene Daten behalten",replaceDescription:"Bereits vorhandene Elemente mit Backup-Daten überschreiben",keepDescription:"Nur Elemente wiederherstellen, die noch nicht existieren",caution:"Vorsicht:",cautionText:"Das Überschreiben ersetzt Ihre aktuellen Konfigurationen durch Backup-Daten. Drucker-Zugangscodes werden aus Sicherheitsgründen niemals überschrieben.",itemsRestored:"Wiederhergestellte Elemente",itemsSkipped:"Übersprungene Elemente",restored:"Wiederhergestellt",skipped:"Übersprungen (existieren bereits)",filesLabel:"Dateien (3MF, Thumbnails, etc.)",newApiKeysGenerated:"Neue API-Schlüssel generiert",newApiKeysWarning:"Diese Schlüssel werden nur einmal angezeigt. Kopieren Sie sie jetzt!",processingBackup:"Backup-Datei wird verarbeitet...",noDataFound:"In der Backup-Datei wurden keine wiederherzustellenden Daten gefunden.",failedToRestore:"Backup konnte nicht wiederhergestellt werden. Bitte überprüfen Sie das Dateiformat."},backupExport:{title:"Backup exportieren",selectData:"Zu exportierende Daten auswählen",selectAll:"Alle auswählen",selectNone:"Keine auswählen",categoryDescriptions:{settings:"Sprache, Theme, Update-Einstellungen",notifications:"ntfy, Pushover, Discord, usw.",templates:"Benutzerdefinierte Nachrichtenvorlagen",smartPlugs:"Tasmota-Plug-Konfigurationen",externalLinks:"Seitenleiste Links zu externen Diensten",printers:"Druckerinformationen (Zugangscodes ausgeschlossen)",plateDetection:"Leere Platten-Referenzbilder",filaments:"Filamenttypen und -kosten",maintenance:"Benutzerdefinierte Wartungspläne",archives:"Alle Druckdaten + Dateien (3MF, Thumbnails, Fotos)",projects:"Projekte, BOM-Elemente und Anhänge",pendingUploads:"Virtueller Drucker-Uploads zur Überprüfung",apiKeys:"Webhook-API-Schlüssel (neue Schlüssel bei Import generiert)"},requiresPrinters:"Drucker müssen ausgewählt sein",zipFileWarning:"ZIP-Datei wird erstellt.",zipFileDescription:"Enthält alle 3MF-Dateien, Thumbnails, Zeitraffer und Fotos. Dies kann eine Weile dauern und zu einer großen Datei führen.",includeAccessCodes:"Zugangscodes einschließen",includeAccessCodesDescription:"Für die Übertragung auf eine andere Maschine",includeAccessCodesWarning:"Zugangscodes werden im Klartext eingeschlossen. Bewahren Sie diese Backup-Datei sicher auf!",categoriesSelected:"{{selectedCount}} Kategorien ausgewählt"},pendingUploads:{placeholders:{notes:"Notizen zu diesem Druck hinzufügen..."},discardUpload:"Upload verwerfen",archiveAllUploads:"Alle Uploads archivieren",discardAllUploads:"Alle Uploads verwerfen",archive:"Archivieren",timeAgo:{justNow:"Gerade eben",minutesAgo:"vor {{minutes}}m",hoursAgo:"vor {{hours}}h",daysAgo:"vor {{days}}d"}},apiBrowser:{placeholders:{requestBody:"JSON-Anforderungstext...",searchEndpoints:"Endpunkte suchen..."}},configureAmsSlot:{searchPresets:"Voreinstellungen suchen...",colorPlaceholder:"Farbname oder Hex (z.B. braun, FF8800)",clearCustomColor:"Benutzerdefinierte Farbe löschen",noCloudPresets:"Keine Cloud-Voreinstellungen. Melden Sie sich bei Bambu Cloud an, um zu synchronisieren.",noMatchingPresets:"Keine passenden Voreinstellungen gefunden.",custom:"Benutzerdefiniert",settingsSentToPrinter:"Einstellungen an Drucker gesendet",filamentProfile:"Filamentprofil"},githubBackup:{title:"GitHub-Backup",history:"Verlauf",downloadBackup:"Backup herunterladen",restoreBackup:"Backup wiederherstellen",noBackupsYet:"Noch keine Backups"},emailSettings:{placeholders:{fromName:"BamBuddy"}},tagManagement:{searchTags:"Tags suchen...",renameTag:"Tag umbenennen",deleteTag:"Tag löschen"},notificationTemplates:{placeholders:{title:"Benachrichtigungstitel...",body:"Benachrichtigungstext..."}},batchTag:{placeholders:{newTag:"Neuen Tag eingeben..."}},photoGallery:{deletePhoto:"Foto löschen"},filamentHoverCard:{copySpoolUuid:"Spulen-UUID kopieren"},kProfilesView:{hasNote:"Hat Notiz",copyProfile:"Profil kopieren"},layout:{openMenu:"Menü öffnen",noPermissionSystemInfo:"Sie haben keine Berechtigung zum Anzeigen von Systeminformationen"},dashboard:{dragToReorder:"Ziehen zum Neuordnen",hideWidget:"Widget ausblenden"},notificationProviderCard:{deleteNotificationProvider:"Benachrichtigungsanbieter löschen"},fileManagerModal:{closeFileManager:"Dateimanager schließen",sortFiles:"Dateien sortieren",goToParentFolder:"Zum übergeordneten Ordner gehen",threeView:"3D-Ansicht"},embeddedCameraViewer:{refreshStream:"Stream aktualisieren",close:"Schließen",zoomOut:"Verkleinern",resetZoom:"Zoom zurücksetzen",zoomIn:"Vergrößern",dragToResize:"Ziehen zum Größe ändern"},timelapseViewer:{skipBack5s:"5s zurückspringen",skipForward5s:"5s vorspringen"},notificationProviders:{descriptions:{email:"SMTP-E-Mail-Benachrichtigungen",telegram:"Benachrichtigungen über Telegram-Bot",discord:"An Discord-Kanal über Webhook senden",ntfy:"Kostenlose, selbst hostbare Push-Benachrichtigungen",pushover:"Einfache, zuverlässige Push-Benachrichtigungen",callmebot:"Kostenlose WhatsApp-Benachrichtigungen über CallMeBot",webhook:"Generischer HTTP POST zu beliebiger URL"}},logViewer:{searchPlaceholder:"Nachricht oder Logger-Name suchen...",noLogEntries:"Keine Logeinträge gefunden"},switchbarPopover:{noSwitchesInSwitchbar:"Keine Schalter in Schalterleiste"},projectPageModal:{placeholders:{title:"Titel",designer:"Designer",license:"Lizenz",description:"Beschreibung eingeben...",profileTitle:"Profil-Titel",profileDescription:"Profilbeschreibung..."}},spoolmanSettings:{}},doe={nav:{printers:"プリンター",archives:"アーカイブ",queue:"キュー",stats:"統計",profiles:"プロファイル",maintenance:"メンテナンス",projects:"プロジェクト",files:"ファイル管理",settings:"設定",system:"システム",collapseSidebar:"サイドバーを閉じる",expandSidebar:"サイドバーを開く",update:"アップデート",updateAvailable:"アップデートあり: v{{version}}",viewOnGithub:"GitHubで表示",keyboardShortcuts:"キーボードショートカット (?)",switchToLight:"ライトモードに切替",switchToDark:"ダークモードに切替",smartSwitches:"スマートスイッチ",logout:"ログアウト",updateAvailableBanner:"バージョン {{version}} が利用可能です!",viewUpdate:"アップデートを表示"},common:{save:"保存",saving:"保存中...",cancel:"キャンセル",delete:"削除",edit:"編集",add:"追加",close:"閉じる",confirm:"確認",loading:"読み込み中...",error:"エラー",success:"成功",warning:"警告",enabled:"有効",disabled:"無効",yes:"はい",no:"いいえ",on:"オン",off:"オフ",all:"すべて",none:"なし",search:"検索",filter:"フィルター",sort:"並べ替え",refresh:"更新",download:"ダウンロード",upload:"アップロード",actions:"操作",status:"ステータス",name:"名前",description:"説明",date:"日付",time:"時間",hours:"時間",minutes:"分",seconds:"秒",disable:"無効にする",permissions:"権限",noPrinters:"プリンターが登録されていません",noData:"データがありません",required:"必須",optional:"オプション",dismiss:"閉じる",apply:"適用",clear:"クリア",noChange:"— 変更なし —",unassigned:"未割当",unknown:"不明",unknownError:"不明なエラー",today:"今日",asap:"即時",now:"今すぐ",collapse:"折りたたむ",expand:"展開",viewArchive:"アーカイブを表示",viewInFileManager:"ファイルマネージャーで表示",addedBy:"{{username}}が追加",more:"もっと見る",printer:"プリンター",type:"種類",print:"印刷",rename:"名前変更",move:"移動",create:"作成",days:"日",enable:"有効化",linkNotFound:"リンクが見つかりません",reset:"リセット",selectAll:"すべて選択",deselectAll:"すべて選択解除",unchanged:"変更なし",overdue:"期限超過",prints:"プリント",ascending:"昇順",descending:"降順",remove:"削除",duplicate:"複製",left:"左",right:"右",done:"完了",saveChanges:"変更を保存",turnOn:"オンにする",turnOff:"オフにする",deletePhoto:"写真を削除",deletePhotoConfirm:"この写真を削除しますか?元に戻せません。",project:"プロジェクト",archive:"アーカイブ",show:"表示",hide:"非表示",back:"戻る",export:"エクスポート",import:"インポート",retry:"リトライ",model:"モデル",ok:"OK"},printers:{title:"プリンター",addPrinter:"プリンターを追加",editPrinter:"プリンターを編集",deletePrinter:"プリンターを削除",printerName:"プリンター名",serialNumber:"シリアル番号",ipAddress:"IPアドレス / ホスト名",accessCode:"アクセスコード",model:"モデル",nozzleCount:"ノズル数",autoArchive:"自動アーカイブ",status:{idle:"待機中",printing:"印刷中",paused:"一時停止",offline:"オフライン",finished:"完了",unknown:"不明",error:"エラー"},temperatures:{nozzle:"ノズル",bed:"ベッド",chamber:"チャンバー"},progress:"{{percent}}% 完了",timeRemaining:"残り {{time}}",maintenanceOk:"メンテナンス正常",maintenanceWarning:"{{count}}件の警告",maintenanceWarning_plural:"{{count}}件の警告",maintenanceDue:"{{count}}件のメンテナンス期限",sort:{name:"名前",status:"ステータス",model:"モデル",location:"ロケーション",ascending:"昇順で並べ替え",descending:"降順で並べ替え"},cardSize:{small:"小",medium:"中",large:"大",extraLarge:"特大"},hideOffline:"オフラインを非表示",powerOn:"電源オン",noPrintersConfigured:"プリンターが設定されていません",readyToPrint:"印刷可能",external:"外部",deleteArchives:"印刷アーカイブを削除",willBeSkipped:"スキップされます",name:"名前",wifiSignal:{veryWeak:"非常に弱い",weak:"弱い",fair:"注意",good:"良好",excellent:"非常に良い"},maintenanceUpToDate:"すべてのメンテナンスが最新です",chamberLightOn:"チャンバーライトをオンにしました",chamberLightOff:"チャンバーライトをオフにしました",browseFiles:"プリンターのファイルを参照",hmsErrors:"クリックしてHMSエラーを表示",resume:"再開",pause:"一時停止",stop:"停止",reconnect:"再接続",mqttDebug:"MQTTデバッグ",activeNozzle:"アクティブ: {{side}}ノズル",nozzleRack:"ノズルラック",nozzleDocked:"ドッキング中",nozzleMounted:"マウント中",nozzleActive:"アクティブ",nozzleIdle:"アイドル",nozzleDiameter:"直径",nozzleType:"タイプ",nozzleStatus:"ステータス",nozzleFilament:"フィラメント",nozzleWear:"摩耗",nozzleMaxTemp:"最高温度",nozzleSerial:"シリアル",nozzleHardenedSteel:"焼入れ鋼",nozzleStainlessSteel:"ステンレス鋼",nozzleTungstenCarbide:"タングステンカーバイド",nozzleFlow:"フロー",nozzleHighFlow:"ハイフロー",nozzleStandardFlow:"スタンダード",toast:{printStopped:"印刷を停止しました",printPaused:"印刷を一時停止しました",printResumed:"印刷を再開しました",failedToSkipObjects:"オブジェクトのスキップに失敗しました",rfidRereadInitiated:"RFID再読み取りを開始しました",printerDeleted:"プリンターを削除しました",printerAdded:"プリンターを追加しました",printerUpdated:"プリンターを更新しました",failedToDelete:"プリンターの削除に失敗しました",failedToAdd:"プリンターの追加に失敗しました",failedToUpdate:"プリンターの更新に失敗しました",commandSent:"コマンドを送信しました",failedToSendCommand:"コマンドの送信に失敗しました",turnedOn:"{{name}} の電源をオンにしました",failedToPowerOn:"{{name}} の電源オンに失敗しました",scriptTriggered:"スクリプトを実行しました",referenceDeleted:"リファレンスを削除しました",detectionAreaSaved:"検出エリアを保存しました",failedToDiscover:"プリンターの検出に失敗しました",cloudLoginRequired:"クラウドログインが必要です",failedToRunScript:"スクリプトの実行に失敗しました",failedToStopPrint:"印刷の停止に失敗しました",failedToPausePrint:"印刷の一時停止に失敗しました",failedToResumePrint:"印刷の再開に失敗しました",failedToControlChamberLight:"チャンバーライトの制御に失敗しました",failedToUpdateSetting:"設定の更新に失敗しました",failedToRereadRfid:"RFIDの再読み取りに失敗しました",failedToCheckPlate:"プレートの確認に失敗しました",failedToUpdateLabel:"ラベルの更新に失敗しました",failedToDeleteReference:"リファレンスの削除に失敗しました",failedToSaveDetectionArea:"検出エリアの保存に失敗しました",plateCheckEnabled:"プレートチェックを有効にしました",plateCheckDisabled:"プレートチェックを無効にしました",calibrationSaved:"キャリブレーションを保存しました!",calibrationFailed:"キャリブレーションに失敗しました"},connection:{connected:"接続中",offline:"オフライン"},queue:{inQueue:"キュー内",inQueue_plural:"{{count}}件がキュー内"},controls:"コントロール",permission:{noFiles:"このディレクトリにファイルがありません",noAdd:"プリンターを追加する権限がありません",noEdit:"プリンターを編集する権限がありません",noDelete:"プリンターを削除する権限がありません",noControl:"プリンターを制御する権限がありません",noAmsRfid:"AMS RFIDを再読み取りする権限がありません",noSmartPlugControl:"スマートプラグを制御する権限がありません"},modal:{selectModel:"モデルを選択...",locationGroup:"ロケーション / グループ",locationPlaceholder:"例: 工房、オフィス、地下室",modelOptional:"モデル(任意)",addTitle:"プリンターを追加",editTitle:"プリンターを編集",myPrinter:"マイプリンター",autoArchiveLabel:"完了した印刷を自動アーカイブ",fromPrinterSettings:"プリンターの設定から取得",saveChanges:"変更を保存"},skipObjects:{onlyWhilePrinting:"オブジェクトスキップ(印刷中のみ)",title:"オブジェクトスキップ",skipped:"スキップ済み",objectsSkipped:"オブジェクトをスキップしました",activeCount:"{{count}}個アクティブ",waitForLayer:"オブジェクトをスキップするにはレイヤー2以降をお待ちください(現在レイヤー{{layer}})",skip:"スキップ",tooltip:"オブジェクトスキップ",requiresMultiple:"オブジェクトスキップ(2個以上必要)",matchIdsInfo:"プリンター画面のIDと照合してください",printerShowsIds:"プリンター画面にビルドプレート上のオブジェクトIDが表示されます",skipSelected:"選択をスキップ",skipping:"スキップ中...",noObjectsSelected:"オブジェクトが選択されていません",selectObjectsToSkip:"現在の印刷からスキップするオブジェクトを選択してください"},confirm:{deleteTitle:"プリンターを削除",deleteMessage:"「{{name}}」を削除しますか?すべての接続設定が削除されます。",stopTitle:"印刷を停止",stopMessage:"「{{name}}」の現在の印刷を停止しますか?印刷ジョブがキャンセルされます。",stopButton:"印刷を停止",pauseTitle:"印刷を一時停止",pauseMessage:"「{{name}}」の現在の印刷を一時停止しますか?",pauseButton:"印刷を一時停止",resumeTitle:"印刷を再開",resumeMessage:"「{{name}}」の印刷を再開しますか?",resumeButton:"印刷を再開",powerOnTitle:"プリンターの電源をオン",powerOnMessage:"「{{name}}」の電源をオンにしますか?",powerOffTitle:"プリンターの電源をオフ",powerOffMessage:"「{{name}}」の電源をオフにしますか?",powerOffWarning:"警告: 「{{name}}」は現在印刷中です!電源をオフにしますか?印刷が中断され、プリンターが損傷する可能性があります。",deleteArchivesNote:"このプリンターのすべての印刷履歴が完全に削除されます。",keepArchivesNote:"印刷履歴は保持されますが、このプリンターとの関連は解除されます。",powerOnButton:"電源オン",powerOffButton:"電源オフ"},discovery:{title:"プリンター",scanning:"スキャン中...",allConfigured:"検出されたすべてのプリンターは既に設定済みです。",subnetToScan:"スキャンするサブネット",scanSubnet:"サブネットをスキャンしてプリンターを検出",discoverNetwork:"ネットワーク上のプリンターを検出",scanningSubnet:"サブネットでBambuプリンターをスキャン中...",scanningNetwork:"ネットワークをスキャン中...",serialRequired:"シリアル番号が必要です",unknown:"不明",failedToStart:"印刷の開始に失敗しました",searching:"検索中...",scanProgress:"スキャン中... {{scanned}}/{{total}}",foundPrinters:"{{count}}台のプリンターを検出",noPrintersFound:"プリンターが見つかりません",noPrintersFoundSubnet:"指定されたサブネットにプリンターが見つかりません。",noPrintersFoundNetwork:"ネットワーク上にプリンターが見つかりません。",alreadyAdded:"追加済み",select:"選択",manualEntry:"手動入力",addFromCloud:"クラウドから追加",dockerNote:"Dockerを検出しました。プリンターのサブネットをCIDR表記で入力してください。docker-compose.ymlでnetwork_mode: hostが必要です。"},filaments:"フィラメント",firmwareUpdateAvailable:"ファームウェアアップデートあり: {{current}} → {{latest}}",firmwareUpToDate:"ファームウェア {{version}} — 最新",plateDetection:{noPermission:"このページにアクセスする権限がありません。",title:"プレート検出",description:"印刷前にビルドプレート上のオブジェクトを検出",referenceCapture:"リファレンス画像を撮影",captureReference:"リファレンスを撮影",deleteReference:"リファレンスを削除",sensitivity:"感度",detectionArea:"検出エリア",saveArea:"エリアを保存",resetArea:"エリアをリセット",testDetection:"検出テスト",testing:"テスト中...",objectsDetected:"オブジェクトを検出しました",noObjectsDetected:"オブジェクトは検出されませんでした",requiresCamera:"カメラが必要です",referenceRequired:"まずリファレンス画像を撮影してください",enabledClick:"プレートチェック有効 - クリックして無効化",disabledClick:"プレートチェック無効 - クリックして有効化",manageCalibration:"プレート検出キャリブレーションを管理",calibrationRequired:"キャリブレーションが必要です",calibrationInstructions:"ビルドプレートが<strong>完全に空</strong>であることを確認してから、キャリブレーションをクリックしてください。",calibrationDescription:"キャリブレーションは空のプレートのリファレンス画像を撮影します。以降のチェックではこのリファレンスと比較してオブジェクトを検出します。",calibrationTip:"<strong>ヒント:</strong> 異なるプレート用に最大5つのキャリブレーションを保存できます。チェック時に最適なものが自動的に使用されます。",plateEmpty:"プレートは空のようです",confidence:"信頼度",difference:"差分",analysisPreview:"分析プレビュー:",analysisLegend:"緑の枠 = 検出エリア、赤のオーバーレイ = キャリブレーションとの差分",savedReferences:"保存済みリファレンス ({{count}}/{{max}})",labelPlaceholder:"ラベル...",clickToEdit:"{{label}} - クリックして編集",clickToAddLabel:"クリックしてラベルを追加"},fans:{partCooling:"パーツ冷却ファン",auxiliary:"補助ファン",chamber:"チャンバーファン"},estimatedCompletion:"完了予定時刻",slotOptions:"スロットオプション",firmwareModal:{title:"ファームウェアアップデート",titleUpToDate:"ファームウェア情報",currentVersion:"現在のバージョン",latestVersion:"最新バージョン",releaseNotes:"リリースノート",sdCardReady:"SDカード準備完了。下をクリックしてファームウェアをアップロードしてください。",applyInstructions:"プリンターでアップデートを適用するには:",step1:"プリンターのタッチスクリーンで設定に移動",step2:"ファームウェアに移動",step3:"SDカードからアップデートを選択",step4:"アップデートには10〜20分かかります",done:"完了",starting:"開始中...",uploadFirmware:"ファームウェアをアップロード",checkingPrereqs:"前提条件を確認中...",uploadedSuccess:"ファームウェアをSDカードにアップロードしました!",uploadFailed:"アップロード開始に失敗しました: {{error}}",uploadedToast:"ファームウェアをアップロードしました!プリンター画面からアップデートを実行してください。"},accessCodePlaceholder:"プリンター設定から取得",roi:{title:"プリンター",xStart:"X開始",yStart:"Y開始",width:"幅",height:"高さ",instruction:"ビルドプレートに焦点を合わせるように検出エリアを調整してください。プレビューの緑の枠が現在のエリアを示しています。"},deleteConfirm:"「{{name}}」を削除しますか?",maintenanceDue_plural:"{{count}}件の期限",offlinePrintersWithPlugs:"スマートプラグ付きオフラインプリンター",noLabel:"ラベルなし",printPreview:"印刷プレビュー",width:"幅",height:"高さ",noObjectsFound:"オブジェクトが見つかりません",objectsLoadedOnPrintStart:"オブジェクトは印刷開始時に読み込まれます",serialCannotBeChanged:"シリアル番号は変更できません",locationHelp:"プリンターのグループ化とキュージョブのフィルタリングに使用",autoOffAfterPrint:"印刷後に自動電源オフ",autoOffExecuted:"自動オフが実行されました - リセットするにはプリンターの電源を入れてください",viewHmsErrors:"{{count}}件のHMSエラーを表示",camera:"カメラ",skipObject:"オブジェクトスキップ",firmwareUpdate:"ファームウェアアップデート",firmwareInstructions:"プリンターのタッチスクリーンで",firmwareNav:"に移動",settings:"設定",firmware:"ファームウェア",discoverPrinters:"プリンターを検出",searching:"検索中...",manualEntry:"手動入力",addFromCloud:"クラウドから追加",cloud:{title:"Bambu Cloud プリンター",loginRequired:"クラウドにログインしてプリンターを追加してください",loginFirst:"まずプロファイルページからBambu Cloudにログインしてください",goToProfiles:"プロファイルへ移動",loadingPrinters:"クラウドプリンターを読み込み中...",noPrinters:"クラウドにプリンターが見つかりません",alreadyConfigured:"設定済み",accessCodeRequired:"アクセスコードが必要です",addPrinter:"プリンターを追加",adding:"追加中..."},name_field:"名前",nozzleSize:"ノズルサイズ",rfid:{reread:"RFID再読み取り"},openCameraOverlay:"カメラオーバーレイを開く",openCameraWindow:"カメラを新しいウィンドウで開く",firmwareUpdateButton:"アップデート",clickToViewHmsErrors:"クリックしてHMSエラーを表示"},archives:{title:"印刷アーカイブ",searchPlaceholder:"アーカイブを検索...",filterByPrinter:"プリンターで絞り込み",filterByStatus:"ステータスで絞り込み",sortBy:"並べ替え",sortNewest:"新しい順",sortOldest:"古い順",sortName:"名前順",sortDuration:"時間順",noArchives:"アーカイブが見つかりません",noArchivesYet:"アーカイブはまだありません",releaseToUpload:"ドロップしてアップロード",showAll:"すべて表示",showFavoritesOnly:"お気に入りのみ表示",gridView:"グリッド表示",listView:"リスト表示",calendarView:"カレンダー表示",showFailedPrints:"失敗した印刷を表示",hideFailedPrints:"失敗した印刷を非表示",printTime:"印刷時間",filamentUsed:"フィラメント使用量",cost:"コスト",reprint:"再印刷",preview:"プレビュー",deleteArchive:"アーカイブを削除",deleteConfirm:"このアーカイブを削除しますか?",favorite:"お気に入り",unfavorite:"お気に入りから削除",viewDetails:"詳細を表示",status:{completed:"完了",failed:"失敗",stopped:"中止"},toast:{source3mfAttached:"ソース3MFを添付しました: {{filename}}",source3mfRemoved:"ソース3MFを削除しました",f3dAttached:"F3Dを添付しました: {{filename}}",f3dRemoved:"F3Dを削除しました",timelapseAttached:"タイムラプスを添付しました: {{filename}}",addedToFavorites:"お気に入りに追加しました",removedFromFavorites:"お気に入りから削除しました",linkCopied:"リンクをクリップボードにコピーしました",photoDeleted:"写真を削除しました",exportDownloaded:"エクスポートをダウンロードしました",exportFailed:"エクスポートに失敗しました",addedToProject:"プロジェクトに追加しました",removedFromProject:"プロジェクトから削除しました",failedToAddToProject:"プロジェクトへの追加に失敗しました",failedToRemoveFromProject:"プロジェクトからの削除に失敗しました",noFile:"印刷ファイルがありません",slicerOpened:"スライサーを開きました",failedToOpenSlicer:"スライサーの起動に失敗しました",archived:"アーカイブしました",sentToFileManager:"ファイルマネージャーに送信しました",deleted:"アーカイブを削除しました",updated:"アーカイブを更新しました",failedToDelete:"アーカイブの削除に失敗しました",failedToUpdate:"アーカイブの更新に失敗しました",failedToSend:"送信に失敗しました",sentToPrinter:"プリンターに送信しました",addedToQueue:"キューに追加しました",failedUploadSource3mf:"ソース3MFのアップロードに失敗しました",failedRemoveSource3mf:"ソース3MFの削除に失敗しました",failedUploadF3d:"F3Dのアップロードに失敗しました",failedRemoveF3d:"F3Dの削除に失敗しました",timelapseAlreadyAttached:"タイムラプスは既に添付されています",noMatchingTimelapse:"一致するタイムラプスが見つかりません",failedScanTimelapse:"タイムラプスのスキャンに失敗しました",failedAttachTimelapse:"タイムラプスの添付に失敗しました",archiveDeleted:"アーカイブを削除しました",failedDeleteArchive:"アーカイブの削除に失敗しました",projectUpdated:"プロジェクトを更新しました",failedUpdateProject:"プロジェクトの更新に失敗しました",failedCopyLink:"リンクのコピーに失敗しました",failedDeletePhoto:"写真の削除に失敗しました",failedDeleteArchives:"アーカイブの削除に失敗しました",failedUpdateFavorites:"お気に入りの更新に失敗しました"},menu:{schedule:"スケジュール",slice:"スライス",externalLink:"外部リンク",viewOnMakerWorld:"MakerWorldで表示",preview3d:"3Dプレビュー",viewTimelapse:"タイムラプスを表示",downloadSource3mf:"ソース3MFをダウンロード",uploadSource3mf:"ソース3MFをアップロード",replaceSource3mf:"ソース3MFを置換",removeSource3mf:"ソース3MFを削除",uploadF3d:"F3Dをアップロード",replaceF3d:"F3Dを置換",downloadF3d:"Fusion 360デザインファイルをダウンロード",removeF3d:"F3Dを削除",download:"ダウンロード",qrCode:"QRコード",viewPhotos:"{{count}}枚の写真を表示",projectPage:"プロジェクトページ",goToProject:"プロジェクトへ: {{name}}",addToProject:"プロジェクトに追加",loading:"アーカイブを読み込み中...",select:"選択",deselect:"選択解除",print:"印刷",openInBambuStudio:"スライサーで開く",scanForTimelapse:"タイムラプスをスキャン",copyDownloadLink:"ダウンロードリンクをコピー",viewPhotosCount:"写真を表示 ({{count}})",addToFavorites:"お気に入りに追加",removeFromFavorites:"お気に入りから削除",edit:"編集",removeFromProject:"プロジェクトから削除",noProjectsAvailable:"利用可能なプロジェクトがありません",delete:"削除"},card:{plateNumber:"プレート {{number}}",moreOptions:"その他のオプション",failed:"失敗",openSource3mf:"ソース3MFをBambu Studioで開く(右クリックでオプション表示)",downloadF3d:"Fusion 360デザインファイルをダウンロード",viewTimelapse:"タイムラプスを表示",viewPhotos:"{{count}}枚の写真を表示",openFolder:"フォルダーを開く: {{name}}",source:"ソース",project:"プロジェクト",layer:"レイヤー",layers:"レイヤー",objects:"{{count}}オブジェクト",noPermissionEdit:"プロファイルを編集する権限がありません",reprint:"再印刷",schedulePrint:"印刷をスケジュール",schedule:"スケジュール",slice:"スライス",externalLink:"外部リンク",preview3d:"3Dプレビュー",download:"ダウンロード",previousPlate:"前のプレート",nextPlate:"次のプレート",addToFavorites:"お気に入りに追加",removeFromFavorites:"お気に入りから削除",cancelled:"キャンセル",duplicate:"重複",duplicateTitle:"このモデルは以前印刷されています",viewPhoto:"写真を表示",slicedFile:"スライス済みファイル - 印刷可能",sourceFile:"ソースファイルのみ - AMSマッピング不可",gcode:"GCODE",estimated:"推定: {{time}}",actual:"実際: {{time}}",accuracy:"精度: {{percent}}%",filament:"{{weight}}g",object:"{{count}}オブジェクト",slicedFor:"{{model}}用にスライス",uploadedBy:"アップロード者",noPermissionReprint:"再印刷する権限がありません",noPermissionDelete:"アーカイブを削除する権限がありません",openInBambuStudio:"スライサーで開く",openInBambuStudioToSlice:"スライサーでスライス",makerWorld:"MakerWorld: {{designer}}",viewProject:"プロジェクトを表示",noExternalLink:"外部リンクなし",edit:"編集",delete:"削除"},modal:{deleteArchive:"アーカイブを削除",deleteConfirm:"このアーカイブを削除しますか?",removeSource3mf:"ソース3MFを削除",removeSource3mfConfirm:'"{{name}}"からソース3MFファイルを削除してもよろしいですか?元のスライサープロジェクトファイルが削除されます。',removeF3d:"F3Dを削除",removeF3dConfirm:'"{{name}}"からFusion 360デザインファイルを削除してもよろしいですか?',selectTimelapse:"タイムラプスを選択",selectTimelapseDesc:"自動一致が見つかりませんでした。この印刷のタイムラプスを選択してください:",deleteArchives:"印刷アーカイブを削除",deleteCount:"{{count}}件を削除",deleteButton:"削除",removeButton:"削除",timelapse:"{{name}} - タイムラプス",deleteArchivesConfirm:"{{count}}件のアーカイブを削除しますか?この操作は元に戻せません。"},page:{title:"印刷アーカイブ",printsCount:"{{count}}回印刷",dropFilesHere:".3mfファイルをここにドロップ",releaseToUpload:"ドロップしてアップロード",only3mfSupported:".3mfファイルのみ対応しています",selected:"{{count}}件選択中",selectAll:"すべて選択",tags:"タグ",project:"プロジェクト",favorite:"お気に入り",toggledFavorites:"{{count}}件のアーカイブのお気に入りを切替えました",photoDeleted:"写真を削除しました",close:"閉じる",delete:"削除",failedUpdateFavorites:"お気に入りの更新に失敗しました",archivesDeleted:"{{count}}件のアーカイブを削除しました",failedDeleteArchives:"アーカイブの削除に失敗しました",failedDeletePhoto:"写真の削除に失敗しました"},list:{size:"サイズ",hasTimelapse:"タイムラプスあり",name:"名前",printer:"プリンター",date:"日付",actions:"操作"},noPrinterAvailable:"利用可能なプリンターがありません",archiveOrReprint:"アーカイブまたは再印刷",multiPrinterPrint:"マルチプリンター印刷",noPrintersForReprint:"再印刷用のプリンターがありません",searchMakerworld:"MakerWorldで検索",searchPrintables:"Printablesで検索",searchThingiverse:"Thingiverseで検索",openInSlicer:"スライサーで開く",openWithProtocol:"{{slicer}}で開く",context:{reprint:"再印刷",addToQueue:"キューに追加",delete:"削除",edit:"編集",compare:"比較",viewTimelapse:"タイムラプスを表示",downloadTimelapse:"タイムラプスをダウンロード",openInBambuStudio:"スライサーで開く",openInOrcaSlicer:"OrcaSlicerで開く",addToProject:"プロジェクトに追加",removeFromProject:"プロジェクトから削除",downloadGcode:"GCodeをダウンロード",download3mf:"3MFをダウンロード",downloadModel:"モデルをダウンロード",viewPhotos:"写真を表示",searchOnline:"オンラインで検索",sendToFileManager:"ファイルマネージャーに送信",sendToPrinter:"プリンターに送信",openStlViewer:"STLビューアーで開く"},permissions:{noReprint:"再印刷する権限がありません",noDelete:"削除する権限がありません",noEdit:"編集する権限がありません",noDownload:"ダウンロードする権限がありません",noQueue:"キューに追加する権限がありません",noSendToPrinter:"プリンターに送信する権限がありません",noSendToFileManager:"ファイルマネージャーに送信する権限がありません",noUpload:"アップロードする権限がありません",noBulkDelete:"一括削除する権限がありません"},costPerPrint:"印刷あたりのコスト",energyCost:"エネルギーコスト",totalCost:"合計コスト",noFilament:"フィラメントデータなし",printCount:"{{count}}回印刷",timesShort:"{{count}}回",perPrint:"/1回あたり",gcodeAvailable:"GCode利用可能",noGcode:"GCodeなし",plates:"プレート",filaments:"フィラメント",settings_label:"設定",weight:"重量",printSettings:"印刷設定",layerHeight:"レイヤー高さ",nozzleTemp:"ノズル温度",bedTemp:"ベッド温度",infill:"インフィル",supports:"サポート",model3d:"3Dモデル",noModel:"モデルなし",printNumber:"印刷 #{{number}}",sortLargest:"大きい順",sortSmallest:"小さい順",sortSize:"サイズ",noArchivesSearch:"検索条件に一致するアーカイブがありません",loadingArchives:"アーカイブを読み込み中...",manageTags:"タグを管理",permission:{noReprint:"このアーカイブを再印刷する権限がありません",noAddToQueue:"キューに追加する権限がありません",noUpdateArchives:"アーカイブを更新する権限がありません",noUploadFiles:"ファイルをアップロードする権限がありません",noDownload:"アーカイブをダウンロードする権限がありません",noCopyLink:"ダウンロードリンクをコピーする権限がありません",noDelete:"このアーカイブを削除する権限がありません",noCreate:"アーカイブを作成する権限がありません"}},queue:{title:"印刷キュー",addToQueue:"キューに追加",schedulePrint:"印刷をスケジュール",editQueueItem:"キューアイテムを編集",adding:"追加中...",clearQueue:"キューをクリア",clearHistory:"履歴をクリア",emptyQueue:"キューは空です",position:"順番",scheduledTime:"予定時刻",moveUp:"上に移動",moveDown:"下に移動",startNow:"今すぐ開始",printingInProgress:"印刷中...",viewArchive:"アーカイブを表示",viewInFileManager:"ファイルマネージャーで表示",itemCount:"{{count}}件",dragToReorder:"ドラッグして並べ替え(ASAPのみ)",addedBy:"{{username}}が追加",nextInQueue:"次のキュー",clearPlate:"プレートをクリアして次を開始",clearPlateSuccess:"プレートをクリアしました — 次の印刷の準備完了",plateReady:"プレートをクリアしました — 次の印刷の準備完了",sections:{currentlyPrinting:"印刷中",queued:"キュー中",history:"履歴"},status:{pending:"待機中",waiting:"待機中",printing:"印刷中",paused:"一時停止",completed:"完了",failed:"失敗",skipped:"スキップ",cancelled:"キャンセル済み"},summary:{printing:"印刷中",queued:"キュー中",history:"履歴",totalTime:"キュー合計時間"},filter:{allPrinters:"すべてのプリンター",unassigned:"未割当",allStatus:"すべてのステータス",allLocations:"すべてのロケーション",any:"すべて"},sort:{byPosition:"順番で並べ替え",byName:"名前で並べ替え",byPrinter:"プリンターで並べ替え",bySchedule:"スケジュールで並べ替え",byDate:"日付で並べ替え",ascendingOldest:"昇順(古い順)",descendingNewest:"降順(新しい順)"},badges:{staged:"ステージ済み",autoPowerOff:"自動電源オフ",requiresPrevious:"前の成功が必要"},empty:{title:"スケジュールされた印刷はありません",description:"アーカイブページのコンテキストメニューから「スケジュール」オプションを使用するか、ファイルをドラッグ&ドロップして始めましょう。"},time:{asap:"即時",overdue:"期限超過",now:"今すぐ",inMinutes:"{{count}}分後",inHours:"{{count}}時間後",lessThanMinute:"1分以内"},actions:{stopPrint:"印刷を停止",startPrint:"印刷を開始",requeue:"再キュー"},bulkEdit:{title:"{{count}}件のアイテムを編集",description:"変更した設定のみが選択されたアイテムに適用されます。",printer:"プリンター",noChange:"— 変更なし —",queueOptions:"キューオプション",staged:"ステージ済み",autoPowerOff:"印刷後に自動電源オフ",printOptions:"印刷オプション",bedLevelling:"ベッドレベリング",flowCalibration:"フローキャリブレーション",vibrationCalibration:"振動キャリブレーション",timelapse:"タイムラプス",useAms:"AMS使用",applyChanges:"変更を適用",selectAll:"すべて選択",deselectAll:"すべて選択解除",selected:"{{count}}件選択中",editSelected:"選択を編集",cancelSelected:"選択をキャンセル",title_plural:"{{count}}件のアイテムを編集",requirePrevious:"前の成功を必要とする",layerInspection:"第一層検査"},confirm:{cancelTitle:"スケジュール済み印刷をキャンセル",cancelMessage:"「{{name}}」をキャンセルしますか?",stopTitle:"印刷を停止",stopMessage:"現在の印刷「{{name}}」を停止しますか?プリンター上の印刷ジョブがキャンセルされます。",removeTitle:"履歴から削除",removeMessage:"「{{name}}」をキュー履歴から削除しますか?",clearHistoryMessage:"{{count}}件の履歴をすべて削除しますか?",cancelButton:"印刷をキャンセル",stopButton:"印刷を停止",thisPrint:"この印刷",thisItem:"このアイテム",clearHistoryTitle:"履歴をクリア"},toast:{cancelled:"キャンセル済み",removeFailed:"プロジェクトからのアーカイブ削除に失敗しました",cancelFailed:"アイテムのキャンセルに失敗しました",removed:"キューアイテムを削除しました",stopped:"印刷を停止しました",stopFailed:"印刷の停止に失敗しました",released:"印刷をキューにリリースしました",startFailed:"印刷の開始に失敗しました",reorderFailed:"キューの並べ替えに失敗しました",historyCleared:"{{count}}件の履歴をクリアしました",clearHistoryFailed:"履歴のクリアに失敗しました",updateFailed:"アイテムの更新に失敗しました",bulkCancelled:"{{count}}件のアイテムをキャンセルしました",bulkCancelFailed:"アイテムのキャンセルに失敗しました"},subtitle:"印刷ジョブのスケジュールと管理",print:"印刷",reprint:"再印刷",printToPrinters:"{{count}}台のプリンターで印刷",queueToPrinters:"{{count}}台のプリンターでキュー追加",sending:"送信中...",sendingProgress:"送信中 {{current}}/{{total}}...",addingProgress:"追加中 {{current}}/{{total}}...",savingProgress:"保存中 {{current}}/{{total}}...",itemCount_plural:"{{count}}件のアイテム",reorderHint:"順番はASAPアイテムのみに影響します。スケジュール済みアイテムは設定時刻に実行されます。",permissions:{noStopPrint:"印刷を停止する権限がありません",noStartPrint:"印刷を開始する権限がありません",noEdit:"このキューアイテムを編集する権限がありません",noCancel:"このキューアイテムをキャンセルする権限がありません",noRequeue:"アイテムを再キューする権限がありません",noRemove:"このキューアイテムを削除する権限がありません",noClearHistory:"すべての履歴をクリアする権限がありません",noEditItems:"キューアイテムを編集する権限がありません",noCancelItems:"キューアイテムをキャンセルする権限がありません"}},stats:{title:"統計",overview:"概要",totalPrints:"総印刷数",successRate:"成功率",totalPrintTime:"総印刷時間",printTime:"印刷時間",totalFilament:"総フィラメント使用量",filamentUsed:"フィラメント使用量",filamentCost:"フィラメントコスト",totalCost:"総コスト",energyUsed:"エネルギー使用量",energyCost:"エネルギーコスト",averagePrintTime:"平均印刷時間",printsPerDay:"1日あたりの印刷数",byPrinter:"プリンター別",printsByPrinter:"プリンター別印刷数",byMaterial:"素材別",byMonth:"月別",last7Days:"過去7日間",last30Days:"過去30日間",last90Days:"過去90日間",allTime:"全期間",quickStats:"クイック統計",printActivity:"印刷アクティビティ",filamentTypes:"フィラメントタイプ",timeAccuracy:"時間精度",successful:"成功",failed:"失敗",perfectEstimate:"100% = 完全な推定",noTimeAccuracyData:"時間精度データがありません",noFilamentData:"フィラメントデータがありません",noPrinterData:"プリンターデータがありません",noPrintData:"印刷データがありません",noPrintDataLast30Days:"過去30日間の印刷データがありません",failureReasons:"失敗理由",topFailureReasons:"主な失敗理由",resetLayout:"レイアウトをリセット",recalculateCosts:"コストを再計算",exportStats:"統計をエクスポート",exportAsCsv:"CSVでエクスポート",exportAsExcel:"Excelでエクスポート",hiddenCount:"{{count}}件非表示",exportDownloaded:"エクスポートをダウンロードしました",exportFailed:"エクスポートに失敗しました",layoutReset:"レイアウトをリセットしました",recalculateFailed:"コストの再計算に失敗しました",noPermissionResetLayout:"レイアウトをリセットする権限がありません",noPermissionRecalculate:"コストを再計算する権限がありません",subtitle:"ウィジェットをドラッグして並べ替え。目のアイコンをクリックして非表示。",filamentTrends:"フィラメントトレンド",failureAnalysis:"失敗分析",failedPrintsCount:"{{failed}} / {{total}} 件の印刷が失敗",lastWeekRate:"先週: {{rate}}%",recalculateCostsHint:"現在のフィラメント価格ですべてのアーカイブコストを再計算",recalculatedCosts:"{{count}}件のアーカイブのコストを再計算しました",loadingStats:"統計を読み込み中..."},maintenance:{title:"メンテナンス",overview:"概要",allOk:"すべてのメンテナンスは最新です",dueCount:"{{count}}件の期限到来",dueCount_plural:"{{count}}件の期限到来",warningCount:"{{count}}件の警告",warningCount_plural:"{{count}}件の警告",totalPrintTime:"総印刷時間",nextMaintenance:"次回メンテナンス",nothingDue:"予定なし",tasks:"タスク",lastPerformed:"前回実施日",interval:"間隔",hoursRemaining:"残り{{hours}}時間",hoursOverdue:"{{hours}}時間超過",markDone:"完了にする",performMaintenance:"メンテナンスを実施",history:"履歴",noHistory:"メンテナンス履歴がありません",editPrintHours:"印刷時間を編集",currentHours:"現在の時間",dueSoon:"まもなく期限",allGood:"問題なし",days:"日",weeks:"{{count}}週間",months:"{{count}}ヶ月",maintenanceTypes:"メンテナンスタイプ",addCustomType:"カスタムタイプを追加",intervalType:"インターバルタイプ",icon:"アイコン",documentationLink:"ドキュメントリンク(任意)",assignToPrinters:"プリンターに割り当て",selectAtLeastOnePrinter:"プリンターを1台以上選択してください",addType:"タイプを追加",custom:"カスタム",printHours:"印刷時間",calendarDays:"カレンダー日数",viewDocumentation:"ドキュメントを表示",timeBasedInterval:"時間ベースのインターバル",intervalOverrides:"インターバルのオーバーライド",assignedToPrinters:"割り当て済みプリンター:",noPrintersAssigned:"プリンター未割り当て",removeFromPrinter:"このプリンターから削除",types:{lubricateRails:"リニアレールの潤滑",cleanNozzle:"ノズル/ホットエンドの清掃",checkBelts:"ベルト張力の確認",cleanBuildPlate:"ビルドプレートの清掃",checkExtruder:"エクストルーダーギアの確認",checkCooling:"冷却ファンの確認",generalInspection:"総合点検",cleanCarbonRods:"カーボンロッドの清掃",checkPtfeTube:"PTFEチューブの確認",replaceHepaFilter:"HEPAフィルター交換",replaceCarbonFilter:"カーボンフィルター交換",lubricateLeftNozzleRail:"左ノズルレールの潤滑"},typeUpdated:"メンテナンスタイプを更新しました",typeDeleted:"メンテナンスタイプを削除しました",printerAssigned:"プリンターを割り当てました",printerRemoved:"プリンターを削除しました",deleteTypeConfirm:"「{{name}}」を削除しますか?",noPermissionUpdate:"メンテナンス記録を更新する権限がありません",noPermissionPerform:"メンテナンスを実行する権限がありません",noPermissionEditTypes:"メンテナンスタイプを編集する権限がありません",noPermissionDeleteTypes:"メンテナンスタイプを削除する権限がありません",noPermissionEditHours:"メンテナンス時間を編集する権限がありません",noPermissionEditIntervals:"メンテナンス間隔を編集する権限がありません",statusTab:"ステータス",settingsTab:"設定",overdueCount:"{{count}}件超過",dueSoonCount:"{{count}}件まもなく期限",overdueBy:"{{duration}}超過",dueIn:"あと{{duration}}",timeLeft:"残り{{duration}}",day:"1日",week:"1週間",month:"1ヶ月",year:"1年",maintenanceTypesDescription:"システムタイプとカスタムメンテナンスタスク",intervalValue:"間隔 ({{type}})",exampleName:"例: HEPAフィルター交換",intervalOverridesDescription:"特定のプリンターの間隔をカスタマイズ",addPrinterShort:"追加:",printersAssignedClick:"{{count}}台のプリンターを割り当て済み - クリックして管理",maintenanceComplete:"メンテナンスを完了としてマークしました",printHoursUpdated:"印刷時間を更新しました",noPermissionRemovePrinter:"プリンターの割り当てを解除する権限がありません",noPermissionAssignPrinter:"プリンターを割り当てる権限がありません",configureSettings:"メンテナンスタイプと間隔を設定"},settings:{title:"設定",general:"一般",tabs:{general:"一般",smartPlugs:"スマートプラグ",notifications:"通知",apiKeys:"APIキー",users:"認証",backup:"バックアップ",filament:"フィラメント",network:"ネットワーク",virtualPrinter:"仮想プリンター",emailAuth:"メール認証"},appearance:"外観",notifications:"通知",smartPlugs:"スマートプラグ",updates:"アップデート",language:"言語",languageDescription:"表示言語を選択してください",theme:"テーマ",themeLight:"ライト",themeDark:"ダーク",themeSystem:"システム設定に従う",defaultView:"デフォルト画面",defaultViewDescription:"アプリ起動時に表示するページ",checkForUpdates:"アップデートを確認",autoUpdate:"自動アップデート",currentVersion:"現在のバージョン",latestVersion:"最新バージョン",upToDate:"最新です",updateAvailable:"アップデートあり",notificationLanguage:"通知の言語",notificationLanguageDescription:"プッシュ通知の言語",notificationProviders:"通知プロバイダー",addProvider:"プロバイダーを追加",editProvider:"プロバイダーを編集",providerType:"プロバイダーの種類",testNotification:"テスト通知",testSuccess:"テスト通知を送信しました",testFailed:"テスト通知の送信に失敗しました",quietHours:"おやすみ時間",quietHoursDescription:"この時間帯は通知を送信しません",quietHoursStart:"開始",quietHoursEnd:"終了",events:{title:"通知イベント",printStart:"印刷開始",printComplete:"印刷完了",printFailed:"印刷失敗",printStopped:"印刷中止",printProgress:"進捗マイルストーン",printProgressDescription:"25%, 50%, 75%で通知",printerOffline:"プリンターオフライン",printerError:"プリンターエラー",filamentLow:"フィラメント残量低下",maintenanceDue:"メンテナンス期限",maintenanceDueDescription:"メンテナンスが必要なときに通知"},smartPlug:{title:"スマートプラグ",add:"スマートプラグを追加",edit:"スマートプラグを編集",name:"名前",ipAddress:"IPアドレス",linkedPrinter:"連携プリンター",autoOn:"自動電源オン",autoOnDescription:"印刷開始時に電源を入れる",autoOff:"自動電源オフ",autoOffDescription:"印刷完了後に電源を切る",offDelay:"オフ遅延",offDelayMinutes:"印刷後の待機時間(分)",offDelayTemp:"ノズル温度が下回ったとき",currentState:"現在の状態",turnOn:"電源オン",turnOff:"電源オフ"},email:{smtpSettings:"SMTP設定",smtpHost:"SMTPサーバー",smtpPort:"SMTPポート",security:"セキュリティ",authentication:"認証",username:"ユーザー名",password:"パスワード",fromEmail:"送信元メールアドレス",fromName:"送信者名",testConnection:"SMTP接続テスト",testRecipient:"テスト受信者メール",sendTest:"テストメール送信",sending:"送信中...",save:"設定を保存",saving:"保存中...",advancedAuth:"高度な認証",advancedAuthEnabled:"高度な認証が有効です",advancedAuthEnabledDesc:"メールベースのユーザー管理機能が有効になっています。新規ユーザーには自動生成されたパスワードがメールで送信され、ユーザーはパスワード忘れ機能でパスワードをリセットできます。",advancedAuthDisabled:"高度な認証が無効です",advancedAuthDisabledDesc:"高度な認証を有効にして、ユーザー管理のメールベース機能を有効化してください。",enable:"有効にする",disable:"無効にする",feature1:"パスワードは自動生成され、新規ユーザーにメールで送信されます",feature2:"ユーザーはユーザー名またはメールでログインできます",feature3:"パスワード忘れ機能が利用可能です",feature4:"管理者はメールでユーザーパスワードをリセットできます",errors:{requiredFields:"すべての必須フィールドに入力してください",usernameRequired:"認証が有効な場合、ユーザー名は必須です",enterTestEmail:"テストメールアドレスを入力してください",smtpServerAndEmail:"テストする前にSMTPサーバーと送信元メールを入力してください",usernamePasswordRequired:"認証が有効な場合、ユーザー名とパスワードは必須です",configureSmtpFirst:"最初にSMTP設定を構成してテストしてください"},success:{settingsSaved:"SMTP設定を保存しました"},securityOptions:{starttls:"STARTTLS (ポート 587)",ssl:"SSL/TLS (ポート 465)",none:"なし (ポート 25)"},authOptions:{enabled:"有効",disabled:"無効"}},noDefaultPrinter:"デフォルトなし(毎回選択)",sidebarOrder:"サイドバーの順序",saveThumbnails:"サムネイルを保存",captureFinishPhoto:"完了写真を撮影",noPrintersConfigured:"プリンターが設定されていません",checkPrinterFirmware:"プリンターファームウェアの確認",enableRetry:"リトライを有効化",homeAssistantDescription:"Home Assistantに接続してHA REST APIでスマートプラグを制御します。switch、light、input_booleanエンティティに対応しています。",environmentManagedLabel:"(環境変数で管理)",autoEnabledViaEnv:"環境変数により自動的に有効化されました",urlFromEnvReadOnly:"HA_URL環境変数で設定された値(読み取り専用)",tokenFromEnvReadOnly:"HA_TOKEN環境変数で設定された値(読み取り専用)",noSmartPlugsDescription:"Tasmotaベースのスマートプラグを追加して、エネルギー消費を追跡し、電源制御を自動化します。",noProvidersDescription:"アラートを受信するにはプロバイダーを追加してください。",noUsersFound:"ユーザーが見つかりません",noGroupsFound:"グループが見つかりません",noGroupsAvailable:"利用可能なグループがありません",passwordsDoNotMatch:"パスワードが一致しません",authDisabledTitle:"認証が無効です",deleteUserConfirm:"このユーザーを削除してもよろしいですか?この操作は元に戻せません。",actionCannotBeUndone:"この操作は元に戻せません",addFirstSmartPlug:"最初のスマートプラグを追加",providers:"プロバイダー",log:"ログ",testAll:"すべてテスト",testResults:"テスト結果",messageTemplates:"メッセージテンプレート",apiKeys:"APIキー",apiKeysDescription:"外部連携やWebhook用のAPIキーを作成します。",createKey:"キーを作成",apiKeyCreated:"APIキーを作成しました",apiKeyCopyWarning:"今すぐこのキーをコピーしてください - 再表示されません!",createNewApiKey:"新しいAPIキーを作成",keyName:"キー名",readStatus:"ステータスの読み取り",readStatusDescription:"プリンターのステータスとキューを表示",manageQueue:"キューの管理",manageQueueDescription:"印刷キューへのアイテムの追加と削除",controlPrinter:"プリンターの制御",controlPrinterDescription:"印刷の一時停止、再開、停止",unnamedKey:"名前なしキー",lastUsed:"最終使用:",createFirstKey:"最初のキーを作成",webhookEndpoints:"Webhookエンドポイント",webhookApiKeyHint:"X-API-KeyヘッダーでAPIキーを使用してください。",webhook:{pausePrint:"印刷を一時停止",resumePrint:"印刷を再開",getAllStatus:"全プリンターステータスを取得",getSpecificStatus:"特定のプリンターステータスを取得",addToQueue:"印刷キューに追加",stopPrint:"印刷を停止"},apiBrowser:"APIブラウザ",apiBrowserDescription:"すべての利用可能なAPIエンドポイントを探索してテストします。",apiKeyForTesting:"テスト用APIキー",apiKeyPlaceholder:"CallMeBot APIキー",deleteApiKeyTitle:"APIキーを削除",deleteApiKeyMessage:"このAPIキーを削除してもよろしいですか?このキーを使用しているすべての連携が動作しなくなります。",deleteKey:"キーを削除",amsThresholdsDescription:"AMS湿度と温度インジケーターの色しきい値を設定します。",humidity:"湿度",goodGreen:"良好(緑)≤",fairOrange:"普通(オレンジ)≤",aboveFairBad:"普通のしきい値以上は赤(悪い)で表示",temperature:"温度",goodBlue:"良好(青)≤",aboveFairHot:"普通のしきい値以上は赤(高温)で表示",historyRetention:"履歴の保持",historyRetentionDescription:"古い湿度と温度データは自動的に削除されます",printModal:"印刷ダイアログ",authentication:"認証",authDisabledDescription:"認証を有効にして、ユーザーアカウントの作成、権限の管理、Bambuddyインスタンスのセキュリティを確保しましょう。",enableAuthentication:"認証を有効にする",currentUser:"現在のユーザー",changePassword:"パスワードを変更",admin:"管理者",users:"ユーザー",addUser:"ユーザーを追加",groups:"グループ",addGroup:"グループを追加",noDescription:"説明なし",createUser:"ユーザーを作成",username:"ユーザー名",enterUsername:"ユーザー名を入力",password:"パスワード",enterPassword:"パスワードを入力(6文字以上)",confirmPassword:"パスワードの確認",confirmPasswordPlaceholder:"パスワードを確認",turnAllPlugsOn:"すべてのプラグをオン",turnAllPlugsOff:"すべてのプラグをオフ",clearLogsMessage:"30日以上前のすべての通知ログを完全に削除します。この操作は元に戻せません。",clearLogs:"通知ログを削除",resetPreferences:"設定をリセット",deleteGroup:"グループを削除",systemDefault:"システムデフォルト",archiveSettings:"アーカイブ設定",costTracking:"コスト追跡",dataManagement:"データ管理",enableMqtt:"MQTTを有効化",useTls:"TLSを使用",enableMetricsEndpoint:"メトリクスエンドポイントを有効化",availableMetrics:"利用可能なメトリクス",editUser:"ユーザーを編集",groupName:"グループ名",enterNewPassword:"新しいパスワードを入力",confirmNewPassword:"新しいパスワードを確認",enterGroupName:"グループ名を入力",enterCurrentPassword:"現在のパスワードを入力",enterNewPasswordMin6:"新しいパスワードを入力(6文字以上)",toast:{keyCopied:"キーをクリップボードにコピーしました",keyAddedToBrowser:"キーをAPIブラウザに追加しました",clearLogsFailed:"ログの削除に失敗しました",apiKeyCreated:"APIキーを作成しました",apiKeyDeleted:"APIキーを削除しました",userCreated:"ユーザーが正常に作成されました",userUpdated:"ユーザーが正常に更新されました",userDeleted:"ユーザーが正常に削除されました",fillRequiredFields:"必須項目をすべて入力してください",passwordsDoNotMatch:"パスワードが一致しません",enterGroupName:"グループ名を入力",settingsSaved:"設定を保存しました",passwordChanged:"パスワードが正常に変更されました",connectionFailed:"接続失敗",testFailed:"テスト通知の送信に失敗しました",uiPreferencesReset:"UI設定をリセットしました。更新中...",authDisabled:"認証を無効にしました",authDisableFailed:"認証の無効化に失敗しました",groupCreated:"グループを作成しました",groupUpdated:"グループを更新しました",groupDeleted:"グループを削除しました",passwordTooShort:"パスワードは6文字以上必要です",cameraConnected:"カメラ接続{{resolution}}",copyFailed:"キーのコピーに失敗しました",cameraSettingsSaved:"カメラ設定を保存しました",enterCameraUrl:"カメラURLを入力してください"},testConnection:"接続テスト",spoolman:"Spoolman",archiveMode:{always:"常にアーカイブを作成",never:"アーカイブを作成しない",ask:"毎回確認"},checkForUpdatesLabel:"アップデートを確認",mqttConnectedTo:"接続先:",prometheusDescription:"プリンターデータをPrometheus形式で公開",noSmartPlugsTitle:"スマートプラグが設定されていません",noProvidersTitle:"プロバイダーが設定されていません",noTemplatesAvailable:"テンプレートがありません。バックエンドを再起動してデフォルトテンプレートを生成してください。",apiPermissionView:"プリンターステータスとキューを表示",apiPermissionEdit:"印刷キューにアイテムを追加・削除",apiKeysEmptyTitle:"APIキーがありません",apiKeysEmptyDescription:"外部サービスと連携するためのAPIキーを作成してください。",systemGroupWarning:"システムグループ名は変更できません",authDisabledFeature1:"システムへのアクセスにログインを要求",authDisabledFeature2:"グループベースの権限で複数ユーザーを作成",authDisabledFeature3:"50以上のきめ細かな権限でアクセスを制御",userHasCreated:"このユーザーは以下を作成しています:",userItemsQuestion:"これらのアイテムをどうしますか?",testPassedCount:"{{count}}件成功",testFailedCount:"{{count}}件失敗",messageTemplatesDescription:"各イベントの通知メッセージをカスタマイズ。",useInApiBrowser:"APIブラウザーで使用",keyNamePlaceholder:"例: Home Assistant, OctoPrint",read:"読み取り",control:"制御",apiKeyHint:"このキーはX-API-Keyヘッダーとしてリクエストに送信されます。",amsDisplayThresholds:"AMS表示しきい値",keepSensorHistory:"センサー履歴の保持期間",expandCustomMapping:"カスタムマッピングをデフォルトで展開",expandCustomMappingDescription:"複数プリンターに印刷する際、プリンターごとのAMSマッピングを展開表示",authEnabledDescription:"ユーザー認証でインスタンスが保護されています",authDisabledMessage:"認証を有効にして、ユーザーアカウントの作成、権限の管理、Bambuddyインスタンスのセキュリティを確保しましょう。",system:"システム",userCount:"{{count}}人のユーザー",permissionCount:"{{count}}件の権限",viewReleaseOnGitHub:"GitHubでリリースを表示",clearNotificationLogs:"通知ログをクリア",resetUiPreferences:"UI設定をリセット",resetUiPreferencesMessage:"すべてのUI設定をデフォルトにリセットします:サイドバー順序、テーマ、ダッシュボードレイアウト、表示モード、ソート設定。プリンター、アーカイブ、サーバー設定は影響を受けません。クリア後にページがリロードされます。",deleteGroupTitle:"グループを削除",deleteGroupMessage:"このグループを削除しますか?このグループのユーザーはこれらの権限を失います。",disableAuthenticationTitle:"認証を無効化",disableAuthenticationMessage:"認証を無効にしますか?Bambuddyインスタンスにログインなしでアクセスできるようになります。ユーザーはデータベースに残りますが、認証は無効になります。",disableAuthentication:"認証を無効化",configureBambuddy:"Bambuddyを設定",newWindow:"新しいウィンドウ",embeddedOverlay:"埋め込みオーバーレイ",preferredSlicer:"優先スライサー",preferredSlicerDescription:"ファイルを開くスライサーアプリケーションを選択",externalCameras:"外部カメラ",printsOnly:"印刷のみ",totalConsumption:"総消費量",clearNotificationLogsDescription:"30日以上前の通知ログを削除",resetUiPreferencesDescription:"サイドバー順序、テーマ、表示モード、レイアウト設定をリセット。プリンター、アーカイブ、設定は影響を受けません。",enableHomeAssistant:"Home Assistantを有効化",deleteUserTitle:"ユーザーを削除",leaveEmptyForAnonymous:"匿名の場合は空のまま",leaveEmptyForNoAuth:"認証なしの場合は空のまま",enterDescriptionOptional:"説明を入力(任意)",spoolmanEnabled:"Spoolman連携を有効化",spoolmanUrl:"Spoolman URL",spoolmanConnected:"接続中",spoolmanDisconnected:"未接続"},notification:{printStarted:{title:"印刷開始",body:"{{printer}}: {{filename}} の印刷を開始しました"},printCompleted:{title:"印刷完了",body:"{{printer}}: {{filename}} が正常に完了しました"},printFailed:{title:"印刷失敗",body:"{{printer}}: {{filename}} が失敗しました"},printStopped:{title:"印刷中止",body:"{{printer}}: {{filename}} が中止されました"},printProgress:{title:"印刷進捗",body:"{{printer}}: {{filename}} は {{percent}}% 完了"},printerOffline:{title:"プリンターオフライン",body:"{{printer}} がオフラインです"},printerError:{title:"プリンターエラー",body:"{{printer}}: {{error}}"},filamentLow:{title:"フィラメント残量低下",body:"{{printer}}: フィラメントが残りわずかです"},maintenanceDue:{title:"メンテナンス期限",body:"{{printer}}: {{items}} の対応が必要です"}},errors:{generic:"問題が発生しました",networkError:"ネットワークエラーです。接続を確認してください。",notFound:"見つかりません",unauthorized:"認証エラー",serverError:"サーバーエラー",validationError:"入力内容を確認してください",printerConnectionFailed:"プリンターへの接続に失敗しました",saveFailed:"保存に失敗しました",deleteFailed:"削除に失敗しました",loadFailed:"データの読み込みに失敗しました"},mqttDebug:{title:"MQTTデバッグログ",searchPlaceholder:"トピックまたはペイロードで検索...",noMessages:"まだメッセージが記録されていません",incoming:"受信",outgoing:"送信",loggingStopped:"ログ記録停止",loggingActive:"ログ記録中 - メッセージは自動更新されます",startLogging:"ログ記録を開始",topic:"トピック",startLoggingHint:"「ログ開始」をクリックしてMQTTメッセージのキャプチャを開始",noMessagesMatch:"フィルターに一致するメッセージがありません",adjustFilterHint:"検索条件やフィルター条件を調整してみてください",stopLogging:"ログ停止",clearLog:"ログをクリア",timestamp:"タイムスタンプ",direction:"方向",all:"すべて"},printerFiles:{filterPlaceholder:"ファイルを検索...",deleteFileConfirm:"このファイルを削除しますか?",noFiles:"このディレクトリにファイルがありません",loadingFiles:"ファイルを読み込み中...",failedToLoad:"ファイルの読み込みに失敗しました",title:"ファイル管理",storageUsed:"使用中:",storageFree:"空き:",deleteButton:"削除",deleteFiles:"{{count}}件のファイルを削除",deleteFilesConfirm:"選択した{{count}}件のファイルを削除しますか?元に戻せません。",toast:{filesDeleted:"{{count}}件のファイルを削除しました",deleteFailed:"削除に失敗: {{error}}"}},confirm:{delete:"削除しますか?",unsavedChanges:"保存されていない変更があります。このページを離れますか?",clearQueue:"キューをクリアしますか?"},login:{title:"Bambuddy ログイン",subtitle:"アカウントにサインイン",username:"ユーザー名",usernamePlaceholder:"ユーザー名を入力",password:"パスワード",passwordPlaceholder:"パスワードを入力",signIn:"サインイン",enterCredentials:"ユーザー名とパスワードを入力してください",signingIn:"ログイン中...",forgotPassword:"パスワードをお忘れですか?",loginSuccess:"ログインしました",loginFailed:"ログインに失敗しました",forgotPasswordTitle:"パスワードを忘れた場合",forgotPasswordMessage:"パスワードを忘れた場合は、システム管理者に連絡してリセットしてもらってください。",howToReset:"パスワードのリセット方法:",resetStep1:"Bambuddy管理者に連絡",resetStep2:"ユーザー管理でパスワードリセットを依頼",resetStep3:"管理者が新しい仮パスワードを設定",resetStep4:"新しいパスワードでログインし、設定で変更",gotIt:"了解",usernameOrEmail:"ユーザー名またはメール",usernameOrEmailPlaceholder:"ユーザー名または @ メール",forgotPasswordEmailMessage:"メールアドレスを入力すると、新しいパスワードを送信します。",emailAddress:"メールアドレス",emailPlaceholder:"your.email@example.com",cancel:"キャンセル",sending:"送信中...",sendResetEmail:"リセットメールを送信"},setup:{title:"Bambuddy セットアップ",adminAccount:"管理者アカウント",adminUsername:"管理者ユーザー名",adminPassword:"管理者パスワード",confirmPassword:"パスワードの確認",confirmPasswordPlaceholder:"パスワードを確認",settingUp:"セットアップ中...",completeSetup:"セットアップを完了",toast:{authEnabledAdminCreated:"認証が有効になり、管理者ユーザーが作成されました",authEnabledExistingAdmins:"既存の管理者ユーザーを使用して認証が有効になりました",setupCompleted:"セットアップが完了しました",passwordsDoNotMatch:"パスワードが一致しません",enterBothCredentials:"管理者のユーザー名とパスワードの両方を入力するか、既存の管理者を使用する場合は両方を空にしてください",passwordTooShort:"パスワードは6文字以上必要です"},adminAccountDesc:"既に管理者ユーザーが存在する場合、既存の管理者アカウントを使用して認証が有効化されます。既存の管理者を使用する場合は下のフィールドを空のままにするか、新しい認証情報を入力して新しい管理者ユーザーを作成してください。",optionalIfAdminExists:"(管理者ユーザーが存在する場合は任意)",adminUsernamePlaceholder:"管理者ユーザー名を入力(任意)",adminPasswordPlaceholder:"管理者パスワードを入力(任意)",subtitle:"Bambuddyインスタンスの認証を設定",enableAuth:"認証を有効化"},changePassword:{currentPassword:"現在のパスワード",newPassword:"新しいパスワード",confirmPasswordPlaceholder:"パスワードを確認",title:"パスワードを変更",currentPasswordPlaceholder:"現在のパスワードを入力",newPasswordPlaceholder:"新しいパスワードを入力(6文字以上)",confirmPassword:"新しいパスワード確認",passwordsDoNotMatch:"パスワードが一致しません",passwordTooShort:"パスワードは6文字以上必要です",changing:"変更中...",success:"パスワードを変更しました",failed:"パスワードの変更に失敗しました"},camera:{invalidPrinterId:"無効なプリンターID",live:"ライブ",snapshot:"スナップショット",restartStream:"ストリームを再開",refreshSnapshot:"スナップショットを更新",fullscreen:"フルスクリーン",exitFullscreen:"フルスクリーンを終了",connectingToCamera:"カメラに接続中...",capturingSnapshot:"スナップショットを撮影中...",connectionLost:"接続が切断されました",reconnectNow:"今すぐ再接続",cameraUnavailable:"カメラが利用できません",retry:"再試行",cameraStream:"カメラストリーム",zoomOut:"ズームアウト",zoomIn:"ズームイン",resetZoom:"ズームをリセット",chamberLight:"チャンバーライト切替",title:"カメラビュー",connectionFailed:"カメラ接続に失敗しました",reconnecting:"{{countdown}}秒後に再接続... (試行 {{attempt}}/{{max}})",cameraUnavailableDesc:"プリンターの電源がオンで接続されていることを確認してください。",noCamera:"カメラがありません",recording:"録画中",startRecording:"録画開始",stopRecording:"録画停止"},groups:{backToSettings:"設定に戻る",createGroup:"グループを作成",noPermission:"このページにアクセスする権限がありません。",noDescription:"説明なし",usersCount:"{{count}}人のユーザー",permissionsCount:"{{count}}個の権限",toast:{deleted:"アーカイブを削除しました",enterGroupName:"グループ名を入力",created:"グループを作成しました",updated:"グループを更新しました"},modal:{editGroup:"グループを編集",createGroup:"グループを作成",cancel:"キャンセル",saving:"保存中...",creating:"作成中...",saveChanges:"変更を保存"},form:{groupName:"グループ名",permissions:"権限",groupNamePlaceholder:"グループ名を入力",systemGroupWarning:"システムグループ名は変更できません",description:"説明",descriptionPlaceholder:"説明を入力(任意)"},deleteModal:{confirm:"確認",title:"グループを削除",message:"このグループを削除しますか?このグループのユーザーはこれらの権限を失います。"},title:"グループ管理",subtitle:"アクセス制御の権限グループを管理",system:"システム",edit:"編集",delete:"削除"},users:{title:"ユーザー管理",backToSettings:"設定に戻る",createUser:"ユーザーを作成",noPermission:"このページにアクセスする権限がありません。",admin:"管理者",noGroups:"グループなし",inactive:"非アクティブ",edit:"編集",delete:"削除",system:"システム",noGroupsAvailable:"利用可能なグループがありません",table:{username:"ユーザー名",groups:"グループ",status:"ステータス",actions:"アクション"},toast:{deleted:"アーカイブを削除しました",passwordsDoNotMatch:"パスワードが一致しません",created:"ユーザーを作成しました",updated:"ユーザーを更新しました",fillRequired:"必須項目をすべて入力してください",passwordTooShort:"パスワードは6文字以上必要です"},modal:{createUser:"ユーザーを作成",editUser:"ユーザーを編集",cancel:"キャンセル",creating:"作成中...",saving:"保存中...",saveChanges:"変更を保存",advancedAuthSubtitle:"高度な認証を使用"},form:{username:"ユーザー名",password:"パスワード",confirmPassword:"パスワードの確認",confirmPasswordPlaceholder:"パスワードを確認",confirmNewPasswordPlaceholder:"新しいパスワードを確認",leaveBlankToKeep:"(現在のパスワードを維持する場合は空白)",groups:"グループ",usernamePlaceholder:"ユーザー名を入力",passwordPlaceholder:"パスワードを入力",newPasswordPlaceholder:"新しいパスワードを入力",email:"メール",emailPlaceholder:"user@example.com",optional:"オプション",autoGeneratedPassword:"安全なパスワードが自動的に生成され、ユーザーにメールで送信されます。",passwordManagedByAdvancedAuth:"パスワードは高度な認証によって管理されています。「パスワードのリセット」を使用して、メールで新しいパスワードをユーザーに送信してください。",resetPassword:"パスワードのリセット",resettingPassword:"パスワードをリセット中..."},deleteModal:{title:"ユーザーを削除",confirm:"ユーザーを削除",message:"このユーザーを削除してもよろしいですか?この操作は元に戻せません。"},subtitle:"ユーザーとBambuddyインスタンスへのアクセスを管理",active:"アクティブ"},streamOverlay:{invalidPrinterId:"無効なプリンターID",cameraStream:"カメラストリーム",eta:"予想時間 {{minutes}} 分",status:{printing:"印刷中",paused:"一時停止",finished:"完了",failed:"失敗",idle:"待機中",unknown:"不明"},title:"ストリームオーバーレイ",progress:"進捗",tomorrow:"明日",printerIdle:"プリンター待機中",printerOffline:"プリンターオフライン"},profiles:{title:"フィラメントプロファイル",connectedAs:"接続中:",logout:"ログアウト",failedToLoad:"ファイルの読み込みに失敗しました",time:{justNow:"たった今",hoursAgo:"{{count}}時間前",daysAgo:"{{count}}日前",minsAgo:"{{count}}分前"},toast:{loggedOut:"ログアウトしました"},login:{title:"Bambuddy ログイン",subtitle:"アカウントにサインイン",email:"メールアドレス",password:"パスワード",region:"リージョン",regionGlobal:"グローバル",regionChina:"中国",verificationCode:"認証コード",totpCode:"認証アプリコード",checkEmail:"メール ({{email}}) に届いた6桁のコードを入力してください",enterTotpHint:"認証アプリの6桁のコードを入力してください",accessToken:"アクセストークン",accessTokenHint:"Bambu Labのアクセストークンを貼り付け(Bambu Studioから取得)",back:"戻る",toast:{loggedIn:"ログインしました",enterTotp:"認証アプリのコードを入力してください",tokenSet:"トークンを設定しました",codeSent:"メールに認証コードを送信しました"},loginButton:"ログイン",verifyButton:"認証",setTokenButton:"トークンを設定",useToken:"アクセストークンを使用",useEmail:"メールでログイン"},presets:{duplicate:"複製",editable:"編集可能",failedToLoadDetails:"プリセットの詳細を読み込めませんでした",deleteConfirm:"このプロファイルを削除しますか?",noDeletePermission:"プロジェクトを削除する権限がありません",types:{filament:"フィラメント",printer:"プリンター",process:"プロセス"},toast:{deleted:"アーカイブを削除しました",fieldAdded:'フィールド "{{key}}" を追加しました',created:"プリセットを作成しました",updated:"プリセットを更新しました",duplicated:"プリセットを複製しました",exported:"プリセットをエクスポートしました"},newPreset:"新規プリセット",editPreset:"プリセットを編集",duplicatePreset:"プリセットを複製",createNewPreset:"新しいプリセットを作成",customizeSettings:"新しいプリセットの設定をカスタマイズ",compareWithBase:"ベースプリセットと比較",compare:"比較",basePreset:"ベースプリセット",selectBasePreset:"ベースプリセットを選択...",presetName:"プリセット名",inheritsFrom:"継承元:",dropJsonToImport:"JSONファイルをドロップしてインポート",availableFields:"利用可能なフィールド",noMatchingFields:"一致するフィールドがありません",allFieldsAdded:"すべてのフィールドが追加済みです",addCustomField:"カスタムフィールドを追加",yourOverrides:"オーバーライド一覧",noOverridesYet:"オーバーライドはまだありません",clickFieldsToAdd:"左のフィールドをクリックして追加",saveAsTemplate:"テンプレートとして保存",myPreset:"マイプリセット(編集可能)",deleteWarning:"「{{name}}」をBambu Cloudから完全に削除します。元に戻せません。",noDuplicatePermission:"プリセットを複製する権限がありません",noEditPermission:"プリセットを編集する権限がありません",baseLabel:"ベース: {{name}}",currentLabel:"現在: {{name}}",myCustomPreset:"カスタムプリセット",tabs:{common:"一般",allFields:"すべてのフィールド"},searchFieldsPlaceholder:"フィールドを検索...",jsonTip:"ヒント: .jsonファイルをこのモーダルにドラッグ&ドロップして設定をインポート"},cloudView:{templates:"テンプレート",refresh:"更新",newPreset:"新規プリセット",clearFilters:"フィルターをクリア",compareMode:"比較モード",selectAnotherPreset:"同じタイプ({{type}})の別のプリセットを選択",clickTwoPresets:"同じタイプのプリセットを2つクリックして比較",selectFirst:"1. 最初を選択",selectSecond:"2. 2番目を選択",compareNow:"比較を実行",lastSynced:"最終同期:",showingCount:"{{total}}件中{{shown}}件を表示",noPresetsFound:"プリセットが見つかりません",columns:{filament:"フィラメント",process:"プロセス",printer:"プリンター"},noFilamentPresets:"フィラメントプリセットなし",noProcessPresets:"プロセスプリセットなし",noPrinterPresets:"プリンタープリセットなし",filters:{type:"種類",owner:"所有者",printer:"プリンター",nozzle:"ノズル",filament:"フィラメント",layer:"レイヤー",myPresets:"マイプリセット",builtIn:"ビルトイン",process:"プロセス",all:"すべて"},noCreatePermission:"プロジェクトを作成する権限がありません",searchPlaceholder:"プリセットを検索...",noTemplatesPermission:"テンプレートを管理する権限がありません",noRefreshPermission:"プロファイルを更新する権限がありません"},templates:{title:"フィラメントプロファイル",noTemplates:"テンプレートがありません。バックエンドを再起動してデフォルトテンプレートを作成してください。",typeFilter:"タイプ:",deleteConfirm:"このプロファイルを削除しますか?",settingsJson:"設定 (JSON)",fieldsCount:"{{count}}フィールド",shownInModals:"モーダルに表示",hiddenInModals:"モーダルで非表示",apply:"適用",toast:{deleted:"アーカイブを削除しました",updated:"テンプレートを更新しました",created:"テンプレートを作成しました",applied:"テンプレートを適用しました"},createFirst:"プリセットエディタからテンプレートを作成",deleteTitle:"テンプレートを削除",deleteWarning:"この操作は元に戻せません",namePlaceholder:"テンプレート名",descriptionPlaceholder:"説明"},subtitle:"スライサープリセットと圧力キャリブレーションの管理",tabs:{cloud:"クラウドプロファイル",local:"ローカルプロファイル",kprofiles:"Kプロファイル"},localProfiles:{title:"ローカルプロファイル",subtitle:"OrcaSlicerからスライサープリセットをインポート・管理",import:"プロファイルをインポート",importDesc:".bbscfg、.bbsflmt、.orca_filament、.zip、.jsonファイルをここにドロップ",importing:"インポート中...",search:"ローカルプリセットを検索...",noPresets:"ローカルプリセットがまだありません",badge:"ローカル",edit:"編集",delete:"削除",cancel:"キャンセル",deleteConfirmTitle:"プリセットを削除",deleteConfirm:"このプリセットを削除してもよろしいですか?元に戻せません。",source:"ソース",inheritsFrom:"継承元",filamentType:"タイプ",vendor:"メーカー",compatiblePrinters:"プリンター",nozzleTemp:"ノズル温度",cost:"コスト",density:"密度",pressureAdvance:"プレッシャーアドバンス",filament:"フィラメント",process:"プロセス",printer:"プリンター",toast:{importSuccess:"{{count}}件のプリセットをインポートしました",importSkipped:"{{count}}件のプリセットをスキップしました(重複)",importError:"インポート中に{{count}}件のエラーが発生しました",deleted:"プリセットを削除しました",updated:"プリセットを更新しました"}},noLogoutPermission:"ログアウトする権限がありません",retry:"リトライ"},fileManager:{uploadFiles:"ファイルをアップロード",newFolder:"新しいフォルダ",folderName:"フォルダ名",folderNamePlaceholder:"例: 機能パーツ",renameFile:"ファイル名を変更",renameFolder:"フォルダ名を変更",rootNoFolder:"ルート(フォルダなし)",current:"(現在)",linkFolder:"フォルダをリンク",linkFolderDescription:"「{{name}}」をプロジェクトまたはアーカイブにリンクしてすばやくアクセス。",noProjectsFound:"プロジェクトが見つかりません",noArchivesFound:"アーカイブが見つかりません",unlink:"リンク解除",link:"リンク",dropFilesHere:"ここにファイルをドロップ",orClickToBrowse:"またはクリックして選択",zipFilesDetected:"ZIPファイルを検出",preserveZipStructure:"ZIPのフォルダ構造を保持",willBeExtracted:"• 展開予定",filesExtracted:"• {{count}}個のファイルを展開済み",uploadComplete:"アップロード完了: {{count}}個成功",uploadFailed:"アップロード失敗",uploading:"アップロード中...",changeLink:"リンクを変更...",linkTo:"リンク先...",linkToProjectOrArchive:"プロジェクトまたはアーカイブにリンク",addToQueue:"キューに追加",schedulePrint:"印刷をスケジュール",gridView:"グリッド表示",listView:"リスト表示",lowDiskSpaceWarning:"ディスク容量不足の警告",folders:"フォルダ",size:"サイズ",free:"空き:",allFiles:"すべてのファイル",searchFiles:"ファイルを検索...",allTypes:"すべての種類",prints:"印刷回数",ascending:"昇順",descending:"降順",selectAll:"すべて選択",deselectAll:"すべて選択解除",selected:"{{count}}件選択中",adding:"追加中...",loadingFiles:"ファイルを読み込み中...",noFilesYet:"ファイルはまだありません",noMatchingFiles:"一致するファイルがありません",noMatchingFilesDescription:"現在の検索またはフィルター条件に一致するファイルがありません。",clearFilters:"フィルターをクリア",printedCount:"{{count}}回印刷済み",deleteFolder:"フォルダを削除",deleteFile:"ファイルを削除",deleteFolderConfirm:"このフォルダを削除しますか?中のファイルもすべて削除されます。",deleteFileConfirm:"このファイルを削除しますか?",deleting:"削除中...",toast:{folderCreated:"フォルダを作成しました",folderDeleted:"フォルダを削除しました",fileDeleted:"ファイルを削除しました",filesMoved:"ファイルを移動しました",folderLinked:"フォルダをリンクしました",folderUnlinked:"フォルダのリンクを解除しました",addedToQueue:"{{count}}個のファイルをキューに追加しました",fileRenamed:"ファイル名を変更しました",folderRenamed:"フォルダ名を変更しました",filesDeleted:"{{count}}件のファイルを削除しました",addedToQueuePartial:"{{added}}件追加、{{failed}}件失敗",failedToAddToQueue:"ファイルの追加に失敗: {{error}}",thumbnailsGenerated:"{{count}}件のサムネイルを生成しました",thumbnailsGeneratedPartial:"{{succeeded}}件生成、{{failed}}件失敗",noStlMissingThumbnails:"サムネイルのないSTLファイルはありません",failedToGenerateThumbnails:"サムネイルの生成に失敗: {{error}}",thumbnailGenerated:"サムネイルを生成しました",failedToGenerateThumbnail:"サムネイルの生成に失敗: {{error}}"},title:"ファイル管理",subtitle:"印刷ファイルの整理と管理",moveFiles:"{{count}}件のファイルを移動",project:"プロジェクト",archive:"アーカイブ",dragDropFiles:"ファイルをここにドラッグ&ドロップ",allFileTypesSupported:"すべてのファイルタイプに対応。ZIPファイルは展開されます。",zipExtractOptions:"ZIPファイルは展開されます。フォルダー構造の処理方法を選択:",createFolderFromZip:"ZIPファイル名からフォルダーを作成",stlThumbnailGeneration:"STLサムネイル生成",zipMayContainStl:"ZIPファイルにSTLファイルが含まれている場合があります。展開時にサムネイルを生成できます。",thumbnailsCanBeGenerated:"STLファイルのサムネイルを生成できます。大きなモデルは処理に時間がかかる場合があります。",generateThumbnailsForStl:"STLファイルのサムネイルを生成",threemfDetected:"3MFファイルを検出",threemfExtractionInfo:"プリンターモデル、素材、色、印刷設定は3MFファイルから自動的に抽出されます。",generateThumbnail:"サムネイルを生成",generateThumbnails:"サムネイルを生成",generateThumbnailsForMissing:"サムネイルのないSTLファイルのサムネイルを生成",lowDiskSpaceDetails:"{{total}}中{{free}}の空き容量のみ。しきい値は設定で{{threshold}}GBに設定されています。",files:"ファイル",wrap:"折り返し",enableTextWrapping:"テキスト折り返しを有効化",disableTextWrapping:"テキスト折り返しを無効化",dragToResizeTooltip:"ドラッグしてリサイズ、ダブルクリックでリセット",resultsCount:"{{total}}件中{{showing}}件",folderIsEmpty:"フォルダーは空です",folderEmptyDescription:"ファイルをアップロードするか、このフォルダーにファイルを移動して開始しましょう。",noFilesDescription:"印刷関連ファイルの整理を始めるにはファイルをアップロードしてください。",uploadedBy:"アップロード者",deleteFilesCount:"{{count}}件のファイルを削除",deleteFilesConfirm:"選択した{{count}}件のファイルを削除しますか?この操作は元に戻せません。",noPermissionRenameFolder:"フォルダー名を変更する権限がありません",noPermissionLinkFolder:"フォルダーをリンクする権限がありません",noPermissionDeleteFolder:"フォルダーを削除する権限がありません",noPermissionPrint:"印刷する権限がありません",noPermissionAddToQueue:"キューに追加する権限がありません",noPermissionDownload:"ファイルをダウンロードする権限がありません",noPermissionRenameFile:"このファイル名を変更する権限がありません",noPermissionGenerateThumbnail:"サムネイルを生成する権限がありません",noPermissionDeleteFile:"このファイルを削除する権限がありません",noPermissionCreateFolder:"フォルダーを作成する権限がありません",noPermissionUpload:"ファイルをアップロードする権限がありません",noPermissionMoveFiles:"ファイルを移動する権限がありません",noPermissionDeleteFiles:"ファイルを削除する権限がありません"},projects:{title:"プロジェクト",subtitle:"印刷プロジェクトを管理",newProject:"新規プロジェクト",editProject:"プロジェクトを編集",deleteProject:"プロジェクトを削除",projectName:"プロジェクト: {{name}}",create:"作成",plates:"プレート",parts:"パーツ",viewDetails:"詳細を表示",namePlaceholder:"プロジェクト名",descriptionPlaceholder:"プロジェクトの説明(任意)",color:"色",targetPlates:"目標プレート数",targetPlatesPlaceholder:"例: 10",targetParts:"目標パーツ数",targetPartsPlaceholder:"例: 50",tagsPlaceholder:"カンマ区切りのタグ",dueDate:"期限",priorityLow:"低",priorityNormal:"通常",priorityHigh:"高",priorityUrgent:"緊急",statusArchived:"アーカイブ済み",done:"完了",completed:"完了",failed:"失敗",inQueue:"キュー内",noPrintsYet:"印刷履歴なし",printJobs:"印刷ジョブ",partsPrinted:"印刷済みパーツ",failedParts:"失敗パーツ",import:"インポート",importProject:"プロジェクトをインポート",loading:"プロジェクトを読み込み中...",noEditPermission:"プロジェクトを編集する権限がありません",noDeletePermission:"プロジェクトを削除する権限がありません",noCreatePermission:"プロジェクトを作成する権限がありません",noImportPermission:"プロジェクトをインポートする権限がありません",noExportPermission:"プロジェクトをエクスポートする権限がありません",toast:{deleted:"アーカイブを削除しました",importFailed:"インポートに失敗しました",created:"プロジェクトを作成しました",updated:"プロジェクトを更新しました",imported:"プロジェクトをインポートしました",multipleImported:"{{count}}件のプロジェクトをインポートしました",exported:"プロジェクトをエクスポートしました(メタデータのみ)"},description:"説明",noProjects:"プロジェクトはまだありません",noProjectsFiltered:"{{status}}のプロジェクトはありません",noProjectsFilteredHelp:"{{status}}のプロジェクトがありません。ステータスが変更されるとここに表示されます。",createFirst:"最初のプロジェクトを作成して、関連する印刷の整理、進捗管理、ビルドの管理を始めましょう。",createFirstButton:"最初のプロジェクトを作成",files:"ファイル",prints:"印刷",lastModified:"最終更新日",deleteConfirm:"このプロジェクトを削除しますか?アーカイブとキューアイテムはリンク解除されますが、削除されません。",addFiles:"ファイルを追加",removeFile:"ファイルを削除",targetPlatesHelp:"印刷ジョブの数",targetPartsHelp:"必要なオブジェクトの総数",tagsLabel:"タグ(カンマ区切り)",priority:"優先度",statusActive:"進行中",statusCompleted:"完了",export:"エクスポート",exportAll:"すべてのプロジェクトをエクスポート"},projectDetail:{notFound:"見つかりません",backToProjects:"プロジェクト一覧に戻る",exportProject:"プロジェクトをエクスポート",noExportPermission:"プロジェクトをエクスポートする権限がありません",noEditPermission:"このプロジェクトを編集する権限がありません",partOf:"所属先",priorityLabel:"優先度",status:{active:"進行中",completed:"完了",archived:"アーカイブ済み"},priority:{low:"低",normal:"通常",high:"高",urgent:"緊急"},dueDate:{overdue:"期限超過",daysLeft:"残り{{count}}日",today:"今日が期限"},progress:{platesProgress:"プレート進捗",partsProgress:"パーツ進捗",printJobs:"印刷ジョブ",parts:"パーツ",percentComplete:"% 完了",remaining:"残り"},stats:{printJobs:"印刷ジョブ",total:"合計",failed:"失敗",partsPrinted:"印刷済みパーツ",printTime:"印刷時間",filamentUsed:"フィラメント使用量"},cost:{filamentCost:"フィラメント",energy:"エネルギー",budget:"予算",remaining:"残り",title:"コスト追跡"},notes:{noEditPermission:"このプロジェクトを編集する権限がありません",empty:"<空>",title:"メモ",placeholder:"このプロジェクトについてメモを追加..."},files:{fileCount:"{{count}}ファイル",empty:"<空>",title:"ファイル",linkFolders:"ファイルマネージャーからフォルダーをリンク",forQuickAccess:"してクイックアクセスできるようにします。"},bom:{showAll:"すべて表示",hideDone:"完了を非表示",addPart:"パーツを追加",partNamePlaceholder:"パーツ名",qty:"数量",sourcingUrlPlaceholder:"URL(任意)",remarksPlaceholder:"備考",deletePart:"パーツを削除",noEditPermission:"このプロジェクトを編集する権限がありません",noDeletePermission:"プロジェクトを削除する権限がありません",totalCost:"合計コスト",empty:"<空>",title:"部品表",acquired:"{{completed}}/{{total}} 取得済み",noAddPermission:"パーツを追加する権限がありません",partName:"パーツ名",price:"価格 ({{currency}})",deleteConfirm:"「{{name}}」を削除しますか?",noUpdatePermission:"パーツを更新する権限がありません"},timeline:{empty:"<空>",title:"アクティビティタイムライン"},template:{saveAsTemplate:"テンプレートとして保存",noCreatePermission:"プロジェクトを作成する権限がありません"},queue:{title:"印刷キュー",viewAll:"すべて表示",printing:"印刷中",queued:"キューに追加"},toast:{projectUpdated:"プロジェクトを更新しました",partAdded:"パーツを追加しました",partRemoved:"パーツを削除しました",exportFailed:"エクスポートに失敗しました",projectExported:"プロジェクトがエクスポートされました",templateCreated:"プロジェクトからテンプレートを作成しました"},export:"エクスポート",noPrints:"このプロジェクトにはまだ印刷がありません",subProjects:{title:"サブプロジェクト ({{count}})"},prints:{title:"印刷 ({{count}})"}},system:{clearLogs:"通知ログを削除",title:"システム情報",version:"バージョン",uptime:"稼働時間",cpuUsage:"CPU使用率",memoryUsage:"メモリ使用量",diskUsage:"ディスク使用量",networkInfo:"ネットワーク情報",logs:"ログ",debugMode:"デバッグモード",enableDebug:"デバッグログを有効化",disableDebug:"デバッグログを無効化",downloadLogs:"ログをダウンロード",dockerInfo:"Docker情報",containerName:"コンテナ名",imageName:"イメージ名",platform:"プラットフォーム",architecture:"アーキテクチャ"},library:{material:"素材",temperature:"温度",title:"フィラメントライブラリ",addFilament:"フィラメントを追加",editFilament:"フィラメントを編集",deleteFilament:"フィラメントを削除",vendor:"メーカー",color:"色",kFactor:"K値",noFilaments:"ライブラリにフィラメントがありません",deleteConfirm:"このフィラメントを削除しますか?",importFromPrinter:"プリンターからインポート",exportToFile:"ファイルにエクスポート"},spoolman:{title:"Spoolman連携",url:"Spoolman URL",connected:"接続中",disconnected:"未接続",sync:"同期",linkToSpoolman:"Spoolmanに連携",noUnlinkedSpools:"Spoolmanに未連携のスプールが見つかりません。",fillSourceLabel:"(Spoolman)",remaining:"残り",disableWeightSync:"AMS推定重量同期を無効化",disableWeightSyncDesc:"AMS推定値から残量を更新しません。AMSの割合ベースの推定よりもSpoolmanの使用量追跡を優先する場合に使用してください。新しいスプールは引き続きAMS推定値を初期重量として使用します。",reportPartialUsage:"失敗した印刷の部分使用量を報告",reportPartialUsageDesc:"印刷が失敗またはキャンセルされた場合、レイヤー進捗に基づいてその時点までの推定フィラメント使用量を報告します。",testConnection:"接続テスト",syncing:"同期中...",lastSync:"最終同期",unlinkSpool:"スプールのリンクを解除",weight:"重量",enabled:"Spoolman有効",openInSpoolman:"Spoolmanで開く",selectSpool:"スプールを選択",linkSuccess:"スプールをSpoolmanにリンクしました",linkFailed:"スプールのリンクに失敗しました",spoolId:"スプールID"},timelapse:{download:"ダウンロード",preview:"プレビュー",processing:"バックアップファイルを処理中...",title:"タイムラプス",create:"タイムラプスを作成",delete:"削除",frameRate:"フレームレート",quality:"品質",noTimelapses:"利用可能なタイムラプスがありません"},ams:{empty:"<空>",humidity:"湿度",temperature:"温度",remaining:"残り",noHistory:"メンテナンス履歴がありません",configureSlot:"フィラメントプロファイルとK値でスロットを設定",externalSpool:"外部スプール",title:"AMS",slot:"スロット",emptySlot:"空のスロット",unknown:"不明",filamentType:"フィラメントタイプ",filamentColor:"色",history:"AMS履歴",profile:"プロファイル",kFactor:"K値",fill:"充填率",configure:"設定"},printModal:{flowCalibration:"フローキャリブレーション",vibrationCalibration:"振動キャリブレーション",startPrint:"印刷を開始",noPrintersAvailable:"利用可能なプリンターがありません",title:"印刷を開始",selectPrinter:"プリンターを選択",selectPlate:"プレートを選択",filamentMapping:"フィラメントマッピング",printSettings:"印刷設定",bedLeveling:"ベッドレベリング",layerInspection:"第一層検査",timelapse:"タイムラプス",addToQueue:"キューに追加",printerBusy:"プリンターは使用中です",printerOffline:"プリンターはオフラインです",cancel:"キャンセル"},backup:{restoreBackup:"バックアップの復元",restoreDescription:"バックアップファイルからすべてのデータを置き換える",lastBackup:"最終バックアップ",autoBackup:"自動バックアップ",backupNow:"今すぐバックアップ",backupFailed:"バックアップに失敗しました: {{error}}",restoreNote:"復元中、仮想プリンターは停止されます",downloadBackup:"バックアップをダウンロード",uploadBackup:"バックアップをアップロード",restoreWarning:"警告: バックアップの復元は現在のすべてのデータを上書きします。",includeArchives:"アーカイブを含む",includeSettings:"設定を含む",includeProfiles:"プロファイルを含む",backupSuccess:"バックアップを作成しました",restoreSuccess:"バックアップを復元しました",restoreFailed:"復元に失敗しました",title:"バックアップと復元",createBackup:"バックアップを作成"},uploadModal:{title:"3MFファイルのアップロード",dragDrop:".3mfファイルをここにドラッグ&ドロップ",or:"または",browseFiles:"ファイルを参照",uploaded:"アップロード済み",failed:"アップロードに失敗しました",uploading:"アップロード中...",upload:"アップロード",uploadFailed:"アップロード失敗",extractionInfo:"プリンターモデルは3MFファイルのメタデータから自動的に抽出されます。"},editArchive:{title:"アーカイブを編集",name:"名前",printer:"プリンター",noPrinter:"プリンターなし",project:"プロジェクト",noProject:"プロジェクトなし",itemsPrinted:"印刷数",notes:"メモ",notesPlaceholder:"この印刷についてメモを追加...",externalLink:"外部リンク",externalLinkPlaceholder:"https://...",tags:"タグ",addMoreTags:"タグをさらに追加...",status:"ステータス",failureReason:"失敗理由",selectReason:"理由を選択...",photos:"印刷結果の写真",printResult:"印刷結果",saving:"保存中...",failureReasons:{adhesionFailure:"定着不良",spaghettiDetached:"スパゲッティ / 剥離",layerShift:"レイヤーシフト",cloggedNozzle:"ノズル詰まり",filamentRunout:"フィラメント切れ",warping:"反り",stringing:"糸引き",underExtrusion:"押出不足",powerFailure:"電源障害",userCancelled:"ユーザーによるキャンセル",other:"その他"},itemsPrintedHelp:"この印刷ジョブで製造したアイテム数",externalLinkHelp:"Printables、Thingiverse、その他のソースへのリンク",matchingTags:'"{{query}}" に一致',existingTags:"既存のタグ",clickToAdd:"(クリックして追加)",photosHelp:"+ をクリックして印刷結果の写真を追加",namePlaceholder:"印刷名",tagsPlaceholder:"タグを追加...",statuses:{completed:"完了",failed:"失敗",aborted:"キャンセル",printing:"印刷中"}},kProfiles:{noPrintersConfigured:"プリンターが設定されていません",noActivePrinters:"アクティブなプリンターがありません",loadingProfiles:"Kプロファイルを読み込み中...",printerOffline:"プリンターオフライン",noMatchingProfiles:"一致するプロファイルなし",noKProfiles:"Kプロファイルなし",createFirstProfile:"最初のプロファイルを作成",nozzle:"ノズル",refresh:"更新",addProfile:"K-プロファイルを追加",import:"インポート",select:"選択",selectAll:"すべて選択",searchPlaceholder:"名前またはフィラメントで検索...",allExtruders:"すべてのエクストルーダー",leftOnly:"左のみ",rightOnly:"右のみ",allFlow:"すべてのフロー",hfOnly:"HFのみ",sOnly:"Sのみ",sortName:"ソート: 名前",sortKValue:"ソート: K値",sortFilament:"ソート: フィラメント",leftExtruder:"左エクストルーダー",rightExtruder:"右エクストルーダー",modal:{profileName:"プロファイル名",profileNamePlaceholder:"マイPLAプロファイル",kValue:"K値",filament:"フィラメント",selectFilament:"フィラメントを選択...",flowType:"フロータイプ",highFlow:"ハイフロー",standard:"スタンダード",nozzleSize:"ノズルサイズ",extruder:"エクストルーダー",extruders:"エクストルーダー",left:"左",right:"右",notesPlaceholder:"このプロファイルのメモを追加...",pleaseWait:"お待ちください",addTitle:"Kプロファイルを追加",editTitle:"Kプロファイルを編集",kValuePlaceholder:"0.020",kValueHelp:"一般的な範囲: PLA 0.01〜0.06、PETG 0.02〜0.10",noFilamentsHelp:"フィラメントが見つかりません。Bambu Studioでまずプロファイルを作成してください。",notes:"メモ(ローカル保存)",notesHelp:"メモはBambuddyに保存され、プリンターには保存されません",syncing:"プリンターと同期中...",savingExtruder:"エクストルーダーに保存中 {{current}}/{{total}}..."},toast:{profileSaved:"Kプロファイルを保存しました",profileDeleted:"Kプロファイルを削除しました",exportedProfiles:"{{count}}件のプロファイルをエクスポートしました",importedProfiles:"{{total}}件中{{imported}}件のプロファイルをインポートしました",noProfilesToExport:"エクスポートするプロファイルがありません",invalidFileFormat:"無効なファイル形式",failedToParseImport:"インポートファイルの解析に失敗しました",failedToSaveNote:"メモの保存に失敗しました",profilesSaved:"Kプロファイルを{{count}}台のエクストルーダーに保存しました",selectAtLeastOneExtruder:"エクストルーダーを1つ以上選択してください",profilesDeleted:"{{count}}件のプロファイルを削除しました",failedToSaveBatch:"Kプロファイルの保存に失敗しました",noteSaved:"メモを保存しました"},title:"Kプロファイル",addPrinterInSettings:"Kプロファイルを管理するには設定でプリンターを追加してください",enablePrinterConnection:"Kプロファイルを表示するにはプリンター接続を有効にしてください",printerOfflineDesc:"選択したプリンターは接続されていません。電源を入れてKプロファイルを表示してください。",noMatchingProfilesDesc:"検索条件に一致するプロファイルがありません",noKProfilesDesc:"{{diameter}}mmノズル用の圧力キャリブレーションプロファイルが見つかりません",printer:"プリンター",export:"エクスポート",delete:"削除",deleteConfirm:{title:"プロファイルを削除",cannotUndo:"元に戻せません",message:"「{{name}}」をプリンターから削除しますか?"},bulkDelete:{title:"プロファイルを削除",cannotUndo:"元に戻せません",message:"選択した{{count}}件のプロファイルをプリンターから削除しますか?"},permission:{noRead:"プロファイルを更新する権限がありません",noCreate:"プロファイルを追加する権限がありません",noUpdate:"Kプロファイルを更新する権限がありません",noDelete:"Kプロファイルを削除する権限がありません",noExport:"プロファイルをエクスポートする権限がありません",noImport:"プロファイルをインポートする権限がありません"}},virtualPrinter:{running:"稼働中",enable:{visibleInSlicer:"スライサーの検出リストに「Bambuddy」として表示",proxyingTo:"{{name}}にプロキシ中",notActive:"非アクティブ",title:"仮想プリンターを有効化"},remoteInterface:{optional:"オプション — 自動検出IPが間違っている場合に使用(複数NIC、Docker、VPNなど)",title:"ネットワークインターフェース上書き",configured:"インターフェース上書き有効",placeholder:"自動検出(デフォルト)...",hint:"SSDPで広告され、TLS証明書に使用されるIPアドレスを上書きします。Bambuddyに複数のネットワークインターフェースがある場合に便利です。"},howItWorks:{step5:"設定したアクセスコードで接続する",step6:"Bambuddyに「印刷」すると、3MFファイルがアーカイブされる",proxyStep1:"ターゲットプリンターを選択(LANモードである必要があります)",proxyStep2:"クロスネットワーク時:スライサーネットワークインターフェースを選択",proxyStep3:"プロキシを有効化 - プリンターがSSDPでスライサー検出に表示されます",proxyStep4:"プリンターのアクセスコードで接続",proxyStep5:"通常通り印刷 - トラフィックはBambuddyを経由して中継されます",proxyStep6:"カメラストリーミングにはNAT/IP転送が必要です(ドキュメント参照)",title:"仕組み",titleProxy:"仕組み(プロキシモード)",step1:"プラットフォーム用のセットアップガイドを完了",step2:"仮想プリンターを有効にしてアクセスコードを設定",step3:"Bambu StudioまたはOrcaSlicerで「プリンター追加」へ",step4:"「Bambuddy」プリンターが検出リストに表示されます"},status:{mode:"モード",pendingFiles:"保留中のファイル",ftpPort:"FTPポート",mqttPort:"MQTTポート",ftpConnections:"FTP接続数",mqttConnections:"MQTT接続数",title:"ステータス詳細",printerName:"プリンター名",model:"モデル",serialNumber:"シリアル番号",targetPrinter:"ターゲットプリンター"},toast:{accessCodeRequired:"先にアクセスコードを設定してください",targetPrinterRequired:"先にターゲットプリンターを選択してください",accessCodeEmpty:"アクセスコードは空にできません",accessCodeLength:"アクセスコードは8文字である必要があります",updated:"仮想プリンター設定を更新しました",failedToUpdate:"設定の更新に失敗しました"},title:"仮想プリンター",stopped:"停止",description:{default:"Bambu StudioとOrcaSlicerに表示される仮想プリンターを有効化。このプリンターに送信されたファイルは印刷せずに直接アーカイブされます。",proxy:"スライサーのトラフィックを実際のプリンターに転送するプロキシを有効化。任意のネットワーク経由でリモート印刷が可能です。"},model:{title:"プリンターモデル",description:"エミュレートするプリンターモデルを選択。",restartWarning:"モデルを変更すると仮想プリンターが再起動されます"},accessCode:{title:"アクセスコード",isSet:"アクセスコードが設定されています",notSet:"アクセスコード未設定 - 有効化に必要です",placeholder:"8文字のコードを入力",placeholderChange:"新しいコードを入力して変更",hint:"正確に8文字必要です。スライサーの認証に使用されます。",charCount:"({{count}}/8)"},targetPrinter:{title:"ターゲットプリンター",configured:"プロキシターゲット設定済み",notConfigured:"ターゲットプリンター未選択 - プロキシモードに必要です",placeholder:"プリンターを選択...",hint:"スライサートラフィックの転送先プリンターを選択。プリンターはLANモードである必要があります。",noPrinters:"プリンターが設定されていません。プロキシモードを使用するにはまずプリンターを追加してください。"},mode:{title:"モード",archive:"アーカイブ",archiveDesc:"ファイルを即座にアーカイブ",review:"レビュー",reviewDesc:"アーカイブ前にレビュー",queue:"キュー",queueDesc:"アーカイブしてキューに追加",proxy:"プロキシ",proxyDesc:"実際のプリンターに転送"},setupRequired:{title:"セットアップが必要です",description:"仮想プリンター機能を使用するには追加のシステム設定が必要です。ポートフォワーディング、ファイアウォールルール、プラットフォーム固有の設定が含まれます。",readGuide:"有効にする前にセットアップガイドをお読みください"}},modelViewer:{openInSlicer:"スライサーで開く",tabs:{model:"3Dモデル",gcode:"G-codeプレビュー"},notAvailable:"利用不可",notSliced:"未スライス",plates:"プレート",allPlates:"全プレート",plateNumber:"プレート {{number}}",plateCount:"{{count}} プレート",plateCount_other:"{{count}} プレート",objectCount:"{{count}} オブジェクト",objectCount_other:"{{count}} オブジェクト",filamentCount:"{{count}} フィラメント",filamentCount_other:"{{count}} フィラメント",eta:"予想時間 {{minutes}} 分",noPreview:"このファイルのプレビューは利用できません",pagination:{pageOf:"ページ {{current}} / {{total}}",prev:"前へ",next:"次へ"},errors:{failedToLoad:"ファイルの読み込みに失敗しました",noMeshes:"3MFファイルにメッシュが見つかりません",unsupportedFormat:"サポートされていないファイル形式です"}},maintenanceDescriptions:{lubricateRails:"リニアレールの潤滑",cleanNozzle:"ノズル/ホットエンドの清掃",checkBelts:"ベルト張力の確認",cleanBuildPlate:"ビルドプレートの清掃",checkExtruder:"エクストルーダーギアの確認",checkCooling:"冷却ファンの確認",generalInspection:"総合点検",cleanCarbonRods:"カーボンロッドの清掃",checkPtfeTube:"PTFEチューブの確認",replaceHepaFilter:"HEPAフィルター交換",replaceCarbonFilter:"カーボンフィルター交換",lubricateLeftNozzleRail:"左ノズルレールの潤滑"},hmsErrors:{title:"エラー - {{name}}",noErrors:"エラーなし",viewOnWiki:"Bambu Lab Wikiで表示",clearInstructions:"プリンターでエラーをクリアするとここからも消えます。"},plateAlert:{title:"印刷が一時停止されました!",message:"ビルドプレート上にオブジェクトが検出されました。印刷が自動的に一時停止されました。プレートをクリアして印刷を再開してください。",understand:"了解"},tags:{title:"タグ",addTag:"タグを追加",editTag:"タグを編集",deleteTag:"タグを削除",tagName:"タグ名",tagColor:"タグの色",noTags:"タグがありません",deleteConfirm:"このタグを削除しますか?",manageTags:"タグを管理"},support:{debugLoggingActive:"デバッグログが有効です",manageLogs:"管理",collectItem7:"プリンター接続状態とファームウェアバージョン",collectItem8:"連携状態(Spoolman、MQTT、HA)",collectItem9:"ネットワークインターフェース(サブネットのみ)",collectItem10:"Pythonパッケージバージョン",collectItem11:"データベース健全性チェック",collectItem12:"Docker環境の詳細"},configureAmsSlot:{searchPresets:"プリセットを検索...",colorPlaceholder:"色名またはHex(例: 茶色、FF8800)",clearCustomColor:"カスタム色をクリア",noCloudPresets:"クラウドプリセットがありません。Bambu Cloudにログインして同期してください。",noMatchingPresets:"一致するプリセットが見つかりません。",custom:"カスタム",settingsSentToPrinter:"設定をプリンターに送信しました",filamentProfile:"フィラメントプロファイル"},emailSettings:{placeholders:{fromName:"BamBuddy"}},smartPlugs:{offline:"オフライン",admin:"管理",openPlugAdminPage:"プラグ管理ページを開く",deleteSmartPlug:"スマートプラグを削除",turnOnSmartPlug:"スマートプラグをオンにする",turnOffSmartPlug:"スマートプラグをオフにする",turnOn:"オンにする",turnOff:"オフにする",addSmartPlug:{scanningNetwork:"ネットワークをスキャン中...",chooseEntity:"エンティティを選択...",connectionFailed:"接続失敗",searchEntities:"エンティティを検索...",searchPowerSensors:"電力センサーを検索...",searchEnergySensors:"エネルギーセンサーを検索...",placeholders:{plugName:"リビングルームプラグ",mqttStateOnValue:"ON, true, 1",mqttSameAsPower:"電力トピックと同じ、または異なる"}}},externalLinks:{noLinksConfigured:"外部リンクが設定されていません",deleteLink:"リンクを削除",removeCustomIcon:"カスタムアイコンを削除",openInNewTab:"新しいタブで開く",placeholders:{linkName:"マイリンク"}},keyboardShortcuts:{title:"キーボードショートカット",navigation:"ナビゲーション",archivesSection:"アーカイブ",kProfilesSection:"Kプロファイル",generalSection:"全般",shortcuts:{goToPrinters:"プリンターへ移動",goToArchives:"アーカイブへ移動",goToQueue:"キューへ移動",goToStats:"統計へ移動",goToProfiles:"クラウドプロファイルへ移動",goToSettings:"設定へ移動",focusSearch:"検索にフォーカス",openUploadModal:"アップロードモーダルを開く",clearSelection:"選択をクリア / 入力をぼかす",contextMenu:"カードのコンテキストメニュー",refreshProfiles:"プロファイルを更新",newProfile:"新しいプロファイル",exitSelectionMode:"選択モードを終了",showHelp:"このヘルプを表示"},footer:"Escキーを押すか外側をクリックして閉じます"},restoreBackup:{title:"バックアップを復元",restoring:"復元中...",restoreComplete:"復元完了",restoreFailed:"復元失敗",importSettings:"バックアップファイルから設定をインポート",pleaseWait:"データの復元中です。しばらくお待ちください",clickToSelect:"クリックしてバックアップファイルを選択(.jsonまたは.zip)",howDuplicateHandling:"重複の処理方法:",categories:{printers:"プリンター",smartPlugs:"スマートプラグ",notificationProviders:"通知プロバイダー",filaments:"フィラメント",archives:"アーカイブ",pendingUploads:"保留中のアップロード",settingsTemplates:"設定とテンプレート"},matchingInfo:{printers:"シリアル番号で照合",smartPlugs:"IPアドレスで照合",notificationProviders:"名前で照合",filaments:"名前+タイプ+ブランドで照合",archives:"コンテンツハッシュで照合",pendingUploads:"ファイル名で照合",settingsTemplates:"常に上書き"},replaceExisting:"既存データを置き換え",keepExisting:"既存データを保持",replaceDescription:"既に存在するアイテムをバックアップデータで上書き",keepDescription:"まだ存在しないアイテムのみを復元",caution:"注意:",cautionText:"上書きすると現在の構成がバックアップデータに置き換えられます。セキュリティ上の理由から、プリンターのアクセスコードは上書きされません。",itemsRestored:"復元されたアイテム",itemsSkipped:"スキップされたアイテム",restored:"復元済み",skipped:"スキップ(既に存在)",filesLabel:"ファイル(3MF、サムネイルなど)",newApiKeysGenerated:"新しいAPIキーが生成されました",newApiKeysWarning:"これらのキーは一度だけ表示されます。今すぐコピーしてください!",processingBackup:"バックアップファイルを処理中...",noDataFound:"バックアップファイルに復元するデータが見つかりませんでした。",failedToRestore:"バックアップの復元に失敗しました。ファイル形式を確認してください。"},backupExport:{title:"バックアップをエクスポート",selectData:"含めるデータを選択",selectAll:"すべて選択",selectNone:"なし",categoryDescriptions:{settings:"言語、テーマ、更新設定",notifications:"ntfy、Pushover、Discordなど",templates:"カスタムメッセージテンプレート",smartPlugs:"Tasmotaプラグ設定",externalLinks:"サイドバーの外部サービスへのリンク",printers:"プリンター情報(アクセスコード除外)",plateDetection:"空プレート参照画像",filaments:"フィラメントの種類とコスト",maintenance:"カスタムメンテナンススケジュール",archives:"すべての印刷データ+ファイル(3MF、サムネイル、写真)",projects:"プロジェクト、BOMアイテム、添付ファイル",pendingUploads:"仮想プリンターアップロード待機中",apiKeys:"Webhook APIキー(インポート時に新しいキーが生成されます)"},requiresPrinters:"プリンターを選択する必要があります",zipFileWarning:"ZIPファイルが作成されます。",zipFileDescription:"すべての3MFファイル、サムネイル、タイムラプス、写真が含まれます。これには時間がかかり、大きなファイルになる可能性があります。",includeAccessCodes:"アクセスコードを含める",includeAccessCodesDescription:"別のマシンへの転送用",includeAccessCodesWarning:"アクセスコードはプレーンテキストで含まれます。このバックアップファイルを安全に保管してください!",categoriesSelected:"{{selectedCount}}カテゴリー選択済み"},tagManagement:{searchTags:"タグを検索...",renameTag:"タグ名を変更",deleteTag:"タグを削除"},notificationTemplates:{placeholders:{title:"通知タイトル...",body:"通知本文..."}},batchTag:{placeholders:{newTag:"新しいタグを入力..."}},photoGallery:{deletePhoto:"写真を削除"},filamentHoverCard:{copySpoolUuid:"スプールUUIDをコピー"},kProfilesView:{hasNote:"メモあり",copyProfile:"プロファイルをコピー"},layout:{openMenu:"メニューを開く",noPermissionSystemInfo:"システム情報を表示する権限がありません"},notificationProviderCard:{deleteNotificationProvider:"通知プロバイダーを削除"},fileManagerModal:{closeFileManager:"ファイルマネージャーを閉じる",sortFiles:"ファイルを並べ替え",goToParentFolder:"親フォルダーへ移動",threeView:"3Dビュー"},embeddedCameraViewer:{refreshStream:"ストリームを更新",close:"閉じる",zoomOut:"ズームアウト",resetZoom:"ズームをリセット",zoomIn:"ズームイン",dragToResize:"ドラッグしてサイズ変更"},timelapseViewer:{skipBack5s:"5秒戻る",skipForward5s:"5秒進む"},notificationProviders:{descriptions:{email:"SMTP電子メール通知",telegram:"Telegramボット経由の通知",discord:"Webhookを介してDiscordチャンネルに送信",ntfy:"無料でセルフホスト可能なプッシュ通知",pushover:"シンプルで信頼性の高いプッシュ通知",callmebot:"CallMeBot経由の無料WhatsApp通知",webhook:"任意のURLへのジェネリックHTTP POST"}},switchbarPopover:{noSwitchesInSwitchbar:"スイッチバーにスイッチがありません"},projectPageModal:{placeholders:{title:"タイトル",designer:"デザイナー",license:"ライセンス",description:"説明を入力...",profileTitle:"プロファイルタイトル",profileDescription:"プロファイルの説明..."}},githubBackupSettings:{},spoolmanSettings:{}},hoe={nav:{printers:"Stampanti",archives:"Archivi",queue:"Coda",stats:"Statistiche",profiles:"Profili",maintenance:"Manutenzione",projects:"Progetti",files:"File",settings:"Impostazioni",system:"Sistema",collapseSidebar:"Comprimi barra laterale",expandSidebar:"Espandi barra laterale",update:"Aggiorna",updateAvailable:"Aggiornamento disponibile: v{{version}}",updateAvailableBanner:"Versione {{version}} disponibile!",viewUpdate:"Vedi aggiornamento",viewOnGithub:"Vedi su GitHub",keyboardShortcuts:"Scorciatoie da tastiera (?)",switchToLight:"Passa a tema chiaro",switchToDark:"Passa a tema scuro",smartSwitches:"Interruttori Smart",logout:"Esci"},common:{save:"Salva",saving:"Salvataggio...",cancel:"Annulla",delete:"Elimina",edit:"Modifica",add:"Aggiungi",close:"Chiudi",confirm:"Conferma",loading:"Caricamento...",error:"Errore",success:"Successo",warning:"Avviso",enabled:"Abilitato",disabled:"Disabilitato",yes:"Si",no:"No",on:"On",off:"Off",all:"Tutti",none:"Nessuno",search:"Cerca",filter:"Filtro",sort:"Ordina",refresh:"Aggiorna",download:"Scarica",upload:"Carica",actions:"Azioni",status:"Stato",name:"Nome",description:"Descrizione",date:"Data",time:"Ora",hours:"ore",minutes:"minuti",seconds:"secondi",days:"giorni",enable:"Abilita",disable:"Disabilita",permissions:"Permessi",noPrinters:"Nessuna stampante configurata",noData:"Nessun dato disponibile",linkNotFound:"Link non trovato",required:"Obbligatorio",optional:"Opzionale",dismiss:"Chiudi",apply:"Applica",reset:"Reimposta",clear:"Pulisci",selectAll:"Seleziona tutto",deselectAll:"Deseleziona tutto",noChange:"— Nessun cambio —",unchanged:"Invariato",unassigned:"Non assegnato",unknown:"Sconosciuto",unknownError:"Errore sconosciuto",today:"Oggi",asap:"ASAP",overdue:"Scaduto",now:"Ora",collapse:"Comprimi",expand:"Espandi",viewArchive:"Vedi archivio",viewInFileManager:"Vedi nel Gestore file",addedBy:"Aggiunto da {{username}}",prints:"stampe",more:"+{{count}} altre",ascending:"Crescente",descending:"Decrescente",printer:"Stampante",remove:"Rimuovi",type:"Tipo",print:"Stampa",rename:"Rinomina",move:"Sposta",create:"Crea",duplicate:"Duplica",left:"Sinistra",right:"Destra"},printers:{title:"Stampanti",addPrinter:"Aggiungi Stampante",editPrinter:"Modifica Stampante",deletePrinter:"Elimina Stampante",printerName:"Nome Stampante",serialNumber:"Numero Seriale",ipAddress:"Indirizzo IP",accessCode:"Codice di Accesso",model:"Modello",nozzleCount:"Numero Ugelli",autoArchive:"Auto Archiviazione",status:{idle:"Inattiva",printing:"In stampa",paused:"In pausa",offline:"Offline",error:"Errore",finished:"Finita",unknown:"Sconosciuto"},temperatures:{nozzle:"Ugello",bed:"Piatto",chamber:"Camera"},progress:"{{percent}}% completato",timeRemaining:"{{time}} rimanente",deleteConfirm:'Sei sicuro di eliminare "{{name}}"?',maintenanceOk:"Manutenzione OK",maintenanceWarning:"{{count}} avviso",maintenanceWarning_plural:"{{count}} avvisi",maintenanceDue:"{{count}} in scadenza",maintenanceDue_plural:"{{count}} in scadenza",sort:{name:"Nome",status:"Stato",model:"Modello",location:"Posizione",ascending:"Ordina crescente",descending:"Ordina decrescente"},cardSize:{small:"Schede piccole",medium:"Schede medie",large:"Schede grandi",extraLarge:"Schede extra grandi"},hideOffline:"Nascondi offline",powerOn:"Accendi",offlinePrintersWithPlugs:"Stampanti offline con smart plug",noPrintersConfigured:"Nessuna stampante configurata",readyToPrint:"Pronta a stampare",external:"Esterna",deleteArchives:"Elimina archivi stampa",noLabel:"Nessuna etichetta",printPreview:"Anteprima stampa",width:"Larghezza",height:"Altezza",noObjectsFound:"Nessun oggetto trovato",objectsLoadedOnPrintStart:"Gli oggetti sono caricati quando inizia una stampa",willBeSkipped:"Verra saltato",name:"Nome",serialCannotBeChanged:"Il numero seriale non può essere cambiato",locationHelp:"Usato per raggruppare stampanti e filtrare i lavori in coda",wifiSignal:{veryWeak:"Molto debole",weak:"Debole",fair:"Discreto",good:"Buono",excellent:"Eccellente"},maintenanceUpToDate:"Tutta la manutenzione aggiornata - Clicca per vedere",chamberLightOn:"Accendi luce camera",chamberLightOff:"Spegni luce camera",browseFiles:"Sfoglia file stampante",autoOffAfterPrint:"Spegnimento automatico dopo stampa",autoOffExecuted:"Spegnimento automatico eseguito - accendi la stampante per reimpostare",hmsErrors:"Errori HMS",viewHmsErrors:"Vedi {{count}} errore(i) HMS",resume:"Riprendi",pause:"Pausa",stop:"Ferma",camera:"Camera",skipObject:"Salta Oggetto",reconnect:"Riconnetti",mqttDebug:"Debug MQTT",activeNozzle:"Attivo: ugello {{nozzle}}",nozzleRack:"Rack Ugelli",nozzleDocked:"Agganciato",nozzleMounted:"Montato",nozzleWear:"Usura",nozzleMaxTemp:"Temp Max",nozzleSerial:"Seriale",nozzleHardenedSteel:"Acciaio Temprato",nozzleStainlessSteel:"Acciaio Inox",nozzleTungstenCarbide:"Carburo di Tungsteno",nozzleFlow:"Flusso",nozzleHighFlow:"Alto Flusso",nozzleStandardFlow:"Standard",firmwareUpdate:"Aggiornamento Firmware",firmwareInstructions:"Sul touchscreen della stampante, vai a",firmwareNav:"Vai a",settings:"Impostazioni",firmware:"Firmware",discoverPrinters:"Trova Stampanti",searching:"Ricerca...",manualEntry:"Inserimento manuale",addFromCloud:"Aggiungi da Cloud",toast:{printerDeleted:"Stampante eliminata",printerAdded:"Stampante aggiunta",printerUpdated:"Stampante aggiornata",failedToDelete:"Impossibile eliminare stampante",failedToAdd:"Impossibile aggiungere stampante",failedToUpdate:"Impossibile aggiornare stampante",commandSent:"Comando inviato",failedToSendCommand:"Impossibile inviare comando",turnedOn:"{{name}} accesa",failedToPowerOn:"Impossibile accendere {{name}}",scriptTriggered:"Script avviato",printStopped:"Stampa fermata",printPaused:"Stampa in pausa",printResumed:"Stampa ripresa",referenceDeleted:"Riferimento eliminato",detectionAreaSaved:"Area rilevamento salvata",failedToRunScript:"Impossibile eseguire script",failedToStopPrint:"Impossibile fermare stampa",failedToPausePrint:"Impossibile mettere in pausa stampa",failedToResumePrint:"Impossibile riprendere stampa",failedToControlChamberLight:"Impossibile controllare luce camera",failedToUpdateSetting:"Impossibile aggiornare impostazione",failedToSkipObjects:"Impossibile saltare oggetti",failedToRereadRfid:"Impossibile rileggere RFID",failedToCheckPlate:"Impossibile controllare piatto",failedToUpdateLabel:"Impossibile aggiornare etichetta",failedToDeleteReference:"Impossibile eliminare riferimento",failedToSaveDetectionArea:"Impossibile salvare area rilevamento",plateCheckEnabled:"Controllo piatto abilitato",plateCheckDisabled:"Controllo piatto disabilitato",calibrationSaved:"Calibrazione salvata!",calibrationFailed:"Calibrazione non riuscita",rfidRereadInitiated:"Rilettura RFID avviata"},connection:{connected:"Connesso",offline:"Offline"},queue:{inQueue:"{{count}} stampa in coda",inQueue_plural:"{{count}} stampe in coda"},controls:"Controlli",rfid:{reread:"Rileggi RFID"},permission:{noAdd:"Non hai il permesso di aggiungere stampanti",noEdit:"Non hai il permesso di modificare stampanti",noDelete:"Non hai il permesso di eliminare stampanti",noControl:"Non hai il permesso di controllare stampanti",noFiles:"Non hai il permesso di accedere ai file stampante",noAmsRfid:"Non hai il permesso di rileggere AMS RFID",noSmartPlugControl:"Non hai il permesso di controllare smart plug"},modal:{addTitle:"Aggiungi Stampante",editTitle:"Modifica Stampante",myPrinter:"La mia Stampante",selectModel:"Seleziona modello...",locationGroup:"Posizione / Gruppo (opzionale)",locationPlaceholder:"es. Officina, Ufficio, Cantina",autoArchiveLabel:"Archivia automaticamente stampe completate",fromPrinterSettings:"Dalle impostazioni della stampante",modelOptional:"Modello (opzionale)",saveChanges:"Salva modifiche"},skipObjects:{tooltip:"Salta oggetti",onlyWhilePrinting:"Salta oggetti (solo durante la stampa)",requiresMultiple:"Salta oggetti (richiede 2+ oggetti)",title:"Salta Oggetti",matchIdsInfo:"Abbina gli ID con il display della stampante",printerShowsIds:"Lo schermo mostra gli ID oggetto sul piatto",skipSelected:"Salta selezionati",skipping:"Saltando...",noObjectsSelected:"Nessun oggetto selezionato",selectObjectsToSkip:"Seleziona gli oggetti da saltare nella stampa corrente",skipped:"saltato",objectsSkipped:"Oggetti saltati",activeCount:"{{count}} attivi",waitForLayer:"Attendi il layer 2+ per saltare oggetti (attualmente layer {{layer}})",skip:"Salta"},confirm:{deleteTitle:"Elimina Stampante",deleteMessage:'Sei sicuro di eliminare "{{name}}"? Questo rimuoverà tutte le impostazioni di connessione.',deleteArchivesNote:"Tutta la cronologia di stampa sarà eliminata definitivamente.",keepArchivesNote:"La cronologia sarà mantenuta ma non più associata a questa stampante.",stopTitle:"Ferma Stampa",stopMessage:'Sei sicuro di fermare la stampa corrente su "{{name}}"? Questo annullerà il lavoro di stampa.',stopButton:"Ferma Stampa",pauseTitle:"Pausa Stampa",pauseMessage:'Sei sicuro di mettere in pausa la stampa corrente su "{{name}}"?',pauseButton:"Pausa Stampa",resumeTitle:"Riprendi Stampa",resumeMessage:'Sei sicuro di riprendere la stampa su "{{name}}"?',resumeButton:"Riprendi Stampa",powerOnTitle:"Accendi Stampante",powerOnMessage:'Sei sicuro di accendere "{{name}}"?',powerOnButton:"Accendi",powerOffTitle:"Spegni Stampante",powerOffMessage:'Sei sicuro di spegnere "{{name}}"?',powerOffWarning:'AVVISO: "{{name}}" sta stampando! Sei sicuro di spegnere? Questo interromperà la stampa e potrebbe danneggiare la stampante.',powerOffButton:"Spegni"},discovery:{title:"Trova Stampanti",searching:"Ricerca...",scanning:"Scansione...",scanProgress:"Scansione... {{scanned}}/{{total}}",foundPrinters:"Trovate {{count}} stampante(i)",noPrintersFound:"Nessuna stampante trovata",noPrintersFoundSubnet:"Nessuna stampante trovata nella sottorete specificata.",noPrintersFoundNetwork:"Nessuna stampante trovata sulla rete.",allConfigured:"Tutte le stampanti trovate sono già configurate.",alreadyAdded:"Già aggiunta",select:"Seleziona",manualEntry:"Inserimento manuale",addFromCloud:"Aggiungi da Cloud",subnetToScan:"Sottorete da scansionare",dockerNote:"Docker rilevato. Inserisci la sottorete della stampante in notazione CIDR. Richiede network_mode: host in docker-compose.yml.",scanSubnet:"Scansiona sottorete per stampanti",discoverNetwork:"Trova stampanti in rete",scanningSubnet:"Scansione sottorete per stampanti Bambu...",scanningNetwork:"Scansione rete...",serialRequired:"Seriale richiesto",unknown:"Sconosciuto",failedToStart:"Avvio ricerca non riuscito"},filaments:"Filamenti",openCameraOverlay:"Apri overlay camera",openCameraWindow:"Apri camera in nuova finestra",firmwareUpdateAvailable:"Aggiornamento firmware disponibile: {{current}} → {{latest}}",firmwareUpToDate:"Firmware {{version}} — Aggiornato",firmwareUpdateButton:"Aggiorna",plateDetection:{noPermission:"Non hai il permesso di aggiornare le stampanti",enabledClick:"Controllo piatto abilitato - Clicca per disabilitare",disabledClick:"Controllo piatto disabilitato - Clicca per abilitare",manageCalibration:"Gestisci calibrazione rilevamento piatto",calibrationRequired:"Calibrazione richiesta",calibrationInstructions:"Assicurati che il piatto sia <strong>completamente vuoto</strong>, poi clicca Calibra.",calibrationDescription:"La calibrazione salva un'immagine di riferimento del piatto vuoto. I controlli futuri confronteranno con questo riferimento per rilevare oggetti.",calibrationTip:"<strong>Suggerimento:</strong> Puoi salvare fino a 5 calibrazioni per piatti diversi. Il sistema usa automaticamente la migliore corrispondenza durante il controllo.",plateEmpty:"Il piatto sembra vuoto",objectsDetected:"Oggetti rilevati sul piatto",confidence:"Confidenza",difference:"Differenza",analysisPreview:"Anteprima analisi:",analysisLegend:"Riquadro verde = area rilevamento, overlay rosso = differenze dalla calibrazione",savedReferences:"Riferimenti salvati ({{count}}/{{max}})",deleteReference:"Elimina riferimento",labelPlaceholder:"Etichetta...",clickToEdit:"{{label}} - Clicca per modificare",clickToAddLabel:"Clicca per aggiungere etichetta"},fans:{partCooling:"Ventola raffreddamento parte",auxiliary:"Ventola ausiliaria",chamber:"Ventola camera"},clickToViewHmsErrors:"Clicca per vedere errori HMS",estimatedCompletion:"Tempo completamento stimato",slotOptions:"Opzioni slot",firmwareModal:{title:"Aggiornamento Firmware",titleUpToDate:"Info Firmware",currentVersion:"Corrente:",latestVersion:"Ultima:",releaseNotes:"Note di rilascio",checkingPrereqs:"Controllo prerequisiti...",sdCardReady:"SD pronta. Clicca sotto per caricare firmware.",uploadedSuccess:"Firmware caricato su SD!",applyInstructions:"Per applicare l'aggiornamento sulla stampante:",step1:"Sul touchscreen della stampante, vai a <strong>Impostazioni</strong>",step2:"Vai a <strong>Firmware</strong>",step3:"Seleziona <strong>Aggiorna da SD</strong>",step4:"L'aggiornamento richiede 10-20 minuti",done:"Fatto",starting:"Avvio...",uploadFirmware:"Carica Firmware",uploadFailed:"Avvio caricamento fallito: {{error}}",uploadedToast:"Firmware caricato! Avvia aggiornamento dal display."},accessCodePlaceholder:"Lascia vuoto per mantenere quello attuale",roi:{title:"Area di rilevamento (ROI)",xStart:"X Inizio",yStart:"Y Inizio",width:"Larghezza",height:"Altezza",instruction:"Regola l'area di rilevamento per focalizzare il piatto. Il riquadro verde mostra l'area corrente."}},archives:{title:"Archivi di stampa",searchPlaceholder:"Cerca archivi...",filterByPrinter:"Filtra per stampante",filterByStatus:"Filtra per stato",sortBy:"Ordina per",sortNewest:"Più recenti",sortOldest:"Meno recenti",sortName:"Nome",sortDuration:"Durata",sortLargest:"Più grandi",sortSmallest:"Più piccoli",sortSize:"Dimensione",noArchives:"Nessun archivio trovato",noArchivesSearch:"Nessun archivio corrisponde alla ricerca",noArchivesYet:"Nessun archivio ancora",loadingArchives:"Caricamento archivi...",releaseToUpload:"Rilascia per caricare",showAll:"Mostra tutti",showFavoritesOnly:"Solo preferiti",gridView:"Vista griglia",listView:"Vista elenco",calendarView:"Vista calendario",manageTags:"Gestisci tag",showFailedPrints:"Mostra stampe fallite",hideFailedPrints:"Nascondi stampe fallite",printTime:"Tempo di stampa",filamentUsed:"Filamento usato",cost:"Costo",reprint:"Ristampa",preview:"Anteprima",deleteArchive:"Elimina archivio",deleteConfirm:"Sei sicuro di eliminare questo archivio?",favorite:"Preferito",unfavorite:"Rimuovi dai preferiti",viewDetails:"Vedi dettagli",status:{completed:"Completato",failed:"Fallito",stopped:"Fermato"},toast:{source3mfAttached:"Sorgente 3MF allegata: {{filename}}",failedUploadSource3mf:"Caricamento sorgente 3MF non riuscito",source3mfRemoved:"Sorgente 3MF rimossa",failedRemoveSource3mf:"Rimozione sorgente 3MF non riuscita",f3dAttached:"F3D allegato: {{filename}}",failedUploadF3d:"Caricamento F3D non riuscito",f3dRemoved:"F3D rimosso",failedRemoveF3d:"Rimozione F3D non riuscita",timelapseAttached:"Timelapse allegato: {{filename}}",timelapseAlreadyAttached:"Timelapse già allegato",noMatchingTimelapse:"Nessun timelapse corrispondente",failedScanTimelapse:"Scansione timelapse non riuscita",failedAttachTimelapse:"Allegato timelapse non riuscito",archiveDeleted:"Archivio eliminato",failedDeleteArchive:"Eliminazione archivio non riuscita",addedToFavorites:"Aggiunto ai preferiti",removedFromFavorites:"Rimosso dai preferiti",projectUpdated:"Progetto aggiornato",failedUpdateProject:"Aggiornamento progetto non riuscito",linkCopied:"Link copiato negli appunti",failedCopyLink:"Copia link non riuscita",photoDeleted:"Foto eliminata",failedDeletePhoto:"Eliminazione foto non riuscita",failedDeleteArchives:"Eliminazione archivi non riuscita",failedUpdateFavorites:"Aggiornamento preferiti non riuscito",exportDownloaded:"Export scaricato",exportFailed:"Export non riuscito"},menu:{print:"Stampa",schedule:"Programma",openInBambuStudio:"Apri nello slicer",slice:"Slice",externalLink:"Link esterno",viewOnMakerWorld:"Vedi su MakerWorld",preview3d:"Anteprima 3D",viewTimelapse:"Vedi Timelapse",scanForTimelapse:"Cerca Timelapse",downloadSource3mf:"Scarica Sorgente 3MF",uploadSource3mf:"Carica Sorgente 3MF",replaceSource3mf:"Sostituisci Sorgente 3MF",removeSource3mf:"Rimuovi Sorgente 3MF",uploadF3d:"Carica F3D",replaceF3d:"Sostituisci F3D",downloadF3d:"Scarica F3D",removeF3d:"Rimuovi F3D",download:"Scarica",copyDownloadLink:"Copia link download",qrCode:"QR Code",viewPhotos:"Vedi foto",viewPhotosCount:"Vedi foto ({{count}})",projectPage:"Pagina progetto",addToFavorites:"Aggiungi ai preferiti",removeFromFavorites:"Rimuovi dai preferiti",edit:"Modifica",goToProject:"Vai al progetto: {{name}}",addToProject:"Aggiungi al progetto",removeFromProject:"Rimuovi dal progetto",loading:"Caricamento...",noProjectsAvailable:"Nessun progetto disponibile",select:"Seleziona",deselect:"Deseleziona",delete:"Elimina"},permission:{noReprint:"Non hai il permesso di ristampare questo archivio",noAddToQueue:"Non hai il permesso di aggiungere alla coda",noUpdateArchives:"Non hai il permesso di aggiornare archivi",noUploadFiles:"Non hai il permesso di caricare file",noDownload:"Non hai il permesso di scaricare archivi",noCopyLink:"Non hai il permesso di copiare link download",noDelete:"Non hai il permesso di eliminare questo archivio",noCreate:"Non hai il permesso di creare archivi"},card:{previousPlate:"Piatto precedente",nextPlate:"Piatto successivo",plateNumber:"Piatto {{index}}",moreOptions:"Clic destro per altre opzioni",addToFavorites:"Aggiungi ai preferiti",removeFromFavorites:"Rimuovi dai preferiti",cancelled:"annullato",failed:"fallito",duplicate:"duplicato",duplicateTitle:"Questo modello è stato stampato prima",openSource3mf:"Apri sorgente 3MF in Bambu Studio (clic destro per altre opzioni)",downloadF3d:"Scarica file design Fusion 360",viewTimelapse:"Vedi timelapse",viewPhoto:"Vedi 1 foto",viewPhotos:"Vedi {{count}} foto",openFolder:"Apri cartella: {{name}}",slicedFile:"File slice - pronto a stampare",sourceFile:"Solo file sorgente - nessuna mappatura AMS disponibile",gcode:"GCODE",source:"SOURCE",project:"Progetto: {{name}}",estimated:"Stimato: {{time}}",actual:"Reale: {{time}}",accuracy:"Accuratezza: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} strato",layers:"{{count}} strati",object:"{{count}} oggetto",objects:"{{count}} oggetti",slicedFor:"Sliced per {{model}}",uploadedBy:"Caricato da",noPermissionReprint:"Non hai il permesso di ristampare",noPermissionEdit:"Non hai il permesso di modificare archivi",noPermissionDelete:"Non hai il permesso di eliminare archivi",reprint:"Ristampa",schedulePrint:"Programma Stampa",schedule:"Programma",openInBambuStudio:"Apri nello slicer",openInBambuStudioToSlice:"Apri nello slicer per slicing",slice:"Slice",externalLink:"Link esterno",makerWorld:"MakerWorld: {{designer}}",viewProject:"Vedi progetto",noExternalLink:"Nessun link esterno",preview3d:"Anteprima 3D",download:"Scarica",edit:"Modifica",delete:"Elimina"},modal:{deleteArchive:"Elimina Archivio",deleteConfirm:'Sei sicuro di eliminare "{{name}}"? Questa azione non può essere annullata.',deleteButton:"Elimina",removeSource3mf:"Rimuovi Sorgente 3MF",removeSource3mfConfirm:'Sei sicuro di rimuovere il file sorgente 3MF da "{{name}}"? Questo eliminerà il progetto slicer originale.',removeButton:"Rimuovi",removeF3d:"Rimuovi F3D",removeF3dConfirm:'Sei sicuro di rimuovere il file Fusion 360 da "{{name}}"?',timelapse:"{{name}} - Timelapse",selectTimelapse:"Seleziona Timelapse",selectTimelapseDesc:"Nessun abbinamento automatico trovato. Seleziona il timelapse per questa stampa:",deleteArchives:"Elimina Archivi",deleteArchivesConfirm:"Sei sicuro di eliminare {{count}} archivio(i)? Questa azione non può essere annullata.",deleteCount:"Elimina {{count}}"},page:{title:"Archivi",printsCount:"{{filtered}} di {{total}} stampe",dropFilesHere:"Rilascia file .3mf qui",releaseToUpload:"Rilascia per caricare",only3mfSupported:"Solo file .3mf supportati",close:"Chiudi",selected:"{{count}} selezionati",selectAll:"Seleziona tutto",tags:"Tag",project:"Progetto",favorite:"Preferito",delete:"Elimina",toggledFavorites:"Preferiti aggiornati per {{count}} archivio(i)",failedUpdateFavorites:"Aggiornamento preferiti non riuscito",archivesDeleted:"{{count}} archivio(i) eliminati",failedDeleteArchives:"Eliminazione archivi non riuscita",photoDeleted:"Foto eliminata",failedDeletePhoto:"Eliminazione foto non riuscita"},list:{name:"Nome",printer:"Stampante",date:"Data",size:"Dimensione",actions:"Azioni",hasTimelapse:"Ha timelapse"}},queue:{title:"Coda di stampa",subtitle:"Programma e gestisci i tuoi lavori di stampa",addToQueue:"Aggiungi alla coda",print:"Stampa",reprint:"Ristampa",schedulePrint:"Programma Stampa",editQueueItem:"Modifica elemento coda",printToPrinters:"Stampa su {{count}} Stampanti",queueToPrinters:"Metti in coda su {{count}} Stampanti",sending:"Invio...",sendingProgress:"Invio {{current}}/{{total}}...",adding:"Aggiunta...",addingProgress:"Aggiunta {{current}}/{{total}}...",savingProgress:"Salvataggio {{current}}/{{total}}...",clearQueue:"Svuota coda",clearHistory:"Svuota cronologia",emptyQueue:"La coda è vuota",position:"Posizione",scheduledTime:"Ora programmata",moveUp:"Sposta su",moveDown:"Sposta giù",startNow:"Avvia ora",printingInProgress:"Stampa in corso...",viewArchive:"Vedi archivio",viewInFileManager:"Vedi nel Gestore file",itemCount:"{{count}} elemento",itemCount_plural:"{{count}} elementi",dragToReorder:"Trascina per riordinare (solo ASAP)",reorderHint:"La posizione influisce solo sugli elementi ASAP. Quelli programmati partono all'orario.",addedBy:"Aggiunto da {{name}}",sections:{currentlyPrinting:"In stampa",queued:"In coda",history:"Cronologia"},status:{pending:"In attesa",waiting:"In attesa",printing:"In stampa",paused:"In pausa",completed:"Completato",failed:"Fallito",skipped:"Saltato",cancelled:"Annullato"},summary:{printing:"In stampa",queued:"In coda",totalTime:"Tempo totale coda",history:"Cronologia"},filter:{allPrinters:"Tutte le stampanti",unassigned:"Non assegnato",allStatus:"Tutti gli stati",allLocations:"Tutte le posizioni",any:"Qualsiasi"},sort:{byPosition:"Ordina per posizione",byName:"Ordina per nome",byPrinter:"Ordina per stampante",bySchedule:"Ordina per programma",byDate:"Ordina per data",ascendingOldest:"Crescente (più vecchi)",descendingNewest:"Decrescente (più recenti)"},badges:{staged:"In staging",requiresPrevious:"Richiede successo precedente",autoPowerOff:"Spegnimento automatico"},empty:{title:"Nessuna stampa programmata",description:`Programma una stampa dalla pagina Archivi usando l'opzione "Programma" nel menu contestuale, o trascina i file per iniziare.`},time:{asap:"ASAP",overdue:"Scaduto",now:"Ora",lessThanMinute:"Tra meno di un minuto",inMinutes:"Tra {{count}} min",inHours:"Tra {{count}} ore"},actions:{stopPrint:"Ferma Stampa",startPrint:"Avvia Stampa",requeue:"Rimetti in coda"},bulkEdit:{title:"Modifica {{count}} elemento",title_plural:"Modifica {{count}} elementi",description:"Solo le impostazioni modificate saranno applicate agli elementi selezionati.",printer:"Stampante",noChange:"— Nessun cambio —",queueOptions:"Opzioni coda",staged:"In staging (avvio manuale)",autoPowerOff:"Spegnimento automatico dopo stampa",requirePrevious:"Richiede successo precedente",printOptions:"Opzioni stampa",bedLevelling:"Livellamento piatto",flowCalibration:"Calibrazione flusso",vibrationCalibration:"Calibrazione vibrazioni",layerInspection:"Controllo primo layer",timelapse:"Timelapse",useAms:"Usa AMS",applyChanges:"Applica modifiche",selectAll:"Seleziona tutto",deselectAll:"Deseleziona tutto",selected:"{{count}} selezionati",editSelected:"Modifica selezionati",cancelSelected:"Annulla selezionati"},confirm:{cancelTitle:"Annulla stampa programmata",cancelMessage:'Sei sicuro di annullare "{{name}}"?',stopTitle:"Ferma Stampa",stopMessage:'Sei sicuro di fermare la stampa corrente "{{name}}"? Questo annullerà il lavoro sulla stampante.',removeTitle:"Rimuovi dalla cronologia",removeMessage:'Sei sicuro di rimuovere "{{name}}" dalla cronologia coda?',clearHistoryTitle:"Svuota cronologia",clearHistoryMessage:"Sei sicuro di rimuovere {{count}} elemento(i) dalla cronologia?",cancelButton:"Annulla Stampa",stopButton:"Ferma Stampa",thisPrint:"questa stampa",thisItem:"questo elemento"},toast:{cancelled:"Elemento coda annullato",cancelFailed:"Annullamento non riuscito",removed:"Elemento coda rimosso",removeFailed:"Rimozione non riuscita",stopped:"Stampa fermata",stopFailed:"Impossibile fermare stampa",released:"Stampa rilasciata in coda",startFailed:"Avvio stampa non riuscito",reorderFailed:"Riordino coda non riuscito",historyCleared:"Cancellati {{count}} elementi cronologia",clearHistoryFailed:"Svuotamento cronologia non riuscito",updateFailed:"Aggiornamento elementi non riuscito",bulkCancelled:"Annullati {{count}} elementi",bulkCancelFailed:"Annullamento elementi non riuscito"},permissions:{noStopPrint:"Non hai il permesso di fermare stampe",noStartPrint:"Non hai il permesso di avviare stampe",noEdit:"Non hai il permesso di modificare questo elemento coda",noCancel:"Non hai il permesso di annullare questo elemento coda",noRequeue:"Non hai il permesso di rimettere in coda elementi",noRemove:"Non hai il permesso di rimuovere questo elemento coda",noClearHistory:"Non hai il permesso di svuotare tutta la cronologia",noEditItems:"Non hai il permesso di modificare elementi coda",noCancelItems:"Non hai il permesso di annullare elementi coda"}},stats:{title:"Dashboard",subtitle:"Trascina i widget per riordinare. Clicca l'icona occhio per nascondere.",overview:"Panoramica",totalPrints:"Stampe totali",successRate:"Tasso di successo",totalPrintTime:"Tempo totale di stampa",printTime:"Tempo di stampa",totalFilament:"Filamento totale usato",filamentUsed:"Filamento usato",filamentCost:"Costo filamento",totalCost:"Costo totale",energyUsed:"Energia usata",energyCost:"Costo energia",averagePrintTime:"Tempo medio di stampa",printsPerDay:"Stampe al giorno",byPrinter:"Per stampante",printsByPrinter:"Stampe per stampante",byMaterial:"Per materiale",byMonth:"Per mese",last7Days:"Ultimi 7 giorni",last30Days:"Ultimi 30 giorni",last90Days:"Ultimi 90 giorni",allTime:"Sempre",quickStats:"Statistiche rapide",printActivity:"Attivita di stampa",filamentTypes:"Tipi di filamento",filamentTrends:"Trend filamento",failureAnalysis:"Analisi guasti",timeAccuracy:"Accuratezza tempo",successful:"Riuscite:",failed:"Fallite:",perfectEstimate:"100% = stima perfetta",noTimeAccuracyData:"Nessun dato accuratezza tempo",noFilamentData:"Nessun dato filamento",noPrinterData:"Nessun dato stampante",noPrintData:"Nessun dato stampa",noPrintDataLast30Days:"Nessun dato stampa negli ultimi 30 giorni",failureReasons:"Cause guasto",topFailureReasons:"Cause principali",failedPrintsCount:"{{failed}} / {{total}} stampe fallite",lastWeekRate:"Settimana scorsa: {{rate}}%",resetLayout:"Reimposta layout",recalculateCosts:"Ricalcola costi",recalculateCostsHint:"Ricalcola tutti i costi archivi usando i prezzi filamento correnti",exportStats:"Esporta statistiche",exportAsCsv:"Esporta come CSV",exportAsExcel:"Esporta come Excel",hiddenCount:"{{count}} Nascosti",exportDownloaded:"Export scaricato",exportFailed:"Export non riuscito",layoutReset:"Layout reimpostato",recalculatedCosts:"Costi ricalcolati per {{count}} archivi",recalculateFailed:"Ricalcolo costi non riuscito",loadingStats:"Caricamento statistiche...",noPermissionResetLayout:"Non hai il permesso di reimpostare il layout",noPermissionRecalculate:"Non hai il permesso di ricalcolare i costi"},maintenance:{title:"Manutenzione",overview:"Panoramica",allOk:"Tutta la manutenzione aggiornata",dueCount:"{{count}} elemento in scadenza",dueCount_plural:"{{count}} elementi in scadenza",warningCount:"{{count}} avviso",warningCount_plural:"{{count}} avvisi",totalPrintTime:"Tempo totale di stampa",nextMaintenance:"Prossima manutenzione",nothingDue:"Niente in scadenza",tasks:"Attivita",lastPerformed:"Ultima esecuzione",interval:"Intervallo",hoursRemaining:"{{hours}}h rimanenti",hoursOverdue:"{{hours}}h in ritardo",markDone:"Segna come fatto",performMaintenance:"Esegui manutenzione",history:"Cronologia",noHistory:"Nessuna cronologia manutenzione",editPrintHours:"Modifica ore stampa",currentHours:"Ore attuali",statusTab:"Stato",settingsTab:"Impostazioni",overdueCount:"{{count}} in ritardo",dueSoonCount:"{{count}} in scadenza",dueSoon:"In scadenza",allGood:"Tutto ok",overdueBy:"In ritardo di {{duration}}",dueIn:"Scade tra {{duration}}",timeLeft:"{{duration}} rimanenti",day:"1 giorno",days:"{{count}} giorni",week:"1 settimana",weeks:"{{count}} settimane",month:"1 mese",months:"{{count}} mesi",year:"1 anno",maintenanceTypes:"Tipi di manutenzione",maintenanceTypesDescription:"Tipi di sistema e tue attivita personalizzate",addCustomType:"Aggiungi tipo personalizzato",intervalType:"Tipo intervallo",intervalValue:"Intervallo ({{type}})",icon:"Icona",documentationLink:"Link documentazione (opzionale)",assignToPrinters:"Assegna alle stampanti",selectAtLeastOnePrinter:"Seleziona almeno una stampante",addType:"Aggiungi tipo",custom:"Personalizzato",printHours:"Ore di stampa",calendarDays:"Giorni calendario",exampleName:"es. Sostituisci filtro HEPA",viewDocumentation:"Vedi documentazione",timeBasedInterval:"Intervallo basato sul tempo",intervalOverrides:"Override intervallo",intervalOverridesDescription:"Personalizza intervalli per stampanti specifiche",assignedToPrinters:"Assegnato alle stampanti:",noPrintersAssigned:"Nessuna stampante assegnata",addPrinterShort:"Aggiungi:",printersAssignedClick:"{{count}} stampante(i) assegnata - clicca per gestire",removeFromPrinter:"Rimuovi da questa stampante",types:{lubricateRails:"Lubrifica guide lineari",cleanNozzle:"Pulisci ugello/Hotend",checkBelts:"Controlla tensione cinghie",cleanBuildPlate:"Pulisci piatto",checkExtruder:"Controlla ingranaggi estrusore",checkCooling:"Controlla ventole raffreddamento",generalInspection:"Ispezione generale",cleanCarbonRods:"Pulisci aste in carbonio",checkPtfeTube:"Controlla tubo PTFE",replaceHepaFilter:"Sostituisci filtro HEPA",replaceCarbonFilter:"Sostituisci filtro carbone",lubricateLeftNozzleRail:"Lubrifica guida ugello sinistro"},maintenanceComplete:"Manutenzione segnata come completata",typeUpdated:"Tipo manutenzione aggiornato",typeDeleted:"Tipo manutenzione eliminato",printHoursUpdated:"Ore di stampa aggiornate",printerAssigned:"Stampante assegnata",printerRemoved:"Stampante rimossa",deleteTypeConfirm:'Eliminare "{{name}}"?',noPermissionUpdate:"Non hai il permesso di aggiornare elementi manutenzione",noPermissionPerform:"Non hai il permesso di eseguire manutenzione",noPermissionEditTypes:"Non hai il permesso di modificare tipi manutenzione",noPermissionDeleteTypes:"Non hai il permesso di eliminare tipi manutenzione",noPermissionEditHours:"Non hai il permesso di modificare ore stampa",noPermissionRemovePrinter:"Non hai il permesso di rimuovere assegnazioni stampanti",noPermissionAssignPrinter:"Non hai il permesso di assegnare stampanti",noPermissionEditIntervals:"Non hai il permesso di modificare intervalli",configureSettings:"Configura tipi e intervalli manutenzione"},settings:{title:"Impostazioni",general:"Generale",tabs:{general:"Generale",smartPlugs:"Prese smart",notifications:"Notifiche",filament:"Filamento",network:"Rete",apiKeys:"Chiavi API",virtualPrinter:"Stampante virtuale",users:"Utenti",backup:"Backup"},appearance:"Aspetto",notifications:"Notifiche",smartPlugs:"Prese smart",spoolman:"Spoolman",updates:"Aggiornamenti",language:"Lingua",languageDescription:"Seleziona la lingua preferita",theme:"Tema",themeLight:"Chiaro",themeDark:"Scuro",themeSystem:"Sistema",defaultView:"Vista predefinita",defaultViewDescription:"Pagina da mostrare all'apertura dell'app",checkForUpdates:"Controlla aggiornamenti",autoUpdate:"Aggiornamento automatico",currentVersion:"Versione attuale",latestVersion:"Ultima versione",upToDate:"Sei aggiornato",updateAvailable:"Aggiornamento disponibile",notificationLanguage:"Lingua notifiche",notificationLanguageDescription:"Lingua per notifiche push",notificationProviders:"Provider notifiche",addProvider:"Aggiungi provider",editProvider:"Modifica provider",providerType:"Tipo provider",testNotification:"Notifica di test",testSuccess:"Notifica di test inviata",testFailed:"Invio notifica di test fallito",quietHours:"Ore silenziose",quietHoursDescription:"Non disturbare in queste ore",quietHoursStart:"Inizio",quietHoursEnd:"Fine",events:{title:"Eventi notifica",printStart:"Stampa avviata",printComplete:"Stampa completata",printFailed:"Stampa fallita",printStopped:"Stampa interrotta",printProgress:"Avanzamento",printProgressDescription:"Notifica al 25%, 50%, 75%",printerOffline:"Stampante offline",printerError:"Errore stampante",filamentLow:"Filamento in esaurimento",maintenanceDue:"Manutenzione dovuta",maintenanceDueDescription:"Notifica quando serve manutenzione"},smartPlug:{title:"Prese smart",add:"Aggiungi presa smart",edit:"Modifica presa smart",name:"Nome",ipAddress:"Indirizzo IP",linkedPrinter:"Stampante collegata",autoOn:"Accensione automatica",autoOnDescription:"Accendi all'avvio stampa",autoOff:"Spegnimento automatico",autoOffDescription:"Spegni dopo il completamento",offDelay:"Ritardo spegnimento",offDelayMinutes:"Minuti dopo la stampa",offDelayTemp:"Quando ugello sotto temperatura",currentState:"Stato attuale",turnOn:"Accendi",turnOff:"Spegni"},spoolmanEnabled:"Abilita integrazione Spoolman",spoolmanUrl:"URL Spoolman",spoolmanConnected:"Connesso",spoolmanDisconnected:"Disconnesso",noDefaultPrinter:"Nessuna predefinita (chiedi ogni volta)",sidebarOrder:"Ordine barra laterale",saveThumbnails:"Salva miniature",captureFinishPhoto:"Acquisisci foto finale",noPrintersConfigured:"Nessuna stampante configurata",archiveMode:{always:"Crea sempre voce archivio",never:"Non creare mai voce archivio",ask:"Chiedi ogni volta"},checkForUpdatesLabel:"Controlla aggiornamenti",checkPrinterFirmware:"Controlla firmware stampante",enableRetry:"Abilita retry",homeAssistantDescription:"Controlla prese smart tramite Home Assistant",environmentManagedLabel:"(Gestito dall'ambiente)",autoEnabledViaEnv:"Abilitato automaticamente tramite variabili d'ambiente",urlFromEnvReadOnly:"Valore impostato dalla variabile d'ambiente HA_URL (sola lettura)",tokenFromEnvReadOnly:"Valore impostato dalla variabile d'ambiente HA_TOKEN (sola lettura)",mqttConnectedTo:"Connesso a",prometheusDescription:"Esponi dati stampante in formato Prometheus",noSmartPlugsTitle:"Nessuna presa smart configurata",noSmartPlugsDescription:"Aggiungi una presa smart Tasmota per monitorare energia e automatizzare il controllo.",noProvidersTitle:"Nessun provider configurato",noProvidersDescription:"Aggiungi un provider per ricevere avvisi.",noTemplatesAvailable:"Nessun template disponibile. Riavvia il backend per generare i template predefiniti.",apiPermissionView:"Visualizza stato stampante e coda",apiPermissionEdit:"Aggiungi e rimuovi elementi dalla coda di stampa",apiKeysEmptyTitle:"Nessuna chiave API",apiKeysEmptyDescription:"Crea una chiave API per integrare servizi esterni.",noUsersFound:"Nessun utente trovato",noGroupsFound:"Nessun gruppo trovato",noGroupsAvailable:"Nessun gruppo disponibile",passwordsDoNotMatch:"Le password non coincidono",systemGroupWarning:"I nomi dei gruppi di sistema non possono essere modificati",authDisabledTitle:"Autenticazione disabilitata",authDisabledFeature1:"Richiedi accesso per usare il sistema",authDisabledFeature2:"Crea più utenti con permessi basati sui gruppi",authDisabledFeature3:"Controlla accesso con 50+ permessi granulari",userHasCreated:"Questo utente ha creato:",userItemsQuestion:"Cosa vuoi fare con questi elementi?",deleteUserConfirm:"Sei sicuro di voler eliminare questo utente?",actionCannotBeUndone:"Questa azione non può essere annullata.",addFirstSmartPlug:"Aggiungi la tua prima presa smart",providers:"Provider",log:"Log",testAll:"Testa tutto",testResults:"Risultati test",testPassedCount:"{{count}} riusciti",testFailedCount:"{{count}} falliti",messageTemplates:"Template messaggi",messageTemplatesDescription:"Personalizza i messaggi per ogni evento.",apiKeys:"Chiavi API",apiKeysDescription:"Crea chiavi API per integrazioni esterne e webhook.",createKey:"Crea chiave",apiKeyCreated:"Chiave API creata con successo",apiKeyCopyWarning:"Copia questa chiave ora - non verra mostrata di nuovo!",useInApiBrowser:"Usa nel Browser API",createNewApiKey:"Crea nuova chiave API",keyName:"Nome chiave",keyNamePlaceholder:"es., Home Assistant, OctoPrint",readStatus:"Leggi stato",readStatusDescription:"Visualizza stato stampante e coda",manageQueue:"Gestisci coda",manageQueueDescription:"Aggiungi e rimuovi elementi dalla coda di stampa",controlPrinter:"Controlla stampante",controlPrinterDescription:"Metti in pausa, riprendi e ferma stampe",unnamedKey:"Chiave senza nome",lastUsed:"Ultimo uso",read:"Lettura",control:"Controllo",createFirstKey:"Crea la tua prima chiave",webhookEndpoints:"Endpoint webhook",webhookApiKeyHint:"Usa la tua chiave API nell'header X-API-Key.",webhook:{getAllStatus:"Ottieni stato di tutte le stampanti",getSpecificStatus:"Ottieni stato di una stampante",addToQueue:"Aggiungi alla coda di stampa",pausePrint:"Metti in pausa stampa",resumePrint:"Riprendi stampa",stopPrint:"Ferma stampa"},apiBrowser:"Browser API",apiBrowserDescription:"Esplora e testa tutti gli endpoint API disponibili.",apiKeyForTesting:"Chiave API per test",apiKeyPlaceholder:"Incolla qui la tua chiave API per testare gli endpoint autenticati...",apiKeyHint:"Questa chiave verra inviata come header X-API-Key.",deleteApiKeyTitle:"Elimina chiave API",deleteApiKeyMessage:"Sei sicuro di voler eliminare questa chiave API? Le integrazioni che la usano non funzioneranno più.",deleteKey:"Elimina chiave",amsDisplayThresholds:"Soglie visualizzazione AMS",amsThresholdsDescription:"Configura soglie colore per umidità e temperatura AMS.",humidity:"Umidità",goodGreen:"Buono (verde)",fairOrange:"Discreto (arancione)",aboveFairBad:"Sopra soglia discreta mostra rosso (scarso)",temperature:"Temperatura",goodBlue:"Buono (blu)",aboveFairHot:"Sopra soglia discreta mostra rosso (caldo)",historyRetention:"Conservazione cronologia",keepSensorHistory:"Mantieni cronologia sensori per",historyRetentionDescription:"I dati più vecchi saranno eliminati automaticamente",printModal:"Modale stampa",expandCustomMapping:"Espandi mapping personalizzato di default",expandCustomMappingDescription:"Quando stampi su più stampanti, mostra mapping AMS per stampante espanso",authentication:"Autenticazione",authEnabledDescription:"La tua istanza è protetta con autenticazione",authDisabledDescription:"Abilita per richiedere accesso e gestire utenti",authDisabledMessage:"Abilita autenticazione per creare account, gestire permessi e proteggere la tua istanza Bambuddy.",enableAuthentication:"Abilita autenticazione",currentUser:"Utente corrente",changePassword:"Cambia password",admin:"Admin",users:"Utenti",addUser:"Aggiungi utente",groups:"Gruppi",addGroup:"Aggiungi gruppo",system:"Sistema",noDescription:"Nessuna descrizione",userCount:"{{count}} utenti",permissionCount:"{{count}} permessi",createUser:"Crea utente",username:"Nome utente",enterUsername:"Inserisci nome utente",password:"Password",enterPassword:"Inserisci password (min 6 caratteri)",confirmPassword:"Conferma password",confirmPasswordPlaceholder:"Conferma password",viewReleaseOnGitHub:"Vedi release su GitHub",turnAllPlugsOn:"Accendi tutte le prese",turnAllPlugsOff:"Spegni tutte le prese",clearNotificationLogs:"Cancella log notifiche",clearLogsMessage:"Questo eliminerà definitivamente tutti i log notifiche più vecchi di 30 giorni. Questa azione non può essere annullata.",clearLogs:"Cancella log",resetUiPreferences:"Reimposta preferenze UI",resetUiPreferencesMessage:"Questo reimposterà le preferenze UI ai valori predefiniti: ordine barra laterale, tema, layout dashboard, modalità vista e preferenze ordinamento. Stampanti, archivi e impostazioni server NON saranno modificati. La pagina si ricaricherà dopo la cancellazione.",resetPreferences:"Reimposta preferenze",deleteGroupTitle:"Elimina gruppo",deleteGroupMessage:"Sei sicuro di voler eliminare questo gruppo? Gli utenti in questo gruppo perderanno questi permessi.",deleteGroup:"Elimina gruppo",disableAuthenticationTitle:"Disabilita autenticazione",disableAuthenticationMessage:"Sei sicuro di voler disabilitare l'autenticazione? Questo renderà la tua istanza Bambuddy accessibile senza login. Tutti gli utenti resteranno nel database ma l'autenticazione sarà disabilitata.",disableAuthentication:"Disabilita autenticazione",configureBambuddy:"Configura Bambuddy",systemDefault:"Predefinito di sistema",archiveSettings:"Impostazioni archivio",newWindow:"Nuova finestra",embeddedOverlay:"Overlay incorporato",preferredSlicer:"Slicer preferito",preferredSlicerDescription:"Scegli quale applicazione slicer usare per aprire i file",externalCameras:"Camere esterne",costTracking:"Tracciamento costi",printsOnly:"Solo stampe",totalConsumption:"Consumo totale",dataManagement:"Gestione dati",clearNotificationLogsDescription:"Elimina log notifiche più vecchi di 30 giorni",resetUiPreferencesDescription:"Reimposta ordine barra laterale, tema, modalità vista e preferenze layout. Stampanti, archivi e impostazioni non vengono modificati.",enableHomeAssistant:"Abilita Home Assistant",enableMqtt:"Abilita MQTT",useTls:"Usa TLS",enableMetricsEndpoint:"Abilita endpoint metriche",availableMetrics:"Metriche disponibili",editUser:"Modifica utente",deleteUserTitle:"Elimina utente",groupName:"Nome gruppo",leaveEmptyForAnonymous:"Lascia vuoto per anonimo",leaveEmptyForNoAuth:"Lascia vuoto per nessuna autenticazione",enterNewPassword:"Inserisci nuova password",confirmNewPassword:"Conferma nuova password",enterGroupName:"Inserisci nome gruppo",enterDescriptionOptional:"Inserisci descrizione (opzionale)",enterCurrentPassword:"Inserisci password attuale",enterNewPasswordMin6:"Inserisci nuova password (min 6 caratteri)",toast:{keyCopied:"Chiave copiata negli appunti",copyFailed:"Copia chiave fallita",keyAddedToBrowser:"Chiave aggiunta al Browser API",clearLogsFailed:"Eliminazione log fallita",uiPreferencesReset:"Preferenze UI reimpostate. Aggiornamento...",authDisabled:"Autenticazione disabilitata con successo",authDisableFailed:"Disabilitazione autenticazione fallita",apiKeyCreated:"Chiave API creata",apiKeyDeleted:"Chiave API eliminata",userCreated:"Utente creato con successo",userUpdated:"Utente aggiornato con successo",userDeleted:"Utente eliminato con successo",groupCreated:"Gruppo creato con successo",groupUpdated:"Gruppo aggiornato con successo",groupDeleted:"Gruppo eliminato con successo",fillRequiredFields:"Compila tutti i campi obbligatori",passwordsDoNotMatch:"Le password non coincidono",passwordTooShort:"La password deve essere di almeno 6 caratteri",enterGroupName:"Inserisci un nome gruppo",settingsSaved:"Impostazioni salvate",cameraSettingsSaved:"Impostazioni camera salvate",enterCameraUrl:"Inserisci un URL camera",passwordChanged:"Password cambiata con successo",connectionFailed:"Connessione fallita",testFailed:"Test fallito",cameraConnected:"Camera connessa{{resolution}}"},testConnection:"Testa connessione"},notification:{printStarted:{title:"Stampa avviata",body:"{{printer}}: {{filename}} ha iniziato a stampare"},printCompleted:{title:"Stampa completata",body:"{{printer}}: {{filename}} completata con successo"},printFailed:{title:"Stampa fallita",body:"{{printer}}: {{filename}} fallita"},printStopped:{title:"Stampa interrotta",body:"{{printer}}: {{filename}} interrotta"},printProgress:{title:"Avanzamento stampa",body:"{{printer}}: {{filename}} al {{percent}}% completamento"},printerOffline:{title:"Stampante offline",body:"{{printer}} e offline"},printerError:{title:"Errore stampante",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filamento in esaurimento",body:"{{printer}}: Filamento in esaurimento"},maintenanceDue:{title:"Manutenzione dovuta",body:"{{printer}}: {{items}} richiedono attenzione"}},errors:{generic:"Qualcosa e andato storto",networkError:"Errore di rete. Controlla la connessione.",notFound:"Non trovato",unauthorized:"Non autorizzato",serverError:"Errore server",validationError:"Controlla i dati inseriti",printerConnectionFailed:"Connessione alla stampante fallita",saveFailed:"Salvataggio modifiche fallito",deleteFailed:"Eliminazione fallita",loadFailed:"Caricamento dati fallito"},hmsErrors:{title:"Errori - {{name}}",noErrors:"Nessun errore",viewOnWiki:"Vedi su Bambu Lab Wiki",clearInstructions:"Cancella gli errori sulla stampante per rimuoverli qui."},mqttDebug:{title:"Log debug MQTT",searchPlaceholder:"Cerca topic o payload...",noMessages:"Nessun messaggio registrato",startLoggingHint:'Clicca "Avvia logging" per iniziare a catturare messaggi MQTT',noMessagesMatch:"Nessun messaggio corrisponde al filtro",adjustFilterHint:"Prova a modificare la ricerca o i filtri",incoming:"In ingresso",outgoing:"In uscita",loggingStopped:"Logging fermato",loggingActive:"Logging attivo - i messaggi si aggiornano automaticamente",startLogging:"Avvia logging",stopLogging:"Ferma logging",clearLog:"Pulisci log",topic:"Topic",timestamp:"Timestamp",direction:"Direzione",all:"Tutti"},printerFiles:{title:"Gestore file",storageUsed:"Usato:",storageFree:"Libero:",filterPlaceholder:"Filtra file...",deleteButton:"Elimina",deleteFiles:"Elimina {{count}} file",deleteFileConfirm:'Eliminare "{{name}}"? Questa azione non può essere annullata.',deleteFilesConfirm:"Eliminare {{count}} file selezionati? Questa azione non può essere annullata.",noFiles:"Nessun file sulla stampante",loadingFiles:"Caricamento file...",failedToLoad:"Caricamento file fallito",toast:{filesDeleted:"Eliminati {{count}} file",deleteFailed:"Eliminazione fallita: {{error}}"}},confirm:{delete:"Sei sicuro di voler eliminare questo?",unsavedChanges:"Hai modifiche non salvate. Sei sicuro di voler uscire?",clearQueue:"Sei sicuro di voler svuotare la coda?"},login:{title:"Login Bambuddy",subtitle:"Accedi al tuo account",username:"Nome utente",usernamePlaceholder:"Inserisci il nome utente",password:"Password",passwordPlaceholder:"Inserisci la password",signIn:"Accedi",signingIn:"Accesso in corso...",forgotPassword:"Hai dimenticato la password?",loginSuccess:"Accesso riuscito",loginFailed:"Accesso fallito",enterCredentials:"Inserisci nome utente e password",forgotPasswordTitle:"Password dimenticata",forgotPasswordMessage:"Se hai dimenticato la password, contatta il tuo amministratore di sistema per reimpostarla.",howToReset:"Come reimpostare la password:",resetStep1:"Contatta il tuo amministratore Bambuddy",resetStep2:"Chiedi di reimpostare la password in Gestione utenti",resetStep3:"Possono impostare una nuova password temporanea",resetStep4:"Accedi con la nuova password e cambiala in Impostazioni",gotIt:"Capito"},setup:{title:"Configurazione Bambuddy",subtitle:"Configura autenticazione per la tua istanza Bambuddy",enableAuth:"Abilita autenticazione",adminAccount:"Account admin",adminAccountDesc:"Se esistono già admin, l'autenticazione verrà abilitata usando gli account esistenti. Lascia i campi sotto vuoti per usare gli admin esistenti, oppure inserisci nuove credenziali per creare un nuovo utente admin.",adminUsername:"Nome utente admin",adminPassword:"Password admin",optionalIfAdminExists:"(opzionale se esistono admin)",adminUsernamePlaceholder:"Inserisci nome utente admin (opzionale)",adminPasswordPlaceholder:"Inserisci password admin (opzionale)",confirmPassword:"Conferma password",confirmPasswordPlaceholder:"Conferma password admin",settingUp:"Configurazione...",completeSetup:"Completa configurazione",toast:{authEnabledAdminCreated:"Autenticazione abilitata e utente admin creato",authEnabledExistingAdmins:"Autenticazione abilitata usando admin esistenti",setupCompleted:"Configurazione completata",enterBothCredentials:"Inserisci nome utente e password admin, oppure lascia entrambi vuoti per usare admin esistenti",passwordsDoNotMatch:"Le password non coincidono",passwordTooShort:"La password deve essere di almeno 6 caratteri"}},changePassword:{title:"Cambia password",currentPassword:"Password attuale",currentPasswordPlaceholder:"Inserisci password attuale",newPassword:"Nuova password",newPasswordPlaceholder:"Inserisci nuova password (min 6 caratteri)",confirmPassword:"Conferma nuova password",confirmPasswordPlaceholder:"Conferma nuova password",passwordsDoNotMatch:"Le password non coincidono",passwordTooShort:"La password deve essere di almeno 6 caratteri",changing:"Modifica in corso...",success:"Password cambiata con successo",failed:"Modifica password fallita"},plateAlert:{title:"Stampa in pausa!",message:"Oggetti rilevati sul piatto. La stampa è stata messa automaticamente in pausa. Svuota il piatto e riprendi la stampa.",understand:"Ho capito"},camera:{title:"Vista camera",invalidPrinterId:"ID stampante non valido",live:"Live",snapshot:"Snapshot",restartStream:"Riavvia stream",refreshSnapshot:"Aggiorna snapshot",fullscreen:"Schermo intero",exitFullscreen:"Esci da schermo intero",connectingToCamera:"Connessione alla camera...",capturingSnapshot:"Acquisizione snapshot...",connectionLost:"Connessione persa",connectionFailed:"Connessione camera fallita",reconnecting:"Riconnessione tra {{countdown}}s... (tentativo {{attempt}}/{{max}})",reconnectNow:"Riconnetti ora",cameraUnavailable:"Camera non disponibile",cameraUnavailableDesc:"Assicurati che la stampante sia accesa e connessa.",noCamera:"Nessuna camera disponibile",retry:"Riprova",cameraStream:"Stream camera",zoomOut:"Zoom indietro",zoomIn:"Zoom avanti",resetZoom:"Reset zoom",recording:"Registrazione",startRecording:"Avvia registrazione",stopRecording:"Ferma registrazione",chamberLight:"Accendi/Spegni luce camera"},groups:{title:"Gestione gruppi",subtitle:"Gestisci gruppi permessi per controllo accesso",backToSettings:"Torna a Impostazioni",createGroup:"Crea gruppo",noPermission:"Non hai il permesso di accedere a questa pagina.",system:"Sistema",noDescription:"Nessuna descrizione",usersCount:"{{count}} utenti",permissionsCount:"{{count}} permessi",edit:"Modifica",delete:"Elimina",toast:{created:"Gruppo creato con successo",updated:"Gruppo aggiornato con successo",deleted:"Gruppo eliminato con successo",enterGroupName:"Inserisci un nome gruppo"},modal:{editGroup:"Modifica gruppo",createGroup:"Crea gruppo",cancel:"Annulla",saving:"Salvataggio...",creating:"Creazione...",saveChanges:"Salva modifiche"},form:{groupName:"Nome gruppo",groupNamePlaceholder:"Inserisci nome gruppo",systemGroupWarning:"I nomi dei gruppi di sistema non possono essere modificati",description:"Descrizione",descriptionPlaceholder:"Inserisci descrizione (opzionale)",permissions:"Permessi ({{count}} selezionati)"},deleteModal:{title:"Elimina gruppo",message:"Sei sicuro di voler eliminare questo gruppo? Gli utenti in questo gruppo perderanno questi permessi.",confirm:"Elimina gruppo"}},users:{title:"Gestione utenti",subtitle:"Gestisci utenti e accesso alla tua istanza Bambuddy",backToSettings:"Torna a Impostazioni",createUser:"Crea utente",noPermission:"Non hai il permesso di accedere a questa pagina.",admin:"Admin",noGroups:"Nessun gruppo",active:"Attivo",inactive:"Inattivo",edit:"Modifica",delete:"Elimina",system:"Sistema",noGroupsAvailable:"Nessun gruppo disponibile",table:{username:"Nome utente",groups:"Gruppi",status:"Stato",actions:"Azioni"},toast:{created:"Utente creato con successo",updated:"Utente aggiornato con successo",deleted:"Utente eliminato con successo",fillRequired:"Compila tutti i campi obbligatori",passwordsDoNotMatch:"Le password non coincidono",passwordTooShort:"La password deve essere di almeno 6 caratteri"},modal:{createUser:"Crea utente",editUser:"Modifica utente",cancel:"Annulla",creating:"Creazione...",saving:"Salvataggio...",saveChanges:"Salva modifiche"},form:{username:"Nome utente",usernamePlaceholder:"Inserisci nome utente",password:"Password",passwordPlaceholder:"Inserisci password",confirmPassword:"Conferma password",confirmPasswordPlaceholder:"Conferma password",newPasswordPlaceholder:"Inserisci nuova password",confirmNewPasswordPlaceholder:"Conferma nuova password",leaveBlankToKeep:"lascia vuoto per mantenere attuale",groups:"Gruppi"},deleteModal:{title:"Elimina utente",message:"Sei sicuro di voler eliminare questo utente? Questa azione non può essere annullata.",confirm:"Elimina utente"}},streamOverlay:{title:"Overlay stream",invalidPrinterId:"ID stampante non valido",cameraStream:"Stream camera",progress:"Avanzamento",eta:"ETA",tomorrow:"Domani",printerIdle:"Stampante inattiva",printerOffline:"Stampante offline",status:{printing:"In stampa",paused:"In pausa",finished:"Completata",failed:"Fallita",idle:"Inattiva",unknown:"Sconosciuto"}},profiles:{title:"Profili",subtitle:"Gestisci preset slicer e calibrazioni pressure advance",tabs:{cloud:"Profili cloud",local:"Profili locali",kprofiles:"K-Profiles"},localProfiles:{title:"Profili locali",subtitle:"Importa e gestisci preset slicer da OrcaSlicer",import:"Importa profili",importDesc:"Trascina file .bbscfg, .bbsflmt, .orca_filament, .zip o .json qui",importing:"Importazione...",search:"Cerca preset locali...",noPresets:"Nessun preset locale ancora",badge:"Locale",edit:"Modifica",delete:"Elimina",cancel:"Annulla",deleteConfirmTitle:"Elimina preset",deleteConfirm:"Sei sicuro di voler eliminare questo preset? Questa azione non può essere annullata.",source:"Fonte",inheritsFrom:"Eredita da",filamentType:"Tipo",vendor:"Produttore",compatiblePrinters:"Stampanti",nozzleTemp:"Temp. ugello",cost:"Costo",density:"Densità",pressureAdvance:"Pressure Advance",filament:"Filamento",process:"Processo",printer:"Stampante",toast:{importSuccess:"{{count}} preset importati",importSkipped:"{{count}} preset saltati (duplicati)",importError:"{{count}} errori durante l'importazione",deleted:"Preset eliminato",updated:"Preset aggiornato"}},connectedAs:"Connesso come",logout:"Esci",noLogoutPermission:"Non hai il permesso di disconnetterti",failedToLoad:"Caricamento profili fallito",retry:"Riprova",time:{justNow:"Proprio ora",minsAgo:"{{count}}m fa",hoursAgo:"{{count}}h fa",daysAgo:"{{count}}g fa"},toast:{loggedOut:"Disconnesso"},login:{title:"Connetti a Bambu Cloud",subtitle:"Sincronizza i preset del slicer tra dispositivi",email:"Email",password:"Password",region:"Regione",regionGlobal:"Globale",regionChina:"Cina",verificationCode:"Codice di verifica",totpCode:"Codice autenticatore",checkEmail:"Controlla la tua email ({{email}}) per un codice a 6 cifre",enterTotpHint:"Inserisci il codice a 6 cifre dalla tua app autenticatore",accessToken:"Access Token",accessTokenHint:"Incolla il tuo access token Bambu Lab (da Bambu Studio)",back:"Indietro",loginButton:"Accedi",verifyButton:"Verifica",setTokenButton:"Imposta token",useToken:"Usa access token invece",useEmail:"Accedi con email invece",toast:{loggedIn:"Accesso riuscito",codeSent:"Codice di verifica inviato via email",enterTotp:"Inserisci il codice dalla tua app autenticatore",tokenSet:"Token impostato con successo"}},presets:{myPreset:"Il mio preset (modificabile)",duplicate:"Duplica",editable:"Modificabile",failedToLoadDetails:"Caricamento dettagli preset fallito",deleteConfirm:"Eliminare questo preset?",deleteWarning:'Questo eliminerà definitivamente "{{name}}" da Bambu Cloud. Questa azione non può essere annullata.',noDuplicatePermission:"Non hai il permesso di duplicare preset",noEditPermission:"Non hai il permesso di modificare preset",noDeletePermission:"Non hai il permesso di eliminare preset",types:{filament:"Preset filamento",printer:"Preset stampante",process:"Preset processo"},toast:{deleted:"Preset eliminato",created:"Preset creato",updated:"Preset aggiornato",duplicated:"Preset duplicato",fieldAdded:'Campo "{{key}}" aggiunto',exported:"Preset esportato"},baseLabel:"Base: {{name}}",currentLabel:"Corrente: {{name}}",newPreset:"Nuovo preset",editPreset:"Modifica preset",duplicatePreset:"Duplica preset",createNewPreset:"Crea nuovo preset",customizeSettings:"Personalizza le impostazioni per il nuovo preset",compareWithBase:"Confronta con base",compare:"Confronta",basePreset:"Preset base",selectBasePreset:"Seleziona preset base...",presetName:"Nome preset",myCustomPreset:"Il mio preset personalizzato",inheritsFrom:"Deriva da",dropJsonToImport:"Rilascia JSON per importare",tabs:{common:"Comune",allFields:"Tutti i campi"},availableFields:"Campi disponibili",searchFieldsPlaceholder:"Cerca campi...",noMatchingFields:"Nessun campo corrispondente",allFieldsAdded:"Tutti i campi aggiunti",addCustomField:"Aggiungi campo personalizzato",yourOverrides:"Le tue override",noOverridesYet:"Nessun override ancora",clickFieldsToAdd:"Clicca i campi a sinistra per aggiungerli",saveAsTemplate:"Salva come template",jsonTip:"Suggerimento: trascina e rilascia un file .json ovunque in questa modale per importare impostazioni"},cloudView:{searchPlaceholder:"Cerca preset...",templates:"Template",refresh:"Aggiorna",newPreset:"Nuovo preset",clearFilters:"Pulisci filtri",compareMode:"Modalita confronto",selectAnotherPreset:"Seleziona un altro preset {{type}}",clickTwoPresets:"Clicca due preset dello stesso tipo per confrontare",selectFirst:"1. Seleziona il primo",selectSecond:"2. Seleziona il secondo",compareNow:"Confronta ora",lastSynced:"Ultima sincronizzazione:",showingCount:"Mostrati {{showing}} di {{total}} preset",noPresetsFound:"Nessun preset trovato",columns:{filament:"Filamento",process:"Processo",printer:"Stampante"},noFilamentPresets:"Nessun preset filamento",noProcessPresets:"Nessun preset processo",noPrinterPresets:"Nessun preset stampante",filters:{type:"Tipo",owner:"Proprietario",printer:"Stampante",nozzle:"Ugello",filament:"Filamento",layer:"Layer",all:"Tutti",myPresets:"I miei preset",builtIn:"Integrati",process:"Processo"},noTemplatesPermission:"Non hai il permesso di gestire i template",noRefreshPermission:"Non hai il permesso di aggiornare i profili",noCreatePermission:"Non hai il permesso di creare preset"},templates:{title:"Template rapidi",noTemplates:"Nessun template ancora",createFirst:"Crea template dall'editor preset",typeFilter:"Tipo:",deleteTitle:"Elimina template",deleteWarning:"Questa azione non può essere annullata",deleteConfirm:'Sei sicuro di voler eliminare "{{name}}"?',namePlaceholder:"Nome template",descriptionPlaceholder:"Descrizione",settingsJson:"Impostazioni (JSON)",fieldsCount:"{{count}} campi",shownInModals:"Mostrati nelle modali",hiddenInModals:"Nascosti nelle modali",apply:"Applica",toast:{deleted:"Template eliminato",updated:"Template aggiornato",created:"Template creato",applied:"Template applicato"}}},support:{debugLoggingActive:"Log debug attivo",manageLogs:"Gestisci",collectItem7:"Connettività stampante e versioni firmware",collectItem8:"Stato integrazioni (Spoolman, MQTT, HA)",collectItem9:"Interfacce di rete (solo subnet)",collectItem10:"Versioni dei pacchetti Python",collectItem11:"Controlli di integrità del database",collectItem12:"Dettagli dell'ambiente Docker"},fileManager:{title:"Gestore file",subtitle:"Organizza e gestisci i tuoi file di stampa",uploadFiles:"Carica file",newFolder:"Nuova cartella",folderName:"Nome cartella",folderNamePlaceholder:"es., Parti funzionali",renameFile:"Rinomina file",renameFolder:"Rinomina cartella",moveFiles:"Sposta {{count}} file",rootNoFolder:"Root (nessuna cartella)",current:"corrente",linkFolder:"Collega cartella",linkFolderDescription:'Collega "{{name}}" a un progetto o archivio per accesso rapido.',project:"Progetto",archive:"Archivio",noProjectsFound:"Nessun progetto trovato",noArchivesFound:"Nessun archivio trovato",unlink:"Scollega",link:"Collega",dragDropFiles:"Trascina e rilascia file qui",dropFilesHere:"Rilascia file qui",orClickToBrowse:"oppure clicca per sfogliare",allFileTypesSupported:"Tutti i tipi di file supportati. I file ZIP saranno estratti.",zipFilesDetected:"File ZIP rilevati",zipExtractOptions:"I file ZIP saranno estratti. Scegli come gestire la struttura cartelle:",preserveZipStructure:"Mantieni struttura cartelle dal ZIP",createFolderFromZip:"Crea cartella dal nome ZIP",stlThumbnailGeneration:"Generazione miniature STL",zipMayContainStl:"I file ZIP possono contenere STL. Le miniature possono essere generate durante l'estrazione.",thumbnailsCanBeGenerated:"Le miniature possono essere generate per file STL. I modelli grandi possono richiedere più tempo.",generateThumbnailsForStl:"Genera miniature per file STL",threemfDetected:"File 3MF rilevati",threemfExtractionInfo:"Modello stampante, materiale, colore e impostazioni stampa saranno estratti automaticamente dai file 3MF.",willBeExtracted:"Sara estratto",filesExtracted:"{{count}} file estratti",uploadComplete:"Caricamento completato: {{succeeded}} riusciti",uploadFailed:"{{count}} falliti",uploading:"Caricamento...",changeLink:"Cambia collegamento...",linkTo:"Collega a...",linkToProjectOrArchive:"Collega a progetto o archivio",addToQueue:"Aggiungi alla coda",schedulePrint:"Pianifica",generateThumbnail:"Genera miniatura",generateThumbnails:"Genera miniature",generateThumbnailsForMissing:"Genera miniature per STL senza miniatura",gridView:"Vista griglia",listView:"Vista elenco",lowDiskSpaceWarning:"Avviso spazio disco basso",lowDiskSpaceDetails:"Solo {{free}} liberi su {{total}} totali. La soglia e {{threshold}} GB nelle impostazioni.",files:"File",folders:"Cartelle",size:"Dimensione",free:"Libero",allFiles:"Tutti i file",wrap:"A capo",enableTextWrapping:"Abilita a capo testo",disableTextWrapping:"Disabilita a capo testo",dragToResizeTooltip:"Trascina per ridimensionare, doppio clic per reset",searchFiles:"Cerca file...",allTypes:"Tutti i tipi",prints:"Stampe",ascending:"Crescente",descending:"Decrescente",resultsCount:"{{showing}} di {{total}} file",selectAll:"Seleziona tutto",deselectAll:"Deseleziona tutto",selected:"{{count}} selezionati",adding:"Aggiunta...",loadingFiles:"Caricamento file...",folderIsEmpty:"La cartella e vuota",noFilesYet:"Nessun file ancora",folderEmptyDescription:"Carica file o sposta file in questa cartella per iniziare.",noFilesDescription:"Carica file per iniziare a organizzare i file di stampa.",noMatchingFiles:"Nessun file corrispondente",noMatchingFilesDescription:"Nessun file corrisponde ai criteri di ricerca o filtro.",clearFilters:"Pulisci filtri",printedCount:"Stampato {{count}}x",uploadedBy:"Caricato da",deleteFolder:"Elimina cartella",deleteFile:"Elimina file",deleteFilesCount:"Elimina {{count}} file",deleteFolderConfirm:"Sei sicuro di voler eliminare questa cartella? Tutti i file dentro saranno eliminati.",deleteFileConfirm:"Sei sicuro di voler eliminare questo file?",deleteFilesConfirm:"Sei sicuro di voler eliminare {{count}} file selezionati? Questa azione non può essere annullata.",deleting:"Eliminazione...",noPermissionRenameFolder:"Non hai il permesso di rinominare cartelle",noPermissionLinkFolder:"Non hai il permesso di collegare cartelle",noPermissionDeleteFolder:"Non hai il permesso di eliminare cartelle",noPermissionPrint:"Non hai il permesso di stampare",noPermissionAddToQueue:"Non hai il permesso di aggiungere alla coda",noPermissionDownload:"Non hai il permesso di scaricare file",noPermissionRenameFile:"Non hai il permesso di rinominare questo file",noPermissionGenerateThumbnail:"Non hai il permesso di generare miniature",noPermissionDeleteFile:"Non hai il permesso di eliminare questo file",noPermissionCreateFolder:"Non hai il permesso di creare cartelle",noPermissionUpload:"Non hai il permesso di caricare file",noPermissionMoveFiles:"Non hai il permesso di spostare file",noPermissionDeleteFiles:"Non hai il permesso di eliminare file",toast:{folderCreated:"Cartella creata",folderDeleted:"Cartella eliminata",fileDeleted:"File eliminato",filesDeleted:"Eliminati {{count}} file",filesMoved:"File spostati",folderLinked:"Cartella collegata",folderUnlinked:"Cartella scollegata",addedToQueue:"Aggiunti {{count}} file alla coda",addedToQueuePartial:"Aggiunti {{added}} file, {{failed}} falliti",failedToAddToQueue:"Aggiunta file fallita: {{error}}",fileRenamed:"File rinominato",folderRenamed:"Cartella rinominata",thumbnailsGenerated:"Generate {{count}} miniature",thumbnailsGeneratedPartial:"Generate {{succeeded}} miniature, {{failed}} fallite",noStlMissingThumbnails:"Nessun file STL senza miniature",failedToGenerateThumbnails:"Generazione miniature fallita: {{error}}",thumbnailGenerated:"Miniatura generata",failedToGenerateThumbnail:"Generazione miniatura fallita: {{error}}"}},projects:{title:"Progetti",subtitle:"Organizza e traccia i tuoi progetti di stampa 3D",newProject:"Nuovo progetto",editProject:"Modifica progetto",deleteProject:"Elimina progetto",projectName:"Nome progetto",description:"Descrizione",noProjects:"Nessun progetto ancora",noProjectsFiltered:"Nessun progetto {{status}}",noProjectsFilteredHelp:"Non hai progetti {{status}}. I progetti appariranno qui quando il loro stato cambia.",createFirst:"Crea il tuo primo progetto per organizzare stampe correlate, tracciare progressi e gestire i tuoi build.",createFirstButton:"Crea il tuo primo progetto",create:"Crea",files:"File",prints:"Stampe",plates:"piatti",parts:"parti",lastModified:"Ultima modifica",deleteConfirm:"Sei sicuro di voler eliminare questo progetto? Archivi e elementi in coda saranno scollegati ma non eliminati.",addFiles:"Aggiungi file",removeFile:"Rimuovi file",viewDetails:"Vedi dettagli",namePlaceholder:"es., Build Voron 2.4",descriptionPlaceholder:"Descrizione opzionale...",color:"Colore",targetPlates:"Piatti target",targetPlatesPlaceholder:"es., 25",targetPlatesHelp:"Numero di job di stampa",targetParts:"Parti target",targetPartsPlaceholder:"es., 150",targetPartsHelp:"Totale oggetti necessari",tagsLabel:"Tag (separati da virgola)",tagsPlaceholder:"es., voron, funzionale, regalo",dueDate:"Data scadenza",priority:"Priorita",priorityLow:"Bassa",priorityNormal:"Normale",priorityHigh:"Alta",priorityUrgent:"Urgente",statusActive:"Attivo",statusCompleted:"Completato",statusArchived:"Archiviato",done:"Fatto",completed:"completato",failed:"fallito",inQueue:"in coda",noPrintsYet:"Nessuna stampa ancora",printJobs:"Job di stampa (piatti)",partsPrinted:"Parti stampate",failedParts:"Parti fallite",import:"Importa",export:"Esporta",importProject:"Importa progetto",exportAll:"Esporta tutti i progetti",loading:"Caricamento progetti...",noEditPermission:"Non hai il permesso di modificare progetti",noDeletePermission:"Non hai il permesso di eliminare progetti",noCreatePermission:"Non hai il permesso di creare progetti",noImportPermission:"Non hai il permesso di importare progetti",noExportPermission:"Non hai il permesso di esportare progetti",toast:{created:"Progetto creato",updated:"Progetto aggiornato",deleted:"Progetto eliminato",imported:"Progetto importato",multipleImported:"{{count}} progetti importati",importFailed:"Import fallito",exported:"Progetti esportati (solo metadati)"}},projectDetail:{notFound:"Progetto non trovato",backToProjects:"Torna a Progetti",export:"Esporta",exportProject:"Esporta progetto",noExportPermission:"Non hai il permesso di esportare progetti",noEditPermission:"Non hai il permesso di modificare progetti",partOf:"Parte di:",priorityLabel:"Priorita:",noPrints:"Nessuna stampa in questo progetto ancora",status:{active:"Attivo",completed:"Completato",archived:"Archiviato"},priority:{low:"Bassa",normal:"Normale",high:"Alta",urgent:"Urgente"},dueDate:{overdue:"Scaduto",today:"Scade oggi",daysLeft:"{{count}} giorni rimanenti"},progress:{platesProgress:"Avanzamento piatti",partsProgress:"Avanzamento parti",printJobs:"job di stampa",parts:"parti",percentComplete:"{{percent}}% completato",remaining:"{{count}} rimanenti"},stats:{printJobs:"Job di stampa",total:"totale",failed:"{{count}} falliti",partsPrinted:"{{count}} parti stampate",printTime:"Tempo di stampa",filamentUsed:"Filamento usato"},cost:{title:"Tracciamento costi",filamentCost:"Costo filamento",energy:"Energia",budget:"Budget",remaining:"Rimanente"},subProjects:{title:"Sotto-progetti ({{count}})"},notes:{title:"Note",noEditPermission:"Non hai il permesso di modificare le note",placeholder:"Aggiungi note su questo progetto...",empty:"Nessuna nota ancora. Clicca Modifica per aggiungere note."},files:{title:"File",linkFolders:"Collega cartelle dal Gestore file",forQuickAccess:"a questo progetto per accesso rapido.",fileCount:"{{count}} file",empty:"Nessuna cartella collegata. Vai a Gestore file e collega una cartella a questo progetto."},bom:{title:"Distinta materiali",acquired:"{{completed}}/{{total}} acquisiti",showAll:"Mostra tutti",hideDone:"Nascondi completati",addPart:"Aggiungi parte",noAddPermission:"Non hai il permesso di aggiungere parti",partNamePlaceholder:"Nome parte (es., viti M3x8)",partName:"Nome parte",qty:"Qta",price:"Prezzo ({{currency}})",sourcingUrlPlaceholder:"URL fornitura (opzionale)",remarksPlaceholder:"Note (opzionale)",deletePart:"Elimina parte",deleteConfirm:'Sei sicuro di voler eliminare "{{name}}"?',noUpdatePermission:"Non hai il permesso di aggiornare parti",noEditPermission:"Non hai il permesso di modificare parti",noDeletePermission:"Non hai il permesso di eliminare parti",totalCost:"Costo totale:",empty:"Nessuna parte nella distinta materiali. Aggiungi hardware, elettronica o altri componenti da reperire."},timeline:{title:"Timeline attivita",empty:"Nessuna attivita ancora."},template:{saveAsTemplate:"Salva come template",noCreatePermission:"Non hai il permesso di creare template"},queue:{title:"Coda",viewAll:"Vedi tutto",printing:"{{count}} in stampa",queued:"{{count}} in coda"},prints:{title:"Stampe ({{count}})"},toast:{projectUpdated:"Progetto aggiornato",partAdded:"Parte aggiunta",partRemoved:"Parte rimossa",exportFailed:"Export fallito",projectExported:"Progetto esportato",templateCreated:"Template creato"}},system:{title:"Informazioni sistema",version:"Versione",uptime:"Tempo attivo",cpuUsage:"Uso CPU",memoryUsage:"Uso memoria",diskUsage:"Uso disco",networkInfo:"Info rete",logs:"Log",debugMode:"Modalita debug",enableDebug:"Abilita log debug",disableDebug:"Disabilita log debug",downloadLogs:"Scarica log",clearLogs:"Cancella log",dockerInfo:"Info Docker",containerName:"Nome container",imageName:"Nome immagine",platform:"Piattaforma",architecture:"Architettura"},library:{title:"Libreria filamenti",addFilament:"Aggiungi filamento",editFilament:"Modifica filamento",deleteFilament:"Elimina filamento",vendor:"Produttore",material:"Materiale",color:"Colore",kFactor:"K Factor",temperature:"Temperatura",noFilaments:"Nessun filamento in libreria",deleteConfirm:"Sei sicuro di voler eliminare questo filamento?",importFromPrinter:"Importa da stampante",exportToFile:"Esporta su file"},spoolman:{title:"Integrazione Spoolman",enabled:"Spoolman abilitato",url:"URL Spoolman",connected:"Connesso",disconnected:"Non connesso",testConnection:"Testa connessione",sync:"Sincronizza",syncing:"Sincronizzazione...",lastSync:"Ultima sincronizzazione",linkToSpoolman:"Collega a Spoolman",openInSpoolman:"Apri in Spoolman",unlinkSpool:"Scollega bobina",selectSpool:"Seleziona bobina",noUnlinkedSpools:"Nessuna bobina scollegata disponibile",linkSuccess:"Bobina collegata a Spoolman con successo",linkFailed:"Collegamento bobina fallito",spoolId:"ID bobina",fillSourceLabel:"(Spoolman)",weight:"Peso",remaining:"Rimanente",disableWeightSync:"Disabilita sync peso stimato AMS",disableWeightSyncDesc:"Non aggiornare la capacità rimanente dalle stime AMS. Usalo se preferisci il tracciamento di Spoolman rispetto alle stime AMS. Le nuove bobine useranno comunque la stima AMS come peso iniziale.",reportPartialUsage:"Segnala uso parziale per stampe fallite",reportPartialUsageDesc:"Quando una stampa fallisce o viene annullata, segnala il filamento stimato usato fino a quel punto in base all'avanzamento layer."},timelapse:{title:"Timelapse",create:"Crea timelapse",download:"Scarica",delete:"Elimina",preview:"Anteprima",frameRate:"Frame rate",quality:"Qualità",processing:"Elaborazione...",noTimelapses:"Nessun timelapse disponibile"},ams:{title:"AMS",slot:"Slot",empty:"Vuoto",emptySlot:"Slot vuoto",unknown:"Sconosciuto",humidity:"Umidità",temperature:"Temperatura",filamentType:"Tipo filamento",filamentColor:"Colore",remaining:"Rimanente",history:"Cronologia AMS",noHistory:"Nessuna cronologia disponibile",configureSlot:"Configura slot",externalSpool:"Bobina esterna",profile:"Profilo",kFactor:"K Factor",fill:"Riempi",configure:"Configura"},printModal:{title:"Avvia stampa",selectPrinter:"Seleziona stampante",selectPlate:"Seleziona piatto",filamentMapping:"Mappatura filamento",printSettings:"Impostazioni stampa",bedLeveling:"Livellamento piatto",flowCalibration:"Calibrazione flusso",vibrationCalibration:"Calibrazione vibrazioni",layerInspection:"Ispezione primo layer",timelapse:"Timelapse",startPrint:"Avvia stampa",addToQueue:"Aggiungi alla coda",cancel:"Annulla",noPrintersAvailable:"Nessuna stampante disponibile",printerBusy:"Stampante occupata",printerOffline:"Stampante offline"},backup:{title:"Backup e ripristino",createBackup:"Crea backup",restoreBackup:"Ripristina backup",restoreDescription:"Sostituisci tutti i dati da un file di backup",downloadBackup:"Scarica backup",uploadBackup:"Carica backup",lastBackup:"Ultimo backup",autoBackup:"Backup automatico",backupNow:"Esegui backup ora",restoreWarning:"Avviso: il ripristino sovrascriverà tutti i dati attuali.",includeArchives:"Includi archivi",includeSettings:"Includi impostazioni",includeProfiles:"Includi profili",backupSuccess:"Backup creato con successo",restoreSuccess:"Backup ripristinato con successo",backupFailed:"Backup fallito",restoreFailed:"Ripristino fallito",restoreNote:"La stampante virtuale verrà fermata durante il ripristino"},tags:{title:"Tag",addTag:"Aggiungi tag",editTag:"Modifica tag",deleteTag:"Elimina tag",tagName:"Nome tag",tagColor:"Colore tag",noTags:"Nessun tag",deleteConfirm:"Sei sicuro di voler eliminare questo tag?",manageTags:"Gestisci tag"},uploadModal:{title:"Carica file 3MF",dragDrop:"Trascina e rilascia file .3mf qui",or:"o",browseFiles:"Sfoglia file",extractionInfo:"Il modello stampante sarà estratto automaticamente dai metadati del file 3MF.",uploaded:"caricati",failed:"falliti",uploading:"Caricamento...",upload:"Carica",uploadFailed:"Caricamento fallito"},editArchive:{title:"Modifica archivio",name:"Nome",namePlaceholder:"Nome stampa",printer:"Stampante",noPrinter:"Nessuna stampante",project:"Progetto",noProject:"Nessun progetto",itemsPrinted:"Elementi stampati",itemsPrintedHelp:"Numero di elementi prodotti in questo job di stampa",notes:"Note",notesPlaceholder:"Aggiungi note su questa stampa...",externalLink:"Link esterno",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link a Printables, Thingiverse o altra fonte",tags:"Tag",tagsPlaceholder:"Aggiungi tag...",addMoreTags:"Aggiungi altri tag...",matchingTags:'Tag corrispondenti "{{query}}"',existingTags:"Tag esistenti",clickToAdd:"(clicca per aggiungere)",status:"Stato",failureReason:"Motivo fallimento",selectReason:"Seleziona motivo...",photos:"Foto del risultato stampato",photosHelp:"Clicca + per aggiungere foto del risultato stampato",printResult:"Risultato stampa",saving:"Salvataggio...",failureReasons:{adhesionFailure:"Fallimento adesione",spaghettiDetached:"Spaghetti / staccato",layerShift:"Spostamento layer",cloggedNozzle:"Ugello intasato",filamentRunout:"Filamento esaurito",warping:"Warping",stringing:"Stringing",underExtrusion:"Sotto-estrusione",powerFailure:"Mancanza corrente",userCancelled:"Annullato dall'utente",other:"Altro"},statuses:{completed:"Completato",failed:"Fallito",aborted:"Annullato",printing:"In stampa"}},kProfiles:{title:"K-Profiles",noPrintersConfigured:"Nessuna stampante configurata",addPrinterInSettings:"Aggiungi una stampante in Impostazioni per gestire i K-profiles",noActivePrinters:"Nessuna stampante attiva",enablePrinterConnection:"Abilita una connessione stampante per vedere i K-profiles",loadingProfiles:"Caricamento K-Profiles...",printerOffline:"Stampante offline",printerOfflineDesc:"La stampante selezionata non e connessa. Accendila per vedere i K-profiles.",noMatchingProfiles:"Nessun profilo corrispondente",noMatchingProfilesDesc:"Nessun profilo corrisponde ai criteri di ricerca",noKProfiles:"Nessun K-Profile",noKProfilesDesc:"Nessun profilo pressure advance per ugello da {{diameter}}mm",createFirstProfile:"Crea primo profilo",printer:"Stampante",nozzle:"Ugello",refresh:"Aggiorna",addProfile:"Aggiungi profilo",export:"Esporta",import:"Importa",select:"Seleziona",selectAll:"Seleziona tutto",delete:"Elimina",searchPlaceholder:"Cerca per nome o filamento...",allExtruders:"Tutti gli estrusori",leftOnly:"Solo sinistro",rightOnly:"Solo destro",allFlow:"Tutto flow",hfOnly:"Solo HF",sOnly:"Solo S",sortName:"Ordina: Nome",sortKValue:"Ordina: K-Value",sortFilament:"Ordina: Filamento",leftExtruder:"Estrusore sinistro",rightExtruder:"Estrusore destro",modal:{addTitle:"Aggiungi K-Profile",editTitle:"Modifica K-Profile",profileName:"Nome profilo",profileNamePlaceholder:"Il mio profilo PLA",kValue:"K-Value",kValuePlaceholder:"0.020",kValueHelp:"Intervallo tipico: 0.01 - 0.06 per PLA, 0.02 - 0.10 per PETG",filament:"Filamento",selectFilament:"Seleziona filamento...",noFilamentsHelp:"Nessun filamento trovato. Crea prima un K-profile in Bambu Studio.",flowType:"Tipo flow",highFlow:"High Flow",standard:"Standard",nozzleSize:"Dimensione ugello",extruder:"Estrusore",extruders:"Estrusori",left:"Sinistra",right:"Destra",notes:"Note (salvate localmente)",notesPlaceholder:"Aggiungi note su questo profilo...",notesHelp:"Le note sono salvate in Bambuddy, non sulla stampante",syncing:"Sincronizzazione con stampante...",savingExtruder:"Salvataggio su estrusore {{current}}/{{total}}...",pleaseWait:"Attendere"},deleteConfirm:{title:"Elimina profilo",cannotUndo:"Questo non può essere annullato",message:'Sei sicuro di voler eliminare "{{name}}" dalla stampante?'},bulkDelete:{title:"Elimina profili",cannotUndo:"Questo non può essere annullato",message:"Sei sicuro di voler eliminare {{count}} profili selezionati dalla stampante?"},toast:{profileSaved:"K-profile salvato",profilesSaved:"K-profile salvato su {{count}} estrusori",selectAtLeastOneExtruder:"Seleziona almeno un estrusore",profileDeleted:"K-profile eliminato",profilesDeleted:"Eliminati {{count}} profili",exportedProfiles:"Esportati {{count}} profili",importedProfiles:"Importati {{count}} di {{total}} profili",noProfilesToExport:"Nessun profilo da esportare",invalidFileFormat:"Formato file non valido",failedToParseImport:"Parsing file import fallito",failedToSaveBatch:"Salvataggio K-profiles fallito",noteSaved:"Nota salvata",failedToSaveNote:"Salvataggio nota fallito"},permission:{noRead:"Non hai il permesso di aggiornare i profili",noCreate:"Non hai il permesso di aggiungere profili",noUpdate:"Non hai il permesso di aggiornare K-profiles",noDelete:"Non hai il permesso di eliminare K-profiles",noExport:"Non hai il permesso di esportare profili",noImport:"Non hai il permesso di importare profili"}},virtualPrinter:{title:"Stampante virtuale",running:"In esecuzione",stopped:"Ferma",description:{default:"Abilita una stampante virtuale che appare in Bambu Studio e OrcaSlicer. I file inviati a questa stampante saranno archiviati senza stampare.",proxy:"Abilita un proxy che inoltra il traffico slicer a una stampante reale, permettendo la stampa remota su qualsiasi rete."},enable:{title:"Abilita stampante virtuale",visibleInSlicer:'Visibile come "Bambuddy" nella ricerca slicer',proxyingTo:"In proxy verso {{name}}",notActive:"Non attivo"},model:{title:"Modello stampante",description:"Seleziona il modello stampante da emulare.",restartWarning:"Cambiare il modello riavviera la stampante virtuale"},accessCode:{title:"Codice accesso",isSet:"Codice accesso impostato",notSet:"Nessun codice accesso impostato - richiesto per abilitare",placeholder:"Inserisci codice 8 caratteri",placeholderChange:"Inserisci nuovo codice per cambiare",hint:"Deve essere esattamente 8 caratteri. Usato dagli slicer per autenticarsi.",charCount:"({{count}}/8)"},targetPrinter:{title:"Stampante target",configured:"Target proxy configurato",notConfigured:"Nessuna stampante target selezionata - richiesta per modalita proxy",placeholder:"Seleziona una stampante...",hint:"Seleziona la stampante a cui fare proxy. La stampante deve essere in modalita LAN.",noPrinters:"Nessuna stampante configurata. Aggiungi una stampante per usare la modalita proxy."},remoteInterface:{title:"Sovrascrittura interfaccia di rete",configured:"Sovrascrittura interfaccia attiva",optional:"Opzionale - usare se l'IP rilevato automaticamente e sbagliato (es. piu NIC, Docker, VPN)",placeholder:"Rilevamento automatico (predefinito)...",hint:"Sovrascrive l'indirizzo IP pubblicizzato via SSDP e usato nel certificato TLS. Utile quando Bambuddy ha piu interfacce di rete."},mode:{title:"Modalita",archive:"Archivio",archiveDesc:"Archivia subito i file",review:"Revisione",reviewDesc:"Rivedi prima di archiviare",queue:"Coda",queueDesc:"Archivia e aggiungi alla coda",proxy:"Proxy",proxyDesc:"Inoltra a stampante reale"},setupRequired:{title:"Configurazione necessaria",description:"La stampante virtuale richiede configurazioni di sistema aggiuntive prima di funzionare. Include port forwarding, regole firewall e impostazioni specifiche della piattaforma.",readGuide:"Leggi la guida prima di abilitare"},howItWorks:{title:"Come funziona",titleProxy:"Come funziona (Modalita proxy)",step1:"Completa la guida di configurazione per la tua piattaforma",step2:"Abilita la stampante virtuale e imposta un codice accesso",step3:'In Bambu Studio o OrcaSlicer, vai su "Aggiungi stampante"',step4:'La stampante "Bambuddy" dovrebbe apparire nella lista',step5:"Connettiti usando il codice accesso impostato",step6:'Quando "stampi" su Bambuddy, il file 3MF viene archiviato',proxyStep1:"Seleziona la stampante target (deve essere in modalita LAN)",proxyStep2:"Per rete diversa: seleziona l'interfaccia rete slicer",proxyStep3:"Abilita il proxy - la stampante appare via SSDP",proxyStep4:"Connettiti usando il codice accesso della stampante",proxyStep5:"Stampa normalmente - il traffico è inoltrato via Bambuddy",proxyStep6:"Lo streaming della camera richiede NAT/IP forwarding (vedi docs)"},status:{title:"Dettagli stato",printerName:"Nome stampante",model:"Modello",serialNumber:"Numero seriale",mode:"Modalita",pendingFiles:"File in sospeso",targetPrinter:"Stampante target",ftpPort:"Porta FTP",mqttPort:"Porta MQTT",ftpConnections:"Connessioni FTP",mqttConnections:"Connessioni MQTT"},toast:{updated:"Impostazioni stampante virtuale aggiornate",failedToUpdate:"Aggiornamento impostazioni fallito",accessCodeRequired:"Imposta prima un codice accesso",targetPrinterRequired:"Seleziona prima una stampante target",accessCodeEmpty:"Il codice accesso non può essere vuoto",accessCodeLength:"Il codice accesso deve essere esattamente 8 caratteri"}},modelViewer:{openInSlicer:"Apri nello slicer",tabs:{model:"Modello 3D",gcode:"Anteprima G-code"},notAvailable:"non disponibile",notSliced:"non sezionato",plates:"Piatti",allPlates:"Tutti i piatti",plateNumber:"Piatto {{number}}",plateCount:"{{count}} piatto",plateCount_other:"{{count}} piatti",objectCount:"{{count}} oggetto",objectCount_other:"{{count}} oggetti",filamentCount:"{{count}} filamento",filamentCount_other:"{{count}} filamenti",eta:"ETA {{minutes}} min",noPreview:"Nessuna anteprima disponibile per questo file",pagination:{pageOf:"Pagina {{current}} di {{total}}",prev:"Prec",next:"Succ"},errors:{failedToLoad:"Caricamento file fallito",noMeshes:"Nessuna mesh trovata nel file 3MF",unsupportedFormat:"Formato file non supportato"}},maintenanceDescriptions:{lubricateRails:"Applica lubrificante alle guide lineari per un movimento fluido",cleanNozzle:"Pulisci hotend e ugello per prevenire intasamenti",checkBelts:"Verifica tensione cinghie per stampe accurate",cleanBuildPlate:"Pulisci il piatto per migliorare l'adesione",checkExtruder:"Ispeziona ingranaggi estrusore per usura",checkCooling:"Assicurati che le ventole di raffreddamento funzionino",generalInspection:"Ispezione generale stampante",cleanCarbonRods:"Pulisci le aste in carbonio per ridurre attrito",checkPtfeTube:"Ispeziona il tubo PTFE per usura o danni",replaceHepaFilter:"Sostituisci filtro HEPA per qualità aria",replaceCarbonFilter:"Sostituisci filtro a carbone attivo",lubricateLeftNozzleRail:"Lubrifica guida ugello sinistro (serie H2)"}},foe={en:{translation:coe},de:{translation:uoe},ja:{translation:doe},it:{translation:hoe}};Cs.use(Z9).use(Bse).init({resources:foe,fallbackLng:"en",supportedLngs:["en","de","ja","it"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const OU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"},{code:"ja",name:"Japanese",nativeName:"日本語"},{code:"it",name:"Italian",nativeName:"Italiano"}];var LU="popstate";function moe(t={}){function e(r,i){let{pathname:s,search:o,hash:l}=r.location;return bj("",{pathname:s,search:o,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:W0(i)}return goe(e,n,null,t)}function ai(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Eo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function poe(){return Math.random().toString(36).substring(2,10)}function FU(t,e){return{usr:t.state,key:t.key,idx:e}}function bj(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Nb(e):e,state:n,key:e&&e.key||r||poe()}}function W0({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 Nb(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 goe(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,o=i.history,l="POP",c=null,u=d();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function d(){return(o.state||{idx:null}).idx}function h(){l="POP";let x=d(),v=x==null?null:x-u;u=x,c&&c({action:l,location:y.location,delta:v})}function p(x,v){l="PUSH";let S=bj(y.location,x,v);u=d()+1;let N=FU(S,u),T=y.createHref(S);try{o.pushState(N,"",T)}catch(M){if(M instanceof DOMException&&M.name==="DataCloneError")throw M;i.location.assign(T)}s&&c&&c({action:l,location:y.location,delta:1})}function m(x,v){l="REPLACE";let S=bj(y.location,x,v);u=d();let N=FU(S,u),T=y.createHref(S);o.replaceState(N,"",T),s&&c&&c({action:l,location:y.location,delta:0})}function b(x){return boe(x)}let y={get action(){return l},get location(){return t(i,o)},listen(x){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(LU,h),c=x,()=>{i.removeEventListener(LU,h),c=null}},createHref(x){return e(i,x)},createURL:b,encodeLocation(x){let v=b(x);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:p,replace:m,go(x){return o.go(x)}};return y}function boe(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ai(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:W0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function J9(t,e,n="/"){return xoe(t,e,n,!1)}function xoe(t,e,n,r){let i=typeof e=="string"?Nb(e):e,s=Bu(i.pathname||"/",n);if(s==null)return null;let o=eW(t);yoe(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Coe(s);l=Toe(o[c],u,r)}return l}function eW(t,e=[],n=[],r="",i=!1){let s=(o,l,c=i,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;ai(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 h=Pu([r,d.relativePath]),p=n.concat(d);o.children&&o.children.length>0&&(ai(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),eW(o.children,e,p,h,c)),!(o.path==null&&!o.index)&&e.push({path:h,score:Moe(h,o.index),routesMeta:p})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))s(o,l);else for(let c of tW(o.path))s(o,l,!0,c)}),e}function tW(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let o=tW(r.join("/")),l=[];return l.push(...o.map(c=>c===""?s:[s,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function yoe(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Eoe(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var voe=/^:[\w-]+$/,woe=3,_oe=2,Soe=1,Noe=10,koe=-2,IU=t=>t==="*";function Moe(t,e){let n=t.split("/"),r=n.length;return n.some(IU)&&(r+=koe),e&&(r+=_oe),n.filter(i=>!IU(i)).reduce((i,s)=>i+(voe.test(s)?woe:s===""?Soe:Noe),r)}function Eoe(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 Toe(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=s==="/"?e:e.slice(s.length)||"/",h=rS({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!h&&u&&n&&!r[r.length-1].route.index&&(h=rS({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(i,h.params),o.push({params:i,pathname:Pu([s,h.pathname]),pathnameBase:Roe(Pu([s,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(s=Pu([s,h.pathnameBase]))}return o}function rS(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Aoe(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let s=i[0],o=s.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:h},p)=>{if(d==="*"){let b=l[p]||"";o=s.slice(0,s.length-b.length).replace(/(.)\/+$/,"$1")}const m=l[p];return h&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:o,pattern:t}}function Aoe(t,e=!1,n=!0){Eo(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 Coe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Eo(!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 Bu(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 nW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Poe=t=>nW.test(t);function joe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Nb(t):t,s;if(n)if(Poe(n))s=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Eo(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?s=zU(n.substring(1),"/"):s=zU(n,e)}else s=e;return{pathname:s,search:Ooe(r),hash:Loe(i)}}function zU(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 fT(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 Doe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function jR(t){let e=Doe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function DR(t,e,n,r=!1){let i;typeof t=="string"?i=Nb(t):(i={...t},ai(!i.pathname||!i.pathname.includes("?"),fT("?","pathname","search",i)),ai(!i.pathname||!i.pathname.includes("#"),fT("#","pathname","hash",i)),ai(!i.search||!i.search.includes("#"),fT("#","search","hash",i)));let s=t===""||i.pathname==="",o=s?"/":i.pathname,l;if(o==null)l=n;else{let h=e.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),h-=1;i.pathname=p.join("/")}l=h>=0?e[h]:"/"}let c=joe(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Pu=t=>t.join("/").replace(/\/\/+/g,"/"),Roe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Ooe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Loe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Foe=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 Ioe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function zoe(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var rW=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function iW(t,e){let n=t;if(typeof n!="string"||!nW.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(rW)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=Bu(o.pathname,e);o.origin===s.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{Eo(!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 aW=["POST","PUT","PATCH","DELETE"];new Set(aW);var Uoe=["GET",...aW];new Set(Uoe);var kb=_.createContext(null);kb.displayName="DataRouter";var bk=_.createContext(null);bk.displayName="DataRouterState";var Boe=_.createContext(!1),sW=_.createContext({isTransitioning:!1});sW.displayName="ViewTransition";var Hoe=_.createContext(new Map);Hoe.displayName="Fetchers";var $oe=_.createContext(null);$oe.displayName="Await";var Po=_.createContext(null);Po.displayName="Navigation";var By=_.createContext(null);By.displayName="Location";var bl=_.createContext({outlet:null,matches:[],isDataRoute:!1});bl.displayName="Route";var RR=_.createContext(null);RR.displayName="RouteError";var oW="REACT_ROUTER_ERROR",Voe="REDIRECT",Goe="ROUTE_ERROR_RESPONSE";function qoe(t){if(t.startsWith(`${oW}:${Voe}:{`))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(`${oW}:${Goe}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new Foe(e.status,e.statusText,e.data)}catch{}}function Koe(t,{relative:e}={}){ai(Mb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=_.useContext(Po),{hash:i,pathname:s,search:o}=Hy(t,{relative:e}),l=s;return n!=="/"&&(l=s==="/"?n:Pu([n,s])),r.createHref({pathname:l,search:o,hash:i})}function Mb(){return _.useContext(By)!=null}function Cc(){return ai(Mb(),"useLocation() may be used only in the context of a <Router> component."),_.useContext(By).location}var lW="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function cW(t){_.useContext(Po).static||_.useLayoutEffect(t)}function Pc(){let{isDataRoute:t}=_.useContext(bl);return t?cle():Xoe()}function Xoe(){ai(Mb(),"useNavigate() may be used only in the context of a <Router> component.");let t=_.useContext(kb),{basename:e,navigator:n}=_.useContext(Po),{matches:r}=_.useContext(bl),{pathname:i}=Cc(),s=JSON.stringify(jR(r)),o=_.useRef(!1);return cW(()=>{o.current=!0}),_.useCallback((c,u={})=>{if(Eo(o.current,lW),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=DR(c,JSON.parse(s),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Pu([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,s,i,t])}var Yoe=_.createContext(null);function Qoe(t){let e=_.useContext(bl).outlet;return _.useMemo(()=>e&&_.createElement(Yoe.Provider,{value:t},e),[e,t])}function xk(){let{matches:t}=_.useContext(bl),e=t[t.length-1];return e?e.params:{}}function Hy(t,{relative:e}={}){let{matches:n}=_.useContext(bl),{pathname:r}=Cc(),i=JSON.stringify(jR(n));return _.useMemo(()=>DR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Zoe(t,e){return uW(t,e)}function uW(t,e,n,r,i){ai(Mb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=_.useContext(Po),{matches:o}=_.useContext(bl),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",h=l&&l.route;{let S=h&&h.path||"";hW(u,!h||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.
- Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let p=Cc(),m;if(e){let S=typeof e=="string"?Nb(e):e;ai(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 b=m.pathname||"/",y=b;if(d!=="/"){let S=d.replace(/^\//,"").split("/");y="/"+b.replace(/^\//,"").split("/").slice(S.length).join("/")}let x=J9(t,{pathname:y});Eo(h||x!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Eo(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.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=rle(x&&x.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:Pu([d,s.encodeLocation?s.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:Pu([d,s.encodeLocation?s.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&v?_.createElement(By.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},v):v}function Joe(){let t=lle(),e=Ioe(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=_.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:s},"ErrorBoundary")," or"," ",_.createElement("code",{style:s},"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 ele=_.createElement(Joe,null),dW=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(bl.Provider,{value:this.props.routeContext},_.createElement(RR.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?_.createElement(tle,{error:t},e):e}};dW.contextType=Boe;var mT=new WeakMap;function tle({children:t,error:e}){let{basename:n}=_.useContext(Po);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=qoe(e.digest);if(r){let i=mT.get(e);if(i)throw i;let s=iW(r.location,n);if(rW&&!mT.get(e))if(s.isExternal||r.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:r.replace}));throw mT.set(e,o),o}return _.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return t}function nle({routeContext:t,match:e,children:n}){let r=_.useContext(kb);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),_.createElement(bl.Provider,{value:t},n)}function rle(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let s=t,o=n?.errors;if(o!=null){let d=s.findIndex(h=>h.route.id&&o?.[h.route.id]!==void 0);ai(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),s=s.slice(0,Math.min(s.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<s.length;d++){let h=s[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(c=d),h.route.id){let{loaderData:p,errors:m}=n,b=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!m||m[h.route.id]===void 0);if(h.route.lazy||b){l=!0,c>=0?s=s.slice(0,c+1):s=[s[0]];break}}}let u=n&&r?(d,h)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:zoe(n.matches),errorInfo:h})}:void 0;return s.reduceRight((d,h,p)=>{let m,b=!1,y=null,x=null;n&&(m=o&&h.route.id?o[h.route.id]:void 0,y=h.route.errorElement||ele,l&&(c<0&&p===0?(hW("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,x=null):c===p&&(b=!0,x=h.route.hydrateFallbackElement||null)));let v=e.concat(s.slice(0,p+1)),S=()=>{let N;return m?N=y:b?N=x:h.route.Component?N=_.createElement(h.route.Component,null):h.route.element?N=h.route.element:N=d,_.createElement(nle,{match:h,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:N})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?_.createElement(dW,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:S(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):S()},null)}function OR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ile(t){let e=_.useContext(kb);return ai(e,OR(t)),e}function ale(t){let e=_.useContext(bk);return ai(e,OR(t)),e}function sle(t){let e=_.useContext(bl);return ai(e,OR(t)),e}function LR(t){let e=sle(t),n=e.matches[e.matches.length-1];return ai(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function ole(){return LR("useRouteId")}function lle(){let t=_.useContext(RR),e=ale("useRouteError"),n=LR("useRouteError");return t!==void 0?t:e.errors?.[n]}function cle(){let{router:t}=ile("useNavigate"),e=LR("useNavigate"),n=_.useRef(!1);return cW(()=>{n.current=!0}),_.useCallback(async(i,s={})=>{Eo(n.current,lW),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var UU={};function hW(t,e,n){!e&&!UU[t]&&(UU[t]=!0,Eo(!1,n))}_.memo(ule);function ule({routes:t,future:e,state:n,onError:r}){return uW(t,void 0,n,r,e)}function Gg({to:t,replace:e,state:n,relative:r}){ai(Mb(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=_.useContext(Po);Eo(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=_.useContext(bl),{pathname:o}=Cc(),l=Pc(),c=DR(t,jR(s),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 dle(t){return Qoe(t.context)}function Fi(t){ai(!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 hle({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1,unstable_useTransitions:o}){ai(!Mb(),"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:s,unstable_useTransitions:o,future:{}}),[l,i,s,o]);typeof n=="string"&&(n=Nb(n));let{pathname:u="/",search:d="",hash:h="",state:p=null,key:m="default"}=n,b=_.useMemo(()=>{let y=Bu(u,l);return y==null?null:{location:{pathname:y,search:d,hash:h,state:p,key:m},navigationType:r}},[l,u,d,h,p,m,r]);return Eo(b!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${h}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:_.createElement(Po.Provider,{value:c},_.createElement(By.Provider,{children:e,value:b}))}function fle({children:t,location:e}){return Zoe(xj(t),e)}function xj(t,e=[]){let n=[];return _.Children.forEach(t,(r,i)=>{if(!_.isValidElement(r))return;let s=[...e,i];if(r.type===_.Fragment){n.push.apply(n,xj(r.props.children,s));return}ai(r.type===Fi,`[${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>`),ai(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=xj(r.props.children,s)),n.push(o)}),n}var E1="get",T1="application/x-www-form-urlencoded";function yk(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function mle(t){return yk(t)&&t.tagName.toLowerCase()==="button"}function ple(t){return yk(t)&&t.tagName.toLowerCase()==="form"}function gle(t){return yk(t)&&t.tagName.toLowerCase()==="input"}function ble(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function xle(t,e){return t.button===0&&(!e||e==="_self")&&!ble(t)}function yj(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 yle(t,e){let n=yj(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(s=>{n.append(i,s)})}),n}var Vw=null;function vle(){if(Vw===null)try{new FormData(document.createElement("form"),0),Vw=!1}catch{Vw=!0}return Vw}var wle=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function pT(t){return t!=null&&!wle.has(t)?(Eo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${T1}"`),null):t}function _le(t,e){let n,r,i,s,o;if(ple(t)){let l=t.getAttribute("action");r=l?Bu(l,e):null,n=t.getAttribute("method")||E1,i=pT(t.getAttribute("enctype"))||T1,s=new FormData(t)}else if(mle(t)||gle(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?Bu(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||E1,i=pT(t.getAttribute("formenctype"))||pT(l.getAttribute("enctype"))||T1,s=new FormData(l,t),!vle()){let{name:u,type:d,value:h}=t;if(d==="image"){let p=u?`${u}.`:"";s.append(`${p}x`,"0"),s.append(`${p}y`,"0")}else u&&s.append(u,h)}}else{if(yk(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=E1,r=null,i=T1,o=t}return s&&i==="text/plain"&&(o=s,s=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:s,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function FR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Sle(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&&Bu(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function Nle(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 kle(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 Mle(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let o=await Nle(s,n);return o.links?o.links():[]}return[]}));return Cle(r.flat(1).filter(kle).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function BU(t,e,n,r,i,s){let o=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return s==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):s==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let h=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 h=="boolean")return h}return!0}):[]}function Ele(t,e,{includeHydrateFallback:n}={}){return Tle(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let s=[i.module];return i.clientActionModule&&(s=s.concat(i.clientActionModule)),i.clientLoaderModule&&(s=s.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(s=s.concat(i.hydrateFallbackModule)),i.imports&&(s=s.concat(i.imports)),s}).flat(1))}function Tle(t){return[...new Set(t)]}function Ale(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Cle(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(Ale(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function fW(){let t=_.useContext(kb);return FR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Ple(){let t=_.useContext(bk);return FR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var IR=_.createContext(void 0);IR.displayName="FrameworkContext";function mW(){let t=_.useContext(IR);return FR(t,"You must render this element inside a <HydratedRouter> element"),t}function jle(t,e){let n=_.useContext(IR),[r,i]=_.useState(!1),[s,o]=_.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:h}=e,p=_.useRef(null);_.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let y=v=>{v.forEach(S=>{o(S.isIntersecting)})},x=new IntersectionObserver(y,{threshold:.5});return p.current&&x.observe(p.current),()=>{x.disconnect()}}},[t]),_.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let m=()=>{i(!0)},b=()=>{i(!1),o(!1)};return n?t!=="intent"?[s,p,{}]:[s,p,{onFocus:Lx(l,m),onBlur:Lx(c,b),onMouseEnter:Lx(u,m),onMouseLeave:Lx(d,b),onTouchStart:Lx(h,m)}]:[!1,p,{}]}function Lx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Dle({page:t,...e}){let{router:n}=fW(),r=_.useMemo(()=>J9(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?_.createElement(Ole,{page:t,matches:r,...e}):null}function Rle(t){let{manifest:e,routeModules:n}=mW(),[r,i]=_.useState([]);return _.useEffect(()=>{let s=!1;return Mle(t,e,n).then(o=>{s||i(o)}),()=>{s=!0}},[t,e,n]),r}function Ole({page:t,matches:e,...n}){let r=Cc(),{future:i,manifest:s,routeModules:o}=mW(),{basename:l}=fW(),{loaderData:c,matches:u}=Ple(),d=_.useMemo(()=>BU(t,e,u,s,r,"data"),[t,e,u,s,r]),h=_.useMemo(()=>BU(t,e,u,s,r,"assets"),[t,e,u,s,r]),p=_.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let y=new Set,x=!1;if(e.forEach(S=>{let N=s.routes[S.route.id];!N||!N.hasLoader||(!d.some(T=>T.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||N.hasClientLoader?x=!0:y.add(S.route.id))}),y.size===0)return[];let v=Sle(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return x&&y.size>0&&v.searchParams.set("_routes",e.filter(S=>y.has(S.route.id)).map(S=>S.route.id).join(",")),[v.pathname+v.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,s,d,e,t,o]),m=_.useMemo(()=>Ele(h,s),[h,s]),b=Rle(h);return _.createElement(_.Fragment,null,p.map(y=>_.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),m.map(y=>_.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),b.map(({key:y,link:x})=>_.createElement("link",{key:y,nonce:n.nonce,...x})))}function Lle(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var Fle=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Fle&&(window.__reactRouterVersion="7.12.0")}catch{}function Ile({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=_.useRef();i.current==null&&(i.current=moe({window:r,v5Compat:!0}));let s=i.current,[o,l]=_.useState({action:s.action,location:s.location}),c=_.useCallback(u=>{n===!1?l(u):_.startTransition(()=>l(u))},[n]);return _.useLayoutEffect(()=>s.listen(c),[s,c]),_.createElement(hle,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:s,unstable_useTransitions:n})}var pW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Us=_.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:p,...m},b){let{basename:y,unstable_useTransitions:x}=_.useContext(Po),v=typeof u=="string"&&pW.test(u),S=iW(u,y);u=S.to;let N=Koe(u,{relative:i}),[T,M,A]=jle(r,m),k=Ble(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:h,unstable_defaultShouldRevalidate:p,unstable_useTransitions:x});function R(P){e&&e(P),P.defaultPrevented||k(P)}let C=_.createElement("a",{...m,...A,href:S.absoluteURL||N,onClick:S.isExternal||s?e:R,ref:Lle(b,M),target:c,"data-discover":!v&&n==="render"?"true":void 0});return T&&!v?_.createElement(_.Fragment,null,C,_.createElement(Dle,{page:N})):C});Us.displayName="Link";var l0=_.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:o,viewTransition:l,children:c,...u},d){let h=Hy(o,{relative:u.relative}),p=Cc(),m=_.useContext(bk),{navigator:b,basename:y}=_.useContext(Po),x=m!=null&&qle(h)&&l===!0,v=b.encodeLocation?b.encodeLocation(h).pathname:h.pathname,S=p.pathname,N=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(S=S.toLowerCase(),N=N?N.toLowerCase():null,v=v.toLowerCase()),N&&y&&(N=Bu(N,y)||N);const T=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let M=S===v||!i&&S.startsWith(v)&&S.charAt(T)==="/",A=N!=null&&(N===v||!i&&N.startsWith(v)&&N.charAt(v.length)==="/"),k={isActive:M,isPending:A,isTransitioning:x},R=M?e:void 0,C;typeof r=="function"?C=r(k):C=[r,M?"active":null,A?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let P=typeof s=="function"?s(k):s;return _.createElement(Us,{...u,"aria-current":R,className:C,ref:d,style:P,to:o,viewTransition:l},typeof c=="function"?c(k):c)});l0.displayName="NavLink";var zle=_.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:o=E1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:p,...m},b)=>{let{unstable_useTransitions:y}=_.useContext(Po),x=Vle(),v=Gle(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",N=typeof l=="string"&&pW.test(l),T=M=>{if(c&&c(M),M.defaultPrevented)return;M.preventDefault();let A=M.nativeEvent.submitter,k=A?.getAttribute("formmethod")||o,R=()=>x(A||M.currentTarget,{fetcherKey:e,method:k,navigate:n,replace:i,state:s,relative:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:p});y&&n!==!1?_.startTransition(()=>R()):R()};return _.createElement("form",{ref:b,method:S,action:v,onSubmit:r?c:T,...m,"data-discover":!N&&t==="render"?"true":void 0})});zle.displayName="Form";function Ule(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function gW(t){let e=_.useContext(kb);return ai(e,Ule(t)),e}function Ble(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=Pc(),d=Cc(),h=Hy(t,{relative:s});return _.useCallback(p=>{if(xle(p,e)){p.preventDefault();let m=n!==void 0?n:W0(d)===W0(h),b=()=>u(t,{replace:m,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l});c?_.startTransition(()=>b()):b()}},[d,u,h,n,r,e,t,i,s,o,l,c])}function zR(t){Eo(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(yj(t)),n=_.useRef(!1),r=Cc(),i=_.useMemo(()=>yle(r.search,n.current?null:e.current),[r.search]),s=Pc(),o=_.useCallback((l,c)=>{const u=yj(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,s("?"+u,c)},[s,i]);return[i,o]}var Hle=0,$le=()=>`__${String(++Hle)}__`;function Vle(){let{router:t}=gW("useSubmit"),{basename:e}=_.useContext(Po),n=ole(),r=t.fetch,i=t.navigate;return _.useCallback(async(s,o={})=>{let{action:l,method:c,encType:u,formData:d,body:h}=_le(s,e);if(o.navigate===!1){let p=o.fetcherKey||$le();await r(p,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:h,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:h,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 Gle(t,{relative:e}={}){let{basename:n}=_.useContext(Po),r=_.useContext(bl);ai(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...Hy(t||".",{relative:e})},o=Cc();if(t==null){s.search=o.search;let l=new URLSearchParams(s.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(h=>h).forEach(h=>l.append("index",h));let d=l.toString();s.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:Pu([n,s.pathname])),W0(s)}function qle(t,{relative:e}={}){let n=_.useContext(sW);ai(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=gW("useViewTransitionState"),i=Hy(t,{relative:e});if(!n.isTransitioning)return!1;let s=Bu(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Bu(n.nextLocation.pathname,r)||n.nextLocation.pathname;return rS(i.pathname,o)!=null||rS(i.pathname,s)!=null}var Su=H9();const Wle=gl(Su);var Lm=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Kle={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Xle=class{#t=Kle;#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)}},Hf=new Xle;function Yle(t){setTimeout(t,0)}var fm=typeof window>"u"||"Deno"in globalThis;function es(){}function Qle(t,e){return typeof t=="function"?t(e):t}function vj(t){return typeof t=="number"&&t>=0&&t!==1/0}function bW(t,e){return Math.max(t+(e||0)-Date.now(),0)}function mh(t,e){return typeof t=="function"?t(e):t}function Xo(t,e){return typeof t=="function"?t(e):t}function HU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==UR(o,e.options))return!1}else if(!K0(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||s&&!s(e))}function $U(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(mm(e.options.mutationKey)!==mm(s))return!1}else if(!K0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function UR(t,e){return(e?.queryKeyHashFn||mm)(t)}function mm(t){return JSON.stringify(t,(e,n)=>wj(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function K0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>K0(t[n],e[n])):!1}var Zle=Object.prototype.hasOwnProperty;function BR(t,e){if(t===e)return t;const n=VU(t)&&VU(e);if(!n&&!(wj(t)&&wj(e)))return e;const i=(n?t:Object.keys(t)).length,s=n?e:Object.keys(e),o=s.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:s[u],h=t[d],p=e[d];if(h===p){l[d]=h,(n?u<i:Zle.call(t,d))&&c++;continue}if(h===null||p===null||typeof h!="object"||typeof p!="object"){l[d]=p;continue}const m=BR(h,p);l[d]=m,m===h&&c++}return i===o&&c===i?t:l}function X0(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 VU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function wj(t){if(!GU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!GU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function GU(t){return Object.prototype.toString.call(t)==="[object Object]"}function Jle(t){return new Promise(e=>{Hf.setTimeout(e,t)})}function _j(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?BR(t,e):e}function ece(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function tce(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var HR=Symbol();function xW(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===HR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function yW(t,e){return typeof t=="function"?t(...e):!!t}var nce=class extends Lm{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!fm&&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"}},$R=new nce;function Sj(){let t,e;const n=new Promise((i,s)=>{t=i,e=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var rce=Yle;function ice(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=rce;const s=l=>{e?t.push(l):i(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||o()}return c},batchCalls:l=>(...c)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var yi=ice(),ace=class extends Lm{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!fm&&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}},iS=new ace;function sce(t){return Math.min(1e3*2**t,3e4)}function vW(t){return(t??"online")==="online"?iS.isOnline():!0}var Nj=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function wW(t){let e=!1,n=0,r;const i=Sj(),s=()=>i.status!=="pending",o=y=>{if(!s()){const x=new Nj(y);p(x),t.onCancel?.(x)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>$R.isFocused()&&(t.networkMode==="always"||iS.isOnline())&&t.canRun(),d=()=>vW(t.networkMode)&&t.canRun(),h=y=>{s()||(r?.(),i.resolve(y))},p=y=>{s()||(r?.(),i.reject(y))},m=()=>new Promise(y=>{r=x=>{(s()||u())&&y(x)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),b=()=>{if(s())return;let y;const x=n===0?t.initialPromise:void 0;try{y=x??t.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(h).catch(v=>{if(s())return;const S=t.retry??(fm?0:3),N=t.retryDelay??sce,T=typeof N=="function"?N(n,v):N,M=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,v);if(e||!M){p(v);return}n++,t.onFail?.(n,v),Jle(T).then(()=>u()?void 0:m()).then(()=>{e?p(v):b()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?b():m().then(b),i)}}var _W=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),vj(this.gcTime)&&(this.#t=Hf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(fm?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Hf.clearTimeout(this.#t),this.#t=void 0)}},oce=class extends _W{#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=WU(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=WU(this.options);e.data!==void 0&&(this.setState(qU(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=_j(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(es).catch(es):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>Xo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===HR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>mh(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:!bW(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=xW(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=wW({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof Nj&&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 Nj){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,...SW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...qU(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),yi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function SW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:vW(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function qU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function WU(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 VR=class extends Lm{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=Sj(),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),KU(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return kj(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return kj(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 Xo(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&&!X0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&XU(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||Xo(this.options.enabled,this.#e)!==Xo(e.enabled,this.#e)||mh(this.options.staleTime,this.#e)!==mh(e.staleTime,this.#e))&&this.#g();const i=this.#b();r&&(this.#e!==n||Xo(this.options.enabled,this.#e)!==Xo(e.enabled,this.#e)||i!==this.#l)&&this.#x(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return cce(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(es)),e}#g(){this.#v();const t=mh(this.options.staleTime,this.#e);if(fm||this.#i.isStale||!vj(t))return;const n=bW(this.#i.dataUpdatedAt,t)+1;this.#c=Hf.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#x(t){this.#w(),this.#l=t,!(fm||Xo(this.options.enabled,this.#e)===!1||!vj(this.#l)||this.#l===0)&&(this.#u=Hf.setInterval(()=>{(this.options.refetchIntervalInBackground||$R.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#x(this.#b())}#v(){this.#c&&(Hf.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Hf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,s=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},h=!1,p;if(e._optimisticResults){const R=this.hasListeners(),C=!R&&KU(t,e),P=R&&XU(t,n,e,r);(C||P)&&(d={...d,...SW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:b,status:y}=d;p=d.data;let x=!1;if(e.placeholderData!==void 0&&p===void 0&&y==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,x=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,R!==void 0&&(y="success",p=_j(i?.data,R,e),h=!0)}if(e.select&&p!==void 0&&!x)if(i&&p===s?.data&&e.select===this.#f)p=this.#d;else try{this.#f=e.select,p=e.select(p),p=_j(i?.data,p,e),this.#d=p,this.#s=null}catch(R){this.#s=R}this.#s&&(m=this.#s,p=this.#d,b=Date.now(),y="error");const v=d.fetchStatus==="fetching",S=y==="pending",N=y==="error",T=S&&v,M=p!==void 0,k={status:y,fetchStatus:d.fetchStatus,isPending:S,isSuccess:y==="success",isError:N,isInitialLoading:T,isLoading:T,data:p,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:b,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:v,isRefetching:v&&!S,isLoadingError:N&&!M,isPaused:d.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:N&&M,isStale:GR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Xo(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)},C=()=>{const U=this.#o=k.promise=Sj();R(U)},P=this.#o;switch(P.status){case"pending":t.queryHash===n.queryHash&&R(P);break;case"fulfilled":(k.status==="error"||k.data!==P.value)&&C();break;case"rejected":(k.status!=="error"||k.error!==P.reason)&&C();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),X0(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const s=new Set(i??this.#p);return this.options.throwOnError&&s.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&s.has(l)})};this.#S({listeners:n()})}#_(){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){yi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function lce(t,e){return Xo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function KU(t,e){return lce(t,e)||t.state.data!==void 0&&kj(t,e,e.refetchOnMount)}function kj(t,e,n){if(Xo(e.enabled,t)!==!1&&mh(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&GR(t,e)}return!1}function XU(t,e,n,r){return(t!==e||Xo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&GR(t,n)}function GR(t,e){return Xo(e.enabled,t)!==!1&&t.isStaleByTime(mh(e.staleTime,t))}function cce(t,e){return!X0(t.getCurrentResult(),e)}function YU(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const h=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},p=xW(e.options,e.fetchOptions),m=async(b,y,x)=>{if(d)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const S=(()=>{const A={client:e.client,queryKey:e.queryKey,pageParam:y,direction:x?"backward":"forward",meta:e.options.meta};return h(A),A})(),N=await p(S),{maxPages:T}=e.options,M=x?tce:ece;return{pages:M(b.pages,N,T),pageParams:M(b.pageParams,y,T)}};if(i&&s.length){const b=i==="backward",y=b?uce:QU,x={pages:s,pageParams:o},v=y(r,x);l=await m(x,v,b)}else{const b=t??s.length;do{const y=c===0?o[0]??r.initialPageParam:QU(r,l);if(c>0&&y==null)break;l=await m(l,y),c++}while(c<b)}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 QU(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 uce(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var dce=class extends _W{#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||NW(),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=wW({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,o)=>{this.#r({type:"failed",failureCount:s,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#r({type:"pending",context:o,variables:t,isPaused:i})}const s=await this.#i.start();return await this.#n.config.onSuccess?.(s,t,this.state.context,this,n),await this.options.onSuccess?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,t,this.state.context,n),this.#r({type:"success",data:s}),s}catch(s){try{throw await this.#n.config.onError?.(s,t,this.state.context,this,n),await this.options.onError?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,s,t,this.state.context,n),s}finally{this.#r({type:"error",error:s})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),yi.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function NW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var hce=class extends Lm{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 dce({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=Gw(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=Gw(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=Gw(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=Gw(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){yi.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=>$U(e,n))}findAll(t={}){return this.getAll().filter(e=>$U(t,e))}notify(t){yi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return yi.batch(()=>Promise.all(t.map(e=>e.continue().catch(es))))}};function Gw(t){return t.options.scope?.id}var fce=class extends Lm{#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),X0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&mm(n.mutationKey)!==mm(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??NW();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){yi.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 ZU(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function mce(t,e,n){const r=t.slice(0);return r[e]=n,r}var pce=class extends Lm{#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,yi.batch(()=>{const n=this.#r,r=this.#c(this.#n);this.#f=r,r.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=r.map(d=>d.observer),s=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,h)=>d!==n[h]),c=o||l,u=c?!0:s.some((d,h)=>{const p=this.#e[h];return!p||!X0(d,p)});!c&&!u||(c&&(this.#r=i),this.#e=s,this.hasListeners()&&(c&&(ZU(n,i).forEach(d=>{d.destroy()}),ZU(i,n).forEach(d=>{d.subscribe(h=>{this.#u(d,h)})})),this.#l()))})}getCurrentResult(){return this.#e}getQueries(){return this.#r.map(t=>t.getCurrentQuery())}getObservers(){return this.#r}getOptimisticResult(t,e){const n=this.#c(t),r=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions));return[r,i=>this.#h(i??r,e),()=>this.#d(r,n)]}#d(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,s=>{e.forEach(o=>{o.observer.trackProp(s)})})})}#h(t,e){return e?((!this.#a||this.#e!==this.#s||e!==this.#o)&&(this.#o=e,this.#s=this.#e,this.#a=BR(this.#a,e(t))),this.#a):t}#c(t){const e=new Map;this.#r.forEach(r=>{const i=r.options.queryHash;if(!i)return;const s=e.get(i);s?s.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#t.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new VR(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=mce(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&&yi.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},gce=class extends Lm{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??UR(r,e);let s=this.get(i);return s||(s=new oce({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(s)),s}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){yi.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=>HU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>HU(t,n)):e}notify(t){yi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){yi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){yi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},bce=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new gce,this.#e=t.mutationCache||new hce,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=$R.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=iS.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(mh(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#t.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),s=this.#t.get(r.queryHash)?.state.data,o=Qle(e,s);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return yi.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;yi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return yi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=yi.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(es).catch(es)}invalidateQueries(t,e={}){return yi.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=yi.batch(()=>this.#t.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(es)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(es)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(mh(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(es).catch(es)}fetchInfiniteQuery(t){return t.behavior=YU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(es).catch(es)}ensureInfiniteQueryData(t){return t.behavior=YU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return iS.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(mm(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{K0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(mm(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{K0(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=UR(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===HR&&(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()}},kW=_.createContext(void 0),nn=t=>{const e=_.useContext(kW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},xce=({client:t,children:e})=>(_.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),a.jsx(kW.Provider,{value:t,children:e})),MW=_.createContext(!1),EW=()=>_.useContext(MW);MW.Provider;function yce(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var vce=_.createContext(yce()),TW=()=>_.useContext(vce),AW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},CW=t=>{_.useEffect(()=>{t.clearReset()},[t])},PW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||yW(n,[t.error,r])),jW=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))}},DW=(t,e)=>t.isLoading&&t.isFetching&&!e,Mj=(t,e)=>t?.suspense&&e.isPending,aS=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function qR({queries:t,...e},n){const r=nn(),i=EW(),s=TW(),o=_.useMemo(()=>t.map(y=>{const x=r.defaultQueryOptions(y);return x._optimisticResults=i?"isRestoring":"optimistic",x}),[t,r,i]);o.forEach(y=>{jW(y),AW(y,s)}),CW(s);const[l]=_.useState(()=>new pce(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),h=!i&&e.subscribed!==!1;_.useSyncExternalStore(_.useCallback(y=>h?l.subscribe(yi.batchCalls(y)):es,[l,h]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),_.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const m=c.some((y,x)=>Mj(o[x],y))?c.flatMap((y,x)=>{const v=o[x];if(v){const S=new VR(r,v);if(Mj(v,y))return aS(v,S,s);DW(y,i)&&aS(v,S,s)}return[]}):[];if(m.length>0)throw Promise.all(m);const b=c.find((y,x)=>{const v=o[x];return v&&PW({result:y,errorResetBoundary:s,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(b?.error)throw b.error;return u(d())}function wce(t,e,n){const r=EW(),i=TW(),s=nn(),o=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",jW(o),AW(o,i),CW(i);const l=!s.getQueryCache().get(o.queryHash),[c]=_.useState(()=>new e(s,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(_.useSyncExternalStore(_.useCallback(h=>{const p=d?c.subscribe(yi.batchCalls(h)):es;return c.updateResult(),p},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),_.useEffect(()=>{c.setOptions(o)},[o,c]),Mj(o,u))throw aS(o,c,i);if(PW({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!fm&&DW(u,r)&&(l?aS(o,c,i):s.getQueryCache().get(o.queryHash)?.promise)?.catch(es).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function nt(t,e){return wce(t,VR)}function dt(t,e){const n=nn(),[r]=_.useState(()=>new fce(n,t));_.useEffect(()=>{r.setOptions(t)},[r,t]);const i=_.useSyncExternalStore(_.useCallback(o=>r.subscribe(yi.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=_.useCallback((o,l)=>{r.mutate(o,l).catch(es)},[r]);if(i.error&&yW(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const _ce=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Sce=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),JU=t=>{const e=Sce(t);return e.charAt(0).toUpperCase()+e.slice(1)},RW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Nce=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var kce={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 Mce=_.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},c)=>_.createElement("svg",{ref:c,...kce,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:RW("lucide",i),...!s&&!Nce(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>_.createElement(u,d)),...Array.isArray(s)?s:[s]]));const Ze=(t,e)=>{const n=_.forwardRef(({className:r,...i},s)=>_.createElement(Mce,{ref:s,iconNode:e,className:RW(`lucide-${_ce(JU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=JU(t),n};const Ece=[["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"}]],Tce=Ze("air-vent",Ece);const Ace=[["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"}]],wo=Ze("archive",Ace);const Cce=[["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"}]],Pce=Ze("arrow-down-wide-narrow",Cce);const jce=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Y0=Ze("arrow-down",jce);const Dce=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Rce=Ze("arrow-left",Dce);const Oce=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],eB=Ze("arrow-right-left",Oce);const Lce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ej=Ze("arrow-right",Lce);const Fce=[["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"}]],OW=Ze("arrow-up-down",Fce);const Ice=[["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"}]],zce=Ze("arrow-up-narrow-wide",Ice);const Uce=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],qg=Ze("arrow-up",Uce);const Bce=[["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"}]],Ag=Ze("bell",Bce);const Hce=[["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"}]],$ce=Ze("bold",Hce);const Vce=[["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"}]],Gce=Ze("book",Vce);const qce=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Wce=Ze("bookmark",qce);const Kce=[["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"}]],zi=Ze("box",Kce);const Xce=[["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"}]],LW=Ze("briefcase",Xce);const Yce=[["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"}]],vk=Ze("bug",Yce);const Qce=[["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"}]],Zce=Ze("cable",Qce);const Jce=[["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"}]],eue=Ze("calculator",Jce);const tue=[["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"}]],nue=Ze("calendar-days",tue);const rue=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Qr=Ze("calendar",rue);const iue=[["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"}]],Wg=Ze("camera",iue);const aue=[["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"}]],sue=Ze("chart-column",aue);const oue=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Vi=Ze("check",oue);const lue=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],hr=Ze("chevron-down",lue);const cue=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ns=Ze("chevron-right",cue);const uue=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Th=Ze("chevron-left",uue);const due=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Hu=Ze("chevron-up",due);const hue=[["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"}]],Ti=Ze("circle-alert",hue);const fue=[["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"}]],gT=Ze("circle-arrow-up",fue);const mue=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],fr=Ze("circle-check-big",mue);const pue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Kg=Ze("circle-check",pue);const gue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],bue=Ze("circle-dot",gue);const xue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],yue=Ze("circle-stop",xue);const vue=[["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"}]],Ji=Ze("circle-x",vue);const wue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Tj=Ze("circle",wue);const _ue=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],er=Ze("clock",_ue);const Sue=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],wk=Ze("cloud",Sue);const Nue=[["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"}]],kue=Ze("code-xml",Nue);const Mue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],FW=Ze("code",Mue);const Eue=[["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"}]],Tue=Ze("coffee",Eue);const Aue=[["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"}]],Cue=Ze("cog",Aue);const Pue=[["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"}]],jue=Ze("compass",Pue);const Due=[["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"}]],Bl=Ze("copy",Due);const Rue=[["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"}]],qw=Ze("cpu",Rue);const Oue=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],Lue=Ze("cylinder",Oue);const Fue=[["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"}]],ju=Ze("database",Fue);const Iue=[["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"}]],Aj=Ze("dollar-sign",Iue);const zue=[["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"}]],_i=Ze("download",zue);const Uue=[["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"}]],_k=Ze("droplet",Uue);const Bue=[["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"}]],WR=Ze("droplets",Bue);const Hue=[["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"}]],ph=Ze("ellipsis-vertical",Hue);const $ue=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],bT=Ze("equal",$ue);const Vue=[["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"}]],Zr=Ze("external-link",Vue);const Gue=[["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"}]],Sk=Ze("eye-off",Gue);const que=[["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"}]],vc=Ze("eye",que);const Wue=[["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"}]],IW=Ze("fan",Wue);const Kue=[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.8",key:"1kchwa"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}],["path",{d:"M3 13.1a2 2 0 0 0-.999 1.76v3.24a2 2 0 0 0 .969 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01z",key:"19flxy"}],["path",{d:"M7 17v5",key:"1yj1jh"}]],Qf=Ze("file-box",Kue);const Xue=[["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"}]],sS=Ze("file-code",Xue);const Yue=[["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"}]],Que=Ze("file-exclamation-point",Yue);const Zue=[["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"}]],oS=Ze("file-spreadsheet",Zue);const Jue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],xs=Ze("file-text",Jue);const ede=[["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"}]],Nk=Ze("file",ede);const tde=[["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"}]],gh=Ze("film",tde);const nde=[["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"}]],rde=Ze("flame",nde);const ide=[["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"}]],rs=Ze("folder-kanban",ide);const ade=[["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"}]],Hl=Ze("folder-open",ade);const sde=[["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"}]],ode=Ze("folder-plus",sde);const lde=[["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"}]],cde=Ze("folder-tree",lde);const ude=[["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"}]],zW=Ze("folder",ude);const dde=[["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"}]],hde=Ze("fullscreen",dde);const fde=[["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"}]],kk=Ze("funnel",fde);const mde=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Mk=Ze("gauge",mde);const pde=[["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"}]],gde=Ze("gift",pde);const bde=[["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"}]],Cg=Ze("git-compare",bde);const xde=[["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"}]],Cj=Ze("github",xde);const yde=[["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"}]],bh=Ze("globe",yde);const vde=[["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"}]],Zf=Ze("grip-vertical",vde);const wde=[["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"}]],UW=Ze("hand",wde);const _de=[["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"}]],Eb=Ze("hard-drive",_de);const Sde=[["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"}]],Nde=Ze("hash",Sde);const kde=[["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"}]],Mde=Ze("headphones",kde);const Ede=[["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"}]],Tde=Ze("heart",Ede);const Ade=[["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=Ze("history",Ade);const Cde=[["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"}]],$y=Ze("house",Cde);const Pde=[["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"}]],$u=Ze("image",Pde);const jde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],yo=Ze("info",jde);const Dde=[["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"}]],Rde=Ze("italic",Dde);const Ode=[["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"}]],Yo=Ze("key",Ode);const Lde=[["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"}]],Pj=Ze("keyboard",Lde);const Fde=[["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"}]],is=Ze("layers",Fde);const Ide=[["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"}]],Ek=Ze("layout-grid",Ide);const zde=[["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"}]],Ude=Ze("link-2-off",zde);const Bde=[["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"}]],pc=Ze("link-2",Bde);const Hde=[["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"}]],Vy=Ze("link",Hde);const $de=[["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"}]],BW=Ze("list-ordered",$de);const Vde=[["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"}]],jj=Ze("list-todo",Vde);const Gde=[["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"}]],Tk=Ze("list",Gde);const qde=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],lt=Ze("loader-circle",qde);const Wde=[["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"}]],A1=Ze("lock-open",Wde);const Kde=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Tf=Ze("lock",Kde);const Xde=[["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"}]],tB=Ze("log-in",Xde);const Yde=[["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"}]],Dj=Ze("log-out",Yde);const Qde=[["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"}]],Z0=Ze("mail",Qde);const Zde=[["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"}]],Jde=Ze("map",Zde);const ehe=[["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"}]],KR=Ze("maximize-2",ehe);const the=[["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"}]],nhe=Ze("maximize",the);const rhe=[["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"}]],ihe=Ze("memory-stick",rhe);const ahe=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],she=Ze("menu",ahe);const ohe=[["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"}]],XR=Ze("minimize-2",ohe);const lhe=[["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"}]],HW=Ze("minimize",lhe);const che=[["path",{d:"M5 12h14",key:"1ays0h"}]],Rj=Ze("minus",che);const uhe=[["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"}]],dhe=Ze("monitor",uhe);const hhe=[["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"}]],lS=Ze("moon",hhe);const fhe=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],mhe=Ze("move-right",fhe);const phe=[["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"}]],Oj=Ze("music",phe);const ghe=[["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"}]],wc=Ze("package",ghe);const bhe=[["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"}]],$W=Ze("palette",bhe);const xhe=[["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"}]],Ak=Ze("pause",xhe);const yhe=[["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"}]],pm=Ze("pen-line",yhe);const vhe=[["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"}]],wg=Ze("pen",vhe);const whe=[["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"}]],ea=Ze("pencil",whe);const _he=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],She=Ze("phone",_he);const Nhe=[["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"}]],To=Ze("play",Nhe);const khe=[["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"}]],sl=Ze("plug",khe);const Mhe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],lr=Ze("plus",Mhe);const Ehe=[["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"}]],Ck=Ze("power-off",Ehe);const The=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],nd=Ze("power",The);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"}]],Dr=Ze("printer",Ahe);const Che=[["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"}]],VW=Ze("qr-code",Che);const Phe=[["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"}]],YR=Ze("radio",Phe);const jhe=[["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"}]],Ir=Ze("refresh-cw",jhe);const Dhe=[["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"}]],Vu=Ze("rotate-ccw",Dhe);const Rhe=[["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"}]],Ohe=Ze("ruler",Rhe);const Lhe=[["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"}]],ys=Ze("save",Lhe);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"}]],cS=Ze("scan-search",Fhe);const Ihe=[["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"}]],zhe=Ze("scissors",Ihe);const Uhe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Zi=Ze("search",Uhe);const Bhe=[["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"}]],Pk=Ze("send",Bhe);const Hhe=[["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"}]],Af=Ze("server",Hhe);const $he=[["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"}]],Gu=Ze("settings-2",$he);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"}]],jk=Ze("settings",Vhe);const Ghe=[["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"}]],xT=Ze("shield",Ghe);const qhe=[["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"}]],GW=Ze("shopping-cart",qhe);const Whe=[["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"}]],Khe=Ze("signal",Whe);const Xhe=[["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"}]],Yhe=Ze("skip-back",Xhe);const Qhe=[["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"}]],QR=Ze("skip-forward",Qhe);const Zhe=[["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"}]],nB=Ze("sliders-vertical",Zhe);const Jhe=[["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"}]],J0=Ze("sparkles",Jhe);const efe=[["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"}]],Ks=Ze("square-check-big",efe);const tfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],nfe=Ze("square-minus",tfe);const rfe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ul=Ze("square",rfe);const ife=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],gm=Ze("star",ife);const afe=[["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"}]],qW=Ze("sticky-note",afe);const sfe=[["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"}]],rB=Ze("sun",sfe);const ofe=[["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"}]],Ah=Ze("tag",ofe);const lfe=[["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"}]],WW=Ze("target",lfe);const cfe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],KW=Ze("terminal",cfe);const ufe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],dfe=Ze("text-align-center",ufe);const hfe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],ffe=Ze("text-align-end",hfe);const mfe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],pfe=Ze("text-align-start",mfe);const gfe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Dk=Ze("thermometer",gfe);const bfe=[["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"}]],Nu=Ze("timer",bfe);const xfe=[["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"}]],hn=Ze("trash-2",xfe);const yfe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],XW=Ze("trending-down",yfe);const vfe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Lj=Ze("trending-up",vfe);const wfe=[["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"}]],En=Ze("triangle-alert",wfe);const _fe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Sfe=Ze("underline",_fe);const Nfe=[["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"}]],ZR=Ze("unlink",Nfe);const kfe=[["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"}]],Na=Ze("upload",kfe);const Mfe=[["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"}]],qu=Ze("user",Mfe);const Efe=[["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"}]],rh=Ze("users",Efe);const Tfe=[["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"}]],JR=Ze("video",Tfe);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"}]],Cfe=Ze("volume-2",Afe);const Pfe=[["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"}]],jfe=Ze("volume-x",Pfe);const Dfe=[["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"}]],Rfe=Ze("wand-sparkles",Dfe);const Ofe=[["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"}]],bm=Ze("wifi-off",Ofe);const Lfe=[["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"}]],Pg=Ze("wifi",Lfe);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"}]],YW=Ze("wind",Ffe);const Ife=[["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"}]],xm=Ze("wrench",Ife);const zfe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Lt=Ze("x",zfe);const Ufe=[["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"}]],eO=Ze("zoom-in",Ufe);const Bfe=[["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"}]],Ch=Ze("zap",Bfe);const Hfe=[["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"}]],tO=Ze("zoom-out",Hfe),un="/api/v1";let ln=localStorage.getItem("auth_token");function c0(t){ln=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Ph(){return ln}function Cf(t){if(!t)return null;const e=t.match(/filename\*=(?:UTF-8|utf-8)''(.+?)(?:;|$)/);if(e)try{return decodeURIComponent(e[1])}catch{}return t.match(/filename="?([^";\n]+)"?/)?.[1]||null}async function Le(t,e={}){const n={"Content-Type":"application/json",...e.headers};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${un}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){const o=(await r.json().catch(()=>({}))).detail,l=typeof o=="string"?o:o?JSON.stringify(o):`HTTP ${r.status}`;throw r.status===401&&["Could not validate credentials","Token has expired","User not found or inactive","Invalid API key","API key has expired"].some(u=>l.includes(u))&&c0(null),new Error(l)}const i=r.headers.get("content-length");if(!(r.status===204||i==="0"))return await r.json()}const ae={getAuthStatus:()=>Le("/auth/status"),setupAuth:t=>Le("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Le("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Le("/auth/logout",{method:"POST"}),getCurrentUser:()=>Le("/auth/me"),disableAuth:()=>Le("/auth/disable",{method:"POST"}),testSMTP:t=>Le("/auth/smtp/test",{method:"POST",body:JSON.stringify(t)}),getSMTPSettings:()=>Le("/auth/smtp"),saveSMTPSettings:t=>Le("/auth/smtp",{method:"POST",body:JSON.stringify(t)}),enableAdvancedAuth:()=>Le("/auth/advanced-auth/enable",{method:"POST"}),disableAdvancedAuth:()=>Le("/auth/advanced-auth/disable",{method:"POST"}),getAdvancedAuthStatus:()=>Le("/auth/advanced-auth/status"),forgotPassword:t=>Le("/auth/forgot-password",{method:"POST",body:JSON.stringify(t)}),resetUserPassword:t=>Le("/auth/reset-password",{method:"POST",body:JSON.stringify(t)}),getUsers:()=>Le("/users/"),getUser:t=>Le(`/users/${t}`),createUser:t=>Le("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Le(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:(t,e=!1)=>Le(`/users/${t}?delete_items=${e}`,{method:"DELETE"}),getUserItemsCount:t=>Le(`/users/${t}/items-count`),changePassword:(t,e)=>Le("/users/me/change-password",{method:"POST",body:JSON.stringify({current_password:t,new_password:e})}),getPermissions:()=>Le("/groups/permissions"),getGroups:()=>Le("/groups/"),getGroup:t=>Le(`/groups/${t}`),createGroup:t=>Le("/groups/",{method:"POST",body:JSON.stringify(t)}),updateGroup:(t,e)=>Le(`/groups/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteGroup:t=>Le(`/groups/${t}`,{method:"DELETE"}),addUserToGroup:(t,e)=>Le(`/groups/${t}/users/${e}`,{method:"POST"}),removeUserFromGroup:(t,e)=>Le(`/groups/${t}/users/${e}`,{method:"DELETE"}),getPrinters:()=>Le("/printers/"),getPrinter:t=>Le(`/printers/${t}`),createPrinter:t=>Le("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Le(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Le(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Le(`/printers/${t}/status`),refreshPrinterStatus:t=>Le(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Le(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Le(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Le(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Le(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Le(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Le(`/printers/${t}/print/resume`,{method:"POST"}),clearPlate:t=>Le(`/printers/${t}/clear-plate`,{method:"POST"}),getCurrentPrintUser:t=>Le(`/printers/${t}/current-print-user`),setChamberLight:(t,e)=>Le(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Le(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Le(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Le(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Le(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Le(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Le(`/printers/${t}/logging`),clearMQTTLogs:t=>Le(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Le(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${un}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,getPrinterFileGcodeUrl:(t,e)=>`${un}/printers/${t}/files/gcode?path=${encodeURIComponent(e)}`,getPrinterFilePlates:(t,e)=>Le(`/printers/${t}/files/plates?path=${encodeURIComponent(e)}`),getPrinterFilePlateThumbnail:(t,e,n)=>`${un}/printers/${t}/files/plate-thumbnail/${e}?path=${encodeURIComponent(n)}`,downloadPrinterFile:async(t,e)=>{const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${un}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,{headers:n});if(!r.ok){const u=await r.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition"),s=Cf(i)||e.split("/").pop()||"download",o=await r.blob(),l=window.URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},downloadPrinterFilesAsZip:async(t,e)=>{const n={"Content-Type":"application/json"};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${un}/printers/${t}/files/download-zip`,{method:"POST",headers:n,body:JSON.stringify({paths:e})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.blob()},deletePrinterFile:(t,e)=>Le(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Le(`/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)),Le(`/archives/?${i}`)},getArchive:t=>Le(`/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)),Le(`/archives/search?${n}`)},rebuildSearchIndex:()=>Le("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Le(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Le(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Le(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Le("/archives/stats"),getTags:()=>Le("/archives/tags"),renameTag:(t,e)=>Le(`/archives/tags/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({new_name:e})}),deleteTag:t=>Le(`/archives/tags/${encodeURIComponent(t)}`,{method:"DELETE"}),recalculateCosts:()=>Le("/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)),Le(`/archives/analysis/failures?${e}`)},compareArchives:t=>Le(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Le(`/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={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${un}/archives/export?${e}`,{headers:n});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition");let s=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(s=l[1])}return{blob:await r.blob(),filename:s}},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={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${un}/archives/stats/export?${e}`,{headers:n});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition");let s=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(s=l[1])}return{blob:await r.blob(),filename:s}},getArchiveDuplicates:t=>Le(`/archives/${t}/duplicates`),backfillContentHashes:()=>Le("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${un}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${un}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${un}/archives/${t}/download`,downloadArchive:async(t,e)=>{const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${un}/archives/${t}/download`,{headers:n});if(!r.ok){const u=await r.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition"),s=Cf(i)||e||`archive_${t}.3mf`,o=await r.blob(),l=window.URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},getArchiveGcode:t=>`${un}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${un}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${un}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Le(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Le(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${un}/archives/${t}/timelapse/upload`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getTimelapseInfo:t=>Le(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Le(`/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={};ln&&(i.Authorization=`Bearer ${ln}`);const s=await fetch(`${un}/archives/${t}/timelapse/process`,{method:"POST",headers:i,body:r});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},getArchivePhotoUrl:(t,e)=>`${un}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${un}/archives/${t}/photos`,{headers:r,method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteArchivePhoto:(t,e)=>Le(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${un}/archives/${t}/source`,downloadSource3mf:async t=>{const e={};ln&&(e.Authorization=`Bearer ${ln}`);const n=await fetch(`${un}/archives/${t}/source`,{headers:e});if(!n.ok){const c=await n.json().catch(()=>({}));throw new Error(c.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition"),i=Cf(r)||`source_${t}.3mf`,s=await n.blob(),o=window.URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=i,document.body.appendChild(l),l.click(),document.body.removeChild(l),window.URL.revokeObjectURL(o)},getSource3mfForSlicer:(t,e)=>`${un}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${un}/archives/${t}/source`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteSource3mf:t=>Le(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${un}/archives/${t}/f3d`,downloadF3d:async t=>{const e={};ln&&(e.Authorization=`Bearer ${ln}`);const n=await fetch(`${un}/archives/${t}/f3d`,{headers:e});if(!n.ok){const c=await n.json().catch(()=>({}));throw new Error(c.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition"),i=Cf(r)||`archive_${t}.f3d`,s=await n.blob(),o=window.URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=i,document.body.appendChild(l),l.click(),document.body.removeChild(l),window.URL.revokeObjectURL(o)},uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${un}/archives/${t}/f3d`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteF3d:t=>Le(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${un}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Le(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Le(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Le(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${un}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${un}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Le(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Le(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Le(`/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?`${un}/archives/upload?printer_id=${e}`:`${un}/archives/upload`,i={};ln&&(i.Authorization=`Bearer ${ln}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(o=>n.append("files",o));const r=e?`${un}/archives/upload-bulk?printer_id=${e}`:`${un}/archives/upload-bulk`,i={};ln&&(i.Authorization=`Bearer ${ln}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},getSettings:()=>Le("/settings/"),updateSettings:t=>Le("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Le("/settings/mqtt/status"),resetSettings:()=>Le("/settings/reset",{method:"POST"}),exportBackup:async()=>{const t=`${un}/settings/backup`,e={};ln&&(e.Authorization=`Bearer ${ln}`);const n=await fetch(t,{headers:e});if(!n.ok){const o=await n.text();throw new Error(o||`Backup failed with status ${n.status}`)}const r=n.headers.get("Content-Disposition");let i="bambuddy-backup.zip";if(r){const o=r.match(/filename=([^;]+)/);o&&(i=o[1].trim())}return{blob:await n.blob(),filename:i}},importBackup:async t=>{const e=new FormData;e.append("file",t);const n=`${un}/settings/restore`,r={};return ln&&(r.Authorization=`Bearer ${ln}`),(await fetch(n,{method:"POST",headers:r,body:e})).json()},checkFfmpeg:()=>Le("/settings/check-ffmpeg"),getNetworkInterfaces:()=>Le("/settings/network-interfaces"),getCloudStatus:()=>Le("/cloud/status"),cloudLogin:(t,e,n="global")=>Le("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e,n)=>Le("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e,tfa_key:n})}),cloudSetToken:t=>Le("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Le("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Le(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Le(`/cloud/settings/${t}`),createCloudSetting:t=>Le("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Le(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Le(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Le("/cloud/devices"),getCloudFields:t=>Le(`/cloud/fields/${t}`),getAllCloudFields:()=>Le("/cloud/fields"),getFilamentInfo:t=>Le("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Le("/smart-plugs/"),getSmartPlug:t=>Le(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Le(`/smart-plugs/by-printer/${t}`),getScriptPlugsByPrinter:t=>Le(`/smart-plugs/by-printer/${t}/scripts`),createSmartPlug:t=>Le("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Le(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Le(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Le(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Le(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Le("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>Le("/smart-plugs/discover/scan",{method:"POST"}),getTasmotaScanStatus:()=>Le("/smart-plugs/discover/status"),stopTasmotaScan:()=>Le("/smart-plugs/discover/stop",{method:"POST"}),getDiscoveredTasmotaDevices:()=>Le("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Le("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Le(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Le("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Le(`/queue/?${n}`)},getQueueItem:t=>Le(`/queue/${t}`),addToQueue:t=>Le("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Le(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Le(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Le("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Le(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Le(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Le(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Le("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Le(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Le(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Le(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Le(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Le(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Le(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Le(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Le(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Le(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i,s="cloud")=>Le(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}&preset_source=${encodeURIComponent(s)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Le(`/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()),Le(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Le(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Le("/filaments/"),getFilament:t=>Le(`/filaments/${t}`),getFilamentsByType:t=>Le(`/filaments/by-type/${t}`),getNotificationProviders:()=>Le("/notifications/"),getNotificationProvider:t=>Le(`/notifications/${t}`),createNotificationProvider:t=>Le("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Le(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Le(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Le(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Le("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Le("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Le("/notification-templates"),getNotificationTemplate:t=>Le(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Le(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Le(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Le("/notification-templates/variables"),previewTemplate:t=>Le("/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)),Le(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Le(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Le(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Le("/spoolman/status"),connectSpoolman:()=>Le("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Le("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Le(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Le("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Le("/spoolman/spools"),getSpoolmanFilaments:()=>Le("/spoolman/filaments"),getUnlinkedSpools:()=>Le("/spoolman/spools/unlinked"),getLinkedSpools:()=>Le("/spoolman/spools/linked"),linkSpool:(t,e)=>Le(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getSpoolmanSettings:()=>Le("/settings/spoolman"),updateSpoolmanSettings:t=>Le("/settings/spoolman",{method:"PUT",body:JSON.stringify(t)}),getVersion:()=>Le("/updates/version"),checkForUpdates:()=>Le("/updates/check"),applyUpdate:()=>Le("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Le("/updates/status"),getMaintenanceTypes:()=>Le("/maintenance/types"),createMaintenanceType:t=>Le("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Le(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Le(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Le("/maintenance/overview"),getPrinterMaintenance:t=>Le(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Le(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Le(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Le(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Le("/maintenance/summary"),setPrinterHours:(t,e)=>Le(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Le(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Le(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${un}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${un}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Le(`/printers/${t}/camera/test`),getCameraStatus:t=>Le(`/printers/${t}/camera/status`),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)),Le(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Le(`/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)),Le(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Le(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Le(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${un}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Le(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Le(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Le("/external-links/"),getExternalLink:t=>Le(`/external-links/${t}`),createExternalLink:t=>Le("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Le(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Le(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Le("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${un}/external-links/${t}/icon`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteExternalLinkIcon:t=>Le(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${un}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Le(`/projects/?${e}`)},getProject:t=>Le(`/projects/${t}`),createProject:t=>Le("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Le(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Le(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Le(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Le(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Le(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Le(`/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={};ln&&(r.Authorization=`Bearer ${ln}`);const i=await fetch(`${un}/projects/${t}/attachments`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getProjectAttachmentUrl:(t,e)=>`${un}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Le(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Le(`/projects/${t}/bom`),createBOMItem:(t,e)=>Le(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Le(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Le(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Le("/projects/templates/"),createTemplateFromProject:t=>Le(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Le(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Le(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Le(`/projects/${t}/export?format=json`),importProject:t=>Le("/projects/import",{method:"POST",body:JSON.stringify(t)}),importProjectFile:async t=>{const e=new FormData;e.append("file",t);const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${un}/projects/import/file`,{method:"POST",headers:n,body:e});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},exportProjectZip:async t=>{const e={};ln&&(e.Authorization=`Bearer ${ln}`);const n=await fetch(`${un}/projects/${t}/export`,{headers: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"),i=Cf(r)||`project_${t}.zip`;return{blob:await n.blob(),filename:i}},getAPIKeys:()=>Le("/api-keys/"),createAPIKey:t=>Le("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Le(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Le(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Le(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Le("/system/info"),getLibraryFolders:()=>Le("/library/folders"),createLibraryFolder:t=>Le("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Le(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Le(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Le(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Le(`/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)),Le(`/library/files?${n}`)},getLibraryFile:t=>Le(`/library/files/${t}`),uploadLibraryFile:async(t,e,n=!0)=>{const r=new FormData;r.append("file",t);const i=new URLSearchParams;e&&i.set("folder_id",String(e)),i.set("generate_stl_thumbnails",String(n));const s={};ln&&(s.Authorization=`Bearer ${ln}`);const o=await fetch(`${un}/library/files?${i}`,{method:"POST",headers:s,body:r});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.json()},extractZipFile:async(t,e,n=!0,r=!1,i=!0)=>{const s=new FormData;s.append("file",t);const o=new URLSearchParams;e&&o.set("folder_id",String(e)),o.set("preserve_structure",String(n)),o.set("create_folder_from_zip",String(r)),o.set("generate_stl_thumbnails",String(i));const l={};ln&&(l.Authorization=`Bearer ${ln}`);const c=await fetch(`${un}/library/files/extract-zip?${o}`,{method:"POST",headers:l,body:s});if(!c.ok){const u=await c.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${c.status}`)}return c.json()},updateLibraryFile:(t,e)=>Le(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Le(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${un}/library/files/${t}/download`,downloadLibraryFile:async(t,e)=>{const n={};ln&&(n.Authorization=`Bearer ${ln}`);const r=await fetch(`${un}/library/files/${t}/download`,{headers:n});if(!r.ok){const u=await r.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition"),s=Cf(i)||e||`file_${t}`,o=await r.blob(),l=window.URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},getLibraryFileThumbnailUrl:t=>`${un}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${un}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${un}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Le("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Le("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Le("/library/stats"),batchGenerateStlThumbnails:t=>Le("/library/generate-stl-thumbnails",{method:"POST",body:JSON.stringify(t)}),addLibraryFilesToQueue:t=>Le("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Le(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Le(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Le(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>Le("/github-backup/config"),saveGitHubBackupConfig:t=>Le("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>Le("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>Le("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>Le(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>Le("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>Le("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>Le("/github-backup/status"),getGitHubBackupLogs:(t=50)=>Le(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>Le(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"}),getLocalPresets:()=>Le("/local-presets/"),getLocalPresetDetail:t=>Le(`/local-presets/${t}`),importLocalPresets:t=>fetch(`${un}/local-presets/import`,{method:"POST",headers:ln?{Authorization:`Bearer ${ln}`}:{},body:t}).then(async e=>{if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.detail||`HTTP ${e.status}`)}return e.json()}),createLocalPreset:t=>Le("/local-presets/",{method:"POST",body:JSON.stringify(t)}),updateLocalPreset:(t,e)=>Le(`/local-presets/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLocalPreset:t=>Le(`/local-presets/${t}`,{method:"DELETE"}),refreshBaseProfileCache:()=>Le("/local-presets/base-cache/refresh",{method:"POST"})},Jl={getInfo:()=>Le("/discovery/info"),getStatus:()=>Le("/discovery/status"),startDiscovery:(t=10)=>Le(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Le("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Le("/discovery/printers"),startSubnetScan:(t,e=1)=>Le("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Le("/discovery/scan/status"),stopSubnetScan:()=>Le("/discovery/scan/stop",{method:"POST"})},C1={getSettings:()=>Le("/settings/virtual-printer"),getModels:()=>Le("/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),t.target_printer_id!==void 0&&e.set("target_printer_id",String(t.target_printer_id)),t.remote_interface_ip!==void 0&&e.set("remote_interface_ip",t.remote_interface_ip),Le(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},fg={list:()=>Le("/pending-uploads/"),getCount:()=>Le("/pending-uploads/count"),get:t=>Le(`/pending-uploads/${t}`),archive:(t,e)=>Le(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Le(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Le("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Le("/pending-uploads/discard-all",{method:"DELETE"})},P1={checkUpdates:()=>Le("/firmware/updates"),checkPrinterUpdate:t=>Le(`/firmware/updates/${t}`),prepareUpload:t=>Le(`/firmware/updates/${t}/prepare`),startUpload:t=>Le(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Le(`/firmware/updates/${t}/upload/status`)},jg={getDebugLoggingState:()=>Le("/support/debug-logging"),setDebugLogging:t=>Le("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t={};ln&&(t.Authorization=`Bearer ${ln}`);const e=await fetch(`${un}/support/bundle`,{headers:t});if(!e.ok){const l=await e.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${e.status}`)}const n=e.headers.get("Content-Disposition"),r=Cf(n)||"bambuddy-support.zip",i=await e.blob(),s=window.URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(s)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return Le(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Le("/support/logs",{method:"DELETE"})},QW=_.createContext(void 0);function $fe({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"),[s,o]=_.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=_.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=_.useState(()=>localStorage.getItem("light-style")||"classic"),[h,p]=_.useState(()=>localStorage.getItem("light-background")||"neutral"),[m,b]=_.useState(()=>localStorage.getItem("light-accent")||"green");_.useEffect(()=>{ae.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&&(b(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-${s}`),k.classList.add(`accent-${l}`)):(k.classList.add(`style-${u}`),k.classList.add(`bg-${h}`),k.classList.add(`accent-${m}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,s,l,u,h,m]);const y=()=>n(k=>k==="dark"?"light":"dark"),x=k=>n(k),v=k=>{i(k),localStorage.setItem("dark-style",k),ae.updateSettings({dark_style:k}).catch(()=>{})},S=k=>{o(k),localStorage.setItem("dark-background",k),ae.updateSettings({dark_background:k}).catch(()=>{})},N=k=>{c(k),localStorage.setItem("dark-accent",k),ae.updateSettings({dark_accent:k}).catch(()=>{})},T=k=>{d(k),localStorage.setItem("light-style",k),ae.updateSettings({light_style:k}).catch(()=>{})},M=k=>{p(k),localStorage.setItem("light-background",k),ae.updateSettings({light_background:k}).catch(()=>{})},A=k=>{b(k),localStorage.setItem("light-accent",k),ae.updateSettings({light_accent:k}).catch(()=>{})};return a.jsx(QW.Provider,{value:{mode:e,darkStyle:r,darkBackground:s,darkAccent:l,lightStyle:u,lightBackground:h,lightAccent:m,toggleMode:y,setMode:x,setDarkStyle:v,setDarkBackground:S,setDarkAccent:N,setLightStyle:T,setLightBackground:M,setLightAccent:A},children:t})}function Fm(){const t=_.useContext(QW);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 a.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,...i,children:t})}function Cn({children:t,className:e=""}){return a.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Mt({children:t,className:e=""}){return a.jsx("div",{className:`p-6 ${e}`,children:t})}function Vfe(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,s)=>({keys:[String(s+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,s)=>({keys:[String(s+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function iB({children:t}){return a.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function Gfe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Yt(),i=Vfe(n,e,r);return _.useEffect(()=>{const s=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:a.jsx(_t,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:a.jsxs(Mt,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Pj,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(s=>a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:s.category}),a.jsx("div",{className:"space-y-2",children:s.items.map(o=>a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&a.jsx(Zr,{className:"w-3 h-3 text-bambu-gray"})]}),a.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>a.jsx(iB,{children:l},l))})]},o.description))})]},s.category))}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",a.jsx(iB,{children:"Esc"})," or click outside to close"]})})]})})})}function Me({variant:t="primary",size:e="md",className:n="",children:r,...i}){const s="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",o={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return a.jsx("button",{className:`${s} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Qn({title:t,message:e,confirmText:n,cancelText:r,variant:i="default",isLoading:s=!1,loadingText:o,onConfirm:l,onCancel:c}){const{t:u}=Yt(),d=n??u("common.confirm"),h=r??u("common.cancel"),p=o??u("common.loading");_.useEffect(()=>{const y=x=>{x.key==="Escape"&&!s&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c,s]);const b={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s?void 0:c,children:a.jsx(_t,{className:"w-full max-w-md",onClick:y=>y.stopPropagation(),children:a.jsxs(Mt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-start gap-4",children:[a.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${b.icon}`,children:a.jsx(En,{className:"w-6 h-6"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),a.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),a.jsxs("div",{className:"flex gap-3 mt-6",children:[a.jsx(Me,{variant:"secondary",onClick:c,className:"flex-1",disabled:s,children:h}),a.jsx(Me,{onClick:l,className:`flex-1 ${b.button}`,disabled:s,children:s?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 mr-2 animate-spin"}),p]}):d})]})]})})})}function qfe({plug:t}){const e=nn(),[n,r]=_.useState(null),{data:i,isLoading:s}=nt({queryKey:["smart-plug-status",t.id],queryFn:()=>ae.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=dt({mutationFn:m=>ae.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,h=t.plug_type==="mqtt",p=()=>{n&&(o.mutate(n),r(null))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`p-1.5 rounded ${h?u?"bg-teal-500/20":"bg-red-500/20":u?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:h?a.jsx(YR,{className:`w-4 h-4 ${u?"text-teal-400":"text-red-400"}`}):a.jsx(sl,{className:`w-4 h-4 ${u?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),a.jsx("div",{className:"flex items-center gap-1 text-xs",children:s?a.jsx(lt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):h?u?a.jsxs(a.Fragment,{children:[a.jsx(Ch,{className:"w-3 h-3 text-teal-400"}),a.jsxs("span",{className:"text-teal-400",children:[Math.round(i?.energy?.power??0),"W"]}),a.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),a.jsx(vc,{className:"w-3 h-3 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):a.jsxs(a.Fragment,{children:[a.jsx(bm,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Waiting"})]}):u?a.jsxs(a.Fragment,{children:[a.jsx(Pg,{className:"w-3 h-3 text-status-ok"}),a.jsx("span",{className:l?"text-status-ok":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),a.jsx(Ch,{className:"w-3 h-3 text-yellow-400"}),a.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(bm,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Offline"})]})})]})]}),!h&&a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>r("on"),disabled:!u||d,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:d?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(nd,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("off"),disabled:!u||d,className:`p-1.5 rounded transition-colors ${!l&&u?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:d?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ck,{className:"w-4 h-4"})})]})]}),n&&a.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 aB({onClose:t}){const{data:e,isLoading:n}=nt({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return a.jsxs("div",{className:"absolute bottom-full left-0 mb-2 w-72 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-xl z-50",onMouseLeave:t,children:[a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:a.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[a.jsx(sl,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),a.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?a.jsxs("div",{className:"text-center py-6 px-4",children:[a.jsx(sl,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):a.jsx("div",{className:"space-y-1",children:r.map(i=>a.jsx(qfe,{plug:i},i.id))})})]})}const ZW=[{name:"globe",icon:bh},{name:"link",icon:Vy},{name:"external-link",icon:Zr},{name:"book",icon:Gce},{name:"file-text",icon:xs},{name:"home",icon:$y},{name:"star",icon:gm},{name:"heart",icon:Tde},{name:"bookmark",icon:Wce},{name:"shopping-cart",icon:GW},{name:"music",icon:Oj},{name:"video",icon:JR},{name:"image",icon:$u},{name:"camera",icon:Wg},{name:"map",icon:Jde},{name:"compass",icon:jue},{name:"coffee",icon:Tue},{name:"gift",icon:gde},{name:"wrench",icon:xm},{name:"zap",icon:Ch},{name:"cloud",icon:wk},{name:"database",icon:ju},{name:"folder",icon:zW},{name:"mail",icon:Z0},{name:"phone",icon:She},{name:"user",icon:qu},{name:"users",icon:rh},{name:"server",icon:Af},{name:"terminal",icon:KW},{name:"code",icon:FW}];function Rk(t){return ZW.find(n=>n.name===t)?.icon||Vy}function Wfe({value:t,onChange:e}){const[n,r]=_.useState(!1),i=Rk(t);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[a.jsx(i,{className:"w-5 h-5"}),a.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),a.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:a.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:ZW.map(({name:s,icon:o})=>a.jsx("button",{type:"button",onClick:()=>{e(s),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===s?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:s,children:a.jsx(o,{className:"w-5 h-5"})},s))})})]})]})}const sB=768;function nO(){const[t,e]=_.useState(()=>typeof window<"u"?window.innerWidth<sB:!1);return _.useEffect(()=>{const n=window.matchMedia(`(max-width: ${sB-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const JW=_.createContext(void 0);function Kfe({children:t}){const[e,n]=_.useState(null),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.useState(!0),u=_.useRef(!1),d=_.useRef(!0),h=async()=>{try{const A=await ae.getAuthStatus();if(!d.current)return;if(i(A.auth_enabled),o(A.requires_setup),A.auth_enabled)if(Ph())try{const R=await ae.getCurrentUser();if(!d.current)return;n(R)}catch{if(c0(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,h(),()=>{d.current=!1}),[]),_.useEffect(()=>{if(!l&&s&&!r){const A=window.location.pathname;A!=="/setup"&&!A.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else s||(u.current=!1)},[l,s,r]);const p=async(A,k)=>{const R=await ae.login({username:A,password:k});c0(R.access_token),n(R.user)},m=()=>{c0(null),n(null),ae.logout().catch(()=>{}),window.location.href="/login"},b=async()=>{if(r&&Ph())try{const A=await ae.getCurrentUser();d.current&&n(A)}catch{c0(null),d.current&&n(null)}},y=async()=>{await h()},x=_.useMemo(()=>new Set(e?.permissions??[]),[e?.permissions]),v=_.useMemo(()=>r?e?.is_admin??!1:!0,[r,e?.is_admin]),S=_.useCallback(A=>!r||v?!0:x.has(A),[r,v,x]),N=_.useCallback((...A)=>!r||v?!0:A.some(k=>x.has(k)),[r,v,x]),T=_.useCallback((...A)=>!r||v?!0:A.every(k=>x.has(k)),[r,v,x]),M=_.useCallback((A,k,R)=>{if(!r||v)return!0;const C=`${A}:${k}_all`,P=`${A}:${k}_own`;return x.has(C)?!0:x.has(P)?R==null?!1:R===e?.id:!1},[r,v,x,e?.id]);return a.jsx(JW.Provider,{value:{user:e,authEnabled:r,requiresSetup:s,loading:l,isAdmin:v,login:p,logout:m,refreshUser:b,refreshAuth:y,hasPermission:S,hasAnyPermission:N,hasAllPermissions:T,canModify:M},children:t})}function Rr(){const t=_.useContext(JW);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const eK=_.createContext(void 0);function kn(){const t=_.useContext(eK);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Xfe={success:a.jsx(fr,{className:"w-5 h-5 text-green-400"}),error:a.jsx(Ji,{className:"w-5 h-5 text-red-400"}),warning:a.jsx(Ti,{className:"w-5 h-5 text-yellow-400"}),info:a.jsx(yo,{className:"w-5 h-5 text-blue-400"}),loading:a.jsx(lt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Yfe={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 Qfe({children:t}){const[e,n]=_.useState([]),r=_.useRef(new Map);_.useEffect(()=>{const l=r.current;return()=>{l.forEach(c=>clearTimeout(c)),l.clear()}},[]);const i=_.useCallback((l,c="success")=>{const u=Math.random().toString(36).substr(2,9);n(h=>[...h,{id:u,message:l,type:c}]);const d=setTimeout(()=>{n(h=>h.filter(p=>p.id!==u)),r.current.delete(u)},3e3);r.current.set(u,d)},[]),s=_.useCallback((l,c,u="info")=>{n(d=>d.find(p=>p.id===l)?d.map(p=>p.id===l?{...p,message:c,type:u,persistent:!0}:p):[...d,{id:l,message:c,type:u,persistent:!0}])},[]),o=_.useCallback(l=>{const c=r.current.get(l);c&&(clearTimeout(c),r.current.delete(l)),n(u=>u.filter(d=>d.id!==l))},[]);return a.jsxs(eK.Provider,{value:{showToast:i,showPersistentToast:s,dismissToast:o},children:[t,a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(l=>a.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Yfe[l.type]}`,children:[Xfe[l.type],a.jsx("span",{className:"text-white text-sm",children:l.message}),a.jsx("button",{onClick:()=>o(l.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-4 h-4"})})]},l.id))})]})}const ey=[{id:"printers",to:"/",icon:Dr,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:wo,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Qr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:sue,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:wk,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:xm,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:rs,labelKey:"nav.projects"},{id:"files",to:"/files",icon:Hl,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:jk,labelKey:"nav.settings"}];function Zfe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return ey.map(e=>e.id)}return ey.map(e=>e.id)}function Jfe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function yT(t){return t.startsWith("ext-")}function tK(){return localStorage.getItem("defaultView")||"/"}function eme(t){localStorage.setItem("defaultView",t)}function tme(){const t=Pc(),e=Cc(),{mode:n,toggleMode:r}=Fm(),{t:i}=Yt(),s=nO(),{user:o,authEnabled:l,logout:c,hasPermission:u}=Rr(),{showToast:d}=kn(),[h,p]=_.useState(!1),[m,b]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[y,x]=_.useState(!1),[v,S]=_.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[N,T]=_.useState(!1),[M,A]=_.useState(!1),[k,R]=_.useState(!1),[C,P]=_.useState(Zfe),[U,F]=_.useState(null),[B,D]=_.useState(null),$=_.useRef(!1),[G,I]=_.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[K,Q]=_.useState(null),{data:se}=nt({queryKey:["version"],queryFn:ae.getVersion,staleTime:1/0}),{data:H}=nt({queryKey:["settings"],queryFn:ae.getSettings,staleTime:300*1e3}),{data:W}=nt({queryKey:["updateCheck"],queryFn:ae.checkForUpdates,enabled:H?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:J}=nt({queryKey:["external-links"],queryFn:ae.getExternalLinks}),{data:ne}=nt({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs,staleTime:30*1e3}),xe=ne?.some(O=>O.show_in_switchbar)??!1,{data:ue}=nt({queryKey:["debugLogging"],queryFn:jg.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:fe}=nt({queryKey:["queue","pending"],queryFn:()=>ae.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),De=fe?.length??0,{data:oe}=nt({queryKey:["pending-uploads","count"],queryFn:fg.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Ne=oe?.count??0,[Fe,ce]=_.useState(null);_.useEffect(()=>{if(!ue?.enabled||!ue.enabled_at){ce(null);return}const O=new Date(ue.enabled_at).getTime(),Z=()=>{ce(Math.floor((Date.now()-O)/1e3))};Z();const me=setInterval(Z,1e3);return()=>clearInterval(me)},[ue?.enabled,ue?.enabled_at]);const Ve=_.useMemo(()=>new Map(ey.map(O=>[O.id,O])),[]),V=_.useMemo(()=>new Map((J||[]).map(O=>[`ext-${O.id}`,O])),[J]),Y=(()=>{const O=[],Z=new Set,me=l&&o?.role==="user";for(const Te of C)me&&Te==="settings"||(Ve.has(Te)||V.has(Te))&&(O.push(Te),Z.add(Te));for(const Te of ey)me&&Te.id==="settings"||Z.has(Te.id)||(O.push(Te.id),Z.add(Te.id));for(const Te of J||[]){const ke=`ext-${Te.id}`;Z.has(ke)||(O.push(ke),Z.add(ke))}return O})(),de=(O,Z)=>{F(Z),O.dataTransfer.effectAllowed="move",O.dataTransfer.setData("text/plain",Z)},q=(O,Z)=>{O.preventDefault(),O.dataTransfer.dropEffect="move",D(Z)},re=()=>{D(null)},X=(O,Z)=>{if(O.preventDefault(),U===null||U===Z){F(null),D(null);return}const me=[...Y],Te=me.indexOf(U),ke=me.indexOf(Z);if(Te===-1||ke===-1){F(null),D(null);return}me.splice(Te,1),me.splice(ke,0,U),P(me),Jfe(me),F(null),D(null)},le=()=>{F(null),D(null)},pe=W?.update_available&&W.latest_version&&W.latest_version!==G,ee=()=>{W?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",W.latest_version),I(W.latest_version))};_.useEffect(()=>{if(!$.current&&e.pathname==="/"){const O=tK();O!=="/"&&($.current=!0,t(O,{replace:!0}))}},[e.pathname,t]),_.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(v))},[v]),_.useEffect(()=>{s&&T(!1)},[e.pathname,s]),_.useEffect(()=>{const O=Z=>{if(!u("printers:control"))return;const me=Z.detail;Q({printer_id:me.printer_id,printer_name:me.printer_name,message:me.message})};return window.addEventListener("plate-not-empty",O),()=>window.removeEventListener("plate-not-empty",O)},[u]);const z=_.useCallback(O=>{const Z=O.target;if(!(Z.tagName==="INPUT"||Z.tagName==="TEXTAREA"||Z.isContentEditable)&&!O.metaKey&&!O.ctrlKey&&!O.altKey){const me=parseInt(O.key);if(me>=1&&me<=Y.length&&me<=9){const Te=Y[me-1];if(O.preventDefault(),yT(Te)){const ke=V.get(Te);if(ke?.open_in_new_tab)window.open(ke.url,"_blank","noopener,noreferrer");else{const Ee=Te.replace("ext-","");t(`/external/${Ee}`)}}else{const ke=Ve.get(Te);ke&&t(ke.to)}return}switch(O.key){case"?":O.preventDefault(),A(!0);break;case"Escape":A(!1);break}}},[t,Y,Ve,V]);return _.useEffect(()=>(document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)),[z]),a.jsxs("div",{className:"flex min-h-screen",children:[s&&a.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[a.jsx("button",{onClick:()=>T(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:a.jsx(she,{className:"w-6 h-6 text-white"})}),a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),s&&N&&a.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>T(!1)}),a.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${s?`fixed inset-y-0 left-0 z-50 w-72 transform ${N?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${v?"w-64":"w-16"}`}`,children:[a.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s||v?"p-4":"p-2"}`,children:a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:s||v?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),a.jsx("nav",{className:"flex-1 p-2",children:a.jsx("ul",{className:"space-y-2",children:Y.map(O=>{if(yT(O)){const me=V.get(O);if(!me)return null;const Te=me.custom_icon?null:Rk(me.icon);return a.jsx("li",{draggable:!0,onDragStart:ke=>de(ke,O),onDragOver:ke=>q(ke,O),onDragLeave:re,onDrop:ke=>X(ke,O),onDragEnd:le,className:`relative ${U===O?"opacity-50":""} ${B===O&&U!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:me.open_in_new_tab?a.jsxs("a",{href:me.url,target:"_blank",rel:"noopener noreferrer",className:`flex items-center ${s||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white`,title:!s&&!v?me.name:void 0,children:[v&&!s&&a.jsx(Zf,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),me.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${me.id}/icon`,alt:"",className:"w-5 h-5 flex-shrink-0"}):Te&&a.jsx(Te,{className:"w-5 h-5 flex-shrink-0"}),(s||v)&&a.jsx("span",{children:me.name})]}):a.jsxs(l0,{to:`/external/${me.id}`,className:({isActive:ke})=>`flex items-center ${s||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ke?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!v?me.name:void 0,children:[v&&!s&&a.jsx(Zf,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),me.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${me.id}/icon`,alt:"",className:"w-5 h-5 flex-shrink-0"}):Te&&a.jsx(Te,{className:"w-5 h-5 flex-shrink-0"}),(s||v)&&a.jsx("span",{children:me.name})]})},O)}else{const me=Ve.get(O);if(!me)return null;const{to:Te,icon:ke,labelKey:Ee}=me,Se=O==="queue"&&De>0,$e=O==="archives"&&Ne>0,Qe=Se?De:$e?Ne:0,Ue=Se||$e;return a.jsx("li",{draggable:!0,onDragStart:be=>de(be,O),onDragOver:be=>q(be,O),onDragLeave:re,onDrop:be=>X(be,O),onDragEnd:le,className:`relative ${U===O?"opacity-50":""} ${B===O&&U!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(l0,{to:Te,className:({isActive:be})=>`flex items-center ${s||v?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${be?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!v?i(Ee):void 0,children:[v&&!s&&a.jsx(Zf,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),a.jsxs("div",{className:"relative",children:[a.jsx(ke,{className:"w-5 h-5 flex-shrink-0"}),Ue&&a.jsx("span",{className:`absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 flex items-center justify-center text-[10px] font-bold rounded-full ${$e?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:Qe>99?"99+":Qe})]}),(s||v)&&a.jsx("span",{children:i(Ee)})]})},O)}})})}),!s&&a.jsx("button",{onClick:()=>S(!v),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(v?"nav.collapseSidebar":"nav.expandSidebar"),children:v?a.jsx(Th,{className:"w-5 h-5"}):a.jsx(Ns,{className:"w-5 h-5"})}),a.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s||v?a.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[xe&&a.jsxs("div",{className:"relative",children:[a.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:a.jsx(sl,{className:"w-5 h-5"})}),k&&a.jsx(aB,{onClose:()=>R(!1)})]}),u("system:read")?a.jsx(l0,{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:a.jsx(yo,{className:"w-5 h-5"})}):a.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:a.jsx(yo,{className:"w-5 h-5"})}),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:a.jsx(Cj,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>A(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:a.jsx(Pj,{className:"w-5 h-5"})}),a.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?a.jsx(rB,{className:"w-5 h-5"}):a.jsx(lS,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.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:a.jsx(Yo,{className:"w-5 h-5"})}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx(Dj,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",se?.version||"..."]}),W?.update_available&&a.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:W.latest_version}),children:[a.jsx(gT,{className:"w-4 h-4"}),a.jsx("span",{children:i("nav.update")})]})]})]}):a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[W?.update_available&&a.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:W.latest_version}),children:a.jsx(gT,{className:"w-5 h-5"})}),xe&&a.jsxs("div",{className:"relative",children:[a.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:a.jsx(sl,{className:"w-5 h-5"})}),k&&a.jsx(aB,{onClose:()=>R(!1)})]}),u("system:read")?a.jsx(l0,{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:a.jsx(yo,{className:"w-5 h-5"})}):a.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:a.jsx(yo,{className:"w-5 h-5"})}),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:a.jsx(Cj,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>A(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:a.jsx(Pj,{className:"w-5 h-5"})}),a.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?a.jsx(rB,{className:"w-5 h-5"}):a.jsx(lS,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.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:a.jsx(Yo,{className:"w-5 h-5"})}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx(Dj,{className:"w-5 h-5"})})]})]})})]}),a.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${s?"mt-14":v?"ml-64":"ml-16"}`,children:[ue?.enabled&&a.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(vk,{className:"w-4 h-4 text-amber-500 animate-pulse"}),a.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),Fe!==null&&a.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(Fe/60),"m ",Fe%60,"s)"]})]}),a.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),pe&&a.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(gT,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{children:i("nav.updateAvailableBanner",{version:W?.latest_version,defaultValue:`Version ${W?.latest_version} is available!`})}),a.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),a.jsx("button",{onClick:ee,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:a.jsx(Lt,{className:"w-4 h-4"})})]}),a.jsx(dle,{})]}),M&&a.jsx(Gfe,{onClose:()=>A(!1),sidebarItems:Y.map(O=>{if(yT(O)){const Z=V.get(O);return Z?{type:"external",label:Z.name}:null}else{const Z=Ve.get(O);return Z?{type:"nav",label:Z.labelKey,labelKey:Z.labelKey}:null}}).filter(Boolean)}),K&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:a.jsx("div",{className:"bg-bambu-dark-secondary border-2 border-yellow-500 rounded-xl shadow-2xl max-w-md w-full animate-in fade-in zoom-in duration-200",children:a.jsxs("div",{className:"p-6 text-center",children:[a.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-500/20 flex items-center justify-center",children:a.jsx("svg",{className:"w-10 h-10 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),a.jsx("h2",{className:"text-xl font-bold text-yellow-400 mb-2",children:i("plateAlert.title")}),a.jsx("p",{className:"text-lg text-white mb-2",children:K.printer_name}),a.jsx("p",{className:"text-bambu-gray mb-6",children:i("plateAlert.message")}),a.jsx("button",{onClick:()=>Q(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")})]})})}),h&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{p(!1),b({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:O=>O.stopPropagation(),children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yo,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("changePassword.title")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{p(!1),b({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Mt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.currentPassword")}),a.jsx("input",{type:"password",value:m.currentPassword,onChange:O=>b({...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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.newPassword")}),a.jsx("input",{type:"password",value:m.newPassword,onChange:O=>b({...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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.confirmPassword")}),a.jsx("input",{type:"password",value:m.confirmPassword,onChange:O=>b({...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&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("changePassword.passwordsDoNotMatch")})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{p(!1),b({currentPassword:"",newPassword:"",confirmPassword:""})},children:i("common.cancel")}),a.jsx(Me,{onClick:async()=>{if(m.newPassword!==m.confirmPassword){d(i("changePassword.passwordsDoNotMatch"),"error");return}if(m.newPassword.length<6){d(i("changePassword.passwordTooShort"),"error");return}x(!0);try{await ae.changePassword(m.currentPassword,m.newPassword),d(i("changePassword.success"),"success"),p(!1),b({currentPassword:"",newPassword:"",confirmPassword:""})}catch(O){const Z=O instanceof Error?O.message:i("changePassword.failed");d(Z,"error")}finally{x(!1)}},disabled:y||!m.currentPassword||!m.newPassword||m.newPassword!==m.confirmPassword||m.newPassword.length<6,children:y?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),i("changePassword.changing")]}):a.jsxs(a.Fragment,{children:[a.jsx(Yo,{className:"w-4 h-4"}),i("changePassword.title")]})})]})]})]})})]})}function nme(t="system"){switch(t){case"us":return"MM/DD/YYYY";case"eu":return"DD/MM/YYYY";case"iso":return"YYYY-MM-DD";case"system":default:{const n=new Date(2e3,11,31).toLocaleDateString();return n.startsWith("12")?"MM/DD/YYYY":n.startsWith("31")?"DD/MM/YYYY":"YYYY-MM-DD"}}}function rme(t="system"){switch(t){case"12h":return"HH:MM AM/PM";case"24h":return"HH:MM";case"system":default:{const n=new Date(2e3,0,1,14,30).toLocaleTimeString();return n.includes("PM")||n.includes("AM")?"HH:MM AM/PM":"HH:MM"}}}function oB(t,e="system"){const n=String(t.getDate()).padStart(2,"0"),r=String(t.getMonth()+1).padStart(2,"0"),i=t.getFullYear();switch(e){case"us":return`${r}/${n}/${i}`;case"eu":return`${n}/${r}/${i}`;case"iso":return`${i}-${r}-${n}`;case"system":default:return t.toLocaleDateString()}}function lB(t,e="system"){const n=t.getHours(),r=String(t.getMinutes()).padStart(2,"0");switch(e){case"12h":{const i=n%12||12,s=n<12?"AM":"PM";return`${i}:${r} ${s}`}case"24h":return`${String(n).padStart(2,"0")}:${r}`;case"system":default:return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}}function Ww(t){for(const e of["/",".","-"]){const n=t.split(e);if(n.length===3)return n}return null}function ime(t,e="system"){if(!t)return null;let n,r,i;try{switch(e){case"us":{const s=Ww(t);if(!s)return null;r=parseInt(s[0],10),n=parseInt(s[1],10),i=parseInt(s[2],10);break}case"eu":{const s=Ww(t);if(!s)return null;n=parseInt(s[0],10),r=parseInt(s[1],10),i=parseInt(s[2],10);break}case"iso":{const s=Ww(t);if(!s)return null;i=parseInt(s[0],10),r=parseInt(s[1],10),n=parseInt(s[2],10);break}case"system":default:{const o=new Date(2e3,11,31).toLocaleDateString(),l=Ww(t);if(l){o.startsWith("12")?(r=parseInt(l[0],10),n=parseInt(l[1],10),i=parseInt(l[2],10)):o.startsWith("31")?(n=parseInt(l[0],10),r=parseInt(l[1],10),i=parseInt(l[2],10)):(i=parseInt(l[0],10),r=parseInt(l[1],10),n=parseInt(l[2],10));break}return null}}return isNaN(n)||isNaN(r)||isNaN(i)||r<1||r>12||n<1||n>31||i<1900||i>2100?null:new Date(i,r-1,n)}catch{return null}}function ame(t){if(!t)return null;try{const e=t.trim().toUpperCase(),n=e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)?$/i);if(n){let i=parseInt(n[1],10);const s=parseInt(n[2],10),o=n[3]?.toUpperCase();return o==="PM"&&i<12&&(i+=12),o==="AM"&&i===12&&(i=0),i<0||i>23||s<0||s>59?null:{hours:i,minutes:s}}const r=e.match(/^(\d{1,2}):(\d{2})$/);if(r){const i=parseInt(r[1],10),s=parseInt(r[2],10);return i<0||i>23||s<0||s>59?null:{hours:i,minutes:s}}return null}catch{return null}}function Fj(t){const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0");return`${e}-${n}-${r}T${i}:${s}`}function N0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Ui(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function Xg(t,e){const n=Ui(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function Yg(t,e="system",n){const r=Ui(t);if(!r)return"";const s=N0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,s)}function sme(t,e="system",n){const i=N0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const rO="181",Dg={ROTATE:0,DOLLY:1,PAN:2},_g={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ome=0,cB=1,lme=2,nK=1,cme=2,mu=3,jh=0,Vs=1,lc=2,Du=0,Rg=1,uB=2,dB=3,hB=4,ume=5,Of=100,dme=101,hme=102,fme=103,mme=104,pme=200,gme=201,bme=202,xme=203,Ij=204,zj=205,yme=206,vme=207,wme=208,_me=209,Sme=210,Nme=211,kme=212,Mme=213,Eme=214,Uj=0,Bj=1,Hj=2,Qg=3,$j=4,Vj=5,Gj=6,qj=7,iO=0,Tme=1,Ame=2,xh=0,Cme=1,Pme=2,jme=3,Dme=4,Rme=5,Ome=6,Lme=7,rK=300,Zg=301,Jg=302,Wj=303,Kj=304,Ok=306,Xj=1e3,ku=1001,Yj=1002,_o=1003,Fme=1004,Kw=1005,il=1006,vT=1007,$f=1008,_c=1009,iK=1010,aK=1011,ty=1012,aO=1013,ym=1014,Mu=1015,Tb=1016,sO=1017,oO=1018,ny=1020,sK=35902,oK=35899,lK=1021,cK=1022,Fl=1023,ry=1026,iy=1027,uK=1028,lO=1029,cO=1030,uO=1031,dO=1033,j1=33776,D1=33777,R1=33778,O1=33779,Qj=35840,Zj=35841,Jj=35842,e3=35843,t3=36196,n3=37492,r3=37496,i3=37808,a3=37809,s3=37810,o3=37811,l3=37812,c3=37813,u3=37814,d3=37815,h3=37816,f3=37817,m3=37818,p3=37819,g3=37820,b3=37821,x3=36492,y3=36494,v3=36495,w3=36283,_3=36284,S3=36285,N3=36286,Ime=3200,zme=3201,dK=0,Ume=1,ih="",mo="srgb",eb="srgb-linear",uS="linear",Tr="srgb",kp=7680,fB=519,Bme=512,Hme=513,$me=514,hK=515,Vme=516,Gme=517,qme=518,Wme=519,mB=35044,pB="300 es",hc=2e3,dS=2001;function fK(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function hS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Kme(){const t=hS("canvas");return t.style.display="block",t}const gB={};function bB(...t){const e="THREE."+t.shift();console.log(e,...t)}function vn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Ei(...t){const e="THREE."+t.shift();console.error(e,...t)}function ay(...t){const e=t.join(" ");e in gB||(gB[e]=!0,vn(...t))}function Xme(t,e,n){return new Promise(function(r,i){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}setTimeout(s,n)})}let Im=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}};const Wa=["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"],L1=Math.PI/180,k3=180/Math.PI;function Gy(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Wa[t&255]+Wa[t>>8&255]+Wa[t>>16&255]+Wa[t>>24&255]+"-"+Wa[e&255]+Wa[e>>8&255]+"-"+Wa[e>>16&15|64]+Wa[e>>24&255]+"-"+Wa[n&63|128]+Wa[n>>8&255]+"-"+Wa[n>>16&255]+Wa[n>>24&255]+Wa[r&255]+Wa[r>>8&255]+Wa[r>>16&255]+Wa[r>>24&255]).toLowerCase()}function Vn(t,e,n){return Math.max(e,Math.min(n,t))}function Yme(t,e){return(t%e+e)%e}function wT(t,e,n){return(1-n)*t+n*e}function Fx(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 Fs(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 Qme={DEG2RAD:L1};let Rn=class mK{constructor(e=0,n=0){mK.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=Vn(this.x,e.x,n.x),this.y=Vn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Vn(this.x,e,n),this.y=Vn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Vn(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(Vn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},vm=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],h=r[i+3],p=s[o+0],m=s[o+1],b=s[o+2],y=s[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h;return}if(l>=1){e[n+0]=p,e[n+1]=m,e[n+2]=b,e[n+3]=y;return}if(h!==y||c!==p||u!==m||d!==b){let x=c*p+u*m+d*b+h*y;x<0&&(p=-p,m=-m,b=-b,y=-y,x=-x);let v=1-l;if(x<.9995){const S=Math.acos(x),N=Math.sin(S);v=Math.sin(v*S)/N,l=Math.sin(l*S)/N,c=c*v+p*l,u=u*v+m*l,d=d*v+b*l,h=h*v+y*l}else{c=c*v+p*l,u=u*v+m*l,d=d*v+b*l,h=h*v+y*l;const S=1/Math.sqrt(c*c+u*u+d*d+h*h);c*=S,u*=S,d*=S,h*=S}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],h=s[o],p=s[o+1],m=s[o+2],b=s[o+3];return e[n]=l*b+d*h+c*m-u*p,e[n+1]=c*b+d*p+u*h-l*m,e[n+2]=u*b+d*m+l*p-c*h,e[n+3]=d*b-l*h-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,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),h=l(s/2),p=c(r/2),m=c(i/2),b=c(s/2);switch(o){case"XYZ":this._x=p*d*h+u*m*b,this._y=u*m*h-p*d*b,this._z=u*d*b+p*m*h,this._w=u*d*h-p*m*b;break;case"YXZ":this._x=p*d*h+u*m*b,this._y=u*m*h-p*d*b,this._z=u*d*b-p*m*h,this._w=u*d*h+p*m*b;break;case"ZXY":this._x=p*d*h-u*m*b,this._y=u*m*h+p*d*b,this._z=u*d*b+p*m*h,this._w=u*d*h-p*m*b;break;case"ZYX":this._x=p*d*h-u*m*b,this._y=u*m*h+p*d*b,this._z=u*d*b-p*m*h,this._w=u*d*h+p*m*b;break;case"YZX":this._x=p*d*h+u*m*b,this._y=u*m*h+p*d*b,this._z=u*d*b-p*m*h,this._w=u*d*h-p*m*b;break;case"XZY":this._x=p*d*h-u*m*b,this._y=u*m*h-p*d*b,this._z=u*d*b+p*m*h,this._w=u*d*h+p*m*b;break;default:vn("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],h=n[10],p=r+l+h;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(s-u)*m,this._z=(o-i)*m}else if(r>l&&r>h){const m=2*Math.sqrt(1+r-l-h);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(s+u)/m}else if(l>h){const m=2*Math.sqrt(1+l-r-h);this._w=(s-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+h-r-l);this._w=(o-i)/m,this._x=(s+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Vn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-s*c,this._y=i*d+o*c+s*l-r*u,this._z=s*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-s*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,s=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,s=-s,o=-o,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+o*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+o*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},pt=class pK{constructor(e=0,n=0,r=0){pK.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(xB.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(xB.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-s*i),h=2*(s*r-o*n);return this.x=n+c*u+o*h-l*d,this.y=r+c*d+l*u-s*h,this.z=i+c*h+s*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Vn(this.x,e.x,n.x),this.y=Vn(this.y,e.y,n.y),this.z=Vn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Vn(this.x,e,n),this.y=Vn(this.y,e,n),this.z=Vn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Vn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-s*l,this.y=s*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return _T.copy(this).projectOnVector(e),this.sub(_T)}reflect(e){return this.sub(_T.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(Vn(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 _T=new pt,xB=new vm;let Ln=class gK{constructor(e,n,r,i,s,o,l,c,u){gK.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u)}set(e,n,r,i,s,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=s,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],h=r[7],p=r[2],m=r[5],b=r[8],y=i[0],x=i[3],v=i[6],S=i[1],N=i[4],T=i[7],M=i[2],A=i[5],k=i[8];return s[0]=o*y+l*S+c*M,s[3]=o*x+l*N+c*A,s[6]=o*v+l*T+c*k,s[1]=u*y+d*S+h*M,s[4]=u*x+d*N+h*A,s[7]=u*v+d*T+h*k,s[2]=p*y+m*S+b*M,s[5]=p*x+m*N+b*A,s[8]=p*v+m*T+b*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],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*s*d+r*l*c+i*s*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=d*o-l*u,p=l*c-d*s,m=u*s-o*c,b=n*h+r*p+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=h*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=p*y,e[4]=(d*n-i*c)*y,e[5]=(i*s-l*n)*y,e[6]=m*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,o,l){const c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(ST.makeScale(e,n)),this}rotate(e){return this.premultiply(ST.makeRotation(-e)),this}translate(e,n){return this.premultiply(ST.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 ST=new Ln,yB=new Ln().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),vB=new Ln().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Zme(){const t={enabled:!0,workingColorSpace:eb,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Tr&&(i.r=Ru(i.r),i.g=Ru(i.g),i.b=Ru(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Tr&&(i.r=Og(i.r),i.g=Og(i.g),i.b=Og(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===ih?uS:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return ay("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return ay("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[eb]:{primaries:e,whitePoint:r,transfer:uS,toXYZ:yB,fromXYZ:vB,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:mo},outputColorSpaceConfig:{drawingBufferColorSpace:mo}},[mo]:{primaries:e,whitePoint:r,transfer:Tr,toXYZ:yB,fromXYZ:vB,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:mo}}}),t}const or=Zme();function Ru(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Og(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Mp,Jme=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{Mp===void 0&&(Mp=hS("canvas")),Mp.width=e.width,Mp.height=e.height;const i=Mp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Mp}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=hS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Ru(s[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Ru(n[r]/255)*255):n[r]=Ru(n[r]);return{data:n,width:e.width,height:e.height}}else return vn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},epe=0,hO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:epe++}),this.uuid=Gy(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?s.push(NT(i[o].image)):s.push(NT(i[o]))}else s=NT(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function NT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Jme.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(vn("Texture: Unable to serialize Texture."),{})}let tpe=0;const kT=new pt;let Gl=class F1 extends Im{constructor(e=F1.DEFAULT_IMAGE,n=F1.DEFAULT_MAPPING,r=ku,i=ku,s=il,o=$f,l=Fl,c=_c,u=F1.DEFAULT_ANISOTROPY,d=ih){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:tpe++}),this.uuid=Gy(),this.name="",this.source=new hO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new Rn(0,0),this.repeat=new Rn(1,1),this.center=new Rn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ln,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(kT).x}get height(){return this.source.getSize(kT).y}get depth(){return this.source.getSize(kT).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){vn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){vn(`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!==rK)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Xj:e.x=e.x-Math.floor(e.x);break;case ku:e.x=e.x<0?0:1;break;case Yj: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 Xj:e.y=e.y-Math.floor(e.y);break;case ku:e.y=e.y<0?0:1;break;case Yj: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++}};Gl.DEFAULT_IMAGE=null;Gl.DEFAULT_MAPPING=rK;Gl.DEFAULT_ANISOTROPY=1;let Bi=class bK{constructor(e=0,n=0,r=0,i=1){bK.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const c=e.elements,u=c[0],d=c[4],h=c[8],p=c[1],m=c[5],b=c[9],y=c[2],x=c[6],v=c[10];if(Math.abs(d-p)<.01&&Math.abs(h-y)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+p)<.1&&Math.abs(h+y)<.1&&Math.abs(b+x)<.1&&Math.abs(u+m+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,T=(m+1)/2,M=(v+1)/2,A=(d+p)/4,k=(h+y)/4,R=(b+x)/4;return N>T&&N>M?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=A/r,s=k/r):T>M?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=A/i,s=R/i):M<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),r=k/s,i=R/s),this.set(r,i,s,n),this}let S=Math.sqrt((x-b)*(x-b)+(h-y)*(h-y)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(h-y)/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=Vn(this.x,e.x,n.x),this.y=Vn(this.y,e.y,n.y),this.z=Vn(this.z,e.z,n.z),this.w=Vn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Vn(this.x,e,n),this.y=Vn(this.y,e,n),this.z=Vn(this.z,e,n),this.w=Vn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Vn(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}},npe=class extends Im{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:il,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 Bi(0,0,e,n),this.scissorTest=!1,this.viewport=new Bi(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new Gl(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=s.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:il,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new hO(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"})}},wm=class extends npe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},xK=class extends Gl{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=_o,this.minFilter=_o,this.wrapR=ku,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},rpe=class extends Gl{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=_o,this.minFilter=_o,this.wrapR=ku,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},yh=class{constructor(e=new pt(1/0,1/0,1/0),n=new pt(-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(kl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(kl.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=kl.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=s.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,kl):kl.fromBufferAttribute(s,o),kl.applyMatrix4(e.matrixWorld),this.expandByPoint(kl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Xw.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Xw.copy(r.boundingBox)),Xw.applyMatrix4(e.matrixWorld),this.union(Xw)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,kl),kl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ix),Yw.subVectors(this.max,Ix),Ep.subVectors(e.a,Ix),Tp.subVectors(e.b,Ix),Ap.subVectors(e.c,Ix),jd.subVectors(Tp,Ep),Dd.subVectors(Ap,Tp),gf.subVectors(Ep,Ap);let n=[0,-jd.z,jd.y,0,-Dd.z,Dd.y,0,-gf.z,gf.y,jd.z,0,-jd.x,Dd.z,0,-Dd.x,gf.z,0,-gf.x,-jd.y,jd.x,0,-Dd.y,Dd.x,0,-gf.y,gf.x,0];return!MT(n,Ep,Tp,Ap,Yw)||(n=[1,0,0,0,1,0,0,0,1],!MT(n,Ep,Tp,Ap,Yw))?!1:(Qw.crossVectors(jd,Dd),n=[Qw.x,Qw.y,Qw.z],MT(n,Ep,Tp,Ap,Yw))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(kl).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)}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 Zc=[new pt,new pt,new pt,new pt,new pt,new pt,new pt,new pt],kl=new pt,Xw=new yh,Ep=new pt,Tp=new pt,Ap=new pt,jd=new pt,Dd=new pt,gf=new pt,Ix=new pt,Yw=new pt,Qw=new pt,bf=new pt;function MT(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){bf.fromArray(t,s);const l=i.x*Math.abs(bf.x)+i.y*Math.abs(bf.y)+i.z*Math.abs(bf.z),c=e.dot(bf),u=n.dot(bf),d=r.dot(bf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const ipe=new yh,zx=new pt,ET=new pt;let Lk=class{constructor(e=new pt,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):ipe.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;zx.subVectors(e,this.center);const n=zx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(zx,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):(ET.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(zx.copy(e.center).add(ET)),this.expandByPoint(zx.copy(e.center).sub(ET))),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 Jc=new pt,TT=new pt,Zw=new pt,Rd=new pt,AT=new pt,Jw=new pt,CT=new pt;let fO=class{constructor(e=new pt,n=new pt(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){TT.copy(e).add(n).multiplyScalar(.5),Zw.copy(n).sub(e).normalize(),Rd.copy(this.origin).sub(TT);const s=e.distanceTo(n)*.5,o=-this.direction.dot(Zw),l=Rd.dot(this.direction),c=-Rd.dot(Zw),u=Rd.lengthSq(),d=Math.abs(1-o*o);let h,p,m,b;if(d>0)if(h=o*c-l,p=o*l-c,b=s*d,h>=0)if(p>=-b)if(p<=b){const y=1/d;h*=y,p*=y,m=h*(h+o*p+2*l)+p*(o*h+p+2*c)+u}else p=s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p=-s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p<=-b?(h=Math.max(0,-(-o*s+l)),p=h>0?-s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u):p<=b?(h=0,p=Math.min(Math.max(-s,-c),s),m=p*(p+2*c)+u):(h=Math.max(0,-(o*s+l)),p=h>0?s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u);else p=o>0?-s:s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(TT).addScaledVector(Zw,p),m}intersectSphere(e,n){Jc.subVectors(e.center,this.origin);const r=Jc.dot(this.direction),i=Jc.dot(Jc)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,h=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?(s=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(s=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),h>=0?(l=(e.min.z-p.z)*h,c=(e.max.z-p.z)*h):(l=(e.max.z-p.z)*h,c=(e.min.z-p.z)*h),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Jc)!==null}intersectTriangle(e,n,r,i,s){AT.subVectors(n,e),Jw.subVectors(r,e),CT.crossVectors(AT,Jw);let o=this.direction.dot(CT),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Rd.subVectors(this.origin,e);const c=l*this.direction.dot(Jw.crossVectors(Rd,Jw));if(c<0)return null;const u=l*this.direction.dot(AT.cross(Rd));if(u<0||c+u>o)return null;const d=-l*Rd.dot(CT);return d<0?null:this.at(d/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Gi=class M3{constructor(e,n,r,i,s,o,l,c,u,d,h,p,m,b,y,x){M3.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u,d,h,p,m,b,y,x)}set(e,n,r,i,s,o,l,c,u,d,h,p,m,b,y,x){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=s,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=h,v[14]=p,v[3]=m,v[7]=b,v[11]=y,v[15]=x,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 M3().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/Cp.setFromMatrixColumn(e,0).length(),s=1/Cp.setFromMatrixColumn(e,1).length(),o=1/Cp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const p=o*d,m=o*h,b=l*d,y=l*h;n[0]=c*d,n[4]=-c*h,n[8]=u,n[1]=m+b*u,n[5]=p-y*u,n[9]=-l*c,n[2]=y-p*u,n[6]=b+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*h,b=u*d,y=u*h;n[0]=p+y*l,n[4]=b*l-m,n[8]=o*u,n[1]=o*h,n[5]=o*d,n[9]=-l,n[2]=m*l-b,n[6]=y+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*h,b=u*d,y=u*h;n[0]=p-y*l,n[4]=-o*h,n[8]=b+m*l,n[1]=m+b*l,n[5]=o*d,n[9]=y-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*h,b=l*d,y=l*h;n[0]=c*d,n[4]=b*u-m,n[8]=p*u+y,n[1]=c*h,n[5]=y*u+p,n[9]=m*u-b,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=y-p*h,n[8]=b*h+m,n[1]=h,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*h+b,n[10]=p-y*h}else if(e.order==="XZY"){const p=o*c,m=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=-h,n[8]=u*d,n[1]=p*h+y,n[5]=o*d,n[9]=m*h-b,n[2]=b*h-m,n[6]=l*d,n[10]=y*h+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(ape,e,spe)}lookAt(e,n,r){const i=this.elements;return co.subVectors(e,n),co.lengthSq()===0&&(co.z=1),co.normalize(),Od.crossVectors(r,co),Od.lengthSq()===0&&(Math.abs(r.z)===1?co.x+=1e-4:co.z+=1e-4,co.normalize(),Od.crossVectors(r,co)),Od.normalize(),e_.crossVectors(co,Od),i[0]=Od.x,i[4]=e_.x,i[8]=co.x,i[1]=Od.y,i[5]=e_.y,i[9]=co.y,i[2]=Od.z,i[6]=e_.z,i[10]=co.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],h=r[5],p=r[9],m=r[13],b=r[2],y=r[6],x=r[10],v=r[14],S=r[3],N=r[7],T=r[11],M=r[15],A=i[0],k=i[4],R=i[8],C=i[12],P=i[1],U=i[5],F=i[9],B=i[13],D=i[2],$=i[6],G=i[10],I=i[14],K=i[3],Q=i[7],se=i[11],H=i[15];return s[0]=o*A+l*P+c*D+u*K,s[4]=o*k+l*U+c*$+u*Q,s[8]=o*R+l*F+c*G+u*se,s[12]=o*C+l*B+c*I+u*H,s[1]=d*A+h*P+p*D+m*K,s[5]=d*k+h*U+p*$+m*Q,s[9]=d*R+h*F+p*G+m*se,s[13]=d*C+h*B+p*I+m*H,s[2]=b*A+y*P+x*D+v*K,s[6]=b*k+y*U+x*$+v*Q,s[10]=b*R+y*F+x*G+v*se,s[14]=b*C+y*B+x*I+v*H,s[3]=S*A+N*P+T*D+M*K,s[7]=S*k+N*U+T*$+M*Q,s[11]=S*R+N*F+T*G+M*se,s[15]=S*C+N*B+T*I+M*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],h=e[6],p=e[10],m=e[14],b=e[3],y=e[7],x=e[11],v=e[15];return b*(+s*c*h-i*u*h-s*l*p+r*u*p+i*l*m-r*c*m)+y*(+n*c*m-n*u*p+s*o*p-i*o*m+i*u*d-s*c*d)+x*(+n*u*h-n*l*m-s*o*h+r*o*m+s*l*d-r*u*d)+v*(-i*l*d-n*c*h+n*l*p+i*o*h-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],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=e[9],p=e[10],m=e[11],b=e[12],y=e[13],x=e[14],v=e[15],S=h*x*u-y*p*u+y*c*m-l*x*m-h*c*v+l*p*v,N=b*p*u-d*x*u-b*c*m+o*x*m+d*c*v-o*p*v,T=d*y*u-b*h*u+b*l*m-o*y*m-d*l*v+o*h*v,M=b*h*c-d*y*c-b*l*p+o*y*p+d*l*x-o*h*x,A=n*S+r*N+i*T+s*M;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/A;return e[0]=S*k,e[1]=(y*p*s-h*x*s-y*i*m+r*x*m+h*i*v-r*p*v)*k,e[2]=(l*x*s-y*c*s+y*i*u-r*x*u-l*i*v+r*c*v)*k,e[3]=(h*c*s-l*p*s-h*i*u+r*p*u+l*i*m-r*c*m)*k,e[4]=N*k,e[5]=(d*x*s-b*p*s+b*i*m-n*x*m-d*i*v+n*p*v)*k,e[6]=(b*c*s-o*x*s-b*i*u+n*x*u+o*i*v-n*c*v)*k,e[7]=(o*p*s-d*c*s+d*i*u-n*p*u-o*i*m+n*c*m)*k,e[8]=T*k,e[9]=(b*h*s-d*y*s-b*r*m+n*y*m+d*r*v-n*h*v)*k,e[10]=(o*y*s-b*l*s+b*r*u-n*y*u-o*r*v+n*l*v)*k,e[11]=(d*l*s-o*h*s-d*r*u+n*h*u+o*r*m-n*l*m)*k,e[12]=M*k,e[13]=(d*y*i-b*h*i+b*r*p-n*y*p-d*r*x+n*h*x)*k,e[14]=(b*l*i-o*y*i-b*r*c+n*y*c+o*r*x-n*l*x)*k,e[15]=(o*h*i-d*l*i+d*r*c-n*h*c-o*r*p+n*l*p)*k,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,o=e.x,l=e.y,c=e.z,u=s*o,d=s*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,o=n._y,l=n._z,c=n._w,u=s+s,d=o+o,h=l+l,p=s*u,m=s*d,b=s*h,y=o*d,x=o*h,v=l*h,S=c*u,N=c*d,T=c*h,M=r.x,A=r.y,k=r.z;return i[0]=(1-(y+v))*M,i[1]=(m+T)*M,i[2]=(b-N)*M,i[3]=0,i[4]=(m-T)*A,i[5]=(1-(p+v))*A,i[6]=(x+S)*A,i[7]=0,i[8]=(b+N)*k,i[9]=(x-S)*k,i[10]=(1-(p+y))*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 s=Cp.set(i[0],i[1],i[2]).length();const o=Cp.set(i[4],i[5],i[6]).length(),l=Cp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Ml.copy(this);const u=1/s,d=1/o,h=1/l;return Ml.elements[0]*=u,Ml.elements[1]*=u,Ml.elements[2]*=u,Ml.elements[4]*=d,Ml.elements[5]*=d,Ml.elements[6]*=d,Ml.elements[8]*=h,Ml.elements[9]*=h,Ml.elements[10]*=h,n.setFromRotationMatrix(Ml),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=hc,c=!1){const u=this.elements,d=2*s/(n-e),h=2*s/(r-i),p=(n+e)/(n-e),m=(r+i)/(r-i);let b,y;if(c)b=s/(o-s),y=o*s/(o-s);else if(l===hc)b=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(l===dS)b=-o/(o-s),y=-o*s/(o-s);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]=h,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=b,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=hc,c=!1){const u=this.elements,d=2/(n-e),h=2/(r-i),p=-(n+e)/(n-e),m=-(r+i)/(r-i);let b,y;if(c)b=1/(o-s),y=o/(o-s);else if(l===hc)b=-2/(o-s),y=-(o+s)/(o-s);else if(l===dS)b=-1/(o-s),y=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=p,u[1]=0,u[5]=h,u[9]=0,u[13]=m,u[2]=0,u[6]=0,u[10]=b,u[14]=y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const Cp=new pt,Ml=new Gi,ape=new pt(0,0,0),spe=new pt(1,1,1),Od=new pt,e_=new pt,co=new pt,wB=new Gi,_B=new vm;let Dh=class yK{constructor(e=0,n=0,r=0,i=yK.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],h=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Vn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Vn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Vn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Vn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Vn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-Vn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:vn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return wB.makeRotationFromQuaternion(e),this.setFromRotationMatrix(wB,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return _B.setFromEuler(this),this.setFromQuaternion(_B,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}};Dh.DEFAULT_ORDER="XYZ";let vK=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}},ope=0;const SB=new pt,Pp=new vm,eu=new Gi,t_=new pt,Ux=new pt,lpe=new pt,cpe=new vm,NB=new pt(1,0,0),kB=new pt(0,1,0),MB=new pt(0,0,1),EB={type:"added"},upe={type:"removed"},jp={type:"childadded",child:null},PT={type:"childremoved",child:null};let Ao=class I1 extends Im{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ope++}),this.uuid=Gy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=I1.DEFAULT_UP.clone();const e=new pt,n=new Dh,r=new vm,i=new pt(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Gi},normalMatrix:{value:new Ln}}),this.matrix=new Gi,this.matrixWorld=new Gi,this.matrixAutoUpdate=I1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=I1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new vK,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 Pp.setFromAxisAngle(e,n),this.quaternion.multiply(Pp),this}rotateOnWorldAxis(e,n){return Pp.setFromAxisAngle(e,n),this.quaternion.premultiply(Pp),this}rotateX(e){return this.rotateOnAxis(NB,e)}rotateY(e){return this.rotateOnAxis(kB,e)}rotateZ(e){return this.rotateOnAxis(MB,e)}translateOnAxis(e,n){return SB.copy(e).applyQuaternion(this.quaternion),this.position.add(SB.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(NB,e)}translateY(e){return this.translateOnAxis(kB,e)}translateZ(e){return this.translateOnAxis(MB,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?t_.copy(e):t_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Ux.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?eu.lookAt(Ux,t_,this.up):eu.lookAt(t_,Ux,this.up),this.quaternion.setFromRotationMatrix(eu),i&&(eu.extractRotation(i.matrixWorld),Pp.setFromRotationMatrix(eu),this.quaternion.premultiply(Pp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Ei("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(EB),jp.child=e,this.dispatchEvent(jp),jp.child=null):Ei("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(upe),PT.child=e,this.dispatchEvent(PT),PT.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),eu.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),eu.multiply(e.parent.matrixWorld)),e.applyMatrix4(eu),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(EB),jp.child=e,this.dispatchEvent(jp),jp.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ux,e,lpe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ux,cpe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const h=c[u];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(s(e.materials,this.material[c]));i.material=l}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(s(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),h=o(e.shapes),p=o(e.skeletons),m=o(e.animations),b=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),h.length>0&&(r.shapes=h),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),b.length>0&&(r.nodes=b)}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}};Ao.DEFAULT_UP=new pt(0,1,0);Ao.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ao.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const El=new pt,tu=new pt,jT=new pt,nu=new pt,Dp=new pt,Rp=new pt,TB=new pt,DT=new pt,RT=new pt,OT=new pt,LT=new Bi,FT=new Bi,IT=new Bi;let Bx=class mg{constructor(e=new pt,n=new pt,r=new pt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),El.subVectors(e,n),i.cross(El);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){El.subVectors(i,n),tu.subVectors(r,n),jT.subVectors(e,n);const o=El.dot(El),l=El.dot(tu),c=El.dot(jT),u=tu.dot(tu),d=tu.dot(jT),h=o*u-l*l;if(h===0)return s.set(0,0,0),null;const p=1/h,m=(u*c-l*d)*p,b=(o*d-l*c)*p;return s.set(1-m-b,b,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,nu)===null?!1:nu.x>=0&&nu.y>=0&&nu.x+nu.y<=1}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,nu)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,nu.x),c.addScaledVector(o,nu.y),c.addScaledVector(l,nu.z),c)}static getInterpolatedAttribute(e,n,r,i,s,o){return LT.setScalar(0),FT.setScalar(0),IT.setScalar(0),LT.fromBufferAttribute(e,n),FT.fromBufferAttribute(e,r),IT.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(LT,s.x),o.addScaledVector(FT,s.y),o.addScaledVector(IT,s.z),o}static isFrontFacing(e,n,r,i){return El.subVectors(r,n),tu.subVectors(e,n),El.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 El.subVectors(this.c,this.b),tu.subVectors(this.a,this.b),El.cross(tu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return mg.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return mg.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return mg.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return mg.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return mg.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let o,l;Dp.subVectors(i,r),Rp.subVectors(s,r),DT.subVectors(e,r);const c=Dp.dot(DT),u=Rp.dot(DT);if(c<=0&&u<=0)return n.copy(r);RT.subVectors(e,i);const d=Dp.dot(RT),h=Rp.dot(RT);if(d>=0&&h<=d)return n.copy(i);const p=c*h-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Dp,o);OT.subVectors(e,s);const m=Dp.dot(OT),b=Rp.dot(OT);if(b>=0&&m<=b)return n.copy(s);const y=m*u-c*b;if(y<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Rp,l);const x=d*b-m*h;if(x<=0&&h-d>=0&&m-b>=0)return TB.subVectors(s,i),l=(h-d)/(h-d+(m-b)),n.copy(i).addScaledVector(TB,l);const v=1/(x+y+p);return o=y*v,l=p*v,n.copy(r).addScaledVector(Dp,o).addScaledVector(Rp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const wK={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},Ld={h:0,s:0,l:0},n_={h:0,s:0,l:0};function zT(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 Fn=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=mo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,or.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=or.workingColorSpace){return this.r=e,this.g=n,this.b=r,or.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=or.workingColorSpace){if(e=Yme(e,1),n=Vn(n,0,1),r=Vn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;this.r=zT(o,s,e+1/3),this.g=zT(o,s,e),this.b=zT(o,s,e-1/3)}return or.colorSpaceToWorking(this,i),this}setStyle(e,n=mo){function r(s){s!==void 0&&parseFloat(s)<1&&vn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:vn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,16),n);vn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=mo){const r=wK[e.toLowerCase()];return r!==void 0?this.setHex(r,n):vn("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=Ru(e.r),this.g=Ru(e.g),this.b=Ru(e.b),this}copyLinearToSRGB(e){return this.r=Og(e.r),this.g=Og(e.g),this.b=Og(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=mo){return or.workingToColorSpace(Ka.copy(this),e),Math.round(Vn(Ka.r*255,0,255))*65536+Math.round(Vn(Ka.g*255,0,255))*256+Math.round(Vn(Ka.b*255,0,255))}getHexString(e=mo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=or.workingColorSpace){or.workingToColorSpace(Ka.copy(this),n);const r=Ka.r,i=Ka.g,s=Ka.b,o=Math.max(r,i,s),l=Math.min(r,i,s);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const h=o-l;switch(u=d<=.5?h/(o+l):h/(2-o-l),o){case r:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-r)/h+2;break;case s:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=or.workingColorSpace){return or.workingToColorSpace(Ka.copy(this),n),e.r=Ka.r,e.g=Ka.g,e.b=Ka.b,e}getStyle(e=mo){or.workingToColorSpace(Ka.copy(this),e);const n=Ka.r,r=Ka.g,i=Ka.b;return e!==mo?`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(Ld),this.setHSL(Ld.h+e,Ld.s+n,Ld.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(Ld),e.getHSL(n_);const r=wT(Ld.h,n_.h,n),i=wT(Ld.s,n_.s,n),s=wT(Ld.l,n_.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Ka=new Fn;Fn.NAMES=wK;let dpe=0,Ab=class extends Im{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:dpe++}),this.uuid=Gy(),this.name="",this.type="Material",this.blending=Rg,this.side=jh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ij,this.blendDst=zj,this.blendEquation=Of,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Fn(0,0,0),this.blendAlpha=0,this.depthFunc=Qg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=fB,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kp,this.stencilZFail=kp,this.stencilZPass=kp,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){vn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){vn(`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!==Rg&&(r.blending=this.blending),this.side!==jh&&(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!==Ij&&(r.blendSrc=this.blendSrc),this.blendDst!==zj&&(r.blendDst=this.blendDst),this.blendEquation!==Of&&(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!==fB&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==kp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==kp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const l in s){const c=s[l];delete c.metadata,o.push(c)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},mO=class extends Ab{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Fn(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 Dh,this.combine=iO,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 Oi=new pt,r_=new Rn;let hpe=0,_s=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:hpe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=mB,this.updateRanges=[],this.gpuType=Mu,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)r_.fromBufferAttribute(this,n),r_.applyMatrix3(e),this.setXY(n,r_.x,r_.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=Fx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Fs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Fx(n,this.array)),n}setX(e,n){return this.normalized&&(n=Fs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Fx(n,this.array)),n}setY(e,n){return this.normalized&&(n=Fs(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=Fx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Fs(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=Fx(n,this.array)),n}setW(e,n){return this.normalized&&(n=Fs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Fs(n,this.array),r=Fs(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=Fs(n,this.array),r=Fs(r,this.array),i=Fs(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Fs(n,this.array),r=Fs(r,this.array),i=Fs(i,this.array),s=Fs(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==mB&&(e.usage=this.usage),e}},_K=class extends _s{constructor(e,n,r){super(new Uint16Array(e),n,r)}},SK=class extends _s{constructor(e,n,r){super(new Uint32Array(e),n,r)}},So=class extends _s{constructor(e,n,r){super(new Float32Array(e),n,r)}},fpe=0;const Bo=new Gi,UT=new Ao,Op=new pt,uo=new yh,Hx=new yh,ma=new pt;let dl=class NK extends Im{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:fpe++}),this.uuid=Gy(),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(fK(e)?SK:_K)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new Ln().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Bo.makeRotationFromQuaternion(e),this.applyMatrix4(Bo),this}rotateX(e){return Bo.makeRotationX(e),this.applyMatrix4(Bo),this}rotateY(e){return Bo.makeRotationY(e),this.applyMatrix4(Bo),this}rotateZ(e){return Bo.makeRotationZ(e),this.applyMatrix4(Bo),this}translate(e,n,r){return Bo.makeTranslation(e,n,r),this.applyMatrix4(Bo),this}scale(e,n,r){return Bo.makeScale(e,n,r),this.applyMatrix4(Bo),this}lookAt(e){return UT.lookAt(e),UT.updateMatrix(),this.applyMatrix4(UT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Op).negate(),this.translate(Op.x,Op.y,Op.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new So(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const s=e[i];n.setXYZ(i,s.x,s.y,s.z||0)}e.length>n.count&&vn("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 yh);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ei("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new pt(-1/0,-1/0,-1/0),new pt(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];uo.setFromBufferAttribute(s),this.morphTargetsRelative?(ma.addVectors(this.boundingBox.min,uo.min),this.boundingBox.expandByPoint(ma),ma.addVectors(this.boundingBox.max,uo.max),this.boundingBox.expandByPoint(ma)):(this.boundingBox.expandByPoint(uo.min),this.boundingBox.expandByPoint(uo.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ei('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 Lk);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ei("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new pt,1/0);return}if(e){const r=this.boundingSphere.center;if(uo.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];Hx.setFromBufferAttribute(l),this.morphTargetsRelative?(ma.addVectors(uo.min,Hx.min),uo.expandByPoint(ma),ma.addVectors(uo.max,Hx.max),uo.expandByPoint(ma)):(uo.expandByPoint(Hx.min),uo.expandByPoint(Hx.max))}uo.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)ma.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(ma));if(n)for(let s=0,o=n.length;s<o;s++){const l=n[s],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)ma.fromBufferAttribute(l,u),c&&(Op.fromBufferAttribute(e,u),ma.add(Op)),i=Math.max(i,r.distanceToSquared(ma))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ei('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){Ei("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new _s(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let R=0;R<r.count;R++)l[R]=new pt,c[R]=new pt;const u=new pt,d=new pt,h=new pt,p=new Rn,m=new Rn,b=new Rn,y=new pt,x=new pt;function v(R,C,P){u.fromBufferAttribute(r,R),d.fromBufferAttribute(r,C),h.fromBufferAttribute(r,P),p.fromBufferAttribute(s,R),m.fromBufferAttribute(s,C),b.fromBufferAttribute(s,P),d.sub(u),h.sub(u),m.sub(p),b.sub(p);const U=1/(m.x*b.y-b.x*m.y);isFinite(U)&&(y.copy(d).multiplyScalar(b.y).addScaledVector(h,-m.y).multiplyScalar(U),x.copy(h).multiplyScalar(m.x).addScaledVector(d,-b.x).multiplyScalar(U),l[R].add(y),l[C].add(y),l[P].add(y),c[R].add(x),c[C].add(x),c[P].add(x))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let R=0,C=S.length;R<C;++R){const P=S[R],U=P.start,F=P.count;for(let B=U,D=U+F;B<D;B+=3)v(e.getX(B+0),e.getX(B+1),e.getX(B+2))}const N=new pt,T=new pt,M=new pt,A=new pt;function k(R){M.fromBufferAttribute(i,R),A.copy(M);const C=l[R];N.copy(C),N.sub(M.multiplyScalar(M.dot(C))).normalize(),T.crossVectors(A,C);const U=T.dot(c[R])<0?-1:1;o.setXYZW(R,N.x,N.y,N.z,U)}for(let R=0,C=S.length;R<C;++R){const P=S[R],U=P.start,F=P.count;for(let B=U,D=U+F;B<D;B+=3)k(e.getX(B+0)),k(e.getX(B+1)),k(e.getX(B+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 _s(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 pt,s=new pt,o=new pt,l=new pt,c=new pt,u=new pt,d=new pt,h=new pt;if(e)for(let p=0,m=e.count;p<m;p+=3){const b=e.getX(p+0),y=e.getX(p+1),x=e.getX(p+2);i.fromBufferAttribute(n,b),s.fromBufferAttribute(n,y),o.fromBufferAttribute(n,x),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),s.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),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++)ma.fromBufferAttribute(e,n),ma.normalize(),e.setXYZ(n,ma.x,ma.y,ma.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,h=l.normalized,p=new u.constructor(c.length*d);let m=0,b=0;for(let y=0,x=c.length;y<x;y++){l.isInterleavedBufferAttribute?m=c[y]*l.data.stride+l.offset:m=c[y]*d;for(let v=0;v<d;v++)p[b++]=u[m++]}return new _s(p,d,h)}if(this.index===null)return vn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new NK,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const s=this.morphAttributes;for(const l in s){const c=[],u=s[l];for(let d=0,h=u.length;d<h;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 s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let h=0,p=u.length;h<p;h++){const m=u[h];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],h=s[u];for(let p=0,m=h.length;p<m;p++)d.push(h[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 h=o[u];this.addGroup(h.start,h.count,h.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 AB=new Gi,xf=new fO,i_=new Lk,CB=new pt,a_=new pt,s_=new pt,o_=new pt,BT=new pt,l_=new pt,PB=new pt,c_=new pt;let hl=class extends Ao{constructor(e=new dl,n=new mO){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(s&&l){l_.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],h=s[c];d!==0&&(BT.fromBufferAttribute(h,e),o?l_.addScaledVector(BT,d):l_.addScaledVector(BT.sub(n),d))}n.add(l_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),i_.copy(r.boundingSphere),i_.applyMatrix4(s),xf.copy(e.ray).recast(e.near),!(i_.containsPoint(xf.origin)===!1&&(xf.intersectSphere(i_,CB)===null||xf.origin.distanceToSquared(CB)>(e.far-e.near)**2))&&(AB.copy(s).invert(),xf.copy(e.ray).applyMatrix4(AB),!(r.boundingBox!==null&&xf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,xf)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,p=s.groups,m=s.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,y=p.length;b<y;b++){const x=p[b],v=o[x.materialIndex],S=Math.max(x.start,m.start),N=Math.min(l.count,Math.min(x.start+x.count,m.start+m.count));for(let T=S,M=N;T<M;T+=3){const A=l.getX(T),k=l.getX(T+1),R=l.getX(T+2);i=u_(this,v,e,r,u,d,h,A,k,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let x=b,v=y;x<v;x+=3){const S=l.getX(x),N=l.getX(x+1),T=l.getX(x+2);i=u_(this,o,e,r,u,d,h,S,N,T),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,y=p.length;b<y;b++){const x=p[b],v=o[x.materialIndex],S=Math.max(x.start,m.start),N=Math.min(c.count,Math.min(x.start+x.count,m.start+m.count));for(let T=S,M=N;T<M;T+=3){const A=T,k=T+1,R=T+2;i=u_(this,v,e,r,u,d,h,A,k,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let x=b,v=y;x<v;x+=3){const S=x,N=x+1,T=x+2;i=u_(this,o,e,r,u,d,h,S,N,T),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}};function mpe(t,e,n,r,i,s,o,l){let c;if(e.side===Vs?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===jh,l),c===null)return null;c_.copy(l),c_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(c_);return u<n.near||u>n.far?null:{distance:u,point:c_.clone(),object:t}}function u_(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,a_),t.getVertexPosition(c,s_),t.getVertexPosition(u,o_);const d=mpe(t,e,n,r,a_,s_,o_,PB);if(d){const h=new pt;Bx.getBarycoord(PB,a_,s_,o_,h),i&&(d.uv=Bx.getInterpolatedAttribute(i,l,c,u,h,new Rn)),s&&(d.uv1=Bx.getInterpolatedAttribute(s,l,c,u,h,new Rn)),o&&(d.normal=Bx.getInterpolatedAttribute(o,l,c,u,h,new pt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:c,c:u,normal:new pt,materialIndex:0};Bx.getNormal(a_,s_,o_,p.normal),d.face=p,d.barycoord=h}return d}let pO=class kK extends dl{constructor(e=1,n=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const l=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],u=[],d=[],h=[];let p=0,m=0;b("z","y","x",-1,-1,r,n,e,o,s,0),b("z","y","x",1,-1,r,n,-e,o,s,1),b("x","z","y",1,1,e,r,n,i,o,2),b("x","z","y",1,-1,e,r,-n,i,o,3),b("x","y","z",1,-1,e,n,r,i,s,4),b("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new So(u,3)),this.setAttribute("normal",new So(d,3)),this.setAttribute("uv",new So(h,2));function b(y,x,v,S,N,T,M,A,k,R,C){const P=T/k,U=M/R,F=T/2,B=M/2,D=A/2,$=k+1,G=R+1;let I=0,K=0;const Q=new pt;for(let se=0;se<G;se++){const H=se*U-B;for(let W=0;W<$;W++){const J=W*P-F;Q[y]=J*S,Q[x]=H*N,Q[v]=D,u.push(Q.x,Q.y,Q.z),Q[y]=0,Q[x]=0,Q[v]=A>0?1:-1,d.push(Q.x,Q.y,Q.z),h.push(W/k),h.push(1-se/R),I+=1}}for(let se=0;se<R;se++)for(let H=0;H<k;H++){const W=p+H+$*se,J=p+H+$*(se+1),ne=p+(H+1)+$*(se+1),xe=p+(H+1)+$*se;c.push(W,J,xe),c.push(J,ne,xe),K+=6}l.addGroup(m,K,C),m+=K,p+=I}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kK(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function tb(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?(vn("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 ps(t){const e={};for(let n=0;n<t.length;n++){const r=tb(t[n]);for(const i in r)e[i]=r[i]}return e}function ppe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function MK(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:or.workingColorSpace}const gpe={clone:tb,merge:ps};var bpe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,xpe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let Wu=class extends Ab{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=bpe,this.fragmentShader=xpe,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=tb(e.uniforms),this.uniformsGroups=ppe(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}},EK=class extends Ao{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gi,this.projectionMatrix=new Gi,this.projectionMatrixInverse=new Gi,this.coordinateSystem=hc,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 Fd=new pt,jB=new Rn,DB=new Rn;let Jo=class extends EK{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=k3*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(L1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return k3*2*Math.atan(Math.tan(L1*.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){Fd.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Fd.x,Fd.y).multiplyScalar(-e/Fd.z),Fd.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Fd.x,Fd.y).multiplyScalar(-e/Fd.z)}getViewSize(e,n){return this.getViewBounds(e,jB,DB),n.subVectors(DB,jB)}setViewOffset(e,n,r,i,s,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(L1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const Lp=-90,Fp=1;let ype=class extends Ao{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Jo(Lp,Fp,e,n);i.layers=this.layers,this.add(i);const s=new Jo(Lp,Fp,e,n);s.layers=this.layers,this.add(s);const o=new Jo(Lp,Fp,e,n);o.layers=this.layers,this.add(o);const l=new Jo(Lp,Fp,e,n);l.layers=this.layers,this.add(l);const c=new Jo(Lp,Fp,e,n);c.layers=this.layers,this.add(c);const u=new Jo(Lp,Fp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const u of n)this.remove(u);if(e===hc)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===dS)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,l,c,u,d]=this.children,h=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(h,p,m),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}},TK=class extends Gl{constructor(e=[],n=Zg,r,i,s,o,l,c,u,d){super(e,n,r,i,s,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},vpe=class extends wm{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 TK(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new pO(5,5,5),s=new Wu({name:"CubemapFromEquirect",uniforms:tb(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Vs,blending:Du});s.uniforms.tEquirect.value=n;const o=new hl(i,s),l=n.minFilter;return n.minFilter===$f&&(n.minFilter=il),new ype(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(s)}},Sg=class extends Ao{constructor(){super(),this.isGroup=!0,this.type="Group"}};const wpe={type:"move"};let HT=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Sg,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 Sg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new pt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new pt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Sg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new pt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new pt),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const x=n.getJointPose(y,r),v=this._getHandJoint(u,y);x!==null&&(v.matrix.fromArray(x.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=x.radius),v.visible=x!==null}const d=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],p=d.position.distanceTo(h.position),m=.02,b=.005;u.inputState.pinching&&p>m+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(wpe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Sg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},_pe=class extends Ao{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 Dh,this.environmentIntensity=1,this.environmentRotation=new Dh,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}},Spe=class extends Gl{constructor(e=null,n=1,r=1,i,s,o,l,c,u=_o,d=_o,h,p){super(null,o,l,c,u,d,i,s,h,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const $T=new pt,Npe=new pt,kpe=new Ln;let Xd=class{constructor(e=new pt(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=$T.subVectors(r,n).cross(Npe.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($T),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||kpe.getNormalMatrix(e),i=this.coplanarPoint($T).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const yf=new Lk,Mpe=new Rn(.5,.5),d_=new pt;let gO=class{constructor(e=new Xd,n=new Xd,r=new Xd,i=new Xd,s=new Xd,o=new Xd){this.planes=[e,n,r,i,s,o]}set(e,n,r,i,s,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(s),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=hc,r=!1){const i=this.planes,s=e.elements,o=s[0],l=s[1],c=s[2],u=s[3],d=s[4],h=s[5],p=s[6],m=s[7],b=s[8],y=s[9],x=s[10],v=s[11],S=s[12],N=s[13],T=s[14],M=s[15];if(i[0].setComponents(u-o,m-d,v-b,M-S).normalize(),i[1].setComponents(u+o,m+d,v+b,M+S).normalize(),i[2].setComponents(u+l,m+h,v+y,M+N).normalize(),i[3].setComponents(u-l,m-h,v-y,M-N).normalize(),r)i[4].setComponents(c,p,x,T).normalize(),i[5].setComponents(u-c,m-p,v-x,M-T).normalize();else if(i[4].setComponents(u-c,m-p,v-x,M-T).normalize(),n===hc)i[5].setComponents(u+c,m+p,v+x,M+T).normalize();else if(n===dS)i[5].setComponents(c,p,x,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(),yf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),yf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(yf)}intersectsSprite(e){yf.center.set(0,0,0);const n=Mpe.distanceTo(e.center);return yf.radius=.7071067811865476+n,yf.applyMatrix4(e.matrixWorld),this.intersectsSphere(yf)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(d_.x=i.normal.x>0?e.max.x:e.min.x,d_.y=i.normal.y>0?e.max.y:e.min.y,d_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(d_)<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)}},AK=class extends Ab{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Fn(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 fS=new pt,mS=new pt,RB=new Gi,$x=new fO,h_=new Lk,VT=new pt,OB=new pt;let Epe=class extends Ao{constructor(e=new dl,n=new AK){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,s=n.count;i<s;i++)fS.fromBufferAttribute(n,i-1),mS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=fS.distanceTo(mS);e.setAttribute("lineDistance",new So(r,1))}else vn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),h_.copy(r.boundingSphere),h_.applyMatrix4(i),h_.radius+=s,e.ray.intersectsSphere(h_)===!1)return;RB.copy(i).invert(),$x.copy(e.ray).applyMatrix4(RB);const l=s/((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),b=Math.min(d.count,o.start+o.count);for(let y=m,x=b-1;y<x;y+=u){const v=d.getX(y),S=d.getX(y+1),N=f_(this,e,$x,c,v,S,y);N&&n.push(N)}if(this.isLineLoop){const y=d.getX(b-1),x=d.getX(m),v=f_(this,e,$x,c,y,x,b-1);v&&n.push(v)}}else{const m=Math.max(0,o.start),b=Math.min(p.count,o.start+o.count);for(let y=m,x=b-1;y<x;y+=u){const v=f_(this,e,$x,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=f_(this,e,$x,c,b-1,m,b-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}};function f_(t,e,n,r,i,s,o){const l=t.geometry.attributes.position;if(fS.fromBufferAttribute(l,i),mS.fromBufferAttribute(l,s),n.distanceSqToSegment(fS,mS,VT,OB)>r)return;VT.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(VT);if(!(u<e.near||u>e.far))return{distance:u,point:OB.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const LB=new pt,FB=new pt;let Tpe=class extends Epe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,s=n.count;i<s;i+=2)LB.fromBufferAttribute(n,i),FB.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+LB.distanceTo(FB);e.setAttribute("lineDistance",new So(r,1))}else vn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},CK=class extends Gl{constructor(e,n,r=ym,i,s,o,l=_o,c=_o,u,d=ry,h=1){if(d!==ry&&d!==iy)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:n,depth:h};super(p,i,s,o,l,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new hO(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 PK extends Gl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let bO=class jK extends dl{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,h=e/l,p=n/c,m=[],b=[],y=[],x=[];for(let v=0;v<d;v++){const S=v*p-o;for(let N=0;N<u;N++){const T=N*h-s;b.push(T,-S,0),y.push(0,0,1),x.push(N/l),x.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const N=S+u*v,T=S+u*(v+1),M=S+1+u*(v+1),A=S+1+u*v;m.push(N,T,A),m.push(T,M,A)}this.setIndex(m),this.setAttribute("position",new So(b,3)),this.setAttribute("normal",new So(y,3)),this.setAttribute("uv",new So(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new jK(e.width,e.height,e.widthSegments,e.heightSegments)}};class DK extends Ab{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Fn(16777215),this.specular=new Fn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Fn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=dK,this.normalScale=new Rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Dh,this.combine=iO,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 Ape=class extends Ab{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ime,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Cpe=class extends Ab{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 IB={enabled:!1,files:{},add:function(t,e){this.enabled!==!1&&(this.files[t]=e)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class Ppe{constructor(e,n,r){const i=this;let s=!1,o=0,l=0,c;const u=[];this.onStart=void 0,this.onLoad=e,this.onProgress=n,this.onError=r,this._abortController=null,this.itemStart=function(d){l++,s===!1&&i.onStart!==void 0&&i.onStart(d,o,l),s=!0},this.itemEnd=function(d){o++,i.onProgress!==void 0&&i.onProgress(d,o,l),o===l&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(d){i.onError!==void 0&&i.onError(d)},this.resolveURL=function(d){return c?c(d):d},this.setURLModifier=function(d){return c=d,this},this.addHandler=function(d,h){return u.push(d,h),this},this.removeHandler=function(d){const h=u.indexOf(d);return h!==-1&&u.splice(h,2),this},this.getHandler=function(d){for(let h=0,p=u.length;h<p;h+=2){const m=u[h],b=u[h+1];if(m.global&&(m.lastIndex=0),m.test(d))return b}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const jpe=new Ppe;class xO{constructor(e){this.manager=e!==void 0?e:jpe,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,n){const r=this;return new Promise(function(i,s){r.load(e,i,n,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}xO.DEFAULT_MATERIAL_NAME="__DEFAULT";const ru={};class Dpe extends Error{constructor(e,n){super(e),this.response=n}}class Rpe extends xO{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,n,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=IB.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{n&&n(s),this.manager.itemEnd(e)},0),s;if(ru[e]!==void 0){ru[e].push({onLoad:n,onProgress:r,onError:i});return}ru[e]=[],ru[e].push({onLoad:n,onProgress:r,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),l=this.mimeType,c=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&vn("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;const d=ru[e],h=u.body.getReader(),p=u.headers.get("X-File-Size")||u.headers.get("Content-Length"),m=p?parseInt(p):0,b=m!==0;let y=0;const x=new ReadableStream({start(v){S();function S(){h.read().then(({done:N,value:T})=>{if(N)v.close();else{y+=T.byteLength;const M=new ProgressEvent("progress",{lengthComputable:b,loaded:y,total:m});for(let A=0,k=d.length;A<k;A++){const R=d[A];R.onProgress&&R.onProgress(M)}v.enqueue(T),S()}},N=>{v.error(N)})}}});return new Response(x)}else throw new Dpe(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(c){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(d=>new DOMParser().parseFromString(d,l));case"json":return u.json();default:if(l==="")return u.text();{const h=/charset="?([^;"\s]*)"?/i.exec(l),p=h&&h[1]?h[1].toLowerCase():void 0,m=new TextDecoder(p);return u.arrayBuffer().then(b=>m.decode(b))}}}).then(u=>{IB.add(`file:${e}`,u);const d=ru[e];delete ru[e];for(let h=0,p=d.length;h<p;h++){const m=d[h];m.onLoad&&m.onLoad(u)}}).catch(u=>{const d=ru[e];if(d===void 0)throw this.manager.itemError(e),u;delete ru[e];for(let h=0,p=d.length;h<p;h++){const m=d[h];m.onError&&m.onError(u)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let RK=class extends Ao{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Fn(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 GT=new Gi,zB=new pt,UB=new pt;let Ope=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Rn(512,512),this.mapType=_c,this.map=null,this.mapPass=null,this.matrix=new Gi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new gO,this._frameExtents=new Rn(1,1),this._viewportCount=1,this._viewports=[new Bi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;zB.setFromMatrixPosition(e.matrixWorld),n.position.copy(zB),UB.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(UB),n.updateMatrixWorld(),GT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(GT,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(GT)}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}},OK=class extends EK{constructor(e=-1,n=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(s,o,l,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class Lpe extends Ope{constructor(){super(new OK(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class BB extends RK{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ao.DEFAULT_UP),this.updateMatrix(),this.target=new Ao,this.shadow=new Lpe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Fpe=class extends RK{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},Ipe=class extends Jo{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},HB=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=Vn(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(Vn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class zpe extends Tpe{constructor(e=10,n=10,r=4473924,i=8947848){r=new Fn(r),i=new Fn(i);const s=n/2,o=e/n,l=e/2,c=[],u=[];for(let p=0,m=0,b=-l;p<=n;p++,b+=o){c.push(-l,0,b,l,0,b),c.push(b,0,-l,b,0,l);const y=p===s?r:i;y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3}const d=new dl;d.setAttribute("position",new So(c,3)),d.setAttribute("color",new So(u,3));const h=new AK({vertexColors:!0,toneMapped:!1});super(d,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Upe extends Im{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){vn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function $B(t,e,n,r){const i=Bpe(r);switch(n){case lK:return t*e;case uK:return t*e/i.components*i.byteLength;case lO:return t*e/i.components*i.byteLength;case cO:return t*e*2/i.components*i.byteLength;case uO:return t*e*2/i.components*i.byteLength;case cK:return t*e*3/i.components*i.byteLength;case Fl:return t*e*4/i.components*i.byteLength;case dO:return t*e*4/i.components*i.byteLength;case j1:case D1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case R1:case O1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Zj:case e3:return Math.max(t,16)*Math.max(e,8)/4;case Qj:case Jj:return Math.max(t,8)*Math.max(e,8)/2;case t3:case n3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case r3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case i3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case a3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case s3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case o3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case l3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case c3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case u3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case d3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case h3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case f3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case m3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case p3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case g3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case b3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case x3:case y3:case v3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case w3:case _3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case S3:case N3:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Bpe(t){switch(t){case _c:case iK:return{byteLength:1,components:1};case ty:case aK:case Tb:return{byteLength:2,components:1};case sO:case oO:return{byteLength:2,components:4};case ym:case aO:case Mu:return{byteLength:4,components:1};case sK:case oK:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:rO}}));typeof window<"u"&&(window.__THREE__?vn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=rO);function LK(){let t=null,e=!1,n=null,r=null;function i(s,o){n(s,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){n=s},setContext:function(s){t=s}}}function Hpe(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,h=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:h}}function r(l,c,u){const d=c.array,h=c.updateRanges;if(t.bindBuffer(u,l),h.length===0)t.bufferSubData(u,0,d);else{h.sort((m,b)=>m.start-b.start);let p=0;for(let m=1;m<h.length;m++){const b=h[p],y=h[m];y.start<=b.start+b.count+1?b.count=Math.max(b.count,y.start+y.count-b.start):(++p,h[p]=y)}h.length=p+1;for(let m=0,b=h.length;m<b;m++){const y=h[m];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function s(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function o(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,l,c),u.version=l.version}}return{get:i,remove:s,update:o}}var $pe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Vpe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,Gpe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,qpe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Wpe=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,Kpe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Xpe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,Ype=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Qpe=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,Zpe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,Jpe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,ege=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,tge=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,nge=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,rge=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,ige=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,age=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,sge=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,oge=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,lge=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,cge=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,uge=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,dge=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,hge=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,fge=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,mge=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,pge=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,gge=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,bge=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,xge=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,yge="gl_FragColor = linearToOutputTexel( gl_FragColor );",vge=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,wge=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,_ge=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,Sge=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,Nge=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,kge=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,Mge=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,Ege=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,Tge=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,Age=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,Cge=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,Pge=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,jge=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,Dge=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Rge=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,Oge=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,Lge=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,Fge=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Ige=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,zge=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Uge=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,Bge=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,Hge=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,$ge=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,Vge=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,Gge=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,qge=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Wge=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Kge=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,Xge=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,Yge=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,Qge=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,Zge=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Jge=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,ebe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,tbe=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,nbe=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,rbe=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,ibe=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,abe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,sbe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,obe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,lbe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,cbe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,ube=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,dbe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,hbe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,fbe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,mbe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,pbe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,gbe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,bbe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,xbe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,ybe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,vbe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,wbe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,_be=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Sbe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Nbe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- if ( hard_shadow != 1.0 ) {
- float distance = compare - distribution.x;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,kbe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,Mbe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,Ebe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,Tbe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,Abe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,Cbe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,Pbe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,jbe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,Dbe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,Rbe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,Obe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,Lbe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,Fbe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,Ibe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,zbe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,Ube=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,Bbe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const Hbe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,$be=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Vbe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Gbe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,qbe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Wbe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Kbe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,Xbe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,Ybe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,Qbe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,Zbe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,Jbe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,exe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,txe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,nxe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,rxe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,ixe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,axe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,sxe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,oxe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,lxe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,cxe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,uxe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,dxe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,hxe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,fxe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,mxe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,pxe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,gxe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,bxe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,xxe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,yxe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,vxe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,wxe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,jn={alphahash_fragment:$pe,alphahash_pars_fragment:Vpe,alphamap_fragment:Gpe,alphamap_pars_fragment:qpe,alphatest_fragment:Wpe,alphatest_pars_fragment:Kpe,aomap_fragment:Xpe,aomap_pars_fragment:Ype,batching_pars_vertex:Qpe,batching_vertex:Zpe,begin_vertex:Jpe,beginnormal_vertex:ege,bsdfs:tge,iridescence_fragment:nge,bumpmap_pars_fragment:rge,clipping_planes_fragment:ige,clipping_planes_pars_fragment:age,clipping_planes_pars_vertex:sge,clipping_planes_vertex:oge,color_fragment:lge,color_pars_fragment:cge,color_pars_vertex:uge,color_vertex:dge,common:hge,cube_uv_reflection_fragment:fge,defaultnormal_vertex:mge,displacementmap_pars_vertex:pge,displacementmap_vertex:gge,emissivemap_fragment:bge,emissivemap_pars_fragment:xge,colorspace_fragment:yge,colorspace_pars_fragment:vge,envmap_fragment:wge,envmap_common_pars_fragment:_ge,envmap_pars_fragment:Sge,envmap_pars_vertex:Nge,envmap_physical_pars_fragment:Oge,envmap_vertex:kge,fog_vertex:Mge,fog_pars_vertex:Ege,fog_fragment:Tge,fog_pars_fragment:Age,gradientmap_pars_fragment:Cge,lightmap_pars_fragment:Pge,lights_lambert_fragment:jge,lights_lambert_pars_fragment:Dge,lights_pars_begin:Rge,lights_toon_fragment:Lge,lights_toon_pars_fragment:Fge,lights_phong_fragment:Ige,lights_phong_pars_fragment:zge,lights_physical_fragment:Uge,lights_physical_pars_fragment:Bge,lights_fragment_begin:Hge,lights_fragment_maps:$ge,lights_fragment_end:Vge,logdepthbuf_fragment:Gge,logdepthbuf_pars_fragment:qge,logdepthbuf_pars_vertex:Wge,logdepthbuf_vertex:Kge,map_fragment:Xge,map_pars_fragment:Yge,map_particle_fragment:Qge,map_particle_pars_fragment:Zge,metalnessmap_fragment:Jge,metalnessmap_pars_fragment:ebe,morphinstance_vertex:tbe,morphcolor_vertex:nbe,morphnormal_vertex:rbe,morphtarget_pars_vertex:ibe,morphtarget_vertex:abe,normal_fragment_begin:sbe,normal_fragment_maps:obe,normal_pars_fragment:lbe,normal_pars_vertex:cbe,normal_vertex:ube,normalmap_pars_fragment:dbe,clearcoat_normal_fragment_begin:hbe,clearcoat_normal_fragment_maps:fbe,clearcoat_pars_fragment:mbe,iridescence_pars_fragment:pbe,opaque_fragment:gbe,packing:bbe,premultiplied_alpha_fragment:xbe,project_vertex:ybe,dithering_fragment:vbe,dithering_pars_fragment:wbe,roughnessmap_fragment:_be,roughnessmap_pars_fragment:Sbe,shadowmap_pars_fragment:Nbe,shadowmap_pars_vertex:kbe,shadowmap_vertex:Mbe,shadowmask_pars_fragment:Ebe,skinbase_vertex:Tbe,skinning_pars_vertex:Abe,skinning_vertex:Cbe,skinnormal_vertex:Pbe,specularmap_fragment:jbe,specularmap_pars_fragment:Dbe,tonemapping_fragment:Rbe,tonemapping_pars_fragment:Obe,transmission_fragment:Lbe,transmission_pars_fragment:Fbe,uv_pars_fragment:Ibe,uv_pars_vertex:zbe,uv_vertex:Ube,worldpos_vertex:Bbe,background_vert:Hbe,background_frag:$be,backgroundCube_vert:Vbe,backgroundCube_frag:Gbe,cube_vert:qbe,cube_frag:Wbe,depth_vert:Kbe,depth_frag:Xbe,distanceRGBA_vert:Ybe,distanceRGBA_frag:Qbe,equirect_vert:Zbe,equirect_frag:Jbe,linedashed_vert:exe,linedashed_frag:txe,meshbasic_vert:nxe,meshbasic_frag:rxe,meshlambert_vert:ixe,meshlambert_frag:axe,meshmatcap_vert:sxe,meshmatcap_frag:oxe,meshnormal_vert:lxe,meshnormal_frag:cxe,meshphong_vert:uxe,meshphong_frag:dxe,meshphysical_vert:hxe,meshphysical_frag:fxe,meshtoon_vert:mxe,meshtoon_frag:pxe,points_vert:gxe,points_frag:bxe,shadow_vert:xxe,shadow_frag:yxe,sprite_vert:vxe,sprite_frag:wxe},Ft={common:{diffuse:{value:new Fn(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},envMapRotation:{value:new Ln},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 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 Rn(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 Fn(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 Fn(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 Fn(16777215)},opacity:{value:1},center:{value:new Rn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}}},sc={basic:{uniforms:ps([Ft.common,Ft.specularmap,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.fog]),vertexShader:jn.meshbasic_vert,fragmentShader:jn.meshbasic_frag},lambert:{uniforms:ps([Ft.common,Ft.specularmap,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.fog,Ft.lights,{emissive:{value:new Fn(0)}}]),vertexShader:jn.meshlambert_vert,fragmentShader:jn.meshlambert_frag},phong:{uniforms:ps([Ft.common,Ft.specularmap,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.fog,Ft.lights,{emissive:{value:new Fn(0)},specular:{value:new Fn(1118481)},shininess:{value:30}}]),vertexShader:jn.meshphong_vert,fragmentShader:jn.meshphong_frag},standard:{uniforms:ps([Ft.common,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.roughnessmap,Ft.metalnessmap,Ft.fog,Ft.lights,{emissive:{value:new Fn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jn.meshphysical_vert,fragmentShader:jn.meshphysical_frag},toon:{uniforms:ps([Ft.common,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.gradientmap,Ft.fog,Ft.lights,{emissive:{value:new Fn(0)}}]),vertexShader:jn.meshtoon_vert,fragmentShader:jn.meshtoon_frag},matcap:{uniforms:ps([Ft.common,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.fog,{matcap:{value:null}}]),vertexShader:jn.meshmatcap_vert,fragmentShader:jn.meshmatcap_frag},points:{uniforms:ps([Ft.points,Ft.fog]),vertexShader:jn.points_vert,fragmentShader:jn.points_frag},dashed:{uniforms:ps([Ft.common,Ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jn.linedashed_vert,fragmentShader:jn.linedashed_frag},depth:{uniforms:ps([Ft.common,Ft.displacementmap]),vertexShader:jn.depth_vert,fragmentShader:jn.depth_frag},normal:{uniforms:ps([Ft.common,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,{opacity:{value:1}}]),vertexShader:jn.meshnormal_vert,fragmentShader:jn.meshnormal_frag},sprite:{uniforms:ps([Ft.sprite,Ft.fog]),vertexShader:jn.sprite_vert,fragmentShader:jn.sprite_frag},background:{uniforms:{uvTransform:{value:new Ln},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:jn.background_vert,fragmentShader:jn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ln}},vertexShader:jn.backgroundCube_vert,fragmentShader:jn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:jn.cube_vert,fragmentShader:jn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:jn.equirect_vert,fragmentShader:jn.equirect_frag},distanceRGBA:{uniforms:ps([Ft.common,Ft.displacementmap,{referencePosition:{value:new pt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:jn.distanceRGBA_vert,fragmentShader:jn.distanceRGBA_frag},shadow:{uniforms:ps([Ft.lights,Ft.fog,{color:{value:new Fn(0)},opacity:{value:1}}]),vertexShader:jn.shadow_vert,fragmentShader:jn.shadow_frag}};sc.physical={uniforms:ps([sc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ln},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ln},clearcoatNormalScale:{value:new Rn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ln},dispersion:{value:0},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 Fn(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 Rn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ln},attenuationDistance:{value:0},attenuationColor:{value:new Fn(0)},specularColor:{value:new Fn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ln},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ln},anisotropyVector:{value:new Rn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ln}}]),vertexShader:jn.meshphysical_vert,fragmentShader:jn.meshphysical_frag};const m_={r:0,b:0,g:0},vf=new Dh,_xe=new Gi;function Sxe(t,e,n,r,i,s,o){const l=new Fn(0);let c=s===!0?0:1,u,d,h=null,p=0,m=null;function b(N){let T=N.isScene===!0?N.background:null;return T&&T.isTexture&&(T=(N.backgroundBlurriness>0?n:e).get(T)),T}function y(N){let T=!1;const M=b(N);M===null?v(l,c):M&&M.isColor&&(v(M,1),T=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,o):A==="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 x(N,T){const M=b(T);M&&(M.isCubeTexture||M.mapping===Ok)?(d===void 0&&(d=new hl(new pO(1,1,1),new Wu({name:"BackgroundCubeMaterial",uniforms:tb(sc.backgroundCube.uniforms),vertexShader:sc.backgroundCube.vertexShader,fragmentShader:sc.backgroundCube.fragmentShader,side:Vs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(A,k,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),vf.copy(T.backgroundRotation),vf.x*=-1,vf.y*=-1,vf.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(vf.y*=-1,vf.z*=-1),d.material.uniforms.envMap.value=M,d.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(_xe.makeRotationFromEuler(vf)),d.material.toneMapped=or.getTransfer(M.colorSpace)!==Tr,(h!==M||p!==M.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,h=M,p=M.version,m=t.toneMapping),d.layers.enableAll(),N.unshift(d,d.geometry,d.material,0,0,null)):M&&M.isTexture&&(u===void 0&&(u=new hl(new bO(2,2),new Wu({name:"BackgroundMaterial",uniforms:tb(sc.background.uniforms),vertexShader:sc.background.vertexShader,fragmentShader:sc.background.fragmentShader,side:jh,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=M,u.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,u.material.toneMapped=or.getTransfer(M.colorSpace)!==Tr,M.matrixAutoUpdate===!0&&M.updateMatrix(),u.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||p!==M.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=M,p=M.version,m=t.toneMapping),u.layers.enableAll(),N.unshift(u,u.geometry,u.material,0,0,null))}function v(N,T){N.getRGB(m_,MK(t)),r.buffers.color.setClear(m_.r,m_.g,m_.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(N,T=1){l.set(N),c=T,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(N){c=N,v(l,c)},render:y,addToRenderList:x,dispose:S}}function Nxe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=p(null);let s=i,o=!1;function l(P,U,F,B,D){let $=!1;const G=h(B,F,U);s!==G&&(s=G,u(s.object)),$=m(P,B,F,D),$&&b(P,B,F,D),D!==null&&e.update(D,t.ELEMENT_ARRAY_BUFFER),($||o)&&(o=!1,T(P,U,F,B),D!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function c(){return t.createVertexArray()}function u(P){return t.bindVertexArray(P)}function d(P){return t.deleteVertexArray(P)}function h(P,U,F){const B=F.wireframe===!0;let D=r[P.id];D===void 0&&(D={},r[P.id]=D);let $=D[U.id];$===void 0&&($={},D[U.id]=$);let G=$[B];return G===void 0&&(G=p(c()),$[B]=G),G}function p(P){const U=[],F=[],B=[];for(let D=0;D<n;D++)U[D]=0,F[D]=0,B[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:F,attributeDivisors:B,object:P,attributes:{},index:null}}function m(P,U,F,B){const D=s.attributes,$=U.attributes;let G=0;const I=F.getAttributes();for(const K in I)if(I[K].location>=0){const se=D[K];let H=$[K];if(H===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(H=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(H=P.instanceColor)),se===void 0||se.attribute!==H||H&&se.data!==H.data)return!0;G++}return s.attributesNum!==G||s.index!==B}function b(P,U,F,B){const D={},$=U.attributes;let G=0;const I=F.getAttributes();for(const K in I)if(I[K].location>=0){let se=$[K];se===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(se=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(se=P.instanceColor));const H={};H.attribute=se,se&&se.data&&(H.data=se.data),D[K]=H,G++}s.attributes=D,s.attributesNum=G,s.index=B}function y(){const P=s.newAttributes;for(let U=0,F=P.length;U<F;U++)P[U]=0}function x(P){v(P,0)}function v(P,U){const F=s.newAttributes,B=s.enabledAttributes,D=s.attributeDivisors;F[P]=1,B[P]===0&&(t.enableVertexAttribArray(P),B[P]=1),D[P]!==U&&(t.vertexAttribDivisor(P,U),D[P]=U)}function S(){const P=s.newAttributes,U=s.enabledAttributes;for(let F=0,B=U.length;F<B;F++)U[F]!==P[F]&&(t.disableVertexAttribArray(F),U[F]=0)}function N(P,U,F,B,D,$,G){G===!0?t.vertexAttribIPointer(P,U,F,D,$):t.vertexAttribPointer(P,U,F,B,D,$)}function T(P,U,F,B){y();const D=B.attributes,$=F.getAttributes(),G=U.defaultAttributeValues;for(const I in $){const K=$[I];if(K.location>=0){let Q=D[I];if(Q===void 0&&(I==="instanceMatrix"&&P.instanceMatrix&&(Q=P.instanceMatrix),I==="instanceColor"&&P.instanceColor&&(Q=P.instanceColor)),Q!==void 0){const se=Q.normalized,H=Q.itemSize,W=e.get(Q);if(W===void 0)continue;const J=W.buffer,ne=W.type,xe=W.bytesPerElement,ue=ne===t.INT||ne===t.UNSIGNED_INT||Q.gpuType===aO;if(Q.isInterleavedBufferAttribute){const fe=Q.data,De=fe.stride,oe=Q.offset;if(fe.isInstancedInterleavedBuffer){for(let Ne=0;Ne<K.locationSize;Ne++)v(K.location+Ne,fe.meshPerAttribute);P.isInstancedMesh!==!0&&B._maxInstanceCount===void 0&&(B._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let Ne=0;Ne<K.locationSize;Ne++)x(K.location+Ne);t.bindBuffer(t.ARRAY_BUFFER,J);for(let Ne=0;Ne<K.locationSize;Ne++)N(K.location+Ne,H/K.locationSize,ne,se,De*xe,(oe+H/K.locationSize*Ne)*xe,ue)}else{if(Q.isInstancedBufferAttribute){for(let fe=0;fe<K.locationSize;fe++)v(K.location+fe,Q.meshPerAttribute);P.isInstancedMesh!==!0&&B._maxInstanceCount===void 0&&(B._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let fe=0;fe<K.locationSize;fe++)x(K.location+fe);t.bindBuffer(t.ARRAY_BUFFER,J);for(let fe=0;fe<K.locationSize;fe++)N(K.location+fe,H/K.locationSize,ne,se,H*xe,H/K.locationSize*fe*xe,ue)}}else if(G!==void 0){const se=G[I];if(se!==void 0)switch(se.length){case 2:t.vertexAttrib2fv(K.location,se);break;case 3:t.vertexAttrib3fv(K.location,se);break;case 4:t.vertexAttrib4fv(K.location,se);break;default:t.vertexAttrib1fv(K.location,se)}}}}S()}function M(){R();for(const P in r){const U=r[P];for(const F in U){const B=U[F];for(const D in B)d(B[D].object),delete B[D];delete U[F]}delete r[P]}}function A(P){if(r[P.id]===void 0)return;const U=r[P.id];for(const F in U){const B=U[F];for(const D in B)d(B[D].object),delete B[D];delete U[F]}delete r[P.id]}function k(P){for(const U in r){const F=r[U];if(F[P.id]===void 0)continue;const B=F[P.id];for(const D in B)d(B[D].object),delete B[D];delete F[P.id]}}function R(){C(),o=!0,s!==i&&(s=i,u(s.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:R,resetDefaultState:C,dispose:M,releaseStatesOfGeometry:A,releaseStatesOfProgram:k,initAttributes:y,enableAttribute:x,disableUnusedAttributes:S}}function kxe(t,e,n){let r;function i(u){r=u}function s(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function o(u,d,h){h!==0&&(t.drawArraysInstanced(r,u,d,h),n.update(d,r,h))}function l(u,d,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,h);let m=0;for(let b=0;b<h;b++)m+=d[b];n.update(m,r,1)}function c(u,d,h,p){if(h===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let b=0;b<u.length;b++)o(u[b],d[b],p[b]);else{m.multiDrawArraysInstancedWEBGL(r,u,0,d,0,p,0,h);let b=0;for(let y=0;y<h;y++)b+=d[y]*p[y];n.update(b,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function Mxe(t,e,n,r){let i;function s(){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!==Fl&&r.convert(k)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(k){const R=k===Tb&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(k!==_c&&r.convert(k)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&k!==Mu&&!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&&(vn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const h=n.logarithmicDepthBuffer===!0,p=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),S=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),N=t.getParameter(t.MAX_VARYING_VECTORS),T=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),M=b>0,A=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:h,reversedDepthBuffer:p,maxTextures:m,maxVertexTextures:b,maxTextureSize:y,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:S,maxVaryings:N,maxFragmentUniforms:T,vertexTextures:M,maxSamples:A}}function Exe(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new Xd,l=new Ln,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const m=h.length!==0||p||r!==0||i;return i=p,r=h.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){n=d(h,p,0)},this.setState=function(h,p,m){const b=h.clippingPlanes,y=h.clipIntersection,x=h.clipShadows,v=t.get(h);if(!i||b===null||b.length===0||s&&!x)s?d(null):u();else{const S=s?0:r,N=S*4;let T=v.clippingState||null;c.value=T,T=d(b,p,N,m);for(let M=0;M!==N;++M)T[M]=n[M];v.clippingState=T,this.numIntersection=y?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(h,p,m,b){const y=h!==null?h.length:0;let x=null;if(y!==0){if(x=c.value,b!==!0||x===null){const v=m+y*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(x===null||x.length<v)&&(x=new Float32Array(v));for(let N=0,T=m;N!==y;++N,T+=4)o.copy(h[N]).applyMatrix4(S,l),o.normal.toArray(x,T),x[T+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,x}}function Txe(t){let e=new WeakMap;function n(o,l){return l===Wj?o.mapping=Zg:l===Kj&&(o.mapping=Jg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===Wj||l===Kj)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 vpe(c.height);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const lh=4,VB=[.125,.215,.35,.446,.526,.582],Lf=20,Axe=256,Vx=new OK,GB=new Fn;let qT=null,WT=0,KT=0,XT=!1;const Cxe=new pt;let qB=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,s={}){const{size:o=256,position:l=Cxe}=s;qT=this._renderer.getRenderTarget(),WT=this._renderer.getActiveCubeFace(),KT=this._renderer.getActiveMipmapLevel(),XT=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=XB(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=KB(),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(qT,WT,KT),this._renderer.xr.enabled=XT,e.scissorTest=!1,Ip(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),qT=this._renderer.getRenderTarget(),WT=this._renderer.getActiveCubeFace(),KT=this._renderer.getActiveMipmapLevel(),XT=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:il,minFilter:il,generateMipmaps:!1,type:Tb,format:Fl,colorSpace:eb,depthBuffer:!1},i=WB(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=WB(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Pxe(s)),this._blurMaterial=Dxe(s,e,n),this._ggxMaterial=jxe(s,e,n)}return i}_compileMaterial(e){const n=new hl(new dl,e);this._renderer.compile(n,Vx)}_sceneToCubeUV(e,n,r,i,s){const c=new Jo(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,p=h.autoClear,m=h.toneMapping;h.getClearColor(GB),h.toneMapping=xh,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new hl(new pO,new mO({name:"PMREM.Background",side:Vs,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,x=y.material;let v=!1;const S=e.background;S?S.isColor&&(x.color.copy(S),e.background=null,v=!0):(x.color.copy(GB),v=!0);for(let N=0;N<6;N++){const T=N%3;T===0?(c.up.set(0,u[N],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+d[N],s.y,s.z)):T===1?(c.up.set(0,0,u[N]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+d[N],s.z)):(c.up.set(0,u[N],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+d[N]));const M=this._cubeSize;Ip(i,T*M,N>2?M:0,M,M),h.setRenderTarget(i),v&&h.render(y,c),h.render(e,c)}h.toneMapping=m,h.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=XB()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=KB());const s=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=s;const l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;Ip(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Vx)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,s=this._pingPongRenderTarget,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),h=Math.sqrt(u*u-d*d),p=.05+u*.95,m=h*p,{_lodMax:b}=this,y=this._sizeLods[r],x=3*y*(r>b-lh?r-b+lh:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=m,c.mipInt.value=b-n,Ip(s,x,v,3*y,2*y),i.setRenderTarget(s),i.render(l,Vx),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=b-r,Ip(e,x,v,3*y,2*y),i.setRenderTarget(e),i.render(l,Vx)}_blur(e,n,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Ei("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[i];h.material=u;const p=u.uniforms,m=this._sizeLods[r]-1,b=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Lf-1),y=s/b,x=isFinite(s)?1+Math.floor(d*y):Lf;x>Lf&&vn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${Lf}`);const v=[];let S=0;for(let k=0;k<Lf;++k){const R=k/y,C=Math.exp(-R*R/2);v.push(C),k===0?S+=C:k<x&&(S+=2*C)}for(let k=0;k<v.length;k++)v[k]=v[k]/S;p.envMap.value=e.texture,p.samples.value=x,p.weights.value=v,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:N}=this;p.dTheta.value=b,p.mipInt.value=N-r;const T=this._sizeLods[i],M=3*T*(i>N-lh?i-N+lh:0),A=4*(this._cubeSize-T);Ip(n,M,A,3*T,2*T),c.setRenderTarget(n),c.render(h,Vx)}};function Pxe(t){const e=[],n=[],r=[];let i=t;const s=t-lh+1+VB.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-lh?c=VB[o-t+lh-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,h=1+u,p=[d,d,h,d,h,h,d,d,h,h,d,h],m=6,b=6,y=3,x=2,v=1,S=new Float32Array(y*b*m),N=new Float32Array(x*b*m),T=new Float32Array(v*b*m);for(let A=0;A<m;A++){const k=A%3*2/3-1,R=A>2?0:-1,C=[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(C,y*b*A),N.set(p,x*b*A);const P=[A,A,A,A,A,A];T.set(P,v*b*A)}const M=new dl;M.setAttribute("position",new _s(S,y)),M.setAttribute("uv",new _s(N,x)),M.setAttribute("faceIndex",new _s(T,v)),r.push(new hl(M,null)),i>lh&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function WB(t,e,n){const r=new wm(t,e,n);return r.texture.mapping=Ok,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Ip(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function jxe(t,e,n){return new Wu({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Axe,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:Fk(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:Du,depthTest:!1,depthWrite:!1})}function Dxe(t,e,n){const r=new Float32Array(Lf),i=new pt(0,1,0);return new Wu({name:"SphericalGaussianBlur",defines:{n:Lf,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:Fk(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:Du,depthTest:!1,depthWrite:!1})}function KB(){return new Wu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Fk(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:Du,depthTest:!1,depthWrite:!1})}function XB(){return new Wu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Fk(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:Du,depthTest:!1,depthWrite:!1})}function Fk(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function Rxe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===Wj||c===Kj,d=c===Zg||c===Jg;if(u||d){let h=e.get(l);const p=h!==void 0?h.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==p)return n===null&&(n=new qB(t)),h=u?n.fromEquirectangular(l,h):n.fromCubemap(l,h),h.texture.pmremVersion=l.pmremVersion,e.set(l,h),h.texture;if(h!==void 0)return h.texture;{const m=l.image;return u&&m&&m.height>0||d&&m&&i(m)?(n===null&&(n=new qB(t)),h=u?n.fromEquirectangular(l):n.fromCubemap(l),h.texture.pmremVersion=l.pmremVersion,e.set(l,h),l.addEventListener("dispose",s),h.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function s(l){const c=l.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function Oxe(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&&ay("WebGLRenderer: "+r+" extension not supported."),i}}}function Lxe(t,e,n,r){const i={},s=new WeakMap;function o(h){const p=h.target;p.index!==null&&e.remove(p.index);for(const b in p.attributes)e.remove(p.attributes[b]);p.removeEventListener("dispose",o),delete i[p.id];const m=s.get(p);m&&(e.remove(m),s.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(h,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(h){const p=h.attributes;for(const m in p)e.update(p[m],t.ARRAY_BUFFER)}function u(h){const p=[],m=h.index,b=h.attributes.position;let y=0;if(m!==null){const S=m.array;y=m.version;for(let N=0,T=S.length;N<T;N+=3){const M=S[N+0],A=S[N+1],k=S[N+2];p.push(M,A,A,k,k,M)}}else if(b!==void 0){const S=b.array;y=b.version;for(let N=0,T=S.length/3-1;N<T;N+=3){const M=N+0,A=N+1,k=N+2;p.push(M,A,A,k,k,M)}}else return;const x=new(fK(p)?SK:_K)(p,1);x.version=y;const v=s.get(h);v&&e.remove(v),s.set(h,x)}function d(h){const p=s.get(h);if(p){const m=h.index;m!==null&&p.version<m.version&&u(h)}else u(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:d}}function Fxe(t,e,n){let r;function i(p){r=p}let s,o;function l(p){s=p.type,o=p.bytesPerElement}function c(p,m){t.drawElements(r,m,s,p*o),n.update(m,r,1)}function u(p,m,b){b!==0&&(t.drawElementsInstanced(r,m,s,p*o,b),n.update(m,r,b))}function d(p,m,b){if(b===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,s,p,0,b);let x=0;for(let v=0;v<b;v++)x+=m[v];n.update(x,r,1)}function h(p,m,b,y){if(b===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let v=0;v<p.length;v++)u(p[v]/o,m[v],y[v]);else{x.multiDrawElementsInstancedWEBGL(r,m,0,s,p,0,y,0,b);let v=0;for(let S=0;S<b;S++)v+=m[S]*y[S];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=h}function Ixe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(s/3);break;case t.LINES:n.lines+=l*(s/2);break;case t.LINE_STRIP:n.lines+=l*(s-1);break;case t.LINE_LOOP:n.lines+=l*s;break;case t.POINTS:n.points+=l*s;break;default:Ei("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 zxe(t,e,n){const r=new WeakMap,i=new Bi;function s(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,h=d!==void 0?d.length:0;let p=r.get(l);if(p===void 0||p.count!==h){let P=function(){R.dispose(),r.delete(l),l.removeEventListener("dispose",P)};var m=P;p!==void 0&&p.texture.dispose();const b=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,x=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],N=l.morphAttributes.color||[];let T=0;b===!0&&(T=1),y===!0&&(T=2),x===!0&&(T=3);let M=l.attributes.position.count*T,A=1;M>e.maxTextureSize&&(A=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const k=new Float32Array(M*A*4*h),R=new xK(k,M,A,h);R.type=Mu,R.needsUpdate=!0;const C=T*4;for(let U=0;U<h;U++){const F=v[U],B=S[U],D=N[U],$=M*A*4*U;for(let G=0;G<F.count;G++){const I=G*C;b===!0&&(i.fromBufferAttribute(F,G),k[$+I+0]=i.x,k[$+I+1]=i.y,k[$+I+2]=i.z,k[$+I+3]=0),y===!0&&(i.fromBufferAttribute(B,G),k[$+I+4]=i.x,k[$+I+5]=i.y,k[$+I+6]=i.z,k[$+I+7]=0),x===!0&&(i.fromBufferAttribute(D,G),k[$+I+8]=i.x,k[$+I+9]=i.y,k[$+I+10]=i.z,k[$+I+11]=D.itemSize===4?i.w:1)}}p={count:h,texture:R,size:new Rn(M,A)},r.set(l,p),l.addEventListener("dispose",P)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let b=0;for(let x=0;x<u.length;x++)b+=u[x];const y=l.morphTargetsRelative?1:1-b;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",p.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",p.size)}return{update:s}}function Uxe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,h=e.get(c,d);if(i.get(h)!==u&&(e.update(h),i.set(h,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 h}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:o}}const FK=new Gl,YB=new CK(1,1),IK=new xK,zK=new rpe,UK=new TK,QB=[],ZB=[],JB=new Float32Array(16),e8=new Float32Array(9),t8=new Float32Array(4);function Cb(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=QB[i];if(s===void 0&&(s=new Float32Array(i),QB[i]=s),e!==0){r.toArray(s,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(s,l)}return s}function ta(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 na(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function Ik(t,e){let n=ZB[e];n===void 0&&(n=new Int32Array(e),ZB[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Bxe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Hxe(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(ta(n,e))return;t.uniform2fv(this.addr,e),na(n,e)}}function $xe(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(ta(n,e))return;t.uniform3fv(this.addr,e),na(n,e)}}function Vxe(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(ta(n,e))return;t.uniform4fv(this.addr,e),na(n,e)}}function Gxe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ta(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),na(n,e)}else{if(ta(n,r))return;t8.set(r),t.uniformMatrix2fv(this.addr,!1,t8),na(n,r)}}function qxe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ta(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),na(n,e)}else{if(ta(n,r))return;e8.set(r),t.uniformMatrix3fv(this.addr,!1,e8),na(n,r)}}function Wxe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ta(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),na(n,e)}else{if(ta(n,r))return;JB.set(r),t.uniformMatrix4fv(this.addr,!1,JB),na(n,r)}}function Kxe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Xxe(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(ta(n,e))return;t.uniform2iv(this.addr,e),na(n,e)}}function Yxe(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(ta(n,e))return;t.uniform3iv(this.addr,e),na(n,e)}}function Qxe(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(ta(n,e))return;t.uniform4iv(this.addr,e),na(n,e)}}function Zxe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Jxe(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(ta(n,e))return;t.uniform2uiv(this.addr,e),na(n,e)}}function e0e(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(ta(n,e))return;t.uniform3uiv(this.addr,e),na(n,e)}}function t0e(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(ta(n,e))return;t.uniform4uiv(this.addr,e),na(n,e)}}function n0e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let s;this.type===t.SAMPLER_2D_SHADOW?(YB.compareFunction=hK,s=YB):s=FK,n.setTexture2D(e||s,i)}function r0e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||zK,i)}function i0e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||UK,i)}function a0e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||IK,i)}function s0e(t){switch(t){case 5126:return Bxe;case 35664:return Hxe;case 35665:return $xe;case 35666:return Vxe;case 35674:return Gxe;case 35675:return qxe;case 35676:return Wxe;case 5124:case 35670:return Kxe;case 35667:case 35671:return Xxe;case 35668:case 35672:return Yxe;case 35669:case 35673:return Qxe;case 5125:return Zxe;case 36294:return Jxe;case 36295:return e0e;case 36296:return t0e;case 35678:case 36198:case 36298:case 36306:case 35682:return n0e;case 35679:case 36299:case 36307:return r0e;case 35680:case 36300:case 36308:case 36293:return i0e;case 36289:case 36303:case 36311:case 36292:return a0e}}function o0e(t,e){t.uniform1fv(this.addr,e)}function l0e(t,e){const n=Cb(e,this.size,2);t.uniform2fv(this.addr,n)}function c0e(t,e){const n=Cb(e,this.size,3);t.uniform3fv(this.addr,n)}function u0e(t,e){const n=Cb(e,this.size,4);t.uniform4fv(this.addr,n)}function d0e(t,e){const n=Cb(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function h0e(t,e){const n=Cb(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function f0e(t,e){const n=Cb(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function m0e(t,e){t.uniform1iv(this.addr,e)}function p0e(t,e){t.uniform2iv(this.addr,e)}function g0e(t,e){t.uniform3iv(this.addr,e)}function b0e(t,e){t.uniform4iv(this.addr,e)}function x0e(t,e){t.uniform1uiv(this.addr,e)}function y0e(t,e){t.uniform2uiv(this.addr,e)}function v0e(t,e){t.uniform3uiv(this.addr,e)}function w0e(t,e){t.uniform4uiv(this.addr,e)}function _0e(t,e,n){const r=this.cache,i=e.length,s=Ik(n,i);ta(r,s)||(t.uniform1iv(this.addr,s),na(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||FK,s[o])}function S0e(t,e,n){const r=this.cache,i=e.length,s=Ik(n,i);ta(r,s)||(t.uniform1iv(this.addr,s),na(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||zK,s[o])}function N0e(t,e,n){const r=this.cache,i=e.length,s=Ik(n,i);ta(r,s)||(t.uniform1iv(this.addr,s),na(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||UK,s[o])}function k0e(t,e,n){const r=this.cache,i=e.length,s=Ik(n,i);ta(r,s)||(t.uniform1iv(this.addr,s),na(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||IK,s[o])}function M0e(t){switch(t){case 5126:return o0e;case 35664:return l0e;case 35665:return c0e;case 35666:return u0e;case 35674:return d0e;case 35675:return h0e;case 35676:return f0e;case 5124:case 35670:return m0e;case 35667:case 35671:return p0e;case 35668:case 35672:return g0e;case 35669:case 35673:return b0e;case 5125:return x0e;case 36294:return y0e;case 36295:return v0e;case 36296:return w0e;case 35678:case 36198:case 36298:case 36306:case 35682:return _0e;case 35679:case 36299:case 36307:return S0e;case 35680:case 36300:case 36308:case 36293:return N0e;case 36289:case 36303:case 36311:case 36292:return k0e}}let E0e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=s0e(n.type)}},T0e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=M0e(n.type)}},A0e=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const l=i[s];l.setValue(e,n[l.id],r)}}};const YT=/(\w+)(\])?(\[|\.)?/g;function n8(t,e){t.seq.push(e),t.map[e.id]=e}function C0e(t,e,n){const r=t.name,i=r.length;for(YT.lastIndex=0;;){const s=YT.exec(r),o=YT.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){n8(n,u===void 0?new E0e(l,t,e):new T0e(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new A0e(l),n8(n,h)),n=h}}}let z1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),o=e.getUniformLocation(n,s.name);C0e(s,o,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let s=0,o=n.length;s!==o;++s){const l=n[s],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function r8(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const P0e=37297;let j0e=0;function D0e(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}const i8=new Ln;function R0e(t){or._getMatrix(i8,or.workingColorSpace,t);const e=`mat3( ${i8.elements.map(n=>n.toFixed(4))} )`;switch(or.getTransfer(t)){case uS:return[e,"LinearTransferOETF"];case Tr:return[e,"sRGBTransferOETF"];default:return vn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function a8(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
- `+s+`
- `+D0e(t.getShaderSource(e),l)}else return s}function O0e(t,e){const n=R0e(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function L0e(t,e){let n;switch(e){case Cme:n="Linear";break;case Pme:n="Reinhard";break;case jme:n="Cineon";break;case Dme:n="ACESFilmic";break;case Ome:n="AgX";break;case Lme:n="Neutral";break;case Rme:n="Custom";break;default:vn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const p_=new pt;function F0e(){or.getLuminanceCoefficients(p_);const t=p_.x.toFixed(4),e=p_.y.toFixed(4),n=p_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function I0e(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(u0).join(`
- `)}function z0e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function U0e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),o=s.name;let l=1;s.type===t.FLOAT_MAT2&&(l=2),s.type===t.FLOAT_MAT3&&(l=3),s.type===t.FLOAT_MAT4&&(l=4),n[o]={type:s.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function u0(t){return t!==""}function s8(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 o8(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const B0e=/^[ \t]*#include +<([\w\d./]+)>/gm;function E3(t){return t.replace(B0e,$0e)}const H0e=new Map;function $0e(t,e){let n=jn[e];if(n===void 0){const r=H0e.get(e);if(r!==void 0)n=jn[r],vn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return E3(n)}const V0e=/#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 l8(t){return t.replace(V0e,G0e)}function G0e(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function c8(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function q0e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===nK?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===cme?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===mu&&(e="SHADOWMAP_TYPE_VSM"),e}function W0e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Zg:case Jg:e="ENVMAP_TYPE_CUBE";break;case Ok:e="ENVMAP_TYPE_CUBE_UV";break}return e}function K0e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Jg:e="ENVMAP_MODE_REFRACTION";break}return e}function X0e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case iO:e="ENVMAP_BLENDING_MULTIPLY";break;case Tme:e="ENVMAP_BLENDING_MIX";break;case Ame:e="ENVMAP_BLENDING_ADD";break}return e}function Y0e(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 Q0e(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=q0e(n),u=W0e(n),d=K0e(n),h=X0e(n),p=Y0e(n),m=I0e(n),b=z0e(s),y=i.createProgram();let x,v,S=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(u0).join(`
- `),x.length>0&&(x+=`
- `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(u0).join(`
- `),v.length>0&&(v+=`
- `)):(x=[c8(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(u0).join(`
- `),v=[c8(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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 "+h:"",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!==xh?"#define TONE_MAPPING":"",n.toneMapping!==xh?jn.tonemapping_pars_fragment:"",n.toneMapping!==xh?L0e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",jn.colorspace_pars_fragment,O0e("linearToOutputTexel",n.outputColorSpace),F0e(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(u0).join(`
- `)),o=E3(o),o=s8(o,n),o=o8(o,n),l=E3(l),l=s8(l,n),l=o8(l,n),o=l8(o),l=l8(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,x=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+x,v=["#define varying in",n.glslVersion===pB?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===pB?"":"#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(`
- `)+`
- `+v);const N=S+x+o,T=S+v+l,M=r8(i,i.VERTEX_SHADER,N),A=r8(i,i.FRAGMENT_SHADER,T);i.attachShader(y,M),i.attachShader(y,A),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function k(U){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(y)||"",B=i.getShaderInfoLog(M)||"",D=i.getShaderInfoLog(A)||"",$=F.trim(),G=B.trim(),I=D.trim();let K=!0,Q=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(K=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,M,A);else{const se=a8(i,M,"vertex"),H=a8(i,A,"fragment");Ei("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Material Name: `+U.name+`
- Material Type: `+U.type+`
- Program Info Log: `+$+`
- `+se+`
- `+H)}else $!==""?vn("WebGLProgram: Program Info Log:",$):(G===""||I==="")&&(Q=!1);Q&&(U.diagnostics={runnable:K,programLog:$,vertexShader:{log:G,prefix:x},fragmentShader:{log:I,prefix:v}})}i.deleteShader(M),i.deleteShader(A),R=new z1(i,y),C=U0e(i,y)}let R;this.getUniforms=function(){return R===void 0&&k(this),R};let C;this.getAttributes=function(){return C===void 0&&k(this),C};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(y,P0e)),P},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=j0e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=M,this.fragmentShader=A,this}let Z0e=0,J0e=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new eye(e),n.set(e,r)),r}},eye=class{constructor(e){this.id=Z0e++,this.code=e,this.usedTimes=0}};function tye(t,e,n,r,i,s,o){const l=new vK,c=new J0e,u=new Set,d=[],h=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(C){return u.add(C),C===0?"uv":`uv${C}`}function x(C,P,U,F,B){const D=F.fog,$=B.geometry,G=C.isMeshStandardMaterial?F.environment:null,I=(C.isMeshStandardMaterial?n:e).get(C.envMap||G),K=I&&I.mapping===Ok?I.image.height:null,Q=b[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&vn("WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const se=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=se!==void 0?se.length:0;let W=0;$.morphAttributes.position!==void 0&&(W=1),$.morphAttributes.normal!==void 0&&(W=2),$.morphAttributes.color!==void 0&&(W=3);let J,ne,xe,ue;if(Q){const Et=sc[Q];J=Et.vertexShader,ne=Et.fragmentShader}else J=C.vertexShader,ne=C.fragmentShader,c.update(C),xe=c.getVertexShaderID(C),ue=c.getFragmentShaderID(C);const fe=t.getRenderTarget(),De=t.state.buffers.depth.getReversed(),oe=B.isInstancedMesh===!0,Ne=B.isBatchedMesh===!0,Fe=!!C.map,ce=!!C.matcap,Ve=!!I,V=!!C.aoMap,Y=!!C.lightMap,de=!!C.bumpMap,q=!!C.normalMap,re=!!C.displacementMap,X=!!C.emissiveMap,le=!!C.metalnessMap,pe=!!C.roughnessMap,ee=C.anisotropy>0,z=C.clearcoat>0,O=C.dispersion>0,Z=C.iridescence>0,me=C.sheen>0,Te=C.transmission>0,ke=ee&&!!C.anisotropyMap,Ee=z&&!!C.clearcoatMap,Se=z&&!!C.clearcoatNormalMap,$e=z&&!!C.clearcoatRoughnessMap,Qe=Z&&!!C.iridescenceMap,Ue=Z&&!!C.iridescenceThicknessMap,be=me&&!!C.sheenColorMap,ve=me&&!!C.sheenRoughnessMap,ze=!!C.specularMap,Ce=!!C.specularColorMap,Ge=!!C.specularIntensityMap,_e=Te&&!!C.transmissionMap,Je=Te&&!!C.thicknessMap,Ae=!!C.gradientMap,Ke=!!C.alphaMap,je=C.alphaTest>0,Re=!!C.alphaHash,we=!!C.extensions;let qe=xh;C.toneMapped&&(fe===null||fe.isXRRenderTarget===!0)&&(qe=t.toneMapping);const xt={shaderID:Q,shaderType:C.type,shaderName:C.name,vertexShader:J,fragmentShader:ne,defines:C.defines,customVertexShaderID:xe,customFragmentShaderID:ue,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:Ne,batchingColor:Ne&&B._colorsTexture!==null,instancing:oe,instancingColor:oe&&B.instanceColor!==null,instancingMorph:oe&&B.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:fe===null?t.outputColorSpace:fe.isXRRenderTarget===!0?fe.texture.colorSpace:eb,alphaToCoverage:!!C.alphaToCoverage,map:Fe,matcap:ce,envMap:Ve,envMapMode:Ve&&I.mapping,envMapCubeUVHeight:K,aoMap:V,lightMap:Y,bumpMap:de,normalMap:q,displacementMap:p&&re,emissiveMap:X,normalMapObjectSpace:q&&C.normalMapType===Ume,normalMapTangentSpace:q&&C.normalMapType===dK,metalnessMap:le,roughnessMap:pe,anisotropy:ee,anisotropyMap:ke,clearcoat:z,clearcoatMap:Ee,clearcoatNormalMap:Se,clearcoatRoughnessMap:$e,dispersion:O,iridescence:Z,iridescenceMap:Qe,iridescenceThicknessMap:Ue,sheen:me,sheenColorMap:be,sheenRoughnessMap:ve,specularMap:ze,specularColorMap:Ce,specularIntensityMap:Ge,transmission:Te,transmissionMap:_e,thicknessMap:Je,gradientMap:Ae,opaque:C.transparent===!1&&C.blending===Rg&&C.alphaToCoverage===!1,alphaMap:Ke,alphaTest:je,alphaHash:Re,combine:C.combine,mapUv:Fe&&y(C.map.channel),aoMapUv:V&&y(C.aoMap.channel),lightMapUv:Y&&y(C.lightMap.channel),bumpMapUv:de&&y(C.bumpMap.channel),normalMapUv:q&&y(C.normalMap.channel),displacementMapUv:re&&y(C.displacementMap.channel),emissiveMapUv:X&&y(C.emissiveMap.channel),metalnessMapUv:le&&y(C.metalnessMap.channel),roughnessMapUv:pe&&y(C.roughnessMap.channel),anisotropyMapUv:ke&&y(C.anisotropyMap.channel),clearcoatMapUv:Ee&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:Se&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$e&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Qe&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Ue&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:be&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:ve&&y(C.sheenRoughnessMap.channel),specularMapUv:ze&&y(C.specularMap.channel),specularColorMapUv:Ce&&y(C.specularColorMap.channel),specularIntensityMapUv:Ge&&y(C.specularIntensityMap.channel),transmissionMapUv:_e&&y(C.transmissionMap.channel),thicknessMapUv:Je&&y(C.thicknessMap.channel),alphaMapUv:Ke&&y(C.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(q||ee),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:B.isPoints===!0&&!!$.attributes.uv&&(Fe||Ke),fog:!!D,useFog:C.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:C.flatShading===!0&&C.wireframe===!1,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:De,skinning:B.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:W,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:qe,decodeVideoTexture:Fe&&C.map.isVideoTexture===!0&&or.getTransfer(C.map.colorSpace)===Tr,decodeVideoTextureEmissive:X&&C.emissiveMap.isVideoTexture===!0&&or.getTransfer(C.emissiveMap.colorSpace)===Tr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===lc,flipSided:C.side===Vs,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:we&&C.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(we&&C.extensions.multiDraw===!0||Ne)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return xt.vertexUv1s=u.has(1),xt.vertexUv2s=u.has(2),xt.vertexUv3s=u.has(3),u.clear(),xt}function v(C){const P=[];if(C.shaderID?P.push(C.shaderID):(P.push(C.customVertexShaderID),P.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)P.push(U),P.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(S(P,C),N(P,C),P.push(t.outputColorSpace)),P.push(C.customProgramCacheKey),P.join()}function S(C,P){C.push(P.precision),C.push(P.outputColorSpace),C.push(P.envMapMode),C.push(P.envMapCubeUVHeight),C.push(P.mapUv),C.push(P.alphaMapUv),C.push(P.lightMapUv),C.push(P.aoMapUv),C.push(P.bumpMapUv),C.push(P.normalMapUv),C.push(P.displacementMapUv),C.push(P.emissiveMapUv),C.push(P.metalnessMapUv),C.push(P.roughnessMapUv),C.push(P.anisotropyMapUv),C.push(P.clearcoatMapUv),C.push(P.clearcoatNormalMapUv),C.push(P.clearcoatRoughnessMapUv),C.push(P.iridescenceMapUv),C.push(P.iridescenceThicknessMapUv),C.push(P.sheenColorMapUv),C.push(P.sheenRoughnessMapUv),C.push(P.specularMapUv),C.push(P.specularColorMapUv),C.push(P.specularIntensityMapUv),C.push(P.transmissionMapUv),C.push(P.thicknessMapUv),C.push(P.combine),C.push(P.fogExp2),C.push(P.sizeAttenuation),C.push(P.morphTargetsCount),C.push(P.morphAttributeCount),C.push(P.numDirLights),C.push(P.numPointLights),C.push(P.numSpotLights),C.push(P.numSpotLightMaps),C.push(P.numHemiLights),C.push(P.numRectAreaLights),C.push(P.numDirLightShadows),C.push(P.numPointLightShadows),C.push(P.numSpotLightShadows),C.push(P.numSpotLightShadowsWithMaps),C.push(P.numLightProbes),C.push(P.shadowMapType),C.push(P.toneMapping),C.push(P.numClippingPlanes),C.push(P.numClipIntersection),C.push(P.depthPacking)}function N(C,P){l.disableAll(),P.supportsVertexTextures&&l.enable(0),P.instancing&&l.enable(1),P.instancingColor&&l.enable(2),P.instancingMorph&&l.enable(3),P.matcap&&l.enable(4),P.envMap&&l.enable(5),P.normalMapObjectSpace&&l.enable(6),P.normalMapTangentSpace&&l.enable(7),P.clearcoat&&l.enable(8),P.iridescence&&l.enable(9),P.alphaTest&&l.enable(10),P.vertexColors&&l.enable(11),P.vertexAlphas&&l.enable(12),P.vertexUv1s&&l.enable(13),P.vertexUv2s&&l.enable(14),P.vertexUv3s&&l.enable(15),P.vertexTangents&&l.enable(16),P.anisotropy&&l.enable(17),P.alphaHash&&l.enable(18),P.batching&&l.enable(19),P.dispersion&&l.enable(20),P.batchingColor&&l.enable(21),P.gradientMap&&l.enable(22),C.push(l.mask),l.disableAll(),P.fog&&l.enable(0),P.useFog&&l.enable(1),P.flatShading&&l.enable(2),P.logarithmicDepthBuffer&&l.enable(3),P.reversedDepthBuffer&&l.enable(4),P.skinning&&l.enable(5),P.morphTargets&&l.enable(6),P.morphNormals&&l.enable(7),P.morphColors&&l.enable(8),P.premultipliedAlpha&&l.enable(9),P.shadowMapEnabled&&l.enable(10),P.doubleSided&&l.enable(11),P.flipSided&&l.enable(12),P.useDepthPacking&&l.enable(13),P.dithering&&l.enable(14),P.transmission&&l.enable(15),P.sheen&&l.enable(16),P.opaque&&l.enable(17),P.pointsUvs&&l.enable(18),P.decodeVideoTexture&&l.enable(19),P.decodeVideoTextureEmissive&&l.enable(20),P.alphaToCoverage&&l.enable(21),C.push(l.mask)}function T(C){const P=b[C.type];let U;if(P){const F=sc[P];U=gpe.clone(F.uniforms)}else U=C.uniforms;return U}function M(C,P){let U;for(let F=0,B=d.length;F<B;F++){const D=d[F];if(D.cacheKey===P){U=D,++U.usedTimes;break}}return U===void 0&&(U=new Q0e(t,P,C,s),d.push(U)),U}function A(C){if(--C.usedTimes===0){const P=d.indexOf(C);d[P]=d[d.length-1],d.pop(),C.destroy()}}function k(C){c.remove(C)}function R(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:T,acquireProgram:M,releaseProgram:A,releaseShaderCache:k,programs:d,dispose:R}}function nye(){let t=new WeakMap;function e(o){return t.has(o)}function n(o){let l=t.get(o);return l===void 0&&(l={},t.set(o,l)),l}function r(o){t.delete(o)}function i(o,l,c){t.get(o)[l]=c}function s(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:s}}function rye(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 u8(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 d8(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(h,p,m,b,y,x){let v=t[e];return v===void 0?(v={id:h.id,object:h,geometry:p,material:m,groupOrder:b,renderOrder:h.renderOrder,z:y,group:x},t[e]=v):(v.id=h.id,v.object=h,v.geometry=p,v.material=m,v.groupOrder=b,v.renderOrder=h.renderOrder,v.z=y,v.group=x),e++,v}function l(h,p,m,b,y,x){const v=o(h,p,m,b,y,x);m.transmission>0?r.push(v):m.transparent===!0?i.push(v):n.push(v)}function c(h,p,m,b,y,x){const v=o(h,p,m,b,y,x);m.transmission>0?r.unshift(v):m.transparent===!0?i.unshift(v):n.unshift(v)}function u(h,p){n.length>1&&n.sort(h||rye),r.length>1&&r.sort(p||u8),i.length>1&&i.sort(p||u8)}function d(){for(let h=e,p=t.length;h<p;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function iye(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new d8,t.set(r,[o])):i>=s.length?(o=new d8,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function aye(){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 pt,color:new Fn};break;case"SpotLight":n={position:new pt,direction:new pt,color:new Fn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new pt,color:new Fn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new pt,skyColor:new Fn,groundColor:new Fn};break;case"RectAreaLight":n={color:new Fn,position:new pt,halfWidth:new pt,halfHeight:new pt};break}return t[e.id]=n,n}}}function sye(){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 Rn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Rn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Rn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let oye=0;function lye(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function cye(t){const e=new aye,n=sye(),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 pt);const i=new pt,s=new Gi,o=new Gi;function l(u){let d=0,h=0,p=0;for(let C=0;C<9;C++)r.probe[C].set(0,0,0);let m=0,b=0,y=0,x=0,v=0,S=0,N=0,T=0,M=0,A=0,k=0;u.sort(lye);for(let C=0,P=u.length;C<P;C++){const U=u[C],F=U.color,B=U.intensity,D=U.distance,$=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)d+=F.r*B,h+=F.g*B,p+=F.b*B;else if(U.isLightProbe){for(let G=0;G<9;G++)r.probe[G].addScaledVector(U.sh.coefficients[G],B);k++}else if(U.isDirectionalLight){const G=e.get(U);if(G.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const I=U.shadow,K=n.get(U);K.shadowIntensity=I.intensity,K.shadowBias=I.bias,K.shadowNormalBias=I.normalBias,K.shadowRadius=I.radius,K.shadowMapSize=I.mapSize,r.directionalShadow[m]=K,r.directionalShadowMap[m]=$,r.directionalShadowMatrix[m]=U.shadow.matrix,S++}r.directional[m]=G,m++}else if(U.isSpotLight){const G=e.get(U);G.position.setFromMatrixPosition(U.matrixWorld),G.color.copy(F).multiplyScalar(B),G.distance=D,G.coneCos=Math.cos(U.angle),G.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),G.decay=U.decay,r.spot[y]=G;const I=U.shadow;if(U.map&&(r.spotLightMap[M]=U.map,M++,I.updateMatrices(U),U.castShadow&&A++),r.spotLightMatrix[y]=I.matrix,U.castShadow){const K=n.get(U);K.shadowIntensity=I.intensity,K.shadowBias=I.bias,K.shadowNormalBias=I.normalBias,K.shadowRadius=I.radius,K.shadowMapSize=I.mapSize,r.spotShadow[y]=K,r.spotShadowMap[y]=$,T++}y++}else if(U.isRectAreaLight){const G=e.get(U);G.color.copy(F).multiplyScalar(B),G.halfWidth.set(U.width*.5,0,0),G.halfHeight.set(0,U.height*.5,0),r.rectArea[x]=G,x++}else if(U.isPointLight){const G=e.get(U);if(G.color.copy(U.color).multiplyScalar(U.intensity),G.distance=U.distance,G.decay=U.decay,U.castShadow){const I=U.shadow,K=n.get(U);K.shadowIntensity=I.intensity,K.shadowBias=I.bias,K.shadowNormalBias=I.normalBias,K.shadowRadius=I.radius,K.shadowMapSize=I.mapSize,K.shadowCameraNear=I.camera.near,K.shadowCameraFar=I.camera.far,r.pointShadow[b]=K,r.pointShadowMap[b]=$,r.pointShadowMatrix[b]=U.shadow.matrix,N++}r.point[b]=G,b++}else if(U.isHemisphereLight){const G=e.get(U);G.skyColor.copy(U.color).multiplyScalar(B),G.groundColor.copy(U.groundColor).multiplyScalar(B),r.hemi[v]=G,v++}}x>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ft.LTC_FLOAT_1,r.rectAreaLTC2=Ft.LTC_FLOAT_2):(r.rectAreaLTC1=Ft.LTC_HALF_1,r.rectAreaLTC2=Ft.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=h,r.ambient[2]=p;const R=r.hash;(R.directionalLength!==m||R.pointLength!==b||R.spotLength!==y||R.rectAreaLength!==x||R.hemiLength!==v||R.numDirectionalShadows!==S||R.numPointShadows!==N||R.numSpotShadows!==T||R.numSpotMaps!==M||R.numLightProbes!==k)&&(r.directional.length=m,r.spot.length=y,r.rectArea.length=x,r.point.length=b,r.hemi.length=v,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=N,r.pointShadowMap.length=N,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=N,r.spotLightMatrix.length=T+M-A,r.spotLightMap.length=M,r.numSpotLightShadowsWithMaps=A,r.numLightProbes=k,R.directionalLength=m,R.pointLength=b,R.spotLength=y,R.rectAreaLength=x,R.hemiLength=v,R.numDirectionalShadows=S,R.numPointShadows=N,R.numSpotShadows=T,R.numSpotMaps=M,R.numLightProbes=k,r.version=oye++)}function c(u,d){let h=0,p=0,m=0,b=0,y=0;const x=d.matrixWorldInverse;for(let v=0,S=u.length;v<S;v++){const N=u[v];if(N.isDirectionalLight){const T=r.directional[h];T.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(x),h++}else if(N.isSpotLight){const T=r.spot[m];T.position.setFromMatrixPosition(N.matrixWorld),T.position.applyMatrix4(x),T.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(x),m++}else if(N.isRectAreaLight){const T=r.rectArea[b];T.position.setFromMatrixPosition(N.matrixWorld),T.position.applyMatrix4(x),o.identity(),s.copy(N.matrixWorld),s.premultiply(x),o.extractRotation(s),T.halfWidth.set(N.width*.5,0,0),T.halfHeight.set(0,N.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),b++}else if(N.isPointLight){const T=r.point[p];T.position.setFromMatrixPosition(N.matrixWorld),T.position.applyMatrix4(x),p++}else if(N.isHemisphereLight){const T=r.hemi[y];T.direction.setFromMatrixPosition(N.matrixWorld),T.direction.transformDirection(x),y++}}}return{setup:l,setupView:c,state:r}}function h8(t){const e=new cye(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function s(d){n.push(d)}function o(d){r.push(d)}function l(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:l,setupLightsView:c,pushLight:s,pushShadow:o}}function uye(t){let e=new WeakMap;function n(i,s=0){const o=e.get(i);let l;return o===void 0?(l=new h8(t),e.set(i,[l])):s>=o.length?(l=new h8(t),o.push(l)):l=o[s],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const dye=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,hye=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function fye(t,e,n){let r=new gO;const i=new Rn,s=new Rn,o=new Bi,l=new Ape({depthPacking:zme}),c=new Cpe,u={},d=n.maxTextureSize,h={[jh]:Vs,[Vs]:jh,[lc]:lc},p=new Wu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Rn},radius:{value:4}},vertexShader:dye,fragmentShader:hye}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const b=new dl;b.setAttribute("position",new _s(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new hl(b,p),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=nK;let v=this.type;this.render=function(A,k,R){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||A.length===0)return;const C=t.getRenderTarget(),P=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Du),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 B=v!==mu&&this.type===mu,D=v===mu&&this.type!==mu;for(let $=0,G=A.length;$<G;$++){const I=A[$],K=I.shadow;if(K===void 0){vn("WebGLShadowMap:",I,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;i.copy(K.mapSize);const Q=K.getFrameExtents();if(i.multiply(Q),s.copy(K.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Q.x),i.x=s.x*Q.x,K.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Q.y),i.y=s.y*Q.y,K.mapSize.y=s.y)),K.map===null||B===!0||D===!0){const H=this.type!==mu?{minFilter:_o,magFilter:_o}:{};K.map!==null&&K.map.dispose(),K.map=new wm(i.x,i.y,H),K.map.texture.name=I.name+".shadowMap",K.camera.updateProjectionMatrix()}t.setRenderTarget(K.map),t.clear();const se=K.getViewportCount();for(let H=0;H<se;H++){const W=K.getViewport(H);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),F.viewport(o),K.updateMatrices(I,H),r=K.getFrustum(),T(k,R,K.camera,I,this.type)}K.isPointLightShadow!==!0&&this.type===mu&&S(K,R),K.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(C,P,U)};function S(A,k){const R=e.update(y);p.defines.VSM_SAMPLES!==A.blurSamples&&(p.defines.VSM_SAMPLES=A.blurSamples,m.defines.VSM_SAMPLES=A.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new wm(i.x,i.y)),p.uniforms.shadow_pass.value=A.map.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,t.setRenderTarget(A.mapPass),t.clear(),t.renderBufferDirect(k,null,R,p,y,null),m.uniforms.shadow_pass.value=A.mapPass.texture,m.uniforms.resolution.value=A.mapSize,m.uniforms.radius.value=A.radius,t.setRenderTarget(A.map),t.clear(),t.renderBufferDirect(k,null,R,m,y,null)}function N(A,k,R,C){let P=null;const U=R.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(U!==void 0)P=U;else if(P=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=P.uuid,B=k.uuid;let D=u[F];D===void 0&&(D={},u[F]=D);let $=D[B];$===void 0&&($=P.clone(),D[B]=$,k.addEventListener("dispose",M)),P=$}if(P.visible=k.visible,P.wireframe=k.wireframe,C===mu?P.side=k.shadowSide!==null?k.shadowSide:k.side:P.side=k.shadowSide!==null?k.shadowSide:h[k.side],P.alphaMap=k.alphaMap,P.alphaTest=k.alphaToCoverage===!0?.5:k.alphaTest,P.map=k.map,P.clipShadows=k.clipShadows,P.clippingPlanes=k.clippingPlanes,P.clipIntersection=k.clipIntersection,P.displacementMap=k.displacementMap,P.displacementScale=k.displacementScale,P.displacementBias=k.displacementBias,P.wireframeLinewidth=k.wireframeLinewidth,P.linewidth=k.linewidth,R.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const F=t.properties.get(P);F.light=R}return P}function T(A,k,R,C,P){if(A.visible===!1)return;if(A.layers.test(k.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&P===mu)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,A.matrixWorld);const B=e.update(A),D=A.material;if(Array.isArray(D)){const $=B.groups;for(let G=0,I=$.length;G<I;G++){const K=$[G],Q=D[K.materialIndex];if(Q&&Q.visible){const se=N(A,Q,C,P);A.onBeforeShadow(t,A,k,R,B,se,K),t.renderBufferDirect(R,null,B,se,A,K),A.onAfterShadow(t,A,k,R,B,se,K)}}}else if(D.visible){const $=N(A,D,C,P);A.onBeforeShadow(t,A,k,R,B,$,null),t.renderBufferDirect(R,null,B,$,A,null),A.onAfterShadow(t,A,k,R,B,$,null)}}const F=A.children;for(let B=0,D=F.length;B<D;B++)T(F[B],k,R,C,P)}function M(A){A.target.removeEventListener("dispose",M);for(const R in u){const C=u[R],P=A.target.uuid;P in C&&(C[P].dispose(),delete C[P])}}}const mye={[Uj]:Bj,[Hj]:Gj,[$j]:qj,[Qg]:Vj,[Bj]:Uj,[Gj]:Hj,[qj]:$j,[Vj]:Qg};function pye(t,e){function n(){let _e=!1;const Je=new Bi;let Ae=null;const Ke=new Bi(0,0,0,0);return{setMask:function(je){Ae!==je&&!_e&&(t.colorMask(je,je,je,je),Ae=je)},setLocked:function(je){_e=je},setClear:function(je,Re,we,qe,xt){xt===!0&&(je*=qe,Re*=qe,we*=qe),Je.set(je,Re,we,qe),Ke.equals(Je)===!1&&(t.clearColor(je,Re,we,qe),Ke.copy(Je))},reset:function(){_e=!1,Ae=null,Ke.set(-1,0,0,0)}}}function r(){let _e=!1,Je=!1,Ae=null,Ke=null,je=null;return{setReversed:function(Re){if(Je!==Re){const we=e.get("EXT_clip_control");Re?we.clipControlEXT(we.LOWER_LEFT_EXT,we.ZERO_TO_ONE_EXT):we.clipControlEXT(we.LOWER_LEFT_EXT,we.NEGATIVE_ONE_TO_ONE_EXT),Je=Re;const qe=je;je=null,this.setClear(qe)}},getReversed:function(){return Je},setTest:function(Re){Re?fe(t.DEPTH_TEST):De(t.DEPTH_TEST)},setMask:function(Re){Ae!==Re&&!_e&&(t.depthMask(Re),Ae=Re)},setFunc:function(Re){if(Je&&(Re=mye[Re]),Ke!==Re){switch(Re){case Uj:t.depthFunc(t.NEVER);break;case Bj:t.depthFunc(t.ALWAYS);break;case Hj:t.depthFunc(t.LESS);break;case Qg:t.depthFunc(t.LEQUAL);break;case $j:t.depthFunc(t.EQUAL);break;case Vj:t.depthFunc(t.GEQUAL);break;case Gj:t.depthFunc(t.GREATER);break;case qj:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ke=Re}},setLocked:function(Re){_e=Re},setClear:function(Re){je!==Re&&(Je&&(Re=1-Re),t.clearDepth(Re),je=Re)},reset:function(){_e=!1,Ae=null,Ke=null,je=null,Je=!1}}}function i(){let _e=!1,Je=null,Ae=null,Ke=null,je=null,Re=null,we=null,qe=null,xt=null;return{setTest:function(Et){_e||(Et?fe(t.STENCIL_TEST):De(t.STENCIL_TEST))},setMask:function(Et){Je!==Et&&!_e&&(t.stencilMask(Et),Je=Et)},setFunc:function(Et,fn,It){(Ae!==Et||Ke!==fn||je!==It)&&(t.stencilFunc(Et,fn,It),Ae=Et,Ke=fn,je=It)},setOp:function(Et,fn,It){(Re!==Et||we!==fn||qe!==It)&&(t.stencilOp(Et,fn,It),Re=Et,we=fn,qe=It)},setLocked:function(Et){_e=Et},setClear:function(Et){xt!==Et&&(t.clearStencil(Et),xt=Et)},reset:function(){_e=!1,Je=null,Ae=null,Ke=null,je=null,Re=null,we=null,qe=null,xt=null}}}const s=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},h={},p=new WeakMap,m=[],b=null,y=!1,x=null,v=null,S=null,N=null,T=null,M=null,A=null,k=new Fn(0,0,0),R=0,C=!1,P=null,U=null,F=null,B=null,D=null;const $=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,I=0;const K=t.getParameter(t.VERSION);K.indexOf("WebGL")!==-1?(I=parseFloat(/^WebGL (\d)/.exec(K)[1]),G=I>=1):K.indexOf("OpenGL ES")!==-1&&(I=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),G=I>=2);let Q=null,se={};const H=t.getParameter(t.SCISSOR_BOX),W=t.getParameter(t.VIEWPORT),J=new Bi().fromArray(H),ne=new Bi().fromArray(W);function xe(_e,Je,Ae,Ke){const je=new Uint8Array(4),Re=t.createTexture();t.bindTexture(_e,Re),t.texParameteri(_e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(_e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let we=0;we<Ae;we++)_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?t.texImage3D(Je,0,t.RGBA,1,1,Ke,0,t.RGBA,t.UNSIGNED_BYTE,je):t.texImage2D(Je+we,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,je);return Re}const ue={};ue[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),ue[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),ue[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ue[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),l.setClear(0),fe(t.DEPTH_TEST),o.setFunc(Qg),de(!1),q(cB),fe(t.CULL_FACE),V(Du);function fe(_e){d[_e]!==!0&&(t.enable(_e),d[_e]=!0)}function De(_e){d[_e]!==!1&&(t.disable(_e),d[_e]=!1)}function oe(_e,Je){return h[_e]!==Je?(t.bindFramebuffer(_e,Je),h[_e]=Je,_e===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=Je),_e===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=Je),!0):!1}function Ne(_e,Je){let Ae=m,Ke=!1;if(_e){Ae=p.get(Je),Ae===void 0&&(Ae=[],p.set(Je,Ae));const je=_e.textures;if(Ae.length!==je.length||Ae[0]!==t.COLOR_ATTACHMENT0){for(let Re=0,we=je.length;Re<we;Re++)Ae[Re]=t.COLOR_ATTACHMENT0+Re;Ae.length=je.length,Ke=!0}}else Ae[0]!==t.BACK&&(Ae[0]=t.BACK,Ke=!0);Ke&&t.drawBuffers(Ae)}function Fe(_e){return b!==_e?(t.useProgram(_e),b=_e,!0):!1}const ce={[Of]:t.FUNC_ADD,[dme]:t.FUNC_SUBTRACT,[hme]:t.FUNC_REVERSE_SUBTRACT};ce[fme]=t.MIN,ce[mme]=t.MAX;const Ve={[pme]:t.ZERO,[gme]:t.ONE,[bme]:t.SRC_COLOR,[Ij]:t.SRC_ALPHA,[Sme]:t.SRC_ALPHA_SATURATE,[wme]:t.DST_COLOR,[yme]:t.DST_ALPHA,[xme]:t.ONE_MINUS_SRC_COLOR,[zj]:t.ONE_MINUS_SRC_ALPHA,[_me]:t.ONE_MINUS_DST_COLOR,[vme]:t.ONE_MINUS_DST_ALPHA,[Nme]:t.CONSTANT_COLOR,[kme]:t.ONE_MINUS_CONSTANT_COLOR,[Mme]:t.CONSTANT_ALPHA,[Eme]:t.ONE_MINUS_CONSTANT_ALPHA};function V(_e,Je,Ae,Ke,je,Re,we,qe,xt,Et){if(_e===Du){y===!0&&(De(t.BLEND),y=!1);return}if(y===!1&&(fe(t.BLEND),y=!0),_e!==ume){if(_e!==x||Et!==C){if((v!==Of||T!==Of)&&(t.blendEquation(t.FUNC_ADD),v=Of,T=Of),Et)switch(_e){case Rg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case uB:t.blendFunc(t.ONE,t.ONE);break;case dB:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case hB:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Ei("WebGLState: Invalid blending: ",_e);break}else switch(_e){case Rg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case uB:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case dB:Ei("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case hB:Ei("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ei("WebGLState: Invalid blending: ",_e);break}S=null,N=null,M=null,A=null,k.set(0,0,0),R=0,x=_e,C=Et}return}je=je||Je,Re=Re||Ae,we=we||Ke,(Je!==v||je!==T)&&(t.blendEquationSeparate(ce[Je],ce[je]),v=Je,T=je),(Ae!==S||Ke!==N||Re!==M||we!==A)&&(t.blendFuncSeparate(Ve[Ae],Ve[Ke],Ve[Re],Ve[we]),S=Ae,N=Ke,M=Re,A=we),(qe.equals(k)===!1||xt!==R)&&(t.blendColor(qe.r,qe.g,qe.b,xt),k.copy(qe),R=xt),x=_e,C=!1}function Y(_e,Je){_e.side===lc?De(t.CULL_FACE):fe(t.CULL_FACE);let Ae=_e.side===Vs;Je&&(Ae=!Ae),de(Ae),_e.blending===Rg&&_e.transparent===!1?V(Du):V(_e.blending,_e.blendEquation,_e.blendSrc,_e.blendDst,_e.blendEquationAlpha,_e.blendSrcAlpha,_e.blendDstAlpha,_e.blendColor,_e.blendAlpha,_e.premultipliedAlpha),o.setFunc(_e.depthFunc),o.setTest(_e.depthTest),o.setMask(_e.depthWrite),s.setMask(_e.colorWrite);const Ke=_e.stencilWrite;l.setTest(Ke),Ke&&(l.setMask(_e.stencilWriteMask),l.setFunc(_e.stencilFunc,_e.stencilRef,_e.stencilFuncMask),l.setOp(_e.stencilFail,_e.stencilZFail,_e.stencilZPass)),X(_e.polygonOffset,_e.polygonOffsetFactor,_e.polygonOffsetUnits),_e.alphaToCoverage===!0?fe(t.SAMPLE_ALPHA_TO_COVERAGE):De(t.SAMPLE_ALPHA_TO_COVERAGE)}function de(_e){P!==_e&&(_e?t.frontFace(t.CW):t.frontFace(t.CCW),P=_e)}function q(_e){_e!==ome?(fe(t.CULL_FACE),_e!==U&&(_e===cB?t.cullFace(t.BACK):_e===lme?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):De(t.CULL_FACE),U=_e}function re(_e){_e!==F&&(G&&t.lineWidth(_e),F=_e)}function X(_e,Je,Ae){_e?(fe(t.POLYGON_OFFSET_FILL),(B!==Je||D!==Ae)&&(t.polygonOffset(Je,Ae),B=Je,D=Ae)):De(t.POLYGON_OFFSET_FILL)}function le(_e){_e?fe(t.SCISSOR_TEST):De(t.SCISSOR_TEST)}function pe(_e){_e===void 0&&(_e=t.TEXTURE0+$-1),Q!==_e&&(t.activeTexture(_e),Q=_e)}function ee(_e,Je,Ae){Ae===void 0&&(Q===null?Ae=t.TEXTURE0+$-1:Ae=Q);let Ke=se[Ae];Ke===void 0&&(Ke={type:void 0,texture:void 0},se[Ae]=Ke),(Ke.type!==_e||Ke.texture!==Je)&&(Q!==Ae&&(t.activeTexture(Ae),Q=Ae),t.bindTexture(_e,Je||ue[_e]),Ke.type=_e,Ke.texture=Je)}function z(){const _e=se[Q];_e!==void 0&&_e.type!==void 0&&(t.bindTexture(_e.type,null),_e.type=void 0,_e.texture=void 0)}function O(){try{t.compressedTexImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Z(){try{t.compressedTexImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function me(){try{t.texSubImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Te(){try{t.texSubImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function ke(){try{t.compressedTexSubImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ee(){try{t.compressedTexSubImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Se(){try{t.texStorage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function $e(){try{t.texStorage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Qe(){try{t.texImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ue(){try{t.texImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function be(_e){J.equals(_e)===!1&&(t.scissor(_e.x,_e.y,_e.z,_e.w),J.copy(_e))}function ve(_e){ne.equals(_e)===!1&&(t.viewport(_e.x,_e.y,_e.z,_e.w),ne.copy(_e))}function ze(_e,Je){let Ae=u.get(Je);Ae===void 0&&(Ae=new WeakMap,u.set(Je,Ae));let Ke=Ae.get(_e);Ke===void 0&&(Ke=t.getUniformBlockIndex(Je,_e.name),Ae.set(_e,Ke))}function Ce(_e,Je){const Ke=u.get(Je).get(_e);c.get(Je)!==Ke&&(t.uniformBlockBinding(Je,Ke,_e.__bindingPointIndex),c.set(Je,Ke))}function Ge(){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={},Q=null,se={},h={},p=new WeakMap,m=[],b=null,y=!1,x=null,v=null,S=null,N=null,T=null,M=null,A=null,k=new Fn(0,0,0),R=0,C=!1,P=null,U=null,F=null,B=null,D=null,J.set(0,0,t.canvas.width,t.canvas.height),ne.set(0,0,t.canvas.width,t.canvas.height),s.reset(),o.reset(),l.reset()}return{buffers:{color:s,depth:o,stencil:l},enable:fe,disable:De,bindFramebuffer:oe,drawBuffers:Ne,useProgram:Fe,setBlending:V,setMaterial:Y,setFlipSided:de,setCullFace:q,setLineWidth:re,setPolygonOffset:X,setScissorTest:le,activeTexture:pe,bindTexture:ee,unbindTexture:z,compressedTexImage2D:O,compressedTexImage3D:Z,texImage2D:Qe,texImage3D:Ue,updateUBOMapping:ze,uniformBlockBinding:Ce,texStorage2D:Se,texStorage3D:$e,texSubImage2D:me,texSubImage3D:Te,compressedTexSubImage2D:ke,compressedTexSubImage3D:Ee,scissor:be,viewport:ve,reset:Ge}}function gye(t,e,n,r,i,s,o){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new Rn,d=new WeakMap;let h;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b(z,O){return m?new OffscreenCanvas(z,O):hS("canvas")}function y(z,O,Z){let me=1;const Te=ee(z);if((Te.width>Z||Te.height>Z)&&(me=Z/Math.max(Te.width,Te.height)),me<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 ke=Math.floor(me*Te.width),Ee=Math.floor(me*Te.height);h===void 0&&(h=b(ke,Ee));const Se=O?b(ke,Ee):h;return Se.width=ke,Se.height=Ee,Se.getContext("2d").drawImage(z,0,0,ke,Ee),vn("WebGLRenderer: Texture has been resized from ("+Te.width+"x"+Te.height+") to ("+ke+"x"+Ee+")."),Se}else return"data"in z&&vn("WebGLRenderer: Image in DataTexture is too big ("+Te.width+"x"+Te.height+")."),z;return z}function x(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 N(z,O,Z,me,Te=!1){if(z!==null){if(t[z]!==void 0)return t[z];vn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let ke=O;if(O===t.RED&&(Z===t.FLOAT&&(ke=t.R32F),Z===t.HALF_FLOAT&&(ke=t.R16F),Z===t.UNSIGNED_BYTE&&(ke=t.R8)),O===t.RED_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ke=t.R8UI),Z===t.UNSIGNED_SHORT&&(ke=t.R16UI),Z===t.UNSIGNED_INT&&(ke=t.R32UI),Z===t.BYTE&&(ke=t.R8I),Z===t.SHORT&&(ke=t.R16I),Z===t.INT&&(ke=t.R32I)),O===t.RG&&(Z===t.FLOAT&&(ke=t.RG32F),Z===t.HALF_FLOAT&&(ke=t.RG16F),Z===t.UNSIGNED_BYTE&&(ke=t.RG8)),O===t.RG_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ke=t.RG8UI),Z===t.UNSIGNED_SHORT&&(ke=t.RG16UI),Z===t.UNSIGNED_INT&&(ke=t.RG32UI),Z===t.BYTE&&(ke=t.RG8I),Z===t.SHORT&&(ke=t.RG16I),Z===t.INT&&(ke=t.RG32I)),O===t.RGB_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ke=t.RGB8UI),Z===t.UNSIGNED_SHORT&&(ke=t.RGB16UI),Z===t.UNSIGNED_INT&&(ke=t.RGB32UI),Z===t.BYTE&&(ke=t.RGB8I),Z===t.SHORT&&(ke=t.RGB16I),Z===t.INT&&(ke=t.RGB32I)),O===t.RGBA_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ke=t.RGBA8UI),Z===t.UNSIGNED_SHORT&&(ke=t.RGBA16UI),Z===t.UNSIGNED_INT&&(ke=t.RGBA32UI),Z===t.BYTE&&(ke=t.RGBA8I),Z===t.SHORT&&(ke=t.RGBA16I),Z===t.INT&&(ke=t.RGBA32I)),O===t.RGB&&(Z===t.UNSIGNED_INT_5_9_9_9_REV&&(ke=t.RGB9_E5),Z===t.UNSIGNED_INT_10F_11F_11F_REV&&(ke=t.R11F_G11F_B10F)),O===t.RGBA){const Ee=Te?uS:or.getTransfer(me);Z===t.FLOAT&&(ke=t.RGBA32F),Z===t.HALF_FLOAT&&(ke=t.RGBA16F),Z===t.UNSIGNED_BYTE&&(ke=Ee===Tr?t.SRGB8_ALPHA8:t.RGBA8),Z===t.UNSIGNED_SHORT_4_4_4_4&&(ke=t.RGBA4),Z===t.UNSIGNED_SHORT_5_5_5_1&&(ke=t.RGB5_A1)}return(ke===t.R16F||ke===t.R32F||ke===t.RG16F||ke===t.RG32F||ke===t.RGBA16F||ke===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ke}function T(z,O){let Z;return z?O===null||O===ym||O===ny?Z=t.DEPTH24_STENCIL8:O===Mu?Z=t.DEPTH32F_STENCIL8:O===ty&&(Z=t.DEPTH24_STENCIL8,vn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===ym||O===ny?Z=t.DEPTH_COMPONENT24:O===Mu?Z=t.DEPTH_COMPONENT32F:O===ty&&(Z=t.DEPTH_COMPONENT16),Z}function M(z,O){return x(z)===!0||z.isFramebufferTexture&&z.minFilter!==_o&&z.minFilter!==il?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 A(z){const O=z.target;O.removeEventListener("dispose",A),R(O),O.isVideoTexture&&d.delete(O)}function k(z){const O=z.target;O.removeEventListener("dispose",k),P(O)}function R(z){const O=r.get(z);if(O.__webglInit===void 0)return;const Z=z.source,me=p.get(Z);if(me){const Te=me[O.__cacheKey];Te.usedTimes--,Te.usedTimes===0&&C(z),Object.keys(me).length===0&&p.delete(Z)}r.remove(z)}function C(z){const O=r.get(z);t.deleteTexture(O.__webglTexture);const Z=z.source,me=p.get(Z);delete me[O.__cacheKey],o.memory.textures--}function P(z){const O=r.get(z);if(z.depthTexture&&(z.depthTexture.dispose(),r.remove(z.depthTexture)),z.isWebGLCubeRenderTarget)for(let me=0;me<6;me++){if(Array.isArray(O.__webglFramebuffer[me]))for(let Te=0;Te<O.__webglFramebuffer[me].length;Te++)t.deleteFramebuffer(O.__webglFramebuffer[me][Te]);else t.deleteFramebuffer(O.__webglFramebuffer[me]);O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer[me])}else{if(Array.isArray(O.__webglFramebuffer))for(let me=0;me<O.__webglFramebuffer.length;me++)t.deleteFramebuffer(O.__webglFramebuffer[me]);else t.deleteFramebuffer(O.__webglFramebuffer);if(O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer),O.__webglMultisampledFramebuffer&&t.deleteFramebuffer(O.__webglMultisampledFramebuffer),O.__webglColorRenderbuffer)for(let me=0;me<O.__webglColorRenderbuffer.length;me++)O.__webglColorRenderbuffer[me]&&t.deleteRenderbuffer(O.__webglColorRenderbuffer[me]);O.__webglDepthRenderbuffer&&t.deleteRenderbuffer(O.__webglDepthRenderbuffer)}const Z=z.textures;for(let me=0,Te=Z.length;me<Te;me++){const ke=r.get(Z[me]);ke.__webglTexture&&(t.deleteTexture(ke.__webglTexture),o.memory.textures--),r.remove(Z[me])}r.remove(z)}let U=0;function F(){U=0}function B(){const z=U;return z>=i.maxTextures&&vn("WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+i.maxTextures),U+=1,z}function D(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 Z=r.get(z);if(z.isVideoTexture&&le(z),z.isRenderTargetTexture===!1&&z.isExternalTexture!==!0&&z.version>0&&Z.__version!==z.version){const me=z.image;if(me===null)vn("WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)vn("WebGLRenderer: Texture marked for update but image is incomplete");else{ue(Z,z,O);return}}else z.isExternalTexture&&(Z.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,Z.__webglTexture,t.TEXTURE0+O)}function G(z,O){const Z=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&Z.__version!==z.version){ue(Z,z,O);return}else z.isExternalTexture&&(Z.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,Z.__webglTexture,t.TEXTURE0+O)}function I(z,O){const Z=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&Z.__version!==z.version){ue(Z,z,O);return}n.bindTexture(t.TEXTURE_3D,Z.__webglTexture,t.TEXTURE0+O)}function K(z,O){const Z=r.get(z);if(z.version>0&&Z.__version!==z.version){fe(Z,z,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Z.__webglTexture,t.TEXTURE0+O)}const Q={[Xj]:t.REPEAT,[ku]:t.CLAMP_TO_EDGE,[Yj]:t.MIRRORED_REPEAT},se={[_o]:t.NEAREST,[Fme]:t.NEAREST_MIPMAP_NEAREST,[Kw]:t.NEAREST_MIPMAP_LINEAR,[il]:t.LINEAR,[vT]:t.LINEAR_MIPMAP_NEAREST,[$f]:t.LINEAR_MIPMAP_LINEAR},H={[Bme]:t.NEVER,[Wme]:t.ALWAYS,[Hme]:t.LESS,[hK]:t.LEQUAL,[$me]:t.EQUAL,[qme]:t.GEQUAL,[Vme]:t.GREATER,[Gme]:t.NOTEQUAL};function W(z,O){if(O.type===Mu&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===il||O.magFilter===vT||O.magFilter===Kw||O.magFilter===$f||O.minFilter===il||O.minFilter===vT||O.minFilter===Kw||O.minFilter===$f)&&vn("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,Q[O.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,Q[O.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,Q[O.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,se[O.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,se[O.minFilter]),O.compareFunction&&(t.texParameteri(z,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(z,t.TEXTURE_COMPARE_FUNC,H[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===_o||O.minFilter!==Kw&&O.minFilter!==$f||O.type===Mu&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||r.get(O).__currentAnisotropy){const Z=e.get("EXT_texture_filter_anisotropic");t.texParameterf(z,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy}}}function J(z,O){let Z=!1;z.__webglInit===void 0&&(z.__webglInit=!0,O.addEventListener("dispose",A));const me=O.source;let Te=p.get(me);Te===void 0&&(Te={},p.set(me,Te));const ke=D(O);if(ke!==z.__cacheKey){Te[ke]===void 0&&(Te[ke]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Z=!0),Te[ke].usedTimes++;const Ee=Te[z.__cacheKey];Ee!==void 0&&(Te[z.__cacheKey].usedTimes--,Ee.usedTimes===0&&C(O)),z.__cacheKey=ke,z.__webglTexture=Te[ke].texture}return Z}function ne(z,O,Z){return Math.floor(Math.floor(z/Z)/O)}function xe(z,O,Z,me){const ke=z.updateRanges;if(ke.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,O.width,O.height,Z,me,O.data);else{ke.sort((Ue,be)=>Ue.start-be.start);let Ee=0;for(let Ue=1;Ue<ke.length;Ue++){const be=ke[Ee],ve=ke[Ue],ze=be.start+be.count,Ce=ne(ve.start,O.width,4),Ge=ne(be.start,O.width,4);ve.start<=ze+1&&Ce===Ge&&ne(ve.start+ve.count-1,O.width,4)===Ce?be.count=Math.max(be.count,ve.start+ve.count-be.start):(++Ee,ke[Ee]=ve)}ke.length=Ee+1;const Se=t.getParameter(t.UNPACK_ROW_LENGTH),$e=t.getParameter(t.UNPACK_SKIP_PIXELS),Qe=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,O.width);for(let Ue=0,be=ke.length;Ue<be;Ue++){const ve=ke[Ue],ze=Math.floor(ve.start/4),Ce=Math.ceil(ve.count/4),Ge=ze%O.width,_e=Math.floor(ze/O.width),Je=Ce,Ae=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ge),t.pixelStorei(t.UNPACK_SKIP_ROWS,_e),n.texSubImage2D(t.TEXTURE_2D,0,Ge,_e,Je,Ae,Z,me,O.data)}z.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Se),t.pixelStorei(t.UNPACK_SKIP_PIXELS,$e),t.pixelStorei(t.UNPACK_SKIP_ROWS,Qe)}}function ue(z,O,Z){let me=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(me=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(me=t.TEXTURE_3D);const Te=J(z,O),ke=O.source;n.bindTexture(me,z.__webglTexture,t.TEXTURE0+Z);const Ee=r.get(ke);if(ke.version!==Ee.__version||Te===!0){n.activeTexture(t.TEXTURE0+Z);const Se=or.getPrimaries(or.workingColorSpace),$e=O.colorSpace===ih?null:or.getPrimaries(O.colorSpace),Qe=O.colorSpace===ih||Se===$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,Qe);let Ue=y(O.image,!1,i.maxTextureSize);Ue=pe(O,Ue);const be=s.convert(O.format,O.colorSpace),ve=s.convert(O.type);let ze=N(O.internalFormat,be,ve,O.colorSpace,O.isVideoTexture);W(me,O);let Ce;const Ge=O.mipmaps,_e=O.isVideoTexture!==!0,Je=Ee.__version===void 0||Te===!0,Ae=ke.dataReady,Ke=M(O,Ue);if(O.isDepthTexture)ze=T(O.format===iy,O.type),Je&&(_e?n.texStorage2D(t.TEXTURE_2D,1,ze,Ue.width,Ue.height):n.texImage2D(t.TEXTURE_2D,0,ze,Ue.width,Ue.height,0,be,ve,null));else if(O.isDataTexture)if(Ge.length>0){_e&&Je&&n.texStorage2D(t.TEXTURE_2D,Ke,ze,Ge[0].width,Ge[0].height);for(let je=0,Re=Ge.length;je<Re;je++)Ce=Ge[je],_e?Ae&&n.texSubImage2D(t.TEXTURE_2D,je,0,0,Ce.width,Ce.height,be,ve,Ce.data):n.texImage2D(t.TEXTURE_2D,je,ze,Ce.width,Ce.height,0,be,ve,Ce.data);O.generateMipmaps=!1}else _e?(Je&&n.texStorage2D(t.TEXTURE_2D,Ke,ze,Ue.width,Ue.height),Ae&&xe(O,Ue,be,ve)):n.texImage2D(t.TEXTURE_2D,0,ze,Ue.width,Ue.height,0,be,ve,Ue.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){_e&&Je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ke,ze,Ge[0].width,Ge[0].height,Ue.depth);for(let je=0,Re=Ge.length;je<Re;je++)if(Ce=Ge[je],O.format!==Fl)if(be!==null)if(_e){if(Ae)if(O.layerUpdates.size>0){const we=$B(Ce.width,Ce.height,O.format,O.type);for(const qe of O.layerUpdates){const xt=Ce.data.subarray(qe*we/Ce.data.BYTES_PER_ELEMENT,(qe+1)*we/Ce.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,qe,Ce.width,Ce.height,1,be,xt)}O.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,0,Ce.width,Ce.height,Ue.depth,be,Ce.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,je,ze,Ce.width,Ce.height,Ue.depth,0,Ce.data,0,0);else vn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else _e?Ae&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,0,Ce.width,Ce.height,Ue.depth,be,ve,Ce.data):n.texImage3D(t.TEXTURE_2D_ARRAY,je,ze,Ce.width,Ce.height,Ue.depth,0,be,ve,Ce.data)}else{_e&&Je&&n.texStorage2D(t.TEXTURE_2D,Ke,ze,Ge[0].width,Ge[0].height);for(let je=0,Re=Ge.length;je<Re;je++)Ce=Ge[je],O.format!==Fl?be!==null?_e?Ae&&n.compressedTexSubImage2D(t.TEXTURE_2D,je,0,0,Ce.width,Ce.height,be,Ce.data):n.compressedTexImage2D(t.TEXTURE_2D,je,ze,Ce.width,Ce.height,0,Ce.data):vn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):_e?Ae&&n.texSubImage2D(t.TEXTURE_2D,je,0,0,Ce.width,Ce.height,be,ve,Ce.data):n.texImage2D(t.TEXTURE_2D,je,ze,Ce.width,Ce.height,0,be,ve,Ce.data)}else if(O.isDataArrayTexture)if(_e){if(Je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ke,ze,Ue.width,Ue.height,Ue.depth),Ae)if(O.layerUpdates.size>0){const je=$B(Ue.width,Ue.height,O.format,O.type);for(const Re of O.layerUpdates){const we=Ue.data.subarray(Re*je/Ue.data.BYTES_PER_ELEMENT,(Re+1)*je/Ue.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Re,Ue.width,Ue.height,1,be,ve,we)}O.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ue.width,Ue.height,Ue.depth,be,ve,Ue.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,ze,Ue.width,Ue.height,Ue.depth,0,be,ve,Ue.data);else if(O.isData3DTexture)_e?(Je&&n.texStorage3D(t.TEXTURE_3D,Ke,ze,Ue.width,Ue.height,Ue.depth),Ae&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ue.width,Ue.height,Ue.depth,be,ve,Ue.data)):n.texImage3D(t.TEXTURE_3D,0,ze,Ue.width,Ue.height,Ue.depth,0,be,ve,Ue.data);else if(O.isFramebufferTexture){if(Je)if(_e)n.texStorage2D(t.TEXTURE_2D,Ke,ze,Ue.width,Ue.height);else{let je=Ue.width,Re=Ue.height;for(let we=0;we<Ke;we++)n.texImage2D(t.TEXTURE_2D,we,ze,je,Re,0,be,ve,null),je>>=1,Re>>=1}}else if(Ge.length>0){if(_e&&Je){const je=ee(Ge[0]);n.texStorage2D(t.TEXTURE_2D,Ke,ze,je.width,je.height)}for(let je=0,Re=Ge.length;je<Re;je++)Ce=Ge[je],_e?Ae&&n.texSubImage2D(t.TEXTURE_2D,je,0,0,be,ve,Ce):n.texImage2D(t.TEXTURE_2D,je,ze,be,ve,Ce);O.generateMipmaps=!1}else if(_e){if(Je){const je=ee(Ue);n.texStorage2D(t.TEXTURE_2D,Ke,ze,je.width,je.height)}Ae&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,be,ve,Ue)}else n.texImage2D(t.TEXTURE_2D,0,ze,be,ve,Ue);x(O)&&v(me),Ee.__version=ke.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function fe(z,O,Z){if(O.image.length!==6)return;const me=J(z,O),Te=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+Z);const ke=r.get(Te);if(Te.version!==ke.__version||me===!0){n.activeTexture(t.TEXTURE0+Z);const Ee=or.getPrimaries(or.workingColorSpace),Se=O.colorSpace===ih?null:or.getPrimaries(O.colorSpace),$e=O.colorSpace===ih||Ee===Se?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 Qe=O.isCompressedTexture||O.image[0].isCompressedTexture,Ue=O.image[0]&&O.image[0].isDataTexture,be=[];for(let Re=0;Re<6;Re++)!Qe&&!Ue?be[Re]=y(O.image[Re],!0,i.maxCubemapSize):be[Re]=Ue?O.image[Re].image:O.image[Re],be[Re]=pe(O,be[Re]);const ve=be[0],ze=s.convert(O.format,O.colorSpace),Ce=s.convert(O.type),Ge=N(O.internalFormat,ze,Ce,O.colorSpace),_e=O.isVideoTexture!==!0,Je=ke.__version===void 0||me===!0,Ae=Te.dataReady;let Ke=M(O,ve);W(t.TEXTURE_CUBE_MAP,O);let je;if(Qe){_e&&Je&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ke,Ge,ve.width,ve.height);for(let Re=0;Re<6;Re++){je=be[Re].mipmaps;for(let we=0;we<je.length;we++){const qe=je[we];O.format!==Fl?ze!==null?_e?Ae&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we,0,0,qe.width,qe.height,ze,qe.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we,Ge,qe.width,qe.height,0,qe.data):vn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_e?Ae&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we,0,0,qe.width,qe.height,ze,Ce,qe.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we,Ge,qe.width,qe.height,0,ze,Ce,qe.data)}}}else{if(je=O.mipmaps,_e&&Je){je.length>0&&Ke++;const Re=ee(be[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Ke,Ge,Re.width,Re.height)}for(let Re=0;Re<6;Re++)if(Ue){_e?Ae&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,0,0,be[Re].width,be[Re].height,ze,Ce,be[Re].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,Ge,be[Re].width,be[Re].height,0,ze,Ce,be[Re].data);for(let we=0;we<je.length;we++){const xt=je[we].image[Re].image;_e?Ae&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we+1,0,0,xt.width,xt.height,ze,Ce,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we+1,Ge,xt.width,xt.height,0,ze,Ce,xt.data)}}else{_e?Ae&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,0,0,ze,Ce,be[Re]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,Ge,ze,Ce,be[Re]);for(let we=0;we<je.length;we++){const qe=je[we];_e?Ae&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we+1,0,0,ze,Ce,qe.image[Re]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we+1,Ge,ze,Ce,qe.image[Re])}}}x(O)&&v(t.TEXTURE_CUBE_MAP),ke.__version=Te.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function De(z,O,Z,me,Te,ke){const Ee=s.convert(Z.format,Z.colorSpace),Se=s.convert(Z.type),$e=N(Z.internalFormat,Ee,Se,Z.colorSpace),Qe=r.get(O),Ue=r.get(Z);if(Ue.__renderTarget=O,!Qe.__hasExternalTextures){const be=Math.max(1,O.width>>ke),ve=Math.max(1,O.height>>ke);Te===t.TEXTURE_3D||Te===t.TEXTURE_2D_ARRAY?n.texImage3D(Te,ke,$e,be,ve,O.depth,0,Ee,Se,null):n.texImage2D(Te,ke,$e,be,ve,0,Ee,Se,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),X(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,me,Te,Ue.__webglTexture,0,re(O)):(Te===t.TEXTURE_2D||Te>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Te<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,me,Te,Ue.__webglTexture,ke),n.bindFramebuffer(t.FRAMEBUFFER,null)}function oe(z,O,Z){if(t.bindRenderbuffer(t.RENDERBUFFER,z),O.depthBuffer){const me=O.depthTexture,Te=me&&me.isDepthTexture?me.type:null,ke=T(O.stencilBuffer,Te),Ee=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Se=re(O);X(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Se,ke,O.width,O.height):Z?t.renderbufferStorageMultisample(t.RENDERBUFFER,Se,ke,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,ke,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ee,t.RENDERBUFFER,z)}else{const me=O.textures;for(let Te=0;Te<me.length;Te++){const ke=me[Te],Ee=s.convert(ke.format,ke.colorSpace),Se=s.convert(ke.type),$e=N(ke.internalFormat,Ee,Se,ke.colorSpace),Qe=re(O);Z&&X(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Qe,$e,O.width,O.height):X(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Qe,$e,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,$e,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ne(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 me=r.get(O.depthTexture);me.__renderTarget=O,(!me.__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 Te=me.__webglTexture,ke=re(O);if(O.depthTexture.format===ry)X(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Te,0,ke):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Te,0);else if(O.depthTexture.format===iy)X(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Te,0,ke):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Te,0);else throw new Error("Unknown depthTexture format")}function Fe(z){const O=r.get(z),Z=z.isWebGLCubeRenderTarget===!0;if(O.__boundDepthTexture!==z.depthTexture){const me=z.depthTexture;if(O.__depthDisposeCallback&&O.__depthDisposeCallback(),me){const Te=()=>{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,me.removeEventListener("dispose",Te)};me.addEventListener("dispose",Te),O.__depthDisposeCallback=Te}O.__boundDepthTexture=me}if(z.depthTexture&&!O.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");const me=z.texture.mipmaps;me&&me.length>0?Ne(O.__webglFramebuffer[0],z):Ne(O.__webglFramebuffer,z)}else if(Z){O.__webglDepthbuffer=[];for(let me=0;me<6;me++)if(n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[me]),O.__webglDepthbuffer[me]===void 0)O.__webglDepthbuffer[me]=t.createRenderbuffer(),oe(O.__webglDepthbuffer[me],z,!1);else{const Te=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ke=O.__webglDepthbuffer[me];t.bindRenderbuffer(t.RENDERBUFFER,ke),t.framebufferRenderbuffer(t.FRAMEBUFFER,Te,t.RENDERBUFFER,ke)}}else{const me=z.texture.mipmaps;if(me&&me.length>0?n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=t.createRenderbuffer(),oe(O.__webglDepthbuffer,z,!1);else{const Te=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ke=O.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ke),t.framebufferRenderbuffer(t.FRAMEBUFFER,Te,t.RENDERBUFFER,ke)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ce(z,O,Z){const me=r.get(z);O!==void 0&&De(me.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Z!==void 0&&Fe(z)}function Ve(z){const O=z.texture,Z=r.get(z),me=r.get(O);z.addEventListener("dispose",k);const Te=z.textures,ke=z.isWebGLCubeRenderTarget===!0,Ee=Te.length>1;if(Ee||(me.__webglTexture===void 0&&(me.__webglTexture=t.createTexture()),me.__version=O.version,o.memory.textures++),ke){Z.__webglFramebuffer=[];for(let Se=0;Se<6;Se++)if(O.mipmaps&&O.mipmaps.length>0){Z.__webglFramebuffer[Se]=[];for(let $e=0;$e<O.mipmaps.length;$e++)Z.__webglFramebuffer[Se][$e]=t.createFramebuffer()}else Z.__webglFramebuffer[Se]=t.createFramebuffer()}else{if(O.mipmaps&&O.mipmaps.length>0){Z.__webglFramebuffer=[];for(let Se=0;Se<O.mipmaps.length;Se++)Z.__webglFramebuffer[Se]=t.createFramebuffer()}else Z.__webglFramebuffer=t.createFramebuffer();if(Ee)for(let Se=0,$e=Te.length;Se<$e;Se++){const Qe=r.get(Te[Se]);Qe.__webglTexture===void 0&&(Qe.__webglTexture=t.createTexture(),o.memory.textures++)}if(z.samples>0&&X(z)===!1){Z.__webglMultisampledFramebuffer=t.createFramebuffer(),Z.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let Se=0;Se<Te.length;Se++){const $e=Te[Se];Z.__webglColorRenderbuffer[Se]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Z.__webglColorRenderbuffer[Se]);const Qe=s.convert($e.format,$e.colorSpace),Ue=s.convert($e.type),be=N($e.internalFormat,Qe,Ue,$e.colorSpace,z.isXRRenderTarget===!0),ve=re(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,be,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Se,t.RENDERBUFFER,Z.__webglColorRenderbuffer[Se])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(Z.__webglDepthRenderbuffer=t.createRenderbuffer(),oe(Z.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ke){n.bindTexture(t.TEXTURE_CUBE_MAP,me.__webglTexture),W(t.TEXTURE_CUBE_MAP,O);for(let Se=0;Se<6;Se++)if(O.mipmaps&&O.mipmaps.length>0)for(let $e=0;$e<O.mipmaps.length;$e++)De(Z.__webglFramebuffer[Se][$e],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,$e);else De(Z.__webglFramebuffer[Se],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0);x(O)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Ee){for(let Se=0,$e=Te.length;Se<$e;Se++){const Qe=Te[Se],Ue=r.get(Qe);let be=t.TEXTURE_2D;(z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(be=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(be,Ue.__webglTexture),W(be,Qe),De(Z.__webglFramebuffer,z,Qe,t.COLOR_ATTACHMENT0+Se,be,0),x(Qe)&&v(be)}n.unbindTexture()}else{let Se=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(Se=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Se,me.__webglTexture),W(Se,O),O.mipmaps&&O.mipmaps.length>0)for(let $e=0;$e<O.mipmaps.length;$e++)De(Z.__webglFramebuffer[$e],z,O,t.COLOR_ATTACHMENT0,Se,$e);else De(Z.__webglFramebuffer,z,O,t.COLOR_ATTACHMENT0,Se,0);x(O)&&v(Se),n.unbindTexture()}z.depthBuffer&&Fe(z)}function V(z){const O=z.textures;for(let Z=0,me=O.length;Z<me;Z++){const Te=O[Z];if(x(Te)){const ke=S(z),Ee=r.get(Te).__webglTexture;n.bindTexture(ke,Ee),v(ke),n.unbindTexture()}}}const Y=[],de=[];function q(z){if(z.samples>0){if(X(z)===!1){const O=z.textures,Z=z.width,me=z.height;let Te=t.COLOR_BUFFER_BIT;const ke=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ee=r.get(z),Se=O.length>1;if(Se)for(let Qe=0;Qe<O.length;Qe++)n.bindFramebuffer(t.FRAMEBUFFER,Ee.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ee.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ee.__webglMultisampledFramebuffer);const $e=z.texture.mipmaps;$e&&$e.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ee.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ee.__webglFramebuffer);for(let Qe=0;Qe<O.length;Qe++){if(z.resolveDepthBuffer&&(z.depthBuffer&&(Te|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&z.resolveStencilBuffer&&(Te|=t.STENCIL_BUFFER_BIT)),Se){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ee.__webglColorRenderbuffer[Qe]);const Ue=r.get(O[Qe]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ue,0)}t.blitFramebuffer(0,0,Z,me,0,0,Z,me,Te,t.NEAREST),c===!0&&(Y.length=0,de.length=0,Y.push(t.COLOR_ATTACHMENT0+Qe),z.depthBuffer&&z.resolveDepthBuffer===!1&&(Y.push(ke),de.push(ke),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,de)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,Y))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Se)for(let Qe=0;Qe<O.length;Qe++){n.bindFramebuffer(t.FRAMEBUFFER,Ee.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.RENDERBUFFER,Ee.__webglColorRenderbuffer[Qe]);const Ue=r.get(O[Qe]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ee.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.TEXTURE_2D,Ue,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ee.__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 re(z){return Math.min(i.maxSamples,z.samples)}function X(z){const O=r.get(z);return z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function le(z){const O=o.render.frame;d.get(z)!==O&&(d.set(z,O),z.update())}function pe(z,O){const Z=z.colorSpace,me=z.format,Te=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||Z!==eb&&Z!==ih&&(or.getTransfer(Z)===Tr?(me!==Fl||Te!==_c)&&vn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ei("WebGLTextures: Unsupported texture color space:",Z)),O}function ee(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=B,this.resetTextureUnits=F,this.setTexture2D=$,this.setTexture2DArray=G,this.setTexture3D=I,this.setTextureCube=K,this.rebindTextures=ce,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=V,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Fe,this.setupFrameBufferTexture=De,this.useMultisampledRTT=X}function bye(t,e){function n(r,i=ih){let s;const o=or.getTransfer(i);if(r===_c)return t.UNSIGNED_BYTE;if(r===sO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===oO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===sK)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===oK)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===iK)return t.BYTE;if(r===aK)return t.SHORT;if(r===ty)return t.UNSIGNED_SHORT;if(r===aO)return t.INT;if(r===ym)return t.UNSIGNED_INT;if(r===Mu)return t.FLOAT;if(r===Tb)return t.HALF_FLOAT;if(r===lK)return t.ALPHA;if(r===cK)return t.RGB;if(r===Fl)return t.RGBA;if(r===ry)return t.DEPTH_COMPONENT;if(r===iy)return t.DEPTH_STENCIL;if(r===uK)return t.RED;if(r===lO)return t.RED_INTEGER;if(r===cO)return t.RG;if(r===uO)return t.RG_INTEGER;if(r===dO)return t.RGBA_INTEGER;if(r===j1||r===D1||r===R1||r===O1)if(o===Tr)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===j1)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===D1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===R1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===O1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===j1)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===D1)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===R1)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===O1)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Qj||r===Zj||r===Jj||r===e3)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===Qj)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Zj)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Jj)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===e3)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===t3||r===n3||r===r3)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===t3||r===n3)return o===Tr?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===r3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===i3||r===a3||r===s3||r===o3||r===l3||r===c3||r===u3||r===d3||r===h3||r===f3||r===m3||r===p3||r===g3||r===b3)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===i3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===a3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===s3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===o3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===l3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===c3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===u3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===d3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===h3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===f3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===m3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===p3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===g3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===b3)return o===Tr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===x3||r===y3||r===v3)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===x3)return o===Tr?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===y3)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===v3)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===w3||r===_3||r===S3||r===N3)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===w3)return s.COMPRESSED_RED_RGTC1_EXT;if(r===_3)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===S3)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===N3)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===ny?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const xye=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,yye=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class vye{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new PK(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 Wu({vertexShader:xye,fragmentShader:yye,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new hl(new bO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let wye=class extends Im{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,h=null,p=null,m=null,b=null;const y=typeof XRWebGLBinding<"u",x=new vye,v={},S=n.getContextAttributes();let N=null,T=null;const M=[],A=[],k=new Rn;let R=null;const C=new Jo;C.viewport=new Bi;const P=new Jo;P.viewport=new Bi;const U=[C,P],F=new Ipe;let B=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ue){let fe=M[ue];return fe===void 0&&(fe=new HT,M[ue]=fe),fe.getTargetRaySpace()},this.getControllerGrip=function(ue){let fe=M[ue];return fe===void 0&&(fe=new HT,M[ue]=fe),fe.getGripSpace()},this.getHand=function(ue){let fe=M[ue];return fe===void 0&&(fe=new HT,M[ue]=fe),fe.getHandSpace()};function $(ue){const fe=A.indexOf(ue.inputSource);if(fe===-1)return;const De=M[fe];De!==void 0&&(De.update(ue.inputSource,ue.frame,u||o),De.dispatchEvent({type:ue.type,data:ue.inputSource}))}function G(){i.removeEventListener("select",$),i.removeEventListener("selectstart",$),i.removeEventListener("selectend",$),i.removeEventListener("squeeze",$),i.removeEventListener("squeezestart",$),i.removeEventListener("squeezeend",$),i.removeEventListener("end",G),i.removeEventListener("inputsourceschange",I);for(let ue=0;ue<M.length;ue++){const fe=A[ue];fe!==null&&(A[ue]=null,M[ue].disconnect(fe))}B=null,D=null,x.reset();for(const ue in v)delete v[ue];e.setRenderTarget(N),m=null,p=null,h=null,i=null,T=null,xe.stop(),r.isPresenting=!1,e.setPixelRatio(R),e.setSize(k.width,k.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ue){s=ue,r.isPresenting===!0&&vn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ue){l=ue,r.isPresenting===!0&&vn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ue){u=ue},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(i,n)),h},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(ue){if(i=ue,i!==null){if(N=e.getRenderTarget(),i.addEventListener("select",$),i.addEventListener("selectstart",$),i.addEventListener("selectend",$),i.addEventListener("squeeze",$),i.addEventListener("squeezestart",$),i.addEventListener("squeezeend",$),i.addEventListener("end",G),i.addEventListener("inputsourceschange",I),S.xrCompatible!==!0&&await n.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(k),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let De=null,oe=null,Ne=null;S.depth&&(Ne=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,De=S.stencil?iy:ry,oe=S.stencil?ny:ym);const Fe={colorFormat:n.RGBA8,depthFormat:Ne,scaleFactor:s};h=this.getBinding(),p=h.createProjectionLayer(Fe),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),T=new wm(p.textureWidth,p.textureHeight,{format:Fl,type:_c,depthTexture:new CK(p.textureWidth,p.textureHeight,oe,void 0,void 0,void 0,void 0,void 0,void 0,De),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const De={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,De),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),T=new wm(m.framebufferWidth,m.framebufferHeight,{format:Fl,type:_c,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),xe.setContext(i),xe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function I(ue){for(let fe=0;fe<ue.removed.length;fe++){const De=ue.removed[fe],oe=A.indexOf(De);oe>=0&&(A[oe]=null,M[oe].disconnect(De))}for(let fe=0;fe<ue.added.length;fe++){const De=ue.added[fe];let oe=A.indexOf(De);if(oe===-1){for(let Fe=0;Fe<M.length;Fe++)if(Fe>=A.length){A.push(De),oe=Fe;break}else if(A[Fe]===null){A[Fe]=De,oe=Fe;break}if(oe===-1)break}const Ne=M[oe];Ne&&Ne.connect(De)}}const K=new pt,Q=new pt;function se(ue,fe,De){K.setFromMatrixPosition(fe.matrixWorld),Q.setFromMatrixPosition(De.matrixWorld);const oe=K.distanceTo(Q),Ne=fe.projectionMatrix.elements,Fe=De.projectionMatrix.elements,ce=Ne[14]/(Ne[10]-1),Ve=Ne[14]/(Ne[10]+1),V=(Ne[9]+1)/Ne[5],Y=(Ne[9]-1)/Ne[5],de=(Ne[8]-1)/Ne[0],q=(Fe[8]+1)/Fe[0],re=ce*de,X=ce*q,le=oe/(-de+q),pe=le*-de;if(fe.matrixWorld.decompose(ue.position,ue.quaternion,ue.scale),ue.translateX(pe),ue.translateZ(le),ue.matrixWorld.compose(ue.position,ue.quaternion,ue.scale),ue.matrixWorldInverse.copy(ue.matrixWorld).invert(),Ne[10]===-1)ue.projectionMatrix.copy(fe.projectionMatrix),ue.projectionMatrixInverse.copy(fe.projectionMatrixInverse);else{const ee=ce+le,z=Ve+le,O=re-pe,Z=X+(oe-pe),me=V*Ve/z*ee,Te=Y*Ve/z*ee;ue.projectionMatrix.makePerspective(O,Z,me,Te,ee,z),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert()}}function H(ue,fe){fe===null?ue.matrixWorld.copy(ue.matrix):ue.matrixWorld.multiplyMatrices(fe.matrixWorld,ue.matrix),ue.matrixWorldInverse.copy(ue.matrixWorld).invert()}this.updateCamera=function(ue){if(i===null)return;let fe=ue.near,De=ue.far;x.texture!==null&&(x.depthNear>0&&(fe=x.depthNear),x.depthFar>0&&(De=x.depthFar)),F.near=P.near=C.near=fe,F.far=P.far=C.far=De,(B!==F.near||D!==F.far)&&(i.updateRenderState({depthNear:F.near,depthFar:F.far}),B=F.near,D=F.far),F.layers.mask=ue.layers.mask|6,C.layers.mask=F.layers.mask&3,P.layers.mask=F.layers.mask&5;const oe=ue.parent,Ne=F.cameras;H(F,oe);for(let Fe=0;Fe<Ne.length;Fe++)H(Ne[Fe],oe);Ne.length===2?se(F,C,P):F.projectionMatrix.copy(C.projectionMatrix),W(ue,F,oe)};function W(ue,fe,De){De===null?ue.matrix.copy(fe.matrixWorld):(ue.matrix.copy(De.matrixWorld),ue.matrix.invert(),ue.matrix.multiply(fe.matrixWorld)),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.updateMatrixWorld(!0),ue.projectionMatrix.copy(fe.projectionMatrix),ue.projectionMatrixInverse.copy(fe.projectionMatrixInverse),ue.isPerspectiveCamera&&(ue.fov=k3*2*Math.atan(1/ue.projectionMatrix.elements[5]),ue.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(ue){c=ue,p!==null&&(p.fixedFoveation=ue),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ue)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(F)},this.getCameraTexture=function(ue){return v[ue]};let J=null;function ne(ue,fe){if(d=fe.getViewerPose(u||o),b=fe,d!==null){const De=d.views;m!==null&&(e.setRenderTargetFramebuffer(T,m.framebuffer),e.setRenderTarget(T));let oe=!1;De.length!==F.cameras.length&&(F.cameras.length=0,oe=!0);for(let Ve=0;Ve<De.length;Ve++){const V=De[Ve];let Y=null;if(m!==null)Y=m.getViewport(V);else{const q=h.getViewSubImage(p,V);Y=q.viewport,Ve===0&&(e.setRenderTargetTextures(T,q.colorTexture,q.depthStencilTexture),e.setRenderTarget(T))}let de=U[Ve];de===void 0&&(de=new Jo,de.layers.enable(Ve),de.viewport=new Bi,U[Ve]=de),de.matrix.fromArray(V.transform.matrix),de.matrix.decompose(de.position,de.quaternion,de.scale),de.projectionMatrix.fromArray(V.projectionMatrix),de.projectionMatrixInverse.copy(de.projectionMatrix).invert(),de.viewport.set(Y.x,Y.y,Y.width,Y.height),Ve===0&&(F.matrix.copy(de.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),oe===!0&&F.cameras.push(de)}const Ne=i.enabledFeatures;if(Ne&&Ne.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){h=r.getBinding();const Ve=h.getDepthInformation(De[0]);Ve&&Ve.isValid&&Ve.texture&&x.init(Ve,i.renderState)}if(Ne&&Ne.includes("camera-access")&&y){e.state.unbindTexture(),h=r.getBinding();for(let Ve=0;Ve<De.length;Ve++){const V=De[Ve].camera;if(V){let Y=v[V];Y||(Y=new PK,v[V]=Y);const de=h.getCameraImage(V);Y.sourceTexture=de}}}}for(let De=0;De<M.length;De++){const oe=A[De],Ne=M[De];oe!==null&&Ne!==void 0&&Ne.update(oe,fe,u||o)}J&&J(ue,fe),fe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:fe}),b=null}const xe=new LK;xe.setAnimationLoop(ne),this.setAnimationLoop=function(ue){J=ue},this.dispose=function(){}}};const wf=new Dh,_ye=new Gi;function Sye(t,e){function n(x,v){x.matrixAutoUpdate===!0&&x.updateMatrix(),v.value.copy(x.matrix)}function r(x,v){v.color.getRGB(x.fogColor.value,MK(t)),v.isFog?(x.fogNear.value=v.near,x.fogFar.value=v.far):v.isFogExp2&&(x.fogDensity.value=v.density)}function i(x,v,S,N,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(x,v):v.isMeshToonMaterial?(s(x,v),h(x,v)):v.isMeshPhongMaterial?(s(x,v),d(x,v)):v.isMeshStandardMaterial?(s(x,v),p(x,v),v.isMeshPhysicalMaterial&&m(x,v,T)):v.isMeshMatcapMaterial?(s(x,v),b(x,v)):v.isMeshDepthMaterial?s(x,v):v.isMeshDistanceMaterial?(s(x,v),y(x,v)):v.isMeshNormalMaterial?s(x,v):v.isLineBasicMaterial?(o(x,v),v.isLineDashedMaterial&&l(x,v)):v.isPointsMaterial?c(x,v,S,N):v.isSpriteMaterial?u(x,v):v.isShadowMaterial?(x.color.value.copy(v.color),x.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(x,v){x.opacity.value=v.opacity,v.color&&x.diffuse.value.copy(v.color),v.emissive&&x.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.bumpMap&&(x.bumpMap.value=v.bumpMap,n(v.bumpMap,x.bumpMapTransform),x.bumpScale.value=v.bumpScale,v.side===Vs&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===Vs&&x.normalScale.value.negate()),v.displacementMap&&(x.displacementMap.value=v.displacementMap,n(v.displacementMap,x.displacementMapTransform),x.displacementScale.value=v.displacementScale,x.displacementBias.value=v.displacementBias),v.emissiveMap&&(x.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,x.emissiveMapTransform)),v.specularMap&&(x.specularMap.value=v.specularMap,n(v.specularMap,x.specularMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest);const S=e.get(v),N=S.envMap,T=S.envMapRotation;N&&(x.envMap.value=N,wf.copy(T),wf.x*=-1,wf.y*=-1,wf.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(wf.y*=-1,wf.z*=-1),x.envMapRotation.value.setFromMatrix4(_ye.makeRotationFromEuler(wf)),x.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=v.reflectivity,x.ior.value=v.ior,x.refractionRatio.value=v.refractionRatio),v.lightMap&&(x.lightMap.value=v.lightMap,x.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,x.lightMapTransform)),v.aoMap&&(x.aoMap.value=v.aoMap,x.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,x.aoMapTransform))}function o(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform))}function l(x,v){x.dashSize.value=v.dashSize,x.totalSize.value=v.dashSize+v.gapSize,x.scale.value=v.scale}function c(x,v,S,N){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.size.value=v.size*S,x.scale.value=N*.5,v.map&&(x.map.value=v.map,n(v.map,x.uvTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function u(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.rotation.value=v.rotation,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function d(x,v){x.specular.value.copy(v.specular),x.shininess.value=Math.max(v.shininess,1e-4)}function h(x,v){v.gradientMap&&(x.gradientMap.value=v.gradientMap)}function p(x,v){x.metalness.value=v.metalness,v.metalnessMap&&(x.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,x.metalnessMapTransform)),x.roughness.value=v.roughness,v.roughnessMap&&(x.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,x.roughnessMapTransform)),v.envMap&&(x.envMapIntensity.value=v.envMapIntensity)}function m(x,v,S){x.ior.value=v.ior,v.sheen>0&&(x.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),x.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(x.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,x.sheenColorMapTransform)),v.sheenRoughnessMap&&(x.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,x.sheenRoughnessMapTransform))),v.clearcoat>0&&(x.clearcoat.value=v.clearcoat,x.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(x.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,x.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(x.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Vs&&x.clearcoatNormalScale.value.negate())),v.dispersion>0&&(x.dispersion.value=v.dispersion),v.iridescence>0&&(x.iridescence.value=v.iridescence,x.iridescenceIOR.value=v.iridescenceIOR,x.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(x.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,x.iridescenceMapTransform)),v.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),v.transmission>0&&(x.transmission.value=v.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(x.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,x.transmissionMapTransform)),x.thickness.value=v.thickness,v.thicknessMap&&(x.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=v.attenuationDistance,x.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(x.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(x.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=v.specularIntensity,x.specularColor.value.copy(v.specularColor),v.specularColorMap&&(x.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,x.specularColorMapTransform)),v.specularIntensityMap&&(x.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,v){v.matcap&&(x.matcap.value=v.matcap)}function y(x,v){const S=e.get(v).light;x.referencePosition.value.setFromMatrixPosition(S.matrixWorld),x.nearDistance.value=S.shadow.camera.near,x.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Nye(t,e,n,r){let i={},s={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,N){const T=N.program;r.uniformBlockBinding(S,T)}function u(S,N){let T=i[S.id];T===void 0&&(b(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",x));const M=N.program;r.updateUBOMapping(S,M);const A=e.render.frame;s[S.id]!==A&&(p(S),s[S.id]=A)}function d(S){const N=h();S.__bindingPointIndex=N;const T=t.createBuffer(),M=S.__size,A=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,M,A),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,T),T}function h(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Ei("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(S){const N=i[S.id],T=S.uniforms,M=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let A=0,k=T.length;A<k;A++){const R=Array.isArray(T[A])?T[A]:[T[A]];for(let C=0,P=R.length;C<P;C++){const U=R[C];if(m(U,A,C,M)===!0){const F=U.__offset,B=Array.isArray(U.value)?U.value:[U.value];let D=0;for(let $=0;$<B.length;$++){const G=B[$],I=y(G);typeof G=="number"||typeof G=="boolean"?(U.__data[0]=G,t.bufferSubData(t.UNIFORM_BUFFER,F+D,U.__data)):G.isMatrix3?(U.__data[0]=G.elements[0],U.__data[1]=G.elements[1],U.__data[2]=G.elements[2],U.__data[3]=0,U.__data[4]=G.elements[3],U.__data[5]=G.elements[4],U.__data[6]=G.elements[5],U.__data[7]=0,U.__data[8]=G.elements[6],U.__data[9]=G.elements[7],U.__data[10]=G.elements[8],U.__data[11]=0):(G.toArray(U.__data,D),D+=I.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,F,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,N,T,M){const A=S.value,k=N+"_"+T;if(M[k]===void 0)return typeof A=="number"||typeof A=="boolean"?M[k]=A:M[k]=A.clone(),!0;{const R=M[k];if(typeof A=="number"||typeof A=="boolean"){if(R!==A)return M[k]=A,!0}else if(R.equals(A)===!1)return R.copy(A),!0}return!1}function b(S){const N=S.uniforms;let T=0;const M=16;for(let k=0,R=N.length;k<R;k++){const C=Array.isArray(N[k])?N[k]:[N[k]];for(let P=0,U=C.length;P<U;P++){const F=C[P],B=Array.isArray(F.value)?F.value:[F.value];for(let D=0,$=B.length;D<$;D++){const G=B[D],I=y(G),K=T%M,Q=K%I.boundary,se=K+Q;T+=Q,se!==0&&M-se<I.storage&&(T+=M-se),F.__data=new Float32Array(I.storage/Float32Array.BYTES_PER_ELEMENT),F.__offset=T,T+=I.storage}}}const A=T%M;return A>0&&(T+=M-A),S.__size=T,S.__cache={},this}function y(S){const N={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(N.boundary=4,N.storage=4):S.isVector2?(N.boundary=8,N.storage=8):S.isVector3||S.isColor?(N.boundary=16,N.storage=12):S.isVector4?(N.boundary=16,N.storage=16):S.isMatrix3?(N.boundary=48,N.storage=48):S.isMatrix4?(N.boundary=64,N.storage=64):S.isTexture?vn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):vn("WebGLRenderer: Unsupported uniform value type.",S),N}function x(S){const N=S.target;N.removeEventListener("dispose",x);const T=o.indexOf(N.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete s[N.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},s={}}return{bind:c,update:u,dispose:v}}const kye=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 iu=null;function Mye(){return iu===null&&(iu=new Spe(kye,32,32,cO,Tb),iu.minFilter=il,iu.magFilter=il,iu.wrapS=ku,iu.wrapT=ku,iu.generateMipmaps=!1,iu.needsUpdate=!0),iu}let Eye=class{constructor(e={}){const{canvas:n=Kme(),context:r=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!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 b=new Set([dO,uO,lO]),y=new Set([_c,ym,ty,ny,sO,oO]),x=new Uint32Array(4),v=new Int32Array(4);let S=null,N=null;const T=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=xh,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const A=this;let k=!1;this._outputColorSpace=mo;let R=0,C=0,P=null,U=-1,F=null;const B=new Bi,D=new Bi;let $=null;const G=new Fn(0);let I=0,K=n.width,Q=n.height,se=1,H=null,W=null;const J=new Bi(0,0,K,Q),ne=new Bi(0,0,K,Q);let xe=!1;const ue=new gO;let fe=!1,De=!1;const oe=new Gi,Ne=new pt,Fe=new Bi,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ve=!1;function V(){return P===null?se:1}let Y=r;function de(he,Ie){return n.getContext(he,Ie)}try{const he={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${rO}`),n.addEventListener("webglcontextlost",je,!1),n.addEventListener("webglcontextrestored",Re,!1),n.addEventListener("webglcontextcreationerror",we,!1),Y===null){const Ie="webgl2";if(Y=de(Ie,he),Y===null)throw de(Ie)?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,re,X,le,pe,ee,z,O,Z,me,Te,ke,Ee,Se,$e,Qe,Ue,be,ve,ze,Ce,Ge,_e,Je;function Ae(){q=new Oxe(Y),q.init(),Ge=new bye(Y,q),re=new Mxe(Y,q,e,Ge),X=new pye(Y,q),re.reversedDepthBuffer&&p&&X.buffers.depth.setReversed(!0),le=new Ixe(Y),pe=new nye,ee=new gye(Y,q,X,pe,re,Ge,le),z=new Txe(A),O=new Rxe(A),Z=new Hpe(Y),_e=new Nxe(Y,Z),me=new Lxe(Y,Z,le,_e),Te=new Uxe(Y,me,Z,le),ve=new zxe(Y,re,ee),Qe=new Exe(pe),ke=new tye(A,z,O,q,re,_e,Qe),Ee=new Sye(A,pe),Se=new iye,$e=new uye(q),be=new Sxe(A,z,O,X,Te,m,c),Ue=new fye(A,Te,re),Je=new Nye(Y,le,re,X),ze=new kxe(Y,q,le),Ce=new Fxe(Y,q,le),le.programs=ke.programs,A.capabilities=re,A.extensions=q,A.properties=pe,A.renderLists=Se,A.shadowMap=Ue,A.state=X,A.info=le}Ae();const Ke=new wye(A,Y);this.xr=Ke,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 se},this.setPixelRatio=function(he){he!==void 0&&(se=he,this.setSize(K,Q,!1))},this.getSize=function(he){return he.set(K,Q)},this.setSize=function(he,Ie,Xe=!0){if(Ke.isPresenting){vn("WebGLRenderer: Can't change size while VR device is presenting.");return}K=he,Q=Ie,n.width=Math.floor(he*se),n.height=Math.floor(Ie*se),Xe===!0&&(n.style.width=he+"px",n.style.height=Ie+"px"),this.setViewport(0,0,he,Ie)},this.getDrawingBufferSize=function(he){return he.set(K*se,Q*se).floor()},this.setDrawingBufferSize=function(he,Ie,Xe){K=he,Q=Ie,se=Xe,n.width=Math.floor(he*Xe),n.height=Math.floor(Ie*Xe),this.setViewport(0,0,he,Ie)},this.getCurrentViewport=function(he){return he.copy(B)},this.getViewport=function(he){return he.copy(J)},this.setViewport=function(he,Ie,Xe,He){he.isVector4?J.set(he.x,he.y,he.z,he.w):J.set(he,Ie,Xe,He),X.viewport(B.copy(J).multiplyScalar(se).round())},this.getScissor=function(he){return he.copy(ne)},this.setScissor=function(he,Ie,Xe,He){he.isVector4?ne.set(he.x,he.y,he.z,he.w):ne.set(he,Ie,Xe,He),X.scissor(D.copy(ne).multiplyScalar(se).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(he){X.setScissorTest(xe=he)},this.setOpaqueSort=function(he){H=he},this.setTransparentSort=function(he){W=he},this.getClearColor=function(he){return he.copy(be.getClearColor())},this.setClearColor=function(){be.setClearColor(...arguments)},this.getClearAlpha=function(){return be.getClearAlpha()},this.setClearAlpha=function(){be.setClearAlpha(...arguments)},this.clear=function(he=!0,Ie=!0,Xe=!0){let He=0;if(he){let ge=!1;if(P!==null){const rt=P.texture.format;ge=b.has(rt)}if(ge){const rt=P.texture.type,ut=y.has(rt),it=be.getClearColor(),Tt=be.getClearAlpha(),Ut=it.r,jt=it.g,Ct=it.b;ut?(x[0]=Ut,x[1]=jt,x[2]=Ct,x[3]=Tt,Y.clearBufferuiv(Y.COLOR,0,x)):(v[0]=Ut,v[1]=jt,v[2]=Ct,v[3]=Tt,Y.clearBufferiv(Y.COLOR,0,v))}else He|=Y.COLOR_BUFFER_BIT}Ie&&(He|=Y.DEPTH_BUFFER_BIT),Xe&&(He|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(He)},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",je,!1),n.removeEventListener("webglcontextrestored",Re,!1),n.removeEventListener("webglcontextcreationerror",we,!1),be.dispose(),Se.dispose(),$e.dispose(),pe.dispose(),z.dispose(),O.dispose(),Te.dispose(),_e.dispose(),Je.dispose(),ke.dispose(),Ke.dispose(),Ke.removeEventListener("sessionstart",yt),Ke.removeEventListener("sessionend",Wt),rn.stop()};function je(he){he.preventDefault(),bB("WebGLRenderer: Context Lost."),k=!0}function Re(){bB("WebGLRenderer: Context Restored."),k=!1;const he=le.autoReset,Ie=Ue.enabled,Xe=Ue.autoUpdate,He=Ue.needsUpdate,ge=Ue.type;Ae(),le.autoReset=he,Ue.enabled=Ie,Ue.autoUpdate=Xe,Ue.needsUpdate=He,Ue.type=ge}function we(he){Ei("WebGLRenderer: A WebGL context could not be created. Reason: ",he.statusMessage)}function qe(he){const Ie=he.target;Ie.removeEventListener("dispose",qe),xt(Ie)}function xt(he){Et(he),pe.remove(he)}function Et(he){const Ie=pe.get(he).programs;Ie!==void 0&&(Ie.forEach(function(Xe){ke.releaseProgram(Xe)}),he.isShaderMaterial&&ke.releaseShaderCache(he))}this.renderBufferDirect=function(he,Ie,Xe,He,ge,rt){Ie===null&&(Ie=ce);const ut=ge.isMesh&&ge.matrixWorld.determinant()<0,it=Pe(he,Ie,Xe,He,ge);X.setMaterial(He,ut);let Tt=Xe.index,Ut=1;if(He.wireframe===!0){if(Tt=me.getWireframeAttribute(Xe),Tt===void 0)return;Ut=2}const jt=Xe.drawRange,Ct=Xe.attributes.position;let an=jt.start*Ut,Vt=(jt.start+jt.count)*Ut;rt!==null&&(an=Math.max(an,rt.start*Ut),Vt=Math.min(Vt,(rt.start+rt.count)*Ut)),Tt!==null?(an=Math.max(an,0),Vt=Math.min(Vt,Tt.count)):Ct!=null&&(an=Math.max(an,0),Vt=Math.min(Vt,Ct.count));const gn=Vt-an;if(gn<0||gn===1/0)return;_e.setup(ge,He,it,Xe,Tt);let Mn,bn=ze;if(Tt!==null&&(Mn=Z.get(Tt),bn=Ce,bn.setIndex(Mn)),ge.isMesh)He.wireframe===!0?(X.setLineWidth(He.wireframeLinewidth*V()),bn.setMode(Y.LINES)):bn.setMode(Y.TRIANGLES);else if(ge.isLine){let qt=He.linewidth;qt===void 0&&(qt=1),X.setLineWidth(qt*V()),ge.isLineSegments?bn.setMode(Y.LINES):ge.isLineLoop?bn.setMode(Y.LINE_LOOP):bn.setMode(Y.LINE_STRIP)}else ge.isPoints?bn.setMode(Y.POINTS):ge.isSprite&&bn.setMode(Y.TRIANGLES);if(ge.isBatchedMesh)if(ge._multiDrawInstances!==null)ay("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),bn.renderMultiDrawInstances(ge._multiDrawStarts,ge._multiDrawCounts,ge._multiDrawCount,ge._multiDrawInstances);else if(q.get("WEBGL_multi_draw"))bn.renderMultiDraw(ge._multiDrawStarts,ge._multiDrawCounts,ge._multiDrawCount);else{const qt=ge._multiDrawStarts,sn=ge._multiDrawCounts,Jt=ge._multiDrawCount,mr=Tt?Z.get(Tt).bytesPerElement:1,Hr=pe.get(He).currentProgram.getUniforms();for(let Jn=0;Jn<Jt;Jn++)Hr.setValue(Y,"_gl_DrawID",Jn),bn.render(qt[Jn]/mr,sn[Jn])}else if(ge.isInstancedMesh)bn.renderInstances(an,gn,ge.count);else if(Xe.isInstancedBufferGeometry){const qt=Xe._maxInstanceCount!==void 0?Xe._maxInstanceCount:1/0,sn=Math.min(Xe.instanceCount,qt);bn.renderInstances(an,gn,sn)}else bn.render(an,gn)};function fn(he,Ie,Xe){he.transparent===!0&&he.side===lc&&he.forceSinglePass===!1?(he.side=Vs,he.needsUpdate=!0,Zn(he,Ie,Xe),he.side=jh,he.needsUpdate=!0,Zn(he,Ie,Xe),he.side=lc):Zn(he,Ie,Xe)}this.compile=function(he,Ie,Xe=null){Xe===null&&(Xe=he),N=$e.get(Xe),N.init(Ie),M.push(N),Xe.traverseVisible(function(ge){ge.isLight&&ge.layers.test(Ie.layers)&&(N.pushLight(ge),ge.castShadow&&N.pushShadow(ge))}),he!==Xe&&he.traverseVisible(function(ge){ge.isLight&&ge.layers.test(Ie.layers)&&(N.pushLight(ge),ge.castShadow&&N.pushShadow(ge))}),N.setupLights();const He=new Set;return he.traverse(function(ge){if(!(ge.isMesh||ge.isPoints||ge.isLine||ge.isSprite))return;const rt=ge.material;if(rt)if(Array.isArray(rt))for(let ut=0;ut<rt.length;ut++){const it=rt[ut];fn(it,Xe,ge),He.add(it)}else fn(rt,Xe,ge),He.add(rt)}),N=M.pop(),He},this.compileAsync=function(he,Ie,Xe=null){const He=this.compile(he,Ie,Xe);return new Promise(ge=>{function rt(){if(He.forEach(function(ut){pe.get(ut).currentProgram.isReady()&&He.delete(ut)}),He.size===0){ge(he);return}setTimeout(rt,10)}q.get("KHR_parallel_shader_compile")!==null?rt():setTimeout(rt,10)})};let It=null;function Oe(he){It&&It(he)}function yt(){rn.stop()}function Wt(){rn.start()}const rn=new LK;rn.setAnimationLoop(Oe),typeof self<"u"&&rn.setContext(self),this.setAnimationLoop=function(he){It=he,Ke.setAnimationLoop(he),he===null?rn.stop():rn.start()},Ke.addEventListener("sessionstart",yt),Ke.addEventListener("sessionend",Wt),this.render=function(he,Ie){if(Ie!==void 0&&Ie.isCamera!==!0){Ei("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(k===!0)return;if(he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),Ie.parent===null&&Ie.matrixWorldAutoUpdate===!0&&Ie.updateMatrixWorld(),Ke.enabled===!0&&Ke.isPresenting===!0&&(Ke.cameraAutoUpdate===!0&&Ke.updateCamera(Ie),Ie=Ke.getCamera()),he.isScene===!0&&he.onBeforeRender(A,he,Ie,P),N=$e.get(he,M.length),N.init(Ie),M.push(N),oe.multiplyMatrices(Ie.projectionMatrix,Ie.matrixWorldInverse),ue.setFromProjectionMatrix(oe,hc,Ie.reversedDepth),De=this.localClippingEnabled,fe=Qe.init(this.clippingPlanes,De),S=Se.get(he,T.length),S.init(),T.push(S),Ke.enabled===!0&&Ke.isPresenting===!0){const rt=A.xr.getDepthSensingMesh();rt!==null&&Qt(rt,Ie,-1/0,A.sortObjects)}Qt(he,Ie,0,A.sortObjects),S.finish(),A.sortObjects===!0&&S.sort(H,W),Ve=Ke.enabled===!1||Ke.isPresenting===!1||Ke.hasDepthSensing()===!1,Ve&&be.addToRenderList(S,he),this.info.render.frame++,fe===!0&&Qe.beginShadows();const Xe=N.state.shadowsArray;Ue.render(Xe,he,Ie),fe===!0&&Qe.endShadows(),this.info.autoReset===!0&&this.info.reset();const He=S.opaque,ge=S.transmissive;if(N.setupLights(),Ie.isArrayCamera){const rt=Ie.cameras;if(ge.length>0)for(let ut=0,it=rt.length;ut<it;ut++){const Tt=rt[ut];Lr(He,ge,he,Tt)}Ve&&be.render(he);for(let ut=0,it=rt.length;ut<it;ut++){const Tt=rt[ut];ur(S,he,Tt,Tt.viewport)}}else ge.length>0&&Lr(He,ge,he,Ie),Ve&&be.render(he),ur(S,he,Ie);P!==null&&C===0&&(ee.updateMultisampleRenderTarget(P),ee.updateRenderTargetMipmap(P)),he.isScene===!0&&he.onAfterRender(A,he,Ie),_e.resetDefaultState(),U=-1,F=null,M.pop(),M.length>0?(N=M[M.length-1],fe===!0&&Qe.setGlobalState(A.clippingPlanes,N.state.camera)):N=null,T.pop(),T.length>0?S=T[T.length-1]:S=null};function Qt(he,Ie,Xe,He){if(he.visible===!1)return;if(he.layers.test(Ie.layers)){if(he.isGroup)Xe=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(Ie);else if(he.isLight)N.pushLight(he),he.castShadow&&N.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||ue.intersectsSprite(he)){He&&Fe.setFromMatrixPosition(he.matrixWorld).applyMatrix4(oe);const ut=Te.update(he),it=he.material;it.visible&&S.push(he,ut,it,Xe,Fe.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||ue.intersectsObject(he))){const ut=Te.update(he),it=he.material;if(He&&(he.boundingSphere!==void 0?(he.boundingSphere===null&&he.computeBoundingSphere(),Fe.copy(he.boundingSphere.center)):(ut.boundingSphere===null&&ut.computeBoundingSphere(),Fe.copy(ut.boundingSphere.center)),Fe.applyMatrix4(he.matrixWorld).applyMatrix4(oe)),Array.isArray(it)){const Tt=ut.groups;for(let Ut=0,jt=Tt.length;Ut<jt;Ut++){const Ct=Tt[Ut],an=it[Ct.materialIndex];an&&an.visible&&S.push(he,ut,an,Xe,Fe.z,Ct)}}else it.visible&&S.push(he,ut,it,Xe,Fe.z,null)}}const rt=he.children;for(let ut=0,it=rt.length;ut<it;ut++)Qt(rt[ut],Ie,Xe,He)}function ur(he,Ie,Xe,He){const{opaque:ge,transmissive:rt,transparent:ut}=he;N.setupLightsView(Xe),fe===!0&&Qe.setGlobalState(A.clippingPlanes,Xe),He&&X.viewport(B.copy(He)),ge.length>0&&nr(ge,Ie,Xe),rt.length>0&&nr(rt,Ie,Xe),ut.length>0&&nr(ut,Ie,Xe),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function Lr(he,Ie,Xe,He){if((Xe.isScene===!0?Xe.overrideMaterial:null)!==null)return;N.state.transmissionRenderTarget[He.id]===void 0&&(N.state.transmissionRenderTarget[He.id]=new wm(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")||q.has("EXT_color_buffer_float")?Tb:_c,minFilter:$f,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:or.workingColorSpace}));const rt=N.state.transmissionRenderTarget[He.id],ut=He.viewport||B;rt.setSize(ut.z*A.transmissionResolutionScale,ut.w*A.transmissionResolutionScale);const it=A.getRenderTarget(),Tt=A.getActiveCubeFace(),Ut=A.getActiveMipmapLevel();A.setRenderTarget(rt),A.getClearColor(G),I=A.getClearAlpha(),I<1&&A.setClearColor(16777215,.5),A.clear(),Ve&&be.render(Xe);const jt=A.toneMapping;A.toneMapping=xh;const Ct=He.viewport;if(He.viewport!==void 0&&(He.viewport=void 0),N.setupLightsView(He),fe===!0&&Qe.setGlobalState(A.clippingPlanes,He),nr(he,Xe,He),ee.updateMultisampleRenderTarget(rt),ee.updateRenderTargetMipmap(rt),q.has("WEBGL_multisampled_render_to_texture")===!1){let an=!1;for(let Vt=0,gn=Ie.length;Vt<gn;Vt++){const Mn=Ie[Vt],{object:bn,geometry:qt,material:sn,group:Jt}=Mn;if(sn.side===lc&&bn.layers.test(He.layers)){const mr=sn.side;sn.side=Vs,sn.needsUpdate=!0,Xt(bn,Xe,He,qt,sn,Jt),sn.side=mr,sn.needsUpdate=!0,an=!0}}an===!0&&(ee.updateMultisampleRenderTarget(rt),ee.updateRenderTargetMipmap(rt))}A.setRenderTarget(it,Tt,Ut),A.setClearColor(G,I),Ct!==void 0&&(He.viewport=Ct),A.toneMapping=jt}function nr(he,Ie,Xe){const He=Ie.isScene===!0?Ie.overrideMaterial:null;for(let ge=0,rt=he.length;ge<rt;ge++){const ut=he[ge],{object:it,geometry:Tt,group:Ut}=ut;let jt=ut.material;jt.allowOverride===!0&&He!==null&&(jt=He),it.layers.test(Xe.layers)&&Xt(it,Ie,Xe,Tt,jt,Ut)}}function Xt(he,Ie,Xe,He,ge,rt){he.onBeforeRender(A,Ie,Xe,He,ge,rt),he.modelViewMatrix.multiplyMatrices(Xe.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),ge.onBeforeRender(A,Ie,Xe,He,he,rt),ge.transparent===!0&&ge.side===lc&&ge.forceSinglePass===!1?(ge.side=Vs,ge.needsUpdate=!0,A.renderBufferDirect(Xe,Ie,He,ge,he,rt),ge.side=jh,ge.needsUpdate=!0,A.renderBufferDirect(Xe,Ie,He,ge,he,rt),ge.side=lc):A.renderBufferDirect(Xe,Ie,He,ge,he,rt),he.onAfterRender(A,Ie,Xe,He,ge,rt)}function Zn(he,Ie,Xe){Ie.isScene!==!0&&(Ie=ce);const He=pe.get(he),ge=N.state.lights,rt=N.state.shadowsArray,ut=ge.state.version,it=ke.getParameters(he,ge.state,rt,Ie,Xe),Tt=ke.getProgramCacheKey(it);let Ut=He.programs;He.environment=he.isMeshStandardMaterial?Ie.environment:null,He.fog=Ie.fog,He.envMap=(he.isMeshStandardMaterial?O:z).get(he.envMap||He.environment),He.envMapRotation=He.environment!==null&&he.envMap===null?Ie.environmentRotation:he.envMapRotation,Ut===void 0&&(he.addEventListener("dispose",qe),Ut=new Map,He.programs=Ut);let jt=Ut.get(Tt);if(jt!==void 0){if(He.currentProgram===jt&&He.lightsStateVersion===ut)return da(he,it),jt}else it.uniforms=ke.getUniforms(he),he.onBeforeCompile(it,A),jt=ke.acquireProgram(it,Tt),Ut.set(Tt,jt),He.uniforms=it.uniforms;const Ct=He.uniforms;return(!he.isShaderMaterial&&!he.isRawShaderMaterial||he.clipping===!0)&&(Ct.clippingPlanes=Qe.uniform),da(he,it),He.needsLights=ht(he),He.lightsStateVersion=ut,He.needsLights&&(Ct.ambientLightColor.value=ge.state.ambient,Ct.lightProbe.value=ge.state.probe,Ct.directionalLights.value=ge.state.directional,Ct.directionalLightShadows.value=ge.state.directionalShadow,Ct.spotLights.value=ge.state.spot,Ct.spotLightShadows.value=ge.state.spotShadow,Ct.rectAreaLights.value=ge.state.rectArea,Ct.ltc_1.value=ge.state.rectAreaLTC1,Ct.ltc_2.value=ge.state.rectAreaLTC2,Ct.pointLights.value=ge.state.point,Ct.pointLightShadows.value=ge.state.pointShadow,Ct.hemisphereLights.value=ge.state.hemi,Ct.directionalShadowMap.value=ge.state.directionalShadowMap,Ct.directionalShadowMatrix.value=ge.state.directionalShadowMatrix,Ct.spotShadowMap.value=ge.state.spotShadowMap,Ct.spotLightMatrix.value=ge.state.spotLightMatrix,Ct.spotLightMap.value=ge.state.spotLightMap,Ct.pointShadowMap.value=ge.state.pointShadowMap,Ct.pointShadowMatrix.value=ge.state.pointShadowMatrix),He.currentProgram=jt,He.uniformsList=null,jt}function oi(he){if(he.uniformsList===null){const Ie=he.currentProgram.getUniforms();he.uniformsList=z1.seqWithValue(Ie.seq,he.uniforms)}return he.uniformsList}function da(he,Ie){const Xe=pe.get(he);Xe.outputColorSpace=Ie.outputColorSpace,Xe.batching=Ie.batching,Xe.batchingColor=Ie.batchingColor,Xe.instancing=Ie.instancing,Xe.instancingColor=Ie.instancingColor,Xe.instancingMorph=Ie.instancingMorph,Xe.skinning=Ie.skinning,Xe.morphTargets=Ie.morphTargets,Xe.morphNormals=Ie.morphNormals,Xe.morphColors=Ie.morphColors,Xe.morphTargetsCount=Ie.morphTargetsCount,Xe.numClippingPlanes=Ie.numClippingPlanes,Xe.numIntersection=Ie.numClipIntersection,Xe.vertexAlphas=Ie.vertexAlphas,Xe.vertexTangents=Ie.vertexTangents,Xe.toneMapping=Ie.toneMapping}function Pe(he,Ie,Xe,He,ge){Ie.isScene!==!0&&(Ie=ce),ee.resetTextureUnits();const rt=Ie.fog,ut=He.isMeshStandardMaterial?Ie.environment:null,it=P===null?A.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:eb,Tt=(He.isMeshStandardMaterial?O:z).get(He.envMap||ut),Ut=He.vertexColors===!0&&!!Xe.attributes.color&&Xe.attributes.color.itemSize===4,jt=!!Xe.attributes.tangent&&(!!He.normalMap||He.anisotropy>0),Ct=!!Xe.morphAttributes.position,an=!!Xe.morphAttributes.normal,Vt=!!Xe.morphAttributes.color;let gn=xh;He.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(gn=A.toneMapping);const Mn=Xe.morphAttributes.position||Xe.morphAttributes.normal||Xe.morphAttributes.color,bn=Mn!==void 0?Mn.length:0,qt=pe.get(He),sn=N.state.lights;if(fe===!0&&(De===!0||he!==F)){const St=he===F&&He.id===U;Qe.setState(He,he,St)}let Jt=!1;He.version===qt.__version?(qt.needsLights&&qt.lightsStateVersion!==sn.state.version||qt.outputColorSpace!==it||ge.isBatchedMesh&&qt.batching===!1||!ge.isBatchedMesh&&qt.batching===!0||ge.isBatchedMesh&&qt.batchingColor===!0&&ge.colorTexture===null||ge.isBatchedMesh&&qt.batchingColor===!1&&ge.colorTexture!==null||ge.isInstancedMesh&&qt.instancing===!1||!ge.isInstancedMesh&&qt.instancing===!0||ge.isSkinnedMesh&&qt.skinning===!1||!ge.isSkinnedMesh&&qt.skinning===!0||ge.isInstancedMesh&&qt.instancingColor===!0&&ge.instanceColor===null||ge.isInstancedMesh&&qt.instancingColor===!1&&ge.instanceColor!==null||ge.isInstancedMesh&&qt.instancingMorph===!0&&ge.morphTexture===null||ge.isInstancedMesh&&qt.instancingMorph===!1&&ge.morphTexture!==null||qt.envMap!==Tt||He.fog===!0&&qt.fog!==rt||qt.numClippingPlanes!==void 0&&(qt.numClippingPlanes!==Qe.numPlanes||qt.numIntersection!==Qe.numIntersection)||qt.vertexAlphas!==Ut||qt.vertexTangents!==jt||qt.morphTargets!==Ct||qt.morphNormals!==an||qt.morphColors!==Vt||qt.toneMapping!==gn||qt.morphTargetsCount!==bn)&&(Jt=!0):(Jt=!0,qt.__version=He.version);let mr=qt.currentProgram;Jt===!0&&(mr=Zn(He,Ie,ge));let Hr=!1,Jn=!1,Bn=!1;const gt=mr.getUniforms(),Rt=qt.uniforms;if(X.useProgram(mr.program)&&(Hr=!0,Jn=!0,Bn=!0),He.id!==U&&(U=He.id,Jn=!0),Hr||F!==he){X.buffers.depth.getReversed()&&he.reversedDepth!==!0&&(he._reversedDepth=!0,he.updateProjectionMatrix()),gt.setValue(Y,"projectionMatrix",he.projectionMatrix),gt.setValue(Y,"viewMatrix",he.matrixWorldInverse);const pn=gt.map.cameraPosition;pn!==void 0&&pn.setValue(Y,Ne.setFromMatrixPosition(he.matrixWorld)),re.logarithmicDepthBuffer&>.setValue(Y,"logDepthBufFC",2/(Math.log(he.far+1)/Math.LN2)),(He.isMeshPhongMaterial||He.isMeshToonMaterial||He.isMeshLambertMaterial||He.isMeshBasicMaterial||He.isMeshStandardMaterial||He.isShaderMaterial)&>.setValue(Y,"isOrthographic",he.isOrthographicCamera===!0),F!==he&&(F=he,Jn=!0,Bn=!0)}if(ge.isSkinnedMesh){gt.setOptional(Y,ge,"bindMatrix"),gt.setOptional(Y,ge,"bindMatrixInverse");const St=ge.skeleton;St&&(St.boneTexture===null&&St.computeBoneTexture(),gt.setValue(Y,"boneTexture",St.boneTexture,ee))}ge.isBatchedMesh&&(gt.setOptional(Y,ge,"batchingTexture"),gt.setValue(Y,"batchingTexture",ge._matricesTexture,ee),gt.setOptional(Y,ge,"batchingIdTexture"),gt.setValue(Y,"batchingIdTexture",ge._indirectTexture,ee),gt.setOptional(Y,ge,"batchingColorTexture"),ge._colorsTexture!==null&>.setValue(Y,"batchingColorTexture",ge._colorsTexture,ee));const on=Xe.morphAttributes;if((on.position!==void 0||on.normal!==void 0||on.color!==void 0)&&ve.update(ge,Xe,mr),(Jn||qt.receiveShadow!==ge.receiveShadow)&&(qt.receiveShadow=ge.receiveShadow,gt.setValue(Y,"receiveShadow",ge.receiveShadow)),He.isMeshGouraudMaterial&&He.envMap!==null&&(Rt.envMap.value=Tt,Rt.flipEnvMap.value=Tt.isCubeTexture&&Tt.isRenderTargetTexture===!1?-1:1),He.isMeshStandardMaterial&&He.envMap===null&&Ie.environment!==null&&(Rt.envMapIntensity.value=Ie.environmentIntensity),Rt.dfgLUT!==void 0&&(Rt.dfgLUT.value=Mye()),Jn&&(gt.setValue(Y,"toneMappingExposure",A.toneMappingExposure),qt.needsLights&&tt(Rt,Bn),rt&&He.fog===!0&&Ee.refreshFogUniforms(Rt,rt),Ee.refreshMaterialUniforms(Rt,He,se,Q,N.state.transmissionRenderTarget[he.id]),z1.upload(Y,oi(qt),Rt,ee)),He.isShaderMaterial&&He.uniformsNeedUpdate===!0&&(z1.upload(Y,oi(qt),Rt,ee),He.uniformsNeedUpdate=!1),He.isSpriteMaterial&>.setValue(Y,"center",ge.center),gt.setValue(Y,"modelViewMatrix",ge.modelViewMatrix),gt.setValue(Y,"normalMatrix",ge.normalMatrix),gt.setValue(Y,"modelMatrix",ge.matrixWorld),He.isShaderMaterial||He.isRawShaderMaterial){const St=He.uniformsGroups;for(let pn=0,rr=St.length;pn<rr;pn++){const ir=St[pn];Je.update(ir,mr),Je.bind(ir,mr)}}return mr}function tt(he,Ie){he.ambientLightColor.needsUpdate=Ie,he.lightProbe.needsUpdate=Ie,he.directionalLights.needsUpdate=Ie,he.directionalLightShadows.needsUpdate=Ie,he.pointLights.needsUpdate=Ie,he.pointLightShadows.needsUpdate=Ie,he.spotLights.needsUpdate=Ie,he.spotLightShadows.needsUpdate=Ie,he.rectAreaLights.needsUpdate=Ie,he.hemisphereLights.needsUpdate=Ie}function ht(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 C},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(he,Ie,Xe){const He=pe.get(he);He.__autoAllocateDepthBuffer=he.resolveDepthBuffer===!1,He.__autoAllocateDepthBuffer===!1&&(He.__useRenderToTexture=!1),pe.get(he.texture).__webglTexture=Ie,pe.get(he.depthTexture).__webglTexture=He.__autoAllocateDepthBuffer?void 0:Xe,He.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(he,Ie){const Xe=pe.get(he);Xe.__webglFramebuffer=Ie,Xe.__useDefaultFramebuffer=Ie===void 0};const mt=Y.createFramebuffer();this.setRenderTarget=function(he,Ie=0,Xe=0){P=he,R=Ie,C=Xe;let He=!0,ge=null,rt=!1,ut=!1;if(he){const Tt=pe.get(he);if(Tt.__useDefaultFramebuffer!==void 0)X.bindFramebuffer(Y.FRAMEBUFFER,null),He=!1;else if(Tt.__webglFramebuffer===void 0)ee.setupRenderTarget(he);else if(Tt.__hasExternalTextures)ee.rebindTextures(he,pe.get(he.texture).__webglTexture,pe.get(he.depthTexture).__webglTexture);else if(he.depthBuffer){const Ct=he.depthTexture;if(Tt.__boundDepthTexture!==Ct){if(Ct!==null&&pe.has(Ct)&&(he.width!==Ct.image.width||he.height!==Ct.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ee.setupDepthRenderbuffer(he)}}const Ut=he.texture;(Ut.isData3DTexture||Ut.isDataArrayTexture||Ut.isCompressedArrayTexture)&&(ut=!0);const jt=pe.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(Array.isArray(jt[Ie])?ge=jt[Ie][Xe]:ge=jt[Ie],rt=!0):he.samples>0&&ee.useMultisampledRTT(he)===!1?ge=pe.get(he).__webglMultisampledFramebuffer:Array.isArray(jt)?ge=jt[Xe]:ge=jt,B.copy(he.viewport),D.copy(he.scissor),$=he.scissorTest}else B.copy(J).multiplyScalar(se).floor(),D.copy(ne).multiplyScalar(se).floor(),$=xe;if(Xe!==0&&(ge=mt),X.bindFramebuffer(Y.FRAMEBUFFER,ge)&&He&&X.drawBuffers(he,ge),X.viewport(B),X.scissor(D),X.setScissorTest($),rt){const Tt=pe.get(he.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,Tt.__webglTexture,Xe)}else if(ut){const Tt=Ie;for(let Ut=0;Ut<he.textures.length;Ut++){const jt=pe.get(he.textures[Ut]);Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0+Ut,jt.__webglTexture,Xe,Tt)}}else if(he!==null&&Xe!==0){const Tt=pe.get(he.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,Tt.__webglTexture,Xe)}U=-1},this.readRenderTargetPixels=function(he,Ie,Xe,He,ge,rt,ut,it=0){if(!(he&&he.isWebGLRenderTarget)){Ei("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Tt=pe.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&ut!==void 0&&(Tt=Tt[ut]),Tt){X.bindFramebuffer(Y.FRAMEBUFFER,Tt);try{const Ut=he.textures[it],jt=Ut.format,Ct=Ut.type;if(!re.textureFormatReadable(jt)){Ei("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!re.textureTypeReadable(Ct)){Ei("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ie>=0&&Ie<=he.width-He&&Xe>=0&&Xe<=he.height-ge&&(he.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+it),Y.readPixels(Ie,Xe,He,ge,Ge.convert(jt),Ge.convert(Ct),rt))}finally{const Ut=P!==null?pe.get(P).__webglFramebuffer:null;X.bindFramebuffer(Y.FRAMEBUFFER,Ut)}}},this.readRenderTargetPixelsAsync=async function(he,Ie,Xe,He,ge,rt,ut,it=0){if(!(he&&he.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Tt=pe.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&ut!==void 0&&(Tt=Tt[ut]),Tt)if(Ie>=0&&Ie<=he.width-He&&Xe>=0&&Xe<=he.height-ge){X.bindFramebuffer(Y.FRAMEBUFFER,Tt);const Ut=he.textures[it],jt=Ut.format,Ct=Ut.type;if(!re.textureFormatReadable(jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!re.textureTypeReadable(Ct))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const an=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,an),Y.bufferData(Y.PIXEL_PACK_BUFFER,rt.byteLength,Y.STREAM_READ),he.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+it),Y.readPixels(Ie,Xe,He,ge,Ge.convert(jt),Ge.convert(Ct),0);const Vt=P!==null?pe.get(P).__webglFramebuffer:null;X.bindFramebuffer(Y.FRAMEBUFFER,Vt);const gn=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);return Y.flush(),await Xme(Y,gn,4),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,an),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,rt),Y.deleteBuffer(an),Y.deleteSync(gn),rt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(he,Ie=null,Xe=0){const He=Math.pow(2,-Xe),ge=Math.floor(he.image.width*He),rt=Math.floor(he.image.height*He),ut=Ie!==null?Ie.x:0,it=Ie!==null?Ie.y:0;ee.setTexture2D(he,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,Xe,0,0,ut,it,ge,rt),X.unbindTexture()};const at=Y.createFramebuffer(),Dt=Y.createFramebuffer();this.copyTextureToTexture=function(he,Ie,Xe=null,He=null,ge=0,rt=null){rt===null&&(ge!==0?(ay("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),rt=ge,ge=0):rt=0);let ut,it,Tt,Ut,jt,Ct,an,Vt,gn;const Mn=he.isCompressedTexture?he.mipmaps[rt]:he.image;if(Xe!==null)ut=Xe.max.x-Xe.min.x,it=Xe.max.y-Xe.min.y,Tt=Xe.isBox3?Xe.max.z-Xe.min.z:1,Ut=Xe.min.x,jt=Xe.min.y,Ct=Xe.isBox3?Xe.min.z:0;else{const on=Math.pow(2,-ge);ut=Math.floor(Mn.width*on),it=Math.floor(Mn.height*on),he.isDataArrayTexture?Tt=Mn.depth:he.isData3DTexture?Tt=Math.floor(Mn.depth*on):Tt=1,Ut=0,jt=0,Ct=0}He!==null?(an=He.x,Vt=He.y,gn=He.z):(an=0,Vt=0,gn=0);const bn=Ge.convert(Ie.format),qt=Ge.convert(Ie.type);let sn;Ie.isData3DTexture?(ee.setTexture3D(Ie,0),sn=Y.TEXTURE_3D):Ie.isDataArrayTexture||Ie.isCompressedArrayTexture?(ee.setTexture2DArray(Ie,0),sn=Y.TEXTURE_2D_ARRAY):(ee.setTexture2D(Ie,0),sn=Y.TEXTURE_2D),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,Ie.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ie.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,Ie.unpackAlignment);const Jt=Y.getParameter(Y.UNPACK_ROW_LENGTH),mr=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),Hr=Y.getParameter(Y.UNPACK_SKIP_PIXELS),Jn=Y.getParameter(Y.UNPACK_SKIP_ROWS),Bn=Y.getParameter(Y.UNPACK_SKIP_IMAGES);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Mn.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,Mn.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,Ut),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,jt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Ct);const gt=he.isDataArrayTexture||he.isData3DTexture,Rt=Ie.isDataArrayTexture||Ie.isData3DTexture;if(he.isDepthTexture){const on=pe.get(he),St=pe.get(Ie),pn=pe.get(on.__renderTarget),rr=pe.get(St.__renderTarget);X.bindFramebuffer(Y.READ_FRAMEBUFFER,pn.__webglFramebuffer),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,rr.__webglFramebuffer);for(let ir=0;ir<Tt;ir++)gt&&(Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,pe.get(he).__webglTexture,ge,Ct+ir),Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,pe.get(Ie).__webglTexture,rt,gn+ir)),Y.blitFramebuffer(Ut,jt,ut,it,an,Vt,ut,it,Y.DEPTH_BUFFER_BIT,Y.NEAREST);X.bindFramebuffer(Y.READ_FRAMEBUFFER,null),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else if(ge!==0||he.isRenderTargetTexture||pe.has(he)){const on=pe.get(he),St=pe.get(Ie);X.bindFramebuffer(Y.READ_FRAMEBUFFER,at),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,Dt);for(let pn=0;pn<Tt;pn++)gt?Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,on.__webglTexture,ge,Ct+pn):Y.framebufferTexture2D(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,on.__webglTexture,ge),Rt?Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,St.__webglTexture,rt,gn+pn):Y.framebufferTexture2D(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,St.__webglTexture,rt),ge!==0?Y.blitFramebuffer(Ut,jt,ut,it,an,Vt,ut,it,Y.COLOR_BUFFER_BIT,Y.NEAREST):Rt?Y.copyTexSubImage3D(sn,rt,an,Vt,gn+pn,Ut,jt,ut,it):Y.copyTexSubImage2D(sn,rt,an,Vt,Ut,jt,ut,it);X.bindFramebuffer(Y.READ_FRAMEBUFFER,null),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else Rt?he.isDataTexture||he.isData3DTexture?Y.texSubImage3D(sn,rt,an,Vt,gn,ut,it,Tt,bn,qt,Mn.data):Ie.isCompressedArrayTexture?Y.compressedTexSubImage3D(sn,rt,an,Vt,gn,ut,it,Tt,bn,Mn.data):Y.texSubImage3D(sn,rt,an,Vt,gn,ut,it,Tt,bn,qt,Mn):he.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,rt,an,Vt,ut,it,bn,qt,Mn.data):he.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,rt,an,Vt,Mn.width,Mn.height,bn,Mn.data):Y.texSubImage2D(Y.TEXTURE_2D,rt,an,Vt,ut,it,bn,qt,Mn);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Jt),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,mr),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,Hr),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,Jn),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Bn),rt===0&&Ie.generateMipmaps&&Y.generateMipmap(sn),X.unbindTexture()},this.initRenderTarget=function(he){pe.get(he).__webglFramebuffer===void 0&&ee.setupRenderTarget(he)},this.initTexture=function(he){he.isCubeTexture?ee.setTextureCube(he,0):he.isData3DTexture?ee.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?ee.setTexture2DArray(he,0):ee.setTexture2D(he,0),X.unbindTexture()},this.resetState=function(){R=0,C=0,P=null,X.reset(),_e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=or._getDrawingBufferColorSpace(e),n.unpackColorSpace=or._getUnpackColorSpace()}};const f8={type:"change"},yO={type:"start"},BK={type:"end"},g_=new fO,m8=new Xd,Tye=Math.cos(70*Qme.DEG2RAD),Xi=new pt,Is=2*Math.PI,Pr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},QT=1e-6;class Aye extends Upe{constructor(e,n=null){super(e,n),this.state=Pr.NONE,this.target=new pt,this.cursor=new pt,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:Dg.ROTATE,MIDDLE:Dg.DOLLY,RIGHT:Dg.PAN},this.touches={ONE:_g.ROTATE,TWO:_g.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new pt,this._lastQuaternion=new vm,this._lastTargetPosition=new pt,this._quat=new vm().setFromUnitVectors(e.up,new pt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new HB,this._sphericalDelta=new HB,this._scale=1,this._panOffset=new pt,this._rotateStart=new Rn,this._rotateEnd=new Rn,this._rotateDelta=new Rn,this._panStart=new Rn,this._panEnd=new Rn,this._panDelta=new Rn,this._dollyStart=new Rn,this._dollyEnd=new Rn,this._dollyDelta=new Rn,this._dollyDirection=new pt,this._mouse=new Rn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Pye.bind(this),this._onPointerDown=Cye.bind(this),this._onPointerUp=jye.bind(this),this._onContextMenu=zye.bind(this),this._onMouseWheel=Oye.bind(this),this._onKeyDown=Lye.bind(this),this._onTouchStart=Fye.bind(this),this._onTouchMove=Iye.bind(this),this._onMouseDown=Dye.bind(this),this._onMouseMove=Rye.bind(this),this._interceptControlDown=Uye.bind(this),this._interceptControlUp=Bye.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(f8),this.update(),this.state=Pr.NONE}update(e=null){const n=this.object.position;Xi.copy(n).sub(this.target),Xi.applyQuaternion(this._quat),this._spherical.setFromVector3(Xi),this.autoRotate&&this.state===Pr.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+=Is:r>Math.PI&&(r-=Is),i<-Math.PI?i+=Is:i>Math.PI&&(i-=Is),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(Xi.setFromSpherical(this._spherical),Xi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Xi),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=Xi.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const l=new pt(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const u=new pt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Xi.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):(g_.origin.copy(this.object.position),g_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(g_.direction))<Tye?this.object.lookAt(this.target):(m8.setFromNormalAndCoplanarPoint(this.object.up,this.target),g_.intersectPlane(m8,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>QT||8*(1-this._lastQuaternion.dot(this.object.quaternion))>QT||this._lastTargetPosition.distanceToSquared(this.target)>QT?(this.dispatchEvent(f8),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Is/60*this.autoRotateSpeed*e:Is/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){Xi.setFromMatrixColumn(n,0),Xi.multiplyScalar(-e),this._panOffset.add(Xi)}_panUp(e,n){this.screenSpacePanning===!0?Xi.setFromMatrixColumn(n,1):(Xi.setFromMatrixColumn(n,0),Xi.crossVectors(this.object.up,Xi)),Xi.multiplyScalar(e),this._panOffset.add(Xi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Xi.copy(i).sub(this.target);let s=Xi.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*n*s/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,s=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Is*this._rotateDelta.x/n.clientHeight),this._rotateUp(Is*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(Is*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(-Is*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(Is*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(-Is*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Is*this._rotateDelta.x/n.clientHeight),this._rotateUp(Is*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(o,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new Rn,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function Cye(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t)))}function Pye(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function jye(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(BK),this.state=Pr.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 Dye(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 Dg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Pr.DOLLY;break;case Dg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Pr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Pr.ROTATE}break;case Dg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Pr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Pr.PAN}break;default:this.state=Pr.NONE}this.state!==Pr.NONE&&this.dispatchEvent(yO)}function Rye(t){switch(this.state){case Pr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Pr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Pr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function Oye(t){this.enabled===!1||this.enableZoom===!1||this.state!==Pr.NONE||(t.preventDefault(),this.dispatchEvent(yO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(BK))}function Lye(t){this.enabled!==!1&&this._handleKeyDown(t)}function Fye(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case _g.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Pr.TOUCH_ROTATE;break;case _g.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Pr.TOUCH_PAN;break;default:this.state=Pr.NONE}break;case 2:switch(this.touches.TWO){case _g.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Pr.TOUCH_DOLLY_PAN;break;case _g.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Pr.TOUCH_DOLLY_ROTATE;break;default:this.state=Pr.NONE}break;default:this.state=Pr.NONE}this.state!==Pr.NONE&&this.dispatchEvent(yO)}function Iye(t){switch(this._trackPointer(t),this.state){case Pr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Pr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Pr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Pr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Pr.NONE}}function zye(t){this.enabled!==!1&&t.preventDefault()}function Uye(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Bye(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Hye(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),s={},o={},l=t[0].morphTargetsRelative,c=new dl;let u=0;for(let d=0;d<t.length;++d){const h=t[d];let p=0;if(n!==(h.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 h.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;s[m]===void 0&&(s[m]=[]),s[m].push(h.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!==h.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 h.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(h.morphAttributes[m])}if(e){let m;if(n)m=h.index.count;else if(h.attributes.position!==void 0)m=h.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 h=[];for(let p=0;p<t.length;++p){const m=t[p].index;for(let b=0;b<m.count;++b)h.push(m.getX(b)+d);d+=t[p].attributes.position.count}c.setIndex(h)}for(const d in s){const h=p8(s[d]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,h)}for(const d in o){const h=o[d][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let p=0;p<h;++p){const m=[];for(let y=0;y<o[d].length;++y)m.push(o[d][y][p]);const b=p8(m);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(b)}}return c}function p8(t){let e,n,r,i=-1,s=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=d.count*n}const o=new e(s),l=new _s(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const h=c/n;for(let p=0,m=d.count;p<m;p++)for(let b=0;b<n;b++){const y=d.getComponent(p,b);l.setComponent(p+h,b,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}class $ye extends xO{constructor(e){super(e)}load(e,n,r,i){const s=this,o=new Rpe(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{n(s.parse(l))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},r,i)}parse(e){function n(u){const d=new DataView(u),h=32/8*3+32/8*3*3+16/8,p=d.getUint32(80,!0);if(80+32/8+p*h===d.byteLength)return!0;const b=[115,111,108,105,100];for(let y=0;y<5;y++)if(r(b,d,y))return!1;return!0}function r(u,d,h){for(let p=0,m=u.length;p<m;p++)if(u[p]!==d.getUint8(h+p))return!1;return!0}function i(u){const d=new DataView(u),h=d.getUint32(80,!0);let p,m,b,y=!1,x,v,S,N,T;for(let U=0;U<70;U++)d.getUint32(U,!1)==1129270351&&d.getUint8(U+4)==82&&d.getUint8(U+5)==61&&(y=!0,x=new Float32Array(h*3*3),v=d.getUint8(U+6)/255,S=d.getUint8(U+7)/255,N=d.getUint8(U+8)/255,T=d.getUint8(U+9)/255);const M=84,A=50,k=new dl,R=new Float32Array(h*3*3),C=new Float32Array(h*3*3),P=new Fn;for(let U=0;U<h;U++){const F=M+U*A,B=d.getFloat32(F,!0),D=d.getFloat32(F+4,!0),$=d.getFloat32(F+8,!0);if(y){const G=d.getUint16(F+48,!0);(G&32768)===0?(p=(G&31)/31,m=(G>>5&31)/31,b=(G>>10&31)/31):(p=v,m=S,b=N)}for(let G=1;G<=3;G++){const I=F+G*12,K=U*3*3+(G-1)*3;R[K]=d.getFloat32(I,!0),R[K+1]=d.getFloat32(I+4,!0),R[K+2]=d.getFloat32(I+8,!0),C[K]=B,C[K+1]=D,C[K+2]=$,y&&(P.setRGB(p,m,b,mo),x[K]=P.r,x[K+1]=P.g,x[K+2]=P.b)}}return k.setAttribute("position",new _s(R,3)),k.setAttribute("normal",new _s(C,3)),y&&(k.setAttribute("color",new _s(x,3)),k.hasColors=!0,k.alpha=T),k}function s(u){const d=new dl,h=/solid([\s\S]*?)endsolid/g,p=/facet([\s\S]*?)endfacet/g,m=/solid\s(.+)/;let b=0;const y=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,x=new RegExp("vertex"+y+y+y,"g"),v=new RegExp("normal"+y+y+y,"g"),S=[],N=[],T=[],M=new pt;let A,k=0,R=0,C=0;for(;(A=h.exec(u))!==null;){R=C;const P=A[0],U=(A=m.exec(P))!==null?A[1]:"";for(T.push(U);(A=p.exec(P))!==null;){let D=0,$=0;const G=A[0];for(;(A=v.exec(G))!==null;)M.x=parseFloat(A[1]),M.y=parseFloat(A[2]),M.z=parseFloat(A[3]),$++;for(;(A=x.exec(G))!==null;)S.push(parseFloat(A[1]),parseFloat(A[2]),parseFloat(A[3])),N.push(M.x,M.y,M.z),D++,C++;$!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+b),D!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+b),b++}const F=R,B=C-R;d.userData.groupNames=T,d.addGroup(F,B,k),k++}return d.setAttribute("position",new So(S,3)),d.setAttribute("normal",new So(N,3)),d}function o(u){return typeof u!="string"?new TextDecoder().decode(u):u}function l(u){if(typeof u=="string"){const d=new Uint8Array(u.length);for(let h=0;h<u.length;h++)d[h]=u.charCodeAt(h)&255;return d.buffer||d}else return u}const c=l(e);return n(c)?i(c):s(o(e))}}function b_(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 ZT={exports:{}};var g8;function Vye(){return g8||(g8=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,s){function o(u,d){if(!i[u]){if(!r[u]){var h=typeof b_=="function"&&b_;if(!d&&h)return h(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(b){var y=r[u][1][b];return o(y||b)},m,m.exports,n,r,i,s)}return i[u].exports}for(var l=typeof b_=="function"&&b_,c=0;c<s.length;c++)o(s[c]);return o})({1:[function(n,r,i){var s=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,h,p,m,b,y,x=[],v=0,S=c.length,N=S,T=s.getTypeOf(c)!=="string";v<c.length;)N=S-v,h=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,b=1<N?(15&d)<<2|h>>6:64,y=2<N?63&h:64,x.push(l.charAt(p)+l.charAt(m)+l.charAt(b)+l.charAt(y));return x.join("")},i.decode=function(c){var u,d,h,p,m,b,y=0,x=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var S,N=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&N--,c.charAt(c.length-2)===l.charAt(64)&&N--,N%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|N):new Array(0|N);y<c.length;)u=l.indexOf(c.charAt(y++))<<2|(p=l.indexOf(c.charAt(y++)))>>4,d=(15&p)<<4|(m=l.indexOf(c.charAt(y++)))>>2,h=(3&m)<<6|(b=l.indexOf(c.charAt(y++))),S[x++]=u,m!==64&&(S[x++]=d),b!==64&&(S[x++]=h);return S}},{"./support":30,"./utils":32}],2:[function(n,r,i){var s=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,h,p,m,b){this.compressedSize=d,this.uncompressedSize=h,this.crc32=p,this.compression=m,this.compressedContent=b}u.prototype={getContentWorker:function(){var d=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,h,p){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(h.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",h)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var s=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var s=n("./utils"),o=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?s.getTypeOf(l)!=="string"?(function(u,d,h,p){var m=o,b=p+h;u^=-1;for(var y=p;y<b;y++)u=u>>>8^m[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,h,p){var m=o,b=p+h;u^=-1;for(var y=p;y<b;y++)u=u>>>8^m[255&(u^d.charCodeAt(y))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=s?"uint8array":"array";function d(h,p){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=p,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,h.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 h=this;this._pako.onData=function(p){h.push({data:p,meta:h.meta})}},i.compressWorker=function(h){return new d("Deflate",h)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function s(m,b){var y,x="";for(y=0;y<b;y++)x+=String.fromCharCode(255&m),m>>>=8;return x}function o(m,b,y,x,v,S){var N,T,M=m.file,A=m.compression,k=S!==u.utf8encode,R=l.transformTo("string",S(M.name)),C=l.transformTo("string",u.utf8encode(M.name)),P=M.comment,U=l.transformTo("string",S(P)),F=l.transformTo("string",u.utf8encode(P)),B=C.length!==M.name.length,D=F.length!==P.length,$="",G="",I="",K=M.dir,Q=M.date,se={crc32:0,compressedSize:0,uncompressedSize:0};b&&!y||(se.crc32=m.crc32,se.compressedSize=m.compressedSize,se.uncompressedSize=m.uncompressedSize);var H=0;b&&(H|=8),k||!B&&!D||(H|=2048);var W=0,J=0;K&&(W|=16),v==="UNIX"?(J=798,W|=(function(xe,ue){var fe=xe;return xe||(fe=ue?16893:33204),(65535&fe)<<16})(M.unixPermissions,K)):(J=20,W|=(function(xe){return 63&(xe||0)})(M.dosPermissions)),N=Q.getUTCHours(),N<<=6,N|=Q.getUTCMinutes(),N<<=5,N|=Q.getUTCSeconds()/2,T=Q.getUTCFullYear()-1980,T<<=4,T|=Q.getUTCMonth()+1,T<<=5,T|=Q.getUTCDate(),B&&(G=s(1,1)+s(d(R),4)+C,$+="up"+s(G.length,2)+G),D&&(I=s(1,1)+s(d(U),4)+F,$+="uc"+s(I.length,2)+I);var ne="";return ne+=`
- \0`,ne+=s(H,2),ne+=A.magic,ne+=s(N,2),ne+=s(T,2),ne+=s(se.crc32,4),ne+=s(se.compressedSize,4),ne+=s(se.uncompressedSize,4),ne+=s(R.length,2),ne+=s($.length,2),{fileRecord:h.LOCAL_FILE_HEADER+ne+R+$,dirRecord:h.CENTRAL_FILE_HEADER+s(J,2)+ne+s(U.length,2)+"\0\0\0\0"+s(W,4)+s(x,4)+R+$+U}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),h=n("../signature");function p(m,b,y,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=y,this.encodeFileName=x,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 b=m.meta.percent||0,y=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:y?(b+100*(y-x-1))/y:100}}))},p.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var b=this.streamFiles&&!m.file.dir;if(b){var y=o(m,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var b=this.streamFiles&&!m.file.dir,y=o(m,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),b)this.push({data:(function(x){return h.DATA_DESCRIPTOR+s(x.crc32,4)+s(x.compressedSize,4)+s(x.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var m=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var y=this.bytesWritten-m,x=(function(v,S,N,T,M){var A=l.transformTo("string",M(T));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(v,2)+s(v,2)+s(S,4)+s(N,4)+s(A.length,2)+A})(this.dirRecords.length,y,m,this.zipComment,this.encodeFileName);this.push({data:x,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 b=this;return m.on("data",function(y){b.processChunk(y)}),m.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),m.on("error",function(y){b.error(y)}),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 b=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var y=0;y<b.length;y++)try{b[y].error(m)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,b=0;b<m.length;b++)m[b].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var s=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{l.forEach(function(p,m){h++;var b=(function(S,N){var T=S||N,M=s[T];if(!M)throw new Error(T+" is not a valid compression method !");return M})(m.options.compression,c.compression),y=m.options.compressionOptions||c.compressionOptions||{},x=m.dir,v=m.date;m._compressWorker(b,y).withStreamInfo("file",{name:p,dir:x,date:v,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new s;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(o,l){return new s().loadAsync(o,l)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var s=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function h(p){return new o.Promise(function(m,b){var y=p.decompressed.getContentWorker().pipe(new u);y.on("error",function(x){b(x)}).on("end",function(){y.streamInfo.crc32!==p.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(p,m){var b=this;return m=s.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.")):s.prepareContent("the loaded zip file",p,!0,m.optimizedBinaryString,m.base64).then(function(y){var x=new c(m);return x.load(y),x}).then(function(y){var x=[o.Promise.resolve(y)],v=y.files;if(m.checkCRC32)for(var S=0;S<v.length;S++)x.push(h(v[S]));return o.Promise.all(x)}).then(function(y){for(var x=y.shift(),v=x.files,S=0;S<v.length;S++){var N=v[S],T=N.fileNameStr,M=s.resolve(N.fileNameStr);b.file(M,N.decompressed,{binary:!0,optimizedBinaryString:!0,date:N.date,dir:N.dir,comment:N.fileCommentStr.length?N.fileCommentStr:null,unixPermissions:N.unixPermissions,dosPermissions:N.dosPermissions,createFolders:m.createFolders}),N.dir||(b.file(M).unsafeOriginalName=T)}return x.zipComment.length&&(b.comment=x.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var s=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(l,o),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var s=n("readable-stream").Readable;function o(l,c,u){s.call(this,c),this._helper=l;var d=this;l.on("data",function(h,p){d.push(h)||d._helper.pause(),u&&u(p)}).on("error",function(h){d.emit("error",h)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,s),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,o);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,o)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var o=new Buffer(s);return o.fill(0),o},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,i){function s(M,A,k){var R,C=l.getTypeOf(A),P=l.extend(k||{},d);P.date=P.date||new Date,P.compression!==null&&(P.compression=P.compression.toUpperCase()),typeof P.unixPermissions=="string"&&(P.unixPermissions=parseInt(P.unixPermissions,8)),P.unixPermissions&&16384&P.unixPermissions&&(P.dir=!0),P.dosPermissions&&16&P.dosPermissions&&(P.dir=!0),P.dir&&(M=v(M)),P.createFolders&&(R=x(M))&&S.call(this,R,!0);var U=C==="string"&&P.binary===!1&&P.base64===!1;k&&k.binary!==void 0||(P.binary=!U),(A instanceof h&&A.uncompressedSize===0||P.dir||!A||A.length===0)&&(P.base64=!1,P.binary=!0,A="",P.compression="STORE",C="string");var F=null;F=A instanceof h||A instanceof c?A:b.isNode&&b.isStream(A)?new y(M,A):l.prepareContent(M,A,P.binary,P.optimizedBinaryString,P.base64);var B=new p(M,F,P);this.files[M]=B}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),h=n("./compressedObject"),p=n("./zipObject"),m=n("./generate"),b=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),x=function(M){M.slice(-1)==="/"&&(M=M.substring(0,M.length-1));var A=M.lastIndexOf("/");return 0<A?M.substring(0,A):""},v=function(M){return M.slice(-1)!=="/"&&(M+="/"),M},S=function(M,A){return A=A!==void 0?A:d.createFolders,M=v(M),this.files[M]||s.call(this,M,null,{dir:!0,createFolders:A}),this.files[M]};function N(M){return Object.prototype.toString.call(M)==="[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(M){var A,k,R;for(A in this.files)R=this.files[A],(k=A.slice(this.root.length,A.length))&&A.slice(0,this.root.length)===this.root&&M(k,R)},filter:function(M){var A=[];return this.forEach(function(k,R){M(k,R)&&A.push(R)}),A},file:function(M,A,k){if(arguments.length!==1)return M=this.root+M,s.call(this,M,A,k),this;if(N(M)){var R=M;return this.filter(function(P,U){return!U.dir&&R.test(P)})}var C=this.files[this.root+M];return C&&!C.dir?C:null},folder:function(M){if(!M)return this;if(N(M))return this.filter(function(C,P){return P.dir&&M.test(C)});var A=this.root+M,k=S.call(this,A),R=this.clone();return R.root=k.name,R},remove:function(M){M=this.root+M;var A=this.files[M];if(A||(M.slice(-1)!=="/"&&(M+="/"),A=this.files[M]),A&&!A.dir)delete this.files[M];else for(var k=this.filter(function(C,P){return P.name.slice(0,M.length)===M}),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(M){var A,k={};try{if((k=l.extend(M||{},{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||"";A=m.generateWorker(this,k,R)}catch(C){(A=new c("error")).error(C)}return new u(A,k.type||"string",k.mimeType)},generateAsync:function(M,A){return this.generateInternalStream(M).accumulate(A)},generateNodeStream:function(M,A){return(M=M||{}).type||(M.type="nodebuffer"),this.generateInternalStream(M).toNodejsStream(A)}};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 s=n("./DataReader");function o(l){s.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,s),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=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]===h)return p-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=l.charCodeAt(3),p=this.readData(4);return c===p[0]&&u===p[1]&&d===p[2]&&h===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 s=n("../utils");function o(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return s.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,i){var s=n("./Uint8ArrayReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var s=n("./DataReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),o.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},o.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},o.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var s=n("./ArrayReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var s=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(h){var p=s.getTypeOf(h);return s.checkSupport(p),p!=="string"||o.uint8array?p==="nodebuffer"?new u(h):o.uint8array?new d(s.transformTo("uint8array",h)):new l(s.transformTo("array",h)):new c(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var s=n("./GenericWorker"),o=n("../utils");function l(c){s.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,s),l.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var s=n("./GenericWorker"),o=n("../crc32");function l(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,s),l.prototype.processChunk=function(c){this.streamInfo.crc32=o(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var s=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(l,o),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}o.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var s=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.inherits(l,o),l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function s(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,l){return this._listeners[o].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,l){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,l)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var l=this;return o.on("data",function(c){l.processChunk(c)}),o.on("end",function(){l.end()}),o.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,l){return this.extraStreamInfo[o]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=s},{}],29:[function(n,r,i){var s=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),h=null;if(u.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(b,y){return new d.Promise(function(x,v){var S=[],N=b._internalType,T=b._outputType,M=b._mimeType;b.on("data",function(A,k){S.push(A),y&&y(k)}).on("error",function(A){S=[],v(A)}).on("end",function(){try{var A=(function(k,R,C){switch(k){case"blob":return s.newBlob(s.transformTo("arraybuffer",R),C);case"base64":return c.encode(R);default:return s.transformTo(k,R)}})(T,(function(k,R){var C,P=0,U=null,F=0;for(C=0;C<R.length;C++)F+=R[C].length;switch(k){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(U=new Uint8Array(F),C=0;C<R.length;C++)U.set(R[C],P),P+=R[C].length;return U;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+k+"'")}})(N,S),M);x(A)}catch(k){v(k)}S=[]}).resume()})}function m(b,y,x){var v=y;switch(y){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=y,this._mimeType=x,s.checkSupport(v),this._worker=b.pipe(new o(v)),b.lock()}catch(S){this._worker=new l("error"),this._worker.error(S)}}m.prototype={accumulate:function(b){return p(this,b)},on:function(b,y){var x=this;return b==="data"?this._worker.on(b,function(v){y.call(x,v.data,v.meta)}):this._worker.on(b,function(){s.delay(y,arguments,x)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},b)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var s=n("./utils"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function h(){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(b){var y,x,v,S,N,T=b.length,M=0;for(S=0;S<T;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<T&&(64512&(v=b.charCodeAt(S+1)))==56320&&(x=65536+(x-55296<<10)+(v-56320),S++),M+=x<128?1:x<2048?2:x<65536?3:4;for(y=o.uint8array?new Uint8Array(M):new Array(M),S=N=0;N<M;S++)(64512&(x=b.charCodeAt(S)))==55296&&S+1<T&&(64512&(v=b.charCodeAt(S+1)))==56320&&(x=65536+(x-55296<<10)+(v-56320),S++),x<128?y[N++]=x:(x<2048?y[N++]=192|x>>>6:(x<65536?y[N++]=224|x>>>12:(y[N++]=240|x>>>18,y[N++]=128|x>>>12&63),y[N++]=128|x>>>6&63),y[N++]=128|63&x);return y})(m)},i.utf8decode=function(m){return o.nodebuffer?s.transformTo("nodebuffer",m).toString("utf-8"):(function(b){var y,x,v,S,N=b.length,T=new Array(2*N);for(y=x=0;y<N;)if((v=b[y++])<128)T[x++]=v;else if(4<(S=u[v]))T[x++]=65533,y+=S-1;else{for(v&=S===2?31:S===3?15:7;1<S&&y<N;)v=v<<6|63&b[y++],S--;1<S?T[x++]=65533:v<65536?T[x++]=v:(v-=65536,T[x++]=55296|v>>10&1023,T[x++]=56320|1023&v)}return T.length!==x&&(T.subarray?T=T.subarray(0,x):T.length=x),s.applyFromCharCode(T)})(m=s.transformTo(o.uint8array?"uint8array":"array",m))},s.inherits(h,c),h.prototype.processChunk=function(m){var b=s.transformTo(o.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var y=b;(b=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),b.set(y,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var x=(function(S,N){var T;for((N=N||S.length)>S.length&&(N=S.length),T=N-1;0<=T&&(192&S[T])==128;)T--;return T<0||T===0?N:T+u[S[T]]>N?T:N})(b),v=b;x!==b.length&&(o.uint8array?(v=b.subarray(0,x),this.leftOver=b.subarray(x,b.length)):(v=b.slice(0,x),this.leftOver=b.slice(x,b.length))),this.push({data:i.utf8decode(v),meta:m.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,s.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 s=n("./support"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(y){return y}function d(y,x){for(var v=0;v<y.length;++v)x[v]=255&y.charCodeAt(v);return x}n("setimmediate"),i.newBlob=function(y,x){i.checkSupport("blob");try{return new Blob([y],{type:x})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(y),v.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(y,x,v){var S=[],N=0,T=y.length;if(T<=v)return String.fromCharCode.apply(null,y);for(;N<T;)x==="array"||x==="nodebuffer"?S.push(String.fromCharCode.apply(null,y.slice(N,Math.min(N+v,T)))):S.push(String.fromCharCode.apply(null,y.subarray(N,Math.min(N+v,T)))),N+=v;return S.join("")},stringifyByChar:function(y){for(var x="",v=0;v<y.length;v++)x+=String.fromCharCode(y[v]);return x},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function p(y){var x=65536,v=i.getTypeOf(y),S=!0;if(v==="uint8array"?S=h.applyCanBeUsed.uint8array:v==="nodebuffer"&&(S=h.applyCanBeUsed.nodebuffer),S)for(;1<x;)try{return h.stringifyByChunk(y,v,x)}catch{x=Math.floor(x/2)}return h.stringifyByChar(y)}function m(y,x){for(var v=0;v<y.length;v++)x[v]=y[v];return x}i.applyFromCharCode=p;var b={};b.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return b.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,l.allocBuffer(y.length))}},b.array={string:p,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(y)}},b.arraybuffer={string:function(y){return p(new Uint8Array(y))},array:function(y){return m(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(new Uint8Array(y))}},b.uint8array={string:p,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return l.newBufferFrom(y)}},b.nodebuffer={string:p,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return b.nodebuffer.uint8array(y).buffer},uint8array:function(y){return m(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,x){if(x=x||"",!y)return x;i.checkSupport(y);var v=i.getTypeOf(x);return b[v][y](x)},i.resolve=function(y){for(var x=y.split("/"),v=[],S=0;S<x.length;S++){var N=x[S];N==="."||N===""&&S!==0&&S!==x.length-1||(N===".."?v.pop():v.push(N))}return v.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":s.nodebuffer&&l.isBuffer(y)?"nodebuffer":s.uint8array&&y instanceof Uint8Array?"uint8array":s.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!s[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var x,v,S="";for(v=0;v<(y||"").length;v++)S+="\\x"+((x=y.charCodeAt(v))<16?"0":"")+x.toString(16).toUpperCase();return S},i.delay=function(y,x,v){setImmediate(function(){y.apply(v||null,x||[])})},i.inherits=function(y,x){function v(){}v.prototype=x.prototype,y.prototype=new v},i.extend=function(){var y,x,v={};for(y=0;y<arguments.length;y++)for(x in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],x)&&v[x]===void 0&&(v[x]=arguments[y][x]);return v},i.prepareContent=function(y,x,v,S,N){return c.Promise.resolve(x).then(function(T){return s.blob&&(T instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T))!==-1)&&typeof FileReader<"u"?new c.Promise(function(M,A){var k=new FileReader;k.onload=function(R){M(R.target.result)},k.onerror=function(R){A(R.target.error)},k.readAsArrayBuffer(T)}):T}).then(function(T){var M=i.getTypeOf(T);return M?(M==="arraybuffer"?T=i.transformTo("uint8array",T):M==="string"&&(N?T=o.decode(T):v&&S!==!0&&(T=(function(A){return d(A,s.uint8array?new Uint8Array(A.length):new Array(A.length))})(T))),T):c.Promise.reject(new Error("Can't read the data of '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var s=n("./reader/readerFor"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){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(h)+")")}},isSignature:function(h,p){var m=this.reader.index;this.reader.setIndex(h);var b=this.reader.readString(4)===p;return this.reader.setIndex(m),b},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 h=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",m=o.transformTo(p,h);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 h,p,m,b=this.zip64EndOfCentralSize-44;0<b;)h=this.reader.readInt(2),p=this.reader.readInt(4),m=this.reader.readData(p),this.zip64ExtensibleData[h]={id:h,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 h,p;for(h=0;h<this.files.length;h++)p=this.files[h],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(h=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);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 h=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(h<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(h);var p=h;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,(h=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(h),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 b=p-m;if(0<b)this.isSignature(p,l.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(h){this.reader=s(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var s=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),h=n("./support");function p(m,b){this.options=m,this.loadOptions=b}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var b,y;if(m.skip(22),this.fileNameLength=m.readInt(2),y=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=(function(x){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===x)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,b,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 b=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(b),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=s(this.extraFields[1].value);this.uncompressedSize===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 b,y,x,v=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<v;)b=m.readInt(2),y=m.readInt(2),x=m.readData(y),this.extraFields[b]={id:b,length:y,value:x};m.setIndex(v)},handleUTF8:function(){var m=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var y=o.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var v=o.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var b=s(m.value);return b.readInt(1)!==1||c(this.fileName)!==b.readInt(4)?null:u.utf8decode(b.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var b=s(m.value);return b.readInt(1)!==1||c(this.fileComment)!==b.readInt(4)?null:u.utf8decode(b.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 s(b,y,x){this.name=b,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=y,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(b){var y=null,x="string";try{if(!b)throw new Error("No output type specified.");var v=(x=b.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),y=this._decompressWorker();var S=!this._dataBinary;S&&!v&&(y=y.pipe(new c.Utf8EncodeWorker)),!S&&v&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(N){(y=new d("error")).error(N)}return new o(y,x,"")},async:function(b,y){return this.internalStream(b).accumulate(y)},nodeStream:function(b,y){return this.internalStream(b||"nodebuffer").toNodejsStream(y)},_compressWorker:function(b,y){if(this._data instanceof u&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,b,y)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var h=["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<h.length;m++)s.prototype[h[m]]=p;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(s){var o,l,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var u=0,d=new c(b),h=s.document.createTextNode("");d.observe(h,{characterData:!0}),o=function(){h.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)o="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var y=s.document.createElement("script");y.onreadystatechange=function(){b(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},s.document.documentElement.appendChild(y)}:function(){setTimeout(b,0)};else{var p=new s.MessageChannel;p.port1.onmessage=b,o=function(){p.port2.postMessage(0)}}var m=[];function b(){var y,x;l=!0;for(var v=m.length;v;){for(x=m,m=[],y=-1;++y<v;)x[y]();v=m.length}l=!1}r.exports=function(y){m.push(y)!==1||l||o()}}).call(this,typeof Hw<"u"?Hw:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&y(this,v)}function p(v,S,N){this.promise=v,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof N=="function"&&(this.onRejected=N,this.callRejected=this.otherCallRejected)}function m(v,S,N){s(function(){var T;try{T=S(N)}catch(M){return l.reject(v,M)}T===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,T)})}function b(v){var S=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof S=="function")return function(){S.apply(v,arguments)}}function y(v,S){var N=!1;function T(k){N||(N=!0,l.reject(v,k))}function M(k){N||(N=!0,l.resolve(v,k))}var A=x(function(){S(M,T)});A.status==="error"&&T(A.value)}function x(v,S){var N={};try{N.value=v(S),N.status="success"}catch(T){N.status="error",N.value=T}return N}(r.exports=h).prototype.finally=function(v){if(typeof v!="function")return this;var S=this.constructor;return this.then(function(N){return S.resolve(v()).then(function(){return N})},function(N){return S.resolve(v()).then(function(){throw N})})},h.prototype.catch=function(v){return this.then(null,v)},h.prototype.then=function(v,S){if(typeof v!="function"&&this.state===u||typeof S!="function"&&this.state===c)return this;var N=new this.constructor(o);return this.state!==d?m(N,this.state===u?v:S,this.outcome):this.queue.push(new p(N,v,S)),N},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 N=x(b,S);if(N.status==="error")return l.reject(v,N.value);var T=N.value;if(T)y(v,T);else{v.state=u,v.outcome=S;for(var M=-1,A=v.queue.length;++M<A;)v.queue[M].callFulfilled(S)}return v},l.reject=function(v,S){v.state=c,v.outcome=S;for(var N=-1,T=v.queue.length;++N<T;)v.queue[N].callRejected(S);return v},h.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},h.reject=function(v){var S=new this(o);return l.reject(S,v)},h.all=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=v.length,T=!1;if(!N)return this.resolve([]);for(var M=new Array(N),A=0,k=-1,R=new this(o);++k<N;)C(v[k],k);return R;function C(P,U){S.resolve(P).then(function(F){M[U]=F,++A!==N||T||(T=!0,l.resolve(R,M))},function(F){T||(T=!0,l.reject(R,F))})}},h.race=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=v.length,T=!1;if(!N)return this.resolve([]);for(var M=-1,A=new this(o);++M<N;)k=v[M],S.resolve(k).then(function(R){T||(T=!0,l.resolve(A,R))},function(R){T||(T=!0,l.reject(A,R))});var k;return A}},{immediate:36}],38:[function(n,r,i){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var s=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,h=0,p=-1,m=0,b=8;function y(v){if(!(this instanceof y))return new y(v);this.options=o.assign({level:p,method:b,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 N=s.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(N!==h)throw new Error(c[N]);if(S.header&&s.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,(N=s.deflateSetDictionary(this.strm,T))!==h)throw new Error(c[N]);this._dict_set=!0}}function x(v,S){var N=new y(S);if(N.push(v,!0),N.err)throw N.msg||c[N.err];return N.result}y.prototype.push=function(v,S){var N,T,M=this.strm,A=this.options.chunkSize;if(this.ended)return!1;T=S===~~S?S:S===!0?4:0,typeof v=="string"?M.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?M.input=new Uint8Array(v):M.input=v,M.next_in=0,M.avail_in=M.input.length;do{if(M.avail_out===0&&(M.output=new o.Buf8(A),M.next_out=0,M.avail_out=A),(N=s.deflate(M,T))!==1&&N!==h)return this.onEnd(N),!(this.ended=!0);M.avail_out!==0&&(M.avail_in!==0||T!==4&&T!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(M.output,M.next_out))):this.onData(o.shrinkBuf(M.output,M.next_out)))}while((0<M.avail_in||M.avail_out===0)&&N!==1);return T===4?(N=s.deflateEnd(this.strm),this.onEnd(N),this.ended=!0,N===h):T!==2||(this.onEnd(h),!(M.avail_out=0))},y.prototype.onData=function(v){this.chunks.push(v)},y.prototype.onEnd=function(v){v===h&&(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=y,i.deflate=x,i.deflateRaw=function(v,S){return(S=S||{}).raw=!0,x(v,S)},i.gzip=function(v,S){return(S=S||{}).gzip=!0,x(v,S)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var s=n("./zlib/inflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),h=n("./zlib/gzheader"),p=Object.prototype.toString;function m(y){if(!(this instanceof m))return new m(y);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},y||{});var x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||y&&y.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&(15&x.windowBits)==0&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var v=s.inflateInit2(this.strm,x.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function b(y,x){var v=new m(x);if(v.push(y,!0),v.err)throw v.msg||u[v.err];return v.result}m.prototype.push=function(y,x){var v,S,N,T,M,A,k=this.strm,R=this.options.chunkSize,C=this.options.dictionary,P=!1;if(this.ended)return!1;S=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?k.input=l.binstring2buf(y):p.call(y)==="[object ArrayBuffer]"?k.input=new Uint8Array(y):k.input=y,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=s.inflate(k,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&C&&(A=typeof C=="string"?l.string2buf(C):p.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,v=s.inflateSetDictionary(this.strm,A)),v===c.Z_BUF_ERROR&&P===!0&&(v=c.Z_OK,P=!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"?(N=l.utf8border(k.output,k.next_out),T=k.next_out-N,M=l.buf2string(k.output,N),k.next_out=T,k.avail_out=R-T,T&&o.arraySet(k.output,k.output,N,T,0),this.onData(M)):this.onData(o.shrinkBuf(k.output,k.next_out)))),k.avail_in===0&&k.avail_out===0&&(P=!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=s.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(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=m,i.inflate=b,i.inflateRaw=function(y,x){return(x=x||{}).raw=!0,b(y,x)},i.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var h in d)d.hasOwnProperty(h)&&(c[h]=d[h])}}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,h,p){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+h),p);else for(var m=0;m<h;m++)c[p+m]=u[d+m]},flattenChunks:function(c){var u,d,h,p,m,b;for(u=h=0,d=c.length;u<d;u++)h+=c[u].length;for(b=new Uint8Array(h),u=p=0,d=c.length;u<d;u++)m=c[u],b.set(m,p),p+=m.length;return b}},l={arraySet:function(c,u,d,h,p){for(var m=0;m<h;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(s)},{}],42:[function(n,r,i){var s=n("./common"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new s.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(h,p){if(p<65537&&(h.subarray&&l||!h.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(h,p));for(var m="",b=0;b<p;b++)m+=String.fromCharCode(h[b]);return m}c[254]=c[254]=1,i.string2buf=function(h){var p,m,b,y,x,v=h.length,S=0;for(y=0;y<v;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<v&&(64512&(b=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(b-56320),y++),S+=m<128?1:m<2048?2:m<65536?3:4;for(p=new s.Buf8(S),y=x=0;x<S;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<v&&(64512&(b=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(b-56320),y++),m<128?p[x++]=m:(m<2048?p[x++]=192|m>>>6:(m<65536?p[x++]=224|m>>>12:(p[x++]=240|m>>>18,p[x++]=128|m>>>12&63),p[x++]=128|m>>>6&63),p[x++]=128|63&m);return p},i.buf2binstring=function(h){return d(h,h.length)},i.binstring2buf=function(h){for(var p=new s.Buf8(h.length),m=0,b=p.length;m<b;m++)p[m]=h.charCodeAt(m);return p},i.buf2string=function(h,p){var m,b,y,x,v=p||h.length,S=new Array(2*v);for(m=b=0;m<v;)if((y=h[m++])<128)S[b++]=y;else if(4<(x=c[y]))S[b++]=65533,m+=x-1;else{for(y&=x===2?31:x===3?15:7;1<x&&m<v;)y=y<<6|63&h[m++],x--;1<x?S[b++]=65533:y<65536?S[b++]=y:(y-=65536,S[b++]=55296|y>>10&1023,S[b++]=56320|1023&y)}return d(S,b)},i.utf8border=function(h,p){var m;for((p=p||h.length)>h.length&&(p=h.length),m=p-1;0<=m&&(192&h[m])==128;)m--;return m<0||m===0?p:m+c[h[m]]>p?m:p}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,o,l,c){for(var u=65535&s|0,d=s>>>16&65535|0,h=0;l!==0;){for(l-=h=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--h;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var s=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l,c,u){var d=s,h=u+c;o^=-1;for(var p=u;p<h;p++)o=o>>>8^d[255&(o^l[p])];return-1^o}},{}],46:[function(n,r,i){var s,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),h=0,p=4,m=0,b=-2,y=-1,x=4,v=2,S=8,N=9,T=286,M=30,A=19,k=2*T+1,R=15,C=3,P=258,U=P+C+1,F=42,B=113,D=1,$=2,G=3,I=4;function K(V,Y){return V.msg=d[Y],Y}function Q(V){return(V<<1)-(4<V?9:0)}function se(V){for(var Y=V.length;0<=--Y;)V[Y]=0}function H(V){var Y=V.state,de=Y.pending;de>V.avail_out&&(de=V.avail_out),de!==0&&(o.arraySet(V.output,Y.pending_buf,Y.pending_out,de,V.next_out),V.next_out+=de,Y.pending_out+=de,V.total_out+=de,V.avail_out-=de,Y.pending-=de,Y.pending===0&&(Y.pending_out=0))}function W(V,Y){l._tr_flush_block(V,0<=V.block_start?V.block_start:-1,V.strstart-V.block_start,Y),V.block_start=V.strstart,H(V.strm)}function J(V,Y){V.pending_buf[V.pending++]=Y}function ne(V,Y){V.pending_buf[V.pending++]=Y>>>8&255,V.pending_buf[V.pending++]=255&Y}function xe(V,Y){var de,q,re=V.max_chain_length,X=V.strstart,le=V.prev_length,pe=V.nice_match,ee=V.strstart>V.w_size-U?V.strstart-(V.w_size-U):0,z=V.window,O=V.w_mask,Z=V.prev,me=V.strstart+P,Te=z[X+le-1],ke=z[X+le];V.prev_length>=V.good_match&&(re>>=2),pe>V.lookahead&&(pe=V.lookahead);do if(z[(de=Y)+le]===ke&&z[de+le-1]===Te&&z[de]===z[X]&&z[++de]===z[X+1]){X+=2,de++;do;while(z[++X]===z[++de]&&z[++X]===z[++de]&&z[++X]===z[++de]&&z[++X]===z[++de]&&z[++X]===z[++de]&&z[++X]===z[++de]&&z[++X]===z[++de]&&z[++X]===z[++de]&&X<me);if(q=P-(me-X),X=me-P,le<q){if(V.match_start=Y,pe<=(le=q))break;Te=z[X+le-1],ke=z[X+le]}}while((Y=Z[Y&O])>ee&&--re!=0);return le<=V.lookahead?le:V.lookahead}function ue(V){var Y,de,q,re,X,le,pe,ee,z,O,Z=V.w_size;do{if(re=V.window_size-V.lookahead-V.strstart,V.strstart>=Z+(Z-U)){for(o.arraySet(V.window,V.window,Z,Z,0),V.match_start-=Z,V.strstart-=Z,V.block_start-=Z,Y=de=V.hash_size;q=V.head[--Y],V.head[Y]=Z<=q?q-Z:0,--de;);for(Y=de=Z;q=V.prev[--Y],V.prev[Y]=Z<=q?q-Z:0,--de;);re+=Z}if(V.strm.avail_in===0)break;if(le=V.strm,pe=V.window,ee=V.strstart+V.lookahead,z=re,O=void 0,O=le.avail_in,z<O&&(O=z),de=O===0?0:(le.avail_in-=O,o.arraySet(pe,le.input,le.next_in,O,ee),le.state.wrap===1?le.adler=c(le.adler,pe,O,ee):le.state.wrap===2&&(le.adler=u(le.adler,pe,O,ee)),le.next_in+=O,le.total_in+=O,O),V.lookahead+=de,V.lookahead+V.insert>=C)for(X=V.strstart-V.insert,V.ins_h=V.window[X],V.ins_h=(V.ins_h<<V.hash_shift^V.window[X+1])&V.hash_mask;V.insert&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[X+C-1])&V.hash_mask,V.prev[X&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=X,X++,V.insert--,!(V.lookahead+V.insert<C)););}while(V.lookahead<U&&V.strm.avail_in!==0)}function fe(V,Y){for(var de,q;;){if(V.lookahead<U){if(ue(V),V.lookahead<U&&Y===h)return D;if(V.lookahead===0)break}if(de=0,V.lookahead>=C&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+C-1])&V.hash_mask,de=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),de!==0&&V.strstart-de<=V.w_size-U&&(V.match_length=xe(V,de)),V.match_length>=C)if(q=l._tr_tally(V,V.strstart-V.match_start,V.match_length-C),V.lookahead-=V.match_length,V.match_length<=V.max_lazy_match&&V.lookahead>=C){for(V.match_length--;V.strstart++,V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+C-1])&V.hash_mask,de=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart,--V.match_length!=0;);V.strstart++}else V.strstart+=V.match_length,V.match_length=0,V.ins_h=V.window[V.strstart],V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+1])&V.hash_mask;else q=l._tr_tally(V,0,V.window[V.strstart]),V.lookahead--,V.strstart++;if(q&&(W(V,!1),V.strm.avail_out===0))return D}return V.insert=V.strstart<C-1?V.strstart:C-1,Y===p?(W(V,!0),V.strm.avail_out===0?G:I):V.last_lit&&(W(V,!1),V.strm.avail_out===0)?D:$}function De(V,Y){for(var de,q,re;;){if(V.lookahead<U){if(ue(V),V.lookahead<U&&Y===h)return D;if(V.lookahead===0)break}if(de=0,V.lookahead>=C&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+C-1])&V.hash_mask,de=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),V.prev_length=V.match_length,V.prev_match=V.match_start,V.match_length=C-1,de!==0&&V.prev_length<V.max_lazy_match&&V.strstart-de<=V.w_size-U&&(V.match_length=xe(V,de),V.match_length<=5&&(V.strategy===1||V.match_length===C&&4096<V.strstart-V.match_start)&&(V.match_length=C-1)),V.prev_length>=C&&V.match_length<=V.prev_length){for(re=V.strstart+V.lookahead-C,q=l._tr_tally(V,V.strstart-1-V.prev_match,V.prev_length-C),V.lookahead-=V.prev_length-1,V.prev_length-=2;++V.strstart<=re&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+C-1])&V.hash_mask,de=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),--V.prev_length!=0;);if(V.match_available=0,V.match_length=C-1,V.strstart++,q&&(W(V,!1),V.strm.avail_out===0))return D}else if(V.match_available){if((q=l._tr_tally(V,0,V.window[V.strstart-1]))&&W(V,!1),V.strstart++,V.lookahead--,V.strm.avail_out===0)return D}else V.match_available=1,V.strstart++,V.lookahead--}return V.match_available&&(q=l._tr_tally(V,0,V.window[V.strstart-1]),V.match_available=0),V.insert=V.strstart<C-1?V.strstart:C-1,Y===p?(W(V,!0),V.strm.avail_out===0?G:I):V.last_lit&&(W(V,!1),V.strm.avail_out===0)?D:$}function oe(V,Y,de,q,re){this.good_length=V,this.max_lazy=Y,this.nice_length=de,this.max_chain=q,this.func=re}function Ne(){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*M+1)),this.bl_tree=new o.Buf16(2*(2*A+1)),se(this.dyn_ltree),se(this.dyn_dtree),se(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),se(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*T+1),se(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 Fe(V){var Y;return V&&V.state?(V.total_in=V.total_out=0,V.data_type=v,(Y=V.state).pending=0,Y.pending_out=0,Y.wrap<0&&(Y.wrap=-Y.wrap),Y.status=Y.wrap?F:B,V.adler=Y.wrap===2?0:1,Y.last_flush=h,l._tr_init(Y),m):K(V,b)}function ce(V){var Y=Fe(V);return Y===m&&(function(de){de.window_size=2*de.w_size,se(de.head),de.max_lazy_match=s[de.level].max_lazy,de.good_match=s[de.level].good_length,de.nice_match=s[de.level].nice_length,de.max_chain_length=s[de.level].max_chain,de.strstart=0,de.block_start=0,de.lookahead=0,de.insert=0,de.match_length=de.prev_length=C-1,de.match_available=0,de.ins_h=0})(V.state),Y}function Ve(V,Y,de,q,re,X){if(!V)return b;var le=1;if(Y===y&&(Y=6),q<0?(le=0,q=-q):15<q&&(le=2,q-=16),re<1||N<re||de!==S||q<8||15<q||Y<0||9<Y||X<0||x<X)return K(V,b);q===8&&(q=9);var pe=new Ne;return(V.state=pe).strm=V,pe.wrap=le,pe.gzhead=null,pe.w_bits=q,pe.w_size=1<<pe.w_bits,pe.w_mask=pe.w_size-1,pe.hash_bits=re+7,pe.hash_size=1<<pe.hash_bits,pe.hash_mask=pe.hash_size-1,pe.hash_shift=~~((pe.hash_bits+C-1)/C),pe.window=new o.Buf8(2*pe.w_size),pe.head=new o.Buf16(pe.hash_size),pe.prev=new o.Buf16(pe.w_size),pe.lit_bufsize=1<<re+6,pe.pending_buf_size=4*pe.lit_bufsize,pe.pending_buf=new o.Buf8(pe.pending_buf_size),pe.d_buf=1*pe.lit_bufsize,pe.l_buf=3*pe.lit_bufsize,pe.level=Y,pe.strategy=X,pe.method=de,ce(V)}s=[new oe(0,0,0,0,function(V,Y){var de=65535;for(de>V.pending_buf_size-5&&(de=V.pending_buf_size-5);;){if(V.lookahead<=1){if(ue(V),V.lookahead===0&&Y===h)return D;if(V.lookahead===0)break}V.strstart+=V.lookahead,V.lookahead=0;var q=V.block_start+de;if((V.strstart===0||V.strstart>=q)&&(V.lookahead=V.strstart-q,V.strstart=q,W(V,!1),V.strm.avail_out===0)||V.strstart-V.block_start>=V.w_size-U&&(W(V,!1),V.strm.avail_out===0))return D}return V.insert=0,Y===p?(W(V,!0),V.strm.avail_out===0?G:I):(V.strstart>V.block_start&&(W(V,!1),V.strm.avail_out),D)}),new oe(4,4,8,4,fe),new oe(4,5,16,8,fe),new oe(4,6,32,32,fe),new oe(4,4,16,16,De),new oe(8,16,32,32,De),new oe(8,16,128,128,De),new oe(8,32,128,256,De),new oe(32,128,258,1024,De),new oe(32,258,258,4096,De)],i.deflateInit=function(V,Y){return Ve(V,Y,S,15,8,0)},i.deflateInit2=Ve,i.deflateReset=ce,i.deflateResetKeep=Fe,i.deflateSetHeader=function(V,Y){return V&&V.state?V.state.wrap!==2?b:(V.state.gzhead=Y,m):b},i.deflate=function(V,Y){var de,q,re,X;if(!V||!V.state||5<Y||Y<0)return V?K(V,b):b;if(q=V.state,!V.output||!V.input&&V.avail_in!==0||q.status===666&&Y!==p)return K(V,V.avail_out===0?-5:b);if(q.strm=V,de=q.last_flush,q.last_flush=Y,q.status===F)if(q.wrap===2)V.adler=0,J(q,31),J(q,139),J(q,8),q.gzhead?(J(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)),J(q,255&q.gzhead.time),J(q,q.gzhead.time>>8&255),J(q,q.gzhead.time>>16&255),J(q,q.gzhead.time>>24&255),J(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),J(q,255&q.gzhead.os),q.gzhead.extra&&q.gzhead.extra.length&&(J(q,255&q.gzhead.extra.length),J(q,q.gzhead.extra.length>>8&255)),q.gzhead.hcrc&&(V.adler=u(V.adler,q.pending_buf,q.pending,0)),q.gzindex=0,q.status=69):(J(q,0),J(q,0),J(q,0),J(q,0),J(q,0),J(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),J(q,3),q.status=B);else{var le=S+(q.w_bits-8<<4)<<8;le|=(2<=q.strategy||q.level<2?0:q.level<6?1:q.level===6?2:3)<<6,q.strstart!==0&&(le|=32),le+=31-le%31,q.status=B,ne(q,le),q.strstart!==0&&(ne(q,V.adler>>>16),ne(q,65535&V.adler)),V.adler=1}if(q.status===69)if(q.gzhead.extra){for(re=q.pending;q.gzindex<(65535&q.gzhead.extra.length)&&(q.pending!==q.pending_buf_size||(q.gzhead.hcrc&&q.pending>re&&(V.adler=u(V.adler,q.pending_buf,q.pending-re,re)),H(V),re=q.pending,q.pending!==q.pending_buf_size));)J(q,255&q.gzhead.extra[q.gzindex]),q.gzindex++;q.gzhead.hcrc&&q.pending>re&&(V.adler=u(V.adler,q.pending_buf,q.pending-re,re)),q.gzindex===q.gzhead.extra.length&&(q.gzindex=0,q.status=73)}else q.status=73;if(q.status===73)if(q.gzhead.name){re=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>re&&(V.adler=u(V.adler,q.pending_buf,q.pending-re,re)),H(V),re=q.pending,q.pending===q.pending_buf_size)){X=1;break}X=q.gzindex<q.gzhead.name.length?255&q.gzhead.name.charCodeAt(q.gzindex++):0,J(q,X)}while(X!==0);q.gzhead.hcrc&&q.pending>re&&(V.adler=u(V.adler,q.pending_buf,q.pending-re,re)),X===0&&(q.gzindex=0,q.status=91)}else q.status=91;if(q.status===91)if(q.gzhead.comment){re=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>re&&(V.adler=u(V.adler,q.pending_buf,q.pending-re,re)),H(V),re=q.pending,q.pending===q.pending_buf_size)){X=1;break}X=q.gzindex<q.gzhead.comment.length?255&q.gzhead.comment.charCodeAt(q.gzindex++):0,J(q,X)}while(X!==0);q.gzhead.hcrc&&q.pending>re&&(V.adler=u(V.adler,q.pending_buf,q.pending-re,re)),X===0&&(q.status=103)}else q.status=103;if(q.status===103&&(q.gzhead.hcrc?(q.pending+2>q.pending_buf_size&&H(V),q.pending+2<=q.pending_buf_size&&(J(q,255&V.adler),J(q,V.adler>>8&255),V.adler=0,q.status=B)):q.status=B),q.pending!==0){if(H(V),V.avail_out===0)return q.last_flush=-1,m}else if(V.avail_in===0&&Q(Y)<=Q(de)&&Y!==p)return K(V,-5);if(q.status===666&&V.avail_in!==0)return K(V,-5);if(V.avail_in!==0||q.lookahead!==0||Y!==h&&q.status!==666){var pe=q.strategy===2?(function(ee,z){for(var O;;){if(ee.lookahead===0&&(ue(ee),ee.lookahead===0)){if(z===h)return D;break}if(ee.match_length=0,O=l._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++,O&&(W(ee,!1),ee.strm.avail_out===0))return D}return ee.insert=0,z===p?(W(ee,!0),ee.strm.avail_out===0?G:I):ee.last_lit&&(W(ee,!1),ee.strm.avail_out===0)?D:$})(q,Y):q.strategy===3?(function(ee,z){for(var O,Z,me,Te,ke=ee.window;;){if(ee.lookahead<=P){if(ue(ee),ee.lookahead<=P&&z===h)return D;if(ee.lookahead===0)break}if(ee.match_length=0,ee.lookahead>=C&&0<ee.strstart&&(Z=ke[me=ee.strstart-1])===ke[++me]&&Z===ke[++me]&&Z===ke[++me]){Te=ee.strstart+P;do;while(Z===ke[++me]&&Z===ke[++me]&&Z===ke[++me]&&Z===ke[++me]&&Z===ke[++me]&&Z===ke[++me]&&Z===ke[++me]&&Z===ke[++me]&&me<Te);ee.match_length=P-(Te-me),ee.match_length>ee.lookahead&&(ee.match_length=ee.lookahead)}if(ee.match_length>=C?(O=l._tr_tally(ee,1,ee.match_length-C),ee.lookahead-=ee.match_length,ee.strstart+=ee.match_length,ee.match_length=0):(O=l._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++),O&&(W(ee,!1),ee.strm.avail_out===0))return D}return ee.insert=0,z===p?(W(ee,!0),ee.strm.avail_out===0?G:I):ee.last_lit&&(W(ee,!1),ee.strm.avail_out===0)?D:$})(q,Y):s[q.level].func(q,Y);if(pe!==G&&pe!==I||(q.status=666),pe===D||pe===G)return V.avail_out===0&&(q.last_flush=-1),m;if(pe===$&&(Y===1?l._tr_align(q):Y!==5&&(l._tr_stored_block(q,0,0,!1),Y===3&&(se(q.head),q.lookahead===0&&(q.strstart=0,q.block_start=0,q.insert=0))),H(V),V.avail_out===0))return q.last_flush=-1,m}return Y!==p?m:q.wrap<=0?1:(q.wrap===2?(J(q,255&V.adler),J(q,V.adler>>8&255),J(q,V.adler>>16&255),J(q,V.adler>>24&255),J(q,255&V.total_in),J(q,V.total_in>>8&255),J(q,V.total_in>>16&255),J(q,V.total_in>>24&255)):(ne(q,V.adler>>>16),ne(q,65535&V.adler)),H(V),0<q.wrap&&(q.wrap=-q.wrap),q.pending!==0?m:1)},i.deflateEnd=function(V){var Y;return V&&V.state?(Y=V.state.status)!==F&&Y!==69&&Y!==73&&Y!==91&&Y!==103&&Y!==B&&Y!==666?K(V,b):(V.state=null,Y===B?K(V,-3):m):b},i.deflateSetDictionary=function(V,Y){var de,q,re,X,le,pe,ee,z,O=Y.length;if(!V||!V.state||(X=(de=V.state).wrap)===2||X===1&&de.status!==F||de.lookahead)return b;for(X===1&&(V.adler=c(V.adler,Y,O,0)),de.wrap=0,O>=de.w_size&&(X===0&&(se(de.head),de.strstart=0,de.block_start=0,de.insert=0),z=new o.Buf8(de.w_size),o.arraySet(z,Y,O-de.w_size,de.w_size,0),Y=z,O=de.w_size),le=V.avail_in,pe=V.next_in,ee=V.input,V.avail_in=O,V.next_in=0,V.input=Y,ue(de);de.lookahead>=C;){for(q=de.strstart,re=de.lookahead-(C-1);de.ins_h=(de.ins_h<<de.hash_shift^de.window[q+C-1])&de.hash_mask,de.prev[q&de.w_mask]=de.head[de.ins_h],de.head[de.ins_h]=q,q++,--re;);de.strstart=q,de.lookahead=C-1,ue(de)}return de.strstart+=de.lookahead,de.block_start=de.strstart,de.insert=de.lookahead,de.lookahead=0,de.match_length=de.prev_length=C-1,de.match_available=0,V.next_in=pe,V.input=ee,V.avail_in=le,de.wrap=X,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(s,o){var l,c,u,d,h,p,m,b,y,x,v,S,N,T,M,A,k,R,C,P,U,F,B,D,$;l=s.state,c=s.next_in,D=s.input,u=c+(s.avail_in-5),d=s.next_out,$=s.output,h=d-(o-s.avail_out),p=d+(s.avail_out-257),m=l.dmax,b=l.wsize,y=l.whave,x=l.wnext,v=l.window,S=l.hold,N=l.bits,T=l.lencode,M=l.distcode,A=(1<<l.lenbits)-1,k=(1<<l.distbits)-1;e:do{N<15&&(S+=D[c++]<<N,N+=8,S+=D[c++]<<N,N+=8),R=T[S&A];t:for(;;){if(S>>>=C=R>>>24,N-=C,(C=R>>>16&255)===0)$[d++]=65535&R;else{if(!(16&C)){if((64&C)==0){R=T[(65535&R)+(S&(1<<C)-1)];continue t}if(32&C){l.mode=12;break e}s.msg="invalid literal/length code",l.mode=30;break e}P=65535&R,(C&=15)&&(N<C&&(S+=D[c++]<<N,N+=8),P+=S&(1<<C)-1,S>>>=C,N-=C),N<15&&(S+=D[c++]<<N,N+=8,S+=D[c++]<<N,N+=8),R=M[S&k];n:for(;;){if(S>>>=C=R>>>24,N-=C,!(16&(C=R>>>16&255))){if((64&C)==0){R=M[(65535&R)+(S&(1<<C)-1)];continue n}s.msg="invalid distance code",l.mode=30;break e}if(U=65535&R,N<(C&=15)&&(S+=D[c++]<<N,(N+=8)<C&&(S+=D[c++]<<N,N+=8)),m<(U+=S&(1<<C)-1)){s.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=C,N-=C,(C=d-h)<U){if(y<(C=U-C)&&l.sane){s.msg="invalid distance too far back",l.mode=30;break e}if(B=v,(F=0)===x){if(F+=b-C,C<P){for(P-=C;$[d++]=v[F++],--C;);F=d-U,B=$}}else if(x<C){if(F+=b+x-C,(C-=x)<P){for(P-=C;$[d++]=v[F++],--C;);if(F=0,x<P){for(P-=C=x;$[d++]=v[F++],--C;);F=d-U,B=$}}}else if(F+=x-C,C<P){for(P-=C;$[d++]=v[F++],--C;);F=d-U,B=$}for(;2<P;)$[d++]=B[F++],$[d++]=B[F++],$[d++]=B[F++],P-=3;P&&($[d++]=B[F++],1<P&&($[d++]=B[F++]))}else{for(F=d-U;$[d++]=$[F++],$[d++]=$[F++],$[d++]=$[F++],2<(P-=3););P&&($[d++]=$[F++],1<P&&($[d++]=$[F++]))}break}}break}}while(c<u&&d<p);c-=P=N>>3,S&=(1<<(N-=P<<3))-1,s.next_in=c,s.next_out=d,s.avail_in=c<u?u-c+5:5-(c-u),s.avail_out=d<p?p-d+257:257-(d-p),l.hold=S,l.bits=N}},{}],49:[function(n,r,i){var s=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,h=2,p=0,m=-2,b=1,y=852,x=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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function N(F){var B;return F&&F.state?(B=F.state,F.total_in=F.total_out=B.total=0,F.msg="",B.wrap&&(F.adler=1&B.wrap),B.mode=b,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new s.Buf32(y),B.distcode=B.distdyn=new s.Buf32(x),B.sane=1,B.back=-1,p):m}function T(F){var B;return F&&F.state?((B=F.state).wsize=0,B.whave=0,B.wnext=0,N(F)):m}function M(F,B){var D,$;return F&&F.state?($=F.state,B<0?(D=0,B=-B):(D=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15<B)?m:($.window!==null&&$.wbits!==B&&($.window=null),$.wrap=D,$.wbits=B,T(F))):m}function A(F,B){var D,$;return F?($=new S,(F.state=$).window=null,(D=M(F,B))!==p&&(F.state=null),D):m}var k,R,C=!0;function P(F){if(C){var B;for(k=new s.Buf32(512),R=new s.Buf32(32),B=0;B<144;)F.lens[B++]=8;for(;B<256;)F.lens[B++]=9;for(;B<280;)F.lens[B++]=7;for(;B<288;)F.lens[B++]=8;for(u(d,F.lens,0,288,k,0,F.work,{bits:9}),B=0;B<32;)F.lens[B++]=5;u(h,F.lens,0,32,R,0,F.work,{bits:5}),C=!1}F.lencode=k,F.lenbits=9,F.distcode=R,F.distbits=5}function U(F,B,D,$){var G,I=F.state;return I.window===null&&(I.wsize=1<<I.wbits,I.wnext=0,I.whave=0,I.window=new s.Buf8(I.wsize)),$>=I.wsize?(s.arraySet(I.window,B,D-I.wsize,I.wsize,0),I.wnext=0,I.whave=I.wsize):($<(G=I.wsize-I.wnext)&&(G=$),s.arraySet(I.window,B,D-$,G,I.wnext),($-=G)?(s.arraySet(I.window,B,D-$,$,0),I.wnext=$,I.whave=I.wsize):(I.wnext+=G,I.wnext===I.wsize&&(I.wnext=0),I.whave<I.wsize&&(I.whave+=G))),0}i.inflateReset=T,i.inflateReset2=M,i.inflateResetKeep=N,i.inflateInit=function(F){return A(F,15)},i.inflateInit2=A,i.inflate=function(F,B){var D,$,G,I,K,Q,se,H,W,J,ne,xe,ue,fe,De,oe,Ne,Fe,ce,Ve,V,Y,de,q,re=0,X=new s.Buf8(4),le=[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;(D=F.state).mode===12&&(D.mode=13),K=F.next_out,G=F.output,se=F.avail_out,I=F.next_in,$=F.input,Q=F.avail_in,H=D.hold,W=D.bits,J=Q,ne=se,Y=p;e:for(;;)switch(D.mode){case b:if(D.wrap===0){D.mode=13;break}for(;W<16;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if(2&D.wrap&&H===35615){X[D.check=0]=255&H,X[1]=H>>>8&255,D.check=l(D.check,X,2,0),W=H=0,D.mode=2;break}if(D.flags=0,D.head&&(D.head.done=!1),!(1&D.wrap)||(((255&H)<<8)+(H>>8))%31){F.msg="incorrect header check",D.mode=30;break}if((15&H)!=8){F.msg="unknown compression method",D.mode=30;break}if(W-=4,V=8+(15&(H>>>=4)),D.wbits===0)D.wbits=V;else if(V>D.wbits){F.msg="invalid window size",D.mode=30;break}D.dmax=1<<V,F.adler=D.check=1,D.mode=512&H?10:12,W=H=0;break;case 2:for(;W<16;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if(D.flags=H,(255&D.flags)!=8){F.msg="unknown compression method",D.mode=30;break}if(57344&D.flags){F.msg="unknown header flags set",D.mode=30;break}D.head&&(D.head.text=H>>8&1),512&D.flags&&(X[0]=255&H,X[1]=H>>>8&255,D.check=l(D.check,X,2,0)),W=H=0,D.mode=3;case 3:for(;W<32;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}D.head&&(D.head.time=H),512&D.flags&&(X[0]=255&H,X[1]=H>>>8&255,X[2]=H>>>16&255,X[3]=H>>>24&255,D.check=l(D.check,X,4,0)),W=H=0,D.mode=4;case 4:for(;W<16;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}D.head&&(D.head.xflags=255&H,D.head.os=H>>8),512&D.flags&&(X[0]=255&H,X[1]=H>>>8&255,D.check=l(D.check,X,2,0)),W=H=0,D.mode=5;case 5:if(1024&D.flags){for(;W<16;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}D.length=H,D.head&&(D.head.extra_len=H),512&D.flags&&(X[0]=255&H,X[1]=H>>>8&255,D.check=l(D.check,X,2,0)),W=H=0}else D.head&&(D.head.extra=null);D.mode=6;case 6:if(1024&D.flags&&(Q<(xe=D.length)&&(xe=Q),xe&&(D.head&&(V=D.head.extra_len-D.length,D.head.extra||(D.head.extra=new Array(D.head.extra_len)),s.arraySet(D.head.extra,$,I,xe,V)),512&D.flags&&(D.check=l(D.check,$,xe,I)),Q-=xe,I+=xe,D.length-=xe),D.length))break e;D.length=0,D.mode=7;case 7:if(2048&D.flags){if(Q===0)break e;for(xe=0;V=$[I+xe++],D.head&&V&&D.length<65536&&(D.head.name+=String.fromCharCode(V)),V&&xe<Q;);if(512&D.flags&&(D.check=l(D.check,$,xe,I)),Q-=xe,I+=xe,V)break e}else D.head&&(D.head.name=null);D.length=0,D.mode=8;case 8:if(4096&D.flags){if(Q===0)break e;for(xe=0;V=$[I+xe++],D.head&&V&&D.length<65536&&(D.head.comment+=String.fromCharCode(V)),V&&xe<Q;);if(512&D.flags&&(D.check=l(D.check,$,xe,I)),Q-=xe,I+=xe,V)break e}else D.head&&(D.head.comment=null);D.mode=9;case 9:if(512&D.flags){for(;W<16;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if(H!==(65535&D.check)){F.msg="header crc mismatch",D.mode=30;break}W=H=0}D.head&&(D.head.hcrc=D.flags>>9&1,D.head.done=!0),F.adler=D.check=0,D.mode=12;break;case 10:for(;W<32;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}F.adler=D.check=v(H),W=H=0,D.mode=11;case 11:if(D.havedict===0)return F.next_out=K,F.avail_out=se,F.next_in=I,F.avail_in=Q,D.hold=H,D.bits=W,2;F.adler=D.check=1,D.mode=12;case 12:if(B===5||B===6)break e;case 13:if(D.last){H>>>=7&W,W-=7&W,D.mode=27;break}for(;W<3;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}switch(D.last=1&H,W-=1,3&(H>>>=1)){case 0:D.mode=14;break;case 1:if(P(D),D.mode=20,B!==6)break;H>>>=2,W-=2;break e;case 2:D.mode=17;break;case 3:F.msg="invalid block type",D.mode=30}H>>>=2,W-=2;break;case 14:for(H>>>=7&W,W-=7&W;W<32;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if((65535&H)!=(H>>>16^65535)){F.msg="invalid stored block lengths",D.mode=30;break}if(D.length=65535&H,W=H=0,D.mode=15,B===6)break e;case 15:D.mode=16;case 16:if(xe=D.length){if(Q<xe&&(xe=Q),se<xe&&(xe=se),xe===0)break e;s.arraySet(G,$,I,xe,K),Q-=xe,I+=xe,se-=xe,K+=xe,D.length-=xe;break}D.mode=12;break;case 17:for(;W<14;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if(D.nlen=257+(31&H),H>>>=5,W-=5,D.ndist=1+(31&H),H>>>=5,W-=5,D.ncode=4+(15&H),H>>>=4,W-=4,286<D.nlen||30<D.ndist){F.msg="too many length or distance symbols",D.mode=30;break}D.have=0,D.mode=18;case 18:for(;D.have<D.ncode;){for(;W<3;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}D.lens[le[D.have++]]=7&H,H>>>=3,W-=3}for(;D.have<19;)D.lens[le[D.have++]]=0;if(D.lencode=D.lendyn,D.lenbits=7,de={bits:D.lenbits},Y=u(0,D.lens,0,19,D.lencode,0,D.work,de),D.lenbits=de.bits,Y){F.msg="invalid code lengths set",D.mode=30;break}D.have=0,D.mode=19;case 19:for(;D.have<D.nlen+D.ndist;){for(;oe=(re=D.lencode[H&(1<<D.lenbits)-1])>>>16&255,Ne=65535&re,!((De=re>>>24)<=W);){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if(Ne<16)H>>>=De,W-=De,D.lens[D.have++]=Ne;else{if(Ne===16){for(q=De+2;W<q;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if(H>>>=De,W-=De,D.have===0){F.msg="invalid bit length repeat",D.mode=30;break}V=D.lens[D.have-1],xe=3+(3&H),H>>>=2,W-=2}else if(Ne===17){for(q=De+3;W<q;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}W-=De,V=0,xe=3+(7&(H>>>=De)),H>>>=3,W-=3}else{for(q=De+7;W<q;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}W-=De,V=0,xe=11+(127&(H>>>=De)),H>>>=7,W-=7}if(D.have+xe>D.nlen+D.ndist){F.msg="invalid bit length repeat",D.mode=30;break}for(;xe--;)D.lens[D.have++]=V}}if(D.mode===30)break;if(D.lens[256]===0){F.msg="invalid code -- missing end-of-block",D.mode=30;break}if(D.lenbits=9,de={bits:D.lenbits},Y=u(d,D.lens,0,D.nlen,D.lencode,0,D.work,de),D.lenbits=de.bits,Y){F.msg="invalid literal/lengths set",D.mode=30;break}if(D.distbits=6,D.distcode=D.distdyn,de={bits:D.distbits},Y=u(h,D.lens,D.nlen,D.ndist,D.distcode,0,D.work,de),D.distbits=de.bits,Y){F.msg="invalid distances set",D.mode=30;break}if(D.mode=20,B===6)break e;case 20:D.mode=21;case 21:if(6<=Q&&258<=se){F.next_out=K,F.avail_out=se,F.next_in=I,F.avail_in=Q,D.hold=H,D.bits=W,c(F,ne),K=F.next_out,G=F.output,se=F.avail_out,I=F.next_in,$=F.input,Q=F.avail_in,H=D.hold,W=D.bits,D.mode===12&&(D.back=-1);break}for(D.back=0;oe=(re=D.lencode[H&(1<<D.lenbits)-1])>>>16&255,Ne=65535&re,!((De=re>>>24)<=W);){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if(oe&&(240&oe)==0){for(Fe=De,ce=oe,Ve=Ne;oe=(re=D.lencode[Ve+((H&(1<<Fe+ce)-1)>>Fe)])>>>16&255,Ne=65535&re,!(Fe+(De=re>>>24)<=W);){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}H>>>=Fe,W-=Fe,D.back+=Fe}if(H>>>=De,W-=De,D.back+=De,D.length=Ne,oe===0){D.mode=26;break}if(32&oe){D.back=-1,D.mode=12;break}if(64&oe){F.msg="invalid literal/length code",D.mode=30;break}D.extra=15&oe,D.mode=22;case 22:if(D.extra){for(q=D.extra;W<q;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}D.length+=H&(1<<D.extra)-1,H>>>=D.extra,W-=D.extra,D.back+=D.extra}D.was=D.length,D.mode=23;case 23:for(;oe=(re=D.distcode[H&(1<<D.distbits)-1])>>>16&255,Ne=65535&re,!((De=re>>>24)<=W);){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if((240&oe)==0){for(Fe=De,ce=oe,Ve=Ne;oe=(re=D.distcode[Ve+((H&(1<<Fe+ce)-1)>>Fe)])>>>16&255,Ne=65535&re,!(Fe+(De=re>>>24)<=W);){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}H>>>=Fe,W-=Fe,D.back+=Fe}if(H>>>=De,W-=De,D.back+=De,64&oe){F.msg="invalid distance code",D.mode=30;break}D.offset=Ne,D.extra=15&oe,D.mode=24;case 24:if(D.extra){for(q=D.extra;W<q;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}D.offset+=H&(1<<D.extra)-1,H>>>=D.extra,W-=D.extra,D.back+=D.extra}if(D.offset>D.dmax){F.msg="invalid distance too far back",D.mode=30;break}D.mode=25;case 25:if(se===0)break e;if(xe=ne-se,D.offset>xe){if((xe=D.offset-xe)>D.whave&&D.sane){F.msg="invalid distance too far back",D.mode=30;break}ue=xe>D.wnext?(xe-=D.wnext,D.wsize-xe):D.wnext-xe,xe>D.length&&(xe=D.length),fe=D.window}else fe=G,ue=K-D.offset,xe=D.length;for(se<xe&&(xe=se),se-=xe,D.length-=xe;G[K++]=fe[ue++],--xe;);D.length===0&&(D.mode=21);break;case 26:if(se===0)break e;G[K++]=D.length,se--,D.mode=21;break;case 27:if(D.wrap){for(;W<32;){if(Q===0)break e;Q--,H|=$[I++]<<W,W+=8}if(ne-=se,F.total_out+=ne,D.total+=ne,ne&&(F.adler=D.check=D.flags?l(D.check,G,ne,K-ne):o(D.check,G,ne,K-ne)),ne=se,(D.flags?H:v(H))!==D.check){F.msg="incorrect data check",D.mode=30;break}W=H=0}D.mode=28;case 28:if(D.wrap&&D.flags){for(;W<32;){if(Q===0)break e;Q--,H+=$[I++]<<W,W+=8}if(H!==(4294967295&D.total)){F.msg="incorrect length check",D.mode=30;break}W=H=0}D.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=K,F.avail_out=se,F.next_in=I,F.avail_in=Q,D.hold=H,D.bits=W,(D.wsize||ne!==F.avail_out&&D.mode<30&&(D.mode<27||B!==4))&&U(F,F.output,F.next_out,ne-F.avail_out)?(D.mode=31,-4):(J-=F.avail_in,ne-=F.avail_out,F.total_in+=J,F.total_out+=ne,D.total+=ne,D.wrap&&ne&&(F.adler=D.check=D.flags?l(D.check,G,ne,F.next_out-ne):o(D.check,G,ne,F.next_out-ne)),F.data_type=D.bits+(D.last?64:0)+(D.mode===12?128:0)+(D.mode===20||D.mode===15?256:0),(J==0&&ne===0||B===4)&&Y===p&&(Y=-5),Y)},i.inflateEnd=function(F){if(!F||!F.state)return m;var B=F.state;return B.window&&(B.window=null),F.state=null,p},i.inflateGetHeader=function(F,B){var D;return F&&F.state?(2&(D=F.state).wrap)==0?m:((D.head=B).done=!1,p):m},i.inflateSetDictionary=function(F,B){var D,$=B.length;return F&&F.state?(D=F.state).wrap!==0&&D.mode!==11?m:D.mode===11&&o(1,B,$,0)!==D.check?-3:U(F,B,$,$)?(D.mode=31,-4):(D.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 s=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,h,p,m,b,y,x,v){var S,N,T,M,A,k,R,C,P,U=v.bits,F=0,B=0,D=0,$=0,G=0,I=0,K=0,Q=0,se=0,H=0,W=null,J=0,ne=new s.Buf16(16),xe=new s.Buf16(16),ue=null,fe=0;for(F=0;F<=15;F++)ne[F]=0;for(B=0;B<m;B++)ne[h[p+B]]++;for(G=U,$=15;1<=$&&ne[$]===0;$--);if($<G&&(G=$),$===0)return b[y++]=20971520,b[y++]=20971520,v.bits=1,0;for(D=1;D<$&&ne[D]===0;D++);for(G<D&&(G=D),F=Q=1;F<=15;F++)if(Q<<=1,(Q-=ne[F])<0)return-1;if(0<Q&&(d===0||$!==1))return-1;for(xe[1]=0,F=1;F<15;F++)xe[F+1]=xe[F]+ne[F];for(B=0;B<m;B++)h[p+B]!==0&&(x[xe[h[p+B]]++]=B);if(k=d===0?(W=ue=x,19):d===1?(W=o,J-=257,ue=l,fe-=257,256):(W=c,ue=u,-1),F=D,A=y,K=B=H=0,T=-1,M=(se=1<<(I=G))-1,d===1&&852<se||d===2&&592<se)return 1;for(;;){for(R=F-K,P=x[B]<k?(C=0,x[B]):x[B]>k?(C=ue[fe+x[B]],W[J+x[B]]):(C=96,0),S=1<<F-K,D=N=1<<I;b[A+(H>>K)+(N-=S)]=R<<24|C<<16|P|0,N!==0;);for(S=1<<F-1;H&S;)S>>=1;if(S!==0?(H&=S-1,H+=S):H=0,B++,--ne[F]==0){if(F===$)break;F=h[p+x[B]]}if(G<F&&(H&M)!==T){for(K===0&&(K=G),A+=D,Q=1<<(I=F-K);I+K<$&&!((Q-=ne[I+K])<=0);)I++,Q<<=1;if(se+=1<<I,d===1&&852<se||d===2&&592<se)return 1;b[T=H&M]=G<<24|I<<16|A-y|0}}return H!==0&&(b[A+H]=F-K<<24|64<<16|0),v.bits=G,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),o=0,l=1;function c(re){for(var X=re.length;0<=--X;)re[X]=0}var u=0,d=29,h=256,p=h+1+d,m=30,b=19,y=2*p+1,x=15,v=16,S=7,N=256,T=16,M=17,A=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],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],P=[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 B=new Array(512);c(B);var D=new Array(256);c(D);var $=new Array(d);c($);var G,I,K,Q=new Array(m);function se(re,X,le,pe,ee){this.static_tree=re,this.extra_bits=X,this.extra_base=le,this.elems=pe,this.max_length=ee,this.has_stree=re&&re.length}function H(re,X){this.dyn_tree=re,this.max_code=0,this.stat_desc=X}function W(re){return re<256?B[re]:B[256+(re>>>7)]}function J(re,X){re.pending_buf[re.pending++]=255&X,re.pending_buf[re.pending++]=X>>>8&255}function ne(re,X,le){re.bi_valid>v-le?(re.bi_buf|=X<<re.bi_valid&65535,J(re,re.bi_buf),re.bi_buf=X>>v-re.bi_valid,re.bi_valid+=le-v):(re.bi_buf|=X<<re.bi_valid&65535,re.bi_valid+=le)}function xe(re,X,le){ne(re,le[2*X],le[2*X+1])}function ue(re,X){for(var le=0;le|=1&re,re>>>=1,le<<=1,0<--X;);return le>>>1}function fe(re,X,le){var pe,ee,z=new Array(x+1),O=0;for(pe=1;pe<=x;pe++)z[pe]=O=O+le[pe-1]<<1;for(ee=0;ee<=X;ee++){var Z=re[2*ee+1];Z!==0&&(re[2*ee]=ue(z[Z]++,Z))}}function De(re){var X;for(X=0;X<p;X++)re.dyn_ltree[2*X]=0;for(X=0;X<m;X++)re.dyn_dtree[2*X]=0;for(X=0;X<b;X++)re.bl_tree[2*X]=0;re.dyn_ltree[2*N]=1,re.opt_len=re.static_len=0,re.last_lit=re.matches=0}function oe(re){8<re.bi_valid?J(re,re.bi_buf):0<re.bi_valid&&(re.pending_buf[re.pending++]=re.bi_buf),re.bi_buf=0,re.bi_valid=0}function Ne(re,X,le,pe){var ee=2*X,z=2*le;return re[ee]<re[z]||re[ee]===re[z]&&pe[X]<=pe[le]}function Fe(re,X,le){for(var pe=re.heap[le],ee=le<<1;ee<=re.heap_len&&(ee<re.heap_len&&Ne(X,re.heap[ee+1],re.heap[ee],re.depth)&&ee++,!Ne(X,pe,re.heap[ee],re.depth));)re.heap[le]=re.heap[ee],le=ee,ee<<=1;re.heap[le]=pe}function ce(re,X,le){var pe,ee,z,O,Z=0;if(re.last_lit!==0)for(;pe=re.pending_buf[re.d_buf+2*Z]<<8|re.pending_buf[re.d_buf+2*Z+1],ee=re.pending_buf[re.l_buf+Z],Z++,pe===0?xe(re,ee,X):(xe(re,(z=D[ee])+h+1,X),(O=k[z])!==0&&ne(re,ee-=$[z],O),xe(re,z=W(--pe),le),(O=R[z])!==0&&ne(re,pe-=Q[z],O)),Z<re.last_lit;);xe(re,N,X)}function Ve(re,X){var le,pe,ee,z=X.dyn_tree,O=X.stat_desc.static_tree,Z=X.stat_desc.has_stree,me=X.stat_desc.elems,Te=-1;for(re.heap_len=0,re.heap_max=y,le=0;le<me;le++)z[2*le]!==0?(re.heap[++re.heap_len]=Te=le,re.depth[le]=0):z[2*le+1]=0;for(;re.heap_len<2;)z[2*(ee=re.heap[++re.heap_len]=Te<2?++Te:0)]=1,re.depth[ee]=0,re.opt_len--,Z&&(re.static_len-=O[2*ee+1]);for(X.max_code=Te,le=re.heap_len>>1;1<=le;le--)Fe(re,z,le);for(ee=me;le=re.heap[1],re.heap[1]=re.heap[re.heap_len--],Fe(re,z,1),pe=re.heap[1],re.heap[--re.heap_max]=le,re.heap[--re.heap_max]=pe,z[2*ee]=z[2*le]+z[2*pe],re.depth[ee]=(re.depth[le]>=re.depth[pe]?re.depth[le]:re.depth[pe])+1,z[2*le+1]=z[2*pe+1]=ee,re.heap[1]=ee++,Fe(re,z,1),2<=re.heap_len;);re.heap[--re.heap_max]=re.heap[1],(function(ke,Ee){var Se,$e,Qe,Ue,be,ve,ze=Ee.dyn_tree,Ce=Ee.max_code,Ge=Ee.stat_desc.static_tree,_e=Ee.stat_desc.has_stree,Je=Ee.stat_desc.extra_bits,Ae=Ee.stat_desc.extra_base,Ke=Ee.stat_desc.max_length,je=0;for(Ue=0;Ue<=x;Ue++)ke.bl_count[Ue]=0;for(ze[2*ke.heap[ke.heap_max]+1]=0,Se=ke.heap_max+1;Se<y;Se++)Ke<(Ue=ze[2*ze[2*($e=ke.heap[Se])+1]+1]+1)&&(Ue=Ke,je++),ze[2*$e+1]=Ue,Ce<$e||(ke.bl_count[Ue]++,be=0,Ae<=$e&&(be=Je[$e-Ae]),ve=ze[2*$e],ke.opt_len+=ve*(Ue+be),_e&&(ke.static_len+=ve*(Ge[2*$e+1]+be)));if(je!==0){do{for(Ue=Ke-1;ke.bl_count[Ue]===0;)Ue--;ke.bl_count[Ue]--,ke.bl_count[Ue+1]+=2,ke.bl_count[Ke]--,je-=2}while(0<je);for(Ue=Ke;Ue!==0;Ue--)for($e=ke.bl_count[Ue];$e!==0;)Ce<(Qe=ke.heap[--Se])||(ze[2*Qe+1]!==Ue&&(ke.opt_len+=(Ue-ze[2*Qe+1])*ze[2*Qe],ze[2*Qe+1]=Ue),$e--)}})(re,X),fe(z,Te,re.bl_count)}function V(re,X,le){var pe,ee,z=-1,O=X[1],Z=0,me=7,Te=4;for(O===0&&(me=138,Te=3),X[2*(le+1)+1]=65535,pe=0;pe<=le;pe++)ee=O,O=X[2*(pe+1)+1],++Z<me&&ee===O||(Z<Te?re.bl_tree[2*ee]+=Z:ee!==0?(ee!==z&&re.bl_tree[2*ee]++,re.bl_tree[2*T]++):Z<=10?re.bl_tree[2*M]++:re.bl_tree[2*A]++,z=ee,Te=(Z=0)===O?(me=138,3):ee===O?(me=6,3):(me=7,4))}function Y(re,X,le){var pe,ee,z=-1,O=X[1],Z=0,me=7,Te=4;for(O===0&&(me=138,Te=3),pe=0;pe<=le;pe++)if(ee=O,O=X[2*(pe+1)+1],!(++Z<me&&ee===O)){if(Z<Te)for(;xe(re,ee,re.bl_tree),--Z!=0;);else ee!==0?(ee!==z&&(xe(re,ee,re.bl_tree),Z--),xe(re,T,re.bl_tree),ne(re,Z-3,2)):Z<=10?(xe(re,M,re.bl_tree),ne(re,Z-3,3)):(xe(re,A,re.bl_tree),ne(re,Z-11,7));z=ee,Te=(Z=0)===O?(me=138,3):ee===O?(me=6,3):(me=7,4)}}c(Q);var de=!1;function q(re,X,le,pe){ne(re,(u<<1)+(pe?1:0),3),(function(ee,z,O,Z){oe(ee),J(ee,O),J(ee,~O),s.arraySet(ee.pending_buf,ee.window,z,O,ee.pending),ee.pending+=O})(re,X,le)}i._tr_init=function(re){de||((function(){var X,le,pe,ee,z,O=new Array(x+1);for(ee=pe=0;ee<d-1;ee++)for($[ee]=pe,X=0;X<1<<k[ee];X++)D[pe++]=ee;for(D[pe-1]=ee,ee=z=0;ee<16;ee++)for(Q[ee]=z,X=0;X<1<<R[ee];X++)B[z++]=ee;for(z>>=7;ee<m;ee++)for(Q[ee]=z<<7,X=0;X<1<<R[ee]-7;X++)B[256+z++]=ee;for(le=0;le<=x;le++)O[le]=0;for(X=0;X<=143;)U[2*X+1]=8,X++,O[8]++;for(;X<=255;)U[2*X+1]=9,X++,O[9]++;for(;X<=279;)U[2*X+1]=7,X++,O[7]++;for(;X<=287;)U[2*X+1]=8,X++,O[8]++;for(fe(U,p+1,O),X=0;X<m;X++)F[2*X+1]=5,F[2*X]=ue(X,5);G=new se(U,k,h+1,p,x),I=new se(F,R,0,m,x),K=new se(new Array(0),C,0,b,S)})(),de=!0),re.l_desc=new H(re.dyn_ltree,G),re.d_desc=new H(re.dyn_dtree,I),re.bl_desc=new H(re.bl_tree,K),re.bi_buf=0,re.bi_valid=0,De(re)},i._tr_stored_block=q,i._tr_flush_block=function(re,X,le,pe){var ee,z,O=0;0<re.level?(re.strm.data_type===2&&(re.strm.data_type=(function(Z){var me,Te=4093624447;for(me=0;me<=31;me++,Te>>>=1)if(1&Te&&Z.dyn_ltree[2*me]!==0)return o;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return l;for(me=32;me<h;me++)if(Z.dyn_ltree[2*me]!==0)return l;return o})(re)),Ve(re,re.l_desc),Ve(re,re.d_desc),O=(function(Z){var me;for(V(Z,Z.dyn_ltree,Z.l_desc.max_code),V(Z,Z.dyn_dtree,Z.d_desc.max_code),Ve(Z,Z.bl_desc),me=b-1;3<=me&&Z.bl_tree[2*P[me]+1]===0;me--);return Z.opt_len+=3*(me+1)+5+5+4,me})(re),ee=re.opt_len+3+7>>>3,(z=re.static_len+3+7>>>3)<=ee&&(ee=z)):ee=z=le+5,le+4<=ee&&X!==-1?q(re,X,le,pe):re.strategy===4||z===ee?(ne(re,2+(pe?1:0),3),ce(re,U,F)):(ne(re,4+(pe?1:0),3),(function(Z,me,Te,ke){var Ee;for(ne(Z,me-257,5),ne(Z,Te-1,5),ne(Z,ke-4,4),Ee=0;Ee<ke;Ee++)ne(Z,Z.bl_tree[2*P[Ee]+1],3);Y(Z,Z.dyn_ltree,me-1),Y(Z,Z.dyn_dtree,Te-1)})(re,re.l_desc.max_code+1,re.d_desc.max_code+1,O+1),ce(re,re.dyn_ltree,re.dyn_dtree)),De(re),pe&&oe(re)},i._tr_tally=function(re,X,le){return re.pending_buf[re.d_buf+2*re.last_lit]=X>>>8&255,re.pending_buf[re.d_buf+2*re.last_lit+1]=255&X,re.pending_buf[re.l_buf+re.last_lit]=255&le,re.last_lit++,X===0?re.dyn_ltree[2*le]++:(re.matches++,X--,re.dyn_ltree[2*(D[le]+h+1)]++,re.dyn_dtree[2*W(X)]++),re.last_lit===re.lit_bufsize-1},i._tr_align=function(re){ne(re,2,3),xe(re,N,U),(function(X){X.bi_valid===16?(J(X,X.bi_buf),X.bi_buf=0,X.bi_valid=0):8<=X.bi_valid&&(X.pending_buf[X.pending++]=255&X.bi_buf,X.bi_buf>>=8,X.bi_valid-=8)})(re)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(s){(function(o,l){if(!o.setImmediate){var c,u,d,h,p=1,m={},b=!1,y=o.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(o);x=x&&x.setTimeout?x:o,c={}.toString.call(o.process)==="[object process]"?function(T){process.nextTick(function(){S(T)})}:(function(){if(o.postMessage&&!o.importScripts){var T=!0,M=o.onmessage;return o.onmessage=function(){T=!1},o.postMessage("","*"),o.onmessage=M,T}})()?(h="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",N,!1):o.attachEvent("onmessage",N),function(T){o.postMessage(h+T,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(T){S(T.data)},function(T){d.port2.postMessage(T)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(T){var M=y.createElement("script");M.onreadystatechange=function(){S(T),M.onreadystatechange=null,u.removeChild(M),M=null},u.appendChild(M)}):function(T){setTimeout(S,0,T)},x.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var M=new Array(arguments.length-1),A=0;A<M.length;A++)M[A]=arguments[A+1];var k={callback:T,args:M};return m[p]=k,c(p),p++},x.clearImmediate=v}function v(T){delete m[T]}function S(T){if(b)setTimeout(S,0,T);else{var M=m[T];if(M){b=!0;try{(function(A){var k=A.callback,R=A.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)}})(M)}finally{v(T),b=!1}}}}function N(T){T.source===o&&typeof T.data=="string"&&T.data.indexOf(h)===0&&S(+T.data.slice(h.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Hw<"u"?Hw:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ZT)),ZT.exports}var Gye=Vye();const qye=gl(Gye);function Wye(t){const e=new Gi;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 b8=Wye;async function x8(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const s=r[i],o=[],l=[],c=s.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const h=c[d];o.push(parseFloat(h.getAttribute("x")||"0"),parseFloat(h.getAttribute("y")||"0"),parseFloat(h.getAttribute("z")||"0"))}const u=s.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const h=u[d];l.push(parseInt(h.getAttribute("v1")||"0"),parseInt(h.getAttribute("v2")||"0"),parseInt(h.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}function y8(t){const e=Array.from(t.attributes).find(r=>{const i=r.name.toLowerCase();return i==="plate_id"||i==="plater_id"||i==="plateid"||i==="platerid"||i.endsWith(":plate_id")||i.endsWith(":plater_id")});if(!e?.value)return null;const n=Number.parseInt(e.value,10);return Number.isFinite(n)?n:null}async function Kye(t){let e;try{e=await qye.loadAsync(t)}catch{throw new Error("Unsupported file format")}const n=new Map,r=[],i=new Map,s=new Map,o=new DOMParser;async function l(N){const T=N.startsWith("/")?N.slice(1):N,M=e.files[T];if(!M)return null;const A=await M.async("string");return o.parseFromString(A,"application/xml")}const c=new Map,u=new Map,d=new Map,h=new Map,p=e.files["Metadata/model_settings.config"];if(p)try{const N=await p.async("string"),T=o.parseFromString(N,"application/xml"),M=T.getElementsByTagName("object");for(let k=0;k<M.length;k++){const R=M[k],C=R.getAttribute("id");if(!C)continue;const P=Array.from(R.children).filter(D=>D.tagName==="metadata"&&D.getAttribute("key")==="extruder");if(P.length>0){const D=P[0].getAttribute("value");D&&c.set(C,Math.max(0,parseInt(D,10)-1))}const F=Array.from(R.children).find(D=>D.tagName==="metadata"&&D.getAttribute("key")==="name")?.getAttribute("value");F&&d.set(C,F);const B=R.getElementsByTagName("part");for(let D=0;D<B.length;D++){const $=B[D],G=$.getAttribute("id");if(!G)continue;const I=Array.from($.children).filter(K=>K.tagName==="metadata"&&K.getAttribute("key")==="extruder");if(I.length>0){const K=I[0].getAttribute("value");K&&u.set(`${C}:${G}`,Math.max(0,parseInt(K,10)-1))}}}const A=T.getElementsByTagName("plate");for(let k=0;k<A.length;k++){const R=A[k];let C=null;const P=R.getElementsByTagName("metadata");let U=0,F=0;for(let D=0;D<P.length;D++){const $=P[D],G=$.getAttribute("key");if(G==="plater_id"||G==="plate_id"){const I=$.getAttribute("value");if(I){const K=Number.parseInt(I,10);Number.isFinite(K)&&(C=K)}}else if(G==="pos_x"){const I=$.getAttribute("value"),K=I?Number.parseFloat(I):Number.NaN;Number.isFinite(K)&&(U=K)}else if(G==="pos_y"){const I=$.getAttribute("value"),K=I?Number.parseFloat(I):Number.NaN;Number.isFinite(K)&&(F=K)}}if(C==null)continue;(U!==0||F!==0)&&s.set(C,{offsetX:U,offsetY:F});const B=R.getElementsByTagName("model_instance");for(let D=0;D<B.length;D++){const G=B[D].getElementsByTagName("metadata");for(let I=0;I<G.length;I++){const K=G[I];if(K.getAttribute("key")==="object_id"){const Q=K.getAttribute("value");Q&&h.set(Q,C)}}}}}catch{}const m=new Map,b=Object.keys(e.files).filter(N=>N.startsWith("Metadata/plate_")&&N.endsWith(".json"));for(const N of b){const T=N.match(/^Metadata\/plate_(\d+)\.json$/);if(!T)continue;const M=Number.parseInt(T[1],10);if(Number.isFinite(M))try{const A=await e.files[N].async("string"),k=JSON.parse(A),R=k.bbox_objects??[];for(const C of R)C?.name&&m.set(C.name,M);if(Array.isArray(k.bbox_all)&&k.bbox_all.length>=4){const[C,P,U,F]=k.bbox_all;[C,P,U,F].every(B=>Number.isFinite(B))&&i.set(M,{minX:C,minY:P,maxX:U,maxY:F})}}catch{}}const y=Object.keys(e.files).find(N=>N==="3D/3dmodel.model"||N.endsWith("/3dmodel.model"));if(!y){const N=Object.keys(e.files).find(T=>T.endsWith(".model"));if(N){const T=await l(N);if(T){const M=await x8(T,0);M.length>0&&n.set("1",{id:"1",meshes:M,defaultExtruder:0})}}return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s}}const x=await l(y);if(!x)return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s};const v=x.getElementsByTagName("object");for(let N=0;N<v.length;N++){const T=v[N],M=T.getAttribute("id");if(!M)continue;const A=y8(T)??h.get(M)??null;let k=c.get(M)??-1;if(k<0){const U=T.getAttribute("p:extruder")||T.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";k=Math.max(0,parseInt(U,10)-1)}const R=[],C=T.getElementsByTagName("mesh");for(let U=0;U<C.length;U++){const F=C[U],B=[],D=[],$=F.getElementsByTagName("vertex");for(let I=0;I<$.length;I++){const K=$[I];B.push(parseFloat(K.getAttribute("x")||"0"),parseFloat(K.getAttribute("y")||"0"),parseFloat(K.getAttribute("z")||"0"))}const G=F.getElementsByTagName("triangle");for(let I=0;I<G.length;I++){const K=G[I];D.push(parseInt(K.getAttribute("v1")||"0"),parseInt(K.getAttribute("v2")||"0"),parseInt(K.getAttribute("v3")||"0"))}B.length>0&&D.length>0&&R.push({vertices:B,triangles:D,extruder:k})}const P=T.getElementsByTagName("component");for(let U=0;U<P.length;U++){const F=P[U],B=F.getAttribute("p:path")||F.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),D=F.getAttribute("objectid");if(B){const $=await l(B);if($){const G=D?`${M}:${D}`:null,I=G?u.get(G)??k:k,K=await x8($,I),Q=F.getAttribute("transform"),se=b8(Q);for(const H of K)if(Q){const W=[];for(let J=0;J<H.vertices.length;J+=3){const ne=new pt(H.vertices[J],H.vertices[J+1],H.vertices[J+2]);ne.applyMatrix4(se),W.push(ne.x,ne.y,ne.z)}R.push({vertices:W,triangles:H.triangles,extruder:H.extruder})}else R.push(H)}}}R.length>0&&n.set(M,{id:M,meshes:R,defaultExtruder:k,plateId:A})}const S=x.getElementsByTagName("build");if(S.length>0){const N=S[0].getElementsByTagName("item");for(let T=0;T<N.length;T++){const M=N[T],A=M.getAttribute("objectid");if(!A)continue;const k=b8(M.getAttribute("transform")),R=y8(M),C=n.get(A)?.plateId??null,P=d.get(A),U=P?m.get(P)??null:null;r.push({objectId:A,transform:k,plateId:R??C??U??null})}}return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s}}function v8(t){const e=new dl,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 _s(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function Xye(t){t.traverse(e=>{if(e instanceof hl)if(e.geometry.dispose(),Array.isArray(e.material))for(const n of e.material)n.dispose();else e.material.dispose()})}function Yye(t,e,n){const{objects:r,buildItems:i}=t,s=new Sg,o=h=>{const m=n?.[h]||"#00ae42",b=new Fn(m);return new DK({color:b,shininess:30,flatShading:!1})},l=new Map,c=i.some(h=>h.plateId!=null),u=e==null||!c?i:i.filter(h=>h.plateId===e),d=u.length>0?u:i;if(d.length>0)for(const h of d){const p=r.get(h.objectId);if(p)for(const m of p.meshes){const b=h.extruder??m.extruder,y=[];for(let v=0;v<m.vertices.length;v+=3){const S=new pt(m.vertices[v],m.vertices[v+1],m.vertices[v+2]);S.applyMatrix4(h.transform),y.push(S.x,S.y,S.z)}const x=v8({vertices:y,triangles:m.triangles});l.has(b)||l.set(b,[]),l.get(b).push(x)}}else for(const h of r.values())for(const p of h.meshes){const m=p.extruder,b=v8(p);l.has(m)||l.set(m,[]),l.get(m).push(b)}for(const[h,p]of l){if(p.length===0)continue;const m=p.length===1?p[0]:Hye(p,!1);if(m){const b=o(h),y=new hl(m,b);s.add(y)}if(p.length>1)for(const b of p)b.dispose()}return s}function HK({url:t,fileType:e,buildVolume:n={x:256,y:256,z:256},filamentColors:r,selectedPlateId:i=null,className:s=""}){const{t:o}=Yt(),l=_.useRef(null),c=_.useRef(null),u=_.useRef(null),d=_.useRef(null),h=_.useRef(null),p=_.useRef(null),m=_.useRef(null),b=_.useRef(null),[y,x]=_.useState(!0),[v,S]=_.useState(null),[N,T]=_.useState(null),[M,A]=_.useState(null);_.useEffect(()=>{if(!l.current)return;const C=l.current,P=C.clientWidth,U=C.clientHeight,F=new _pe;F.background=new Fn(1710618),u.current=F;const B=new Jo(45,P/U,.1,1e4);B.position.set(150,150,150),d.current=B;const D=new Eye({antialias:!0});D.setSize(P,U),D.setPixelRatio(window.devicePixelRatio),C.appendChild(D.domElement),c.current=D;const $=new Aye(B,D.domElement);$.enableDamping=!0,$.dampingFactor=.05,h.current=$;const G=new Fpe(16777215,.6);F.add(G);const I=new BB(16777215,.8);I.position.set(100,100,100),F.add(I);const K=new BB(16777215,.4);K.position.set(-100,50,-100),F.add(K);const Q=Math.max(n.x,n.y),se=Math.ceil(Q/16),H=new zpe(Q,se,4473924,3355443);F.add(H),b.current=H;const W=new bO(n.x,n.y),J=new mO({color:44610,transparent:!0,opacity:.15,side:lc}),ne=new hl(W,J);ne.rotation.x=-Math.PI/2,ne.position.y=-.5,F.add(ne),m.current=ne;let xe;const ue=()=>{xe=requestAnimationFrame(ue),$.update(),D.render(F,B)};ue(),x(!0),S(null),T(null),A(null);const fe=(e||t.split("?")[0].split(".").pop()||"").toLowerCase(),De={},oe=Ph();oe&&(De.Authorization=`Bearer ${oe}`),fe==="stl"?fetch(t,{headers:De}).then(ce=>{if(!ce.ok)throw new Error(o("modelViewer.errors.failedToLoad"));return ce.arrayBuffer()}).then(ce=>{const V=new $ye().parse(ce);V.computeVertexNormals(),V.rotateX(-Math.PI/2),A(V)}).catch(ce=>{S(ce.message),x(!1)}):fe==="3mf"?fetch(t,{headers:De}).then(ce=>{if(!ce.ok)throw new Error(o("modelViewer.errors.failedToLoad"));return ce.arrayBuffer()}).then(Kye).then(ce=>{if(ce.objects.size===0)throw new Error(o("modelViewer.errors.noMeshes"));T(ce)}).catch(ce=>{S(ce.message),x(!1)}):(S(o("modelViewer.errors.unsupportedFormat")),x(!1));const Ne=()=>{if(!C)return;const ce=C.clientWidth,Ve=C.clientHeight;ce===0||Ve===0||(B.aspect=ce/Ve,B.updateProjectionMatrix(),D.setSize(ce,Ve))};window.addEventListener("resize",Ne);const Fe=new ResizeObserver(()=>{Ne()});return Fe.observe(C),()=>{window.removeEventListener("resize",Ne),Fe.disconnect(),cancelAnimationFrame(xe),$.dispose(),D.dispose(),C.removeChild(D.domElement),p.current=null,m.current=null,b.current=null}},[t,n,e,o]),_.useEffect(()=>{if(!u.current||!d.current||!h.current||!N&&!M)return;p.current&&(u.current.remove(p.current),Xye(p.current));const C=!!M,P=C?(()=>{const fe=r?.[0]||"#00ae42",De=new DK({color:new Fn(fe),shininess:30}),oe=new hl(M,De),Ne=new Sg;return Ne.add(oe),Ne})():Yye(N,i??null,r);p.current=P,u.current.add(P);const U=new yh().setFromObject(P),F=U.getCenter(new pt);P.position.y=-U.min.y;const B=!C&&i!=null&&N.buildItems.length>0?N.plateBounds.get(i):void 0,D=!C&&i!=null?N.plateOffsets.get(i):void 0,$=C||N.buildItems.length===0||i!=null&&!B&&!D,G=$?-F.x:0,I=$?-F.z:0;let K=0,Q=0;if(!C&&i!=null&&N.buildItems.length>0&&B){const fe=new yh().setFromObject(P);K=fe.min.x-B.minX,Q=fe.min.z-B.minY}const se=n.x/2,H=n.y/2;!C&&i!=null&&N.buildItems.length>0&&B?(P.position.x=G-K,P.position.z=I-Q):!C&&i!=null&&D?(P.position.x=G+(se-D.offsetX),P.position.z=I+(H-D.offsetY)):$?(P.position.x=G+se,P.position.z=I+H):(P.position.x=G,P.position.z=I),m.current&&(m.current.position.x=se,m.current.position.z=H),b.current&&(b.current.position.x=se,b.current.position.z=H);const W=new yh().setFromObject(P),J=W.getCenter(new pt),ne=W.getSize(new pt),ue=Math.max(ne.x,ne.y,ne.z)*1.8;d.current.position.set(J.x+ue*.7,J.y+ue*.5,J.z+ue*.7),h.current.target.copy(J),h.current.update(),x(!1)},[N,M,i,r,n]);const k=()=>{d.current&&h.current&&(d.current.position.set(150,150,150),h.current.target.set(0,50,0),h.current.update())},R=C=>{d.current&&d.current.position.multiplyScalar(C)};return a.jsxs("div",{className:`relative ${s}`,children:[a.jsx("div",{ref:l,className:"w-full h-full min-h-[400px]"}),y&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}),v&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx("p",{className:"text-red-400",children:v})}),!y&&!v&&a.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>R(.8),children:a.jsx(eO,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>R(1.25),children:a.jsx(tO,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:k,children:a.jsx(Vu,{className:"w-4 h-4"})})]})]})}const zk="159",zp={ROTATE:0,DOLLY:1,PAN:2},Up={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Qye=0,w8=1,Zye=2,$K=1,Jye=2,pu=3,Rh=0,Gs=1,vu=2,vh=0,Lg=1,_8=2,S8=3,N8=4,eve=5,Ff=100,tve=101,nve=102,k8=103,M8=104,rve=200,ive=201,ave=202,sve=203,T3=204,A3=205,ove=206,lve=207,cve=208,uve=209,dve=210,hve=211,fve=212,mve=213,pve=214,gve=0,bve=1,xve=2,pS=3,yve=4,vve=5,wve=6,_ve=7,vO=0,Sve=1,Nve=2,wh=0,kve=1,Mve=2,Eve=3,Tve=4,Ave=5,VK=300,nb=301,rb=302,C3=303,P3=304,Uk=306,j3=1e3,jl=1001,D3=1002,Fa=1003,E8=1004,JT=1005,el=1006,Cve=1007,sy=1008,_h=1009,Pve=1010,jve=1011,wO=1012,GK=1013,ch=1014,Eu=1015,oy=1016,qK=1017,WK=1018,Jf=1020,Dve=1021,tl=1023,Rve=1024,Ove=1025,em=1026,ib=1027,Lve=1028,KK=1029,Fve=1030,XK=1031,YK=1033,eA=33776,tA=33777,nA=33778,rA=33779,T8=35840,A8=35841,C8=35842,P8=35843,QK=36196,j8=37492,D8=37496,R8=37808,O8=37809,L8=37810,F8=37811,I8=37812,z8=37813,U8=37814,B8=37815,H8=37816,$8=37817,V8=37818,G8=37819,q8=37820,W8=37821,iA=36492,K8=36494,X8=36495,Ive=36283,Y8=36284,Q8=36285,Z8=36286,ZK=3e3,tm=3001,zve=3200,Uve=3201,JK=0,Bve=1,nl="",Ia="srgb",Ku="srgb-linear",_O="display-p3",Bk="display-p3-linear",gS="linear",Kr="srgb",bS="rec709",xS="p3",Bp=7680,J8=519,Hve=512,$ve=513,Vve=514,eX=515,Gve=516,qve=517,Wve=518,Kve=519,R3=35044,e6="300 es",O3=1035,fc=2e3,ly=2001;class zm{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}}const Xa=["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 t6=1234567;const k0=Math.PI/180,cy=180/Math.PI;function Ou(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Xa[t&255]+Xa[t>>8&255]+Xa[t>>16&255]+Xa[t>>24&255]+"-"+Xa[e&255]+Xa[e>>8&255]+"-"+Xa[e>>16&15|64]+Xa[e>>24&255]+"-"+Xa[n&63|128]+Xa[n>>8&255]+"-"+Xa[n>>16&255]+Xa[n>>24&255]+Xa[r&255]+Xa[r>>8&255]+Xa[r>>16&255]+Xa[r>>24&255]).toLowerCase()}function za(t,e,n){return Math.max(e,Math.min(n,t))}function SO(t,e){return(t%e+e)%e}function Xve(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function Yve(t,e,n){return t!==e?(n-t)/(e-t):0}function M0(t,e,n){return(1-n)*t+n*e}function Qve(t,e,n,r){return M0(t,e,1-Math.exp(-n*r))}function Zve(t,e=1){return e-Math.abs(SO(t,e*2)-e)}function Jve(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function ewe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function twe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function nwe(t,e){return t+Math.random()*(e-t)}function rwe(t){return t*(.5-Math.random())}function iwe(t){t!==void 0&&(t6=t);let e=t6+=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 awe(t){return t*k0}function swe(t){return t*cy}function L3(t){return(t&t-1)===0&&t!==0}function owe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function yS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function lwe(t,e,n,r,i){const s=Math.cos,o=Math.sin,l=s(n/2),c=o(n/2),u=s((e+r)/2),d=o((e+r)/2),h=s((e-r)/2),p=o((e-r)/2),m=s((r-e)/2),b=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*h,c*p,l*u);break;case"YZY":t.set(c*p,l*d,c*h,l*u);break;case"ZXZ":t.set(c*h,c*p,l*d,l*u);break;case"XZX":t.set(l*d,c*b,c*m,l*u);break;case"YXY":t.set(c*m,l*d,c*b,l*u);break;case"ZYZ":t.set(c*b,c*m,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function cc(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 Ar(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 tX={DEG2RAD:k0,RAD2DEG:cy,generateUUID:Ou,clamp:za,euclideanModulo:SO,mapLinear:Xve,inverseLerp:Yve,lerp:M0,damp:Qve,pingpong:Zve,smoothstep:Jve,smootherstep:ewe,randInt:twe,randFloat:nwe,randFloatSpread:rwe,seededRandom:iwe,degToRad:awe,radToDeg:swe,isPowerOfTwo:L3,ceilPowerOfTwo:owe,floorPowerOfTwo:yS,setQuaternionFromProperEuler:lwe,normalize:Ar,denormalize:cc};class _n{constructor(e=0,n=0){_n.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(za(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Un{constructor(e,n,r,i,s,o,l,c,u){Un.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u)}set(e,n,r,i,s,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=s,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],h=r[7],p=r[2],m=r[5],b=r[8],y=i[0],x=i[3],v=i[6],S=i[1],N=i[4],T=i[7],M=i[2],A=i[5],k=i[8];return s[0]=o*y+l*S+c*M,s[3]=o*x+l*N+c*A,s[6]=o*v+l*T+c*k,s[1]=u*y+d*S+h*M,s[4]=u*x+d*N+h*A,s[7]=u*v+d*T+h*k,s[2]=p*y+m*S+b*M,s[5]=p*x+m*N+b*A,s[8]=p*v+m*T+b*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],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*s*d+r*l*c+i*s*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=d*o-l*u,p=l*c-d*s,m=u*s-o*c,b=n*h+r*p+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=h*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=p*y,e[4]=(d*n-i*c)*y,e[5]=(i*s-l*n)*y,e[6]=m*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,o,l){const c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(aA.makeScale(e,n)),this}rotate(e){return this.premultiply(aA.makeRotation(-e)),this}translate(e,n){return this.premultiply(aA.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 aA=new Un;function nX(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function vS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function cwe(){const t=vS("canvas");return t.style.display="block",t}const n6={};function E0(t){t in n6||(n6[t]=!0,console.warn(t))}const r6=new Un().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),i6=new Un().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),x_={[Ku]:{transfer:gS,primaries:bS,toReference:t=>t,fromReference:t=>t},[Ia]:{transfer:Kr,primaries:bS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[Bk]:{transfer:gS,primaries:xS,toReference:t=>t.applyMatrix3(i6),fromReference:t=>t.applyMatrix3(r6)},[_O]:{transfer:Kr,primaries:xS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(i6),fromReference:t=>t.applyMatrix3(r6).convertLinearToSRGB()}},uwe=new Set([Ku,Bk]),Cr={enabled:!0,_workingColorSpace:Ku,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(!uwe.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=x_[e].toReference,i=x_[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 x_[t].primaries},getTransfer:function(t){return t===nl?gS:x_[t].transfer}};function Fg(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function sA(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Hp;class rX{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Hp===void 0&&(Hp=vS("canvas")),Hp.width=e.width,Hp.height=e.height;const r=Hp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Hp}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=vS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Fg(s[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Fg(n[r]/255)*255):n[r]=Fg(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 dwe=0;class iX{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:dwe++}),this.uuid=Ou(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?s.push(oA(i[o].image)):s.push(oA(i[o]))}else s=oA(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function oA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?rX.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 hwe=0;class qs extends zm{constructor(e=qs.DEFAULT_IMAGE,n=qs.DEFAULT_MAPPING,r=jl,i=jl,s=el,o=sy,l=tl,c=_h,u=qs.DEFAULT_ANISOTROPY,d=nl){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:hwe++}),this.uuid=Ou(),this.name="",this.source=new iX(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new _n(0,0),this.repeat=new _n(1,1),this.center=new _n(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Un,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(E0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===tm?Ia:nl),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!==VK)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case j3:e.x=e.x-Math.floor(e.x);break;case jl:e.x=e.x<0?0:1;break;case D3: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 j3:e.y=e.y-Math.floor(e.y);break;case jl:e.y=e.y<0?0:1;break;case D3: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 E0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ia?tm:ZK}set encoding(e){E0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===tm?Ia:nl}}qs.DEFAULT_IMAGE=null;qs.DEFAULT_MAPPING=VK;qs.DEFAULT_ANISOTROPY=1;class jr{constructor(e=0,n=0,r=0,i=1){jr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const c=e.elements,u=c[0],d=c[4],h=c[8],p=c[1],m=c[5],b=c[9],y=c[2],x=c[6],v=c[10];if(Math.abs(d-p)<.01&&Math.abs(h-y)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+p)<.1&&Math.abs(h+y)<.1&&Math.abs(b+x)<.1&&Math.abs(u+m+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,T=(m+1)/2,M=(v+1)/2,A=(d+p)/4,k=(h+y)/4,R=(b+x)/4;return N>T&&N>M?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=A/r,s=k/r):T>M?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=A/i,s=R/i):M<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),r=k/s,i=R/s),this.set(r,i,s,n),this}let S=Math.sqrt((x-b)*(x-b)+(h-y)*(h-y)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(h-y)/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 fwe extends zm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new jr(0,0,e,n),this.scissorTest=!1,this.viewport=new jr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(E0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===tm?Ia:nl),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:el,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new qs(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 iX(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 _m extends fwe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class aX extends qs{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=Fa,this.minFilter=Fa,this.wrapR=jl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class mwe extends qs{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=Fa,this.minFilter=Fa,this.wrapR=jl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Sm{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],h=r[i+3];const p=s[o+0],m=s[o+1],b=s[o+2],y=s[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h;return}if(l===1){e[n+0]=p,e[n+1]=m,e[n+2]=b,e[n+3]=y;return}if(h!==y||c!==p||u!==m||d!==b){let x=1-l;const v=c*p+u*m+d*b+h*y,S=v>=0?1:-1,N=1-v*v;if(N>Number.EPSILON){const M=Math.sqrt(N),A=Math.atan2(M,v*S);x=Math.sin(x*A)/M,l=Math.sin(l*A)/M}const T=l*S;if(c=c*x+p*T,u=u*x+m*T,d=d*x+b*T,h=h*x+y*T,x===1-l){const M=1/Math.sqrt(c*c+u*u+d*d+h*h);c*=M,u*=M,d*=M,h*=M}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],h=s[o],p=s[o+1],m=s[o+2],b=s[o+3];return e[n]=l*b+d*h+c*m-u*p,e[n+1]=c*b+d*p+u*h-l*m,e[n+2]=u*b+d*m+l*p-c*h,e[n+3]=d*b-l*h-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,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),h=l(s/2),p=c(r/2),m=c(i/2),b=c(s/2);switch(o){case"XYZ":this._x=p*d*h+u*m*b,this._y=u*m*h-p*d*b,this._z=u*d*b+p*m*h,this._w=u*d*h-p*m*b;break;case"YXZ":this._x=p*d*h+u*m*b,this._y=u*m*h-p*d*b,this._z=u*d*b-p*m*h,this._w=u*d*h+p*m*b;break;case"ZXY":this._x=p*d*h-u*m*b,this._y=u*m*h+p*d*b,this._z=u*d*b+p*m*h,this._w=u*d*h-p*m*b;break;case"ZYX":this._x=p*d*h-u*m*b,this._y=u*m*h+p*d*b,this._z=u*d*b-p*m*h,this._w=u*d*h+p*m*b;break;case"YZX":this._x=p*d*h+u*m*b,this._y=u*m*h+p*d*b,this._z=u*d*b-p*m*h,this._w=u*d*h-p*m*b;break;case"XZY":this._x=p*d*h-u*m*b,this._y=u*m*h-p*d*b,this._z=u*d*b+p*m*h,this._w=u*d*h+p*m*b;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],h=n[10],p=r+l+h;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(s-u)*m,this._z=(o-i)*m}else if(r>l&&r>h){const m=2*Math.sqrt(1+r-l-h);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(s+u)/m}else if(l>h){const m=2*Math.sqrt(1+l-r-h);this._w=(s-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+h-r-l);this._w=(o-i)/m,this._x=(s+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(za(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-s*c,this._y=i*d+o*c+s*l-r*u,this._z=s*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-s*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const c=1-l*l;if(c<=Number.EPSILON){const 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*s+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),h=Math.sin((1-n)*d)/u,p=Math.sin(n*d)/u;return this._w=o*h+this._w*p,this._x=r*h+this._x*p,this._y=i*h+this._y*p,this._z=s*h+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(),s=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(s),r*Math.cos(s),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ye{constructor(e=0,n=0,r=0){Ye.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(a6.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(a6.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-s*i),h=2*(s*r-o*n);return this.x=n+c*u+o*h-l*d,this.y=r+c*d+l*u-s*h,this.z=i+c*h+s*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-s*l,this.y=s*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return lA.copy(this).projectOnVector(e),this.sub(lA)}reflect(e){return this.sub(lA.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(za(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 lA=new Ye,a6=new Sm;class ol{constructor(e=new Ye(1/0,1/0,1/0),n=new Ye(-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(Tl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Tl.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=Tl.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=s.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Tl):Tl.fromBufferAttribute(s,o),Tl.applyMatrix4(e.matrixWorld),this.expandByPoint(Tl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),y_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),y_.copy(r.boundingBox)),y_.applyMatrix4(e.matrixWorld),this.union(y_)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Tl),Tl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Gx),v_.subVectors(this.max,Gx),$p.subVectors(e.a,Gx),Vp.subVectors(e.b,Gx),Gp.subVectors(e.c,Gx),Id.subVectors(Vp,$p),zd.subVectors(Gp,Vp),_f.subVectors($p,Gp);let n=[0,-Id.z,Id.y,0,-zd.z,zd.y,0,-_f.z,_f.y,Id.z,0,-Id.x,zd.z,0,-zd.x,_f.z,0,-_f.x,-Id.y,Id.x,0,-zd.y,zd.x,0,-_f.y,_f.x,0];return!cA(n,$p,Vp,Gp,v_)||(n=[1,0,0,0,1,0,0,0,1],!cA(n,$p,Vp,Gp,v_))?!1:(w_.crossVectors(Id,zd),n=[w_.x,w_.y,w_.z],cA(n,$p,Vp,Gp,v_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Tl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Tl).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:(au[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),au[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),au[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),au[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),au[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),au[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),au[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),au[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(au),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 au=[new Ye,new Ye,new Ye,new Ye,new Ye,new Ye,new Ye,new Ye],Tl=new Ye,y_=new ol,$p=new Ye,Vp=new Ye,Gp=new Ye,Id=new Ye,zd=new Ye,_f=new Ye,Gx=new Ye,v_=new Ye,w_=new Ye,Sf=new Ye;function cA(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){Sf.fromArray(t,s);const l=i.x*Math.abs(Sf.x)+i.y*Math.abs(Sf.y)+i.z*Math.abs(Sf.z),c=e.dot(Sf),u=n.dot(Sf),d=r.dot(Sf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const pwe=new ol,qx=new Ye,uA=new Ye;class gc{constructor(e=new Ye,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):pwe.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;qx.subVectors(e,this.center);const n=qx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(qx,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):(uA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(qx.copy(e.center).add(uA)),this.expandByPoint(qx.copy(e.center).sub(uA))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const su=new Ye,dA=new Ye,__=new Ye,Ud=new Ye,hA=new Ye,S_=new Ye,fA=new Ye;class NO{constructor(e=new Ye,n=new Ye(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,su)),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=su.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(su.copy(this.origin).addScaledVector(this.direction,n),su.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){dA.copy(e).add(n).multiplyScalar(.5),__.copy(n).sub(e).normalize(),Ud.copy(this.origin).sub(dA);const s=e.distanceTo(n)*.5,o=-this.direction.dot(__),l=Ud.dot(this.direction),c=-Ud.dot(__),u=Ud.lengthSq(),d=Math.abs(1-o*o);let h,p,m,b;if(d>0)if(h=o*c-l,p=o*l-c,b=s*d,h>=0)if(p>=-b)if(p<=b){const y=1/d;h*=y,p*=y,m=h*(h+o*p+2*l)+p*(o*h+p+2*c)+u}else p=s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p=-s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p<=-b?(h=Math.max(0,-(-o*s+l)),p=h>0?-s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u):p<=b?(h=0,p=Math.min(Math.max(-s,-c),s),m=p*(p+2*c)+u):(h=Math.max(0,-(o*s+l)),p=h>0?s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u);else p=o>0?-s:s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(dA).addScaledVector(__,p),m}intersectSphere(e,n){su.subVectors(e.center,this.origin);const r=su.dot(this.direction),i=su.dot(su)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,h=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?(s=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(s=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),h>=0?(l=(e.min.z-p.z)*h,c=(e.max.z-p.z)*h):(l=(e.max.z-p.z)*h,c=(e.min.z-p.z)*h),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,su)!==null}intersectTriangle(e,n,r,i,s){hA.subVectors(n,e),S_.subVectors(r,e),fA.crossVectors(hA,S_);let o=this.direction.dot(fA),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Ud.subVectors(this.origin,e);const c=l*this.direction.dot(S_.crossVectors(Ud,S_));if(c<0)return null;const u=l*this.direction.dot(hA.cross(Ud));if(u<0||c+u>o)return null;const d=-l*Ud.dot(fA);return d<0?null:this.at(d/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Vr{constructor(e,n,r,i,s,o,l,c,u,d,h,p,m,b,y,x){Vr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u,d,h,p,m,b,y,x)}set(e,n,r,i,s,o,l,c,u,d,h,p,m,b,y,x){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=s,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=h,v[14]=p,v[3]=m,v[7]=b,v[11]=y,v[15]=x,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 Vr().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/qp.setFromMatrixColumn(e,0).length(),s=1/qp.setFromMatrixColumn(e,1).length(),o=1/qp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const p=o*d,m=o*h,b=l*d,y=l*h;n[0]=c*d,n[4]=-c*h,n[8]=u,n[1]=m+b*u,n[5]=p-y*u,n[9]=-l*c,n[2]=y-p*u,n[6]=b+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*h,b=u*d,y=u*h;n[0]=p+y*l,n[4]=b*l-m,n[8]=o*u,n[1]=o*h,n[5]=o*d,n[9]=-l,n[2]=m*l-b,n[6]=y+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*h,b=u*d,y=u*h;n[0]=p-y*l,n[4]=-o*h,n[8]=b+m*l,n[1]=m+b*l,n[5]=o*d,n[9]=y-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*h,b=l*d,y=l*h;n[0]=c*d,n[4]=b*u-m,n[8]=p*u+y,n[1]=c*h,n[5]=y*u+p,n[9]=m*u-b,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=y-p*h,n[8]=b*h+m,n[1]=h,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*h+b,n[10]=p-y*h}else if(e.order==="XZY"){const p=o*c,m=o*u,b=l*c,y=l*u;n[0]=c*d,n[4]=-h,n[8]=u*d,n[1]=p*h+y,n[5]=o*d,n[9]=m*h-b,n[2]=b*h-m,n[6]=l*d,n[10]=y*h+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(gwe,e,bwe)}lookAt(e,n,r){const i=this.elements;return ho.subVectors(e,n),ho.lengthSq()===0&&(ho.z=1),ho.normalize(),Bd.crossVectors(r,ho),Bd.lengthSq()===0&&(Math.abs(r.z)===1?ho.x+=1e-4:ho.z+=1e-4,ho.normalize(),Bd.crossVectors(r,ho)),Bd.normalize(),N_.crossVectors(ho,Bd),i[0]=Bd.x,i[4]=N_.x,i[8]=ho.x,i[1]=Bd.y,i[5]=N_.y,i[9]=ho.y,i[2]=Bd.z,i[6]=N_.z,i[10]=ho.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],h=r[5],p=r[9],m=r[13],b=r[2],y=r[6],x=r[10],v=r[14],S=r[3],N=r[7],T=r[11],M=r[15],A=i[0],k=i[4],R=i[8],C=i[12],P=i[1],U=i[5],F=i[9],B=i[13],D=i[2],$=i[6],G=i[10],I=i[14],K=i[3],Q=i[7],se=i[11],H=i[15];return s[0]=o*A+l*P+c*D+u*K,s[4]=o*k+l*U+c*$+u*Q,s[8]=o*R+l*F+c*G+u*se,s[12]=o*C+l*B+c*I+u*H,s[1]=d*A+h*P+p*D+m*K,s[5]=d*k+h*U+p*$+m*Q,s[9]=d*R+h*F+p*G+m*se,s[13]=d*C+h*B+p*I+m*H,s[2]=b*A+y*P+x*D+v*K,s[6]=b*k+y*U+x*$+v*Q,s[10]=b*R+y*F+x*G+v*se,s[14]=b*C+y*B+x*I+v*H,s[3]=S*A+N*P+T*D+M*K,s[7]=S*k+N*U+T*$+M*Q,s[11]=S*R+N*F+T*G+M*se,s[15]=S*C+N*B+T*I+M*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],h=e[6],p=e[10],m=e[14],b=e[3],y=e[7],x=e[11],v=e[15];return b*(+s*c*h-i*u*h-s*l*p+r*u*p+i*l*m-r*c*m)+y*(+n*c*m-n*u*p+s*o*p-i*o*m+i*u*d-s*c*d)+x*(+n*u*h-n*l*m-s*o*h+r*o*m+s*l*d-r*u*d)+v*(-i*l*d-n*c*h+n*l*p+i*o*h-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],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=e[9],p=e[10],m=e[11],b=e[12],y=e[13],x=e[14],v=e[15],S=h*x*u-y*p*u+y*c*m-l*x*m-h*c*v+l*p*v,N=b*p*u-d*x*u-b*c*m+o*x*m+d*c*v-o*p*v,T=d*y*u-b*h*u+b*l*m-o*y*m-d*l*v+o*h*v,M=b*h*c-d*y*c-b*l*p+o*y*p+d*l*x-o*h*x,A=n*S+r*N+i*T+s*M;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/A;return e[0]=S*k,e[1]=(y*p*s-h*x*s-y*i*m+r*x*m+h*i*v-r*p*v)*k,e[2]=(l*x*s-y*c*s+y*i*u-r*x*u-l*i*v+r*c*v)*k,e[3]=(h*c*s-l*p*s-h*i*u+r*p*u+l*i*m-r*c*m)*k,e[4]=N*k,e[5]=(d*x*s-b*p*s+b*i*m-n*x*m-d*i*v+n*p*v)*k,e[6]=(b*c*s-o*x*s-b*i*u+n*x*u+o*i*v-n*c*v)*k,e[7]=(o*p*s-d*c*s+d*i*u-n*p*u-o*i*m+n*c*m)*k,e[8]=T*k,e[9]=(b*h*s-d*y*s-b*r*m+n*y*m+d*r*v-n*h*v)*k,e[10]=(o*y*s-b*l*s+b*r*u-n*y*u-o*r*v+n*l*v)*k,e[11]=(d*l*s-o*h*s-d*r*u+n*h*u+o*r*m-n*l*m)*k,e[12]=M*k,e[13]=(d*y*i-b*h*i+b*r*p-n*y*p-d*r*x+n*h*x)*k,e[14]=(b*l*i-o*y*i-b*r*c+n*y*c+o*r*x-n*l*x)*k,e[15]=(o*h*i-d*l*i+d*r*c-n*h*c-o*r*p+n*l*p)*k,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,o=e.x,l=e.y,c=e.z,u=s*o,d=s*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,o=n._y,l=n._z,c=n._w,u=s+s,d=o+o,h=l+l,p=s*u,m=s*d,b=s*h,y=o*d,x=o*h,v=l*h,S=c*u,N=c*d,T=c*h,M=r.x,A=r.y,k=r.z;return i[0]=(1-(y+v))*M,i[1]=(m+T)*M,i[2]=(b-N)*M,i[3]=0,i[4]=(m-T)*A,i[5]=(1-(p+v))*A,i[6]=(x+S)*A,i[7]=0,i[8]=(b+N)*k,i[9]=(x-S)*k,i[10]=(1-(p+y))*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 s=qp.set(i[0],i[1],i[2]).length();const o=qp.set(i[4],i[5],i[6]).length(),l=qp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Al.copy(this);const u=1/s,d=1/o,h=1/l;return Al.elements[0]*=u,Al.elements[1]*=u,Al.elements[2]*=u,Al.elements[4]*=d,Al.elements[5]*=d,Al.elements[6]*=d,Al.elements[8]*=h,Al.elements[9]*=h,Al.elements[10]*=h,n.setFromRotationMatrix(Al),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=fc){const c=this.elements,u=2*s/(n-e),d=2*s/(r-i),h=(n+e)/(n-e),p=(r+i)/(r-i);let m,b;if(l===fc)m=-(o+s)/(o-s),b=-2*o*s/(o-s);else if(l===ly)m=-o/(o-s),b=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=h,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]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=fc){const c=this.elements,u=1/(n-e),d=1/(r-i),h=1/(o-s),p=(n+e)*u,m=(r+i)*d;let b,y;if(l===fc)b=(o+s)*h,y=-2*h;else if(l===ly)b=s*h,y=-1*h;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]=y,c[14]=-b,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 qp=new Ye,Al=new Vr,gwe=new Ye(0,0,0),bwe=new Ye(1,1,1),Bd=new Ye,N_=new Ye,ho=new Ye,s6=new Vr,o6=new Sm;class qy{constructor(e=0,n=0,r=0,i=qy.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],h=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(za(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-za(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(za(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-za(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(za(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-za(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return s6.makeRotationFromQuaternion(e),this.setFromRotationMatrix(s6,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return o6.setFromEuler(this),this.setFromQuaternion(o6,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}}qy.DEFAULT_ORDER="XYZ";class sX{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 xwe=0;const l6=new Ye,Wp=new Sm,ou=new Vr,k_=new Ye,Wx=new Ye,ywe=new Ye,vwe=new Sm,c6=new Ye(1,0,0),u6=new Ye(0,1,0),d6=new Ye(0,0,1),wwe={type:"added"},_we={type:"removed"};class Ss extends zm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:xwe++}),this.uuid=Ou(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ss.DEFAULT_UP.clone();const e=new Ye,n=new qy,r=new Sm,i=new Ye(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Vr},normalMatrix:{value:new Un}}),this.matrix=new Vr,this.matrixWorld=new Vr,this.matrixAutoUpdate=Ss.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ss.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new sX,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 Wp.setFromAxisAngle(e,n),this.quaternion.multiply(Wp),this}rotateOnWorldAxis(e,n){return Wp.setFromAxisAngle(e,n),this.quaternion.premultiply(Wp),this}rotateX(e){return this.rotateOnAxis(c6,e)}rotateY(e){return this.rotateOnAxis(u6,e)}rotateZ(e){return this.rotateOnAxis(d6,e)}translateOnAxis(e,n){return l6.copy(e).applyQuaternion(this.quaternion),this.position.add(l6.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(c6,e)}translateY(e){return this.translateOnAxis(u6,e)}translateZ(e){return this.translateOnAxis(d6,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ou.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?k_.copy(e):k_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Wx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ou.lookAt(Wx,k_,this.up):ou.lookAt(k_,Wx,this.up),this.quaternion.setFromRotationMatrix(ou),i&&(ou.extractRotation(i.matrixWorld),Wp.setFromRotationMatrix(ou),this.quaternion.premultiply(Wp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(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(wwe)):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(_we)),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),ou.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ou.multiply(e.parent.matrixWorld)),e.applyMatrix4(ou),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wx,e,ywe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Wx,vwe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const s=n[r];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++){const l=i[s];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const h=c[u];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(s(e.materials,this.material[c]));i.material=l}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(s(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),h=o(e.shapes),p=o(e.skeletons),m=o(e.animations),b=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),h.length>0&&(r.shapes=h),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),b.length>0&&(r.nodes=b)}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}}Ss.DEFAULT_UP=new Ye(0,1,0);Ss.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ss.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Cl=new Ye,lu=new Ye,mA=new Ye,cu=new Ye,Kp=new Ye,Xp=new Ye,h6=new Ye,pA=new Ye,gA=new Ye,bA=new Ye;let M_=!1;class Pl{constructor(e=new Ye,n=new Ye,r=new Ye){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Cl.subVectors(e,n),i.cross(Cl);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){Cl.subVectors(i,n),lu.subVectors(r,n),mA.subVectors(e,n);const o=Cl.dot(Cl),l=Cl.dot(lu),c=Cl.dot(mA),u=lu.dot(lu),d=lu.dot(mA),h=o*u-l*l;if(h===0)return s.set(-2,-1,-1);const p=1/h,m=(u*c-l*d)*p,b=(o*d-l*c)*p;return s.set(1-m-b,b,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,cu),cu.x>=0&&cu.y>=0&&cu.x+cu.y<=1}static getUV(e,n,r,i,s,o,l,c){return M_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),M_=!0),this.getInterpolation(e,n,r,i,s,o,l,c)}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,cu),c.setScalar(0),c.addScaledVector(s,cu.x),c.addScaledVector(o,cu.y),c.addScaledVector(l,cu.z),c}static isFrontFacing(e,n,r,i){return Cl.subVectors(r,n),lu.subVectors(e,n),Cl.cross(lu).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 Cl.subVectors(this.c,this.b),lu.subVectors(this.a,this.b),Cl.cross(lu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Pl.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Pl.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return M_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),M_=!0),Pl.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return Pl.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Pl.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Pl.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let o,l;Kp.subVectors(i,r),Xp.subVectors(s,r),pA.subVectors(e,r);const c=Kp.dot(pA),u=Xp.dot(pA);if(c<=0&&u<=0)return n.copy(r);gA.subVectors(e,i);const d=Kp.dot(gA),h=Xp.dot(gA);if(d>=0&&h<=d)return n.copy(i);const p=c*h-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Kp,o);bA.subVectors(e,s);const m=Kp.dot(bA),b=Xp.dot(bA);if(b>=0&&m<=b)return n.copy(s);const y=m*u-c*b;if(y<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Xp,l);const x=d*b-m*h;if(x<=0&&h-d>=0&&m-b>=0)return h6.subVectors(s,i),l=(h-d)/(h-d+(m-b)),n.copy(i).addScaledVector(h6,l);const v=1/(x+y+p);return o=y*v,l=p*v,n.copy(r).addScaledVector(Kp,o).addScaledVector(Xp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const oX={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},Hd={h:0,s:0,l:0},E_={h:0,s:0,l:0};function xA(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 dn=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=Ia){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Cr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Cr.workingColorSpace){return this.r=e,this.g=n,this.b=r,Cr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Cr.workingColorSpace){if(e=SO(e,1),n=za(n,0,1),r=za(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;this.r=xA(o,s,e+1/3),this.g=xA(o,s,e),this.b=xA(o,s,e-1/3)}return Cr.toWorkingColorSpace(this,i),this}setStyle(e,n=Ia){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Ia){const r=oX[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=Fg(e.r),this.g=Fg(e.g),this.b=Fg(e.b),this}copyLinearToSRGB(e){return this.r=sA(e.r),this.g=sA(e.g),this.b=sA(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ia){return Cr.fromWorkingColorSpace(Ya.copy(this),e),Math.round(za(Ya.r*255,0,255))*65536+Math.round(za(Ya.g*255,0,255))*256+Math.round(za(Ya.b*255,0,255))}getHexString(e=Ia){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Cr.workingColorSpace){Cr.fromWorkingColorSpace(Ya.copy(this),n);const r=Ya.r,i=Ya.g,s=Ya.b,o=Math.max(r,i,s),l=Math.min(r,i,s);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const h=o-l;switch(u=d<=.5?h/(o+l):h/(2-o-l),o){case r:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-r)/h+2;break;case s:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Cr.workingColorSpace){return Cr.fromWorkingColorSpace(Ya.copy(this),n),e.r=Ya.r,e.g=Ya.g,e.b=Ya.b,e}getStyle(e=Ia){Cr.fromWorkingColorSpace(Ya.copy(this),e);const n=Ya.r,r=Ya.g,i=Ya.b;return e!==Ia?`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(Hd),this.setHSL(Hd.h+e,Hd.s+n,Hd.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(Hd),e.getHSL(E_);const r=M0(Hd.h,E_.h,n),i=M0(Hd.s,E_.s,n),s=M0(Hd.l,E_.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Ya=new dn;dn.NAMES=oX;let Swe=0;class Pb extends zm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Swe++}),this.uuid=Ou(),this.name="",this.type="Material",this.blending=Lg,this.side=Rh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=T3,this.blendDst=A3,this.blendEquation=Ff,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new dn(0,0,0),this.blendAlpha=0,this.depthFunc=pS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=J8,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Bp,this.stencilZFail=Bp,this.stencilZPass=Bp,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!==Lg&&(r.blending=this.blending),this.side!==Rh&&(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!==T3&&(r.blendSrc=this.blendSrc),this.blendDst!==A3&&(r.blendDst=this.blendDst),this.blendEquation!==Ff&&(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!==pS&&(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!==J8&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Bp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Bp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Bp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const l in s){const c=s[l];delete c.metadata,o.push(c)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class lX extends Pb{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new dn(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=vO,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 Li=new Ye,T_=new _n;class No{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=R3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Eu,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)T_.fromBufferAttribute(this,n),T_.applyMatrix3(e),this.setXY(n,T_.x,T_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Li.fromBufferAttribute(this,n),Li.applyMatrix3(e),this.setXYZ(n,Li.x,Li.y,Li.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Li.fromBufferAttribute(this,n),Li.applyMatrix4(e),this.setXYZ(n,Li.x,Li.y,Li.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Li.fromBufferAttribute(this,n),Li.applyNormalMatrix(e),this.setXYZ(n,Li.x,Li.y,Li.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Li.fromBufferAttribute(this,n),Li.transformDirection(e),this.setXYZ(n,Li.x,Li.y,Li.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=cc(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Ar(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=cc(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ar(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=cc(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ar(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=cc(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ar(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=cc(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ar(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ar(n,this.array),r=Ar(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=Ar(n,this.array),r=Ar(r,this.array),i=Ar(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Ar(n,this.array),r=Ar(r,this.array),i=Ar(i,this.array),s=Ar(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==R3&&(e.usage=this.usage),e}}class cX extends No{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class uX extends No{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Ai extends No{constructor(e,n,r){super(new Float32Array(e),n,r)}}let Nwe=0;const Ho=new Vr,yA=new Ss,Yp=new Ye,fo=new ol,Kx=new ol,pa=new Ye;class ss extends zm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Nwe++}),this.uuid=Ou(),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(nX(e)?uX:cX)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new Un().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ho.makeRotationFromQuaternion(e),this.applyMatrix4(Ho),this}rotateX(e){return Ho.makeRotationX(e),this.applyMatrix4(Ho),this}rotateY(e){return Ho.makeRotationY(e),this.applyMatrix4(Ho),this}rotateZ(e){return Ho.makeRotationZ(e),this.applyMatrix4(Ho),this}translate(e,n,r){return Ho.makeTranslation(e,n,r),this.applyMatrix4(Ho),this}scale(e,n,r){return Ho.makeScale(e,n,r),this.applyMatrix4(Ho),this}lookAt(e){return yA.lookAt(e),yA.updateMatrix(),this.applyMatrix4(yA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Yp).negate(),this.translate(Yp.x,Yp.y,Yp.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const s=e[r];n.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Ai(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ol);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 Ye(-1/0,-1/0,-1/0),new Ye(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];fo.setFromBufferAttribute(s),this.morphTargetsRelative?(pa.addVectors(this.boundingBox.min,fo.min),this.boundingBox.expandByPoint(pa),pa.addVectors(this.boundingBox.max,fo.max),this.boundingBox.expandByPoint(pa)):(this.boundingBox.expandByPoint(fo.min),this.boundingBox.expandByPoint(fo.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 gc);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 Ye,1/0);return}if(e){const r=this.boundingSphere.center;if(fo.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];Kx.setFromBufferAttribute(l),this.morphTargetsRelative?(pa.addVectors(fo.min,Kx.min),fo.expandByPoint(pa),pa.addVectors(fo.max,Kx.max),fo.expandByPoint(pa)):(fo.expandByPoint(Kx.min),fo.expandByPoint(Kx.max))}fo.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)pa.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(pa));if(n)for(let s=0,o=n.length;s<o;s++){const l=n[s],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)pa.fromBufferAttribute(l,u),c&&(Yp.fromBufferAttribute(e,u),pa.add(Yp)),i=Math.max(i,r.distanceToSquared(pa))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,s=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new No(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let P=0;P<l;P++)u[P]=new Ye,d[P]=new Ye;const h=new Ye,p=new Ye,m=new Ye,b=new _n,y=new _n,x=new _n,v=new Ye,S=new Ye;function N(P,U,F){h.fromArray(i,P*3),p.fromArray(i,U*3),m.fromArray(i,F*3),b.fromArray(o,P*2),y.fromArray(o,U*2),x.fromArray(o,F*2),p.sub(h),m.sub(h),y.sub(b),x.sub(b);const B=1/(y.x*x.y-x.x*y.y);isFinite(B)&&(v.copy(p).multiplyScalar(x.y).addScaledVector(m,-y.y).multiplyScalar(B),S.copy(m).multiplyScalar(y.x).addScaledVector(p,-x.x).multiplyScalar(B),u[P].add(v),u[U].add(v),u[F].add(v),d[P].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 P=0,U=T.length;P<U;++P){const F=T[P],B=F.start,D=F.count;for(let $=B,G=B+D;$<G;$+=3)N(r[$+0],r[$+1],r[$+2])}const M=new Ye,A=new Ye,k=new Ye,R=new Ye;function C(P){k.fromArray(s,P*3),R.copy(k);const U=u[P];M.copy(U),M.sub(k.multiplyScalar(k.dot(U))).normalize(),A.crossVectors(R,U);const B=A.dot(d[P])<0?-1:1;c[P*4]=M.x,c[P*4+1]=M.y,c[P*4+2]=M.z,c[P*4+3]=B}for(let P=0,U=T.length;P<U;++P){const F=T[P],B=F.start,D=F.count;for(let $=B,G=B+D;$<G;$+=3)C(r[$+0]),C(r[$+1]),C(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 No(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 Ye,s=new Ye,o=new Ye,l=new Ye,c=new Ye,u=new Ye,d=new Ye,h=new Ye;if(e)for(let p=0,m=e.count;p<m;p+=3){const b=e.getX(p+0),y=e.getX(p+1),x=e.getX(p+2);i.fromBufferAttribute(n,b),s.fromBufferAttribute(n,y),o.fromBufferAttribute(n,x),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),s.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),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++)pa.fromBufferAttribute(e,n),pa.normalize(),e.setXYZ(n,pa.x,pa.y,pa.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,h=l.normalized,p=new u.constructor(c.length*d);let m=0,b=0;for(let y=0,x=c.length;y<x;y++){l.isInterleavedBufferAttribute?m=c[y]*l.data.stride+l.offset:m=c[y]*d;for(let v=0;v<d;v++)p[b++]=u[m++]}return new No(p,d,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ss,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const s=this.morphAttributes;for(const l in s){const c=[],u=s[l];for(let d=0,h=u.length;d<h;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 s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let h=0,p=u.length;h<p;h++){const m=u[h];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],h=s[u];for(let p=0,m=h.length;p<m;p++)d.push(h[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 h=o[u];this.addGroup(h.start,h.count,h.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 f6=new Vr,Nf=new NO,A_=new gc,m6=new Ye,Qp=new Ye,Zp=new Ye,Jp=new Ye,vA=new Ye,C_=new Ye,P_=new _n,j_=new _n,D_=new _n,p6=new Ye,g6=new Ye,b6=new Ye,R_=new Ye,O_=new Ye;class Il extends Ss{constructor(e=new ss,n=new lX){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(s&&l){C_.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],h=s[c];d!==0&&(vA.fromBufferAttribute(h,e),o?C_.addScaledVector(vA,d):C_.addScaledVector(vA.sub(n),d))}n.add(C_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),A_.copy(r.boundingSphere),A_.applyMatrix4(s),Nf.copy(e.ray).recast(e.near),!(A_.containsPoint(Nf.origin)===!1&&(Nf.intersectSphere(A_,m6)===null||Nf.origin.distanceToSquared(m6)>(e.far-e.near)**2))&&(f6.copy(s).invert(),Nf.copy(e.ray).applyMatrix4(f6),!(r.boundingBox!==null&&Nf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Nf)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,h=s.attributes.normal,p=s.groups,m=s.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,y=p.length;b<y;b++){const x=p[b],v=o[x.materialIndex],S=Math.max(x.start,m.start),N=Math.min(l.count,Math.min(x.start+x.count,m.start+m.count));for(let T=S,M=N;T<M;T+=3){const A=l.getX(T),k=l.getX(T+1),R=l.getX(T+2);i=L_(this,v,e,r,u,d,h,A,k,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let x=b,v=y;x<v;x+=3){const S=l.getX(x),N=l.getX(x+1),T=l.getX(x+2);i=L_(this,o,e,r,u,d,h,S,N,T),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,y=p.length;b<y;b++){const x=p[b],v=o[x.materialIndex],S=Math.max(x.start,m.start),N=Math.min(c.count,Math.min(x.start+x.count,m.start+m.count));for(let T=S,M=N;T<M;T+=3){const A=T,k=T+1,R=T+2;i=L_(this,v,e,r,u,d,h,A,k,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let x=b,v=y;x<v;x+=3){const S=x,N=x+1,T=x+2;i=L_(this,o,e,r,u,d,h,S,N,T),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}}function kwe(t,e,n,r,i,s,o,l){let c;if(e.side===Gs?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===Rh,l),c===null)return null;O_.copy(l),O_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(O_);return u<n.near||u>n.far?null:{distance:u,point:O_.clone(),object:t}}function L_(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,Qp),t.getVertexPosition(c,Zp),t.getVertexPosition(u,Jp);const d=kwe(t,e,n,r,Qp,Zp,Jp,R_);if(d){i&&(P_.fromBufferAttribute(i,l),j_.fromBufferAttribute(i,c),D_.fromBufferAttribute(i,u),d.uv=Pl.getInterpolation(R_,Qp,Zp,Jp,P_,j_,D_,new _n)),s&&(P_.fromBufferAttribute(s,l),j_.fromBufferAttribute(s,c),D_.fromBufferAttribute(s,u),d.uv1=Pl.getInterpolation(R_,Qp,Zp,Jp,P_,j_,D_,new _n),d.uv2=d.uv1),o&&(p6.fromBufferAttribute(o,l),g6.fromBufferAttribute(o,c),b6.fromBufferAttribute(o,u),d.normal=Pl.getInterpolation(R_,Qp,Zp,Jp,p6,g6,b6,new Ye),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const h={a:l,b:c,c:u,normal:new Ye,materialIndex:0};Pl.getNormal(Qp,Zp,Jp,h.normal),d.face=h}return d}class Wy extends ss{constructor(e=1,n=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const l=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],u=[],d=[],h=[];let p=0,m=0;b("z","y","x",-1,-1,r,n,e,o,s,0),b("z","y","x",1,-1,r,n,-e,o,s,1),b("x","z","y",1,1,e,r,n,i,o,2),b("x","z","y",1,-1,e,r,-n,i,o,3),b("x","y","z",1,-1,e,n,r,i,s,4),b("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new Ai(u,3)),this.setAttribute("normal",new Ai(d,3)),this.setAttribute("uv",new Ai(h,2));function b(y,x,v,S,N,T,M,A,k,R,C){const P=T/k,U=M/R,F=T/2,B=M/2,D=A/2,$=k+1,G=R+1;let I=0,K=0;const Q=new Ye;for(let se=0;se<G;se++){const H=se*U-B;for(let W=0;W<$;W++){const J=W*P-F;Q[y]=J*S,Q[x]=H*N,Q[v]=D,u.push(Q.x,Q.y,Q.z),Q[y]=0,Q[x]=0,Q[v]=A>0?1:-1,d.push(Q.x,Q.y,Q.z),h.push(W/k),h.push(1-se/R),I+=1}}for(let se=0;se<R;se++)for(let H=0;H<k;H++){const W=p+H+$*se,J=p+H+$*(se+1),ne=p+(H+1)+$*(se+1),xe=p+(H+1)+$*se;c.push(W,J,xe),c.push(J,ne,xe),K+=6}l.addGroup(m,K,C),m+=K,p+=I}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ab(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 gs(t){const e={};for(let n=0;n<t.length;n++){const r=ab(t[n]);for(const i in r)e[i]=r[i]}return e}function Mwe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function dX(t){return t.getRenderTarget()===null?t.outputColorSpace:Cr.workingColorSpace}const kO={clone:ab,merge:gs};var Ewe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Twe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Oh extends Pb{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ewe,this.fragmentShader=Twe,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=ab(e.uniforms),this.uniformsGroups=Mwe(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 hX extends Ss{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Vr,this.projectionMatrix=new Vr,this.projectionMatrixInverse=new Vr,this.coordinateSystem=fc}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 go extends hX{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=cy*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(k0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return cy*2*Math.atan(Math.tan(k0*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,s,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(k0*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const eg=-90,tg=1;class Awe extends Ss{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new go(eg,tg,e,n);i.layers=this.layers,this.add(i);const s=new go(eg,tg,e,n);s.layers=this.layers,this.add(s);const o=new go(eg,tg,e,n);o.layers=this.layers,this.add(o);const l=new go(eg,tg,e,n);l.layers=this.layers,this.add(l);const c=new go(eg,tg,e,n);c.layers=this.layers,this.add(c);const u=new go(eg,tg,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const u of n)this.remove(u);if(e===fc)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===ly)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,l,c,u,d]=this.children,h=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(h,p,m),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}}class fX extends qs{constructor(e,n,r,i,s,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:nb,super(e,n,r,i,s,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Cwe extends _m{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&&(E0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===tm?Ia:nl),this.texture=new fX(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:el}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new Wy(5,5,5),s=new Oh({name:"CubemapFromEquirect",uniforms:ab(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Gs,blending:vh});s.uniforms.tEquirect.value=n;const o=new Il(i,s),l=n.minFilter;return n.minFilter===sy&&(n.minFilter=el),new Awe(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(s)}}const wA=new Ye,Pwe=new Ye,jwe=new Un;class Yd{constructor(e=new Ye(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=wA.subVectors(r,n).cross(Pwe.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(wA),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||jwe.getNormalMatrix(e),i=this.coplanarPoint(wA).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const kf=new gc,F_=new Ye;class Hk{constructor(e=new Yd,n=new Yd,r=new Yd,i=new Yd,s=new Yd,o=new Yd){this.planes=[e,n,r,i,s,o]}set(e,n,r,i,s,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(s),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=fc){const r=this.planes,i=e.elements,s=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],h=i[6],p=i[7],m=i[8],b=i[9],y=i[10],x=i[11],v=i[12],S=i[13],N=i[14],T=i[15];if(r[0].setComponents(c-s,p-u,x-m,T-v).normalize(),r[1].setComponents(c+s,p+u,x+m,T+v).normalize(),r[2].setComponents(c+o,p+d,x+b,T+S).normalize(),r[3].setComponents(c-o,p-d,x-b,T-S).normalize(),r[4].setComponents(c-l,p-h,x-y,T-N).normalize(),n===fc)r[5].setComponents(c+l,p+h,x+y,T+N).normalize();else if(n===ly)r[5].setComponents(l,h,y,N).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),kf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),kf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(kf)}intersectsSprite(e){return kf.center.set(0,0,0),kf.radius=.7071067811865476,kf.applyMatrix4(e.matrixWorld),this.intersectsSphere(kf)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(F_.x=i.normal.x>0?e.max.x:e.min.x,F_.y=i.normal.y>0?e.max.y:e.min.y,F_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(F_)<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 mX(){let t=null,e=!1,n=null,r=null;function i(s,o){n(s,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){n=s},setContext:function(s){t=s}}}function Dwe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const h=u.array,p=u.usage,m=h.byteLength,b=t.createBuffer();t.bindBuffer(d,b),t.bufferData(d,h,p),u.onUploadCallback();let y;if(h instanceof Float32Array)y=t.FLOAT;else if(h instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(h instanceof Int16Array)y=t.SHORT;else if(h instanceof Uint32Array)y=t.UNSIGNED_INT;else if(h instanceof Int32Array)y=t.INT;else if(h instanceof Int8Array)y=t.BYTE;else if(h instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:b,type:y,bytesPerElement:h.BYTES_PER_ELEMENT,version:u.version,size:m}}function s(u,d,h){const p=d.array,m=d._updateRange,b=d.updateRanges;if(t.bindBuffer(h,u),m.count===-1&&b.length===0&&t.bufferSubData(h,0,p),b.length!==0){for(let y=0,x=b.length;y<x;y++){const v=b[y];n?t.bufferSubData(h,v.start*p.BYTES_PER_ELEMENT,p,v.start,v.count):t.bufferSubData(h,v.start*p.BYTES_PER_ELEMENT,p.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(h,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):t.bufferSubData(h,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 h=r.get(u);if(h===void 0)r.set(u,i(u,d));else if(h.version<u.version){if(h.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(h.buffer,u,d),h.version=u.version}}return{get:o,remove:l,update:c}}class MO extends ss{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,h=e/l,p=n/c,m=[],b=[],y=[],x=[];for(let v=0;v<d;v++){const S=v*p-o;for(let N=0;N<u;N++){const T=N*h-s;b.push(T,-S,0),y.push(0,0,1),x.push(N/l),x.push(1-v/c)}}for(let v=0;v<c;v++)for(let S=0;S<l;S++){const N=S+u*v,T=S+u*(v+1),M=S+1+u*(v+1),A=S+1+u*v;m.push(N,T,A),m.push(T,M,A)}this.setIndex(m),this.setAttribute("position",new Ai(b,3)),this.setAttribute("normal",new Ai(y,3)),this.setAttribute("uv",new Ai(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new MO(e.width,e.height,e.widthSegments,e.heightSegments)}}var Rwe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Owe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,Lwe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Fwe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Iwe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,zwe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Uwe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,Bwe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Hwe=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,$we=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,Vwe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,Gwe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,qwe=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,Wwe=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,Kwe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,Xwe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,Ywe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,Qwe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,Zwe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,Jwe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,e_e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,t_e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,n_e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,r_e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,i_e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,a_e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,s_e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,o_e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,l_e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,c_e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,u_e="gl_FragColor = linearToOutputTexel( gl_FragColor );",d_e=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,h_e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,f_e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,m_e=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,p_e=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,g_e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,b_e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,x_e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,y_e=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,v_e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,w_e=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,__e=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,S_e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,N_e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,k_e=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,M_e=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,E_e=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,T_e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,A_e=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,C_e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,P_e=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,j_e=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,D_e=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,R_e=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,O_e=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,L_e=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,F_e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,I_e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,z_e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,U_e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,B_e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,H_e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,$_e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,V_e=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,G_e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,q_e=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,W_e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,K_e=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,X_e=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,Y_e=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,Q_e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,Z_e=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,J_e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,e1e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,t1e=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,n1e=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,r1e=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,i1e=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,a1e=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,s1e=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,o1e=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,l1e=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,c1e=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,u1e=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,d1e=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,h1e=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,f1e=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,m1e=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,p1e=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,g1e=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,b1e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,x1e=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,y1e=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,v1e=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,w1e=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,_1e=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,S1e=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,N1e=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,k1e=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,M1e=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,E1e=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,T1e=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,A1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,C1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,P1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,j1e=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const D1e=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,R1e=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,O1e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,L1e=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,F1e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,I1e=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,z1e=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,U1e=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,B1e=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,H1e=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,$1e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,V1e=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,G1e=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,q1e=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,W1e=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,K1e=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,X1e=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Y1e=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Q1e=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,Z1e=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,J1e=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,eSe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,tSe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,nSe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,rSe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,iSe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,aSe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,sSe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,oSe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,lSe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,cSe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,uSe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,dSe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,hSe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,Dn={alphahash_fragment:Rwe,alphahash_pars_fragment:Owe,alphamap_fragment:Lwe,alphamap_pars_fragment:Fwe,alphatest_fragment:Iwe,alphatest_pars_fragment:zwe,aomap_fragment:Uwe,aomap_pars_fragment:Bwe,batching_pars_vertex:Hwe,batching_vertex:$we,begin_vertex:Vwe,beginnormal_vertex:Gwe,bsdfs:qwe,iridescence_fragment:Wwe,bumpmap_pars_fragment:Kwe,clipping_planes_fragment:Xwe,clipping_planes_pars_fragment:Ywe,clipping_planes_pars_vertex:Qwe,clipping_planes_vertex:Zwe,color_fragment:Jwe,color_pars_fragment:e_e,color_pars_vertex:t_e,color_vertex:n_e,common:r_e,cube_uv_reflection_fragment:i_e,defaultnormal_vertex:a_e,displacementmap_pars_vertex:s_e,displacementmap_vertex:o_e,emissivemap_fragment:l_e,emissivemap_pars_fragment:c_e,colorspace_fragment:u_e,colorspace_pars_fragment:d_e,envmap_fragment:h_e,envmap_common_pars_fragment:f_e,envmap_pars_fragment:m_e,envmap_pars_vertex:p_e,envmap_physical_pars_fragment:E_e,envmap_vertex:g_e,fog_vertex:b_e,fog_pars_vertex:x_e,fog_fragment:y_e,fog_pars_fragment:v_e,gradientmap_pars_fragment:w_e,lightmap_fragment:__e,lightmap_pars_fragment:S_e,lights_lambert_fragment:N_e,lights_lambert_pars_fragment:k_e,lights_pars_begin:M_e,lights_toon_fragment:T_e,lights_toon_pars_fragment:A_e,lights_phong_fragment:C_e,lights_phong_pars_fragment:P_e,lights_physical_fragment:j_e,lights_physical_pars_fragment:D_e,lights_fragment_begin:R_e,lights_fragment_maps:O_e,lights_fragment_end:L_e,logdepthbuf_fragment:F_e,logdepthbuf_pars_fragment:I_e,logdepthbuf_pars_vertex:z_e,logdepthbuf_vertex:U_e,map_fragment:B_e,map_pars_fragment:H_e,map_particle_fragment:$_e,map_particle_pars_fragment:V_e,metalnessmap_fragment:G_e,metalnessmap_pars_fragment:q_e,morphcolor_vertex:W_e,morphnormal_vertex:K_e,morphtarget_pars_vertex:X_e,morphtarget_vertex:Y_e,normal_fragment_begin:Q_e,normal_fragment_maps:Z_e,normal_pars_fragment:J_e,normal_pars_vertex:e1e,normal_vertex:t1e,normalmap_pars_fragment:n1e,clearcoat_normal_fragment_begin:r1e,clearcoat_normal_fragment_maps:i1e,clearcoat_pars_fragment:a1e,iridescence_pars_fragment:s1e,opaque_fragment:o1e,packing:l1e,premultiplied_alpha_fragment:c1e,project_vertex:u1e,dithering_fragment:d1e,dithering_pars_fragment:h1e,roughnessmap_fragment:f1e,roughnessmap_pars_fragment:m1e,shadowmap_pars_fragment:p1e,shadowmap_pars_vertex:g1e,shadowmap_vertex:b1e,shadowmask_pars_fragment:x1e,skinbase_vertex:y1e,skinning_pars_vertex:v1e,skinning_vertex:w1e,skinnormal_vertex:_1e,specularmap_fragment:S1e,specularmap_pars_fragment:N1e,tonemapping_fragment:k1e,tonemapping_pars_fragment:M1e,transmission_fragment:E1e,transmission_pars_fragment:T1e,uv_pars_fragment:A1e,uv_pars_vertex:C1e,uv_vertex:P1e,worldpos_vertex:j1e,background_vert:D1e,background_frag:R1e,backgroundCube_vert:O1e,backgroundCube_frag:L1e,cube_vert:F1e,cube_frag:I1e,depth_vert:z1e,depth_frag:U1e,distanceRGBA_vert:B1e,distanceRGBA_frag:H1e,equirect_vert:$1e,equirect_frag:V1e,linedashed_vert:G1e,linedashed_frag:q1e,meshbasic_vert:W1e,meshbasic_frag:K1e,meshlambert_vert:X1e,meshlambert_frag:Y1e,meshmatcap_vert:Q1e,meshmatcap_frag:Z1e,meshnormal_vert:J1e,meshnormal_frag:eSe,meshphong_vert:tSe,meshphong_frag:nSe,meshphysical_vert:rSe,meshphysical_frag:iSe,meshtoon_vert:aSe,meshtoon_frag:sSe,points_vert:oSe,points_frag:lSe,shadow_vert:cSe,shadow_frag:uSe,sprite_vert:dSe,sprite_frag:hSe},Ot={common:{diffuse:{value:new dn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Un},alphaMap:{value:null},alphaMapTransform:{value:new Un},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Un}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Un}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Un}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Un},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Un},normalScale:{value:new _n(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Un},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Un}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Un}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Un}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new dn(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 dn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Un},alphaTest:{value:0},uvTransform:{value:new Un}},sprite:{diffuse:{value:new dn(16777215)},opacity:{value:1},center:{value:new _n(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Un},alphaMap:{value:null},alphaMapTransform:{value:new Un},alphaTest:{value:0}}},Bs={basic:{uniforms:gs([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.fog]),vertexShader:Dn.meshbasic_vert,fragmentShader:Dn.meshbasic_frag},lambert:{uniforms:gs([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 dn(0)}}]),vertexShader:Dn.meshlambert_vert,fragmentShader:Dn.meshlambert_frag},phong:{uniforms:gs([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 dn(0)},specular:{value:new dn(1118481)},shininess:{value:30}}]),vertexShader:Dn.meshphong_vert,fragmentShader:Dn.meshphong_frag},standard:{uniforms:gs([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 dn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Dn.meshphysical_vert,fragmentShader:Dn.meshphysical_frag},toon:{uniforms:gs([Ot.common,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.gradientmap,Ot.fog,Ot.lights,{emissive:{value:new dn(0)}}]),vertexShader:Dn.meshtoon_vert,fragmentShader:Dn.meshtoon_frag},matcap:{uniforms:gs([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,{matcap:{value:null}}]),vertexShader:Dn.meshmatcap_vert,fragmentShader:Dn.meshmatcap_frag},points:{uniforms:gs([Ot.points,Ot.fog]),vertexShader:Dn.points_vert,fragmentShader:Dn.points_frag},dashed:{uniforms:gs([Ot.common,Ot.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Dn.linedashed_vert,fragmentShader:Dn.linedashed_frag},depth:{uniforms:gs([Ot.common,Ot.displacementmap]),vertexShader:Dn.depth_vert,fragmentShader:Dn.depth_frag},normal:{uniforms:gs([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,{opacity:{value:1}}]),vertexShader:Dn.meshnormal_vert,fragmentShader:Dn.meshnormal_frag},sprite:{uniforms:gs([Ot.sprite,Ot.fog]),vertexShader:Dn.sprite_vert,fragmentShader:Dn.sprite_frag},background:{uniforms:{uvTransform:{value:new Un},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Dn.background_vert,fragmentShader:Dn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Dn.backgroundCube_vert,fragmentShader:Dn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Dn.cube_vert,fragmentShader:Dn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Dn.equirect_vert,fragmentShader:Dn.equirect_frag},distanceRGBA:{uniforms:gs([Ot.common,Ot.displacementmap,{referencePosition:{value:new Ye},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Dn.distanceRGBA_vert,fragmentShader:Dn.distanceRGBA_frag},shadow:{uniforms:gs([Ot.lights,Ot.fog,{color:{value:new dn(0)},opacity:{value:1}}]),vertexShader:Dn.shadow_vert,fragmentShader:Dn.shadow_frag}};Bs.physical={uniforms:gs([Bs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Un},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Un},clearcoatNormalScale:{value:new _n(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Un},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Un},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Un},sheen:{value:0},sheenColor:{value:new dn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Un},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Un},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Un},transmissionSamplerSize:{value:new _n},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Un},attenuationDistance:{value:0},attenuationColor:{value:new dn(0)},specularColor:{value:new dn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Un},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Un},anisotropyVector:{value:new _n},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Un}}]),vertexShader:Dn.meshphysical_vert,fragmentShader:Dn.meshphysical_frag};const I_={r:0,b:0,g:0};function fSe(t,e,n,r,i,s,o){const l=new dn(0);let c=s===!0?0:1,u,d,h=null,p=0,m=null;function b(x,v){let S=!1,N=v.isScene===!0?v.background:null;N&&N.isTexture&&(N=(v.backgroundBlurriness>0?n:e).get(N)),N===null?y(l,c):N&&N.isColor&&(y(N,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),N&&(N.isCubeTexture||N.mapping===Uk)?(d===void 0&&(d=new Il(new Wy(1,1,1),new Oh({name:"BackgroundCubeMaterial",uniforms:ab(Bs.backgroundCube.uniforms),vertexShader:Bs.backgroundCube.vertexShader,fragmentShader:Bs.backgroundCube.fragmentShader,side:Gs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(M,A,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=N,d.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=Cr.getTransfer(N.colorSpace)!==Kr,(h!==N||p!==N.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,h=N,p=N.version,m=t.toneMapping),d.layers.enableAll(),x.unshift(d,d.geometry,d.material,0,0,null)):N&&N.isTexture&&(u===void 0&&(u=new Il(new MO(2,2),new Oh({name:"BackgroundMaterial",uniforms:ab(Bs.background.uniforms),vertexShader:Bs.background.vertexShader,fragmentShader:Bs.background.fragmentShader,side:Rh,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=N,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=Cr.getTransfer(N.colorSpace)!==Kr,N.matrixAutoUpdate===!0&&N.updateMatrix(),u.material.uniforms.uvTransform.value.copy(N.matrix),(h!==N||p!==N.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=N,p=N.version,m=t.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null))}function y(x,v){x.getRGB(I_,dX(t)),r.buffers.color.setClear(I_.r,I_.g,I_.b,v,o)}return{getClearColor:function(){return l},setClearColor:function(x,v=1){l.set(x),c=v,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(x){c=x,y(l,c)},render:b}}function mSe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,l={},c=x(null);let u=c,d=!1;function h(D,$,G,I,K){let Q=!1;if(o){const se=y(I,G,$);u!==se&&(u=se,m(u.object)),Q=v(D,I,G,K),Q&&S(D,I,G,K)}else{const se=$.wireframe===!0;(u.geometry!==I.id||u.program!==G.id||u.wireframe!==se)&&(u.geometry=I.id,u.program=G.id,u.wireframe=se,Q=!0)}K!==null&&n.update(K,t.ELEMENT_ARRAY_BUFFER),(Q||d)&&(d=!1,R(D,$,G,I),K!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(K).buffer))}function p(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function m(D){return r.isWebGL2?t.bindVertexArray(D):s.bindVertexArrayOES(D)}function b(D){return r.isWebGL2?t.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function y(D,$,G){const I=G.wireframe===!0;let K=l[D.id];K===void 0&&(K={},l[D.id]=K);let Q=K[$.id];Q===void 0&&(Q={},K[$.id]=Q);let se=Q[I];return se===void 0&&(se=x(p()),Q[I]=se),se}function x(D){const $=[],G=[],I=[];for(let K=0;K<i;K++)$[K]=0,G[K]=0,I[K]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:G,attributeDivisors:I,object:D,attributes:{},index:null}}function v(D,$,G,I){const K=u.attributes,Q=$.attributes;let se=0;const H=G.getAttributes();for(const W in H)if(H[W].location>=0){const ne=K[W];let xe=Q[W];if(xe===void 0&&(W==="instanceMatrix"&&D.instanceMatrix&&(xe=D.instanceMatrix),W==="instanceColor"&&D.instanceColor&&(xe=D.instanceColor)),ne===void 0||ne.attribute!==xe||xe&&ne.data!==xe.data)return!0;se++}return u.attributesNum!==se||u.index!==I}function S(D,$,G,I){const K={},Q=$.attributes;let se=0;const H=G.getAttributes();for(const W in H)if(H[W].location>=0){let ne=Q[W];ne===void 0&&(W==="instanceMatrix"&&D.instanceMatrix&&(ne=D.instanceMatrix),W==="instanceColor"&&D.instanceColor&&(ne=D.instanceColor));const xe={};xe.attribute=ne,ne&&ne.data&&(xe.data=ne.data),K[W]=xe,se++}u.attributes=K,u.attributesNum=se,u.index=I}function N(){const D=u.newAttributes;for(let $=0,G=D.length;$<G;$++)D[$]=0}function T(D){M(D,0)}function M(D,$){const G=u.newAttributes,I=u.enabledAttributes,K=u.attributeDivisors;G[D]=1,I[D]===0&&(t.enableVertexAttribArray(D),I[D]=1),K[D]!==$&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,$),K[D]=$)}function A(){const D=u.newAttributes,$=u.enabledAttributes;for(let G=0,I=$.length;G<I;G++)$[G]!==D[G]&&(t.disableVertexAttribArray(G),$[G]=0)}function k(D,$,G,I,K,Q,se){se===!0?t.vertexAttribIPointer(D,$,G,K,Q):t.vertexAttribPointer(D,$,G,I,K,Q)}function R(D,$,G,I){if(r.isWebGL2===!1&&(D.isInstancedMesh||I.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;N();const K=I.attributes,Q=G.getAttributes(),se=$.defaultAttributeValues;for(const H in Q){const W=Q[H];if(W.location>=0){let J=K[H];if(J===void 0&&(H==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),H==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const ne=J.normalized,xe=J.itemSize,ue=n.get(J);if(ue===void 0)continue;const fe=ue.buffer,De=ue.type,oe=ue.bytesPerElement,Ne=r.isWebGL2===!0&&(De===t.INT||De===t.UNSIGNED_INT||J.gpuType===GK);if(J.isInterleavedBufferAttribute){const Fe=J.data,ce=Fe.stride,Ve=J.offset;if(Fe.isInstancedInterleavedBuffer){for(let V=0;V<W.locationSize;V++)M(W.location+V,Fe.meshPerAttribute);D.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=Fe.meshPerAttribute*Fe.count)}else for(let V=0;V<W.locationSize;V++)T(W.location+V);t.bindBuffer(t.ARRAY_BUFFER,fe);for(let V=0;V<W.locationSize;V++)k(W.location+V,xe/W.locationSize,De,ne,ce*oe,(Ve+xe/W.locationSize*V)*oe,Ne)}else{if(J.isInstancedBufferAttribute){for(let Fe=0;Fe<W.locationSize;Fe++)M(W.location+Fe,J.meshPerAttribute);D.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let Fe=0;Fe<W.locationSize;Fe++)T(W.location+Fe);t.bindBuffer(t.ARRAY_BUFFER,fe);for(let Fe=0;Fe<W.locationSize;Fe++)k(W.location+Fe,xe/W.locationSize,De,ne,xe*oe,xe/W.locationSize*Fe*oe,Ne)}}else if(se!==void 0){const ne=se[H];if(ne!==void 0)switch(ne.length){case 2:t.vertexAttrib2fv(W.location,ne);break;case 3:t.vertexAttrib3fv(W.location,ne);break;case 4:t.vertexAttrib4fv(W.location,ne);break;default:t.vertexAttrib1fv(W.location,ne)}}}}A()}function C(){F();for(const D in l){const $=l[D];for(const G in $){const I=$[G];for(const K in I)b(I[K].object),delete I[K];delete $[G]}delete l[D]}}function P(D){if(l[D.id]===void 0)return;const $=l[D.id];for(const G in $){const I=$[G];for(const K in I)b(I[K].object),delete I[K];delete $[G]}delete l[D.id]}function U(D){for(const $ in l){const G=l[$];if(G[D.id]===void 0)continue;const I=G[D.id];for(const K in I)b(I[K].object),delete I[K];delete G[D.id]}}function F(){B(),d=!0,u!==c&&(u=c,m(u.object))}function B(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:F,resetDefaultState:B,dispose:C,releaseStatesOfGeometry:P,releaseStatesOfProgram:U,initAttributes:N,enableAttribute:T,disableUnusedAttributes:A}}function pSe(t,e,n,r){const i=r.isWebGL2;let s;function o(d){s=d}function l(d,h){t.drawArrays(s,d,h),n.update(h,s,1)}function c(d,h,p){if(p===0)return;let m,b;if(i)m=t,b="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),b="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[b](s,d,h,p),n.update(h,s,p)}function u(d,h,p){if(p===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let b=0;b<p;b++)this.render(d[b],h[b]);else{m.multiDrawArraysWEBGL(s,d,0,h,0,p);let b=0;for(let y=0;y<p;y++)b+=h[y];n.update(b,s,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function gSe(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 s(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=s(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),x=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),v=t.getParameter(t.MAX_VARYING_VECTORS),S=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),N=p>0,T=o||e.has("OES_texture_float"),M=N&&T,A=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:l,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:b,maxAttributes:y,maxVertexUniforms:x,maxVaryings:v,maxFragmentUniforms:S,vertexTextures:N,floatFragmentTextures:T,floatVertexTextures:M,maxSamples:A}}function bSe(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new Yd,l=new Un,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const m=h.length!==0||p||r!==0||i;return i=p,r=h.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){n=d(h,p,0)},this.setState=function(h,p,m){const b=h.clippingPlanes,y=h.clipIntersection,x=h.clipShadows,v=t.get(h);if(!i||b===null||b.length===0||s&&!x)s?d(null):u();else{const S=s?0:r,N=S*4;let T=v.clippingState||null;c.value=T,T=d(b,p,N,m);for(let M=0;M!==N;++M)T[M]=n[M];v.clippingState=T,this.numIntersection=y?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(h,p,m,b){const y=h!==null?h.length:0;let x=null;if(y!==0){if(x=c.value,b!==!0||x===null){const v=m+y*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(x===null||x.length<v)&&(x=new Float32Array(v));for(let N=0,T=m;N!==y;++N,T+=4)o.copy(h[N]).applyMatrix4(S,l),o.normal.toArray(x,T),x[T+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,x}}function xSe(t){let e=new WeakMap;function n(o,l){return l===C3?o.mapping=nb:l===P3&&(o.mapping=rb),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===C3||l===P3)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 Cwe(c.height/2);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class ySe extends hX{constructor(e=-1,n=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(s,o,l,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Ng=4,x6=[.125,.215,.35,.446,.526,.582],If=20,_A=new ySe,y6=new dn;let SA=null,NA=0,kA=0;const Pf=(1+Math.sqrt(5))/2,ng=1/Pf,v6=[new Ye(1,1,1),new Ye(-1,1,1),new Ye(1,1,-1),new Ye(-1,1,-1),new Ye(0,Pf,ng),new Ye(0,Pf,-ng),new Ye(ng,0,Pf),new Ye(-ng,0,Pf),new Ye(Pf,ng,0),new Ye(-Pf,ng,0)];class w6{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){SA=this._renderer.getRenderTarget(),NA=this._renderer.getActiveCubeFace(),kA=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,r,i,s),n>0&&this._blur(s,0,0,n),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=N6(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=S6(),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(SA,NA,kA),e.scissorTest=!1,z_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===nb||e.mapping===rb?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),SA=this._renderer.getRenderTarget(),NA=this._renderer.getActiveCubeFace(),kA=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:el,minFilter:el,generateMipmaps:!1,type:oy,format:tl,colorSpace:Ku,depthBuffer:!1},i=_6(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=_6(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=vSe(s)),this._blurMaterial=wSe(s,e,n)}return i}_compileMaterial(e){const n=new Il(this._lodPlanes[0],e);this._renderer.compile(n,_A)}_sceneToCubeUV(e,n,r,i){const l=new go(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,h=d.autoClear,p=d.toneMapping;d.getClearColor(y6),d.toneMapping=wh,d.autoClear=!1;const m=new lX({name:"PMREM.Background",side:Gs,depthWrite:!1,depthTest:!1}),b=new Il(new Wy,m);let y=!1;const x=e.background;x?x.isColor&&(m.color.copy(x),e.background=null,y=!0):(m.color.copy(y6),y=!0);for(let v=0;v<6;v++){const S=v%3;S===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):S===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const N=this._cubeSize;z_(i,S*N,v>2?N:0,N,N),d.setRenderTarget(i),y&&d.render(b,l),d.render(e,l)}b.geometry.dispose(),b.material.dispose(),d.toneMapping=p,d.autoClear=h,e.background=x}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===nb||e.mapping===rb;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=N6()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=S6());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Il(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;z_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,_A)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=v6[(i-1)%v6.length];this._blur(e,i-1,i,s,o)}n.autoClear=r}_blur(e,n,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,h=new Il(this._lodPlanes[i],u),p=u.uniforms,m=this._sizeLods[r]-1,b=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*If-1),y=s/b,x=isFinite(s)?1+Math.floor(d*y):If;x>If&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${If}`);const v=[];let S=0;for(let k=0;k<If;++k){const R=k/y,C=Math.exp(-R*R/2);v.push(C),k===0?S+=C:k<x&&(S+=2*C)}for(let k=0;k<v.length;k++)v[k]=v[k]/S;p.envMap.value=e.texture,p.samples.value=x,p.weights.value=v,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:N}=this;p.dTheta.value=b,p.mipInt.value=N-r;const T=this._sizeLods[i],M=3*T*(i>N-Ng?i-N+Ng:0),A=4*(this._cubeSize-T);z_(n,M,A,3*T,2*T),c.setRenderTarget(n),c.render(h,_A)}}function vSe(t){const e=[],n=[],r=[];let i=t;const s=t-Ng+1+x6.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Ng?c=x6[o-t+Ng-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,h=1+u,p=[d,d,h,d,h,h,d,d,h,h,d,h],m=6,b=6,y=3,x=2,v=1,S=new Float32Array(y*b*m),N=new Float32Array(x*b*m),T=new Float32Array(v*b*m);for(let A=0;A<m;A++){const k=A%3*2/3-1,R=A>2?0:-1,C=[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(C,y*b*A),N.set(p,x*b*A);const P=[A,A,A,A,A,A];T.set(P,v*b*A)}const M=new ss;M.setAttribute("position",new No(S,y)),M.setAttribute("uv",new No(N,x)),M.setAttribute("faceIndex",new No(T,v)),e.push(M),i>Ng&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function _6(t,e,n){const r=new _m(t,e,n);return r.texture.mapping=Uk,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function z_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function wSe(t,e,n){const r=new Float32Array(If),i=new Ye(0,1,0);return new Oh({name:"SphericalGaussianBlur",defines:{n:If,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:EO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:vh,depthTest:!1,depthWrite:!1})}function S6(){return new Oh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:EO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:vh,depthTest:!1,depthWrite:!1})}function N6(){return new Oh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:EO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:vh,depthTest:!1,depthWrite:!1})}function EO(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function _Se(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===C3||c===P3,d=c===nb||c===rb;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let h=e.get(l);return n===null&&(n=new w6(t)),h=u?n.fromEquirectangular(l,h):n.fromCubemap(l,h),e.set(l,h),h.texture}else{if(e.has(l))return e.get(l).texture;{const h=l.image;if(u&&h&&h.height>0||d&&h&&i(h)){n===null&&(n=new w6(t));const p=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,p),l.addEventListener("dispose",s),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 s(l){const c=l.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function SSe(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 NSe(t,e,n,r){const i={},s=new WeakMap;function o(h){const p=h.target;p.index!==null&&e.remove(p.index);for(const b in p.attributes)e.remove(p.attributes[b]);for(const b in p.morphAttributes){const y=p.morphAttributes[b];for(let x=0,v=y.length;x<v;x++)e.remove(y[x])}p.removeEventListener("dispose",o),delete i[p.id];const m=s.get(p);m&&(e.remove(m),s.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(h,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(h){const p=h.attributes;for(const b in p)e.update(p[b],t.ARRAY_BUFFER);const m=h.morphAttributes;for(const b in m){const y=m[b];for(let x=0,v=y.length;x<v;x++)e.update(y[x],t.ARRAY_BUFFER)}}function u(h){const p=[],m=h.index,b=h.attributes.position;let y=0;if(m!==null){const S=m.array;y=m.version;for(let N=0,T=S.length;N<T;N+=3){const M=S[N+0],A=S[N+1],k=S[N+2];p.push(M,A,A,k,k,M)}}else if(b!==void 0){const S=b.array;y=b.version;for(let N=0,T=S.length/3-1;N<T;N+=3){const M=N+0,A=N+1,k=N+2;p.push(M,A,A,k,k,M)}}else return;const x=new(nX(p)?uX:cX)(p,1);x.version=y;const v=s.get(h);v&&e.remove(v),s.set(h,x)}function d(h){const p=s.get(h);if(p){const m=h.index;m!==null&&p.version<m.version&&u(h)}else u(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:d}}function kSe(t,e,n,r){const i=r.isWebGL2;let s;function o(m){s=m}let l,c;function u(m){l=m.type,c=m.bytesPerElement}function d(m,b){t.drawElements(s,b,l,m*c),n.update(b,s,1)}function h(m,b,y){if(y===0)return;let x,v;if(i)x=t,v="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[v](s,b,l,m*c,y),n.update(b,s,y)}function p(m,b,y){if(y===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let v=0;v<y;v++)this.render(m[v]/c,b[v]);else{x.multiDrawElementsWEBGL(s,b,0,l,m,0,y);let v=0;for(let S=0;S<y;S++)v+=b[S];n.update(v,s,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=h,this.renderMultiDraw=p}function MSe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(s/3);break;case t.LINES:n.lines+=l*(s/2);break;case t.LINE_STRIP:n.lines+=l*(s-1);break;case t.LINE_LOOP:n.lines+=l*s;break;case t.POINTS:n.points+=l*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function ESe(t,e){return t[0]-e[0]}function TSe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function ASe(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,o=new jr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,h){const p=u.morphTargetInfluences;if(e.isWebGL2===!0){const b=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=b!==void 0?b.length:0;let x=s.get(d);if(x===void 0||x.count!==y){let $=function(){B.dispose(),s.delete(d),d.removeEventListener("dispose",$)};var m=$;x!==void 0&&x.texture.dispose();const N=d.morphAttributes.position!==void 0,T=d.morphAttributes.normal!==void 0,M=d.morphAttributes.color!==void 0,A=d.morphAttributes.position||[],k=d.morphAttributes.normal||[],R=d.morphAttributes.color||[];let C=0;N===!0&&(C=1),T===!0&&(C=2),M===!0&&(C=3);let P=d.attributes.position.count*C,U=1;P>e.maxTextureSize&&(U=Math.ceil(P/e.maxTextureSize),P=e.maxTextureSize);const F=new Float32Array(P*U*4*y),B=new aX(F,P,U,y);B.type=Eu,B.needsUpdate=!0;const D=C*4;for(let G=0;G<y;G++){const I=A[G],K=k[G],Q=R[G],se=P*U*4*G;for(let H=0;H<I.count;H++){const W=H*D;N===!0&&(o.fromBufferAttribute(I,H),F[se+W+0]=o.x,F[se+W+1]=o.y,F[se+W+2]=o.z,F[se+W+3]=0),T===!0&&(o.fromBufferAttribute(K,H),F[se+W+4]=o.x,F[se+W+5]=o.y,F[se+W+6]=o.z,F[se+W+7]=0),M===!0&&(o.fromBufferAttribute(Q,H),F[se+W+8]=o.x,F[se+W+9]=o.y,F[se+W+10]=o.z,F[se+W+11]=Q.itemSize===4?o.w:1)}}x={count:y,texture:B,size:new _n(P,U)},s.set(d,x),d.addEventListener("dispose",$)}let v=0;for(let N=0;N<p.length;N++)v+=p[N];const S=d.morphTargetsRelative?1:1-v;h.getUniforms().setValue(t,"morphTargetBaseInfluence",S),h.getUniforms().setValue(t,"morphTargetInfluences",p),h.getUniforms().setValue(t,"morphTargetsTexture",x.texture,n),h.getUniforms().setValue(t,"morphTargetsTextureSize",x.size)}else{const b=p===void 0?0:p.length;let y=r[d.id];if(y===void 0||y.length!==b){y=[];for(let T=0;T<b;T++)y[T]=[T,0];r[d.id]=y}for(let T=0;T<b;T++){const M=y[T];M[0]=T,M[1]=p[T]}y.sort(TSe);for(let T=0;T<8;T++)T<b&&y[T][1]?(l[T][0]=y[T][0],l[T][1]=y[T][1]):(l[T][0]=Number.MAX_SAFE_INTEGER,l[T][1]=0);l.sort(ESe);const x=d.morphAttributes.position,v=d.morphAttributes.normal;let S=0;for(let T=0;T<8;T++){const M=l[T],A=M[0],k=M[1];A!==Number.MAX_SAFE_INTEGER&&k?(x&&d.getAttribute("morphTarget"+T)!==x[A]&&d.setAttribute("morphTarget"+T,x[A]),v&&d.getAttribute("morphNormal"+T)!==v[A]&&d.setAttribute("morphNormal"+T,v[A]),i[T]=k,S+=k):(x&&d.hasAttribute("morphTarget"+T)===!0&&d.deleteAttribute("morphTarget"+T),v&&d.hasAttribute("morphNormal"+T)===!0&&d.deleteAttribute("morphNormal"+T),i[T]=0)}const N=d.morphTargetsRelative?1:1-S;h.getUniforms().setValue(t,"morphTargetBaseInfluence",N),h.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function CSe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,h=e.get(c,d);if(i.get(h)!==u&&(e.update(h),i.set(h,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 h}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:o}}class pX extends qs{constructor(e,n,r,i,s,o,l,c,u,d){if(d=d!==void 0?d:em,d!==em&&d!==ib)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===em&&(r=ch),r===void 0&&d===ib&&(r=Jf),super(null,i,s,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:Fa,this.minFilter=c!==void 0?c:Fa,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 gX=new qs,bX=new pX(1,1);bX.compareFunction=eX;const xX=new aX,yX=new mwe,vX=new fX,k6=[],M6=[],E6=new Float32Array(16),T6=new Float32Array(9),A6=new Float32Array(4);function jb(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=k6[i];if(s===void 0&&(s=new Float32Array(i),k6[i]=s),e!==0){r.toArray(s,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(s,l)}return s}function ra(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 ia(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function $k(t,e){let n=M6[e];n===void 0&&(n=new Int32Array(e),M6[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function PSe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function jSe(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(ra(n,e))return;t.uniform2fv(this.addr,e),ia(n,e)}}function DSe(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(ra(n,e))return;t.uniform3fv(this.addr,e),ia(n,e)}}function RSe(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(ra(n,e))return;t.uniform4fv(this.addr,e),ia(n,e)}}function OSe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ra(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ia(n,e)}else{if(ra(n,r))return;A6.set(r),t.uniformMatrix2fv(this.addr,!1,A6),ia(n,r)}}function LSe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ra(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ia(n,e)}else{if(ra(n,r))return;T6.set(r),t.uniformMatrix3fv(this.addr,!1,T6),ia(n,r)}}function FSe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ra(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ia(n,e)}else{if(ra(n,r))return;E6.set(r),t.uniformMatrix4fv(this.addr,!1,E6),ia(n,r)}}function ISe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function zSe(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(ra(n,e))return;t.uniform2iv(this.addr,e),ia(n,e)}}function USe(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(ra(n,e))return;t.uniform3iv(this.addr,e),ia(n,e)}}function BSe(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(ra(n,e))return;t.uniform4iv(this.addr,e),ia(n,e)}}function HSe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function $Se(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(ra(n,e))return;t.uniform2uiv(this.addr,e),ia(n,e)}}function VSe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ra(n,e))return;t.uniform3uiv(this.addr,e),ia(n,e)}}function GSe(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(ra(n,e))return;t.uniform4uiv(this.addr,e),ia(n,e)}}function qSe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const s=this.type===t.SAMPLER_2D_SHADOW?bX:gX;n.setTexture2D(e||s,i)}function WSe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||yX,i)}function KSe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||vX,i)}function XSe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||xX,i)}function YSe(t){switch(t){case 5126:return PSe;case 35664:return jSe;case 35665:return DSe;case 35666:return RSe;case 35674:return OSe;case 35675:return LSe;case 35676:return FSe;case 5124:case 35670:return ISe;case 35667:case 35671:return zSe;case 35668:case 35672:return USe;case 35669:case 35673:return BSe;case 5125:return HSe;case 36294:return $Se;case 36295:return VSe;case 36296:return GSe;case 35678:case 36198:case 36298:case 36306:case 35682:return qSe;case 35679:case 36299:case 36307:return WSe;case 35680:case 36300:case 36308:case 36293:return KSe;case 36289:case 36303:case 36311:case 36292:return XSe}}function QSe(t,e){t.uniform1fv(this.addr,e)}function ZSe(t,e){const n=jb(e,this.size,2);t.uniform2fv(this.addr,n)}function JSe(t,e){const n=jb(e,this.size,3);t.uniform3fv(this.addr,n)}function eNe(t,e){const n=jb(e,this.size,4);t.uniform4fv(this.addr,n)}function tNe(t,e){const n=jb(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function nNe(t,e){const n=jb(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function rNe(t,e){const n=jb(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function iNe(t,e){t.uniform1iv(this.addr,e)}function aNe(t,e){t.uniform2iv(this.addr,e)}function sNe(t,e){t.uniform3iv(this.addr,e)}function oNe(t,e){t.uniform4iv(this.addr,e)}function lNe(t,e){t.uniform1uiv(this.addr,e)}function cNe(t,e){t.uniform2uiv(this.addr,e)}function uNe(t,e){t.uniform3uiv(this.addr,e)}function dNe(t,e){t.uniform4uiv(this.addr,e)}function hNe(t,e,n){const r=this.cache,i=e.length,s=$k(n,i);ra(r,s)||(t.uniform1iv(this.addr,s),ia(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||gX,s[o])}function fNe(t,e,n){const r=this.cache,i=e.length,s=$k(n,i);ra(r,s)||(t.uniform1iv(this.addr,s),ia(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||yX,s[o])}function mNe(t,e,n){const r=this.cache,i=e.length,s=$k(n,i);ra(r,s)||(t.uniform1iv(this.addr,s),ia(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||vX,s[o])}function pNe(t,e,n){const r=this.cache,i=e.length,s=$k(n,i);ra(r,s)||(t.uniform1iv(this.addr,s),ia(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||xX,s[o])}function gNe(t){switch(t){case 5126:return QSe;case 35664:return ZSe;case 35665:return JSe;case 35666:return eNe;case 35674:return tNe;case 35675:return nNe;case 35676:return rNe;case 5124:case 35670:return iNe;case 35667:case 35671:return aNe;case 35668:case 35672:return sNe;case 35669:case 35673:return oNe;case 5125:return lNe;case 36294:return cNe;case 36295:return uNe;case 36296:return dNe;case 35678:case 36198:case 36298:case 36306:case 35682:return hNe;case 35679:case 36299:case 36307:return fNe;case 35680:case 36300:case 36308:case 36293:return mNe;case 36289:case 36303:case 36311:case 36292:return pNe}}class bNe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=YSe(n.type)}}class xNe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=gNe(n.type)}}class yNe{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const l=i[s];l.setValue(e,n[l.id],r)}}}const MA=/(\w+)(\])?(\[|\.)?/g;function C6(t,e){t.seq.push(e),t.map[e.id]=e}function vNe(t,e,n){const r=t.name,i=r.length;for(MA.lastIndex=0;;){const s=MA.exec(r),o=MA.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){C6(n,u===void 0?new bNe(l,t,e):new xNe(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new yNe(l),C6(n,h)),n=h}}}class U1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),o=e.getUniformLocation(n,s.name);vNe(s,o,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let s=0,o=n.length;s!==o;++s){const l=n[s],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function P6(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const wNe=37297;let _Ne=0;function SNe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}function NNe(t){const e=Cr.getPrimaries(Cr.workingColorSpace),n=Cr.getPrimaries(t);let r;switch(e===n?r="":e===xS&&n===bS?r="LinearDisplayP3ToLinearSRGB":e===bS&&n===xS&&(r="LinearSRGBToLinearDisplayP3"),t){case Ku:case Bk:return[r,"LinearTransferOETF"];case Ia:case _O:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function j6(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
- `+i+`
- `+SNe(t.getShaderSource(e),o)}else return i}function kNe(t,e){const n=NNe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function MNe(t,e){let n;switch(e){case kve:n="Linear";break;case Mve:n="Reinhard";break;case Eve:n="OptimizedCineon";break;case Tve:n="ACESFilmic";break;case Ave:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function ENe(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(d0).join(`
- `)}function TNe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function ANe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),o=s.name;let l=1;s.type===t.FLOAT_MAT2&&(l=2),s.type===t.FLOAT_MAT3&&(l=3),s.type===t.FLOAT_MAT4&&(l=4),n[o]={type:s.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function d0(t){return t!==""}function D6(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 R6(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const CNe=/^[ \t]*#include +<([\w\d./]+)>/gm;function F3(t){return t.replace(CNe,jNe)}const PNe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function jNe(t,e){let n=Dn[e];if(n===void 0){const r=PNe.get(e);if(r!==void 0)n=Dn[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 F3(n)}const DNe=/#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 O6(t){return t.replace(DNe,RNe)}function RNe(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function L6(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function ONe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===$K?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Jye?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===pu&&(e="SHADOWMAP_TYPE_VSM"),e}function LNe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case nb:case rb:e="ENVMAP_TYPE_CUBE";break;case Uk:e="ENVMAP_TYPE_CUBE_UV";break}return e}function FNe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case rb:e="ENVMAP_MODE_REFRACTION";break}return e}function INe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case vO:e="ENVMAP_BLENDING_MULTIPLY";break;case Sve:e="ENVMAP_BLENDING_MIX";break;case Nve:e="ENVMAP_BLENDING_ADD";break}return e}function zNe(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 UNe(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=ONe(n),u=LNe(n),d=FNe(n),h=INe(n),p=zNe(n),m=n.isWebGL2?"":ENe(n),b=TNe(s),y=i.createProgram();let x,v,S=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(d0).join(`
- `),x.length>0&&(x+=`
- `),v=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(d0).join(`
- `),v.length>0&&(v+=`
- `)):(x=[L6(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(d0).join(`
- `),v=[m,L6(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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 "+h:"",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!==wh?"#define TONE_MAPPING":"",n.toneMapping!==wh?Dn.tonemapping_pars_fragment:"",n.toneMapping!==wh?MNe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Dn.colorspace_pars_fragment,kNe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(d0).join(`
- `)),o=F3(o),o=D6(o,n),o=R6(o,n),l=F3(l),l=D6(l,n),l=R6(l,n),o=O6(o),l=O6(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+x,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===e6?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===e6?"":"#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(`
- `)+`
- `+v);const N=S+x+o,T=S+v+l,M=P6(i,i.VERTEX_SHADER,N),A=P6(i,i.FRAGMENT_SHADER,T);i.attachShader(y,M),i.attachShader(y,A),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function k(U){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(y).trim(),B=i.getShaderInfoLog(M).trim(),D=i.getShaderInfoLog(A).trim();let $=!0,G=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if($=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,M,A);else{const I=j6(i,M,"vertex"),K=j6(i,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+F+`
- `+I+`
- `+K)}else F!==""?console.warn("THREE.WebGLProgram: Program Info Log:",F):(B===""||D==="")&&(G=!1);G&&(U.diagnostics={runnable:$,programLog:F,vertexShader:{log:B,prefix:x},fragmentShader:{log:D,prefix:v}})}i.deleteShader(M),i.deleteShader(A),R=new U1(i,y),C=ANe(i,y)}let R;this.getUniforms=function(){return R===void 0&&k(this),R};let C;this.getAttributes=function(){return C===void 0&&k(this),C};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(y,wNe)),P},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=_Ne++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=M,this.fragmentShader=A,this}let BNe=0;class HNe{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new $Ne(e),n.set(e,r)),r}}class $Ne{constructor(e){this.id=BNe++,this.code=e,this.usedTimes=0}}function VNe(t,e,n,r,i,s,o){const l=new sX,c=new HNe,u=[],d=i.isWebGL2,h=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(C){return C===0?"uv":`uv${C}`}function x(C,P,U,F,B){const D=F.fog,$=B.geometry,G=C.isMeshStandardMaterial?F.environment:null,I=(C.isMeshStandardMaterial?n:e).get(C.envMap||G),K=I&&I.mapping===Uk?I.image.height:null,Q=b[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const se=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=se!==void 0?se.length:0;let W=0;$.morphAttributes.position!==void 0&&(W=1),$.morphAttributes.normal!==void 0&&(W=2),$.morphAttributes.color!==void 0&&(W=3);let J,ne,xe,ue;if(Q){const fn=Bs[Q];J=fn.vertexShader,ne=fn.fragmentShader}else J=C.vertexShader,ne=C.fragmentShader,c.update(C),xe=c.getVertexShaderID(C),ue=c.getFragmentShaderID(C);const fe=t.getRenderTarget(),De=B.isInstancedMesh===!0,oe=B.isBatchedMesh===!0,Ne=!!C.map,Fe=!!C.matcap,ce=!!I,Ve=!!C.aoMap,V=!!C.lightMap,Y=!!C.bumpMap,de=!!C.normalMap,q=!!C.displacementMap,re=!!C.emissiveMap,X=!!C.metalnessMap,le=!!C.roughnessMap,pe=C.anisotropy>0,ee=C.clearcoat>0,z=C.iridescence>0,O=C.sheen>0,Z=C.transmission>0,me=pe&&!!C.anisotropyMap,Te=ee&&!!C.clearcoatMap,ke=ee&&!!C.clearcoatNormalMap,Ee=ee&&!!C.clearcoatRoughnessMap,Se=z&&!!C.iridescenceMap,$e=z&&!!C.iridescenceThicknessMap,Qe=O&&!!C.sheenColorMap,Ue=O&&!!C.sheenRoughnessMap,be=!!C.specularMap,ve=!!C.specularColorMap,ze=!!C.specularIntensityMap,Ce=Z&&!!C.transmissionMap,Ge=Z&&!!C.thicknessMap,_e=!!C.gradientMap,Je=!!C.alphaMap,Ae=C.alphaTest>0,Ke=!!C.alphaHash,je=!!C.extensions,Re=!!$.attributes.uv1,we=!!$.attributes.uv2,qe=!!$.attributes.uv3;let xt=wh;return C.toneMapped&&(fe===null||fe.isXRRenderTarget===!0)&&(xt=t.toneMapping),{isWebGL2:d,shaderID:Q,shaderType:C.type,shaderName:C.name,vertexShader:J,fragmentShader:ne,defines:C.defines,customVertexShaderID:xe,customFragmentShaderID:ue,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:oe,instancing:De,instancingColor:De&&B.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:fe===null?t.outputColorSpace:fe.isXRRenderTarget===!0?fe.texture.colorSpace:Ku,map:Ne,matcap:Fe,envMap:ce,envMapMode:ce&&I.mapping,envMapCubeUVHeight:K,aoMap:Ve,lightMap:V,bumpMap:Y,normalMap:de,displacementMap:p&&q,emissiveMap:re,normalMapObjectSpace:de&&C.normalMapType===Bve,normalMapTangentSpace:de&&C.normalMapType===JK,metalnessMap:X,roughnessMap:le,anisotropy:pe,anisotropyMap:me,clearcoat:ee,clearcoatMap:Te,clearcoatNormalMap:ke,clearcoatRoughnessMap:Ee,iridescence:z,iridescenceMap:Se,iridescenceThicknessMap:$e,sheen:O,sheenColorMap:Qe,sheenRoughnessMap:Ue,specularMap:be,specularColorMap:ve,specularIntensityMap:ze,transmission:Z,transmissionMap:Ce,thicknessMap:Ge,gradientMap:_e,opaque:C.transparent===!1&&C.blending===Lg,alphaMap:Je,alphaTest:Ae,alphaHash:Ke,combine:C.combine,mapUv:Ne&&y(C.map.channel),aoMapUv:Ve&&y(C.aoMap.channel),lightMapUv:V&&y(C.lightMap.channel),bumpMapUv:Y&&y(C.bumpMap.channel),normalMapUv:de&&y(C.normalMap.channel),displacementMapUv:q&&y(C.displacementMap.channel),emissiveMapUv:re&&y(C.emissiveMap.channel),metalnessMapUv:X&&y(C.metalnessMap.channel),roughnessMapUv:le&&y(C.roughnessMap.channel),anisotropyMapUv:me&&y(C.anisotropyMap.channel),clearcoatMapUv:Te&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:ke&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ee&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Se&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:$e&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:Qe&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Ue&&y(C.sheenRoughnessMap.channel),specularMapUv:be&&y(C.specularMap.channel),specularColorMapUv:ve&&y(C.specularColorMap.channel),specularIntensityMapUv:ze&&y(C.specularIntensityMap.channel),transmissionMapUv:Ce&&y(C.transmissionMap.channel),thicknessMapUv:Ge&&y(C.thicknessMap.channel),alphaMapUv:Je&&y(C.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(de||pe),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,vertexUv1s:Re,vertexUv2s:we,vertexUv3s:qe,pointsUvs:B.isPoints===!0&&!!$.attributes.uv&&(Ne||Je),fog:!!D,useFog:C.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:B.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:W,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:xt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Ne&&C.map.isVideoTexture===!0&&Cr.getTransfer(C.map.colorSpace)===Kr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===vu,flipSided:C.side===Gs,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:je&&C.extensions.derivatives===!0,extensionFragDepth:je&&C.extensions.fragDepth===!0,extensionDrawBuffers:je&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:je&&C.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()}}function v(C){const P=[];if(C.shaderID?P.push(C.shaderID):(P.push(C.customVertexShaderID),P.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)P.push(U),P.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(S(P,C),N(P,C),P.push(t.outputColorSpace)),P.push(C.customProgramCacheKey),P.join()}function S(C,P){C.push(P.precision),C.push(P.outputColorSpace),C.push(P.envMapMode),C.push(P.envMapCubeUVHeight),C.push(P.mapUv),C.push(P.alphaMapUv),C.push(P.lightMapUv),C.push(P.aoMapUv),C.push(P.bumpMapUv),C.push(P.normalMapUv),C.push(P.displacementMapUv),C.push(P.emissiveMapUv),C.push(P.metalnessMapUv),C.push(P.roughnessMapUv),C.push(P.anisotropyMapUv),C.push(P.clearcoatMapUv),C.push(P.clearcoatNormalMapUv),C.push(P.clearcoatRoughnessMapUv),C.push(P.iridescenceMapUv),C.push(P.iridescenceThicknessMapUv),C.push(P.sheenColorMapUv),C.push(P.sheenRoughnessMapUv),C.push(P.specularMapUv),C.push(P.specularColorMapUv),C.push(P.specularIntensityMapUv),C.push(P.transmissionMapUv),C.push(P.thicknessMapUv),C.push(P.combine),C.push(P.fogExp2),C.push(P.sizeAttenuation),C.push(P.morphTargetsCount),C.push(P.morphAttributeCount),C.push(P.numDirLights),C.push(P.numPointLights),C.push(P.numSpotLights),C.push(P.numSpotLightMaps),C.push(P.numHemiLights),C.push(P.numRectAreaLights),C.push(P.numDirLightShadows),C.push(P.numPointLightShadows),C.push(P.numSpotLightShadows),C.push(P.numSpotLightShadowsWithMaps),C.push(P.numLightProbes),C.push(P.shadowMapType),C.push(P.toneMapping),C.push(P.numClippingPlanes),C.push(P.numClipIntersection),C.push(P.depthPacking)}function N(C,P){l.disableAll(),P.isWebGL2&&l.enable(0),P.supportsVertexTextures&&l.enable(1),P.instancing&&l.enable(2),P.instancingColor&&l.enable(3),P.matcap&&l.enable(4),P.envMap&&l.enable(5),P.normalMapObjectSpace&&l.enable(6),P.normalMapTangentSpace&&l.enable(7),P.clearcoat&&l.enable(8),P.iridescence&&l.enable(9),P.alphaTest&&l.enable(10),P.vertexColors&&l.enable(11),P.vertexAlphas&&l.enable(12),P.vertexUv1s&&l.enable(13),P.vertexUv2s&&l.enable(14),P.vertexUv3s&&l.enable(15),P.vertexTangents&&l.enable(16),P.anisotropy&&l.enable(17),P.alphaHash&&l.enable(18),P.batching&&l.enable(19),C.push(l.mask),l.disableAll(),P.fog&&l.enable(0),P.useFog&&l.enable(1),P.flatShading&&l.enable(2),P.logarithmicDepthBuffer&&l.enable(3),P.skinning&&l.enable(4),P.morphTargets&&l.enable(5),P.morphNormals&&l.enable(6),P.morphColors&&l.enable(7),P.premultipliedAlpha&&l.enable(8),P.shadowMapEnabled&&l.enable(9),P.useLegacyLights&&l.enable(10),P.doubleSided&&l.enable(11),P.flipSided&&l.enable(12),P.useDepthPacking&&l.enable(13),P.dithering&&l.enable(14),P.transmission&&l.enable(15),P.sheen&&l.enable(16),P.opaque&&l.enable(17),P.pointsUvs&&l.enable(18),P.decodeVideoTexture&&l.enable(19),C.push(l.mask)}function T(C){const P=b[C.type];let U;if(P){const F=Bs[P];U=kO.clone(F.uniforms)}else U=C.uniforms;return U}function M(C,P){let U;for(let F=0,B=u.length;F<B;F++){const D=u[F];if(D.cacheKey===P){U=D,++U.usedTimes;break}}return U===void 0&&(U=new UNe(t,P,C,s),u.push(U)),U}function A(C){if(--C.usedTimes===0){const P=u.indexOf(C);u[P]=u[u.length-1],u.pop(),C.destroy()}}function k(C){c.remove(C)}function R(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:T,acquireProgram:M,releaseProgram:A,releaseShaderCache:k,programs:u,dispose:R}}function GNe(){let t=new WeakMap;function e(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function n(s){t.delete(s)}function r(s,o,l){t.get(s)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function qNe(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 F6(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 I6(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(h,p,m,b,y,x){let v=t[e];return v===void 0?(v={id:h.id,object:h,geometry:p,material:m,groupOrder:b,renderOrder:h.renderOrder,z:y,group:x},t[e]=v):(v.id=h.id,v.object=h,v.geometry=p,v.material=m,v.groupOrder=b,v.renderOrder=h.renderOrder,v.z=y,v.group=x),e++,v}function l(h,p,m,b,y,x){const v=o(h,p,m,b,y,x);m.transmission>0?r.push(v):m.transparent===!0?i.push(v):n.push(v)}function c(h,p,m,b,y,x){const v=o(h,p,m,b,y,x);m.transmission>0?r.unshift(v):m.transparent===!0?i.unshift(v):n.unshift(v)}function u(h,p){n.length>1&&n.sort(h||qNe),r.length>1&&r.sort(p||F6),i.length>1&&i.sort(p||F6)}function d(){for(let h=e,p=t.length;h<p;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function WNe(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new I6,t.set(r,[o])):i>=s.length?(o=new I6,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function KNe(){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 Ye,color:new dn};break;case"SpotLight":n={position:new Ye,direction:new Ye,color:new dn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ye,color:new dn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ye,skyColor:new dn,groundColor:new dn};break;case"RectAreaLight":n={color:new dn,position:new Ye,halfWidth:new Ye,halfHeight:new Ye};break}return t[e.id]=n,n}}}function XNe(){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 _n};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _n};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _n,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let YNe=0;function QNe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function ZNe(t,e){const n=new KNe,r=XNe(),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 Ye);const s=new Ye,o=new Vr,l=new Vr;function c(d,h){let p=0,m=0,b=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let y=0,x=0,v=0,S=0,N=0,T=0,M=0,A=0,k=0,R=0,C=0;d.sort(QNe);const P=h===!0?Math.PI:1;for(let F=0,B=d.length;F<B;F++){const D=d[F],$=D.color,G=D.intensity,I=D.distance,K=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)p+=$.r*G*P,m+=$.g*G*P,b+=$.b*G*P;else if(D.isLightProbe){for(let Q=0;Q<9;Q++)i.probe[Q].addScaledVector(D.sh.coefficients[Q],G);C++}else if(D.isDirectionalLight){const Q=n.get(D);if(Q.color.copy(D.color).multiplyScalar(D.intensity*P),D.castShadow){const se=D.shadow,H=r.get(D);H.shadowBias=se.bias,H.shadowNormalBias=se.normalBias,H.shadowRadius=se.radius,H.shadowMapSize=se.mapSize,i.directionalShadow[y]=H,i.directionalShadowMap[y]=K,i.directionalShadowMatrix[y]=D.shadow.matrix,T++}i.directional[y]=Q,y++}else if(D.isSpotLight){const Q=n.get(D);Q.position.setFromMatrixPosition(D.matrixWorld),Q.color.copy($).multiplyScalar(G*P),Q.distance=I,Q.coneCos=Math.cos(D.angle),Q.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),Q.decay=D.decay,i.spot[v]=Q;const se=D.shadow;if(D.map&&(i.spotLightMap[k]=D.map,k++,se.updateMatrices(D),D.castShadow&&R++),i.spotLightMatrix[v]=se.matrix,D.castShadow){const H=r.get(D);H.shadowBias=se.bias,H.shadowNormalBias=se.normalBias,H.shadowRadius=se.radius,H.shadowMapSize=se.mapSize,i.spotShadow[v]=H,i.spotShadowMap[v]=K,A++}v++}else if(D.isRectAreaLight){const Q=n.get(D);Q.color.copy($).multiplyScalar(G),Q.halfWidth.set(D.width*.5,0,0),Q.halfHeight.set(0,D.height*.5,0),i.rectArea[S]=Q,S++}else if(D.isPointLight){const Q=n.get(D);if(Q.color.copy(D.color).multiplyScalar(D.intensity*P),Q.distance=D.distance,Q.decay=D.decay,D.castShadow){const se=D.shadow,H=r.get(D);H.shadowBias=se.bias,H.shadowNormalBias=se.normalBias,H.shadowRadius=se.radius,H.shadowMapSize=se.mapSize,H.shadowCameraNear=se.camera.near,H.shadowCameraFar=se.camera.far,i.pointShadow[x]=H,i.pointShadowMap[x]=K,i.pointShadowMatrix[x]=D.shadow.matrix,M++}i.point[x]=Q,x++}else if(D.isHemisphereLight){const Q=n.get(D);Q.skyColor.copy(D.color).multiplyScalar(G*P),Q.groundColor.copy(D.groundColor).multiplyScalar(G*P),i.hemi[N]=Q,N++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ot.LTC_FLOAT_1,i.rectAreaLTC2=Ot.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Ot.LTC_HALF_1,i.rectAreaLTC2=Ot.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]=b;const U=i.hash;(U.directionalLength!==y||U.pointLength!==x||U.spotLength!==v||U.rectAreaLength!==S||U.hemiLength!==N||U.numDirectionalShadows!==T||U.numPointShadows!==M||U.numSpotShadows!==A||U.numSpotMaps!==k||U.numLightProbes!==C)&&(i.directional.length=y,i.spot.length=v,i.rectArea.length=S,i.point.length=x,i.hemi.length=N,i.directionalShadow.length=T,i.directionalShadowMap.length=T,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=A,i.spotShadowMap.length=A,i.directionalShadowMatrix.length=T,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=A+k-R,i.spotLightMap.length=k,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=C,U.directionalLength=y,U.pointLength=x,U.spotLength=v,U.rectAreaLength=S,U.hemiLength=N,U.numDirectionalShadows=T,U.numPointShadows=M,U.numSpotShadows=A,U.numSpotMaps=k,U.numLightProbes=C,i.version=YNe++)}function u(d,h){let p=0,m=0,b=0,y=0,x=0;const v=h.matrixWorldInverse;for(let S=0,N=d.length;S<N;S++){const T=d[S];if(T.isDirectionalLight){const M=i.directional[p];M.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(v),p++}else if(T.isSpotLight){const M=i.spot[b];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(v),M.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(v),b++}else if(T.isRectAreaLight){const M=i.rectArea[y];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(v),l.identity(),o.copy(T.matrixWorld),o.premultiply(v),l.extractRotation(o),M.halfWidth.set(T.width*.5,0,0),M.halfHeight.set(0,T.height*.5,0),M.halfWidth.applyMatrix4(l),M.halfHeight.applyMatrix4(l),y++}else if(T.isPointLight){const M=i.point[m];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(v),m++}else if(T.isHemisphereLight){const M=i.hemi[x];M.direction.setFromMatrixPosition(T.matrixWorld),M.direction.transformDirection(v),x++}}}return{setup:c,setupView:u,state:i}}function z6(t,e){const n=new ZNe(t,e),r=[],i=[];function s(){r.length=0,i.length=0}function o(h){r.push(h)}function l(h){i.push(h)}function c(h){n.setup(r,h)}function u(h){n.setupView(r,h)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function JNe(t,e){let n=new WeakMap;function r(s,o=0){const l=n.get(s);let c;return l===void 0?(c=new z6(t,e),n.set(s,[c])):o>=l.length?(c=new z6(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class eke extends Pb{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=zve,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 tke extends Pb{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 nke=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,rke=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function ike(t,e,n){let r=new Hk;const i=new _n,s=new _n,o=new jr,l=new eke({depthPacking:Uve}),c=new tke,u={},d=n.maxTextureSize,h={[Rh]:Gs,[Gs]:Rh,[vu]:vu},p=new Oh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new _n},radius:{value:4}},vertexShader:nke,fragmentShader:rke}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const b=new ss;b.setAttribute("position",new No(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Il(b,p),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=$K;let v=this.type;this.render=function(M,A,k){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||M.length===0)return;const R=t.getRenderTarget(),C=t.getActiveCubeFace(),P=t.getActiveMipmapLevel(),U=t.state;U.setBlending(vh),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const F=v!==pu&&this.type===pu,B=v===pu&&this.type!==pu;for(let D=0,$=M.length;D<$;D++){const G=M[D],I=G.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",G,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;i.copy(I.mapSize);const K=I.getFrameExtents();if(i.multiply(K),s.copy(I.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/K.x),i.x=s.x*K.x,I.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/K.y),i.y=s.y*K.y,I.mapSize.y=s.y)),I.map===null||F===!0||B===!0){const se=this.type!==pu?{minFilter:Fa,magFilter:Fa}:{};I.map!==null&&I.map.dispose(),I.map=new _m(i.x,i.y,se),I.map.texture.name=G.name+".shadowMap",I.camera.updateProjectionMatrix()}t.setRenderTarget(I.map),t.clear();const Q=I.getViewportCount();for(let se=0;se<Q;se++){const H=I.getViewport(se);o.set(s.x*H.x,s.y*H.y,s.x*H.z,s.y*H.w),U.viewport(o),I.updateMatrices(G,se),r=I.getFrustum(),T(A,k,I.camera,G,this.type)}I.isPointLightShadow!==!0&&this.type===pu&&S(I,k),I.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(R,C,P)};function S(M,A){const k=e.update(y);p.defines.VSM_SAMPLES!==M.blurSamples&&(p.defines.VSM_SAMPLES=M.blurSamples,m.defines.VSM_SAMPLES=M.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),M.mapPass===null&&(M.mapPass=new _m(i.x,i.y)),p.uniforms.shadow_pass.value=M.map.texture,p.uniforms.resolution.value=M.mapSize,p.uniforms.radius.value=M.radius,t.setRenderTarget(M.mapPass),t.clear(),t.renderBufferDirect(A,null,k,p,y,null),m.uniforms.shadow_pass.value=M.mapPass.texture,m.uniforms.resolution.value=M.mapSize,m.uniforms.radius.value=M.radius,t.setRenderTarget(M.map),t.clear(),t.renderBufferDirect(A,null,k,m,y,null)}function N(M,A,k,R){let C=null;const P=k.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(P!==void 0)C=P;else if(C=k.isPointLight===!0?c:l,t.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0){const U=C.uuid,F=A.uuid;let B=u[U];B===void 0&&(B={},u[U]=B);let D=B[F];D===void 0&&(D=C.clone(),B[F]=D),C=D}if(C.visible=A.visible,C.wireframe=A.wireframe,R===pu?C.side=A.shadowSide!==null?A.shadowSide:A.side:C.side=A.shadowSide!==null?A.shadowSide:h[A.side],C.alphaMap=A.alphaMap,C.alphaTest=A.alphaTest,C.map=A.map,C.clipShadows=A.clipShadows,C.clippingPlanes=A.clippingPlanes,C.clipIntersection=A.clipIntersection,C.displacementMap=A.displacementMap,C.displacementScale=A.displacementScale,C.displacementBias=A.displacementBias,C.wireframeLinewidth=A.wireframeLinewidth,C.linewidth=A.linewidth,k.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const U=t.properties.get(C);U.light=k}return C}function T(M,A,k,R,C){if(M.visible===!1)return;if(M.layers.test(A.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&C===pu)&&(!M.frustumCulled||r.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,M.matrixWorld);const F=e.update(M),B=M.material;if(Array.isArray(B)){const D=F.groups;for(let $=0,G=D.length;$<G;$++){const I=D[$],K=B[I.materialIndex];if(K&&K.visible){const Q=N(M,K,R,C);M.onBeforeShadow(t,M,A,k,F,Q,I),t.renderBufferDirect(k,null,F,Q,M,I),M.onAfterShadow(t,M,A,k,F,Q,I)}}}else if(B.visible){const D=N(M,B,R,C);M.onBeforeShadow(t,M,A,k,F,D,null),t.renderBufferDirect(k,null,F,D,M,null),M.onAfterShadow(t,M,A,k,F,D,null)}}const U=M.children;for(let F=0,B=U.length;F<B;F++)T(U[F],A,k,R,C)}}function ake(t,e,n){const r=n.isWebGL2;function i(){let Ae=!1;const Ke=new jr;let je=null;const Re=new jr(0,0,0,0);return{setMask:function(we){je!==we&&!Ae&&(t.colorMask(we,we,we,we),je=we)},setLocked:function(we){Ae=we},setClear:function(we,qe,xt,Et,fn){fn===!0&&(we*=Et,qe*=Et,xt*=Et),Ke.set(we,qe,xt,Et),Re.equals(Ke)===!1&&(t.clearColor(we,qe,xt,Et),Re.copy(Ke))},reset:function(){Ae=!1,je=null,Re.set(-1,0,0,0)}}}function s(){let Ae=!1,Ke=null,je=null,Re=null;return{setTest:function(we){we?oe(t.DEPTH_TEST):Ne(t.DEPTH_TEST)},setMask:function(we){Ke!==we&&!Ae&&(t.depthMask(we),Ke=we)},setFunc:function(we){if(je!==we){switch(we){case gve:t.depthFunc(t.NEVER);break;case bve:t.depthFunc(t.ALWAYS);break;case xve:t.depthFunc(t.LESS);break;case pS:t.depthFunc(t.LEQUAL);break;case yve:t.depthFunc(t.EQUAL);break;case vve:t.depthFunc(t.GEQUAL);break;case wve:t.depthFunc(t.GREATER);break;case _ve:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}je=we}},setLocked:function(we){Ae=we},setClear:function(we){Re!==we&&(t.clearDepth(we),Re=we)},reset:function(){Ae=!1,Ke=null,je=null,Re=null}}}function o(){let Ae=!1,Ke=null,je=null,Re=null,we=null,qe=null,xt=null,Et=null,fn=null;return{setTest:function(It){Ae||(It?oe(t.STENCIL_TEST):Ne(t.STENCIL_TEST))},setMask:function(It){Ke!==It&&!Ae&&(t.stencilMask(It),Ke=It)},setFunc:function(It,Oe,yt){(je!==It||Re!==Oe||we!==yt)&&(t.stencilFunc(It,Oe,yt),je=It,Re=Oe,we=yt)},setOp:function(It,Oe,yt){(qe!==It||xt!==Oe||Et!==yt)&&(t.stencilOp(It,Oe,yt),qe=It,xt=Oe,Et=yt)},setLocked:function(It){Ae=It},setClear:function(It){fn!==It&&(t.clearStencil(It),fn=It)},reset:function(){Ae=!1,Ke=null,je=null,Re=null,we=null,qe=null,xt=null,Et=null,fn=null}}}const l=new i,c=new s,u=new o,d=new WeakMap,h=new WeakMap;let p={},m={},b=new WeakMap,y=[],x=null,v=!1,S=null,N=null,T=null,M=null,A=null,k=null,R=null,C=new dn(0,0,0),P=0,U=!1,F=null,B=null,D=null,$=null,G=null;const I=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,Q=0;const se=t.getParameter(t.VERSION);se.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(se)[1]),K=Q>=1):se.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),K=Q>=2);let H=null,W={};const J=t.getParameter(t.SCISSOR_BOX),ne=t.getParameter(t.VIEWPORT),xe=new jr().fromArray(J),ue=new jr().fromArray(ne);function fe(Ae,Ke,je,Re){const we=new Uint8Array(4),qe=t.createTexture();t.bindTexture(Ae,qe),t.texParameteri(Ae,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Ae,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let xt=0;xt<je;xt++)r&&(Ae===t.TEXTURE_3D||Ae===t.TEXTURE_2D_ARRAY)?t.texImage3D(Ke,0,t.RGBA,1,1,Re,0,t.RGBA,t.UNSIGNED_BYTE,we):t.texImage2D(Ke+xt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,we);return qe}const De={};De[t.TEXTURE_2D]=fe(t.TEXTURE_2D,t.TEXTURE_2D,1),De[t.TEXTURE_CUBE_MAP]=fe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(De[t.TEXTURE_2D_ARRAY]=fe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),De[t.TEXTURE_3D]=fe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),oe(t.DEPTH_TEST),c.setFunc(pS),re(!1),X(w8),oe(t.CULL_FACE),de(vh);function oe(Ae){p[Ae]!==!0&&(t.enable(Ae),p[Ae]=!0)}function Ne(Ae){p[Ae]!==!1&&(t.disable(Ae),p[Ae]=!1)}function Fe(Ae,Ke){return m[Ae]!==Ke?(t.bindFramebuffer(Ae,Ke),m[Ae]=Ke,r&&(Ae===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Ke),Ae===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Ke)),!0):!1}function ce(Ae,Ke){let je=y,Re=!1;if(Ae)if(je=b.get(Ke),je===void 0&&(je=[],b.set(Ke,je)),Ae.isWebGLMultipleRenderTargets){const we=Ae.texture;if(je.length!==we.length||je[0]!==t.COLOR_ATTACHMENT0){for(let qe=0,xt=we.length;qe<xt;qe++)je[qe]=t.COLOR_ATTACHMENT0+qe;je.length=we.length,Re=!0}}else je[0]!==t.COLOR_ATTACHMENT0&&(je[0]=t.COLOR_ATTACHMENT0,Re=!0);else je[0]!==t.BACK&&(je[0]=t.BACK,Re=!0);Re&&(n.isWebGL2?t.drawBuffers(je):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(je))}function Ve(Ae){return x!==Ae?(t.useProgram(Ae),x=Ae,!0):!1}const V={[Ff]:t.FUNC_ADD,[tve]:t.FUNC_SUBTRACT,[nve]:t.FUNC_REVERSE_SUBTRACT};if(r)V[k8]=t.MIN,V[M8]=t.MAX;else{const Ae=e.get("EXT_blend_minmax");Ae!==null&&(V[k8]=Ae.MIN_EXT,V[M8]=Ae.MAX_EXT)}const Y={[rve]:t.ZERO,[ive]:t.ONE,[ave]:t.SRC_COLOR,[T3]:t.SRC_ALPHA,[dve]:t.SRC_ALPHA_SATURATE,[cve]:t.DST_COLOR,[ove]:t.DST_ALPHA,[sve]:t.ONE_MINUS_SRC_COLOR,[A3]:t.ONE_MINUS_SRC_ALPHA,[uve]:t.ONE_MINUS_DST_COLOR,[lve]:t.ONE_MINUS_DST_ALPHA,[hve]:t.CONSTANT_COLOR,[fve]:t.ONE_MINUS_CONSTANT_COLOR,[mve]:t.CONSTANT_ALPHA,[pve]:t.ONE_MINUS_CONSTANT_ALPHA};function de(Ae,Ke,je,Re,we,qe,xt,Et,fn,It){if(Ae===vh){v===!0&&(Ne(t.BLEND),v=!1);return}if(v===!1&&(oe(t.BLEND),v=!0),Ae!==eve){if(Ae!==S||It!==U){if((N!==Ff||A!==Ff)&&(t.blendEquation(t.FUNC_ADD),N=Ff,A=Ff),It)switch(Ae){case Lg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case _8:t.blendFunc(t.ONE,t.ONE);break;case S8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case N8:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",Ae);break}else switch(Ae){case Lg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case _8:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case S8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case N8:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",Ae);break}T=null,M=null,k=null,R=null,C.set(0,0,0),P=0,S=Ae,U=It}return}we=we||Ke,qe=qe||je,xt=xt||Re,(Ke!==N||we!==A)&&(t.blendEquationSeparate(V[Ke],V[we]),N=Ke,A=we),(je!==T||Re!==M||qe!==k||xt!==R)&&(t.blendFuncSeparate(Y[je],Y[Re],Y[qe],Y[xt]),T=je,M=Re,k=qe,R=xt),(Et.equals(C)===!1||fn!==P)&&(t.blendColor(Et.r,Et.g,Et.b,fn),C.copy(Et),P=fn),S=Ae,U=!1}function q(Ae,Ke){Ae.side===vu?Ne(t.CULL_FACE):oe(t.CULL_FACE);let je=Ae.side===Gs;Ke&&(je=!je),re(je),Ae.blending===Lg&&Ae.transparent===!1?de(vh):de(Ae.blending,Ae.blendEquation,Ae.blendSrc,Ae.blendDst,Ae.blendEquationAlpha,Ae.blendSrcAlpha,Ae.blendDstAlpha,Ae.blendColor,Ae.blendAlpha,Ae.premultipliedAlpha),c.setFunc(Ae.depthFunc),c.setTest(Ae.depthTest),c.setMask(Ae.depthWrite),l.setMask(Ae.colorWrite);const Re=Ae.stencilWrite;u.setTest(Re),Re&&(u.setMask(Ae.stencilWriteMask),u.setFunc(Ae.stencilFunc,Ae.stencilRef,Ae.stencilFuncMask),u.setOp(Ae.stencilFail,Ae.stencilZFail,Ae.stencilZPass)),pe(Ae.polygonOffset,Ae.polygonOffsetFactor,Ae.polygonOffsetUnits),Ae.alphaToCoverage===!0?oe(t.SAMPLE_ALPHA_TO_COVERAGE):Ne(t.SAMPLE_ALPHA_TO_COVERAGE)}function re(Ae){F!==Ae&&(Ae?t.frontFace(t.CW):t.frontFace(t.CCW),F=Ae)}function X(Ae){Ae!==Qye?(oe(t.CULL_FACE),Ae!==B&&(Ae===w8?t.cullFace(t.BACK):Ae===Zye?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ne(t.CULL_FACE),B=Ae}function le(Ae){Ae!==D&&(K&&t.lineWidth(Ae),D=Ae)}function pe(Ae,Ke,je){Ae?(oe(t.POLYGON_OFFSET_FILL),($!==Ke||G!==je)&&(t.polygonOffset(Ke,je),$=Ke,G=je)):Ne(t.POLYGON_OFFSET_FILL)}function ee(Ae){Ae?oe(t.SCISSOR_TEST):Ne(t.SCISSOR_TEST)}function z(Ae){Ae===void 0&&(Ae=t.TEXTURE0+I-1),H!==Ae&&(t.activeTexture(Ae),H=Ae)}function O(Ae,Ke,je){je===void 0&&(H===null?je=t.TEXTURE0+I-1:je=H);let Re=W[je];Re===void 0&&(Re={type:void 0,texture:void 0},W[je]=Re),(Re.type!==Ae||Re.texture!==Ke)&&(H!==je&&(t.activeTexture(je),H=je),t.bindTexture(Ae,Ke||De[Ae]),Re.type=Ae,Re.texture=Ke)}function Z(){const Ae=W[H];Ae!==void 0&&Ae.type!==void 0&&(t.bindTexture(Ae.type,null),Ae.type=void 0,Ae.texture=void 0)}function me(){try{t.compressedTexImage2D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function Te(){try{t.compressedTexImage3D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function ke(){try{t.texSubImage2D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function Ee(){try{t.texSubImage3D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function Se(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function $e(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function Qe(){try{t.texStorage2D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function Ue(){try{t.texStorage3D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function be(){try{t.texImage2D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function ve(){try{t.texImage3D.apply(t,arguments)}catch(Ae){console.error("THREE.WebGLState:",Ae)}}function ze(Ae){xe.equals(Ae)===!1&&(t.scissor(Ae.x,Ae.y,Ae.z,Ae.w),xe.copy(Ae))}function Ce(Ae){ue.equals(Ae)===!1&&(t.viewport(Ae.x,Ae.y,Ae.z,Ae.w),ue.copy(Ae))}function Ge(Ae,Ke){let je=h.get(Ke);je===void 0&&(je=new WeakMap,h.set(Ke,je));let Re=je.get(Ae);Re===void 0&&(Re=t.getUniformBlockIndex(Ke,Ae.name),je.set(Ae,Re))}function _e(Ae,Ke){const Re=h.get(Ke).get(Ae);d.get(Ke)!==Re&&(t.uniformBlockBinding(Ke,Re,Ae.__bindingPointIndex),d.set(Ke,Re))}function Je(){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={},H=null,W={},m={},b=new WeakMap,y=[],x=null,v=!1,S=null,N=null,T=null,M=null,A=null,k=null,R=null,C=new dn(0,0,0),P=0,U=!1,F=null,B=null,D=null,$=null,G=null,xe.set(0,0,t.canvas.width,t.canvas.height),ue.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:oe,disable:Ne,bindFramebuffer:Fe,drawBuffers:ce,useProgram:Ve,setBlending:de,setMaterial:q,setFlipSided:re,setCullFace:X,setLineWidth:le,setPolygonOffset:pe,setScissorTest:ee,activeTexture:z,bindTexture:O,unbindTexture:Z,compressedTexImage2D:me,compressedTexImage3D:Te,texImage2D:be,texImage3D:ve,updateUBOMapping:Ge,uniformBlockBinding:_e,texStorage2D:Qe,texStorage3D:Ue,texSubImage2D:ke,texSubImage3D:Ee,compressedTexSubImage2D:Se,compressedTexSubImage3D:$e,scissor:ze,viewport:Ce,reset:Je}}function ske(t,e,n,r,i,s,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,h=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),b=new WeakMap;let y;const x=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):vS("canvas")}function N(z,O,Z,me){let Te=1;if((z.width>me||z.height>me)&&(Te=me/Math.max(z.width,z.height)),Te<1||O===!0)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap){const ke=O?yS:Math.floor,Ee=ke(Te*z.width),Se=ke(Te*z.height);y===void 0&&(y=S(Ee,Se));const $e=Z?S(Ee,Se):y;return $e.width=Ee,$e.height=Se,$e.getContext("2d").drawImage(z,0,0,Ee,Se),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+Ee+"x"+Se+")."),$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 L3(z.width)&&L3(z.height)}function M(z){return l?!1:z.wrapS!==jl||z.wrapT!==jl||z.minFilter!==Fa&&z.minFilter!==el}function A(z,O){return z.generateMipmaps&&O&&z.minFilter!==Fa&&z.minFilter!==el}function k(z){t.generateMipmap(z)}function R(z,O,Z,me,Te=!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 ke=O;if(O===t.RED&&(Z===t.FLOAT&&(ke=t.R32F),Z===t.HALF_FLOAT&&(ke=t.R16F),Z===t.UNSIGNED_BYTE&&(ke=t.R8)),O===t.RED_INTEGER&&(Z===t.UNSIGNED_BYTE&&(ke=t.R8UI),Z===t.UNSIGNED_SHORT&&(ke=t.R16UI),Z===t.UNSIGNED_INT&&(ke=t.R32UI),Z===t.BYTE&&(ke=t.R8I),Z===t.SHORT&&(ke=t.R16I),Z===t.INT&&(ke=t.R32I)),O===t.RG&&(Z===t.FLOAT&&(ke=t.RG32F),Z===t.HALF_FLOAT&&(ke=t.RG16F),Z===t.UNSIGNED_BYTE&&(ke=t.RG8)),O===t.RGBA){const Ee=Te?gS:Cr.getTransfer(me);Z===t.FLOAT&&(ke=t.RGBA32F),Z===t.HALF_FLOAT&&(ke=t.RGBA16F),Z===t.UNSIGNED_BYTE&&(ke=Ee===Kr?t.SRGB8_ALPHA8:t.RGBA8),Z===t.UNSIGNED_SHORT_4_4_4_4&&(ke=t.RGBA4),Z===t.UNSIGNED_SHORT_5_5_5_1&&(ke=t.RGB5_A1)}return(ke===t.R16F||ke===t.R32F||ke===t.RG16F||ke===t.RG32F||ke===t.RGBA16F||ke===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ke}function C(z,O,Z){return A(z,Z)===!0||z.isFramebufferTexture&&z.minFilter!==Fa&&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 P(z){return z===Fa||z===E8||z===JT?t.NEAREST:t.LINEAR}function U(z){const O=z.target;O.removeEventListener("dispose",U),B(O),O.isVideoTexture&&b.delete(O)}function F(z){const O=z.target;O.removeEventListener("dispose",F),$(O)}function B(z){const O=r.get(z);if(O.__webglInit===void 0)return;const Z=z.source,me=x.get(Z);if(me){const Te=me[O.__cacheKey];Te.usedTimes--,Te.usedTimes===0&&D(z),Object.keys(me).length===0&&x.delete(Z)}r.remove(z)}function D(z){const O=r.get(z);t.deleteTexture(O.__webglTexture);const Z=z.source,me=x.get(Z);delete me[O.__cacheKey],o.memory.textures--}function $(z){const O=z.texture,Z=r.get(z),me=r.get(O);if(me.__webglTexture!==void 0&&(t.deleteTexture(me.__webglTexture),o.memory.textures--),z.depthTexture&&z.depthTexture.dispose(),z.isWebGLCubeRenderTarget)for(let Te=0;Te<6;Te++){if(Array.isArray(Z.__webglFramebuffer[Te]))for(let ke=0;ke<Z.__webglFramebuffer[Te].length;ke++)t.deleteFramebuffer(Z.__webglFramebuffer[Te][ke]);else t.deleteFramebuffer(Z.__webglFramebuffer[Te]);Z.__webglDepthbuffer&&t.deleteRenderbuffer(Z.__webglDepthbuffer[Te])}else{if(Array.isArray(Z.__webglFramebuffer))for(let Te=0;Te<Z.__webglFramebuffer.length;Te++)t.deleteFramebuffer(Z.__webglFramebuffer[Te]);else t.deleteFramebuffer(Z.__webglFramebuffer);if(Z.__webglDepthbuffer&&t.deleteRenderbuffer(Z.__webglDepthbuffer),Z.__webglMultisampledFramebuffer&&t.deleteFramebuffer(Z.__webglMultisampledFramebuffer),Z.__webglColorRenderbuffer)for(let Te=0;Te<Z.__webglColorRenderbuffer.length;Te++)Z.__webglColorRenderbuffer[Te]&&t.deleteRenderbuffer(Z.__webglColorRenderbuffer[Te]);Z.__webglDepthRenderbuffer&&t.deleteRenderbuffer(Z.__webglDepthRenderbuffer)}if(z.isWebGLMultipleRenderTargets)for(let Te=0,ke=O.length;Te<ke;Te++){const Ee=r.get(O[Te]);Ee.__webglTexture&&(t.deleteTexture(Ee.__webglTexture),o.memory.textures--),r.remove(O[Te])}r.remove(O),r.remove(z)}let G=0;function I(){G=0}function K(){const z=G;return z>=c&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+c),G+=1,z}function Q(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 se(z,O){const Z=r.get(z);if(z.isVideoTexture&&pe(z),z.isRenderTargetTexture===!1&&z.version>0&&Z.__version!==z.version){const me=z.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{oe(Z,z,O);return}}n.bindTexture(t.TEXTURE_2D,Z.__webglTexture,t.TEXTURE0+O)}function H(z,O){const Z=r.get(z);if(z.version>0&&Z.__version!==z.version){oe(Z,z,O);return}n.bindTexture(t.TEXTURE_2D_ARRAY,Z.__webglTexture,t.TEXTURE0+O)}function W(z,O){const Z=r.get(z);if(z.version>0&&Z.__version!==z.version){oe(Z,z,O);return}n.bindTexture(t.TEXTURE_3D,Z.__webglTexture,t.TEXTURE0+O)}function J(z,O){const Z=r.get(z);if(z.version>0&&Z.__version!==z.version){Ne(Z,z,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Z.__webglTexture,t.TEXTURE0+O)}const ne={[j3]:t.REPEAT,[jl]:t.CLAMP_TO_EDGE,[D3]:t.MIRRORED_REPEAT},xe={[Fa]:t.NEAREST,[E8]:t.NEAREST_MIPMAP_NEAREST,[JT]:t.NEAREST_MIPMAP_LINEAR,[el]:t.LINEAR,[Cve]:t.LINEAR_MIPMAP_NEAREST,[sy]:t.LINEAR_MIPMAP_LINEAR},ue={[Hve]:t.NEVER,[Kve]:t.ALWAYS,[$ve]:t.LESS,[eX]:t.LEQUAL,[Vve]:t.EQUAL,[Wve]:t.GEQUAL,[Gve]:t.GREATER,[qve]:t.NOTEQUAL};function fe(z,O,Z){if(Z?(t.texParameteri(z,t.TEXTURE_WRAP_S,ne[O.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,ne[O.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,ne[O.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,xe[O.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,xe[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!==jl||O.wrapT!==jl)&&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,P(O.magFilter)),t.texParameteri(z,t.TEXTURE_MIN_FILTER,P(O.minFilter)),O.minFilter!==Fa&&O.minFilter!==el&&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,ue[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const me=e.get("EXT_texture_filter_anisotropic");if(O.magFilter===Fa||O.minFilter!==JT&&O.minFilter!==sy||O.type===Eu&&e.has("OES_texture_float_linear")===!1||l===!1&&O.type===oy&&e.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(t.texParameterf(z,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function De(z,O){let Z=!1;z.__webglInit===void 0&&(z.__webglInit=!0,O.addEventListener("dispose",U));const me=O.source;let Te=x.get(me);Te===void 0&&(Te={},x.set(me,Te));const ke=Q(O);if(ke!==z.__cacheKey){Te[ke]===void 0&&(Te[ke]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Z=!0),Te[ke].usedTimes++;const Ee=Te[z.__cacheKey];Ee!==void 0&&(Te[z.__cacheKey].usedTimes--,Ee.usedTimes===0&&D(O)),z.__cacheKey=ke,z.__webglTexture=Te[ke].texture}return Z}function oe(z,O,Z){let me=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(me=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(me=t.TEXTURE_3D);const Te=De(z,O),ke=O.source;n.bindTexture(me,z.__webglTexture,t.TEXTURE0+Z);const Ee=r.get(ke);if(ke.version!==Ee.__version||Te===!0){n.activeTexture(t.TEXTURE0+Z);const Se=Cr.getPrimaries(Cr.workingColorSpace),$e=O.colorSpace===nl?null:Cr.getPrimaries(O.colorSpace),Qe=O.colorSpace===nl||Se===$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,Qe);const Ue=M(O)&&T(O.image)===!1;let be=N(O.image,Ue,!1,d);be=ee(O,be);const ve=T(be)||l,ze=s.convert(O.format,O.colorSpace);let Ce=s.convert(O.type),Ge=R(O.internalFormat,ze,Ce,O.colorSpace,O.isVideoTexture);fe(me,O,ve);let _e;const Je=O.mipmaps,Ae=l&&O.isVideoTexture!==!0&&Ge!==QK,Ke=Ee.__version===void 0||Te===!0,je=C(O,be,ve);if(O.isDepthTexture)Ge=t.DEPTH_COMPONENT,l?O.type===Eu?Ge=t.DEPTH_COMPONENT32F:O.type===ch?Ge=t.DEPTH_COMPONENT24:O.type===Jf?Ge=t.DEPTH24_STENCIL8:Ge=t.DEPTH_COMPONENT16:O.type===Eu&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===em&&Ge===t.DEPTH_COMPONENT&&O.type!==wO&&O.type!==ch&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=ch,Ce=s.convert(O.type)),O.format===ib&&Ge===t.DEPTH_COMPONENT&&(Ge=t.DEPTH_STENCIL,O.type!==Jf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Jf,Ce=s.convert(O.type))),Ke&&(Ae?n.texStorage2D(t.TEXTURE_2D,1,Ge,be.width,be.height):n.texImage2D(t.TEXTURE_2D,0,Ge,be.width,be.height,0,ze,Ce,null));else if(O.isDataTexture)if(Je.length>0&&ve){Ae&&Ke&&n.texStorage2D(t.TEXTURE_2D,je,Ge,Je[0].width,Je[0].height);for(let Re=0,we=Je.length;Re<we;Re++)_e=Je[Re],Ae?n.texSubImage2D(t.TEXTURE_2D,Re,0,0,_e.width,_e.height,ze,Ce,_e.data):n.texImage2D(t.TEXTURE_2D,Re,Ge,_e.width,_e.height,0,ze,Ce,_e.data);O.generateMipmaps=!1}else Ae?(Ke&&n.texStorage2D(t.TEXTURE_2D,je,Ge,be.width,be.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,be.width,be.height,ze,Ce,be.data)):n.texImage2D(t.TEXTURE_2D,0,Ge,be.width,be.height,0,ze,Ce,be.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ae&&Ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,je,Ge,Je[0].width,Je[0].height,be.depth);for(let Re=0,we=Je.length;Re<we;Re++)_e=Je[Re],O.format!==tl?ze!==null?Ae?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,0,_e.width,_e.height,be.depth,ze,_e.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Re,Ge,_e.width,_e.height,be.depth,0,_e.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ae?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,0,_e.width,_e.height,be.depth,ze,Ce,_e.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Re,Ge,_e.width,_e.height,be.depth,0,ze,Ce,_e.data)}else{Ae&&Ke&&n.texStorage2D(t.TEXTURE_2D,je,Ge,Je[0].width,Je[0].height);for(let Re=0,we=Je.length;Re<we;Re++)_e=Je[Re],O.format!==tl?ze!==null?Ae?n.compressedTexSubImage2D(t.TEXTURE_2D,Re,0,0,_e.width,_e.height,ze,_e.data):n.compressedTexImage2D(t.TEXTURE_2D,Re,Ge,_e.width,_e.height,0,_e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ae?n.texSubImage2D(t.TEXTURE_2D,Re,0,0,_e.width,_e.height,ze,Ce,_e.data):n.texImage2D(t.TEXTURE_2D,Re,Ge,_e.width,_e.height,0,ze,Ce,_e.data)}else if(O.isDataArrayTexture)Ae?(Ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,je,Ge,be.width,be.height,be.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,be.width,be.height,be.depth,ze,Ce,be.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ge,be.width,be.height,be.depth,0,ze,Ce,be.data);else if(O.isData3DTexture)Ae?(Ke&&n.texStorage3D(t.TEXTURE_3D,je,Ge,be.width,be.height,be.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,be.width,be.height,be.depth,ze,Ce,be.data)):n.texImage3D(t.TEXTURE_3D,0,Ge,be.width,be.height,be.depth,0,ze,Ce,be.data);else if(O.isFramebufferTexture){if(Ke)if(Ae)n.texStorage2D(t.TEXTURE_2D,je,Ge,be.width,be.height);else{let Re=be.width,we=be.height;for(let qe=0;qe<je;qe++)n.texImage2D(t.TEXTURE_2D,qe,Ge,Re,we,0,ze,Ce,null),Re>>=1,we>>=1}}else if(Je.length>0&&ve){Ae&&Ke&&n.texStorage2D(t.TEXTURE_2D,je,Ge,Je[0].width,Je[0].height);for(let Re=0,we=Je.length;Re<we;Re++)_e=Je[Re],Ae?n.texSubImage2D(t.TEXTURE_2D,Re,0,0,ze,Ce,_e):n.texImage2D(t.TEXTURE_2D,Re,Ge,ze,Ce,_e);O.generateMipmaps=!1}else Ae?(Ke&&n.texStorage2D(t.TEXTURE_2D,je,Ge,be.width,be.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ze,Ce,be)):n.texImage2D(t.TEXTURE_2D,0,Ge,ze,Ce,be);A(O,ve)&&k(me),Ee.__version=ke.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Ne(z,O,Z){if(O.image.length!==6)return;const me=De(z,O),Te=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+Z);const ke=r.get(Te);if(Te.version!==ke.__version||me===!0){n.activeTexture(t.TEXTURE0+Z);const Ee=Cr.getPrimaries(Cr.workingColorSpace),Se=O.colorSpace===nl?null:Cr.getPrimaries(O.colorSpace),$e=O.colorSpace===nl||Ee===Se?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 Qe=O.isCompressedTexture||O.image[0].isCompressedTexture,Ue=O.image[0]&&O.image[0].isDataTexture,be=[];for(let Re=0;Re<6;Re++)!Qe&&!Ue?be[Re]=N(O.image[Re],!1,!0,u):be[Re]=Ue?O.image[Re].image:O.image[Re],be[Re]=ee(O,be[Re]);const ve=be[0],ze=T(ve)||l,Ce=s.convert(O.format,O.colorSpace),Ge=s.convert(O.type),_e=R(O.internalFormat,Ce,Ge,O.colorSpace),Je=l&&O.isVideoTexture!==!0,Ae=ke.__version===void 0||me===!0;let Ke=C(O,ve,ze);fe(t.TEXTURE_CUBE_MAP,O,ze);let je;if(Qe){Je&&Ae&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ke,_e,ve.width,ve.height);for(let Re=0;Re<6;Re++){je=be[Re].mipmaps;for(let we=0;we<je.length;we++){const qe=je[we];O.format!==tl?Ce!==null?Je?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we,0,0,qe.width,qe.height,Ce,qe.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we,_e,qe.width,qe.height,0,qe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we,0,0,qe.width,qe.height,Ce,Ge,qe.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we,_e,qe.width,qe.height,0,Ce,Ge,qe.data)}}}else{je=O.mipmaps,Je&&Ae&&(je.length>0&&Ke++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Ke,_e,be[0].width,be[0].height));for(let Re=0;Re<6;Re++)if(Ue){Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,0,0,be[Re].width,be[Re].height,Ce,Ge,be[Re].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,_e,be[Re].width,be[Re].height,0,Ce,Ge,be[Re].data);for(let we=0;we<je.length;we++){const xt=je[we].image[Re].image;Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we+1,0,0,xt.width,xt.height,Ce,Ge,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we+1,_e,xt.width,xt.height,0,Ce,Ge,xt.data)}}else{Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,0,0,Ce,Ge,be[Re]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0,_e,Ce,Ge,be[Re]);for(let we=0;we<je.length;we++){const qe=je[we];Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we+1,0,0,Ce,Ge,qe.image[Re]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,we+1,_e,Ce,Ge,qe.image[Re])}}}A(O,ze)&&k(t.TEXTURE_CUBE_MAP),ke.__version=Te.version,O.onUpdate&&O.onUpdate(O)}z.__version=O.version}function Fe(z,O,Z,me,Te,ke){const Ee=s.convert(Z.format,Z.colorSpace),Se=s.convert(Z.type),$e=R(Z.internalFormat,Ee,Se,Z.colorSpace);if(!r.get(O).__hasExternalTextures){const Ue=Math.max(1,O.width>>ke),be=Math.max(1,O.height>>ke);Te===t.TEXTURE_3D||Te===t.TEXTURE_2D_ARRAY?n.texImage3D(Te,ke,$e,Ue,be,O.depth,0,Ee,Se,null):n.texImage2D(Te,ke,$e,Ue,be,0,Ee,Se,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),le(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,me,Te,r.get(Z).__webglTexture,0,X(O)):(Te===t.TEXTURE_2D||Te>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Te<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,me,Te,r.get(Z).__webglTexture,ke),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ce(z,O,Z){if(t.bindRenderbuffer(t.RENDERBUFFER,z),O.depthBuffer&&!O.stencilBuffer){let me=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(Z||le(O)){const Te=O.depthTexture;Te&&Te.isDepthTexture&&(Te.type===Eu?me=t.DEPTH_COMPONENT32F:Te.type===ch&&(me=t.DEPTH_COMPONENT24));const ke=X(O);le(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ke,me,O.width,O.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ke,me,O.width,O.height)}else t.renderbufferStorage(t.RENDERBUFFER,me,O.width,O.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,z)}else if(O.depthBuffer&&O.stencilBuffer){const me=X(O);Z&&le(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,me,t.DEPTH24_STENCIL8,O.width,O.height):le(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,me,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 me=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let Te=0;Te<me.length;Te++){const ke=me[Te],Ee=s.convert(ke.format,ke.colorSpace),Se=s.convert(ke.type),$e=R(ke.internalFormat,Ee,Se,ke.colorSpace),Qe=X(O);Z&&le(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Qe,$e,O.width,O.height):le(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Qe,$e,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,$e,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ve(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),se(O.depthTexture,0);const me=r.get(O.depthTexture).__webglTexture,Te=X(O);if(O.depthTexture.format===em)le(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,me,0,Te):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,me,0);else if(O.depthTexture.format===ib)le(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,me,0,Te):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,me,0);else throw new Error("Unknown depthTexture format")}function V(z){const O=r.get(z),Z=z.isWebGLCubeRenderTarget===!0;if(z.depthTexture&&!O.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");Ve(O.__webglFramebuffer,z)}else if(Z){O.__webglDepthbuffer=[];for(let me=0;me<6;me++)n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[me]),O.__webglDepthbuffer[me]=t.createRenderbuffer(),ce(O.__webglDepthbuffer[me],z,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer=t.createRenderbuffer(),ce(O.__webglDepthbuffer,z,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function Y(z,O,Z){const me=r.get(z);O!==void 0&&Fe(me.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Z!==void 0&&V(z)}function de(z){const O=z.texture,Z=r.get(z),me=r.get(O);z.addEventListener("dispose",F),z.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=t.createTexture()),me.__version=O.version,o.memory.textures++);const Te=z.isWebGLCubeRenderTarget===!0,ke=z.isWebGLMultipleRenderTargets===!0,Ee=T(z)||l;if(Te){Z.__webglFramebuffer=[];for(let Se=0;Se<6;Se++)if(l&&O.mipmaps&&O.mipmaps.length>0){Z.__webglFramebuffer[Se]=[];for(let $e=0;$e<O.mipmaps.length;$e++)Z.__webglFramebuffer[Se][$e]=t.createFramebuffer()}else Z.__webglFramebuffer[Se]=t.createFramebuffer()}else{if(l&&O.mipmaps&&O.mipmaps.length>0){Z.__webglFramebuffer=[];for(let Se=0;Se<O.mipmaps.length;Se++)Z.__webglFramebuffer[Se]=t.createFramebuffer()}else Z.__webglFramebuffer=t.createFramebuffer();if(ke)if(i.drawBuffers){const Se=z.texture;for(let $e=0,Qe=Se.length;$e<Qe;$e++){const Ue=r.get(Se[$e]);Ue.__webglTexture===void 0&&(Ue.__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&&le(z)===!1){const Se=ke?O:[O];Z.__webglMultisampledFramebuffer=t.createFramebuffer(),Z.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let $e=0;$e<Se.length;$e++){const Qe=Se[$e];Z.__webglColorRenderbuffer[$e]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Z.__webglColorRenderbuffer[$e]);const Ue=s.convert(Qe.format,Qe.colorSpace),be=s.convert(Qe.type),ve=R(Qe.internalFormat,Ue,be,Qe.colorSpace,z.isXRRenderTarget===!0),ze=X(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,ze,ve,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.RENDERBUFFER,Z.__webglColorRenderbuffer[$e])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(Z.__webglDepthRenderbuffer=t.createRenderbuffer(),ce(Z.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Te){n.bindTexture(t.TEXTURE_CUBE_MAP,me.__webglTexture),fe(t.TEXTURE_CUBE_MAP,O,Ee);for(let Se=0;Se<6;Se++)if(l&&O.mipmaps&&O.mipmaps.length>0)for(let $e=0;$e<O.mipmaps.length;$e++)Fe(Z.__webglFramebuffer[Se][$e],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,$e);else Fe(Z.__webglFramebuffer[Se],z,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0);A(O,Ee)&&k(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ke){const Se=z.texture;for(let $e=0,Qe=Se.length;$e<Qe;$e++){const Ue=Se[$e],be=r.get(Ue);n.bindTexture(t.TEXTURE_2D,be.__webglTexture),fe(t.TEXTURE_2D,Ue,Ee),Fe(Z.__webglFramebuffer,z,Ue,t.COLOR_ATTACHMENT0+$e,t.TEXTURE_2D,0),A(Ue,Ee)&&k(t.TEXTURE_2D)}n.unbindTexture()}else{let Se=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(l?Se=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Se,me.__webglTexture),fe(Se,O,Ee),l&&O.mipmaps&&O.mipmaps.length>0)for(let $e=0;$e<O.mipmaps.length;$e++)Fe(Z.__webglFramebuffer[$e],z,O,t.COLOR_ATTACHMENT0,Se,$e);else Fe(Z.__webglFramebuffer,z,O,t.COLOR_ATTACHMENT0,Se,0);A(O,Ee)&&k(Se),n.unbindTexture()}z.depthBuffer&&V(z)}function q(z){const O=T(z)||l,Z=z.isWebGLMultipleRenderTargets===!0?z.texture:[z.texture];for(let me=0,Te=Z.length;me<Te;me++){const ke=Z[me];if(A(ke,O)){const Ee=z.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Se=r.get(ke).__webglTexture;n.bindTexture(Ee,Se),k(Ee),n.unbindTexture()}}}function re(z){if(l&&z.samples>0&&le(z)===!1){const O=z.isWebGLMultipleRenderTargets?z.texture:[z.texture],Z=z.width,me=z.height;let Te=t.COLOR_BUFFER_BIT;const ke=[],Ee=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Se=r.get(z),$e=z.isWebGLMultipleRenderTargets===!0;if($e)for(let Qe=0;Qe<O.length;Qe++)n.bindFramebuffer(t.FRAMEBUFFER,Se.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Se.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Se.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Se.__webglFramebuffer);for(let Qe=0;Qe<O.length;Qe++){ke.push(t.COLOR_ATTACHMENT0+Qe),z.depthBuffer&&ke.push(Ee);const Ue=Se.__ignoreDepthValues!==void 0?Se.__ignoreDepthValues:!1;if(Ue===!1&&(z.depthBuffer&&(Te|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&(Te|=t.STENCIL_BUFFER_BIT)),$e&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Se.__webglColorRenderbuffer[Qe]),Ue===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Ee]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Ee])),$e){const be=r.get(O[Qe]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,be,0)}t.blitFramebuffer(0,0,Z,me,0,0,Z,me,Te,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ke)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),$e)for(let Qe=0;Qe<O.length;Qe++){n.bindFramebuffer(t.FRAMEBUFFER,Se.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.RENDERBUFFER,Se.__webglColorRenderbuffer[Qe]);const Ue=r.get(O[Qe]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Se.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Qe,t.TEXTURE_2D,Ue,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Se.__webglMultisampledFramebuffer)}}function X(z){return Math.min(h,z.samples)}function le(z){const O=r.get(z);return l&&z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function pe(z){const O=o.render.frame;b.get(z)!==O&&(b.set(z,O),z.update())}function ee(z,O){const Z=z.colorSpace,me=z.format,Te=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||z.format===O3||Z!==Ku&&Z!==nl&&(Cr.getTransfer(Z)===Kr?l===!1?e.has("EXT_sRGB")===!0&&me===tl?(z.format=O3,z.minFilter=el,z.generateMipmaps=!1):O=rX.sRGBToLinear(O):(me!==tl||Te!==_h)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Z)),O}this.allocateTextureUnit=K,this.resetTextureUnits=I,this.setTexture2D=se,this.setTexture2DArray=H,this.setTexture3D=W,this.setTextureCube=J,this.rebindTextures=Y,this.setupRenderTarget=de,this.updateRenderTargetMipmap=q,this.updateMultisampleRenderTarget=re,this.setupDepthRenderbuffer=V,this.setupFrameBufferTexture=Fe,this.useMultisampledRTT=le}function oke(t,e,n){const r=n.isWebGL2;function i(s,o=nl){let l;const c=Cr.getTransfer(o);if(s===_h)return t.UNSIGNED_BYTE;if(s===qK)return t.UNSIGNED_SHORT_4_4_4_4;if(s===WK)return t.UNSIGNED_SHORT_5_5_5_1;if(s===Pve)return t.BYTE;if(s===jve)return t.SHORT;if(s===wO)return t.UNSIGNED_SHORT;if(s===GK)return t.INT;if(s===ch)return t.UNSIGNED_INT;if(s===Eu)return t.FLOAT;if(s===oy)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(s===Dve)return t.ALPHA;if(s===tl)return t.RGBA;if(s===Rve)return t.LUMINANCE;if(s===Ove)return t.LUMINANCE_ALPHA;if(s===em)return t.DEPTH_COMPONENT;if(s===ib)return t.DEPTH_STENCIL;if(s===O3)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(s===Lve)return t.RED;if(s===KK)return t.RED_INTEGER;if(s===Fve)return t.RG;if(s===XK)return t.RG_INTEGER;if(s===YK)return t.RGBA_INTEGER;if(s===eA||s===tA||s===nA||s===rA)if(c===Kr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(s===eA)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===tA)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===nA)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===rA)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(s===eA)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===tA)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===nA)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===rA)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===T8||s===A8||s===C8||s===P8)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(s===T8)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===A8)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===C8)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===P8)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===QK)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===j8||s===D8)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(s===j8)return c===Kr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(s===D8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===R8||s===O8||s===L8||s===F8||s===I8||s===z8||s===U8||s===B8||s===H8||s===$8||s===V8||s===G8||s===q8||s===W8)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(s===R8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===O8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===L8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===F8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===I8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===z8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===U8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===B8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===H8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===$8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===V8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===G8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===q8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===W8)return c===Kr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===iA||s===K8||s===X8)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(s===iA)return c===Kr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===K8)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===X8)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Ive||s===Y8||s===Q8||s===Z8)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(s===iA)return l.COMPRESSED_RED_RGTC1_EXT;if(s===Y8)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Q8)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Z8)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Jf?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[s]!==void 0?t[s]:null}return{convert:i}}class lke extends go{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class h0 extends Ss{constructor(){super(),this.isGroup=!0,this.type="Group"}}const cke={type:"move"};class EA{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new h0,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 h0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ye,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ye),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new h0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ye,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ye),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const x=n.getJointPose(y,r),v=this._getHandJoint(u,y);x!==null&&(v.matrix.fromArray(x.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=x.radius),v.visible=x!==null}const d=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],p=d.position.distanceTo(h.position),m=.02,b=.005;u.inputState.pinching&&p>m+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(cke)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new h0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class uke extends zm{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,h=null,p=null,m=null,b=null;const y=n.getContextAttributes();let x=null,v=null;const S=[],N=[],T=new _n;let M=null;const A=new go;A.layers.enable(1),A.viewport=new jr;const k=new go;k.layers.enable(2),k.viewport=new jr;const R=[A,k],C=new lke;C.layers.enable(1),C.layers.enable(2);let P=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let ne=S[J];return ne===void 0&&(ne=new EA,S[J]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(J){let ne=S[J];return ne===void 0&&(ne=new EA,S[J]=ne),ne.getGripSpace()},this.getHand=function(J){let ne=S[J];return ne===void 0&&(ne=new EA,S[J]=ne),ne.getHandSpace()};function F(J){const ne=N.indexOf(J.inputSource);if(ne===-1)return;const xe=S[ne];xe!==void 0&&(xe.update(J.inputSource,J.frame,u||o),xe.dispatchEvent({type:J.type,data:J.inputSource}))}function B(){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",B),i.removeEventListener("inputsourceschange",D);for(let J=0;J<S.length;J++){const ne=N[J];ne!==null&&(N[J]=null,S[J].disconnect(ne))}P=null,U=null,e.setRenderTarget(x),m=null,p=null,h=null,i=null,v=null,W.stop(),r.isPresenting=!1,e.setPixelRatio(M),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){s=J,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){l=J,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(J){u=J},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return h},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(J){if(i=J,i!==null){if(x=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",B),i.addEventListener("inputsourceschange",D),y.xrCompatible!==!0&&await n.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(T),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ne={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,ne),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),v=new _m(m.framebufferWidth,m.framebufferHeight,{format:tl,type:_h,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ne=null,xe=null,ue=null;y.depth&&(ue=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ne=y.stencil?ib:em,xe=y.stencil?Jf:ch);const fe={colorFormat:n.RGBA8,depthFormat:ue,scaleFactor:s};h=new XRWebGLBinding(i,n),p=h.createProjectionLayer(fe),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),v=new _m(p.textureWidth,p.textureHeight,{format:tl,type:_h,depthTexture:new pX(p.textureWidth,p.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const De=e.properties.get(v);De.__ignoreDepthValues=p.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),W.setContext(i),W.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function D(J){for(let ne=0;ne<J.removed.length;ne++){const xe=J.removed[ne],ue=N.indexOf(xe);ue>=0&&(N[ue]=null,S[ue].disconnect(xe))}for(let ne=0;ne<J.added.length;ne++){const xe=J.added[ne];let ue=N.indexOf(xe);if(ue===-1){for(let De=0;De<S.length;De++)if(De>=N.length){N.push(xe),ue=De;break}else if(N[De]===null){N[De]=xe,ue=De;break}if(ue===-1)break}const fe=S[ue];fe&&fe.connect(xe)}}const $=new Ye,G=new Ye;function I(J,ne,xe){$.setFromMatrixPosition(ne.matrixWorld),G.setFromMatrixPosition(xe.matrixWorld);const ue=$.distanceTo(G),fe=ne.projectionMatrix.elements,De=xe.projectionMatrix.elements,oe=fe[14]/(fe[10]-1),Ne=fe[14]/(fe[10]+1),Fe=(fe[9]+1)/fe[5],ce=(fe[9]-1)/fe[5],Ve=(fe[8]-1)/fe[0],V=(De[8]+1)/De[0],Y=oe*Ve,de=oe*V,q=ue/(-Ve+V),re=q*-Ve;ne.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(re),J.translateZ(q),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert();const X=oe+q,le=Ne+q,pe=Y-re,ee=de+(ue-re),z=Fe*Ne/le*X,O=ce*Ne/le*X;J.projectionMatrix.makePerspective(pe,ee,z,O,X,le),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}function K(J,ne){ne===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(ne.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;C.near=k.near=A.near=J.near,C.far=k.far=A.far=J.far,(P!==C.near||U!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),P=C.near,U=C.far);const ne=J.parent,xe=C.cameras;K(C,ne);for(let ue=0;ue<xe.length;ue++)K(xe[ue],ne);xe.length===2?I(C,A,k):C.projectionMatrix.copy(A.projectionMatrix),Q(J,C,ne)};function Q(J,ne,xe){xe===null?J.matrix.copy(ne.matrixWorld):(J.matrix.copy(xe.matrixWorld),J.matrix.invert(),J.matrix.multiply(ne.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(ne.projectionMatrix),J.projectionMatrixInverse.copy(ne.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=cy*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(J){c=J,p!==null&&(p.fixedFoveation=J),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=J)};let se=null;function H(J,ne){if(d=ne.getViewerPose(u||o),b=ne,d!==null){const xe=d.views;m!==null&&(e.setRenderTargetFramebuffer(v,m.framebuffer),e.setRenderTarget(v));let ue=!1;xe.length!==C.cameras.length&&(C.cameras.length=0,ue=!0);for(let fe=0;fe<xe.length;fe++){const De=xe[fe];let oe=null;if(m!==null)oe=m.getViewport(De);else{const Fe=h.getViewSubImage(p,De);oe=Fe.viewport,fe===0&&(e.setRenderTargetTextures(v,Fe.colorTexture,p.ignoreDepthValues?void 0:Fe.depthStencilTexture),e.setRenderTarget(v))}let Ne=R[fe];Ne===void 0&&(Ne=new go,Ne.layers.enable(fe),Ne.viewport=new jr,R[fe]=Ne),Ne.matrix.fromArray(De.transform.matrix),Ne.matrix.decompose(Ne.position,Ne.quaternion,Ne.scale),Ne.projectionMatrix.fromArray(De.projectionMatrix),Ne.projectionMatrixInverse.copy(Ne.projectionMatrix).invert(),Ne.viewport.set(oe.x,oe.y,oe.width,oe.height),fe===0&&(C.matrix.copy(Ne.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),ue===!0&&C.cameras.push(Ne)}}for(let xe=0;xe<S.length;xe++){const ue=N[xe],fe=S[xe];ue!==null&&fe!==void 0&&fe.update(ue,ne,u||o)}se&&se(J,ne),ne.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ne}),b=null}const W=new mX;W.setAnimationLoop(H),this.setAnimationLoop=function(J){se=J},this.dispose=function(){}}}function dke(t,e){function n(x,v){x.matrixAutoUpdate===!0&&x.updateMatrix(),v.value.copy(x.matrix)}function r(x,v){v.color.getRGB(x.fogColor.value,dX(t)),v.isFog?(x.fogNear.value=v.near,x.fogFar.value=v.far):v.isFogExp2&&(x.fogDensity.value=v.density)}function i(x,v,S,N,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(x,v):v.isMeshToonMaterial?(s(x,v),h(x,v)):v.isMeshPhongMaterial?(s(x,v),d(x,v)):v.isMeshStandardMaterial?(s(x,v),p(x,v),v.isMeshPhysicalMaterial&&m(x,v,T)):v.isMeshMatcapMaterial?(s(x,v),b(x,v)):v.isMeshDepthMaterial?s(x,v):v.isMeshDistanceMaterial?(s(x,v),y(x,v)):v.isMeshNormalMaterial?s(x,v):v.isLineBasicMaterial?(o(x,v),v.isLineDashedMaterial&&l(x,v)):v.isPointsMaterial?c(x,v,S,N):v.isSpriteMaterial?u(x,v):v.isShadowMaterial?(x.color.value.copy(v.color),x.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(x,v){x.opacity.value=v.opacity,v.color&&x.diffuse.value.copy(v.color),v.emissive&&x.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.bumpMap&&(x.bumpMap.value=v.bumpMap,n(v.bumpMap,x.bumpMapTransform),x.bumpScale.value=v.bumpScale,v.side===Gs&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===Gs&&x.normalScale.value.negate()),v.displacementMap&&(x.displacementMap.value=v.displacementMap,n(v.displacementMap,x.displacementMapTransform),x.displacementScale.value=v.displacementScale,x.displacementBias.value=v.displacementBias),v.emissiveMap&&(x.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,x.emissiveMapTransform)),v.specularMap&&(x.specularMap.value=v.specularMap,n(v.specularMap,x.specularMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest);const S=e.get(v).envMap;if(S&&(x.envMap.value=S,x.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=v.reflectivity,x.ior.value=v.ior,x.refractionRatio.value=v.refractionRatio),v.lightMap){x.lightMap.value=v.lightMap;const N=t._useLegacyLights===!0?Math.PI:1;x.lightMapIntensity.value=v.lightMapIntensity*N,n(v.lightMap,x.lightMapTransform)}v.aoMap&&(x.aoMap.value=v.aoMap,x.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,x.aoMapTransform))}function o(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform))}function l(x,v){x.dashSize.value=v.dashSize,x.totalSize.value=v.dashSize+v.gapSize,x.scale.value=v.scale}function c(x,v,S,N){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.size.value=v.size*S,x.scale.value=N*.5,v.map&&(x.map.value=v.map,n(v.map,x.uvTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function u(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.rotation.value=v.rotation,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function d(x,v){x.specular.value.copy(v.specular),x.shininess.value=Math.max(v.shininess,1e-4)}function h(x,v){v.gradientMap&&(x.gradientMap.value=v.gradientMap)}function p(x,v){x.metalness.value=v.metalness,v.metalnessMap&&(x.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,x.metalnessMapTransform)),x.roughness.value=v.roughness,v.roughnessMap&&(x.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,x.roughnessMapTransform)),e.get(v).envMap&&(x.envMapIntensity.value=v.envMapIntensity)}function m(x,v,S){x.ior.value=v.ior,v.sheen>0&&(x.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),x.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(x.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,x.sheenColorMapTransform)),v.sheenRoughnessMap&&(x.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,x.sheenRoughnessMapTransform))),v.clearcoat>0&&(x.clearcoat.value=v.clearcoat,x.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(x.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,x.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(x.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Gs&&x.clearcoatNormalScale.value.negate())),v.iridescence>0&&(x.iridescence.value=v.iridescence,x.iridescenceIOR.value=v.iridescenceIOR,x.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(x.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,x.iridescenceMapTransform)),v.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),v.transmission>0&&(x.transmission.value=v.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(x.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,x.transmissionMapTransform)),x.thickness.value=v.thickness,v.thicknessMap&&(x.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=v.attenuationDistance,x.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(x.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(x.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=v.specularIntensity,x.specularColor.value.copy(v.specularColor),v.specularColorMap&&(x.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,x.specularColorMapTransform)),v.specularIntensityMap&&(x.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,v){v.matcap&&(x.matcap.value=v.matcap)}function y(x,v){const S=e.get(v).light;x.referencePosition.value.setFromMatrixPosition(S.matrixWorld),x.nearDistance.value=S.shadow.camera.near,x.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function hke(t,e,n,r){let i={},s={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,N){const T=N.program;r.uniformBlockBinding(S,T)}function u(S,N){let T=i[S.id];T===void 0&&(b(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",x));const M=N.program;r.updateUBOMapping(S,M);const A=e.render.frame;s[S.id]!==A&&(p(S),s[S.id]=A)}function d(S){const N=h();S.__bindingPointIndex=N;const T=t.createBuffer(),M=S.__size,A=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,M,A),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,T),T}function h(){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 N=i[S.id],T=S.uniforms,M=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let A=0,k=T.length;A<k;A++){const R=T[A];if(m(R,A,M)===!0){const C=R.__offset,P=Array.isArray(R.value)?R.value:[R.value];let U=0;for(let F=0;F<P.length;F++){const B=P[F],D=y(B);typeof B=="number"?(R.__data[0]=B,t.bufferSubData(t.UNIFORM_BUFFER,C+U,R.__data)):B.isMatrix3?(R.__data[0]=B.elements[0],R.__data[1]=B.elements[1],R.__data[2]=B.elements[2],R.__data[3]=B.elements[0],R.__data[4]=B.elements[3],R.__data[5]=B.elements[4],R.__data[6]=B.elements[5],R.__data[7]=B.elements[0],R.__data[8]=B.elements[6],R.__data[9]=B.elements[7],R.__data[10]=B.elements[8],R.__data[11]=B.elements[0]):(B.toArray(R.__data,U),U+=D.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,C,R.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,N,T){const M=S.value;if(T[N]===void 0){if(typeof M=="number")T[N]=M;else{const A=Array.isArray(M)?M:[M],k=[];for(let R=0;R<A.length;R++)k.push(A[R].clone());T[N]=k}return!0}else if(typeof M=="number"){if(T[N]!==M)return T[N]=M,!0}else{const A=Array.isArray(T[N])?T[N]:[T[N]],k=Array.isArray(M)?M:[M];for(let R=0;R<A.length;R++){const C=A[R];if(C.equals(k[R])===!1)return C.copy(k[R]),!0}}return!1}function b(S){const N=S.uniforms;let T=0;const M=16;let A=0;for(let k=0,R=N.length;k<R;k++){const C=N[k],P={boundary:0,storage:0},U=Array.isArray(C.value)?C.value:[C.value];for(let F=0,B=U.length;F<B;F++){const D=U[F],$=y(D);P.boundary+=$.boundary,P.storage+=$.storage}if(C.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=T,k>0){A=T%M;const F=M-A;A!==0&&F-P.boundary<0&&(T+=M-A,C.__offset=T)}T+=P.storage}return A=T%M,A>0&&(T+=M-A),S.__size=T,S.__cache={},this}function y(S){const N={boundary:0,storage:0};return typeof S=="number"?(N.boundary=4,N.storage=4):S.isVector2?(N.boundary=8,N.storage=8):S.isVector3||S.isColor?(N.boundary=16,N.storage=12):S.isVector4?(N.boundary=16,N.storage=16):S.isMatrix3?(N.boundary=48,N.storage=48):S.isMatrix4?(N.boundary=64,N.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),N}function x(S){const N=S.target;N.removeEventListener("dispose",x);const T=o.indexOf(N.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete s[N.id]}function v(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},s={}}return{bind:c,update:u,dispose:v}}class I3{constructor(e={}){const{canvas:n=cwe(),context:r=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let p;r!==null?p=r.getContextAttributes().alpha:p=o;const m=new Uint32Array(4),b=new Int32Array(4);let y=null,x=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=Ia,this._useLegacyLights=!1,this.toneMapping=wh,this.toneMappingExposure=1;const N=this;let T=!1,M=0,A=0,k=null,R=-1,C=null;const P=new jr,U=new jr;let F=null;const B=new dn(0);let D=0,$=n.width,G=n.height,I=1,K=null,Q=null;const se=new jr(0,0,$,G),H=new jr(0,0,$,G);let W=!1;const J=new Hk;let ne=!1,xe=!1,ue=null;const fe=new Vr,De=new _n,oe=new Ye,Ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Fe(){return k===null?I:1}let ce=r;function Ve(Pe,tt){for(let ht=0;ht<Pe.length;ht++){const mt=Pe[ht],at=n.getContext(mt,tt);if(at!==null)return at}return null}try{const Pe={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${zk}`),n.addEventListener("webglcontextlost",Je,!1),n.addEventListener("webglcontextrestored",Ae,!1),n.addEventListener("webglcontextcreationerror",Ke,!1),ce===null){const tt=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&tt.shift(),ce=Ve(tt,Pe),ce===null)throw Ve(tt)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ce instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ce.getShaderPrecisionFormat===void 0&&(ce.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Pe){throw console.error("THREE.WebGLRenderer: "+Pe.message),Pe}let V,Y,de,q,re,X,le,pe,ee,z,O,Z,me,Te,ke,Ee,Se,$e,Qe,Ue,be,ve,ze,Ce;function Ge(){V=new SSe(ce),Y=new gSe(ce,V,e),V.init(Y),ve=new oke(ce,V,Y),de=new ake(ce,V,Y),q=new MSe(ce),re=new GNe,X=new ske(ce,V,de,re,Y,ve,q),le=new xSe(N),pe=new _Se(N),ee=new Dwe(ce,Y),ze=new mSe(ce,V,ee,Y),z=new NSe(ce,ee,q,ze),O=new CSe(ce,z,ee,q),Qe=new ASe(ce,Y,X),Ee=new bSe(re),Z=new VNe(N,le,pe,V,Y,ze,Ee),me=new dke(N,re),Te=new WNe,ke=new JNe(V,Y),$e=new fSe(N,le,pe,de,O,p,c),Se=new ike(N,O,Y),Ce=new hke(ce,q,Y,de),Ue=new pSe(ce,V,q,Y),be=new kSe(ce,V,q,Y),q.programs=Z.programs,N.capabilities=Y,N.extensions=V,N.properties=re,N.renderLists=Te,N.shadowMap=Se,N.state=de,N.info=q}Ge();const _e=new uke(N,ce);this.xr=_e,this.getContext=function(){return ce},this.getContextAttributes=function(){return ce.getContextAttributes()},this.forceContextLoss=function(){const Pe=V.get("WEBGL_lose_context");Pe&&Pe.loseContext()},this.forceContextRestore=function(){const Pe=V.get("WEBGL_lose_context");Pe&&Pe.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(Pe){Pe!==void 0&&(I=Pe,this.setSize($,G,!1))},this.getSize=function(Pe){return Pe.set($,G)},this.setSize=function(Pe,tt,ht=!0){if(_e.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}$=Pe,G=tt,n.width=Math.floor(Pe*I),n.height=Math.floor(tt*I),ht===!0&&(n.style.width=Pe+"px",n.style.height=tt+"px"),this.setViewport(0,0,Pe,tt)},this.getDrawingBufferSize=function(Pe){return Pe.set($*I,G*I).floor()},this.setDrawingBufferSize=function(Pe,tt,ht){$=Pe,G=tt,I=ht,n.width=Math.floor(Pe*ht),n.height=Math.floor(tt*ht),this.setViewport(0,0,Pe,tt)},this.getCurrentViewport=function(Pe){return Pe.copy(P)},this.getViewport=function(Pe){return Pe.copy(se)},this.setViewport=function(Pe,tt,ht,mt){Pe.isVector4?se.set(Pe.x,Pe.y,Pe.z,Pe.w):se.set(Pe,tt,ht,mt),de.viewport(P.copy(se).multiplyScalar(I).floor())},this.getScissor=function(Pe){return Pe.copy(H)},this.setScissor=function(Pe,tt,ht,mt){Pe.isVector4?H.set(Pe.x,Pe.y,Pe.z,Pe.w):H.set(Pe,tt,ht,mt),de.scissor(U.copy(H).multiplyScalar(I).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(Pe){de.setScissorTest(W=Pe)},this.setOpaqueSort=function(Pe){K=Pe},this.setTransparentSort=function(Pe){Q=Pe},this.getClearColor=function(Pe){return Pe.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(Pe=!0,tt=!0,ht=!0){let mt=0;if(Pe){let at=!1;if(k!==null){const Dt=k.texture.format;at=Dt===YK||Dt===XK||Dt===KK}if(at){const Dt=k.texture.type,he=Dt===_h||Dt===ch||Dt===wO||Dt===Jf||Dt===qK||Dt===WK,Ie=$e.getClearColor(),Xe=$e.getClearAlpha(),He=Ie.r,ge=Ie.g,rt=Ie.b;he?(m[0]=He,m[1]=ge,m[2]=rt,m[3]=Xe,ce.clearBufferuiv(ce.COLOR,0,m)):(b[0]=He,b[1]=ge,b[2]=rt,b[3]=Xe,ce.clearBufferiv(ce.COLOR,0,b))}else mt|=ce.COLOR_BUFFER_BIT}tt&&(mt|=ce.DEPTH_BUFFER_BIT),ht&&(mt|=ce.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ce.clear(mt)},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",Je,!1),n.removeEventListener("webglcontextrestored",Ae,!1),n.removeEventListener("webglcontextcreationerror",Ke,!1),Te.dispose(),ke.dispose(),re.dispose(),le.dispose(),pe.dispose(),O.dispose(),ze.dispose(),Ce.dispose(),Z.dispose(),_e.dispose(),_e.removeEventListener("sessionstart",fn),_e.removeEventListener("sessionend",It),ue&&(ue.dispose(),ue=null),Oe.stop()};function Je(Pe){Pe.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function Ae(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const Pe=q.autoReset,tt=Se.enabled,ht=Se.autoUpdate,mt=Se.needsUpdate,at=Se.type;Ge(),q.autoReset=Pe,Se.enabled=tt,Se.autoUpdate=ht,Se.needsUpdate=mt,Se.type=at}function Ke(Pe){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Pe.statusMessage)}function je(Pe){const tt=Pe.target;tt.removeEventListener("dispose",je),Re(tt)}function Re(Pe){we(Pe),re.remove(Pe)}function we(Pe){const tt=re.get(Pe).programs;tt!==void 0&&(tt.forEach(function(ht){Z.releaseProgram(ht)}),Pe.isShaderMaterial&&Z.releaseShaderCache(Pe))}this.renderBufferDirect=function(Pe,tt,ht,mt,at,Dt){tt===null&&(tt=Ne);const he=at.isMesh&&at.matrixWorld.determinant()<0,Ie=Zn(Pe,tt,ht,mt,at);de.setMaterial(mt,he);let Xe=ht.index,He=1;if(mt.wireframe===!0){if(Xe=z.getWireframeAttribute(ht),Xe===void 0)return;He=2}const ge=ht.drawRange,rt=ht.attributes.position;let ut=ge.start*He,it=(ge.start+ge.count)*He;Dt!==null&&(ut=Math.max(ut,Dt.start*He),it=Math.min(it,(Dt.start+Dt.count)*He)),Xe!==null?(ut=Math.max(ut,0),it=Math.min(it,Xe.count)):rt!=null&&(ut=Math.max(ut,0),it=Math.min(it,rt.count));const Tt=it-ut;if(Tt<0||Tt===1/0)return;ze.setup(at,mt,Ie,ht,Xe);let Ut,jt=Ue;if(Xe!==null&&(Ut=ee.get(Xe),jt=be,jt.setIndex(Ut)),at.isMesh)mt.wireframe===!0?(de.setLineWidth(mt.wireframeLinewidth*Fe()),jt.setMode(ce.LINES)):jt.setMode(ce.TRIANGLES);else if(at.isLine){let Ct=mt.linewidth;Ct===void 0&&(Ct=1),de.setLineWidth(Ct*Fe()),at.isLineSegments?jt.setMode(ce.LINES):at.isLineLoop?jt.setMode(ce.LINE_LOOP):jt.setMode(ce.LINE_STRIP)}else at.isPoints?jt.setMode(ce.POINTS):at.isSprite&&jt.setMode(ce.TRIANGLES);if(at.isBatchedMesh)jt.renderMultiDraw(at._multiDrawStarts,at._multiDrawCounts,at._multiDrawCount);else if(at.isInstancedMesh)jt.renderInstances(ut,Tt,at.count);else if(ht.isInstancedBufferGeometry){const Ct=ht._maxInstanceCount!==void 0?ht._maxInstanceCount:1/0,an=Math.min(ht.instanceCount,Ct);jt.renderInstances(ut,Tt,an)}else jt.render(ut,Tt)};function qe(Pe,tt,ht){Pe.transparent===!0&&Pe.side===vu&&Pe.forceSinglePass===!1?(Pe.side=Gs,Pe.needsUpdate=!0,Lr(Pe,tt,ht),Pe.side=Rh,Pe.needsUpdate=!0,Lr(Pe,tt,ht),Pe.side=vu):Lr(Pe,tt,ht)}this.compile=function(Pe,tt,ht=null){ht===null&&(ht=Pe),x=ke.get(ht),x.init(),S.push(x),ht.traverseVisible(function(at){at.isLight&&at.layers.test(tt.layers)&&(x.pushLight(at),at.castShadow&&x.pushShadow(at))}),Pe!==ht&&Pe.traverseVisible(function(at){at.isLight&&at.layers.test(tt.layers)&&(x.pushLight(at),at.castShadow&&x.pushShadow(at))}),x.setupLights(N._useLegacyLights);const mt=new Set;return Pe.traverse(function(at){const Dt=at.material;if(Dt)if(Array.isArray(Dt))for(let he=0;he<Dt.length;he++){const Ie=Dt[he];qe(Ie,ht,at),mt.add(Ie)}else qe(Dt,ht,at),mt.add(Dt)}),S.pop(),x=null,mt},this.compileAsync=function(Pe,tt,ht=null){const mt=this.compile(Pe,tt,ht);return new Promise(at=>{function Dt(){if(mt.forEach(function(he){re.get(he).currentProgram.isReady()&&mt.delete(he)}),mt.size===0){at(Pe);return}setTimeout(Dt,10)}V.get("KHR_parallel_shader_compile")!==null?Dt():setTimeout(Dt,10)})};let xt=null;function Et(Pe){xt&&xt(Pe)}function fn(){Oe.stop()}function It(){Oe.start()}const Oe=new mX;Oe.setAnimationLoop(Et),typeof self<"u"&&Oe.setContext(self),this.setAnimationLoop=function(Pe){xt=Pe,_e.setAnimationLoop(Pe),Pe===null?Oe.stop():Oe.start()},_e.addEventListener("sessionstart",fn),_e.addEventListener("sessionend",It),this.render=function(Pe,tt){if(tt!==void 0&&tt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;Pe.matrixWorldAutoUpdate===!0&&Pe.updateMatrixWorld(),tt.parent===null&&tt.matrixWorldAutoUpdate===!0&&tt.updateMatrixWorld(),_e.enabled===!0&&_e.isPresenting===!0&&(_e.cameraAutoUpdate===!0&&_e.updateCamera(tt),tt=_e.getCamera()),Pe.isScene===!0&&Pe.onBeforeRender(N,Pe,tt,k),x=ke.get(Pe,S.length),x.init(),S.push(x),fe.multiplyMatrices(tt.projectionMatrix,tt.matrixWorldInverse),J.setFromProjectionMatrix(fe),xe=this.localClippingEnabled,ne=Ee.init(this.clippingPlanes,xe),y=Te.get(Pe,v.length),y.init(),v.push(y),yt(Pe,tt,0,N.sortObjects),y.finish(),N.sortObjects===!0&&y.sort(K,Q),this.info.render.frame++,ne===!0&&Ee.beginShadows();const ht=x.state.shadowsArray;if(Se.render(ht,Pe,tt),ne===!0&&Ee.endShadows(),this.info.autoReset===!0&&this.info.reset(),$e.render(y,Pe),x.setupLights(N._useLegacyLights),tt.isArrayCamera){const mt=tt.cameras;for(let at=0,Dt=mt.length;at<Dt;at++){const he=mt[at];Wt(y,Pe,he,he.viewport)}}else Wt(y,Pe,tt);k!==null&&(X.updateMultisampleRenderTarget(k),X.updateRenderTargetMipmap(k)),Pe.isScene===!0&&Pe.onAfterRender(N,Pe,tt),ze.resetDefaultState(),R=-1,C=null,S.pop(),S.length>0?x=S[S.length-1]:x=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function yt(Pe,tt,ht,mt){if(Pe.visible===!1)return;if(Pe.layers.test(tt.layers)){if(Pe.isGroup)ht=Pe.renderOrder;else if(Pe.isLOD)Pe.autoUpdate===!0&&Pe.update(tt);else if(Pe.isLight)x.pushLight(Pe),Pe.castShadow&&x.pushShadow(Pe);else if(Pe.isSprite){if(!Pe.frustumCulled||J.intersectsSprite(Pe)){mt&&oe.setFromMatrixPosition(Pe.matrixWorld).applyMatrix4(fe);const he=O.update(Pe),Ie=Pe.material;Ie.visible&&y.push(Pe,he,Ie,ht,oe.z,null)}}else if((Pe.isMesh||Pe.isLine||Pe.isPoints)&&(!Pe.frustumCulled||J.intersectsObject(Pe))){const he=O.update(Pe),Ie=Pe.material;if(mt&&(Pe.boundingSphere!==void 0?(Pe.boundingSphere===null&&Pe.computeBoundingSphere(),oe.copy(Pe.boundingSphere.center)):(he.boundingSphere===null&&he.computeBoundingSphere(),oe.copy(he.boundingSphere.center)),oe.applyMatrix4(Pe.matrixWorld).applyMatrix4(fe)),Array.isArray(Ie)){const Xe=he.groups;for(let He=0,ge=Xe.length;He<ge;He++){const rt=Xe[He],ut=Ie[rt.materialIndex];ut&&ut.visible&&y.push(Pe,he,ut,ht,oe.z,rt)}}else Ie.visible&&y.push(Pe,he,Ie,ht,oe.z,null)}}const Dt=Pe.children;for(let he=0,Ie=Dt.length;he<Ie;he++)yt(Dt[he],tt,ht,mt)}function Wt(Pe,tt,ht,mt){const at=Pe.opaque,Dt=Pe.transmissive,he=Pe.transparent;x.setupLightsView(ht),ne===!0&&Ee.setGlobalState(N.clippingPlanes,ht),Dt.length>0&&rn(at,Dt,tt,ht),mt&&de.viewport(P.copy(mt)),at.length>0&&Qt(at,tt,ht),Dt.length>0&&Qt(Dt,tt,ht),he.length>0&&Qt(he,tt,ht),de.buffers.depth.setTest(!0),de.buffers.depth.setMask(!0),de.buffers.color.setMask(!0),de.setPolygonOffset(!1)}function rn(Pe,tt,ht,mt){if((ht.isScene===!0?ht.overrideMaterial:null)!==null)return;const Dt=Y.isWebGL2;ue===null&&(ue=new _m(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")?oy:_h,minFilter:sy,samples:Dt?4:0})),N.getDrawingBufferSize(De),Dt?ue.setSize(De.x,De.y):ue.setSize(yS(De.x),yS(De.y));const he=N.getRenderTarget();N.setRenderTarget(ue),N.getClearColor(B),D=N.getClearAlpha(),D<1&&N.setClearColor(16777215,.5),N.clear();const Ie=N.toneMapping;N.toneMapping=wh,Qt(Pe,ht,mt),X.updateMultisampleRenderTarget(ue),X.updateRenderTargetMipmap(ue);let Xe=!1;for(let He=0,ge=tt.length;He<ge;He++){const rt=tt[He],ut=rt.object,it=rt.geometry,Tt=rt.material,Ut=rt.group;if(Tt.side===vu&&ut.layers.test(mt.layers)){const jt=Tt.side;Tt.side=Gs,Tt.needsUpdate=!0,ur(ut,ht,mt,it,Tt,Ut),Tt.side=jt,Tt.needsUpdate=!0,Xe=!0}}Xe===!0&&(X.updateMultisampleRenderTarget(ue),X.updateRenderTargetMipmap(ue)),N.setRenderTarget(he),N.setClearColor(B,D),N.toneMapping=Ie}function Qt(Pe,tt,ht){const mt=tt.isScene===!0?tt.overrideMaterial:null;for(let at=0,Dt=Pe.length;at<Dt;at++){const he=Pe[at],Ie=he.object,Xe=he.geometry,He=mt===null?he.material:mt,ge=he.group;Ie.layers.test(ht.layers)&&ur(Ie,tt,ht,Xe,He,ge)}}function ur(Pe,tt,ht,mt,at,Dt){Pe.onBeforeRender(N,tt,ht,mt,at,Dt),Pe.modelViewMatrix.multiplyMatrices(ht.matrixWorldInverse,Pe.matrixWorld),Pe.normalMatrix.getNormalMatrix(Pe.modelViewMatrix),at.onBeforeRender(N,tt,ht,mt,Pe,Dt),at.transparent===!0&&at.side===vu&&at.forceSinglePass===!1?(at.side=Gs,at.needsUpdate=!0,N.renderBufferDirect(ht,tt,mt,at,Pe,Dt),at.side=Rh,at.needsUpdate=!0,N.renderBufferDirect(ht,tt,mt,at,Pe,Dt),at.side=vu):N.renderBufferDirect(ht,tt,mt,at,Pe,Dt),Pe.onAfterRender(N,tt,ht,mt,at,Dt)}function Lr(Pe,tt,ht){tt.isScene!==!0&&(tt=Ne);const mt=re.get(Pe),at=x.state.lights,Dt=x.state.shadowsArray,he=at.state.version,Ie=Z.getParameters(Pe,at.state,Dt,tt,ht),Xe=Z.getProgramCacheKey(Ie);let He=mt.programs;mt.environment=Pe.isMeshStandardMaterial?tt.environment:null,mt.fog=tt.fog,mt.envMap=(Pe.isMeshStandardMaterial?pe:le).get(Pe.envMap||mt.environment),He===void 0&&(Pe.addEventListener("dispose",je),He=new Map,mt.programs=He);let ge=He.get(Xe);if(ge!==void 0){if(mt.currentProgram===ge&&mt.lightsStateVersion===he)return Xt(Pe,Ie),ge}else Ie.uniforms=Z.getUniforms(Pe),Pe.onBuild(ht,Ie,N),Pe.onBeforeCompile(Ie,N),ge=Z.acquireProgram(Ie,Xe),He.set(Xe,ge),mt.uniforms=Ie.uniforms;const rt=mt.uniforms;return(!Pe.isShaderMaterial&&!Pe.isRawShaderMaterial||Pe.clipping===!0)&&(rt.clippingPlanes=Ee.uniform),Xt(Pe,Ie),mt.needsLights=da(Pe),mt.lightsStateVersion=he,mt.needsLights&&(rt.ambientLightColor.value=at.state.ambient,rt.lightProbe.value=at.state.probe,rt.directionalLights.value=at.state.directional,rt.directionalLightShadows.value=at.state.directionalShadow,rt.spotLights.value=at.state.spot,rt.spotLightShadows.value=at.state.spotShadow,rt.rectAreaLights.value=at.state.rectArea,rt.ltc_1.value=at.state.rectAreaLTC1,rt.ltc_2.value=at.state.rectAreaLTC2,rt.pointLights.value=at.state.point,rt.pointLightShadows.value=at.state.pointShadow,rt.hemisphereLights.value=at.state.hemi,rt.directionalShadowMap.value=at.state.directionalShadowMap,rt.directionalShadowMatrix.value=at.state.directionalShadowMatrix,rt.spotShadowMap.value=at.state.spotShadowMap,rt.spotLightMatrix.value=at.state.spotLightMatrix,rt.spotLightMap.value=at.state.spotLightMap,rt.pointShadowMap.value=at.state.pointShadowMap,rt.pointShadowMatrix.value=at.state.pointShadowMatrix),mt.currentProgram=ge,mt.uniformsList=null,ge}function nr(Pe){if(Pe.uniformsList===null){const tt=Pe.currentProgram.getUniforms();Pe.uniformsList=U1.seqWithValue(tt.seq,Pe.uniforms)}return Pe.uniformsList}function Xt(Pe,tt){const ht=re.get(Pe);ht.outputColorSpace=tt.outputColorSpace,ht.batching=tt.batching,ht.instancing=tt.instancing,ht.instancingColor=tt.instancingColor,ht.skinning=tt.skinning,ht.morphTargets=tt.morphTargets,ht.morphNormals=tt.morphNormals,ht.morphColors=tt.morphColors,ht.morphTargetsCount=tt.morphTargetsCount,ht.numClippingPlanes=tt.numClippingPlanes,ht.numIntersection=tt.numClipIntersection,ht.vertexAlphas=tt.vertexAlphas,ht.vertexTangents=tt.vertexTangents,ht.toneMapping=tt.toneMapping}function Zn(Pe,tt,ht,mt,at){tt.isScene!==!0&&(tt=Ne),X.resetTextureUnits();const Dt=tt.fog,he=mt.isMeshStandardMaterial?tt.environment:null,Ie=k===null?N.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:Ku,Xe=(mt.isMeshStandardMaterial?pe:le).get(mt.envMap||he),He=mt.vertexColors===!0&&!!ht.attributes.color&&ht.attributes.color.itemSize===4,ge=!!ht.attributes.tangent&&(!!mt.normalMap||mt.anisotropy>0),rt=!!ht.morphAttributes.position,ut=!!ht.morphAttributes.normal,it=!!ht.morphAttributes.color;let Tt=wh;mt.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(Tt=N.toneMapping);const Ut=ht.morphAttributes.position||ht.morphAttributes.normal||ht.morphAttributes.color,jt=Ut!==void 0?Ut.length:0,Ct=re.get(mt),an=x.state.lights;if(ne===!0&&(xe===!0||Pe!==C)){const Hr=Pe===C&&mt.id===R;Ee.setState(mt,Pe,Hr)}let Vt=!1;mt.version===Ct.__version?(Ct.needsLights&&Ct.lightsStateVersion!==an.state.version||Ct.outputColorSpace!==Ie||at.isBatchedMesh&&Ct.batching===!1||!at.isBatchedMesh&&Ct.batching===!0||at.isInstancedMesh&&Ct.instancing===!1||!at.isInstancedMesh&&Ct.instancing===!0||at.isSkinnedMesh&&Ct.skinning===!1||!at.isSkinnedMesh&&Ct.skinning===!0||at.isInstancedMesh&&Ct.instancingColor===!0&&at.instanceColor===null||at.isInstancedMesh&&Ct.instancingColor===!1&&at.instanceColor!==null||Ct.envMap!==Xe||mt.fog===!0&&Ct.fog!==Dt||Ct.numClippingPlanes!==void 0&&(Ct.numClippingPlanes!==Ee.numPlanes||Ct.numIntersection!==Ee.numIntersection)||Ct.vertexAlphas!==He||Ct.vertexTangents!==ge||Ct.morphTargets!==rt||Ct.morphNormals!==ut||Ct.morphColors!==it||Ct.toneMapping!==Tt||Y.isWebGL2===!0&&Ct.morphTargetsCount!==jt)&&(Vt=!0):(Vt=!0,Ct.__version=mt.version);let gn=Ct.currentProgram;Vt===!0&&(gn=Lr(mt,tt,at));let Mn=!1,bn=!1,qt=!1;const sn=gn.getUniforms(),Jt=Ct.uniforms;if(de.useProgram(gn.program)&&(Mn=!0,bn=!0,qt=!0),mt.id!==R&&(R=mt.id,bn=!0),Mn||C!==Pe){sn.setValue(ce,"projectionMatrix",Pe.projectionMatrix),sn.setValue(ce,"viewMatrix",Pe.matrixWorldInverse);const Hr=sn.map.cameraPosition;Hr!==void 0&&Hr.setValue(ce,oe.setFromMatrixPosition(Pe.matrixWorld)),Y.logarithmicDepthBuffer&&sn.setValue(ce,"logDepthBufFC",2/(Math.log(Pe.far+1)/Math.LN2)),(mt.isMeshPhongMaterial||mt.isMeshToonMaterial||mt.isMeshLambertMaterial||mt.isMeshBasicMaterial||mt.isMeshStandardMaterial||mt.isShaderMaterial)&&sn.setValue(ce,"isOrthographic",Pe.isOrthographicCamera===!0),C!==Pe&&(C=Pe,bn=!0,qt=!0)}if(at.isSkinnedMesh){sn.setOptional(ce,at,"bindMatrix"),sn.setOptional(ce,at,"bindMatrixInverse");const Hr=at.skeleton;Hr&&(Y.floatVertexTextures?(Hr.boneTexture===null&&Hr.computeBoneTexture(),sn.setValue(ce,"boneTexture",Hr.boneTexture,X)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}at.isBatchedMesh&&(sn.setOptional(ce,at,"batchingTexture"),sn.setValue(ce,"batchingTexture",at._matricesTexture,X));const mr=ht.morphAttributes;if((mr.position!==void 0||mr.normal!==void 0||mr.color!==void 0&&Y.isWebGL2===!0)&&Qe.update(at,ht,gn),(bn||Ct.receiveShadow!==at.receiveShadow)&&(Ct.receiveShadow=at.receiveShadow,sn.setValue(ce,"receiveShadow",at.receiveShadow)),mt.isMeshGouraudMaterial&&mt.envMap!==null&&(Jt.envMap.value=Xe,Jt.flipEnvMap.value=Xe.isCubeTexture&&Xe.isRenderTargetTexture===!1?-1:1),bn&&(sn.setValue(ce,"toneMappingExposure",N.toneMappingExposure),Ct.needsLights&&oi(Jt,qt),Dt&&mt.fog===!0&&me.refreshFogUniforms(Jt,Dt),me.refreshMaterialUniforms(Jt,mt,I,G,ue),U1.upload(ce,nr(Ct),Jt,X)),mt.isShaderMaterial&&mt.uniformsNeedUpdate===!0&&(U1.upload(ce,nr(Ct),Jt,X),mt.uniformsNeedUpdate=!1),mt.isSpriteMaterial&&sn.setValue(ce,"center",at.center),sn.setValue(ce,"modelViewMatrix",at.modelViewMatrix),sn.setValue(ce,"normalMatrix",at.normalMatrix),sn.setValue(ce,"modelMatrix",at.matrixWorld),mt.isShaderMaterial||mt.isRawShaderMaterial){const Hr=mt.uniformsGroups;for(let Jn=0,Bn=Hr.length;Jn<Bn;Jn++)if(Y.isWebGL2){const gt=Hr[Jn];Ce.update(gt,gn),Ce.bind(gt,gn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return gn}function oi(Pe,tt){Pe.ambientLightColor.needsUpdate=tt,Pe.lightProbe.needsUpdate=tt,Pe.directionalLights.needsUpdate=tt,Pe.directionalLightShadows.needsUpdate=tt,Pe.pointLights.needsUpdate=tt,Pe.pointLightShadows.needsUpdate=tt,Pe.spotLights.needsUpdate=tt,Pe.spotLightShadows.needsUpdate=tt,Pe.rectAreaLights.needsUpdate=tt,Pe.hemisphereLights.needsUpdate=tt}function da(Pe){return Pe.isMeshLambertMaterial||Pe.isMeshToonMaterial||Pe.isMeshPhongMaterial||Pe.isMeshStandardMaterial||Pe.isShadowMaterial||Pe.isShaderMaterial&&Pe.lights===!0}this.getActiveCubeFace=function(){return M},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(Pe,tt,ht){re.get(Pe.texture).__webglTexture=tt,re.get(Pe.depthTexture).__webglTexture=ht;const mt=re.get(Pe);mt.__hasExternalTextures=!0,mt.__hasExternalTextures&&(mt.__autoAllocateDepthBuffer=ht===void 0,mt.__autoAllocateDepthBuffer||V.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),mt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(Pe,tt){const ht=re.get(Pe);ht.__webglFramebuffer=tt,ht.__useDefaultFramebuffer=tt===void 0},this.setRenderTarget=function(Pe,tt=0,ht=0){k=Pe,M=tt,A=ht;let mt=!0,at=null,Dt=!1,he=!1;if(Pe){const Xe=re.get(Pe);Xe.__useDefaultFramebuffer!==void 0?(de.bindFramebuffer(ce.FRAMEBUFFER,null),mt=!1):Xe.__webglFramebuffer===void 0?X.setupRenderTarget(Pe):Xe.__hasExternalTextures&&X.rebindTextures(Pe,re.get(Pe.texture).__webglTexture,re.get(Pe.depthTexture).__webglTexture);const He=Pe.texture;(He.isData3DTexture||He.isDataArrayTexture||He.isCompressedArrayTexture)&&(he=!0);const ge=re.get(Pe).__webglFramebuffer;Pe.isWebGLCubeRenderTarget?(Array.isArray(ge[tt])?at=ge[tt][ht]:at=ge[tt],Dt=!0):Y.isWebGL2&&Pe.samples>0&&X.useMultisampledRTT(Pe)===!1?at=re.get(Pe).__webglMultisampledFramebuffer:Array.isArray(ge)?at=ge[ht]:at=ge,P.copy(Pe.viewport),U.copy(Pe.scissor),F=Pe.scissorTest}else P.copy(se).multiplyScalar(I).floor(),U.copy(H).multiplyScalar(I).floor(),F=W;if(de.bindFramebuffer(ce.FRAMEBUFFER,at)&&Y.drawBuffers&&mt&&de.drawBuffers(Pe,at),de.viewport(P),de.scissor(U),de.setScissorTest(F),Dt){const Xe=re.get(Pe.texture);ce.framebufferTexture2D(ce.FRAMEBUFFER,ce.COLOR_ATTACHMENT0,ce.TEXTURE_CUBE_MAP_POSITIVE_X+tt,Xe.__webglTexture,ht)}else if(he){const Xe=re.get(Pe.texture),He=tt||0;ce.framebufferTextureLayer(ce.FRAMEBUFFER,ce.COLOR_ATTACHMENT0,Xe.__webglTexture,ht||0,He)}R=-1},this.readRenderTargetPixels=function(Pe,tt,ht,mt,at,Dt,he){if(!(Pe&&Pe.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ie=re.get(Pe).__webglFramebuffer;if(Pe.isWebGLCubeRenderTarget&&he!==void 0&&(Ie=Ie[he]),Ie){de.bindFramebuffer(ce.FRAMEBUFFER,Ie);try{const Xe=Pe.texture,He=Xe.format,ge=Xe.type;if(He!==tl&&ve.convert(He)!==ce.getParameter(ce.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const rt=ge===oy&&(V.has("EXT_color_buffer_half_float")||Y.isWebGL2&&V.has("EXT_color_buffer_float"));if(ge!==_h&&ve.convert(ge)!==ce.getParameter(ce.IMPLEMENTATION_COLOR_READ_TYPE)&&!(ge===Eu&&(Y.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float")))&&!rt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}tt>=0&&tt<=Pe.width-mt&&ht>=0&&ht<=Pe.height-at&&ce.readPixels(tt,ht,mt,at,ve.convert(He),ve.convert(ge),Dt)}finally{const Xe=k!==null?re.get(k).__webglFramebuffer:null;de.bindFramebuffer(ce.FRAMEBUFFER,Xe)}}},this.copyFramebufferToTexture=function(Pe,tt,ht=0){const mt=Math.pow(2,-ht),at=Math.floor(tt.image.width*mt),Dt=Math.floor(tt.image.height*mt);X.setTexture2D(tt,0),ce.copyTexSubImage2D(ce.TEXTURE_2D,ht,0,0,Pe.x,Pe.y,at,Dt),de.unbindTexture()},this.copyTextureToTexture=function(Pe,tt,ht,mt=0){const at=tt.image.width,Dt=tt.image.height,he=ve.convert(ht.format),Ie=ve.convert(ht.type);X.setTexture2D(ht,0),ce.pixelStorei(ce.UNPACK_FLIP_Y_WEBGL,ht.flipY),ce.pixelStorei(ce.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ht.premultiplyAlpha),ce.pixelStorei(ce.UNPACK_ALIGNMENT,ht.unpackAlignment),tt.isDataTexture?ce.texSubImage2D(ce.TEXTURE_2D,mt,Pe.x,Pe.y,at,Dt,he,Ie,tt.image.data):tt.isCompressedTexture?ce.compressedTexSubImage2D(ce.TEXTURE_2D,mt,Pe.x,Pe.y,tt.mipmaps[0].width,tt.mipmaps[0].height,he,tt.mipmaps[0].data):ce.texSubImage2D(ce.TEXTURE_2D,mt,Pe.x,Pe.y,he,Ie,tt.image),mt===0&&ht.generateMipmaps&&ce.generateMipmap(ce.TEXTURE_2D),de.unbindTexture()},this.copyTextureToTexture3D=function(Pe,tt,ht,mt,at=0){if(N.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Dt=Pe.max.x-Pe.min.x+1,he=Pe.max.y-Pe.min.y+1,Ie=Pe.max.z-Pe.min.z+1,Xe=ve.convert(mt.format),He=ve.convert(mt.type);let ge;if(mt.isData3DTexture)X.setTexture3D(mt,0),ge=ce.TEXTURE_3D;else if(mt.isDataArrayTexture)X.setTexture2DArray(mt,0),ge=ce.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ce.pixelStorei(ce.UNPACK_FLIP_Y_WEBGL,mt.flipY),ce.pixelStorei(ce.UNPACK_PREMULTIPLY_ALPHA_WEBGL,mt.premultiplyAlpha),ce.pixelStorei(ce.UNPACK_ALIGNMENT,mt.unpackAlignment);const rt=ce.getParameter(ce.UNPACK_ROW_LENGTH),ut=ce.getParameter(ce.UNPACK_IMAGE_HEIGHT),it=ce.getParameter(ce.UNPACK_SKIP_PIXELS),Tt=ce.getParameter(ce.UNPACK_SKIP_ROWS),Ut=ce.getParameter(ce.UNPACK_SKIP_IMAGES),jt=ht.isCompressedTexture?ht.mipmaps[0]:ht.image;ce.pixelStorei(ce.UNPACK_ROW_LENGTH,jt.width),ce.pixelStorei(ce.UNPACK_IMAGE_HEIGHT,jt.height),ce.pixelStorei(ce.UNPACK_SKIP_PIXELS,Pe.min.x),ce.pixelStorei(ce.UNPACK_SKIP_ROWS,Pe.min.y),ce.pixelStorei(ce.UNPACK_SKIP_IMAGES,Pe.min.z),ht.isDataTexture||ht.isData3DTexture?ce.texSubImage3D(ge,at,tt.x,tt.y,tt.z,Dt,he,Ie,Xe,He,jt.data):ht.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ce.compressedTexSubImage3D(ge,at,tt.x,tt.y,tt.z,Dt,he,Ie,Xe,jt.data)):ce.texSubImage3D(ge,at,tt.x,tt.y,tt.z,Dt,he,Ie,Xe,He,jt),ce.pixelStorei(ce.UNPACK_ROW_LENGTH,rt),ce.pixelStorei(ce.UNPACK_IMAGE_HEIGHT,ut),ce.pixelStorei(ce.UNPACK_SKIP_PIXELS,it),ce.pixelStorei(ce.UNPACK_SKIP_ROWS,Tt),ce.pixelStorei(ce.UNPACK_SKIP_IMAGES,Ut),at===0&&mt.generateMipmaps&&ce.generateMipmap(ge),de.unbindTexture()},this.initTexture=function(Pe){Pe.isCubeTexture?X.setTextureCube(Pe,0):Pe.isData3DTexture?X.setTexture3D(Pe,0):Pe.isDataArrayTexture||Pe.isCompressedArrayTexture?X.setTexture2DArray(Pe,0):X.setTexture2D(Pe,0),de.unbindTexture()},this.resetState=function(){M=0,A=0,k=null,de.reset(),ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return fc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===_O?"display-p3":"srgb",n.unpackColorSpace=Cr.workingColorSpace===Bk?"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===Ia?tm:ZK}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===tm?Ia:Ku}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 fke extends I3{}fke.prototype.isWebGL1Renderer=!0;class TO{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new dn(e),this.near=n,this.far=r}clone(){return new TO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class mke extends Ss{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 pke{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=R3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Ou()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ou()),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=Ou()),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 ms=new Ye;class uh{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++)ms.fromBufferAttribute(this,n),ms.applyMatrix4(e),this.setXYZ(n,ms.x,ms.y,ms.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ms.fromBufferAttribute(this,n),ms.applyNormalMatrix(e),this.setXYZ(n,ms.x,ms.y,ms.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ms.fromBufferAttribute(this,n),ms.transformDirection(e),this.setXYZ(n,ms.x,ms.y,ms.z);return this}setX(e,n){return this.normalized&&(n=Ar(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Ar(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Ar(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Ar(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=cc(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=cc(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=cc(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=cc(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Ar(n,this.array),r=Ar(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=Ar(n,this.array),r=Ar(r,this.array),i=Ar(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(n=Ar(n,this.array),r=Ar(r,this.array),i=Ar(i,this.array),s=Ar(s,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return new No(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 uh(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class gke extends qs{constructor(e=null,n=1,r=1,i,s,o,l,c,u=Fa,d=Fa,h,p){super(null,o,l,c,u,d,i,s,h,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function bke(t,e){return t.z-e.z}function xke(t,e){return e.z-t.z}class yke{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const s=r[this.index];i.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=n}reset(){this.list.length=0,this.index=0}}const rg="batchId",$d=new Vr,U6=new Vr,vke=new Vr,B6=new Vr,TA=new Hk,U_=new ol,Mf=new gc,Xx=new Ye,AA=new yke,Qa=new Il,B_=[];function wke(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let s=0;s<i;s++)for(let o=0;o<r;o++)e.setComponent(s+n,o,t.getComponent(s,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class _ke extends Il{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new ss,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 gke(n,e,e,tl,Eu);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:h}=c,p=new u.constructor(r*d),m=new c.constructor(p,d,h);m.setUsage(c.usage),n.setAttribute(l,m)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new No(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(rg,new No(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(rg))throw new Error(`BatchedMesh: Geometry cannot use attribute "${rg}"`);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===rg)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=n.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ol);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,$d),this.getBoundingBoxAt(i,U_).applyMatrix4($d),n.union(U_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new gc);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,$d),this.getBoundingSphereAt(i,Mf).applyMatrix4($d),n.union(Mf))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,s===null?i.vertexStart=0:i.vertexStart=s.vertexStart+s.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,s===null?i.indexStart=0:i.indexStart=s.indexStart+s.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._visibility,p=this._active,m=this._matricesTexture,b=this._matricesTexture.image.data;h.push(!0),p.push(!0);const y=this._geometryCount;this._geometryCount++,vke.toArray(b,y*16),m.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new ol,sphereInitialized:!1,sphere:new gc});const x=this.geometry.getAttribute(rg);for(let v=0;v<i.vertexCount;v++)x.setX(i.vertexStart+v,y);return x.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,s=r.getIndex(),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===rg)continue;const b=n.getAttribute(m),y=r.getAttribute(m);wke(b,y,c);const x=b.itemSize;for(let v=b.count,S=u;v<S;v++){const N=c+v;for(let T=0;T<x;T++)y.setComponent(N,T,0)}y.needsUpdate=!0}if(i){const m=l.indexStart;for(let b=0;b<o.count;b++)s.setX(m+b,c+o.getX(b));for(let b=o.count,y=l.indexCount;b<y;b++)s.setX(m+b,c);s.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const h=this._drawRanges[e],p=n.getAttribute("position");return h.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],s=i.box,o=this.geometry;if(i.boxInitialized===!1){s.makeEmpty();const l=o.index,c=o.attributes.position,u=this._drawRanges[e];for(let d=u.start,h=u.start+u.count;d<h;d++){let p=d;l&&(p=l.getX(p)),s.expandByPoint(Xx.fromBufferAttribute(c,p))}i.boxInitialized=!0}return n.copy(s),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],s=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,U_),U_.getCenter(s.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let h=u.start,p=u.start+u.count;h<p;h++){let m=h;l&&(m=l.getX(m)),Xx.fromBufferAttribute(c,m),d=Math.max(d,s.center.distanceToSquared(Xx))}s.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(s),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(s,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,s=this._geometryCount;return e>=s||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,s=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;Qa.material=this.material,Qa.geometry.index=c.index,Qa.geometry.attributes=c.attributes,Qa.geometry.boundingBox===null&&(Qa.geometry.boundingBox=new ol),Qa.geometry.boundingSphere===null&&(Qa.geometry.boundingSphere=new gc);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=s[u];Qa.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Qa.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Qa.geometry.boundingBox),this.getBoundingSphereAt(u,Qa.geometry.boundingSphere),Qa.raycast(e,B_);for(let h=0,p=B_.length;h<p;h++){const m=B_[h];m.object=this,m.batchId=u,n.push(m)}B_.length=0}Qa.material=null,Qa.geometry.index=null,Qa.geometry.attributes={},Qa.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,h=this._drawRanges,p=this.perObjectFrustumCulled;p&&(B6.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),TA.setFromProjectionMatrix(B6,e.isWebGPURenderer?ly:fc));let m=0;if(this.sortObjects){U6.copy(this.matrixWorld).invert(),Xx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(U6);for(let x=0,v=c.length;x<v;x++)if(c[x]){this.getMatrixAt(x,$d),this.getBoundingSphereAt(x,Mf).applyMatrix4($d);let S=!1;if(p&&(S=!TA.intersectsSphere(Mf)),!S){const N=Xx.distanceTo(Mf.center);AA.push(h[x],N)}}const b=AA.list,y=this.customSort;y===null?b.sort(s.transparent?xke:bke):y.call(this,b,r);for(let x=0,v=b.length;x<v;x++){const S=b[x];u[m]=S.start*l,d[m]=S.count,m++}AA.reset()}else for(let b=0,y=c.length;b<y;b++)if(c[b]){let x=!1;if(p&&(this.getMatrixAt(b,$d),this.getBoundingSphereAt(b,Mf).applyMatrix4($d),x=!TA.intersectsSphere(Mf)),!x){const v=h[b];u[m]=v.start*l,d[m]=v.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,o){this.onBeforeRender(e,null,i,s,o)}}class Ky extends Pb{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new dn(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 H6=new Ye,$6=new Ye,V6=new Vr,CA=new NO,H_=new gc;let Ske=class extends Ss{constructor(e=new ss,n=new Ky){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,s=n.count;i<s;i++)H6.fromBufferAttribute(n,i-1),$6.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=H6.distanceTo($6);e.setAttribute("lineDistance",new Ai(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),H_.copy(r.boundingSphere),H_.applyMatrix4(i),H_.radius+=s,e.ray.intersectsSphere(H_)===!1)return;V6.copy(i).invert(),CA.copy(e.ray).applyMatrix4(V6);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new Ye,d=new Ye,h=new Ye,p=new Ye,m=this.isLineSegments?2:1,b=r.index,x=r.attributes.position;if(b!==null){const v=Math.max(0,o.start),S=Math.min(b.count,o.start+o.count);for(let N=v,T=S-1;N<T;N+=m){const M=b.getX(N),A=b.getX(N+1);if(u.fromBufferAttribute(x,M),d.fromBufferAttribute(x,A),CA.distanceSqToSegment(u,d,p,h)>c)continue;p.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(p);R<e.near||R>e.far||n.push({distance:R,point:h.clone().applyMatrix4(this.matrixWorld),index:N,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let N=v,T=S-1;N<T;N+=m){if(u.fromBufferAttribute(x,N),d.fromBufferAttribute(x,N+1),CA.distanceSqToSegment(u,d,p,h)>c)continue;p.applyMatrix4(this.matrixWorld);const A=e.ray.origin.distanceTo(p);A<e.near||A>e.far||n.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:N,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}};const G6=new Ye,q6=new Ye;class Vk extends Ske{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,s=n.count;i<s;i+=2)G6.fromBufferAttribute(n,i),q6.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+G6.distanceTo(q6);e.setAttribute("lineDistance",new Ai(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Nke extends ss{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Ye,s=new Ye;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 h=c[u],p=h.start,m=h.count;for(let b=p,y=p+m;b<y;b+=3)for(let x=0;x<3;x++){const v=l.getX(b+x),S=l.getX(b+(x+1)%3);i.fromBufferAttribute(o,v),s.fromBufferAttribute(o,S),W6(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}}else{const o=e.attributes.position;for(let l=0,c=o.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,h=3*l+(u+1)%3;i.fromBufferAttribute(o,d),s.fromBufferAttribute(o,h),W6(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ai(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function W6(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 kke extends Pb{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new dn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new dn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=JK,this.normalScale=new _n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=vO,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 Mke extends Ky{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 wX extends Ss{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new dn(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 PA=new Vr,K6=new Ye,X6=new Ye;class Eke{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new _n(512,512),this.map=null,this.mapPass=null,this.matrix=new Vr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Hk,this._frameExtents=new _n(1,1),this._viewportCount=1,this._viewports=[new jr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;K6.setFromMatrixPosition(e.matrixWorld),n.position.copy(K6),X6.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(X6),n.updateMatrixWorld(),PA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(PA),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(PA)}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 Y6=new Vr,Yx=new Ye,jA=new Ye;class Tke extends Eke{constructor(){super(new go(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new _n(4,2),this._viewportCount=6,this._viewports=[new jr(2,1,1,1),new jr(0,1,1,1),new jr(3,1,1,1),new jr(1,1,1,1),new jr(3,0,1,1),new jr(1,0,1,1)],this._cubeDirections=[new Ye(1,0,0),new Ye(-1,0,0),new Ye(0,0,1),new Ye(0,0,-1),new Ye(0,1,0),new Ye(0,-1,0)],this._cubeUps=[new Ye(0,1,0),new Ye(0,1,0),new Ye(0,1,0),new Ye(0,1,0),new Ye(0,0,1),new Ye(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Yx.setFromMatrixPosition(e.matrixWorld),r.position.copy(Yx),jA.copy(r.position),jA.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(jA),r.updateMatrixWorld(),i.makeTranslation(-Yx.x,-Yx.y,-Yx.z),Y6.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Y6)}}class Ake extends wX{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 Tke}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 Cke extends wX{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class Pke extends ss{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 z3 extends pke{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 Q6{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(za(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Z6=new Ye,$_=new Ye;class jke{constructor(e=new Ye,n=new Ye){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){Z6.subVectors(e,this.start),$_.subVectors(this.end,this.start);const r=$_.dot($_);let s=$_.dot(Z6)/r;return n&&(s=za(s,0,1)),s}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class Dke extends Vk{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 ss;i.setAttribute("position",new Ai(n,3)),i.setAttribute("color",new Ai(r,3));const s=new Ky({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new dn,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(n),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:zk}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=zk);class bc{constructor(e,n,r,i,s="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(s),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),bc.nextNameID=bc.nextNameID||0,this.$name.id=`lil-gui-name-${++bc.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 Rke extends bc{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 U3(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 Oke={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:U3,toHexString:U3},uy={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},Lke={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=uy.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 uy.toHexString(i)}},Fke={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=uy.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 uy.toHexString(i)}},Ike=[Oke,uy,Lke,Fke];function zke(t){return Ike.find(e=>e.match(t))}class Uke extends bc{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=zke(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const s=U3(this.$text.value);s&&this._setValueFromHexString(s)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class DA extends bc{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 Bke extends bc{constructor(e,n,r,i,s,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(s);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let S=parseFloat(this.$input.value);isNaN(S)||(this._stepExplicit&&(S=this._snap(S)),this.setValue(this._clamp(S)))},r=S=>{const N=parseFloat(this.$input.value);isNaN(N)||(this._snapClampSetValue(N+S),this.$input.value=this.getValue())},i=S=>{S.key==="Enter"&&this.$input.blur(),S.code==="ArrowUp"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S))),S.code==="ArrowDown"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S)*-1))},s=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,h;const p=5,m=S=>{l=S.clientX,c=u=S.clientY,o=!0,d=this.getValue(),h=0,window.addEventListener("mousemove",b),window.addEventListener("mouseup",y)},b=S=>{if(o){const N=S.clientX-l,T=S.clientY-c;Math.abs(T)>p?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(N)>p&&y()}if(!o){const N=S.clientY-u;h-=N*this._step*this._arrowKeyMultiplier(S),d+h>this._max?h=this._max-d:d+h<this._min&&(h=this._min-d),this._snapClampSetValue(d+h)}u=S.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)},x=()=>{this._inputFocused=!0},v=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",x),this.$input.addEventListener("blur",v)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(v,S,N,T,M)=>(v-S)/(N-S)*(M-T)+T,n=v=>{const S=this.$slider.getBoundingClientRect();let N=e(v,S.left,S.right,this._min,this._max);this._snapClampSetValue(N)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=v=>{n(v.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let o=!1,l,c;const u=v=>{v.preventDefault(),this._setDraggingStyle(!0),n(v.touches[0].clientX),o=!1},d=v=>{v.touches.length>1||(this._hasScrollBar?(l=v.touches[0].clientX,c=v.touches[0].clientY,o=!0):u(v),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",p))},h=v=>{if(o){const S=v.touches[0].clientX-l,N=v.touches[0].clientY-c;Math.abs(S)>Math.abs(N)?u(v):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",p))}else v.preventDefault(),n(v.touches[0].clientX)},p=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",p)},m=this._callOnFinishChange.bind(this),b=400;let y;const x=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const N=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+N),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(m,b)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",x,{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 Hke extends bc{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 $ke extends bc{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 Vke=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function Gke(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 J6=!1;class wS{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:s="Controls",closeFolders:o=!1,injectStyles:l=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!J6&&l&&(Gke(Vke),J6=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=o}add(e,n,r,i,s){if(Object(r)===r)return new Hke(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new Bke(this,e,n,r,i,s);case"boolean":return new Rke(this,e,n);case"string":return new $ke(this,e,n);case"function":return new DA(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new Uke(this,e,n,r)}addFolder(e){const n=new wS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof DA||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 DA)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function RA(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(h){h(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class AO{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 AO(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 CO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class eH extends CO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Vd extends CO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class tH{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class _S{constructor(e){this.lines=[],this.preamble=new tH(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((s=>s.comment))).thumbnails;for(const[s,o]of Object.entries(i))this.metadata.thumbnails[s]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),s=i[0],o=n&&i[1]||void 0,l=s.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new eH(e,c,u,o);case"t0":return new Vd(e,c,o,0);case"t1":return new Vd(e,c,o,1);case"t2":return new Vd(e,c,o,2);case"t3":return new Vd(e,c,o,3);case"t4":return new Vd(e,c,o,4);case"t5":return new Vd(e,c,o,5);case"t6":return new Vd(e,c,o,6);case"t7":return new Vd(e,c,o,7);default:return new CO(e,c,u,o)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,s)=>{if(i%2==0)return n;let o=s[i-1];return o=o.toLowerCase(),this.isAlpha(o)&&(n[o]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof eH){const s=i.params;if(s.z&&(this.curZ=s.z),((n=s.e)!==null&&n!==void 0?n:0)>0&&(s.x!=null||s.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new tH(this.layers.length,[],r,o))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const s=i.comment;if(!s)continue;const o=s.indexOf("thumbnail begin"),l=s.indexOf("thumbnail end");o>-1?r=AO.parse(s.slice(o+15).trim()):r&&(l==-1?r.chars+=s.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}_S.prototype.parseGcode=_S.prototype.parseGCode;const nH={type:"change"},OA={type:"start"},rH={type:"end"},V_=new NO,iH=new Yd,qke=Math.cos(70*tX.DEG2RAD);class Wke extends zm{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Ye,this.cursor=new Ye,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:zp.ROTATE,MIDDLE:zp.DOLLY,RIGHT:zp.PAN},this.touches={ONE:Up.ROTATE,TWO:Up.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",Fe),this._domElementKeyEvents=Y},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Fe),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(nH),r.update(),s=i.NONE},this.update=(function(){const Y=new Ye,de=new Sm().setFromUnitVectors(e.up,new Ye(0,1,0)),q=de.clone().invert(),re=new Ye,X=new Sm,le=new Ye,pe=2*Math.PI;return function(ee=null){const z=r.object.position;Y.copy(z).sub(r.target),Y.applyQuaternion(de),l.setFromVector3(Y),r.autoRotate&&s===i.NONE&&P((function(Te){return Te!==null?2*Math.PI/60*r.autoRotateSpeed*Te:2*Math.PI/60/60*r.autoRotateSpeed})(ee)),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,Z=r.maxAzimuthAngle;isFinite(O)&&isFinite(Z)&&(O<-Math.PI?O+=pe:O>Math.PI&&(O-=pe),Z<-Math.PI?Z+=pe:Z>Math.PI&&(Z-=pe),l.theta=O<=Z?Math.max(O,Math.min(Z,l.theta)):l.theta>(O+Z)/2?Math.max(O,l.theta):Math.min(Z,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&&A||r.object.isOrthographicCamera?l.radius=K(l.radius):l.radius=K(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 me=!1;if(r.zoomToCursor&&A){let Te=null;if(r.object.isPerspectiveCamera){const ke=Y.length();Te=K(ke*u);const Ee=ke-Te;r.object.position.addScaledVector(T,Ee),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ke=new Ye(M.x,M.y,0);ke.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),me=!0;const Ee=new Ye(M.x,M.y,0);Ee.unproject(r.object),r.object.position.sub(Ee).add(ke),r.object.updateMatrixWorld(),Te=Y.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;Te!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(Te).add(r.object.position):(V_.origin.copy(r.object.position),V_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(V_.direction))<qke?e.lookAt(r.target):(iH.setFromNormalAndCoplanarPoint(r.object.up,r.target),V_.intersectPlane(iH,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),me=!0);return u=1,A=!1,!!(me||re.distanceToSquared(r.object.position)>o||8*(1-X.dot(r.object.quaternion))>o||le.distanceToSquared(r.target)>0)&&(r.dispatchEvent(nH),re.copy(r.object.position),X.copy(r.object.quaternion),le.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ce),r.domElement.removeEventListener("pointerdown",fe),r.domElement.removeEventListener("pointercancel",oe),r.domElement.removeEventListener("wheel",Ne),r.domElement.removeEventListener("pointermove",De),r.domElement.removeEventListener("pointerup",oe),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Fe),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const o=1e-6,l=new Q6,c=new Q6;let u=1;const d=new Ye,h=new _n,p=new _n,m=new _n,b=new _n,y=new _n,x=new _n,v=new _n,S=new _n,N=new _n,T=new Ye,M=new _n;let A=!1;const k=[],R={};function C(){return Math.pow(.95,r.zoomSpeed)}function P(Y){c.theta-=Y}function U(Y){c.phi-=Y}const F=(function(){const Y=new Ye;return function(de,q){Y.setFromMatrixColumn(q,0),Y.multiplyScalar(-de),d.add(Y)}})(),B=(function(){const Y=new Ye;return function(de,q){r.screenSpacePanning===!0?Y.setFromMatrixColumn(q,1):(Y.setFromMatrixColumn(q,0),Y.crossVectors(r.object.up,Y)),Y.multiplyScalar(de),d.add(Y)}})(),D=(function(){const Y=new Ye;return function(de,q){const re=r.domElement;if(r.object.isPerspectiveCamera){const X=r.object.position;Y.copy(X).sub(r.target);let le=Y.length();le*=Math.tan(r.object.fov/2*Math.PI/180),F(2*de*le/re.clientHeight,r.object.matrix),B(2*q*le/re.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(F(de*(r.object.right-r.object.left)/r.object.zoom/re.clientWidth,r.object.matrix),B(q*(r.object.top-r.object.bottom)/r.object.zoom/re.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 G(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 I(Y){if(!r.zoomToCursor)return;A=!0;const de=r.domElement.getBoundingClientRect(),q=Y.clientX-de.left,re=Y.clientY-de.top,X=de.width,le=de.height;M.x=q/X*2-1,M.y=-re/le*2+1,T.set(M.x,M.y,1).unproject(r.object).sub(r.object.position).normalize()}function K(Y){return Math.max(r.minDistance,Math.min(r.maxDistance,Y))}function Q(Y){h.set(Y.clientX,Y.clientY)}function se(Y){b.set(Y.clientX,Y.clientY)}function H(){if(k.length===1)h.set(k[0].pageX,k[0].pageY);else{const Y=.5*(k[0].pageX+k[1].pageX),de=.5*(k[0].pageY+k[1].pageY);h.set(Y,de)}}function W(){if(k.length===1)b.set(k[0].pageX,k[0].pageY);else{const Y=.5*(k[0].pageX+k[1].pageX),de=.5*(k[0].pageY+k[1].pageY);b.set(Y,de)}}function J(){const Y=k[0].pageX-k[1].pageX,de=k[0].pageY-k[1].pageY,q=Math.sqrt(Y*Y+de*de);v.set(0,q)}function ne(Y){if(k.length==1)p.set(Y.pageX,Y.pageY);else{const q=V(Y),re=.5*(Y.pageX+q.x),X=.5*(Y.pageY+q.y);p.set(re,X)}m.subVectors(p,h).multiplyScalar(r.rotateSpeed);const de=r.domElement;P(2*Math.PI*m.x/de.clientHeight),U(2*Math.PI*m.y/de.clientHeight),h.copy(p)}function xe(Y){if(k.length===1)y.set(Y.pageX,Y.pageY);else{const de=V(Y),q=.5*(Y.pageX+de.x),re=.5*(Y.pageY+de.y);y.set(q,re)}x.subVectors(y,b).multiplyScalar(r.panSpeed),D(x.x,x.y),b.copy(y)}function ue(Y){const de=V(Y),q=Y.pageX-de.x,re=Y.pageY-de.y,X=Math.sqrt(q*q+re*re);S.set(0,X),N.set(0,Math.pow(S.y/v.y,r.zoomSpeed)),$(N.y),v.copy(S)}function fe(Y){r.enabled!==!1&&(k.length===0&&(r.domElement.setPointerCapture(Y.pointerId),r.domElement.addEventListener("pointermove",De),r.domElement.addEventListener("pointerup",oe)),(function(de){k.push(de)})(Y),Y.pointerType==="touch"?(function(de){switch(Ve(de),k.length){case 1:switch(r.touches.ONE){case Up.ROTATE:if(r.enableRotate===!1)return;H(),s=i.TOUCH_ROTATE;break;case Up.PAN:if(r.enablePan===!1)return;W(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case Up.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&J(),r.enablePan&&W(),s=i.TOUCH_DOLLY_PAN;break;case Up.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&J(),r.enableRotate&&H(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(OA)})(Y):(function(de){let q;switch(de.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 zp.DOLLY:if(r.enableZoom===!1)return;(function(re){I(re),v.set(re.clientX,re.clientY)})(de),s=i.DOLLY;break;case zp.ROTATE:if(de.ctrlKey||de.metaKey||de.shiftKey){if(r.enablePan===!1)return;se(de),s=i.PAN}else{if(r.enableRotate===!1)return;Q(de),s=i.ROTATE}break;case zp.PAN:if(de.ctrlKey||de.metaKey||de.shiftKey){if(r.enableRotate===!1)return;Q(de),s=i.ROTATE}else{if(r.enablePan===!1)return;se(de),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(OA)})(Y))}function De(Y){r.enabled!==!1&&(Y.pointerType==="touch"?(function(de){switch(Ve(de),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ne(de),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;xe(de),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(q){r.enableZoom&&ue(q),r.enablePan&&xe(q)})(de),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(q){r.enableZoom&&ue(q),r.enableRotate&&ne(q)})(de),r.update();break;default:s=i.NONE}})(Y):(function(de){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(q){p.set(q.clientX,q.clientY),m.subVectors(p,h).multiplyScalar(r.rotateSpeed);const re=r.domElement;P(2*Math.PI*m.x/re.clientHeight),U(2*Math.PI*m.y/re.clientHeight),h.copy(p),r.update()})(de);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(q){S.set(q.clientX,q.clientY),N.subVectors(S,v),N.y>0?$(C()):N.y<0&&G(C()),v.copy(S),r.update()})(de);break;case i.PAN:if(r.enablePan===!1)return;(function(q){y.set(q.clientX,q.clientY),x.subVectors(y,b).multiplyScalar(r.panSpeed),D(x.x,x.y),b.copy(y),r.update()})(de)}})(Y))}function oe(Y){(function(de){delete R[de.pointerId];for(let q=0;q<k.length;q++)if(k[q].pointerId==de.pointerId)return void k.splice(q,1)})(Y),k.length===0&&(r.domElement.releasePointerCapture(Y.pointerId),r.domElement.removeEventListener("pointermove",De),r.domElement.removeEventListener("pointerup",oe)),r.dispatchEvent(rH),s=i.NONE}function Ne(Y){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(Y.preventDefault(),r.dispatchEvent(OA),(function(de){I(de),de.deltaY<0?G(C()):de.deltaY>0&&$(C()),r.update()})(Y),r.dispatchEvent(rH))}function Fe(Y){r.enabled!==!1&&r.enablePan!==!1&&(function(de){let q=!1;switch(de.code){case r.keys.UP:de.ctrlKey||de.metaKey||de.shiftKey?U(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,r.keyPanSpeed),q=!0;break;case r.keys.BOTTOM:de.ctrlKey||de.metaKey||de.shiftKey?U(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,-r.keyPanSpeed),q=!0;break;case r.keys.LEFT:de.ctrlKey||de.metaKey||de.shiftKey?P(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(r.keyPanSpeed,0),q=!0;break;case r.keys.RIGHT:de.ctrlKey||de.metaKey||de.shiftKey?P(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(-r.keyPanSpeed,0),q=!0}q&&(de.preventDefault(),r.update())})(Y)}function ce(Y){r.enabled!==!1&&Y.preventDefault()}function Ve(Y){let de=R[Y.pointerId];de===void 0&&(de=new _n,R[Y.pointerId]=de),de.set(Y.pageX,Y.pageY)}function V(Y){const de=Y.pointerId===k[0].pointerId?k[1]:k[0];return R[de.pointerId]}r.domElement.addEventListener("contextmenu",ce),r.domElement.addEventListener("pointerdown",fe),r.domElement.addEventListener("pointercancel",oe),r.domElement.addEventListener("wheel",Ne,{passive:!1}),this.update()}}Ot.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new _n(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Bs.line={uniforms:kO.merge([Ot.common,Ot.fog,Ot.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class _X extends Oh{constructor(e){super({type:"LineMaterial",uniforms:kO.clone(Bs.line.uniforms),vertexShader:Bs.line.vertexShader,fragmentShader:Bs.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 aH=new ol,G_=new Ye;class SX extends Pke{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 Ai([-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 Ai([-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 z3(n,6,1);return this.setAttribute("instanceStart",new uh(r,3,0)),this.setAttribute("instanceEnd",new uh(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 z3(n,6,1);return this.setAttribute("instanceColorStart",new uh(r,3,0)),this.setAttribute("instanceColorEnd",new uh(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 Nke(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ol);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),aH.setFromBufferAttribute(n),this.boundingBox.union(aH))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new gc),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)G_.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(G_)),G_.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(G_));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 sH=new Ye,oH=new Ye,ja=new jr,Da=new jr,ec=new jr,LA=new Ye,FA=new Vr,Ra=new jke,lH=new Ye,q_=new ol,W_=new gc,tc=new jr;let nc,zf;function cH(t,e,n){return tc.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),tc.multiplyScalar(1/tc.w),tc.x=zf/n.width,tc.y=zf/n.height,tc.applyMatrix4(t.projectionMatrixInverse),tc.multiplyScalar(1/tc.w),Math.abs(Math.max(tc.x,tc.y))}class Kke extends Il{constructor(e=new SX,n=new _X({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)sH.fromBufferAttribute(n,o),oH.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+sH.distanceTo(oH);const s=new z3(i,2,1);return e.setAttribute("instanceDistanceStart",new uh(s,1,0)),e.setAttribute("instanceDistanceEnd",new uh(s,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;nc=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;zf=c.linewidth+s,l.boundingSphere===null&&l.computeBoundingSphere(),W_.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*zf:u=cH(i,Math.max(i.near,W_.distanceToPoint(nc.origin)),c.resolution),W_.radius+=u,nc.intersectsSphere(W_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),q_.copy(l.boundingBox).applyMatrix4(o),r?d=.5*zf:d=cH(i,Math.max(i.near,q_.distanceToPoint(nc.origin)),c.resolution),q_.expandByScalar(d),nc.intersectsBox(q_)!==!1&&(r?(function(h,p){const m=h.matrixWorld,b=h.geometry,y=b.attributes.instanceStart,x=b.attributes.instanceEnd;for(let v=0,S=Math.min(b.instanceCount,y.count);v<S;v++){Ra.start.fromBufferAttribute(y,v),Ra.end.fromBufferAttribute(x,v),Ra.applyMatrix4(m);const N=new Ye,T=new Ye;nc.distanceSqToSegment(Ra.start,Ra.end,T,N),T.distanceTo(N)<.5*zf&&p.push({point:T,pointOnLine:N,distance:nc.origin.distanceTo(T),object:h,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(h,p,m){const b=p.projectionMatrix,y=h.material.resolution,x=h.matrixWorld,v=h.geometry,S=v.attributes.instanceStart,N=v.attributes.instanceEnd,T=Math.min(v.instanceCount,S.count),M=-p.near;nc.at(1,ec),ec.w=1,ec.applyMatrix4(p.matrixWorldInverse),ec.applyMatrix4(b),ec.multiplyScalar(1/ec.w),ec.x*=y.x/2,ec.y*=y.y/2,ec.z=0,LA.copy(ec),FA.multiplyMatrices(p.matrixWorldInverse,x);for(let A=0,k=T;A<k;A++){if(ja.fromBufferAttribute(S,A),Da.fromBufferAttribute(N,A),ja.w=1,Da.w=1,ja.applyMatrix4(FA),Da.applyMatrix4(FA),ja.z>M&&Da.z>M)continue;if(ja.z>M){const F=ja.z-Da.z,B=(ja.z-M)/F;ja.lerp(Da,B)}else if(Da.z>M){const F=Da.z-ja.z,B=(Da.z-M)/F;Da.lerp(ja,B)}ja.applyMatrix4(b),Da.applyMatrix4(b),ja.multiplyScalar(1/ja.w),Da.multiplyScalar(1/Da.w),ja.x*=y.x/2,ja.y*=y.y/2,Da.x*=y.x/2,Da.y*=y.y/2,Ra.start.copy(ja),Ra.start.z=0,Ra.end.copy(Da),Ra.end.z=0;const R=Ra.closestPointToPointParameter(LA,!0);Ra.at(R,lH);const C=tX.lerp(ja.z,Da.z,R),P=C>=-1&&C<=1,U=LA.distanceTo(lH)<.5*zf;if(P&&U){Ra.start.fromBufferAttribute(S,A),Ra.end.fromBufferAttribute(N,A),Ra.start.applyMatrix4(x),Ra.end.applyMatrix4(x);const F=new Ye,B=new Ye;nc.distanceSqToSegment(Ra.start,Ra.end,B,F),m.push({point:B,pointOnLine:F,distance:nc.origin.distanceTo(B),object:h,face:null,faceIndex:A,uv:null,uv1:null})}}})(this,i,n)))}}class Xke extends Vk{constructor(e,n,r,i,s=4473924,o=8947848){s=new dn(s),o=new dn(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?s: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?s: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 h=new ss;h.setAttribute("position",new Ai(c,3)),h.setAttribute("color",new Ai(u,3)),super(h,new Ky({vertexColors:!0,toneMapped:!1}))}}function Yke(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new ss,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 Ai(d,3)),u})(t,e,n),s=new Vk(i,new Mke({color:new dn(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var T0=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),s=i,o=0,l=n(new T0.Panel("FPS","#0ff","#002")),c=n(new T0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new T0.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(c.update(d-i,200),d>=s+1e3&&(l.update(1e3*o/(d-s),100),s=d,o=0,u)){var h=performance.memory;u.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};T0.Panel=function(t,e,n){var r=1/0,i=0,s=Math.round,o=s(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,h=3*o,p=15*o,m=74*o,b=30*o,y=document.createElement("canvas");y.width=l,y.height=c,y.style.cssText="width:80px;height:48px";var x=y.getContext("2d");return x.font="bold "+9*o+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=n,x.fillRect(0,0,l,c),x.fillStyle=e,x.fillText(t,u,d),x.fillRect(h,p,m,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(h,p,m,b),{dom:y,update:function(v,S){r=Math.min(r,v),i=Math.max(i,v),x.fillStyle=n,x.globalAlpha=1,x.fillRect(0,0,l,p),x.fillStyle=e,x.fillText(s(v)+" "+t+" ("+s(r)+"-"+s(i)+")",u,d),x.drawImage(y,h+o,p,m-o,b,h,p,m-o,b),x.fillRect(h+m-o,p,o,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(h+m-o,p,o,s((1-v/S)*b))}}};var Qke=T0;class uH{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new wS,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 wS,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 Zke extends ss{constructor(e=[new Ye],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const s=new Ye,o=new Ye,l=new _n,c=[],u=[],d=[],h=[];function p(m){const[b,y,x]=(function(v){const S=e[v],N=new Ye,T=new Ye,M=new Ye,A=new Ye;N.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(N.x),C=Math.abs(N.y),P=Math.abs(N.z);return R<=k&&(k=R,T.set(1,0,0)),C<=k&&(k=C,T.set(0,1,0)),P<=k&&T.set(0,0,1),A.crossVectors(N,T).normalize(),T.crossVectors(N,A),M.crossVectors(N,T),[S,T,M]})(m);for(let v=0;v<=i;v++){const S=v/i*Math.PI*2,N=Math.sin(S),T=-Math.cos(S);o.x=T*y.x+N*x.x,o.y=T*y.y+N*x.y,o.z=T*y.z+N*x.z,o.normalize(),u.push(o.x,o.y,o.z),s.x=b.x+n*o.x*.5,s.y=b.y+n*o.y*.5,s.z=b.z+r*o.z*.5,c.push(s.x,s.y,s.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 b=0;b<=i;b++)l.x=m/e.length,l.y=b/i,d.push(l.x,l.y)})(),(function(){for(let m=1;m<e.length;m++)for(let b=1;b<=i;b++){const y=(i+1)*(m-1)+(b-1),x=(i+1)*m+(b-1),v=(i+1)*m+b,S=(i+1)*(m-1)+b;h.push(y,x,S),h.push(x,v,S)}})()})(),this.setIndex(h),this.setAttribute("position",new Ai(c,3)),this.setAttribute("normal",new Ai(u,3)),this.setAttribute("uv",new Ai(d,2))}}class A0{static get initial(){const e=new A0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const IA={h:0,s:0,l:0};class Ig{constructor(e){var n,r,i,s,o,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=A0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Ig.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new dn(14737632),this._travelColor=new dn(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 _S(this.minLayerThreshold),this.scene=new mke,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new dn(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(s=e.renderExtrusion)!==null&&s!==void 0?s:this.renderExtrusion,this.renderTravel=(o=e.renderTravel)!==null&&o!==void 0?o:this.renderTravel,this.nonTravelmoves=(l=e.nonTravelMoves)!==null&&l!==void 0?l:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new Qke:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new dn(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new dn(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new dn(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,b]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new dn(b)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+zk),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 I3({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 I3({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new go(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const h=this.camera.far,p=.8*h;this.scene.fog=new TO(this._backgroundColor,p,h),this.resize(),this.controls=new Wke(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 dn(r)}else this._extrusionColor=new dn(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Ig.defaultExtrusionColor:this._extrusionColor instanceof dn?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Ig.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new dn(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new dn(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new dn(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new dn(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 Dke(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 Cke(13421772,.3*Math.PI),n=new Ake(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 h0;return n.name=e,n.quaternion.setFromEuler(new qy(-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=A0.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 RA(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,s,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],h={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(h,e),h.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,b={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(s=m.params.r)!==null&&s!==void 0?s:this.state.r,e:(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 y=((u=m.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(p.gcode)>-1;(b.x!=this.state.x||b.y!=this.state.y||b.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(p.gcode=="g2"||p.gcode=="g3"||p.gcode=="g02"||p.gcode=="g03"?this.addArcSegment(h,this.state,b,y,p.gcode=="g2"||p.gcode=="g02"):this.addLineSegment(h,this.state,b,y))}this.state.x=b.x,this.state.y=b.y,this.state.z=b.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(h,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let s=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;s.getHSL(IA),s=new dn().setHSL(IA.h,IA.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:s,l=(i=this._lastSegmentColor)!==null&&i!==void 0?i:o,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,o.getHex(),e.height),this.addTubeLine([...u,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,o.getHex()),this.addLine([...u,...c],l.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,s.getHex(),e.height):this.addLine(e.extrusion,s.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new Xke(this.buildVolume.x,10,this.buildVolume.y,10));const e=Yke(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 _S(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=A0.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,s){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,h=r.y,p=r.z;let m=r.r,b=r.i,y=r.j;if(m){const $=d-l,G=h-c,I=Math.sqrt(Math.pow($/2,2)+Math.pow(G/2,2));m=Math.max(m,I);const K=Math.pow($,2)+Math.pow(G,2),Q=Math.pow(m,2)-K/4;let se=Math.sqrt(Q/K);(s&&m<0||!s&&m>0)&&(se=-se),b=$/2+G*se,y=G/2-$*se}const x=l==d&&c==h,v=l+b,S=c+y,N=Math.sqrt(b*b+y*y),T=Math.atan2(-y,-b),M=Math.atan2(h-S,d-v);let A;x?A=2*Math.PI:(A=s?T-M:M-T,A<0&&(A+=2*Math.PI));let k=N*A/1.8;this.inches&&(k*=25),k<1&&(k=1);let R=A/k;R*=s?-1:1;const C=[];C.push({x:l,y:c,z:u});const P=(u-p)/k;let U=l,F=c,B=u,D=T;for(let $=0;$<k-1;$++)D+=R,U=v+N*Math.cos(D),F=S+N*Math.sin(D),B+=P,C.push({x:U,y:F,z:B});C.push({x:r.x,y:r.y,z:r.z});for(let $=0;$<C.length-1;$++)o.push(C[$].x,C[$].y,C[$].z,C[$+1].x,C[$+1].y,C[$+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new ss;i.setAttribute("position",new Ai(e,3)),this.disposables.push(i);const s=new Ky({color:n});this.disposables.push(s);const o=new Vk(i,s);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const s=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new Ye(l[0],l[1],l[2]),u=new Ye(l[3],l[4],l[5]),d=new Ye(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),s.push(i),i=[])}s.forEach((o=>{var l;const c=new Zke(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 SX;this.disposables.push(i);const s=new _X({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const o=new Kke(i,s);(r=this.group)===null||r===void 0||r.add(o)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>RA(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 kke({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new _ke(r.length,s,void 0,i);return this.disposables.push(o),(n=this.group)===null||n===void 0||n.add(o),o}_readFromStream(e){var n,r;return RA(this,void 0,void 0,(function*(){const i=e.getReader();let s,o="",l=0;do{console.debug("reading from stream"),s=yield i.read(),l+=(r=(n=s.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=s.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),h=u.slice(0,d);this.parser.parseGCode(o+h),o=u.slice(d)}while(!s.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new uH(this):typeof this.devMode=="object"&&(this.devGui=new uH(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())}}Ig.defaultExtrusionColor=new dn("hotpink");function NX({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=_.useRef(null),s=_.useRef(null),o=_.useRef(null),l=_.useRef(!1),[c,u]=_.useState(!0),[d,h]=_.useState(null),[p,m]=_.useState(!1),[b,y]=_.useState(0),[x,v]=_.useState(0),S=_.useMemo(()=>JSON.stringify(n),[n]);_.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const M=i.current,A=M.parentElement?.getBoundingClientRect();A&&(M.width=A.width,M.height=A.height);const k=n&&n.length>1,R=n?.[0]||"#00ae42",C=new Ig({canvas:M,buildVolume:e,backgroundColor:1710618,extrusionColor:k?n:R,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});s.current=C;const P={},U=Ph();U&&(P.Authorization=`Bearer ${U}`),fetch(t,{headers:P}).then(async B=>{if(!B.ok)throw B.status===404&&(await B.json().catch(()=>({}))).detail?.includes("sliced")?(m(!0),new Error("not_sliced")):new Error("Failed to load G-code");return B.text()}).then(B=>{const D=new Set,$=/^(\s*)T(\d+)(\s*;.*)?$/gim;let G;for(;(G=$.exec(B))!==null;){const W=parseInt(G[2],10);W<=15&&D.add(W)}const I=new Map,K=Array.from(D).sort((W,J)=>W-J);K.forEach((W,J)=>{I.set(W,J%8)});const Q=[];K.forEach((W,J)=>{const ne=n?.[W]||"#00ae42";Q[J%8]=ne});const se=B.split(`
- `).map(W=>{const J=W.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(J){const ne=parseInt(J[2],10);if(ne>15)return`; FILTERED: ${W.trim()}`;const xe=I.get(ne)??0;return`${J[1]}T${xe}${J[3]||""}`}return W}).join(`
- `);Q.length>0&&(C.extrusionColor=Q),C.processGCode(se);const H=C.layers?.length||0;v(H),y(H),C.render(),u(!1)}).catch(B=>{B.message!=="not_sliced"&&h(B.message),u(!1)});const F=()=>{if(M.parentElement&&s.current){const B=M.parentElement.getBoundingClientRect();M.width=B.width,M.height=B.height,s.current.resize()}};return window.addEventListener("resize",F),()=>{window.removeEventListener("resize",F),o.current&&cancelAnimationFrame(o.current),s.current&&(s.current.dispose(),s.current=null),l.current=!1}},[t,S]);const N=_.useCallback(M=>{if(!s.current)return;const A=Math.max(1,Math.min(M,x));y(A),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{s.current&&(s.current.endLayer=A,s.current.render())})},[x]),T=M=>{N(parseInt(M.target.value,10))};return a.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[a.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsxs("div",{className:"text-center",children:[a.jsx(lt,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),p&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsxs("div",{className:"text-center max-w-sm px-4",children:[a.jsx(Que,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),a.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing in Bambu Studio or Orca Slicer."})]})}),d&&!p&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx("div",{className:"text-center text-red-400",children:a.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!p&&x>0&&a.jsx("div",{className:"mt-4 px-2",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(is,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("button",{onClick:()=>N(b-1),disabled:b<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(Th,{className:"w-4 h-4"})}),a.jsx("input",{type:"range",min:1,max:x,value:b,onChange:T,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),a.jsx("button",{onClick:()=>N(b+1),disabled:b>=x,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(Ns,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[b," / ",x]})]})})]})}function Jke({printerId:t,filePath:e,filename:n,onClose:r}){const[i,s]=_.useState(null),[o,l]=_.useState([]),[c,u]=_.useState(!1),[d,h]=_.useState(null),p=n.toLowerCase().split(".").pop()||"",m=p==="3mf"||p==="stl",b=p==="gcode"||p==="3mf";_.useEffect(()=>{s(m?"3d":b?"gcode":null)},[m,b]),_.useEffect(()=>{l([]),h(null),m&&(u(!0),ae.getPrinterFilePlates(t,e).then(v=>l(v.plates||[])).catch(()=>l([])).finally(()=>u(!1)))},[e,m,t]);const y=o.length>1,x=d==null?null:o.find(v=>v.index===d)??null;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-6",onClick:r,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:v=>v.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:n}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>m&&s("3d"),disabled:!m,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="3d"?"text-bambu-green border-b-2 border-bambu-green":m?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(zi,{className:"w-4 h-4"}),"3D Model",!m&&a.jsx("span",{className:"text-xs",children:"(not available)"})]}),a.jsxs("button",{onClick:()=>b&&s("gcode"),disabled:!b,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="gcode"?"text-bambu-green border-b-2 border-bambu-green":b?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(xs,{className:"w-4 h-4"}),"G-code Preview",!b&&a.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:i==="3d"&&m?a.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[y&&a.jsxs("div",{className:"rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray mb-2",children:[a.jsx(zi,{className:"w-4 h-4"}),"Plates",c&&a.jsx(lt,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>h(null),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d==null?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(zi,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:"All Plates"}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[o.length," plate",o.length!==1?"s":""]})]}),d==null&&a.jsx(Ks,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]}),o.map(v=>a.jsxs("button",{type:"button",onClick:()=>h(v.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d===v.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[v.has_thumbnail?a.jsx("img",{src:ae.getPrinterFilePlateThumbnail(t,v.index,e),alt:`Plate ${v.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(zi,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:v.name||`Plate ${v.index}`}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:v.objects.length>0?v.objects.slice(0,2).join(", ")+(v.objects.length>2?"…":""):`${v.filaments.length} filament${v.filaments.length!==1?"s":""}`})]}),d===v.index&&a.jsx(Ks,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},v.index))]}),x&&a.jsxs("div",{className:"mt-3 text-xs text-bambu-gray flex flex-wrap gap-x-4 gap-y-1",children:[a.jsxs("span",{children:["Plate ",x.index]}),x.print_time_seconds!=null&&a.jsxs("span",{children:["ETA ",Math.round(x.print_time_seconds/60)," min"]}),x.filament_used_grams!=null&&a.jsxs("span",{children:[x.filament_used_grams.toFixed(1)," g"]}),x.filaments.length>0&&a.jsxs("span",{children:[x.filaments.length," filament",x.filaments.length!==1?"s":""]})]})]}),a.jsx("div",{className:"flex-1",children:a.jsx(HK,{url:ae.getPrinterFileDownloadUrl(t,e),fileType:p,selectedPlateId:d,className:"w-full h-full"})})]}):i==="gcode"&&b?a.jsx(NX,{gcodeUrl:ae.getPrinterFileGcodeUrl(t,e),className:"w-full h-full"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function eMe(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 dH(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 tMe(t,e){if(e)return zW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Qf;case"gcode":return xs;case"mp4":case"avi":return gh;case"png":case"jpg":case"jpeg":return $u;default:return Nk}}const nMe=[{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 rMe({printerId:t,printerName:e,onClose:n}){const{t:r}=Yt(),{showToast:i}=kn(),s=nn(),[o,l]=_.useState("/"),[c,u]=_.useState(new Set),[d,h]=_.useState(""),[p,m]=_.useState([]),[b,y]=_.useState("name-asc"),[x,v]=_.useState(null),[S,N]=_.useState(null);_.useEffect(()=>{const I=K=>{K.key==="Escape"&&n()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[n]);const{data:T,isLoading:M,refetch:A}=nt({queryKey:["printerFiles",t,o],queryFn:()=>ae.getPrinterFiles(t,o)}),{data:k}=nt({queryKey:["printerStorage",t],queryFn:()=>ae.getPrinterStorage(t),staleTime:3e4}),R=dt({mutationFn:async I=>{for(const K of I)await ae.deletePrinterFile(t,K)},onSuccess:()=>{i(r("printerFiles.toast.filesDeleted",{count:p.length})),s.invalidateQueries({queryKey:["printerFiles",t]}),u(new Set),m([])},onError:I=>{i(r("printerFiles.toast.deleteFailed",{error:I.message}),"error")}}),C=I=>{l(I),u(new Set)},P=()=>{if(o==="/")return;const I=o.split("/").filter(Boolean);I.pop(),l(I.length?"/"+I.join("/"):"/"),u(new Set)},U=(I,K)=>{K.stopPropagation(),u(Q=>{const se=new Set(Q);return se.has(I)?se.delete(I):se.add(I),se})},F=()=>{if(!T?.files)return;const I=T.files.filter(K=>!K.is_directory&&(!d||K.name.toLowerCase().includes(d.toLowerCase()))).map(K=>K.path);u(new Set(I))},B=()=>{u(new Set)},D=async()=>{if(c.size===0)return;const I=Array.from(c);if(I.length===1){ae.downloadPrinterFile(t,I[0]).catch(K=>{console.error("Printer file download failed:",K)}),u(new Set);return}v({current:0,total:I.length});try{const K=await ae.downloadPrinterFilesAsZip(t,I),Q=URL.createObjectURL(K),se=document.createElement("a");se.href=Q,se.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(se),se.click(),document.body.removeChild(se),URL.revokeObjectURL(Q),i(`Downloaded ${I.length} files as ZIP`),u(new Set)}catch(K){i(`Download failed: ${K instanceof Error?K.message:"Unknown error"}`,"error")}finally{v(null)}},$=()=>{c.size!==0&&m(Array.from(c))},G=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[a.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:I=>I.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Eb,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("printerFiles.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[k&&(k.used_bytes!=null||k.free_bytes!=null)&&a.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[k.used_bytes!=null&&a.jsxs("span",{children:[r("printerFiles.storageUsed")," ",dH(k.used_bytes)]}),k.used_bytes!=null&&k.free_bytes!=null&&a.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),k.free_bytes!=null&&a.jsxs("span",{children:[r("printerFiles.storageFree")," ",dH(k.free_bytes)]})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",title:"Close file manager","aria-label":"Close file manager",children:a.jsx(Lt,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[G.map(I=>a.jsx("button",{onClick:()=>{C(I.path),h("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===I.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:I.label},I.path)),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"relative",children:[a.jsx(Zi,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:r("printerFiles.filterPlaceholder"),value:d,onChange:I=>h(I.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"relative flex items-center gap-1",children:[a.jsx(OW,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("select",{value:b,onChange:I=>y(I.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",title:"Sort files","aria-label":"Sort files",children:nMe.map(I=>a.jsx("option",{value:I.value,children:I.label},I.value))})]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>A(),disabled:M,children:a.jsx(Ir,{className:`w-4 h-4 ${M?"animate-spin":""}`})})]}),a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[a.jsx("button",{onClick:P,disabled:o==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",title:"Go to parent folder","aria-label":"Go to parent folder",children:a.jsx(Th,{className:"w-4 h-4"})}),a.jsx("span",{className:"text-bambu-gray font-mono",children:o})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:M?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):T?.files?.length?a.jsx("div",{className:"space-y-1",children:[...T.files].filter(I=>!d||I.name.toLowerCase().includes(d.toLowerCase())).sort((I,K)=>{if(I.is_directory&&!K.is_directory)return-1;if(!I.is_directory&&K.is_directory)return 1;switch(b){case"name-asc":return I.name.localeCompare(K.name);case"name-desc":return K.name.localeCompare(I.name);case"size-asc":return I.size-K.size;case"size-desc":return K.size-I.size;case"date-asc":{const Q=I.mtime?new Date(I.mtime).getTime():0,se=K.mtime?new Date(K.mtime).getTime():0;return Q-se}case"date-desc":{const Q=I.mtime?new Date(I.mtime).getTime():0;return(K.mtime?new Date(K.mtime).getTime():0)-Q}default:return I.name.localeCompare(K.name)}}).map(I=>{const K=tMe(I.name,I.is_directory),Q=c.has(I.path);return a.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${Q?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{I.is_directory&&C(I.path)},children:[I.is_directory?null:a.jsx("button",{onClick:se=>U(I.path,se),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:Q?a.jsx(Ks,{className:"w-5 h-5 text-bambu-green"}):a.jsx(ul,{className:"w-5 h-5"})}),a.jsx(K,{className:`w-5 h-5 flex-shrink-0 ${I.is_directory?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:"flex-1 text-white truncate",children:I.name}),!I.is_directory&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:eMe(I.size)}),(I.name.toLowerCase().endsWith(".3mf")||I.name.toLowerCase().endsWith(".gcode")||I.name.toLowerCase().endsWith(".stl"))&&a.jsx("button",{onClick:se=>{se.stopPropagation(),N({path:I.path,name:I.name})},className:"p-1 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green",title:"3D View",children:a.jsx(zi,{className:"w-4 h-4"})})]}),I.is_directory&&a.jsx(Th,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},I.path)})}):a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"text-sm text-bambu-gray",children:c.size>0?`${c.size} selected`:d?`${T?.files?.filter(I=>I.name.toLowerCase().includes(d.toLowerCase())).length||0} of ${T?.files?.length||0} items`:`${T?.files?.length||0} items`}),T?.files?.some(I=>!I.is_directory)&&a.jsx("div",{className:"flex items-center gap-2",children:c.size>0?a.jsxs("button",{onClick:B,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(nfe,{className:"w-4 h-4"}),"Deselect All"]}):a.jsxs("button",{onClick:F,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(Ks,{className:"w-4 h-4"}),"Select All"]})})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",disabled:c.size===0||x!==null,onClick:D,children:x?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),x.current,"/",x.total]}):a.jsxs(a.Fragment,{children:[a.jsx(_i,{className:"w-4 h-4"}),"Download",c.size>1?` (${c.size})`:""]})}),a.jsxs(Me,{variant:"secondary",disabled:c.size===0||R.isPending,onClick:$,className:"text-red-400 hover:text-red-300",children:[R.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(hn,{className:"w-4 h-4"}),r("printerFiles.deleteButton"),c.size>1?` (${c.size})`:""]})]})]})]}),p.length>0&&a.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:()=>{R.mutate(p)},onCancel:()=>m([])}),S&&a.jsx(Jke,{printerId:t,filePath:S.path,filename:S.name,onClose:()=>N(null)})]})}function PO({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return a.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[a.jsxs("g",{stroke:r,opacity:i,children:[a.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),a.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),a.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),a.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),a.jsx("path",{d:"M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24",fill:n,stroke:r}),a.jsx("path",{d:"M12 24h8",stroke:r}),a.jsx("path",{d:"M12 27h8",stroke:r}),a.jsx("path",{d:"M13 30h6",stroke:r})]})}const Gk=({className:t})=>a.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[a.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),a.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),a.jsx("polyline",{points:"12,10 14,12 12,14"})]});function jO({printerId:t,isOpen:e,onClose:n}){const{t:r}=Yt(),{showToast:i}=kn(),{hasPermission:s}=Rr(),{data:o}=nt({queryKey:["printerStatus",t],queryFn:()=>ae.getPrinterStatus(t),refetchInterval:3e4,enabled:e}),{data:l,refetch:c}=nt({queryKey:["printableObjects",t],queryFn:()=>ae.getPrintableObjects(t),enabled:e,refetchInterval:e?5e3:!1}),u=dt({mutationFn:d=>ae.skipObjects(t,d),onSuccess:d=>{i(d.message||r("printers.skipObjects.objectsSkipped")),c()},onError:d=>i(d.message||r("printers.toast.failedToSkipObjects"),"error")});return e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,onKeyDown:d=>d.key==="Escape"&&n(),tabIndex:-1,ref:d=>d?.focus(),children:[a.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),a.jsxs("div",{className:"relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] max-h-[85vh] flex flex-col overflow-hidden",onClick:d=>d.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Gk,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:r("printers.skipObjects.title")})]}),a.jsx("button",{onClick:n,className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:a.jsx(Lt,{className:"w-4 h-4"})})]}),l?l.objects.length===0?a.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[a.jsx("p",{className:"text-sm",children:r("printers.noObjectsFound")}),a.jsx("p",{className:"text-xs mt-1 opacity-70",children:r("printers.objectsLoadedOnPrintStart")})]}):a.jsxs("div",{className:"flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[a.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center",children:a.jsx(dhe,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:r("printers.skipObjects.matchIdsInfo")}),a.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:r("printers.skipObjects.printerShowsIds")})]}),a.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[l.skipped_count,"/",l.total," ",r("printers.skipObjects.skipped")]})]}),(o?.layer_num??0)<=1&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[a.jsx(Ti,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),a.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:r("printers.skipObjects.waitForLayer",{layer:o?.layer_num??0})})]}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx("div",{className:"w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary overflow-y-auto",children:a.jsxs("div",{className:"relative",children:[o?.cover_url?a.jsx("img",{src:`${o.cover_url}?view=top`,alt:r("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"}):a.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:a.jsx(zi,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),l.objects.length>0&&a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:l.objects.map((d,h)=>{let p,m;if(d.x!=null&&d.y!=null&&l.bbox_all){const[b,y,x,v]=l.bbox_all,S=x-b,N=v-y,T=8,M=100-T*2;p=T+(d.x-b)/S*M,m=T+(v-d.y)/N*M,p=Math.max(5,Math.min(95,p)),m=Math.max(5,Math.min(95,m))}else if(d.x!=null&&d.y!=null)p=d.x/256*100,m=100-d.y/256*100,p=Math.max(5,Math.min(95,p)),m=Math.max(5,Math.min(95,m));else{const b=Math.ceil(Math.sqrt(l.objects.length)),y=Math.floor(h/b),x=h%b,v=Math.ceil(l.objects.length/b);p=15+x*(70/b)+35/b,m=15+y*(70/v)+35/v}return a.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${d.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${p}%`,top:`${m}%`,transform:"translate(-50%, -50%)"},title:d.name,children:d.id},d.id)})}),a.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:r("printers.skipObjects.activeCount",{count:l.objects.filter(d=>!d.skipped).length})})]})}),a.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:l.objects.map(d=>a.jsxs("div",{className:`
- flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
- ${d.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
- `,children:[a.jsxs("div",{className:`
- w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
- ${d.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"}
- `,children:[a.jsx("span",{className:`text-lg font-mono font-bold ${d.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:d.id}),a.jsx("span",{className:`text-[8px] uppercase tracking-wider ${d.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:`block text-sm truncate ${d.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:d.name}),d.skipped&&a.jsx("span",{className:"text-[10px] text-red-400/60",children:r("printers.willBeSkipped")})]}),d.skipped?a.jsx("span",{className:"px-4 py-2 text-xs text-red-500 dark:text-red-400/70 bg-red-100 dark:bg-red-500/10 rounded-lg",children:r("printers.skipObjects.skipped")}):a.jsx("button",{onClick:()=>u.mutate([d.id]),disabled:u.isPending||(o?.layer_num??0)<=1||!s("printers:control"),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(o?.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")?(o?.layer_num??0)<=1?r("printers.skipObjects.waitForLayer",{layer:o?.layer_num??0}):r("printers.skipObjects.skip"):r("printers.permission.noControl"),children:r("printers.skipObjects.skip")})]},d.id))})]})]}):a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(lt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}):null}const iMe="embeddedCameraState_",hH=5,aMe=2e3,sMe=3e4,oMe=5e3,zA={x:window.innerWidth-420,y:20,width:400,height:300};function lMe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const{t:i}=Yt(),s=nn(),{showToast:o}=kn(),{hasPermission:l}=Rr(),c=`${iMe}${t}`,u=()=>{try{const Re=localStorage.getItem(c);if(Re){const we=JSON.parse(Re);return{x:Math.min(Math.max(0,we.x),window.innerWidth-100),y:Math.min(Math.max(0,we.y),window.innerHeight-100),width:Math.max(200,Math.min(we.width,window.innerWidth-20)),height:Math.max(150,Math.min(we.height,window.innerHeight-20))}}}catch{}const je=n*30;return{...zA,x:Math.max(0,zA.x-je),y:Math.max(0,zA.y+je)}},[d,h]=_.useState(u),[p,m]=_.useState(!1),[b,y]=_.useState(!1),[x,v]=_.useState({x:0,y:0}),[S,N]=_.useState(!1),[T,M]=_.useState(!1),[A,k]=_.useState(1),[R,C]=_.useState({x:0,y:0}),[P,U]=_.useState(!1),[F,B]=_.useState({x:0,y:0}),[D,$]=_.useState(null),[G,I]=_.useState(null),[K,Q]=_.useState(!1),[se,H]=_.useState(!0),[W,J]=_.useState(Date.now()),[ne,xe]=_.useState(0),[ue,fe]=_.useState(!1),[De,oe]=_.useState(0),Ne=_.useRef(null),Fe=_.useRef(null),ce=_.useRef(null),Ve=_.useRef(null),V=_.useRef(null),[Y,de]=_.useState(!1),{data:q}=nt({queryKey:["printer",t],queryFn:()=>ae.getPrinter(t),enabled:t>0}),{data:re}=nt({queryKey:["printerStatus",t],queryFn:()=>ae.getPrinterStatus(t),refetchInterval:3e4,enabled:t>0}),X=dt({mutationFn:je=>ae.setChamberLight(t,je),onMutate:async je=>{await s.cancelQueries({queryKey:["printerStatus",t]});const Re=s.getQueryData(["printerStatus",t]);return s.setQueryData(["printerStatus",t],we=>({...we,chamber_light:je})),{previousStatus:Re}},onSuccess:(je,Re)=>{o(`Chamber light ${Re?"on":"off"}`)},onError:(je,Re,we)=>{we?.previousStatus&&s.setQueryData(["printerStatus",t],we.previousStatus),o(je.message||i("printers.toast.failedToControlChamberLight"),"error")}}),le=(re?.state==="RUNNING"||re?.state==="PAUSE"||re?.state==="PAUSED")&&(re?.printable_objects_count??0)>=2;_.useEffect(()=>{const je=setTimeout(()=>{localStorage.setItem(c,JSON.stringify(d))},500);return()=>clearTimeout(je)},[d,c]);const pe=_.useRef(!1);_.useEffect(()=>{pe.current=!1;const je=`/api/v1/printers/${t}/camera/stop`,Re=()=>{if(t>0&&!pe.current){pe.current=!0;const qe={},xt=Ph();xt&&(qe.Authorization=`Bearer ${xt}`),fetch(je,{method:"POST",keepalive:!0,headers:qe}).catch(()=>{})}},we=Fe.current;return()=>{we&&(we.src=""),Re(),ce.current&&clearTimeout(ce.current),Ve.current&&clearInterval(Ve.current),V.current&&clearInterval(V.current)}},[t]),_.useEffect(()=>{if(se){const je=setTimeout(()=>H(!1),3e3);return()=>clearTimeout(je)}},[se,W]);const ee=_.useCallback(()=>{if(ne>=hH){fe(!1),Q(!0);return}const je=Math.min(aMe*Math.pow(2,ne),sMe);fe(!0),oe(Math.ceil(je/1e3)),Ve.current=setInterval(()=>{oe(Re=>Re<=1?(Ve.current&&clearInterval(Ve.current),0):Re-1)},1e3),ce.current=setTimeout(()=>{xe(Re=>Re+1),fe(!1),H(!0),Q(!1),Fe.current&&(Fe.current.src=""),J(Date.now())},je)},[ne]);_.useEffect(()=>{if(se||ue||S){V.current&&(clearInterval(V.current),V.current=null);return}return V.current=setInterval(async()=>{try{const je=await ae.getCameraStatus(t);(je.stalled||!je.active&&!K)&&(V.current&&(clearInterval(V.current),V.current=null),H(!1),ee())}catch{}},oMe),()=>{V.current&&(clearInterval(V.current),V.current=null)}},[se,K,ue,S,t,ee]),_.useEffect(()=>{const je=()=>{const Re=!!document.fullscreenElement;M(Re),Re||(k(1),C({x:0,y:0}))};return document.addEventListener("fullscreenchange",je),()=>document.removeEventListener("fullscreenchange",je)},[]);const z=()=>{Ne.current&&(document.fullscreenElement?document.exitFullscreen():Ne.current.requestFullscreen())},O=()=>{k(je=>Math.min(je+.5,4))},Z=()=>{k(je=>{const Re=Math.max(je-.5,1);return Re===1&&C({x:0,y:0}),Re})},me=je=>{je.preventDefault(),je.deltaY<0?O():Z()},Te=je=>{A>1&&(je.preventDefault(),U(!0),B({x:je.clientX-R.x,y:je.clientY-R.y}))},ke=_.useCallback(()=>{if(!Ne.current||!Fe.current)return{x:200,y:150};const je=Ne.current.getBoundingClientRect(),Re=je.width*(A-1)/2,we=je.height*(A-1)/2;return{x:Math.max(50,Re),y:Math.max(50,we)}},[A]),Ee=je=>{if(P&&A>1){const Re=je.clientX-F.x,we=je.clientY-F.y,qe=ke();C({x:Math.max(-qe.x,Math.min(qe.x,Re)),y:Math.max(-qe.y,Math.min(qe.y,we))})}},Se=()=>{U(!1)},$e=je=>{if(je.length<2)return 0;const Re=je[0].clientX-je[1].clientX,we=je[0].clientY-je[1].clientY;return Math.sqrt(Re*Re+we*we)},Qe=je=>je.length<2?{x:je[0].clientX,y:je[0].clientY}:{x:(je[0].clientX+je[1].clientX)/2,y:(je[0].clientY+je[1].clientY)/2},Ue=je=>{je.touches.length===2?(je.preventDefault(),$($e(je.touches)),I(Qe(je.touches))):je.touches.length===1&&A>1&&(je.preventDefault(),U(!0),B({x:je.touches[0].clientX-R.x,y:je.touches[0].clientY-R.y}))},be=je=>{if(je.touches.length===2&&D!==null){je.preventDefault();const Re=$e(je.touches),we=Re/D;k(xt=>{const Et=Math.max(1,Math.min(4,xt*we));return Et===1&&C({x:0,y:0}),Et}),$(Re);const qe=Qe(je.touches);if(G){const xt=ke();C(Et=>({x:Math.max(-xt.x,Math.min(xt.x,Et.x+(qe.x-G.x))),y:Math.max(-xt.y,Math.min(xt.y,Et.y+(qe.y-G.y)))}))}I(qe)}else if(je.touches.length===1&&P&&A>1){je.preventDefault();const Re=je.touches[0].clientX-F.x,we=je.touches[0].clientY-F.y,qe=ke();C({x:Math.max(-qe.x,Math.min(qe.x,Re)),y:Math.max(-qe.y,Math.min(qe.y,we))})}},ve=je=>{je.touches.length<2&&($(null),I(null)),je.touches.length===0&&U(!1)},ze=()=>{k(1),C({x:0,y:0})},Ce=()=>{H(!1),ne<hH?ee():Q(!0)},Ge=()=>{H(!1),Q(!1),xe(0),fe(!1),ce.current&&clearTimeout(ce.current),Ve.current&&clearInterval(Ve.current)},_e=()=>{H(!0),Q(!1),xe(0),fe(!1),ce.current&&clearTimeout(ce.current),Ve.current&&clearInterval(Ve.current);const je={},Re=Ph();Re&&(je.Authorization=`Bearer ${Re}`),fetch(`/api/v1/printers/${t}/camera/stop`,{method:"POST",headers:je}).catch(()=>{}),Fe.current&&(Fe.current.src=""),setTimeout(()=>J(Date.now()),100)},Je=je=>{je.target.closest(".no-drag")||(m(!0),v({x:je.clientX-d.x,y:je.clientY-d.y}))},Ae=je=>{je.stopPropagation(),y(!0)};_.useEffect(()=>{const je=we=>{if(p)h(qe=>({...qe,x:Math.max(0,Math.min(we.clientX-x.x,window.innerWidth-qe.width)),y:Math.max(0,Math.min(we.clientY-x.y,window.innerHeight-qe.height))}));else if(b&&Ne.current){const qe=Ne.current.getBoundingClientRect();h(xt=>({...xt,width:Math.max(200,Math.min(we.clientX-qe.left,window.innerWidth-xt.x-10)),height:Math.max(150,Math.min(we.clientY-qe.top,window.innerHeight-xt.y-10))}))}},Re=()=>{m(!1),y(!1)};if(p||b)return document.addEventListener("mousemove",je),document.addEventListener("mouseup",Re),()=>{document.removeEventListener("mousemove",je),document.removeEventListener("mouseup",Re)}},[p,b,x]);const Ke=`/api/v1/printers/${t}/camera/stream?fps=15&t=${W}`;return a.jsxs("div",{ref:Ne,className:`${T?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:T?void 0:{left:d.x,top:d.y,width:S?200:d.width,height:S?40:d.height,cursor:p?"grabbing":"default"},children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:Je,children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[a.jsx(Zf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:q?.name||e})]}),a.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[a.jsx("button",{onClick:()=>X.mutate(!re?.chamber_light),disabled:!re?.connected||X.isPending||!l("printers:control"),className:`p-1 rounded disabled:opacity-50 ${re?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:l("printers:control")?i("camera.chamberLight"):i("printers.permission.noControl"),children:a.jsx(PO,{on:re?.chamber_light??!1,className:"w-3.5 h-3.5"})}),a.jsx("button",{onClick:()=>de(!0),disabled:!le||!l("printers:control"),className:`p-1 rounded disabled:opacity-50 ${le&&l("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:l("printers:control")?i(le?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):i("printers.permission.noControl"),children:a.jsx(Gk,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:_e,disabled:se||ue,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:a.jsx(Ir,{className:`w-3.5 h-3.5 text-bambu-gray ${se?"animate-spin":""}`})}),a.jsx("button",{onClick:z,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:T?"Exit fullscreen":"Fullscreen",children:T?a.jsx(HW,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(hde,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:()=>N(!S),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:S?"Expand":"Minimize",children:S?a.jsx(KR,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(XR,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:a.jsx(Lt,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!S&&a.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:me,onMouseMove:Ee,onMouseUp:Se,onMouseLeave:Se,onTouchStart:Ue,onTouchMove:be,onTouchEnd:ve,style:{touchAction:"none"},children:[se&&!ue&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsx(Ir,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),ue&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-2",children:[a.jsx(bm,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",De,"s..."]})]})}),K&&!ue&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-2",children:[a.jsx(En,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),a.jsx("button",{onClick:_e,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),a.jsx("img",{ref:Fe,src:Ke,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${A}) translate(${R.x/A}px, ${R.y/A}px)`,cursor:A>1?P?"grabbing":"grab":"default"},onError:Ce,onLoad:Ge,onMouseDown:Te,draggable:!1},W),a.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag",children:[a.jsx("button",{onClick:Z,disabled:A<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:a.jsx(tO,{className:"w-3.5 h-3.5 text-white"})}),a.jsxs("button",{onClick:ze,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(A*100),"%"]}),a.jsx("button",{onClick:O,disabled:A>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:a.jsx(eO,{className:"w-3.5 h-3.5 text-white"})})]}),!T&&a.jsx("div",{className:"absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors",onMouseDown:Ae,title:"Drag to resize",children:a.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:a.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]}),a.jsx(jO,{printerId:t,isOpen:Y,onClose:()=>de(!1)})]})}function cMe({printerId:t,printerName:e,onClose:n}){const{t:r}=Yt(),i=nn(),[s,o]=_.useState(!0),[l,c]=_.useState(new Set),[u,d]=_.useState(""),[h,p]=_.useState("all"),m=_.useRef(null),{data:b,isLoading:y,refetch:x}=nt({queryKey:["mqtt-logs",t],queryFn:()=>ae.getMQTTLogs(t),refetchInterval:1e3}),v=dt({mutationFn:()=>ae.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=dt({mutationFn:()=>ae.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),N=dt({mutationFn:()=>ae.clearMQTTLogs(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}});_.useEffect(()=>{const P=U=>{U.key==="Escape"&&n()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[n]),_.useEffect(()=>{s&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[b?.logs,s]);const T=P=>{c(U=>{const F=new Set(U);return F.has(P)?F.delete(P):F.add(P),F})},M=P=>new Date(P).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),A=(P,U)=>{if(P==null)return"<empty>";const F=typeof P=="string"?JSON.parse(P):P,B=JSON.stringify(F,null,U?2:0);return!U&&B.length>100?B.substring(0,100)+"...":B},k=b?.logging_enabled??!1,R=_.useMemo(()=>b?.logs??[],[b?.logs]),C=_.useMemo(()=>R.filter(P=>{if(h!=="all"&&P.direction!==h)return!1;if(u.trim()){const U=u.toLowerCase(),F=P.topic.toLowerCase().includes(U),D=JSON.stringify(P.payload).toLowerCase().includes(U);return F||D}return!0}),[R,u,h]);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("mqttDebug.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[k?a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending,children:[a.jsx(ul,{className:"w-4 h-4"}),r("mqttDebug.stopLogging")]}):a.jsxs(Me,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[a.jsx(To,{className:"w-4 h-4"}),r("mqttDebug.startLogging")]}),a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>N.mutate(),disabled:N.isPending||R.length===0,children:[a.jsx(hn,{className:"w-4 h-4"}),r("mqttDebug.clearLog")]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>x(),disabled:y,children:a.jsx(Ir,{className:`w-4 h-4 ${y?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:s,onChange:P=>o(P.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[C.length,"/",R.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Zi,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:r("mqttDebug.searchPlaceholder"),value:u,onChange:P=>d(P.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&&a.jsx("button",{onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Lt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>p("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${h==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:r("mqttDebug.all")}),a.jsxs("button",{onClick:()=>p("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${h==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[a.jsx(Y0,{className:"w-3 h-3"}),r("mqttDebug.incoming")]}),a.jsxs("button",{onClick:()=>p("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${h==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[a.jsx(qg,{className:"w-3 h-3"}),r("mqttDebug.outgoing")]})]})]})]}),a.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:R.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessages")}),!k&&a.jsx("p",{className:"text-sm",children:r("mqttDebug.startLoggingHint")})]}):C.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessagesMatch")}),a.jsx("p",{className:"text-sm",children:r("mqttDebug.adjustFilterHint")})]}):a.jsx("div",{className:"space-y-1",children:C.map((P,U)=>{const F=l.has(U),B=P.direction==="in";return a.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>T(U),children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray shrink-0",children:M(P.timestamp)}),a.jsx("span",{className:`shrink-0 ${B?"text-blue-400":"text-green-400"}`,title:r(B?"mqttDebug.incoming":"mqttDebug.outgoing"),children:B?a.jsx(Y0,{className:"w-3 h-3"}):a.jsx(qg,{className:"w-3 h-3"})}),a.jsx("span",{className:"text-purple-400 shrink-0",children:P.topic})]}),F?a.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:A(P.payload,!0)}):a.jsx("pre",{className:"mt-1 text-white/80 truncate",children:A(P.payload,!1)})]},U)})})}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-sm text-bambu-gray",children:k?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),r("mqttDebug.loggingActive")]}):a.jsx("span",{children:r("mqttDebug.loggingStopped")})}),a.jsx(Me,{variant:"secondary",onClick:n,children:r("common.close")})]})]})})}const B3={"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 uMe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:En};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:En};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Ti};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:yo}}}function H3(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 dMe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=H3(e.attr,n);return B3[r]!==void 0})}function hMe(){return"https://wiki.bambulab.com/en/hms/home"}function fMe({printerName:t,errors:e,onClose:n}){const{t:r}=Yt();console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const i=e.filter(s=>{const o=parseInt(s.code.replace("0x",""),16)||0,l=H3(s.attr,o);return B3[l]!==void 0});return _.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(En,{className:"w-5 h-5 text-orange-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("hmsErrors.title",{name:t})})]}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Ti,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{children:r("hmsErrors.noErrors")})]}):a.jsx("div",{className:"space-y-3",children:i.map((s,o)=>{const{label:l,color:c,bgColor:u,Icon:d}=uMe(s.severity),h=parseInt(s.code.replace("0x",""),16)||0,p=H3(s.attr,h),m=B3[p],b=hMe(),y=p.replace("_","-");return a.jsx("div",{className:`p-4 rounded-lg ${u} border border-white/10`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(d,{className:`w-5 h-5 ${c} flex-shrink-0 mt-0.5`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("span",{className:`font-mono text-sm ${c}`,children:["[",y,"]"]}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${u} ${c}`,children:l})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),a.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[a.jsx(Zr,{className:"w-3 h-3"}),r("hmsErrors.viewOnWiki")]})]})]})},`${s.code}-${o}`)})})}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:r("hmsErrors.clearInstructions")})})]})})}function mMe(t){if(!t)return"ASAP";const e=Ui(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 pMe({printerId:t,printerState:e}){const{t:n}=Yt(),r=nn(),{showToast:i}=kn(),{hasPermission:s}=Rr(),{data:o}=nt({queryKey:["queue",t,"pending"],queryFn:()=>ae.getQueue(t,"pending"),refetchInterval:3e4}),l=dt({mutationFn:()=>ae.clearPlate(t),onSuccess:()=>{r.invalidateQueries({queryKey:["queue",t]}),r.invalidateQueries({queryKey:["printerStatus",t]}),i(n("queue.clearPlateSuccess"),"success")},onError:h=>{i(h.message,"error")}}),c=o?.[0],u=o?.length||0;return u===0?null:e==="FINISH"||e==="FAILED"?a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-yellow-400/30",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx(Qr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("queue.nextInQueue")}),a.jsx("p",{className:"text-sm text-white truncate",children:c?.archive_name||`Archive #${c?.archive_id}`})]}),u>1&&a.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded flex-shrink-0",children:["+",u-1]})]}),l.isSuccess?a.jsxs("div",{className:"w-full py-2 px-3 rounded-lg bg-bambu-green/10 border border-bambu-green/20 text-bambu-green text-sm flex items-center justify-center gap-2",children:[a.jsx(Kg,{className:"w-4 h-4"}),n("queue.plateReady")]}):a.jsxs("button",{onClick:()=>l.mutate(),disabled:l.isPending||!s("printers:control"),className:"w-full py-2 px-3 rounded-lg bg-bambu-green/20 border border-bambu-green/40 text-bambu-green hover:bg-bambu-green/30 transition-colors text-sm font-medium flex items-center justify-center gap-2 disabled:opacity-50",children:[l.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Kg,{className:"w-4 h-4"}),n("queue.clearPlate")]})]}):a.jsx(Us,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx(Qr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("queue.nextInQueue")}),a.jsx("p",{className:"text-sm text-white truncate",children:c?.archive_name||`Archive #${c?.archive_id}`})]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(er,{className:"w-3 h-3"}),mMe(c?.scheduled_time||null)]}),u>1&&a.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",u-1]}),a.jsx(Ns,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function kX(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=kX(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function tr(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=kX(t))&&(r&&(r+=" "),r+=e);return r}var gMe=["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 DO(t){if(typeof t!="string")return!1;var e=gMe;return e.includes(t)}var bMe=["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"],xMe=new Set(bMe);function MX(t){return typeof t!="string"?!1:xMe.has(t)}function EX(t){return typeof t=="string"&&t.startsWith("data-")}function ks(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(MX(n)||EX(n))&&(e[n]=t[n]);return e}function Nm(t){if(t==null)return null;if(_.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return ks(e)}return typeof t=="object"&&!Array.isArray(t)?ks(t):null}function Ha(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(MX(n)||EX(n)||DO(n))&&(e[n]=t[n]);return e}function yMe(t){return t==null?null:_.isValidElement(t)?Ha(t.props):typeof t=="object"&&!Array.isArray(t)?Ha(t):null}var vMe=["children","width","height","viewBox","className","style","title","desc"];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 wMe(t,e){if(t==null)return{};var n,r,i=_Me(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _Me(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 RO=_.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:o,style:l,title:c,desc:u}=t,d=wMe(t,vMe),h=s||{width:r,height:i,x:0,y:0},p=tr("recharts-surface",o);return _.createElement("svg",$3({},Ha(d),{className:p,width:r,height:i,style:l,viewBox:"".concat(h.x," ").concat(h.y," ").concat(h.width," ").concat(h.height),ref:e}),_.createElement("title",null,c),_.createElement("desc",null,u),n)}),SMe=["children","className"];function V3(){return V3=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},V3.apply(null,arguments)}function NMe(t,e){if(t==null)return{};var n,r,i=kMe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function kMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var ci=_.forwardRef((t,e)=>{var{children:n,className:r}=t,i=NMe(t,SMe),s=tr("recharts-layer",r);return _.createElement("g",V3({className:s},Ha(i),{ref:e}),n)}),TX=_.createContext(null),MMe=()=>_.useContext(TX);function $r(t){return function(){return t}}const AX=Math.cos,SS=Math.sin,ql=Math.sqrt,NS=Math.PI,qk=2*NS,G3=Math.PI,q3=2*G3,jf=1e-6,EMe=q3-jf;function CX(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function TMe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return CX;const n=10**e;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class AMe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?CX:TMe(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,s,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+s},${this._y1=+o}`}arcTo(e,n,r,i,s){if(e=+e,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,h=l-n,p=d*d+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(p>jf)if(!(Math.abs(h*c-u*d)>jf)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-o,b=i-l,y=c*c+u*u,x=m*m+b*b,v=Math.sqrt(y),S=Math.sqrt(p),N=s*Math.tan((G3-Math.acos((y+p-x)/(2*v*S)))/2),T=N/S,M=N/v;Math.abs(T-1)>jf&&this._append`L${e+T*d},${n+T*h}`,this._append`A${s},${s},0,0,${+(h*m>d*b)},${this._x1=e+M*c},${this._y1=n+M*u}`}}arc(e,n,r,i,s,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,h=1^o,p=o?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>jf||Math.abs(this._y1-d)>jf)&&this._append`L${u},${d}`,r&&(p<0&&(p=p%q3+q3),p>EMe?this._append`A${r},${r},0,1,${h},${e-l},${n-c}A${r},${r},0,1,${h},${this._x1=u},${this._y1=d}`:p>jf&&this._append`A${r},${r},0,${+(p>=G3)},${h},${this._x1=e+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function OO(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 AMe(e)}function LO(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function PX(t){this._context=t}PX.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);break}}};function Wk(t){return new PX(t)}function jX(t){return t[0]}function DX(t){return t[1]}function RX(t,e){var n=$r(!0),r=null,i=Wk,s=null,o=OO(l);t=typeof t=="function"?t:t===void 0?jX:$r(t),e=typeof e=="function"?e:e===void 0?DX:$r(e);function l(c){var u,d=(c=LO(c)).length,h,p=!1,m;for(r==null&&(s=i(m=o())),u=0;u<=d;++u)!(u<d&&n(h=c[u],u,c))===p&&((p=!p)?s.lineStart():s.lineEnd()),p&&s.point(+t(h,u,c),+e(h,u,c));if(m)return s=null,m+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:$r(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:$r(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:$r(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(s=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=s=null:s=i(r=c),l):r},l}function K_(t,e,n){var r=null,i=$r(!0),s=null,o=Wk,l=null,c=OO(u);t=typeof t=="function"?t:t===void 0?jX:$r(+t),e=typeof e=="function"?e:$r(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?DX:$r(+n);function u(h){var p,m,b,y=(h=LO(h)).length,x,v=!1,S,N=new Array(y),T=new Array(y);for(s==null&&(l=o(S=c())),p=0;p<=y;++p){if(!(p<y&&i(x=h[p],p,h))===v)if(v=!v)m=p,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),b=p-1;b>=m;--b)l.point(N[b],T[b]);l.lineEnd(),l.areaEnd()}v&&(N[p]=+t(x,p,h),T[p]=+e(x,p,h),l.point(r?+r(x,p,h):N[p],n?+n(x,p,h):T[p]))}if(S)return l=null,S+""||null}function d(){return RX().defined(i).curve(o).context(s)}return u.x=function(h){return arguments.length?(t=typeof h=="function"?h:$r(+h),r=null,u):t},u.x0=function(h){return arguments.length?(t=typeof h=="function"?h:$r(+h),u):t},u.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:$r(+h),u):r},u.y=function(h){return arguments.length?(e=typeof h=="function"?h:$r(+h),n=null,u):e},u.y0=function(h){return arguments.length?(e=typeof h=="function"?h:$r(+h),u):e},u.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:$r(+h),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(h){return arguments.length?(i=typeof h=="function"?h:$r(!!h),u):i},u.curve=function(h){return arguments.length?(o=h,s!=null&&(l=o(s)),u):o},u.context=function(h){return arguments.length?(h==null?s=l=null:l=o(s=h),u):s},u}class OX{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 OX(t,!0)}function PMe(t){return new OX(t,!1)}const FO={draw(t,e){const n=ql(e/NS);t.moveTo(n,0),t.arc(0,0,n,0,qk)}},jMe={draw(t,e){const n=ql(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},LX=ql(1/3),DMe=LX*2,RMe={draw(t,e){const n=ql(e/DMe),r=n*LX;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},OMe={draw(t,e){const n=ql(e),r=-n/2;t.rect(r,r,n,n)}},LMe=.8908130915292852,FX=SS(NS/10)/SS(7*NS/10),FMe=SS(qk/10)*FX,IMe=-AX(qk/10)*FX,zMe={draw(t,e){const n=ql(e*LMe),r=FMe*n,i=IMe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const o=qk*s/5,l=AX(o),c=SS(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},UA=ql(3),UMe={draw(t,e){const n=-ql(e/(UA*3));t.moveTo(0,n*2),t.lineTo(-UA*n,-n),t.lineTo(UA*n,-n),t.closePath()}},$o=-.5,Vo=ql(3)/2,W3=1/ql(12),BMe=(W3/2+1)*3,HMe={draw(t,e){const n=ql(e/BMe),r=n/2,i=n*W3,s=r,o=n*W3+n,l=-s,c=o;t.moveTo(r,i),t.lineTo(s,o),t.lineTo(l,c),t.lineTo($o*r-Vo*i,Vo*r+$o*i),t.lineTo($o*s-Vo*o,Vo*s+$o*o),t.lineTo($o*l-Vo*c,Vo*l+$o*c),t.lineTo($o*r+Vo*i,$o*i-Vo*r),t.lineTo($o*s+Vo*o,$o*o-Vo*s),t.lineTo($o*l+Vo*c,$o*c-Vo*l),t.closePath()}};function $Me(t,e){let n=null,r=OO(i);t=typeof t=="function"?t:$r(t||FO),e=typeof e=="function"?e:$r(e===void 0?64:+e);function i(){let s;if(n||(n=s=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),s)return n=null,s+""||null}return i.type=function(s){return arguments.length?(t=typeof s=="function"?s:$r(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:$r(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function kS(){}function MS(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 IX(t){this._context=t}IX.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:MS(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:MS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function VMe(t){return new IX(t)}function zX(t){this._context=t}zX.prototype={areaStart:kS,areaEnd:kS,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:MS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function GMe(t){return new zX(t)}function UX(t){this._context=t}UX.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(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:MS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function qMe(t){return new UX(t)}function BX(t){this._context=t}BX.prototype={areaStart:kS,areaEnd:kS,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 WMe(t){return new BX(t)}function fH(t){return t<0?-1:1}function mH(t,e,n){var r=t._x1-t._x0,i=e-t._x1,s=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(s*i+o*r)/(r+i);return(fH(s)+fH(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(l))||0}function pH(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function BA(t,e,n){var r=t._x0,i=t._y0,s=t._x1,o=t._y1,l=(s-r)/3;t._context.bezierCurveTo(r+l,i+l*e,s-l,o-l*n,s,o)}function ES(t){this._context=t}ES.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:BA(this,this._t0,pH(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,BA(this,pH(this,n=mH(this,t,e)),n);break;default:BA(this,this._t0,n=mH(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function HX(t){this._context=new $X(t)}(HX.prototype=Object.create(ES.prototype)).point=function(t,e){ES.prototype.point.call(this,e,t)};function $X(t){this._context=t}$X.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,s){this._context.bezierCurveTo(e,t,r,n,s,i)}};function KMe(t){return new ES(t)}function XMe(t){return new HX(t)}function VX(t){this._context=t}VX.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var r=gH(t),i=gH(e),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],t[o],e[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function gH(t){var e,n=t.length-1,r,i=new Array(n),s=new Array(n),o=new Array(n);for(i[0]=0,s[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,s[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,s[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/s[e-1],s[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/s[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/s[e];for(s[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)s[e]=2*t[e+1]-i[e+1];return[i,s]}function YMe(t){return new VX(t)}function Kk(t,e){this._context=t,this._t=e}Kk.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 QMe(t){return new Kk(t,.5)}function ZMe(t){return new Kk(t,0)}function JMe(t){return new Kk(t,1)}function sb(t,e){if((o=t.length)>1)for(var n=1,r,i,s=t[e[0]],o,l=s.length;n<o;++n)for(i=s,s=t[e[n]],r=0;r<l;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function K3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function e2e(t,e){return t[e]}function t2e(t){const e=[];return e.key=t,e}function n2e(){var t=$r([]),e=K3,n=sb,r=e2e;function i(s){var o=Array.from(t.apply(this,arguments),t2e),l,c=o.length,u=-1,d;for(const h of s)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(h,o[l].key,u,s)]).data=h;for(l=0,d=LO(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(s){return arguments.length?(t=typeof s=="function"?s:$r(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:$r(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?K3:typeof s=="function"?s:$r(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??sb,i):n},i}function r2e(t,e){if((r=t.length)>0){for(var n,r,i=0,s=t[0].length,o;i<s;++i){for(o=n=0;n<r;++n)o+=t[n][i][1]||0;if(o)for(n=0;n<r;++n)t[n][i][1]/=o}sb(t,e)}}function i2e(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,s=r.length;n<s;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}sb(t,e)}}function a2e(t,e){if(!(!((o=t.length)>0)||!((s=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,s,o;r<s;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],h=d[r][1]||0,p=d[r-1][1]||0,m=(h-p)/2,b=0;b<l;++b){var y=t[e[b]],x=y[r][1]||0,v=y[r-1][1]||0;m+=x-v}c+=h,u+=m*h}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,sb(t,e)}}var HA={},$A={},bH;function s2e(){return bH||(bH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})($A)),$A}var VA={},xH;function GX(){return xH||(xH=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})(VA)),VA}var GA={},yH;function IO(){return yH||(yH=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})(GA)),GA}var qA={},WA={},vH;function o2e(){return vH||(vH=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})(WA)),WA}var wH;function zO(){return wH||(wH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=o2e(),n=IO();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const s=[],o=i.length;if(o===0)return s;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(s.push(""),l++);l<o;){const h=i[l];u?h==="\\"&&l+1<o?(l++,c+=i[l]):h===u?u="":c+=h:d?h==='"'||h==="'"?u=h:h==="]"?(d=!1,s.push(c),c=""):c+=h:h==="["?(d=!0,c&&(s.push(c),c="")):h==="."?c&&(s.push(c),c=""):c+=h,l++}return c&&s.push(c),s}t.toPath=r})(qA)),qA}var _H;function UO(){return _H||(_H=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=s2e(),n=GX(),r=IO(),i=zO();function s(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?s(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function o(l,c,u){if(c.length===0)return u;let d=l;for(let h=0;h<c.length;h++){if(d==null||e.isUnsafeProperty(c[h]))return u;d=d[c[h]]}return d===void 0?u:d}t.get=s})(HA)),HA}var KA,SH;function l2e(){return SH||(SH=1,KA=UO().get),KA}var c2e=l2e();const km=gl(c2e);var wa=t=>t===0?0:t>0?1:-1,Xs=t=>typeof t=="number"&&t!=+t,Xu=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Ht=t=>(typeof t=="number"||t instanceof Number)&&!Xs(t),fl=t=>Ht(t)||typeof t=="string",u2e=0,dy=t=>{var e=++u2e;return"".concat(t||"").concat(e)},as=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(!Ht(e)&&typeof e!="string")return r;var s;if(Xu(e)){if(n==null)return r;var o=e.indexOf("%");s=n*parseFloat(e.slice(0,o))/100}else s=+e;return Xs(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},qX=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 pr(t,e,n){return Ht(t)&&Ht(e)?t+n*(e-t):e}function WX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):km(r,e))===n)}var Jr=t=>t===null||typeof t>"u",Xy=t=>Jr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function d2e(t){return t!=null}function Yy(){}var h2e=["type","size","sizeType"];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 NH(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 kH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?NH(Object(n),!0).forEach(function(r){f2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):NH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function f2e(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=p2e(t,"string");return typeof e=="symbol"?e:e+""}function p2e(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 g2e(t,e){if(t==null)return{};var n,r,i=b2e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function b2e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var KX={symbolCircle:FO,symbolCross:jMe,symbolDiamond:RMe,symbolSquare:OMe,symbolStar:zMe,symbolTriangle:UMe,symbolWye:HMe},x2e=Math.PI/180,y2e=t=>{var e="symbol".concat(Xy(t));return KX[e]||FO},v2e=(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*x2e;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}},w2e=(t,e)=>{KX["symbol".concat(Xy(t))]=e},BO=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=g2e(t,h2e),s=kH(kH({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var p=y2e(o),m=$Me().type(p).size(v2e(n,r,o)),b=m();if(b!==null)return b},{className:c,cx:u,cy:d}=s,h=Ha(s);return Ht(u)&&Ht(d)&&Ht(n)?_.createElement("path",X3({},h,{className:tr("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};BO.registerSymbol=w2e;var XX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,HO=(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=>{DO(i)&&(r[i]=(s=>n[i](n,s)))}),r},_2e=(t,e,n)=>r=>(t(e,n,r),null),Qy=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var s=t[i];DO(i)&&typeof s=="function"&&(r||(r={}),r[i]=_2e(s,e,n))}),r};function MH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function S2e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?MH(Object(n),!0).forEach(function(r){N2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):MH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function N2e(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=M2e(t,"string");return typeof e=="symbol"?e:e+""}function M2e(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 ui(t,e){var n=S2e({},t),r=e,i=Object.keys(e),s=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return s}function TS(){return TS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},TS.apply(null,arguments)}function 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 E2e(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){T2e(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 T2e(t,e,n){return(e=A2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function A2e(t){var e=C2e(t,"string");return typeof e=="symbol"?e:e+""}function C2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Wo=32,P2e={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function j2e(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Wo/2,s=Wo/6,o=Wo/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:Wo,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,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(Wo,"M").concat(2*o,",").concat(i,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return _.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(Wo/8,"h").concat(Wo,"v").concat(Wo*3/4,"h").concat(-Wo,"z"),className:"recharts-legend-icon"});if(_.isValidElement(e.legendIcon)){var d=E2e({},e);return delete d.legendIcon,_.cloneElement(e.legendIcon,d)}return _.createElement(BO,{fill:l,cx:i,cy:i,size:Wo,sizeType:"diameter",type:c})}function D2e(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:o}=t,l={x:0,y:0,width:Wo,height:Wo},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,h)=>{var p=d.formatter||i,m=tr({"recharts-legend-item":!0,["legend-item-".concat(h)]:!0,inactive:d.inactive});if(d.type==="none")return null;var b=d.inactive?s:d.color,y=p?p(d.value,d,h):d.value;return _.createElement("li",TS({className:m,style:c,key:"legend-item-".concat(h)},Qy(t,d,h)),_.createElement(RO,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},_.createElement(j2e,{data:d,iconType:o,inactiveColor:s})),_.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},y))})}var R2e=t=>{var e=ui(t,P2e),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var s={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return _.createElement("ul",{className:"recharts-default-legend",style:s},_.createElement(D2e,TS({},e,{payload:n})))},XA={},YA={},TH;function O2e(){return TH||(TH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let s=0;s<n.length;s++){const o=n[s],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(YA)),YA}var QA={},AH;function YX(){return AH||(AH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(QA)),QA}var ZA={},JA={},eC={},CH;function L2e(){return CH||(CH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(eC)),eC}var PH;function $O(){return PH||(PH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=L2e();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(JA)),JA}var tC={},jH;function F2e(){return jH||(jH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(tC)),tC}var DH;function I2e(){return DH||(DH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$O(),n=F2e();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(ZA)),ZA}var nC={},rC={},RH;function z2e(){return RH||(RH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UO();function n(r){return function(i){return e.get(i,r)}}t.property=n})(rC)),rC}var iC={},aC={},sC={},oC={},OH;function QX(){return OH||(OH=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})(oC)),oC}var lC={},LH;function ZX(){return LH||(LH=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})(lC)),lC}var cC={},FH;function JX(){return FH||(FH=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})(cC)),cC}var IH;function U2e(){return IH||(IH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QX(),n=ZX(),r=JX();function i(d,h,p){return typeof p!="function"?i(d,h,()=>{}):s(d,h,function m(b,y,x,v,S,N){const T=p(b,y,x,v,S,N);return T!==void 0?!!T:s(b,y,m,N)},new Map)}function s(d,h,p,m){if(h===d)return!0;switch(typeof h){case"object":return o(d,h,p,m);case"function":return Object.keys(h).length>0?s(d,{...h},p,m):r.eq(d,h);default:return e.isObject(d)?typeof h=="string"?h==="":!0:r.eq(d,h)}}function o(d,h,p,m){if(h==null)return!0;if(Array.isArray(h))return c(d,h,p,m);if(h instanceof Map)return l(d,h,p,m);if(h instanceof Set)return u(d,h,p,m);const b=Object.keys(h);if(d==null)return b.length===0;if(b.length===0)return!0;if(m?.has(h))return m.get(h)===d;m?.set(h,d);try{for(let y=0;y<b.length;y++){const x=b[y];if(!n.isPrimitive(d)&&!(x in d)||h[x]===void 0&&d[x]!==void 0||h[x]===null&&d[x]!==null||!p(d[x],h[x],x,d,h,m))return!1}return!0}finally{m?.delete(h)}}function l(d,h,p,m){if(h.size===0)return!0;if(!(d instanceof Map))return!1;for(const[b,y]of h.entries()){const x=d.get(b);if(p(x,y,b,d,h,m)===!1)return!1}return!0}function c(d,h,p,m){if(h.length===0)return!0;if(!Array.isArray(d))return!1;const b=new Set;for(let y=0;y<h.length;y++){const x=h[y];let v=!1;for(let S=0;S<d.length;S++){if(b.has(S))continue;const N=d[S];let T=!1;if(p(N,x,y,d,h,m)&&(T=!0),T){b.add(S),v=!0;break}}if(!v)return!1}return!0}function u(d,h,p,m){return h.size===0?!0:d instanceof Set?c([...d],[...h],p,m):!1}t.isMatchWith=i,t.isSetMatch=u})(sC)),sC}var zH;function eY(){return zH||(zH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=U2e();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(aC)),aC}var uC={},dC={},hC={},UH;function B2e(){return UH||(UH=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})(hC)),hC}var fC={},BH;function tY(){return BH||(BH=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})(fC)),fC}var mC={},HH;function nY(){return HH||(HH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",s="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",h="[object Function]",p="[object ArrayBuffer]",m="[object Object]",b="[object Error]",y="[object DataView]",x="[object Uint8Array]",v="[object Uint8ClampedArray]",S="[object Uint16Array]",N="[object Uint32Array]",T="[object BigUint64Array]",M="[object Int8Array]",A="[object Int16Array]",k="[object Int32Array]",R="[object BigInt64Array]",C="[object Float32Array]",P="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=p,t.arrayTag=d,t.bigInt64ArrayTag=R,t.bigUint64ArrayTag=T,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=b,t.float32ArrayTag=C,t.float64ArrayTag=P,t.functionTag=h,t.int16ArrayTag=A,t.int32ArrayTag=k,t.int8ArrayTag=M,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=N,t.uint8ArrayTag=x,t.uint8ClampedArrayTag=v})(mC)),mC}var pC={},$H;function H2e(){return $H||($H=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(pC)),pC}var VH;function rY(){return VH||(VH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=B2e(),n=tY(),r=nY(),i=ZX(),s=H2e();function o(d,h){return l(d,void 0,d,new Map,h)}function l(d,h,p,m=new Map,b=void 0){const y=b?.(d,h,p,m);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const x=new Array(d.length);m.set(d,x);for(let v=0;v<d.length;v++)x[v]=l(d[v],v,p,m,b);return Object.hasOwn(d,"index")&&(x.index=d.index),Object.hasOwn(d,"input")&&(x.input=d.input),x}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const x=new RegExp(d.source,d.flags);return x.lastIndex=d.lastIndex,x}if(d instanceof Map){const x=new Map;m.set(d,x);for(const[v,S]of d)x.set(v,l(S,v,p,m,b));return x}if(d instanceof Set){const x=new Set;m.set(d,x);for(const v of d)x.add(l(v,void 0,p,m,b));return x}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(s.isTypedArray(d)){const x=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,x);for(let v=0;v<d.length;v++)x[v]=l(d[v],v,p,m,b);return x}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const x=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,x),c(x,d,p,m,b),x}if(typeof File<"u"&&d instanceof File){const x=new File([d],d.name,{type:d.type});return m.set(d,x),c(x,d,p,m,b),x}if(typeof Blob<"u"&&d instanceof Blob){const x=new Blob([d],{type:d.type});return m.set(d,x),c(x,d,p,m,b),x}if(d instanceof Error){const x=new d.constructor;return m.set(d,x),x.message=d.message,x.name=d.name,x.stack=d.stack,x.cause=d.cause,c(x,d,p,m,b),x}if(d instanceof Boolean){const x=new Boolean(d.valueOf());return m.set(d,x),c(x,d,p,m,b),x}if(d instanceof Number){const x=new Number(d.valueOf());return m.set(d,x),c(x,d,p,m,b),x}if(d instanceof String){const x=new String(d.valueOf());return m.set(d,x),c(x,d,p,m,b),x}if(typeof d=="object"&&u(d)){const x=Object.create(Object.getPrototypeOf(d));return m.set(d,x),c(x,d,p,m,b),x}return d}function c(d,h,p=d,m,b){const y=[...Object.keys(h),...e.getSymbols(h)];for(let x=0;x<y.length;x++){const v=y[x],S=Object.getOwnPropertyDescriptor(d,v);(S==null||S.writable)&&(d[v]=l(h[v],v,p,m,b))}}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})(dC)),dC}var GH;function $2e(){return GH||(GH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rY();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(uC)),uC}var qH;function V2e(){return qH||(qH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eY(),n=$2e();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(iC)),iC}var gC={},bC={},xC={},WH;function G2e(){return WH||(WH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rY(),n=nY();function r(i,s){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=s?.(o,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const h=new i.constructor(i?.valueOf());return e.copyProperties(h,i),h}case n.argumentsTag:{const h={};return e.copyProperties(h,i),h.length=i.length,h[Symbol.iterator]=i[Symbol.iterator],h}default:return}})}t.cloneDeepWith=r})(xC)),xC}var KH;function q2e(){return KH||(KH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=G2e();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(bC)),bC}var yC={},vC={},XH;function iY(){return XH||(XH=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})(vC)),vC}var wC={},YH;function W2e(){return YH||(YH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tY();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(wC)),wC}var QH;function K2e(){return QH||(QH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GX(),n=iY(),r=W2e(),i=zO();function s(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let d=0;d<c.length;d++){const h=c[d];if((u==null||!Object.hasOwn(u,h))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(h)&&h<u.length))return!1;u=u[h]}return!0}t.has=s})(yC)),yC}var ZH;function X2e(){return ZH||(ZH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eY(),n=IO(),r=q2e(),i=UO(),s=K2e();function o(l,c){switch(typeof l){case"object":{Object.is(l?.valueOf(),-0)&&(l="-0");break}case"number":{l=n.toKey(l);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,l);return d===void 0?s.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=o})(gC)),gC}var JH;function Y2e(){return JH||(JH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YX(),n=z2e(),r=V2e(),i=X2e();function s(o){if(o==null)return e.identity;switch(typeof o){case"function":return o;case"object":return Array.isArray(o)&&o.length===2?i.matchesProperty(o[0],o[1]):r.matches(o);case"string":case"symbol":case"number":return n.property(o)}}t.iteratee=s})(nC)),nC}var e$;function Q2e(){return e$||(e$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=O2e(),n=YX(),r=I2e(),i=Y2e();function s(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=s})(XA)),XA}var _C,t$;function Z2e(){return t$||(t$=1,_C=Q2e().uniqBy),_C}var J2e=Z2e();const n$=gl(J2e);function aY(t,e,n){return e===!0?n$(t,n):typeof e=="function"?n$(t,e):t}var SC={exports:{}},NC={};var r$;function eEe(){if(r$)return NC;r$=1;var t=Sb(),e=X9();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,s=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return NC.useSyncExternalStoreWithSelector=function(u,d,h,p,m){var b=s(null);if(b.current===null){var y={hasValue:!1,value:null};b.current=y}else y=b.current;b=l(function(){function v(A){if(!S){if(S=!0,N=A,A=p(A),m!==void 0&&y.hasValue){var k=y.value;if(m(k,A))return T=k}return T=A}if(k=T,r(N,A))return k;var R=p(A);return m!==void 0&&m(k,R)?(N=A,k):(N=A,T=R)}var S=!1,N,T,M=h===void 0?null:h;return[function(){return v(d())},M===null?void 0:function(){return v(M())}]},[d,h,p,m]);var x=i(u,b[0],b[1]);return o(function(){y.hasValue=!0,y.value=x},[x]),c(x),x},NC}var i$;function tEe(){return i$||(i$=1,SC.exports=eEe()),SC.exports}var sY=tEe(),VO=_.createContext(null),nEe=t=>t,Br=()=>{var t=_.useContext(VO);return t?t.store.dispatch:nEe},B1=()=>{},rEe=()=>B1,iEe=(t,e)=>t===e;function zt(t){var e=_.useContext(VO);return sY.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:rEe,e?e.store.getState:B1,e?e.store.getState:B1,e?t:B1,iEe)}function aEe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function sEe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function oEe(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 a$=t=>Array.isArray(t)?t:[t];function lEe(t){const e=Array.isArray(t[0])?t[0]:t;return oEe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function cEe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var uEe=class{constructor(t){this.value=t}deref(){return this.value}},dEe=typeof WeakRef<"u"?WeakRef:uEe,hEe=0,s$=1;function X_(){return{s:hEe,v:void 0,o:null,p:null}}function oY(t,e={}){let n=X_();const{resultEqualityCheck:r}=e;let i,s=0;function o(){let l=n;const{length:c}=arguments;for(let h=0,p=c;h<p;h++){const m=arguments[h];if(typeof m=="function"||typeof m=="object"&&m!==null){let b=l.o;b===null&&(l.o=b=new WeakMap);const y=b.get(m);y===void 0?(l=X_(),b.set(m,l)):l=y}else{let b=l.p;b===null&&(l.p=b=new Map);const y=b.get(m);y===void 0?(l=X_(),b.set(m,l)):l=y}}const u=l;let d;if(l.s===s$)d=l.v;else if(d=t.apply(null,arguments),s++,r){const h=i?.deref?.()??i;h!=null&&r(h,d)&&(d=h,s!==0&&s--),i=typeof d=="object"&&d!==null||typeof d=="function"?new dEe(d):d}return u.s=s$,u.v=d,d}return o.clearCache=()=>{n=X_(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function fEe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),aEe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:h,memoizeOptions:p=[],argsMemoize:m=oY,argsMemoizeOptions:b=[]}=d,y=a$(p),x=a$(b),v=lEe(i),S=h(function(){return s++,u.apply(null,arguments)},...y),N=m(function(){o++;const M=cEe(v,arguments);return l=S.apply(null,M),l},...x);return Object.assign(N,{resultFunc:u,memoizedResultFunc:S,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:h,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var st=fEe(oY),mEe=Object.assign((t,e=st)=>{sEe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(s=>t[s]);return e(r,(...s)=>s.reduce((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>mEe}),kC={},MC={},EC={},o$;function pEe(){return o$||(o$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,s)=>{if(r!==i){const o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return s==="desc"?1:-1;if(r>i)return s==="desc"?-1:1}return s==="desc"?l-o:o-l}return 0};t.compareValues=n})(EC)),EC}var TC={},AC={},l$;function lY(){return l$||(l$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(AC)),AC}var c$;function gEe(){return c$||(c$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lY(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,o){return Array.isArray(s)?!1:typeof s=="number"||typeof s=="boolean"||s==null||e.isSymbol(s)?!0:typeof s=="string"&&(r.test(s)||!n.test(s))||o!=null&&Object.hasOwn(o,s)}t.isKey=i})(TC)),TC}var u$;function bEe(){return u$||(u$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pEe(),n=gEe(),r=zO();function i(s,o,l,c){if(s==null)return[];l=c?void 0:l,Array.isArray(s)||(s=Object.values(s)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(m=>String(m));const u=(m,b)=>{let y=m;for(let x=0;x<b.length&&y!=null;++x)y=y[b[x]];return y},d=(m,b)=>b==null||m==null?b:typeof m=="object"&&"key"in m?Object.hasOwn(b,m.key)?b[m.key]:u(b,m.path):typeof m=="function"?m(b):Array.isArray(m)?u(b,m):typeof b=="object"?b[m]:b,h=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 s.map(m=>({original:m,criteria:h.map(b=>d(b,m))})).slice().sort((m,b)=>{for(let y=0;y<h.length;y++){const x=e.compareValues(m.criteria[y],b.criteria[y],l[y]);if(x!==0)return x}return 0}).map(m=>m.original)}t.orderBy=i})(MC)),MC}var CC={},d$;function xEe(){return d$||(d$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],s=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<s?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(CC)),CC}var PC={},h$;function cY(){return h$||(h$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iY(),n=$O(),r=QX(),i=JX();function s(o,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.eq(c[l],o):!1}t.isIterateeCall=s})(PC)),PC}var f$;function yEe(){return f$||(f$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bEe(),n=xEe(),r=cY();function i(s,...o){const l=o.length;return l>1&&r.isIterateeCall(s,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(s,n.flatten(o),["asc"])}t.sortBy=i})(kC)),kC}var jC,m$;function vEe(){return m$||(m$=1,jC=yEe().sortBy),jC}var wEe=vEe();const Xk=gl(wEe);var uY=t=>t.legend.settings,_Ee=t=>t.legend.size,SEe=t=>t.legend.payload,NEe=st([SEe,uY],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?Xk(r,n):r});function kEe(){return zt(NEe)}var Y_=1;function dY(){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 s=i.getBoundingClientRect(),o={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(o.height-e.height)>Y_||Math.abs(o.left-e.left)>Y_||Math.abs(o.top-e.top)>Y_||Math.abs(o.width-e.width)>Y_)&&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 Oa(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 MEe=typeof Symbol=="function"&&Symbol.observable||"@@observable",p$=MEe,DC=()=>Math.random().toString(36).substring(7).split("").join("."),EEe={INIT:`@@redux/INIT${DC()}`,REPLACE:`@@redux/REPLACE${DC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${DC()}`},AS=EEe;function GO(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 hY(t,e,n){if(typeof t!="function")throw new Error(Oa(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Oa(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Oa(1));return n(hY)(t,e)}let r=t,i=e,s=new Map,o=s,l=0,c=!1;function u(){o===s&&(o=new Map,s.forEach((x,v)=>{o.set(v,x)}))}function d(){if(c)throw new Error(Oa(3));return i}function h(x){if(typeof x!="function")throw new Error(Oa(4));if(c)throw new Error(Oa(5));let v=!0;u();const S=l++;return o.set(S,x),function(){if(v){if(c)throw new Error(Oa(6));v=!1,u(),o.delete(S),s=null}}}function p(x){if(!GO(x))throw new Error(Oa(7));if(typeof x.type>"u")throw new Error(Oa(8));if(typeof x.type!="string")throw new Error(Oa(17));if(c)throw new Error(Oa(9));try{c=!0,i=r(i,x)}finally{c=!1}return(s=o).forEach(S=>{S()}),x}function m(x){if(typeof x!="function")throw new Error(Oa(10));r=x,p({type:AS.REPLACE})}function b(){const x=h;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(Oa(11));function S(){const T=v;T.next&&T.next(d())}return S(),{unsubscribe:x(S)}},[p$](){return this}}}return p({type:AS.INIT}),{dispatch:p,subscribe:h,getState:d,replaceReducer:m,[p$]:b}}function TEe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:AS.INIT})>"u")throw new Error(Oa(12));if(typeof n(void 0,{type:AS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Oa(13))})}function fY(t){const e=Object.keys(t),n={};for(let s=0;s<e.length;s++){const o=e[s];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{TEe(n)}catch(s){i=s}return function(o={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const h=r[d],p=n[h],m=o[h],b=p(m,l);if(typeof b>"u")throw l&&l.type,new Error(Oa(14));u[h]=b,c=c||b!==m}return c=c||r.length!==Object.keys(o).length,c?u:o}}function CS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function AEe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Oa(15))};const o={getState:i.getState,dispatch:(c,...u)=>s(c,...u)},l=t.map(c=>c(o));return s=CS(...l)(i.dispatch),{...i,dispatch:s}}}function mY(t){return GO(t)&&"type"in t&&typeof t.type=="string"}var pY=Symbol.for("immer-nothing"),g$=Symbol.for("immer-draftable"),Ms=Symbol.for("immer-state");function Dl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var vo=Object,ob=vo.getPrototypeOf,PS="constructor",Yk="prototype",Y3="configurable",jS="enumerable",H1="writable",hy="value",Yu=t=>!!t&&!!t[Ms];function $l(t){return t?gY(t)||Qk(t)||!!t[g$]||!!t[PS]?.[g$]||Zk(t)||Jk(t):!1}var CEe=vo[Yk][PS].toString(),b$=new WeakMap;function gY(t){if(!t||!qO(t))return!1;const e=ob(t);if(e===null||e===vo[Yk])return!0;const n=vo.hasOwnProperty.call(e,PS)&&e[PS];if(n===Object)return!0;if(!pg(n))return!1;let r=b$.get(n);return r===void 0&&(r=Function.toString.call(n),b$.set(n,r)),r===CEe}function Zy(t,e,n=!0){Jy(t)===0?(n?Reflect.ownKeys(t):vo.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Jy(t){const e=t[Ms];return e?e.type_:Qk(t)?1:Zk(t)?2:Jk(t)?3:0}var x$=(t,e,n=Jy(t))=>n===2?t.has(e):vo[Yk].hasOwnProperty.call(t,e),Q3=(t,e,n=Jy(t))=>n===2?t.get(e):t[e],DS=(t,e,n,r=Jy(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function PEe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Qk=Array.isArray,Zk=t=>t instanceof Map,Jk=t=>t instanceof Set,qO=t=>typeof t=="object",pg=t=>typeof t=="function",RC=t=>typeof t=="boolean",yu=t=>t.copy_||t.base_,WO=t=>t.modified_?t.copy_:t.base_;function Z3(t,e){if(Zk(t))return new Map(t);if(Jk(t))return new Set(t);if(Qk(t))return Array[Yk].slice.call(t);const n=gY(t);if(e===!0||e==="class_only"&&!n){const r=vo.getOwnPropertyDescriptors(t);delete r[Ms];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l[H1]===!1&&(l[H1]=!0,l[Y3]=!0),(l.get||l.set)&&(r[o]={[Y3]:!0,[H1]:!0,[jS]:l[jS],[hy]:t[o]})}return vo.create(ob(t),r)}else{const r=ob(t);if(r!==null&&n)return{...t};const i=vo.create(r);return vo.assign(i,t)}}function KO(t,e=!1){return eM(t)||Yu(t)||!$l(t)||(Jy(t)>1&&vo.defineProperties(t,{set:Q_,add:Q_,clear:Q_,delete:Q_}),vo.freeze(t),e&&Zy(t,(n,r)=>{KO(r,!0)},!1)),t}function jEe(){Dl(2)}var Q_={[hy]:jEe};function eM(t){return t===null||!qO(t)?!0:vo.isFrozen(t)}var RS="MapSet",J3="Patches",bY={};function lb(t){const e=bY[t];return e||Dl(0,t),e}var DEe=t=>!!bY[t],fy,xY=()=>fy,REe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:DEe(RS)?lb(RS):void 0});function y$(t,e){e&&(t.patchPlugin_=lb(J3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function eD(t){tD(t),t.drafts_.forEach(OEe),t.drafts_=null}function tD(t){t===fy&&(fy=t.parent_)}var v$=t=>fy=REe(fy,t);function OEe(t){const e=t[Ms];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function w$(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Ms].modified_&&(eD(e),Dl(4)),$l(t)&&(t=_$(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Ms].base_,t,e)}else t=_$(e,n);return LEe(e,t,!0),eD(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==pY?t:void 0}function _$(t,e){if(eM(e))return e;const n=e[Ms];if(!n)return XO(e,t.handledSet_,t);if(!tM(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);wY(n,t)}return n.copy_}function LEe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&KO(e,n)}function yY(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var tM=(t,e)=>t.scope_===e,FEe=[];function vY(t,e,n,r){const i=yu(t),s=t.type_;if(r!==void 0&&Q3(i,r,s)===e){DS(i,r,n,s);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;Zy(i,(c,u)=>{if(Yu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??FEe;for(const l of o)DS(i,l,n,s)}function IEe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!tM(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const o=WO(s);vY(t,s.draft_??s,o,n),wY(s,i)})}function wY(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)}yY(t)}}function zEe(t,e,n){const{scope_:r}=t;if(Yu(n)){const i=n[Ms];tM(i,r)&&i.callbacks_.push(function(){$1(t);const o=WO(i);vY(t,n,o,e)})}else $l(n)&&t.callbacks_.push(function(){const s=yu(t);Q3(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&XO(Q3(t.copy_,e,t.type_),r.handledSet_,r)})}function XO(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Yu(t)||e.has(t)||!$l(t)||eM(t)||(e.add(t),Zy(t,(r,i)=>{if(Yu(i)){const s=i[Ms];if(tM(s,n)){const o=WO(s);DS(t,r,o,t.type_),yY(s)}}else $l(i)&&XO(i,e,n)})),t}function UEe(t,e){const n=Qk(t),r={type_:n?1:0,scope_:e?e.scope_:xY(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,s=YO;n&&(i=[r],s=my);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,[l,r]}var YO={get(t,e){if(e===Ms)return t;const n=yu(t);if(!x$(n,e,t.type_))return BEe(t,n,e);const r=n[e];if(t.finalized_||!$l(r))return r;if(r===OC(t.base_,e)){$1(t);const i=t.type_===1?+e:e,s=rD(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in yu(t)},ownKeys(t){return Reflect.ownKeys(yu(t))},set(t,e,n){const r=_Y(yu(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=OC(yu(t),e),s=i?.[Ms];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(PEe(n,i)&&(n!==void 0||x$(t.base_,e,t.type_)))return!0;$1(t),nD(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),zEe(t,e,n)),!0},deleteProperty(t,e){return $1(t),OC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),nD(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=yu(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[H1]:!0,[Y3]:t.type_!==1||e!=="length",[jS]:r[jS],[hy]:n[e]}},defineProperty(){Dl(11)},getPrototypeOf(t){return ob(t.base_)},setPrototypeOf(){Dl(12)}},my={};Zy(YO,(t,e)=>{my[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});my.deleteProperty=function(t,e){return my.set.call(this,t,e,void 0)};my.set=function(t,e,n){return YO.set.call(this,t[0],e,n,t[0])};function OC(t,e){const n=t[Ms];return(n?yu(n):t)[e]}function BEe(t,e,n){const r=_Y(e,n);return r?hy in r?r[hy]:r.get?.call(t.draft_):void 0}function _Y(t,e){if(!(e in t))return;let n=ob(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=ob(n)}}function nD(t){t.modified_||(t.modified_=!0,t.parent_&&nD(t.parent_))}function $1(t){t.copy_||(t.assigned_=new Map,t.copy_=Z3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var HEe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(pg(n)&&!pg(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,h=>r.call(this,h,...d))}}pg(r)||Dl(6),i!==void 0&&!pg(i)&&Dl(7);let s;if($l(n)){const o=v$(this),l=rD(o,n,void 0);let c=!0;try{s=r(l),c=!1}finally{c?eD(o):tD(o)}return y$(o,i),w$(s,o)}else if(!n||!qO(n)){if(s=r(n),s===void 0&&(s=n),s===pY&&(s=void 0),this.autoFreeze_&&KO(s,!0),i){const o=[],l=[];lb(J3).generateReplacementPatches_(n,s,{patches_:o,inversePatches_:l}),i(o,l)}return s}else Dl(1,n)},this.produceWithPatches=(n,r)=>{if(pg(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,s;return[this.produce(n,r,(l,c)=>{i=l,s=c}),i,s]},RC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),RC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),RC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){$l(e)||Dl(8),Yu(e)&&(e=Ul(e));const n=v$(this),r=rD(n,e,void 0);return r[Ms].isManual_=!0,tD(n),r}finishDraft(e,n){const r=e&&e[Ms];(!r||!r.isManual_)&&Dl(9);const{scope_:i}=r;return y$(i,n),w$(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const s=n[r];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}r>-1&&(n=n.slice(r+1));const i=lb(J3).applyPatches_;return Yu(e)?i(e,n):this.produce(e,s=>i(s,n))}};function rD(t,e,n,r){const[i,s]=Zk(e)?lb(RS).proxyMap_(e,n):Jk(e)?lb(RS).proxySet_(e,n):UEe(e,n);return(n?.scope_??xY()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?IEe(n,s,r):s.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:u}=c;s.modified_&&u&&u.generatePatches_(s,[],c)}),i}function Ul(t){return Yu(t)||Dl(10,t),SY(t)}function SY(t){if(!$l(t)||eM(t))return t;const e=t[Ms];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Z3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=Z3(t,!0);return Zy(n,(i,s)=>{DS(n,i,SY(s))},r),e&&(e.finalized_=!1),n}var $Ee=new HEe,NY=$Ee.produce;function kY(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var VEe=kY(),GEe=kY,qEe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?CS:CS.apply(null,arguments)};function ml(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(ko(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=>mY(r)&&r.type===t,n}var MY=class f0 extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,f0.prototype)}static get[Symbol.species](){return f0}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new f0(...e[0].concat(this)):new f0(...e.concat(this))}};function S$(t){return $l(t)?NY(t,()=>{}):t}function Z_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function WEe(t){return typeof t=="boolean"}var KEe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let o=new MY;return n&&(WEe(n)?o.push(VEe):o.push(GEe(n.extraArgument))),o},EY="RTK_autoBatch",ni=()=>t=>({payload:t,meta:{[EY]:!0}}),N$=t=>e=>{setTimeout(e,t)},TY=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,s=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:N$(10):t.type==="callback"?t.queueNotification:N$(t.timeout),u=()=>{o=!1,s&&(s=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const h=()=>i&&d(),p=r.subscribe(h);return l.add(d),()=>{p(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[EY],s=!i,s&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},XEe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new MY(t);return r&&i.push(TY(typeof r=="object"?r:void 0)),i};function YEe(t){const e=KEe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:s=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(GO(n))l=fY(n);else throw new Error(ko(1));let c;typeof r=="function"?c=r(e):c=e();let u=CS;i&&(u=qEe({trace:!1,...typeof i=="object"&&i}));const d=AEe(...c),h=XEe(d);let p=typeof o=="function"?o(h):h();const m=u(...p);return hY(l,s,m)}function AY(t){const e={},n=[];let r;const i={addCase(s,o){const l=typeof s=="string"?s:s.type;if(!l)throw new Error(ko(28));if(l in e)throw new Error(ko(29));return e[l]=o,i},addAsyncThunk(s,o){return o.pending&&(e[s.pending.type]=o.pending),o.rejected&&(e[s.rejected.type]=o.rejected),o.fulfilled&&(e[s.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:s.settled,reducer:o.settled}),i},addMatcher(s,o){return n.push({matcher:s,reducer:o}),i},addDefaultCase(s){return r=s,i}};return t(i),[e,n,r]}function QEe(t){return typeof t=="function"}function ZEe(t,e){let[n,r,i]=AY(e),s;if(QEe(t))s=()=>S$(t());else{const l=S$(t);s=()=>l}function o(l=s(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,h)=>{if(h)if(Yu(d)){const m=h(d,c);return m===void 0?d:m}else{if($l(d))return NY(d,p=>h(p,c));{const p=h(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=s,o}var JEe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",eTe=(t=21)=>{let e="",n=t;for(;n--;)e+=JEe[Math.random()*64|0];return e},tTe=Symbol.for("rtk-slice-createasyncthunk");function nTe(t,e){return`${t}/${e}`}function rTe({creators:t}={}){const e=t?.asyncThunk?.[tTe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(ko(11));const o=(typeof r.reducers=="function"?r.reducers(aTe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(N,T){const M=typeof N=="string"?N:N.type;if(!M)throw new Error(ko(12));if(M in c.sliceCaseReducersByType)throw new Error(ko(13));return c.sliceCaseReducersByType[M]=T,u},addMatcher(N,T){return c.sliceMatchers.push({matcher:N,reducer:T}),u},exposeAction(N,T){return c.actionCreators[N]=T,u},exposeCaseReducer(N,T){return c.sliceCaseReducersByName[N]=T,u}};l.forEach(N=>{const T=o[N],M={reducerName:N,type:nTe(i,N),createNotation:typeof r.reducers=="function"};oTe(T)?cTe(M,T,u,e):sTe(M,T,u)});function d(){const[N={},T=[],M=void 0]=typeof r.extraReducers=="function"?AY(r.extraReducers):[r.extraReducers],A={...N,...c.sliceCaseReducersByType};return ZEe(r.initialState,k=>{for(let R in A)k.addCase(R,A[R]);for(let R of c.sliceMatchers)k.addMatcher(R.matcher,R.reducer);for(let R of T)k.addMatcher(R.matcher,R.reducer);M&&k.addDefaultCase(M)})}const h=N=>N,p=new Map,m=new WeakMap;let b;function y(N,T){return b||(b=d()),b(N,T)}function x(){return b||(b=d()),b.getInitialState()}function v(N,T=!1){function M(k){let R=k[N];return typeof R>"u"&&T&&(R=Z_(m,M,x)),R}function A(k=h){const R=Z_(p,T,()=>new WeakMap);return Z_(R,k,()=>{const C={};for(const[P,U]of Object.entries(r.selectors??{}))C[P]=iTe(U,k,()=>Z_(m,k,x),T);return C})}return{reducerPath:N,getSelectors:A,get selectors(){return A(M)},selectSlice:M}}const S={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:x,...v(s),injectInto(N,{reducerPath:T,...M}={}){const A=T??s;return N.inject({reducerPath:A,reducer:y},M),{...S,...v(A,!0)}}};return S}}function iTe(t,e,n,r){function i(s,...o){let l=e(s);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var Ys=rTe();function aTe(){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 sTe({type:t,reducerName:e,createNotation:n},r,i){let s,o;if("reducer"in r){if(n&&!lTe(r))throw new Error(ko(17));s=r.reducer,o=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,o?ml(t,o):ml(t))}function oTe(t){return t._reducerDefinitionType==="asyncThunk"}function lTe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function cTe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(ko(18));const{payloadCreator:s,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,h=i(t,s,d);r.exposeAction(e,h),o&&r.addCase(h.fulfilled,o),l&&r.addCase(h.pending,l),c&&r.addCase(h.rejected,c),u&&r.addMatcher(h.settled,u),r.exposeCaseReducer(e,{fulfilled:o||J_,pending:l||J_,rejected:c||J_,settled:u||J_})}function J_(){}var uTe="task",CY="listener",PY="completed",QO="cancelled",dTe=`task-${QO}`,hTe=`task-${PY}`,iD=`${CY}-${QO}`,fTe=`${CY}-${PY}`,nM=class{constructor(t){this.code=t,this.message=`${uTe} ${QO} (reason: ${t})`}name="TaskAbortError";message},ZO=(t,e)=>{if(typeof t!="function")throw new TypeError(ko(32))},OS=()=>{},jY=(t,e=OS)=>(t.catch(e),t),DY=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),nm=(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))},rm=t=>{if(t.aborted){const{reason:e}=t;throw new nM(e)}};function RY(t,e){let n=OS;return new Promise((r,i)=>{const s=()=>i(new nM(t.reason));if(t.aborted){s();return}n=DY(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=OS})}var mTe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof nM?"cancelled":"rejected",error:n}}finally{e?.()}},LS=t=>e=>jY(RY(t,e).then(n=>(rm(t),n))),OY=t=>{const e=LS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:zg}=Object,k$={},rM="listenerMiddleware",pTe=(t,e)=>{const n=r=>DY(t,()=>nm(r,t.reason));return(r,i)=>{ZO(r);const s=new AbortController;n(s);const o=mTe(async()=>{rm(t),rm(s.signal);const l=await r({pause:LS(s.signal),delay:OY(s.signal),signal:s.signal});return rm(s.signal),l},()=>nm(s,hTe));return i?.autoJoin&&e.push(o.catch(OS)),{result:LS(t)(o),cancel(){nm(s,dTe)}}}},gTe=(t,e)=>{const n=async(r,i)=>{rm(e);let s=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(h,p)=>{p.unsubscribe(),c([h,p.getState(),p.getOriginalState()])}});s=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await RY(e,Promise.race(l));return rm(e),c}finally{s()}};return(r,i)=>jY(n(r,i))},LY=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=ml(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(ko(21));return ZO(s),{predicate:i,type:e,effect:s}},FY=zg(t=>{const{type:e,predicate:n,effect:r}=LY(t);return{id:eTe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(ko(22))}}},{withTypes:()=>FY}),M$=(t,e)=>{const{type:n,effect:r,predicate:i}=LY(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},aD=t=>{t.pending.forEach(e=>{nm(e,iD)})},bTe=(t,e)=>()=>{for(const n of e.keys())aD(n);t.clear()},E$=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},IY=zg(ml(`${rM}/add`),{withTypes:()=>IY}),xTe=ml(`${rM}/removeAll`),zY=zg(ml(`${rM}/remove`),{withTypes:()=>zY}),yTe=(...t)=>{console.error(`${rM}/error`,...t)},ev=(t={})=>{const e=new Map,n=new Map,r=m=>{const b=n.get(m)??0;n.set(m,b+1)},i=m=>{const b=n.get(m)??1;b===1?n.delete(m):n.set(m,b-1)},{extra:s,onError:o=yTe}=t;ZO(o);const l=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),b=>{m.unsubscribe(),b?.cancelActive&&aD(m)}),c=m=>{const b=M$(e,m)??FY(m);return l(b)};zg(c,{withTypes:()=>c});const u=m=>{const b=M$(e,m);return b&&(b.unsubscribe(),m.cancelActive&&aD(b)),!!b};zg(u,{withTypes:()=>u});const d=async(m,b,y,x)=>{const v=new AbortController,S=gTe(c,v.signal),N=[];try{m.pending.add(v),r(m),await Promise.resolve(m.effect(b,zg({},y,{getOriginalState:x,condition:(T,M)=>S(T,M).then(Boolean),take:S,delay:OY(v.signal),pause:LS(v.signal),extra:s,signal:v.signal,fork:pTe(v.signal,N),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((T,M,A)=>{T!==v&&(nm(T,iD),A.delete(T))})},cancel:()=>{nm(v,iD),m.pending.delete(v)},throwIfCancelled:()=>{rm(v.signal)}})))}catch(T){T instanceof nM||E$(o,T,{raisedBy:"effect"})}finally{await Promise.all(N),nm(v,fTe),i(m),m.pending.delete(v)}},h=bTe(e,n);return{middleware:m=>b=>y=>{if(!mY(y))return b(y);if(IY.match(y))return c(y.payload);if(xTe.match(y)){h();return}if(zY.match(y))return u(y.payload);let x=m.getState();const v=()=>{if(x===k$)throw new Error(ko(23));return x};let S;try{if(S=b(y),e.size>0){const N=m.getState(),T=Array.from(e.values());for(const M of T){let A=!1;try{A=M.predicate(y,N,x)}catch(k){A=!1,E$(o,k,{raisedBy:"predicate"})}A&&d(M,y,m,v)}}}finally{x=k$}return S},startListening:c,stopListening:u,clearListeners:h}};function ko(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 vTe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},UY=Ys({name:"chartLayout",initialState:vTe,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,s;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(s=e.payload.left)!==null&&s!==void 0?s:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:wTe,setLayout:_Te,setChartSize:STe,setScale:NTe}=UY.actions,kTe=UY.reducer;function BY(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function T$(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 kg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T$(Object(n),!0).forEach(function(r){MTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MTe(t,e,n){return(e=ETe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ETe(t){var e=TTe(t,"string");return typeof e=="symbol"?e:e+""}function TTe(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 wr(t,e,n){return Jr(t)||Jr(e)?n:fl(e)?km(t,e,n):typeof e=="function"?e(t):n}var ATe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:s,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&s!=="center"&&Ht(t[s]))return kg(kg({},t),{},{[s]:t[s]+(r||0)});if((l==="horizontal"||l==="vertical"&&s==="center")&&o!=="middle"&&Ht(t[o]))return kg(kg({},t),{},{[o]:t[o]+(i||0)})}return t},jc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",HY=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,s,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(s=!0),l.coordinate));return i||o.push(e),s||o.push(n),o},$Y=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:h,niceTicks:p,axisType:m}=t;if(!o)return null;var b=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,y=i==="category"&&o.bandwidth?o.bandwidth()/b:0;if(y=m==="angleAxis"&&s&&s.length>=2?wa(s[0]-s[1])*2*y:y,h||p){var x=(h||p||[]).map((v,S)=>{var N=r?r.indexOf(v):v;return{coordinate:o(N)+y,value:v,offset:y,index:S}});return x.filter(v=>!Xs(v.coordinate))}return c&&u?u.map((v,S)=>({coordinate:o(v)+y,value:v,index:S,offset:y})):o.ticks&&d!=null?o.ticks(d).map((v,S)=>({coordinate:o(v)+y,value:v,offset:y,index:S})):o.domain().map((v,S)=>({coordinate:o(v)+y,value:r?r[v]:v,index:S,offset:y}))},A$=1e-4,CTe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-A$,s=Math.max(r[0],r[1])+A$,o=t(e[0]),l=t(e[n-1]);(o<i||o>s||l<i||l>s)&&t.domain([e[0],e[n-1]])}},PTe=(t,e)=>{if(!e||e.length!==2||!Ht(e[0])||!Ht(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(!Ht(t[0])||t[0]<n)&&(i[0]=n),(!Ht(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},jTe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0,o=0;o<e;++o){var l=Xs(t[o][n][1])?t[o][n][0]:t[o][n][1];l>=0?(t[o][n][0]=i,t[o][n][1]=i+l,i=t[o][n][1]):(t[o][n][0]=s,t[o][n][1]=s+l,s=t[o][n][1])}},DTe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0;s<e;++s){var o=Xs(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=i,t[s][n][1]=i+o,i=t[s][n][1]):(t[s][n][0]=0,t[s][n][1]=0)}},RTe={sign:jTe,expand:r2e,none:sb,silhouette:i2e,wiggle:a2e,positive:DTe},OTe=(t,e,n)=>{var r=RTe[n],i=n2e().keys(e).value((s,o)=>Number(wr(s,o,0))).order(K3).offset(r);return i(t)};function VY(t){return t==null?void 0:String(t)}function FS(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Jr(i[e.dataKey])){var l=WX(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var c=wr(i,Jr(o)?e.dataKey:o);return Jr(c)?null:e.scale(c)}var C$=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:s,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=wr(s,e.dataKey,e.scale.domain()[o]);return Jr(l)?null:e.scale(l)-i/2+r},LTe=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]},FTe=t=>{var e=t.flat(2).filter(Ht);return[Math.min(...e),Math.max(...e)]},ITe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],zTe=(t,e,n)=>{if(t!=null)return ITe(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:o}=s,l=o.reduce((c,u)=>{var d=BY(u,e,n),h=FTe(d);return[Math.min(c[0],h[0]),Math.max(c[1],h[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},P$=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,j$=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Lh=(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=Xk(e,d=>d.coordinate),s=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];s=Math.min((c.coordinate||0)-(u.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function D$(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return kg(kg({},e),{},{dataKey:n,payload:r,value:i,name:s})}function $h(t,e){if(t)return String(t);if(typeof e=="string")return e}var UTe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},BTe=(t,e)=>e==="centric"?t.angle:t.radius,rd=t=>t.layout.width,id=t=>t.layout.height,HTe=t=>t.layout.scale,GY=t=>t.layout.margin,iM=st(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),aM=st(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),qY="data-recharts-item-index",WY="data-recharts-item-data-key",tv=60;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 e1(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){$Te(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 $Te(t,e,n){return(e=VTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VTe(t){var e=GTe(t,"string");return typeof e=="symbol"?e:e+""}function GTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var qTe=t=>t.brush.height;function WTe(t){var e=aM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:tv;return n+i}return n},0)}function KTe(t){var e=aM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:tv;return n+i}return n},0)}function XTe(t){var e=iM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function YTe(t){var e=iM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var aa=st([rd,id,GY,qTe,WTe,KTe,XTe,YTe,uY,_Ee],(t,e,n,r,i,s,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+s},h={top:(n.top||0)+o,bottom:(n.bottom||0)+l},p=e1(e1({},h),d),m=p.bottom;p.bottom+=r,p=ATe(p,c,u);var b=t-p.left-p.right,y=e-p.top-p.bottom;return e1(e1({brushBottom:m},p),{},{width:Math.max(b,0),height:Math.max(y,0)})}),QTe=st(aa,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),JO=st(rd,id,(t,e)=>({x:0,y:0,width:t,height:e})),ZTe=_.createContext(null),sa=()=>_.useContext(ZTe)!=null,sM=t=>t.brush,oM=st([sM,aa,GY],(t,e,n)=>({height:t.height,x:Ht(t.x)?t.x:e.left,y:Ht(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Ht(t.width)?t.width:e.width})),LC={},FC={},IC={},O$;function JTe(){return O$||(O$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:s}={}){let o,l=null;const c=s!=null&&s.includes("leading"),u=s==null||s.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},h=()=>{u&&d(),y()};let p=null;const m=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,h()},r)},b=()=>{p!==null&&(clearTimeout(p),p=null)},y=()=>{b(),o=void 0,l=null},x=()=>{d()},v=function(...S){if(i?.aborted)return;o=this,l=S;const N=p==null;m(),c&&N&&d()};return v.schedule=m,v.cancel=y,v.flush=x,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(IC)),IC}var L$;function eAe(){return L$||(L$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=JTe();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:o=!1,trailing:l=!0,maxWait:c}=s,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,h=null;const p=e.debounce(function(...y){d=r.apply(this,y),h=null},i,{edges:u}),m=function(...y){return c!=null&&(h===null&&(h=Date.now()),Date.now()-h>=c)?(d=r.apply(this,y),h=Date.now(),p.cancel(),p.schedule(),d):(p.apply(this,y),d)},b=()=>(p.flush(),d);return m.cancel=p.cancel,m.flush=b,m}t.debounce=n})(FC)),FC}var F$;function tAe(){return F$||(F$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eAe();function n(r,i=0,s={}){const{leading:o=!0,trailing:l=!0}=s;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})(LC)),LC}var zC,I$;function nAe(){return I$||(I$=1,zC=tAe().throttle),zC}var rAe=nAe();const iAe=gl(rAe);var IS=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},KY=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:s,maxHeight:o}=n,l=Xu(r)?t:Number(r),c=Xu(i)?e:Number(i);return s&&s>0&&(l?c=l/s:c&&(l=c*s),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},aAe={width:0,height:0,overflow:"visible"},sAe={width:0,overflowX:"visible"},oAe={height:0,overflowY:"visible"},lAe={},cAe=t=>{var{width:e,height:n}=t,r=Xu(e),i=Xu(n);return r&&i?aAe:r?sAe:i?oAe:lAe};function uAe(t){var{width:e,height:n,aspect:r}=t,i=e,s=n;return i===void 0&&s===void 0?(i="100%",s="100%"):i===void 0?i=r&&r>0?void 0:"100%":s===void 0&&(s=r&&r>0?void 0:"100%"),{width:i,height:s}}function _r(t){return Number.isFinite(t)}function Sc(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function sD(){return sD=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},sD.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 U$(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){dAe(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 dAe(t,e,n){return(e=hAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hAe(t){var e=fAe(t,"string");return typeof e=="symbol"?e:e+""}function fAe(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 XY=_.createContext({width:-1,height:-1});function mAe(t){return Sc(t.width)&&Sc(t.height)}function YY(t){var{children:e,width:n,height:r}=t,i=_.useMemo(()=>({width:n,height:r}),[n,r]);return mAe(i)?_.createElement(XY.Provider,{value:i},e):null}var eL=()=>_.useContext(XY),pAe=_.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:s,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:h,className:p,onResize:m,style:b={}}=t,y=_.useRef(null),x=_.useRef();x.current=m,_.useImperativeHandle(e,()=>y.current);var[v,S]=_.useState({containerWidth:r.width,containerHeight:r.height}),N=_.useCallback((R,C)=>{S(P=>{var U=Math.round(R),F=Math.round(C);return P.containerWidth===U&&P.containerHeight===F?P:{containerWidth:U,containerHeight:F}})},[]);_.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return Yy;var R=F=>{var B,{width:D,height:$}=F[0].contentRect;N(D,$),(B=x.current)===null||B===void 0||B.call(x,D,$)};d>0&&(R=iAe(R,d,{trailing:!0,leading:!1}));var C=new ResizeObserver(R),{width:P,height:U}=y.current.getBoundingClientRect();return N(P,U),C.observe(y.current),()=>{C.disconnect()}},[N,d]);var{containerWidth:T,containerHeight:M}=v;IS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:A,calculatedHeight:k}=KY(T,M,{width:i,height:s,aspect:n,maxHeight:c});return IS(A!=null&&A>0||k!=null&&k>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,A,k,i,s,o,l,n),_.createElement("div",{id:h?"".concat(h):void 0,className:tr("recharts-responsive-container",p),style:U$(U$({},b),{},{width:i,height:s,minWidth:o,minHeight:l,maxHeight:c}),ref:y},_.createElement("div",{style:cAe({width:i,height:s})},_.createElement(YY,{width:A,height:k},u)))}),V1=_.forwardRef((t,e)=>{var n=eL();if(Sc(n.width)&&Sc(n.height))return t.children;var{width:r,height:i}=uAe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:o}=KY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Ht(s)&&Ht(o)?_.createElement(YY,{width:s,height:o},t.children):_.createElement(pAe,sD({},t,{width:r,height:i,ref:e}))});function QY(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 nv=()=>{var t,e=sa(),n=zt(QTe),r=zt(oM),i=(t=zt(sM))===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}},gAe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},ZY=()=>{var t;return(t=zt(aa))!==null&&t!==void 0?t:gAe},tL=()=>zt(rd),nL=()=>zt(id),bAe=()=>zt(t=>t.layout.margin),Gn=t=>t.layout.layoutType,Um=()=>zt(Gn),xAe=()=>{var t=Um();if(t==="horizontal"||t==="vertical")return t},yAe=()=>{var t=Um();return t!==void 0},lM=t=>{var e=Br(),n=sa(),{width:r,height:i}=t,s=eL(),o=r,l=i;return s&&(o=s.width>0?s.width:r,l=s.height>0?s.height:i),_.useEffect(()=>{!n&&Sc(o)&&Sc(l)&&e(STe({width:o,height:l}))},[e,n,o,l]),null},JY=Symbol.for("immer-nothing"),B$=Symbol.for("immer-draftable"),Co=Symbol.for("immer-state");function Rl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var py=Object.getPrototypeOf;function cb(t){return!!t&&!!t[Co]}function Mm(t){return t?eQ(t)||Array.isArray(t)||!!t[B$]||!!t.constructor?.[B$]||rv(t)||uM(t):!1}var vAe=Object.prototype.constructor.toString(),H$=new WeakMap;function eQ(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=H$.get(n);return r===void 0&&(r=Function.toString.call(n),H$.set(n,r)),r===vAe}function zS(t,e,n=!0){cM(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 cM(t){const e=t[Co];return e?e.type_:Array.isArray(t)?1:rv(t)?2:uM(t)?3:0}function oD(t,e){return cM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function tQ(t,e,n){const r=cM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function wAe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function rv(t){return t instanceof Map}function uM(t){return t instanceof Set}function Df(t){return t.copy_||t.base_}function lD(t,e){if(rv(t))return new Map(t);if(uM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=eQ(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Co];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[o]})}return Object.create(py(t),r)}else{const r=py(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function rL(t,e=!1){return dM(t)||cb(t)||!Mm(t)||(cM(t)>1&&Object.defineProperties(t,{set:t1,add:t1,clear:t1,delete:t1}),Object.freeze(t),e&&Object.values(t).forEach(n=>rL(n,!0))),t}function _Ae(){Rl(2)}var t1={value:_Ae};function dM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var SAe={};function Em(t){const e=SAe[t];return e||Rl(0,t),e}var gy;function nQ(){return gy}function NAe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function $$(t,e){e&&(Em("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function cD(t){uD(t),t.drafts_.forEach(kAe),t.drafts_=null}function uD(t){t===gy&&(gy=t.parent_)}function V$(t){return gy=NAe(gy,t)}function kAe(t){const e=t[Co];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function G$(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Co].modified_&&(cD(e),Rl(4)),Mm(t)&&(t=US(e,t),e.parent_||BS(e,t)),e.patches_&&Em("Patches").generateReplacementPatches_(n[Co].base_,t,e.patches_,e.inversePatches_)):t=US(e,n,[]),cD(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==JY?t:void 0}function US(t,e,n){if(dM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Co];if(!i)return zS(e,(s,o)=>q$(t,i,e,s,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return BS(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let o=s,l=!1;i.type_===3&&(o=new Set(s),s.clear(),l=!0),zS(o,(c,u)=>q$(t,i,s,c,u,n,l),r),BS(t,s,!1),n&&t.patches_&&Em("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function q$(t,e,n,r,i,s,o){if(i==null||typeof i!="object"&&!o)return;const l=dM(i);if(!(l&&!o)){if(cb(i)){const c=s&&e&&e.type_!==3&&!oD(e.assigned_,r)?s.concat(r):void 0,u=US(t,i,c);if(tQ(n,r,u),cb(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Mm(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;US(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(rv(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&BS(t,i)}}}function BS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&rL(e,n)}function MAe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:nQ(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=iL;n&&(i=[r],s=by);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,l}var iL={get(t,e){if(e===Co)return t;const n=Df(t);if(!oD(n,e))return EAe(t,n,e);const r=n[e];return t.finalized_||!Mm(r)?r:r===UC(t.base_,e)?(BC(t),t.copy_[e]=hD(r,t)):r},has(t,e){return e in Df(t)},ownKeys(t){return Reflect.ownKeys(Df(t))},set(t,e,n){const r=rQ(Df(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=UC(Df(t),e),s=i?.[Co];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(wAe(n,i)&&(n!==void 0||oD(t.base_,e)))return!0;BC(t),dD(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 UC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,BC(t),dD(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Df(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Rl(11)},getPrototypeOf(t){return py(t.base_)},setPrototypeOf(){Rl(12)}},by={};zS(iL,(t,e)=>{by[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});by.deleteProperty=function(t,e){return by.set.call(this,t,e,void 0)};by.set=function(t,e,n){return iL.set.call(this,t[0],e,n,t[0])};function UC(t,e){const n=t[Co];return(n?Df(n):t)[e]}function EAe(t,e,n){const r=rQ(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function rQ(t,e){if(!(e in t))return;let n=py(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=py(n)}}function dD(t){t.modified_||(t.modified_=!0,t.parent_&&dD(t.parent_))}function BC(t){t.copy_||(t.copy_=lD(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var TAe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const s=n;n=e;const o=this;return function(c=s,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Rl(6),r!==void 0&&typeof r!="function"&&Rl(7);let i;if(Mm(e)){const s=V$(this),o=hD(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?cD(s):uD(s)}return $$(s,r),G$(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===JY&&(i=void 0),this.autoFreeze_&&rL(i,!0),r){const s=[],o=[];Em("Patches").generateReplacementPatches_(e,i,s,o),r(s,o)}return i}else Rl(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){Mm(t)||Rl(8),cb(t)&&(t=AAe(t));const e=V$(this),n=hD(t,void 0);return n[Co].isManual_=!0,uD(e),n}finishDraft(t,e){const n=t&&t[Co];(!n||!n.isManual_)&&Rl(9);const{scope_:r}=n;return $$(r,e),G$(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=Em("Patches").applyPatches_;return cb(t)?r(t,e):this.produce(t,i=>r(i,e))}};function hD(t,e){const n=rv(t)?Em("MapSet").proxyMap_(t,e):uM(t)?Em("MapSet").proxySet_(t,e):MAe(t,e);return(e?e.scope_:nQ()).drafts_.push(n),n}function AAe(t){return cb(t)||Rl(10,t),iQ(t)}function iQ(t){if(!Mm(t)||dM(t))return t;const e=t[Co];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=lD(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=lD(t,!0);return zS(n,(i,s)=>{tQ(n,i,iQ(s))},r),e&&(e.finalized_=!1),n}var CAe=new TAe;CAe.produce;var PAe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},aQ=Ys({name:"legend",initialState:PAe,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:ni()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ul(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:ni()},removeLegendPayload:{reducer(t,e){var n=Ul(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:ni()}}}),{setLegendSize:W$,setLegendSettings:jAe,addLegendPayload:sQ,replaceLegendPayload:oQ,removeLegendPayload:lQ}=aQ.actions,DAe=aQ.reducer,RAe=["contextPayload"];function fD(){return fD=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},fD.apply(null,arguments)}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 ub(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){OAe(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 OAe(t,e,n){return(e=LAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LAe(t){var e=FAe(t,"string");return typeof e=="symbol"?e:e+""}function FAe(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 IAe(t,e){if(t==null)return{};var n,r,i=zAe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function zAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function UAe(t){return t.value}function BAe(t){var{contextPayload:e}=t,n=IAe(t,RAe),r=aY(e,t.payloadUniqBy,UAe),i=ub(ub({},n),{},{payload:r});return _.isValidElement(t.content)?_.cloneElement(t.content,i):typeof t.content=="function"?_.createElement(t.content,i):_.createElement(R2e,i)}function HAe(t,e,n,r,i,s){var{layout:o,align:l,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(l==="center"&&o==="vertical"?u={left:((r||0)-s.width)/2}:u=l==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(c==="middle"?d={top:((i||0)-s.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),ub(ub({},u),d)}function $Ae(t){var e=Br();return _.useEffect(()=>{e(jAe(t))},[e,t]),null}function VAe(t){var e=Br();return _.useEffect(()=>(e(W$(t)),()=>{e(W$({width:0,height:0}))}),[e,t]),null}function GAe(t,e,n,r){return t==="vertical"&&Ht(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var qAe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function aL(t){var e=ui(t,qAe),n=kEe(),r=MMe(),i=bAe(),{width:s,height:o,wrapperStyle:l,portal:c}=e,[u,d]=dY([n]),h=tL(),p=nL();if(h==null||p==null)return null;var m=h-(i?.left||0)-(i?.right||0),b=GAe(e.layout,o,s,m),y=c?l:ub(ub({position:"absolute",width:b?.width||s||"auto",height:b?.height||o||"auto"},HAe(l,e,i,h,p,u)),l),x=c??r;if(x==null||n==null)return null;var v=_.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},_.createElement($Ae,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&_.createElement(VAe,{width:u.width,height:u.height}),_.createElement(BAe,fD({},e,b,{margin:i,chartWidth:h,chartHeight:p,contextPayload:n})));return Su.createPortal(v,x)}aL.displayName="Legend";function mD(){return mD=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},mD.apply(null,arguments)}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 HC(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){WAe(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 WAe(t,e,n){return(e=KAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KAe(t){var e=XAe(t,"string");return typeof e=="symbol"?e:e+""}function XAe(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 YAe(t){return Array.isArray(t)&&fl(t[0])&&fl(t[1])?t.join(" ~ "):t}var QAe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:h,accessibilityLayer:p=!1}=t,m=()=>{if(s&&s.length){var M={padding:0,margin:0},A=(l?Xk(s,l):s).map((k,R)=>{if(k.type==="none")return null;var C=k.formatter||o||YAe,{value:P,name:U}=k,F=P,B=U;if(C){var D=C(P,U,k,R,s);if(Array.isArray(D))[F,B]=D;else if(D!=null)F=D;else return null}var $=HC({display:"block",paddingTop:4,paddingBottom:4,color:k.color||"#000"},r);return _.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(R),style:$},fl(B)?_.createElement("span",{className:"recharts-tooltip-item-name"},B):null,fl(B)?_.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:M},A)}return null},b=HC({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=HC({margin:0},i),x=!Jr(d),v=x?d:"",S=tr("recharts-default-tooltip",c),N=tr("recharts-tooltip-label",u);x&&h&&s!==void 0&&s!==null&&(v=h(d,s));var T=p?{role:"status","aria-live":"assertive"}:{};return _.createElement("div",mD({className:S,style:b},T),_.createElement("p",{className:N,style:y},_.isValidElement(v)?v:"".concat(v)),m())},Qx="recharts-tooltip-wrapper",ZAe={visibility:"hidden"};function JAe(t){var{coordinate:e,translateX:n,translateY:r}=t;return tr(Qx,{["".concat(Qx,"-right")]:Ht(n)&&e&&Ht(e.x)&&n>=e.x,["".concat(Qx,"-left")]:Ht(n)&&e&&Ht(e.x)&&n<e.x,["".concat(Qx,"-bottom")]:Ht(r)&&e&&Ht(e.y)&&r>=e.y,["".concat(Qx,"-top")]:Ht(r)&&e&&Ht(e.y)&&r<e.y})}function Y$(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(s&&Ht(s[r]))return s[r];var d=n[r]-l-(i>0?i:0),h=n[r]+i;if(e[r])return o[r]?d:h;var p=c[r];if(p==null)return 0;if(o[r]){var m=d,b=p;return m<b?Math.max(h,p):Math.max(d,p)}if(u==null)return 0;var y=h+l,x=p+u;return y>x?Math.max(d,p):Math.max(h,p)}function eCe(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 tCe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,h;return o.height>0&&o.width>0&&n?(d=Y$({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),h=Y$({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=eCe({translateX:d,translateY:h,useTranslate3d:l})):u=ZAe,{cssProperties:u,cssClasses:JAe({translateX:d,translateY:h,coordinate:n})}}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 n1(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){pD(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 pD(t,e,n){return(e=nCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nCe(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)}class iCe extends _.PureComponent{constructor(){super(...arguments),pD(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),pD(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,s;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(s=this.props.coordinate)===null||s===void 0?void 0:s.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:s,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:h,useTranslate3d:p,viewBox:m,wrapperStyle:b,lastBoundingBox:y,innerRef:x,hasPortalFromProps:v}=this.props,{cssClasses:S,cssProperties:N}=tCe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:h,tooltipBox:{height:y.height,width:y.width},useTranslate3d:p,viewBox:m}),T=v?{}:n1(n1({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},N),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),M=n1(n1({},T),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},b);return _.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:S,style:M,ref:x},s)}}var cQ=()=>{var t;return(t=zt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function gD(){return gD=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},gD.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 J$(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){aCe(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 aCe(t,e,n){return(e=sCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sCe(t){var e=oCe(t,"string");return typeof e=="symbol"?e:e+""}function oCe(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 eV={curveBasisClosed:GMe,curveBasisOpen:qMe,curveBasis:VMe,curveBumpX:CMe,curveBumpY:PMe,curveLinearClosed:WMe,curveLinear:Wk,curveMonotoneX:KMe,curveMonotoneY:XMe,curveNatural:YMe,curveStep:QMe,curveStepAfter:JMe,curveStepBefore:ZMe},HS=t=>_r(t.x)&&_r(t.y),tV=t=>t.base!=null&&HS(t.base)&&HS(t),Zx=t=>t.x,Jx=t=>t.y,lCe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Xy(t));return(n==="curveMonotone"||n==="curveBump")&&e?eV["".concat(n).concat(e==="vertical"?"Y":"X")]:eV[n]||Wk},cCe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,o=lCe(e,i),l=s?n.filter(HS):n,c;if(Array.isArray(r)){var u=n.map((m,b)=>J$(J$({},m),{},{base:r[b]}));i==="vertical"?c=K_().y(Jx).x1(Zx).x0(m=>m.base.x):c=K_().x(Zx).y1(Jx).y0(m=>m.base.y);var d=c.defined(tV).curve(o),h=s?u.filter(tV):u;return d(h)}i==="vertical"&&Ht(r)?c=K_().y(Jx).x1(Zx).x0(r):Ht(r)?c=K_().x(Zx).y1(Jx).y0(r):c=RX().x(Zx).y(Jx);var p=c.defined(HS).curve(o);return p(l)},Ug=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?cCe(t):r;return _.createElement("path",gD({},ks(t),HO(t),{className:tr("recharts-curve",e),d:s===null?void 0:s,ref:i}))},uCe=["x","y","top","left","width","height","className"];function bD(){return bD=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},bD.apply(null,arguments)}function nV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function dCe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nV(Object(n),!0).forEach(function(r){hCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hCe(t,e,n){return(e=fCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fCe(t){var e=mCe(t,"string");return typeof e=="symbol"?e:e+""}function mCe(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 pCe(t,e){if(t==null)return{};var n,r,i=gCe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function gCe(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 bCe=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),xCe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:o=0,className:l}=t,c=pCe(t,uCe),u=dCe({x:e,y:n,top:r,left:i,width:s,height:o},c);return!Ht(e)||!Ht(n)||!Ht(s)||!Ht(o)||!Ht(r)||!Ht(i)?null:_.createElement("path",bD({},Ha(u),{className:tr("recharts-cross",l),d:bCe(e,n,s,o,r,i)}))};function yCe(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 rV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function iV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rV(Object(n),!0).forEach(function(r){vCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vCe(t,e,n){return(e=wCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wCe(t){var e=_Ce(t,"string");return typeof e=="symbol"?e:e+""}function _Ce(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 SCe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),uQ=(t,e,n)=>t.map(r=>"".concat(SCe(r)," ").concat(e,"ms ").concat(n)).join(","),NCe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),xy=(t,e)=>Object.keys(e).reduce((n,r)=>iV(iV({},n),{},{[r]:t(r,e[r])}),{});function aV(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 Yi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aV(Object(n),!0).forEach(function(r){kCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kCe(t,e,n){return(e=MCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MCe(t){var e=ECe(t,"string");return typeof e=="symbol"?e:e+""}function ECe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var $S=(t,e,n)=>t+(e-t)*n,xD=t=>{var{from:e,to:n}=t;return e!==n},dQ=(t,e,n)=>{var r=xy((i,s)=>{if(xD(s)){var[o,l]=t(s.from,s.to,s.velocity);return Yi(Yi({},s),{},{from:o,velocity:l})}return s},e);return n<1?xy((i,s)=>xD(s)?Yi(Yi({},s),{},{velocity:$S(s.velocity,r[i].velocity,n),from:$S(s.from,r[i].from,n)}):s,e):dQ(t,r,n-1)};function TCe(t,e,n,r,i,s){var o,l=r.reduce((p,m)=>Yi(Yi({},p),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),c=()=>xy((p,m)=>m.from,l),u=()=>!Object.values(l).filter(xD).length,d=null,h=p=>{o||(o=p);var m=p-o,b=m/n.dt;l=dQ(n,l,b),i(Yi(Yi(Yi({},t),e),c())),o=p,u()||(d=s.setTimeout(h))};return()=>(d=s.setTimeout(h),()=>{var p;(p=d)===null||p===void 0||p()})}function ACe(t,e,n,r,i,s,o){var l=null,c=i.reduce((h,p)=>Yi(Yi({},h),{},{[p]:[t[p],e[p]]}),{}),u,d=h=>{u||(u=h);var p=(h-u)/r,m=xy((y,x)=>$S(...x,n(p)),c);if(s(Yi(Yi(Yi({},t),e),m)),p<1)l=o.setTimeout(d);else{var b=xy((y,x)=>$S(...x,n(1)),c);s(Yi(Yi(Yi({},t),e),b))}};return()=>(l=o.setTimeout(d),()=>{var h;(h=l)===null||h===void 0||h()})}const CCe=(t,e,n,r,i,s)=>{var o=NCe(t,e);return n==null?()=>(i(Yi(Yi({},t),e)),()=>{}):n.isStepper===!0?TCe(t,e,n,o,i,s):ACe(t,e,n,r,o,i,s)};var VS=1e-4,hQ=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],fQ=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),sV=(t,e)=>n=>{var r=hQ(t,e);return fQ(r,n)},PCe=(t,e)=>n=>{var r=hQ(t,e),i=[...r.map((s,o)=>s*o).slice(1),0];return fQ(i,n)},jCe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,s=n[0].split("(");if(s[0]==="cubic-bezier"&&((i=s[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var o=s[1].split(")")[0].split(",").map(l=>parseFloat(l));return[o[0],o[1],o[2],o[3]]}}}return n.length===4?n:[0,0,1,1]},DCe=(t,e,n,r)=>{var i=sV(t,n),s=sV(e,r),o=PCe(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,h=d,p=0;p<8;++p){var m=i(h)-d,b=o(h);if(Math.abs(m-d)<VS||b<VS)return s(h);h=l(h-m/b)}return s(h)};return c.isStepper=!1,c},oV=function(){return DCe(...jCe(...arguments))},RCe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,s=(o,l,c)=>{var u=-(o-l)*n,d=c*r,h=c+(u-d)*i/1e3,p=c*i/1e3+o;return Math.abs(p-l)<VS&&Math.abs(h)<VS?[l,0]:[p,h]};return s.isStepper=!0,s.dt=i,s},OCe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return oV(t);case"spring":return RCe();default:if(t.split("(")[0]==="cubic-bezier")return oV(t)}return typeof t=="function"?t:null};function LCe(t){var e,n=()=>null,r=!1,i=null,s=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(s.bind(null,u),c);return}s(c),i=t.setTimeout(s.bind(null,u));return}typeof o=="string"&&(e=o,n(e)),typeof o=="object"&&(e=o,n(e)),typeof o=="function"&&o()}};return{stop:()=>{r=!0},start:o=>{r=!1,i&&(i(),i=null),s(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class FCe{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,s=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>{i!=null&&cancelAnimationFrame(i)}}}function ICe(){return LCe(new FCe)}var zCe=_.createContext(ICe);function UCe(t,e){var n=_.useContext(zCe);return _.useMemo(()=>e??n(t),[t,e,n])}var BCe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Db={devToolsEnabled:!1,isSsr:BCe()},HCe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},lV={t:0},$C={t:1};function Rb(t){var e=ui(t,HCe),{isActive:n,canBegin:r,duration:i,easing:s,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Db.isSsr:n,h=UCe(e.animationId,e.animationManager),[p,m]=_.useState(d?lV:$C),b=_.useRef(null);return _.useEffect(()=>{d||m($C)},[d]),_.useEffect(()=>{if(!d||!r)return Yy;var y=CCe(lV,$C,OCe(s),i,m,h.getTimeoutController()),x=()=>{b.current=y()};return h.start([c,o,x,i,l]),()=>{h.stop(),b.current&&b.current(),l()}},[d,r,i,s,o,c,l,h]),u(p.t)}function Ob(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=_.useRef(dy(e)),r=_.useRef(t);return r.current!==t&&(n.current=dy(e),r.current=t),n.current}var $Ce=["radius"],VCe=["radius"];function cV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function uV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cV(Object(n),!0).forEach(function(r){GCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GCe(t,e,n){return(e=qCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qCe(t){var e=WCe(t,"string");return typeof e=="symbol"?e:e+""}function WCe(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 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)}function dV(t,e){if(t==null)return{};var n,r,i=KCe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function KCe(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 hV=(t,e,n,r,i)=>{var s=Math.min(Math.abs(n)/2,Math.abs(r)/2),o=r>=0?1:-1,l=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(s>0&&i instanceof Array){for(var d=[0,0,0,0],h=0,p=4;h<p;h++)d[h]=i[h]>s?s:i[h];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,`,
- `).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,`,
- `).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,`,
- `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(s>0&&i===+i&&i>0){var m=Math.min(s,i);u="M ".concat(t,",").concat(e+o*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+l*m,",").concat(e,`
- L `).concat(t+n-l*m,",").concat(e,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*m,`
- L `).concat(t+n,",").concat(e+r-o*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n-l*m,",").concat(e+r,`
- L `).concat(t+l*m,",").concat(e+r,`
- 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},fV={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},mQ=t=>{var e=ui(t,fV),n=_.useRef(null),[r,i]=_.useState(-1);_.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var I=n.current.getTotalLength();I&&i(I)}catch{}},[]);var{x:s,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:h,animationDuration:p,animationBegin:m,isAnimationActive:b,isUpdateAnimationActive:y}=e,x=_.useRef(l),v=_.useRef(c),S=_.useRef(s),N=_.useRef(o),T=_.useMemo(()=>({x:s,y:o,width:l,height:c,radius:u}),[s,o,l,c,u]),M=Ob(T,"rectangle-");if(s!==+s||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var A=tr("recharts-rectangle",d);if(!y){var k=Ha(e),{radius:R}=k,C=dV(k,$Ce);return _.createElement("path",GS({},C,{radius:typeof u=="number"?u:void 0,className:A,d:hV(s,o,l,c,u)}))}var P=x.current,U=v.current,F=S.current,B=N.current,D="0px ".concat(r===-1?1:r,"px"),$="".concat(r,"px 0px"),G=uQ(["strokeDasharray"],p,typeof h=="string"?h:fV.animationEasing);return _.createElement(Rb,{animationId:M,key:M,canBegin:r>0,duration:p,easing:h,isActive:y,begin:m},I=>{var K=pr(P,l,I),Q=pr(U,c,I),se=pr(F,s,I),H=pr(B,o,I);n.current&&(x.current=K,v.current=Q,S.current=se,N.current=H);var W;b?I>0?W={transition:G,strokeDasharray:$}:W={strokeDasharray:D}:W={strokeDasharray:$};var J=Ha(e),{radius:ne}=J,xe=dV(J,VCe);return _.createElement("path",GS({},xe,{radius:typeof u=="number"?u:void 0,className:A,d:hV(se,H,K,Q,u),ref:n,style:uV(uV({},W),e.style)}))})};function mV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mV(Object(n),!0).forEach(function(r){XCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XCe(t,e,n){return(e=YCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YCe(t){var e=QCe(t,"string");return typeof e=="symbol"?e:e+""}function QCe(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 qS=Math.PI/180,ZCe=t=>t*180/Math.PI,Hi=(t,e,n,r)=>({x:t+Math.cos(-qS*r)*n,y:e+Math.sin(-qS*r)*n}),pQ=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(e-(r.left||0)-(r.right||0)),Math.abs(n-(r.top||0)-(r.bottom||0)))/2},JCe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},ePe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,o=JCe({x:n,y:r},{x:i,y:s});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>s&&(c=2*Math.PI-c),{radius:o,angle:ZCe(c),angleInRadian:c}},tPe=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),s=Math.min(r,i);return{startAngle:e-s*360,endAngle:n-s*360}},nPe=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),s=Math.floor(r/360),o=Math.min(i,s);return t+o*360},rPe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=ePe({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=tPe(e),d=s,h;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;h=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;h=d>=u&&d<=c}return h?pV(pV({},e),{},{radius:i,angle:nPe(d,e)}):null};function gQ(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,o=Hi(e,n,r,i),l=Hi(e,n,r,s);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function yD(){return yD=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},yD.apply(null,arguments)}var iPe=(t,e)=>{var n=wa(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},r1=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/qS,h=c?i:i+s*d,p=Hi(e,n,u,h),m=Hi(e,n,r,h),b=c?i-s*d:i,y=Hi(e,n,u*Math.cos(d*qS),b);return{center:p,circleTangency:m,lineTangency:y,theta:d}},bQ=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:o}=t,l=iPe(s,o),c=s+l,u=Hi(e,n,i,s),d=Hi(e,n,i,c),h="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(s>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var p=Hi(e,n,r,s),m=Hi(e,n,r,c);h+="L ".concat(m.x,",").concat(m.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(s<=c),`,
- `).concat(p.x,",").concat(p.y," Z")}else h+="L ".concat(e,",").concat(n," Z");return h},aPe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=wa(u-c),{circleTangency:h,lineTangency:p,theta:m}=r1({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:s,cornerIsExternal:l}),{circleTangency:b,lineTangency:y,theta:x}=r1({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:s,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-m-x;if(v<0)return o?"M ".concat(p.x,",").concat(p.y,`
- a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0
- a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0
- `):bQ({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S="M ".concat(p.x,",").concat(p.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(h.x,",").concat(h.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(v>180),",").concat(+(d<0),",").concat(b.x,",").concat(b.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
- `);if(r>0){var{circleTangency:N,lineTangency:T,theta:M}=r1({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),{circleTangency:A,lineTangency:k,theta:R}=r1({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),C=l?Math.abs(c-u):Math.abs(c-u)-M-R;if(C<0&&s===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+="L".concat(k.x,",").concat(k.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(C>180),",").concat(+(d>0),",").concat(N.x,",").concat(N.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(T.x,",").concat(T.y,"Z")}else S+="L".concat(e,",").concat(n,"Z");return S},sPe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},xQ=t=>{var e=ui(t,sPe),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:h}=e;if(s<i||u===d)return null;var p=tr("recharts-sector",h),m=s-i,b=as(o,m,0,!0),y;return b>0&&Math.abs(u-d)<360?y=aPe({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(b,m/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=bQ({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:u,endAngle:d}),_.createElement("path",yD({},Ha(e),{className:p,d:y}))};function oPe(t,e,n){if(t==="horizontal")return[{x:e.x,y:n.top},{x:e.x,y:n.top+n.height}];if(t==="vertical")return[{x:n.left,y:e.y},{x:n.left+n.width,y:e.y}];if(XX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:o,angle:l}=e,c=Hi(r,i,s,l),u=Hi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return gQ(e)}}var VC={},GC={},qC={},gV;function lPe(){return gV||(gV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lY();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(qC)),qC}var bV;function cPe(){return bV||(bV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lPe();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})(GC)),GC}var xV;function uPe(){return xV||(xV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cY(),n=cPe();function r(i,s,o){o&&typeof o!="number"&&e.isIterateeCall(i,s,o)&&(s=o=void 0),i=n.toFinite(i),s===void 0?(s=i,i=0):s=n.toFinite(s),o=o===void 0?i<s?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((s-i)/(o||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=o;return c}t.range=r})(VC)),VC}var WC,yV;function dPe(){return yV||(yV=1,WC=uPe().range),WC}var hPe=dPe();const yQ=gl(hPe);function Sh(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function fPe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function sL(t){let e,n,r;t.length!==2?(e=Sh,n=(l,c)=>Sh(t(l),c),r=(l,c)=>t(l)-c):(e=t===Sh||t===fPe?t:mPe,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 h=u+d>>>1;n(l[h],c)<0?u=h+1:d=h}while(u<d)}return u}function s(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const h=u+d>>>1;n(l[h],c)<=0?u=h+1:d=h}while(u<d)}return u}function o(l,c,u=0,d=l.length){const h=i(l,c,u,d-1);return h>u&&r(l[h-1],c)>-r(l[h],c)?h-1:h}return{left:i,center:o,right:s}}function mPe(){return 0}function vQ(t){return t===null?NaN:+t}function*pPe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const gPe=sL(Sh),iv=gPe.right;sL(vQ).center;class vV extends Map{constructor(e,n=yPe){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(wV(this,e))}has(e){return super.has(wV(this,e))}set(e,n){return super.set(bPe(this,e),n)}delete(e){return super.delete(xPe(this,e))}}function wV({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function bPe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function xPe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function yPe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function vPe(t=Sh){if(t===Sh)return wQ;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 wQ(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const wPe=Math.sqrt(50),_Pe=Math.sqrt(10),SPe=Math.sqrt(2);function WS(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),o=s>=wPe?10:s>=_Pe?5:s>=SPe?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?WS(t,e,n*2):[l,c,u]}function vD(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,s,o]=r?WS(e,t,n):WS(t,e,n);if(!(s>=i))return[];const l=s-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(s-u)/-o;else for(let u=0;u<l;++u)c[u]=(s-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(i+u)/-o;else for(let u=0;u<l;++u)c[u]=(i+u)*o;return c}function wD(t,e,n){return e=+e,t=+t,n=+n,WS(t,e,n)[2]}function _D(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?wD(e,t,n):wD(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function _V(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function SV(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function _Q(t,e,n=0,r=1/0,i){if(e=Math.floor(e),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(t.length-1,r)),!(n<=e&&e<=r))return t;for(i=i===void 0?wQ:vPe(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),h=.5*Math.exp(2*d/3),p=.5*Math.sqrt(d*h*(c-h)/c)*(u-c/2<0?-1:1),m=Math.max(n,Math.floor(e-u*h/c+p)),b=Math.min(r,Math.floor(e+(c-u)*h/c+p));_Q(t,e,m,b,i)}const s=t[e];let o=n,l=r;for(e0(t,n,e),i(t[r],s)>0&&e0(t,n,r);o<l;){for(e0(t,o,l),++o,--l;i(t[o],s)<0;)++o;for(;i(t[l],s)>0;)--l}i(t[n],s)===0?e0(t,n,l):(++l,e0(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function e0(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function NPe(t,e,n){if(t=Float64Array.from(pPe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return SV(t);if(e>=1)return _V(t);var r,i=(r-1)*e,s=Math.floor(i),o=_V(_Q(t,s).subarray(0,s+1)),l=SV(t.subarray(s+1));return o+(l-o)*(i-s)}}function kPe(t,e,n=vQ){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,s=Math.floor(i),o=+n(t[s],s,t),l=+n(t[s+1],s+1,t);return o+(l-o)*(i-s)}}function MPe(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,s=new Array(i);++r<i;)s[r]=t+r*n;return s}function xl(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function ad(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 SD=Symbol("implicit");function oL(){var t=new vV,e=[],n=[],r=SD;function i(s){let o=t.get(s);if(o===void 0){if(r!==SD)return r;t.set(s,o=e.push(s)-1)}return n[o%n.length]}return i.domain=function(s){if(!arguments.length)return e.slice();e=[],t=new vV;for(const o of s)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(s){return arguments.length?(n=Array.from(s),i):n.slice()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return oL(e,n).unknown(r)},xl.apply(i,arguments),i}function lL(){var t=oL().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function h(){var p=e().length,m=i<r,b=m?i:r,y=m?r:i;s=(y-b)/Math.max(1,p-c+u*2),l&&(s=Math.floor(s)),b+=(y-b-s*(p-c))*d,o=s*(1-c),l&&(b=Math.round(b),o=Math.round(o));var x=MPe(p).map(function(v){return b+s*v});return n(m?x.reverse():x)}return t.domain=function(p){return arguments.length?(e(p),h()):e()},t.range=function(p){return arguments.length?([r,i]=p,r=+r,i=+i,h()):[r,i]},t.rangeRound=function(p){return[r,i]=p,r=+r,i=+i,l=!0,h()},t.bandwidth=function(){return o},t.step=function(){return s},t.round=function(p){return arguments.length?(l=!!p,h()):l},t.padding=function(p){return arguments.length?(c=Math.min(1,u=+p),h()):c},t.paddingInner=function(p){return arguments.length?(c=Math.min(1,p),h()):c},t.paddingOuter=function(p){return arguments.length?(u=+p,h()):u},t.align=function(p){return arguments.length?(d=Math.max(0,Math.min(1,p)),h()):d},t.copy=function(){return lL(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},xl.apply(h(),arguments)}function SQ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return SQ(e())},t}function EPe(){return SQ(lL.apply(null,arguments).paddingInner(1))}function cL(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function NQ(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function av(){}var yy=.7,KS=1/yy,Bg="\\s*([+-]?\\d+)\\s*",vy="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",TPe=/^#([0-9a-f]{3,8})$/,APe=new RegExp(`^rgb\\(${Bg},${Bg},${Bg}\\)$`),CPe=new RegExp(`^rgb\\(${xc},${xc},${xc}\\)$`),PPe=new RegExp(`^rgba\\(${Bg},${Bg},${Bg},${vy}\\)$`),jPe=new RegExp(`^rgba\\(${xc},${xc},${xc},${vy}\\)$`),DPe=new RegExp(`^hsl\\(${vy},${xc},${xc}\\)$`),RPe=new RegExp(`^hsla\\(${vy},${xc},${xc},${vy}\\)$`),NV={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};cL(av,wy,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:kV,formatHex:kV,formatHex8:OPe,formatHsl:LPe,formatRgb:MV,toString:MV});function kV(){return this.rgb().formatHex()}function OPe(){return this.rgb().formatHex8()}function LPe(){return kQ(this).formatHsl()}function MV(){return this.rgb().formatRgb()}function wy(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=TPe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?EV(e):n===3?new $s(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?i1(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?i1(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=APe.exec(t))?new $s(e[1],e[2],e[3],1):(e=CPe.exec(t))?new $s(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=PPe.exec(t))?i1(e[1],e[2],e[3],e[4]):(e=jPe.exec(t))?i1(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=DPe.exec(t))?CV(e[1],e[2]/100,e[3]/100,1):(e=RPe.exec(t))?CV(e[1],e[2]/100,e[3]/100,e[4]):NV.hasOwnProperty(t)?EV(NV[t]):t==="transparent"?new $s(NaN,NaN,NaN,0):null}function EV(t){return new $s(t>>16&255,t>>8&255,t&255,1)}function i1(t,e,n,r){return r<=0&&(t=e=n=NaN),new $s(t,e,n,r)}function FPe(t){return t instanceof av||(t=wy(t)),t?(t=t.rgb(),new $s(t.r,t.g,t.b,t.opacity)):new $s}function ND(t,e,n,r){return arguments.length===1?FPe(t):new $s(t,e,n,r??1)}function $s(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}cL($s,ND,NQ(av,{brighter(t){return t=t==null?KS:Math.pow(KS,t),new $s(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?yy:Math.pow(yy,t),new $s(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new $s(im(this.r),im(this.g),im(this.b),XS(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:TV,formatHex:TV,formatHex8:IPe,formatRgb:AV,toString:AV}));function TV(){return`#${Vf(this.r)}${Vf(this.g)}${Vf(this.b)}`}function IPe(){return`#${Vf(this.r)}${Vf(this.g)}${Vf(this.b)}${Vf((isNaN(this.opacity)?1:this.opacity)*255)}`}function AV(){const t=XS(this.opacity);return`${t===1?"rgb(":"rgba("}${im(this.r)}, ${im(this.g)}, ${im(this.b)}${t===1?")":`, ${t})`}`}function XS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function im(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Vf(t){return t=im(t),(t<16?"0":"")+t.toString(16)}function CV(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Ol(t,e,n,r)}function kQ(t){if(t instanceof Ol)return new Ol(t.h,t.s,t.l,t.opacity);if(t instanceof av||(t=wy(t)),!t)return new Ol;if(t instanceof Ol)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=NaN,l=s-i,c=(s+i)/2;return l?(e===s?o=(n-r)/l+(n<r)*6:n===s?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?s+i:2-s-i,o*=60):l=c>0&&c<1?0:o,new Ol(o,l,c,t.opacity)}function zPe(t,e,n,r){return arguments.length===1?kQ(t):new Ol(t,e,n,r??1)}function Ol(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}cL(Ol,zPe,NQ(av,{brighter(t){return t=t==null?KS:Math.pow(KS,t),new Ol(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?yy:Math.pow(yy,t),new Ol(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 $s(KC(t>=240?t-240:t+120,i,r),KC(t,i,r),KC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Ol(PV(this.h),a1(this.s),a1(this.l),XS(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=XS(this.opacity);return`${t===1?"hsl(":"hsla("}${PV(this.h)}, ${a1(this.s)*100}%, ${a1(this.l)*100}%${t===1?")":`, ${t})`}`}}));function PV(t){return t=(t||0)%360,t<0?t+360:t}function a1(t){return Math.max(0,Math.min(1,t||0))}function KC(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 uL=t=>()=>t;function UPe(t,e){return function(n){return t+n*e}}function BPe(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 HPe(t){return(t=+t)==1?MQ:function(e,n){return n-e?BPe(e,n,t):uL(isNaN(e)?n:e)}}function MQ(t,e){var n=e-t;return n?UPe(t,n):uL(isNaN(t)?e:t)}const jV=(function t(e){var n=HPe(e);function r(i,s){var o=n((i=ND(i)).r,(s=ND(s)).r),l=n(i.g,s.g),c=n(i.b,s.b),u=MQ(i.opacity,s.opacity);return function(d){return i.r=o(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function $Pe(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=t[i]*(1-s)+e[i]*s;return r}}function VPe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function GPe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),s=new Array(n),o;for(o=0;o<r;++o)i[o]=Lb(t[o],e[o]);for(;o<n;++o)s[o]=e[o];return function(l){for(o=0;o<r;++o)s[o]=i[o](l);return s}}function qPe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function YS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function WPe(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]=Lb(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var kD=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,XC=new RegExp(kD.source,"g");function KPe(t){return function(){return t}}function XPe(t){return function(e){return t(e)+""}}function YPe(t,e){var n=kD.lastIndex=XC.lastIndex=0,r,i,s,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=kD.exec(t))&&(i=XC.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),l[o]?l[o]+=s:l[++o]=s),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:YS(r,i)})),n=XC.lastIndex;return n<e.length&&(s=e.slice(n),l[o]?l[o]+=s:l[++o]=s),l.length<2?c[0]?XPe(c[0].x):KPe(e):(e=c.length,function(u){for(var d=0,h;d<e;++d)l[(h=c[d]).i]=h.x(u);return l.join("")})}function Lb(t,e){var n=typeof e,r;return e==null||n==="boolean"?uL(e):(n==="number"?YS:n==="string"?(r=wy(e))?(e=r,jV):YPe:e instanceof wy?jV:e instanceof Date?qPe:VPe(e)?$Pe:Array.isArray(e)?GPe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?WPe:YS)(t,e)}function dL(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function QPe(t,e){e===void 0&&(e=t,t=Lb);for(var n=0,r=e.length-1,i=e[0],s=new Array(r<0?0:r);n<r;)s[n]=t(i,i=e[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return s[l](o-l)}}function ZPe(t){return function(){return t}}function QS(t){return+t}var DV=[0,1];function vs(t){return t}function MD(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:ZPe(isNaN(e)?NaN:.5)}function JPe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function eje(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=MD(i,r),s=n(o,s)):(r=MD(r,i),s=n(s,o)),function(l){return s(r(l))}}function tje(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=MD(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(l){var c=iv(t,l,1,r)-1;return s[c](i[c](l))}}function sv(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function hM(){var t=DV,e=DV,n=Lb,r,i,s,o=vs,l,c,u;function d(){var p=Math.min(t.length,e.length);return o!==vs&&(o=JPe(t[0],t[p-1])),l=p>2?tje:eje,c=u=null,h}function h(p){return p==null||isNaN(p=+p)?s:(c||(c=l(t.map(r),e,n)))(r(o(p)))}return h.invert=function(p){return o(i((u||(u=l(e,t.map(r),YS)))(p)))},h.domain=function(p){return arguments.length?(t=Array.from(p,QS),d()):t.slice()},h.range=function(p){return arguments.length?(e=Array.from(p),d()):e.slice()},h.rangeRound=function(p){return e=Array.from(p),n=dL,d()},h.clamp=function(p){return arguments.length?(o=p?!0:vs,d()):o!==vs},h.interpolate=function(p){return arguments.length?(n=p,d()):n},h.unknown=function(p){return arguments.length?(s=p,h):s},function(p,m){return r=p,i=m,d()}}function hL(){return hM()(vs,vs)}function nje(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function ZS(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 db(t){return t=ZS(Math.abs(t)),t?t[1]:NaN}function rje(t,e){return function(n,r){for(var i=n.length,s=[],o=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),s.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[o=(o+1)%t.length];return s.reverse().join(e)}}function ije(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var aje=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function _y(t){if(!(e=aje.exec(t)))throw new Error("invalid format: "+t);var e;return new fL({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]})}_y.prototype=fL.prototype;function fL(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+""}fL.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 sje(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 EQ;function oje(t,e){var n=ZS(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(EQ=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return s===o?r:s>o?r+new Array(s-o+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+ZS(t,Math.max(0,e+s-1))[0]}function RV(t,e){var n=ZS(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 OV={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:nje,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)=>RV(t*100,e),r:RV,s:oje,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function LV(t){return t}var FV=Array.prototype.map,IV=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function lje(t){var e=t.grouping===void 0||t.thousands===void 0?LV:rje(FV.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",s=t.numerals===void 0?LV:ije(FV.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(h){h=_y(h);var p=h.fill,m=h.align,b=h.sign,y=h.symbol,x=h.zero,v=h.width,S=h.comma,N=h.precision,T=h.trim,M=h.type;M==="n"?(S=!0,M="g"):OV[M]||(N===void 0&&(N=12),T=!0,M="g"),(x||p==="0"&&m==="=")&&(x=!0,p="0",m="=");var A=y==="$"?n:y==="#"&&/[boxX]/.test(M)?"0"+M.toLowerCase():"",k=y==="$"?r:/[%p]/.test(M)?o:"",R=OV[M],C=/[defgprs%]/.test(M);N=N===void 0?6:/[gprs]/.test(M)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function P(U){var F=A,B=k,D,$,G;if(M==="c")B=R(U)+B,U="";else{U=+U;var I=U<0||1/U<0;if(U=isNaN(U)?c:R(Math.abs(U),N),T&&(U=sje(U)),I&&+U==0&&b!=="+"&&(I=!1),F=(I?b==="("?b:l:b==="-"||b==="("?"":b)+F,B=(M==="s"?IV[8+EQ/3]:"")+B+(I&&b==="("?")":""),C){for(D=-1,$=U.length;++D<$;)if(G=U.charCodeAt(D),48>G||G>57){B=(G===46?i+U.slice(D+1):U.slice(D))+B,U=U.slice(0,D);break}}}S&&!x&&(U=e(U,1/0));var K=F.length+U.length+B.length,Q=K<v?new Array(v-K+1).join(p):"";switch(S&&x&&(U=e(Q+U,Q.length?v-B.length:1/0),Q=""),m){case"<":U=F+U+B+Q;break;case"=":U=F+Q+U+B;break;case"^":U=Q.slice(0,K=Q.length>>1)+F+U+B+Q.slice(K);break;default:U=Q+F+U+B;break}return s(U)}return P.toString=function(){return h+""},P}function d(h,p){var m=u((h=_y(h),h.type="f",h)),b=Math.max(-8,Math.min(8,Math.floor(db(p)/3)))*3,y=Math.pow(10,-b),x=IV[8+b/3];return function(v){return m(y*v)+x}}return{format:u,formatPrefix:d}}var s1,mL,TQ;cje({thousands:",",grouping:[3],currency:["$",""]});function cje(t){return s1=lje(t),mL=s1.format,TQ=s1.formatPrefix,s1}function uje(t){return Math.max(0,-db(Math.abs(t)))}function dje(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(db(e)/3)))*3-db(Math.abs(t)))}function hje(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,db(e)-db(t))+1}function AQ(t,e,n,r){var i=_D(t,e,n),s;switch(r=_y(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=dje(i,o))&&(r.precision=s),TQ(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=hje(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=uje(i))&&(r.precision=s-(r.type==="%")*2);break}}return mL(r)}function Vh(t){var e=t.domain;return t.ticks=function(n){var r=e();return vD(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return AQ(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,s=r.length-1,o=r[i],l=r[s],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=s,s=u);d-- >0;){if(u=wD(o,l,n),u===c)return r[i]=o,r[s]=l,e(r);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function CQ(){var t=hL();return t.copy=function(){return sv(t,CQ())},xl.apply(t,arguments),Vh(t)}function PQ(t){var e;function n(r){return r==null||isNaN(r=+r)?e:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(t=Array.from(r,QS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return PQ(t).unknown(e)},t=arguments.length?Array.from(t,QS):[0,1],Vh(n)}function jQ(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],o;return s<i&&(o=n,n=r,r=o,o=i,i=s,s=o),t[n]=e.floor(i),t[r]=e.ceil(s),t}function zV(t){return Math.log(t)}function UV(t){return Math.exp(t)}function fje(t){return-Math.log(-t)}function mje(t){return-Math.exp(-t)}function pje(t){return isFinite(t)?+("1e"+t):t<0?0:t}function gje(t){return t===10?pje:t===Math.E?Math.exp:e=>Math.pow(t,e)}function bje(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 BV(t){return(e,n)=>-t(-e,n)}function pL(t){const e=t(zV,UV),n=e.domain;let r=10,i,s;function o(){return i=bje(r),s=gje(r),n()[0]<0?(i=BV(i),s=BV(s),t(fje,mje)):t(zV,UV),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 h=d<u;h&&([u,d]=[d,u]);let p=i(u),m=i(d),b,y;const x=l==null?10:+l;let v=[];if(!(r%1)&&m-p<x){if(p=Math.floor(p),m=Math.ceil(m),u>0){for(;p<=m;++p)for(b=1;b<r;++b)if(y=p<0?b/s(-p):b*s(p),!(y<u)){if(y>d)break;v.push(y)}}else for(;p<=m;++p)for(b=r-1;b>=1;--b)if(y=p>0?b/s(-p):b*s(p),!(y<u)){if(y>d)break;v.push(y)}v.length*2<x&&(v=vD(u,d,x))}else v=vD(p,m,Math.min(m-p,x)).map(s);return h?v.reverse():v},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=_y(c)).precision==null&&(c.trim=!0),c=mL(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let h=d/s(Math.round(i(d)));return h*r<r-.5&&(h*=r),h<=u?c(d):""}},e.nice=()=>n(jQ(n(),{floor:l=>s(Math.floor(i(l))),ceil:l=>s(Math.ceil(i(l)))})),e}function DQ(){const t=pL(hM()).domain([1,10]);return t.copy=()=>sv(t,DQ()).base(t.base()),xl.apply(t,arguments),t}function HV(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function $V(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function gL(t){var e=1,n=t(HV(e),$V(e));return n.constant=function(r){return arguments.length?t(HV(e=+r),$V(e)):e},Vh(n)}function RQ(){var t=gL(hM());return t.copy=function(){return sv(t,RQ()).constant(t.constant())},xl.apply(t,arguments)}function VV(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function xje(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function yje(t){return t<0?-t*t:t*t}function bL(t){var e=t(vs,vs),n=1;function r(){return n===1?t(vs,vs):n===.5?t(xje,yje):t(VV(n),VV(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Vh(e)}function xL(){var t=bL(hM());return t.copy=function(){return sv(t,xL()).exponent(t.exponent())},xl.apply(t,arguments),t}function vje(){return xL.apply(null,arguments).exponent(.5)}function GV(t){return Math.sign(t)*t*t}function wje(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function OQ(){var t=hL(),e=[0,1],n=!1,r;function i(s){var o=wje(t(s));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(s){return t.invert(GV(s))},i.domain=function(s){return arguments.length?(t.domain(s),i):t.domain()},i.range=function(s){return arguments.length?(t.range((e=Array.from(s,QS)).map(GV)),i):e.slice()},i.rangeRound=function(s){return i.range(s).round(!0)},i.round=function(s){return arguments.length?(n=!!s,i):n},i.clamp=function(s){return arguments.length?(t.clamp(s),i):t.clamp()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return OQ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},xl.apply(i,arguments),Vh(i)}function LQ(){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]=kPe(t,o/l);return s}function s(o){return o==null||isNaN(o=+o)?r:e[iv(n,o)]}return s.invertExtent=function(o){var l=e.indexOf(o);return l<0?[NaN,NaN]:[l>0?n[l-1]:t[0],l<n.length?n[l]:t[t.length-1]]},s.domain=function(o){if(!arguments.length)return t.slice();t=[];for(let l of o)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(Sh),i()},s.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},s.unknown=function(o){return arguments.length?(r=o,s):r},s.quantiles=function(){return n.slice()},s.copy=function(){return LQ().domain(t).range(e).unknown(r)},xl.apply(s,arguments)}function FQ(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function o(c){return c!=null&&c<=c?i[iv(r,c,0,n)]:s}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return o}return o.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,l()):[t,e]},o.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,l()):i.slice()},o.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},o.unknown=function(c){return arguments.length&&(s=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return FQ().domain([t,e]).range(i).unknown(s)},xl.apply(Vh(o),arguments)}function IQ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[iv(t,s,0,r)]:n}return i.domain=function(s){return arguments.length?(t=Array.from(s),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(s){return arguments.length?(e=Array.from(s),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(s){var o=e.indexOf(s);return[t[o-1],t[o]]},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return IQ().domain(t).range(e).unknown(n)},xl.apply(i,arguments)}const YC=new Date,QC=new Date;function oa(t,e,n,r){function i(s){return t(s=arguments.length===0?new Date:new Date(+s)),s}return i.floor=s=>(t(s=new Date(+s)),s),i.ceil=s=>(t(s=new Date(s-1)),e(s,1),t(s),s),i.round=s=>{const o=i(s),l=i.ceil(s);return s-o<l-s?o:l},i.offset=(s,o)=>(e(s=new Date(+s),o==null?1:Math.floor(o)),s),i.range=(s,o,l)=>{const c=[];if(s=i.ceil(s),l=l==null?1:Math.floor(l),!(s<o)||!(l>0))return c;let u;do c.push(u=new Date(+s)),e(s,l),t(s);while(u<s&&s<o);return c},i.filter=s=>oa(o=>{if(o>=o)for(;t(o),!s(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!s(o););else for(;--l>=0;)for(;e(o,1),!s(o););}),n&&(i.count=(s,o)=>(YC.setTime(+s),QC.setTime(+o),t(YC),t(QC),Math.floor(n(YC,QC))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(r?o=>r(o)%s===0:o=>i.count(0,o)%s===0):i)),i}const JS=oa(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);JS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?oa(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):JS);JS.range;const Tu=1e3,al=Tu*60,Au=al*60,Qu=Au*24,yL=Qu*7,qV=Qu*30,ZC=Qu*365,Gf=oa(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Tu)},(t,e)=>(e-t)/Tu,t=>t.getUTCSeconds());Gf.range;const vL=oa(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Tu)},(t,e)=>{t.setTime(+t+e*al)},(t,e)=>(e-t)/al,t=>t.getMinutes());vL.range;const wL=oa(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*al)},(t,e)=>(e-t)/al,t=>t.getUTCMinutes());wL.range;const _L=oa(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Tu-t.getMinutes()*al)},(t,e)=>{t.setTime(+t+e*Au)},(t,e)=>(e-t)/Au,t=>t.getHours());_L.range;const SL=oa(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Au)},(t,e)=>(e-t)/Au,t=>t.getUTCHours());SL.range;const ov=oa(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*al)/Qu,t=>t.getDate()-1);ov.range;const fM=oa(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Qu,t=>t.getUTCDate()-1);fM.range;const zQ=oa(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Qu,t=>Math.floor(t/Qu));zQ.range;function Bm(t){return oa(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())*al)/yL)}const mM=Bm(0),eN=Bm(1),_je=Bm(2),Sje=Bm(3),hb=Bm(4),Nje=Bm(5),kje=Bm(6);mM.range;eN.range;_je.range;Sje.range;hb.range;Nje.range;kje.range;function Hm(t){return oa(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)/yL)}const pM=Hm(0),tN=Hm(1),Mje=Hm(2),Eje=Hm(3),fb=Hm(4),Tje=Hm(5),Aje=Hm(6);pM.range;tN.range;Mje.range;Eje.range;fb.range;Tje.range;Aje.range;const NL=oa(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());NL.range;const kL=oa(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());kL.range;const Zu=oa(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Zu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:oa(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});Zu.range;const Ju=oa(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());Ju.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:oa(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)});Ju.range;function UQ(t,e,n,r,i,s){const o=[[Gf,1,Tu],[Gf,5,5*Tu],[Gf,15,15*Tu],[Gf,30,30*Tu],[s,1,al],[s,5,5*al],[s,15,15*al],[s,30,30*al],[i,1,Au],[i,3,3*Au],[i,6,6*Au],[i,12,12*Au],[r,1,Qu],[r,2,2*Qu],[n,1,yL],[e,1,qV],[e,3,3*qV],[t,1,ZC]];function l(u,d,h){const p=d<u;p&&([u,d]=[d,u]);const m=h&&typeof h.range=="function"?h:c(u,d,h),b=m?m.range(u,+d+1):[];return p?b.reverse():b}function c(u,d,h){const p=Math.abs(d-u)/h,m=sL(([,,x])=>x).right(o,p);if(m===o.length)return t.every(_D(u/ZC,d/ZC,h));if(m===0)return JS.every(Math.max(_D(u,d,h),1));const[b,y]=o[p/o[m-1][2]<o[m][2]/p?m-1:m];return b.every(y)}return[l,c]}const[Cje,Pje]=UQ(Ju,kL,pM,zQ,SL,wL),[jje,Dje]=UQ(Zu,NL,mM,ov,_L,vL);function JC(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 eP(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 t0(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function Rje(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=n0(i),d=r0(i),h=n0(s),p=r0(s),m=n0(o),b=r0(o),y=n0(l),x=r0(l),v=n0(c),S=r0(c),N={a:I,A:K,b:Q,B:se,c:null,d:ZV,e:ZV,f:r3e,g:f3e,G:p3e,H:e3e,I:t3e,j:n3e,L:BQ,m:i3e,M:a3e,p:H,q:W,Q:tG,s:nG,S:s3e,u:o3e,U:l3e,V:c3e,w:u3e,W:d3e,x:null,X:null,y:h3e,Y:m3e,Z:g3e,"%":eG},T={a:J,A:ne,b:xe,B:ue,c:null,d:JV,e:JV,f:v3e,g:C3e,G:j3e,H:b3e,I:x3e,j:y3e,L:$Q,m:w3e,M:_3e,p:fe,q:De,Q:tG,s:nG,S:S3e,u:N3e,U:k3e,V:M3e,w:E3e,W:T3e,x:null,X:null,y:A3e,Y:P3e,Z:D3e,"%":eG},M={a:P,A:U,b:F,B,c:D,d:YV,e:YV,f:Yje,g:XV,G:KV,H:QV,I:QV,j:qje,L:Xje,m:Gje,M:Wje,p:C,q:Vje,Q:Zje,s:Jje,S:Kje,u:zje,U:Uje,V:Bje,w:Ije,W:Hje,x:$,X:G,y:XV,Y:KV,Z:$je,"%":Qje};N.x=A(n,N),N.X=A(r,N),N.c=A(e,N),T.x=A(n,T),T.X=A(r,T),T.c=A(e,T);function A(oe,Ne){return function(Fe){var ce=[],Ve=-1,V=0,Y=oe.length,de,q,re;for(Fe instanceof Date||(Fe=new Date(+Fe));++Ve<Y;)oe.charCodeAt(Ve)===37&&(ce.push(oe.slice(V,Ve)),(q=WV[de=oe.charAt(++Ve)])!=null?de=oe.charAt(++Ve):q=de==="e"?" ":"0",(re=Ne[de])&&(de=re(Fe,q)),ce.push(de),V=Ve+1);return ce.push(oe.slice(V,Ve)),ce.join("")}}function k(oe,Ne){return function(Fe){var ce=t0(1900,void 0,1),Ve=R(ce,oe,Fe+="",0),V,Y;if(Ve!=Fe.length)return null;if("Q"in ce)return new Date(ce.Q);if("s"in ce)return new Date(ce.s*1e3+("L"in ce?ce.L:0));if(Ne&&!("Z"in ce)&&(ce.Z=0),"p"in ce&&(ce.H=ce.H%12+ce.p*12),ce.m===void 0&&(ce.m="q"in ce?ce.q:0),"V"in ce){if(ce.V<1||ce.V>53)return null;"w"in ce||(ce.w=1),"Z"in ce?(V=eP(t0(ce.y,0,1)),Y=V.getUTCDay(),V=Y>4||Y===0?tN.ceil(V):tN(V),V=fM.offset(V,(ce.V-1)*7),ce.y=V.getUTCFullYear(),ce.m=V.getUTCMonth(),ce.d=V.getUTCDate()+(ce.w+6)%7):(V=JC(t0(ce.y,0,1)),Y=V.getDay(),V=Y>4||Y===0?eN.ceil(V):eN(V),V=ov.offset(V,(ce.V-1)*7),ce.y=V.getFullYear(),ce.m=V.getMonth(),ce.d=V.getDate()+(ce.w+6)%7)}else("W"in ce||"U"in ce)&&("w"in ce||(ce.w="u"in ce?ce.u%7:"W"in ce?1:0),Y="Z"in ce?eP(t0(ce.y,0,1)).getUTCDay():JC(t0(ce.y,0,1)).getDay(),ce.m=0,ce.d="W"in ce?(ce.w+6)%7+ce.W*7-(Y+5)%7:ce.w+ce.U*7-(Y+6)%7);return"Z"in ce?(ce.H+=ce.Z/100|0,ce.M+=ce.Z%100,eP(ce)):JC(ce)}}function R(oe,Ne,Fe,ce){for(var Ve=0,V=Ne.length,Y=Fe.length,de,q;Ve<V;){if(ce>=Y)return-1;if(de=Ne.charCodeAt(Ve++),de===37){if(de=Ne.charAt(Ve++),q=M[de in WV?Ne.charAt(Ve++):de],!q||(ce=q(oe,Fe,ce))<0)return-1}else if(de!=Fe.charCodeAt(ce++))return-1}return ce}function C(oe,Ne,Fe){var ce=u.exec(Ne.slice(Fe));return ce?(oe.p=d.get(ce[0].toLowerCase()),Fe+ce[0].length):-1}function P(oe,Ne,Fe){var ce=m.exec(Ne.slice(Fe));return ce?(oe.w=b.get(ce[0].toLowerCase()),Fe+ce[0].length):-1}function U(oe,Ne,Fe){var ce=h.exec(Ne.slice(Fe));return ce?(oe.w=p.get(ce[0].toLowerCase()),Fe+ce[0].length):-1}function F(oe,Ne,Fe){var ce=v.exec(Ne.slice(Fe));return ce?(oe.m=S.get(ce[0].toLowerCase()),Fe+ce[0].length):-1}function B(oe,Ne,Fe){var ce=y.exec(Ne.slice(Fe));return ce?(oe.m=x.get(ce[0].toLowerCase()),Fe+ce[0].length):-1}function D(oe,Ne,Fe){return R(oe,e,Ne,Fe)}function $(oe,Ne,Fe){return R(oe,n,Ne,Fe)}function G(oe,Ne,Fe){return R(oe,r,Ne,Fe)}function I(oe){return o[oe.getDay()]}function K(oe){return s[oe.getDay()]}function Q(oe){return c[oe.getMonth()]}function se(oe){return l[oe.getMonth()]}function H(oe){return i[+(oe.getHours()>=12)]}function W(oe){return 1+~~(oe.getMonth()/3)}function J(oe){return o[oe.getUTCDay()]}function ne(oe){return s[oe.getUTCDay()]}function xe(oe){return c[oe.getUTCMonth()]}function ue(oe){return l[oe.getUTCMonth()]}function fe(oe){return i[+(oe.getUTCHours()>=12)]}function De(oe){return 1+~~(oe.getUTCMonth()/3)}return{format:function(oe){var Ne=A(oe+="",N);return Ne.toString=function(){return oe},Ne},parse:function(oe){var Ne=k(oe+="",!1);return Ne.toString=function(){return oe},Ne},utcFormat:function(oe){var Ne=A(oe+="",T);return Ne.toString=function(){return oe},Ne},utcParse:function(oe){var Ne=k(oe+="",!0);return Ne.toString=function(){return oe},Ne}}}var WV={"-":"",_:" ",0:"0"},ka=/^\s*\d+/,Oje=/^%/,Lje=/[\\^$*+?|[\]().{}]/g;function cr(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function Fje(t){return t.replace(Lje,"\\$&")}function n0(t){return new RegExp("^(?:"+t.map(Fje).join("|")+")","i")}function r0(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Ije(t,e,n){var r=ka.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function zje(t,e,n){var r=ka.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Uje(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Bje(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Hje(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function KV(t,e,n){var r=ka.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function XV(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function $je(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 Vje(t,e,n){var r=ka.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Gje(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function YV(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function qje(t,e,n){var r=ka.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function QV(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Wje(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Kje(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Xje(t,e,n){var r=ka.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Yje(t,e,n){var r=ka.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Qje(t,e,n){var r=Oje.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Zje(t,e,n){var r=ka.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Jje(t,e,n){var r=ka.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function ZV(t,e){return cr(t.getDate(),e,2)}function e3e(t,e){return cr(t.getHours(),e,2)}function t3e(t,e){return cr(t.getHours()%12||12,e,2)}function n3e(t,e){return cr(1+ov.count(Zu(t),t),e,3)}function BQ(t,e){return cr(t.getMilliseconds(),e,3)}function r3e(t,e){return BQ(t,e)+"000"}function i3e(t,e){return cr(t.getMonth()+1,e,2)}function a3e(t,e){return cr(t.getMinutes(),e,2)}function s3e(t,e){return cr(t.getSeconds(),e,2)}function o3e(t){var e=t.getDay();return e===0?7:e}function l3e(t,e){return cr(mM.count(Zu(t)-1,t),e,2)}function HQ(t){var e=t.getDay();return e>=4||e===0?hb(t):hb.ceil(t)}function c3e(t,e){return t=HQ(t),cr(hb.count(Zu(t),t)+(Zu(t).getDay()===4),e,2)}function u3e(t){return t.getDay()}function d3e(t,e){return cr(eN.count(Zu(t)-1,t),e,2)}function h3e(t,e){return cr(t.getFullYear()%100,e,2)}function f3e(t,e){return t=HQ(t),cr(t.getFullYear()%100,e,2)}function m3e(t,e){return cr(t.getFullYear()%1e4,e,4)}function p3e(t,e){var n=t.getDay();return t=n>=4||n===0?hb(t):hb.ceil(t),cr(t.getFullYear()%1e4,e,4)}function g3e(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+cr(e/60|0,"0",2)+cr(e%60,"0",2)}function JV(t,e){return cr(t.getUTCDate(),e,2)}function b3e(t,e){return cr(t.getUTCHours(),e,2)}function x3e(t,e){return cr(t.getUTCHours()%12||12,e,2)}function y3e(t,e){return cr(1+fM.count(Ju(t),t),e,3)}function $Q(t,e){return cr(t.getUTCMilliseconds(),e,3)}function v3e(t,e){return $Q(t,e)+"000"}function w3e(t,e){return cr(t.getUTCMonth()+1,e,2)}function _3e(t,e){return cr(t.getUTCMinutes(),e,2)}function S3e(t,e){return cr(t.getUTCSeconds(),e,2)}function N3e(t){var e=t.getUTCDay();return e===0?7:e}function k3e(t,e){return cr(pM.count(Ju(t)-1,t),e,2)}function VQ(t){var e=t.getUTCDay();return e>=4||e===0?fb(t):fb.ceil(t)}function M3e(t,e){return t=VQ(t),cr(fb.count(Ju(t),t)+(Ju(t).getUTCDay()===4),e,2)}function E3e(t){return t.getUTCDay()}function T3e(t,e){return cr(tN.count(Ju(t)-1,t),e,2)}function A3e(t,e){return cr(t.getUTCFullYear()%100,e,2)}function C3e(t,e){return t=VQ(t),cr(t.getUTCFullYear()%100,e,2)}function P3e(t,e){return cr(t.getUTCFullYear()%1e4,e,4)}function j3e(t,e){var n=t.getUTCDay();return t=n>=4||n===0?fb(t):fb.ceil(t),cr(t.getUTCFullYear()%1e4,e,4)}function D3e(){return"+0000"}function eG(){return"%"}function tG(t){return+t}function nG(t){return Math.floor(+t/1e3)}var ig,GQ,qQ;R3e({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 R3e(t){return ig=Rje(t),GQ=ig.format,ig.parse,qQ=ig.utcFormat,ig.utcParse,ig}function O3e(t){return new Date(t)}function L3e(t){return t instanceof Date?+t:+new Date(+t)}function ML(t,e,n,r,i,s,o,l,c,u){var d=hL(),h=d.invert,p=d.domain,m=u(".%L"),b=u(":%S"),y=u("%I:%M"),x=u("%I %p"),v=u("%a %d"),S=u("%b %d"),N=u("%B"),T=u("%Y");function M(A){return(c(A)<A?m:l(A)<A?b:o(A)<A?y:s(A)<A?x:r(A)<A?i(A)<A?v:S:n(A)<A?N:T)(A)}return d.invert=function(A){return new Date(h(A))},d.domain=function(A){return arguments.length?p(Array.from(A,L3e)):p().map(O3e)},d.ticks=function(A){var k=p();return t(k[0],k[k.length-1],A??10)},d.tickFormat=function(A,k){return k==null?M:u(k)},d.nice=function(A){var k=p();return(!A||typeof A.range!="function")&&(A=e(k[0],k[k.length-1],A??10)),A?p(jQ(k,A)):d},d.copy=function(){return sv(d,ML(t,e,n,r,i,s,o,l,c,u))},d}function F3e(){return xl.apply(ML(jje,Dje,Zu,NL,mM,ov,_L,vL,Gf,GQ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function I3e(){return xl.apply(ML(Cje,Pje,Ju,kL,pM,fM,SL,wL,Gf,qQ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function gM(){var t=0,e=1,n,r,i,s,o=vs,l=!1,c;function u(h){return h==null||isNaN(h=+h)?c:o(i===0?.5:(h=(s(h)-n)*i,l?Math.max(0,Math.min(1,h)):h))}u.domain=function(h){return arguments.length?([t,e]=h,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(h){return arguments.length?(l=!!h,u):l},u.interpolator=function(h){return arguments.length?(o=h,u):o};function d(h){return function(p){var m,b;return arguments.length?([m,b]=p,o=h(m,b),u):[o(0),o(1)]}}return u.range=d(Lb),u.rangeRound=d(dL),u.unknown=function(h){return arguments.length?(c=h,u):c},function(h){return s=h,n=h(t),r=h(e),i=n===r?0:1/(r-n),u}}function Gh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function WQ(){var t=Vh(gM()(vs));return t.copy=function(){return Gh(t,WQ())},ad.apply(t,arguments)}function KQ(){var t=pL(gM()).domain([1,10]);return t.copy=function(){return Gh(t,KQ()).base(t.base())},ad.apply(t,arguments)}function XQ(){var t=gL(gM());return t.copy=function(){return Gh(t,XQ()).constant(t.constant())},ad.apply(t,arguments)}function EL(){var t=bL(gM());return t.copy=function(){return Gh(t,EL()).exponent(t.exponent())},ad.apply(t,arguments)}function z3e(){return EL.apply(null,arguments).exponent(.5)}function YQ(){var t=[],e=vs;function n(r){if(r!=null&&!isNaN(r=+r))return e((iv(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(Sh),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,s)=>NPe(t,s/r))},n.copy=function(){return YQ(e).domain(t)},ad.apply(n,arguments)}function bM(){var t=0,e=.5,n=1,r=1,i,s,o,l,c,u=vs,d,h=!1,p;function m(y){return isNaN(y=+y)?p:(y=.5+((y=+d(y))-s)*(r*y<r*s?l:c),u(h?Math.max(0,Math.min(1,y)):y))}m.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),s=d(e=+e),o=d(n=+n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,m):[t,e,n]},m.clamp=function(y){return arguments.length?(h=!!y,m):h},m.interpolator=function(y){return arguments.length?(u=y,m):u};function b(y){return function(x){var v,S,N;return arguments.length?([v,S,N]=x,u=QPe(y,[v,S,N]),m):[u(0),u(.5),u(1)]}}return m.range=b(Lb),m.rangeRound=b(dL),m.unknown=function(y){return arguments.length?(p=y,m):p},function(y){return d=y,i=y(t),s=y(e),o=y(n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,m}}function QQ(){var t=Vh(bM()(vs));return t.copy=function(){return Gh(t,QQ())},ad.apply(t,arguments)}function ZQ(){var t=pL(bM()).domain([.1,1,10]);return t.copy=function(){return Gh(t,ZQ()).base(t.base())},ad.apply(t,arguments)}function JQ(){var t=gL(bM());return t.copy=function(){return Gh(t,JQ()).constant(t.constant())},ad.apply(t,arguments)}function TL(){var t=bL(bM());return t.copy=function(){return Gh(t,TL()).exponent(t.exponent())},ad.apply(t,arguments)}function U3e(){return TL.apply(null,arguments).exponent(.5)}const m0=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:lL,scaleDiverging:QQ,scaleDivergingLog:ZQ,scaleDivergingPow:TL,scaleDivergingSqrt:U3e,scaleDivergingSymlog:JQ,scaleIdentity:PQ,scaleImplicit:SD,scaleLinear:CQ,scaleLog:DQ,scaleOrdinal:oL,scalePoint:EPe,scalePow:xL,scaleQuantile:LQ,scaleQuantize:FQ,scaleRadial:OQ,scaleSequential:WQ,scaleSequentialLog:KQ,scaleSequentialPow:EL,scaleSequentialQuantile:YQ,scaleSequentialSqrt:z3e,scaleSequentialSymlog:XQ,scaleSqrt:vje,scaleSymlog:RQ,scaleThreshold:IQ,scaleTime:F3e,scaleUtc:I3e,tickFormat:AQ},Symbol.toStringTag,{value:"Module"}));var qh=t=>t.chartData,AL=st([qh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),lv=(t,e,n,r)=>r?AL(t):qh(t);function Fh(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(_r(e)&&_r(n))return!0}return!1}function rG(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function eZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(_r(n))i=n;else if(typeof n=="function")return;if(_r(r))s=r;else if(typeof r=="function")return;var o=[i,s];if(Fh(o))return o}}function B3e(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Fh(r))return rG(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,s]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(Ht(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&P$.test(i)){var c=P$.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(s==="auto")e!=null&&(l=Math.max(...e));else if(Ht(s))l=s;else if(typeof s=="function")try{e!=null&&(l=s(e?.[1]))}catch{}else if(typeof s=="string"&&j$.test(s)){var d=j$.exec(s);if(d==null||e==null)l=void 0;else{var h=+d[1];l=e[1]+h}}else l=e?.[1];var p=[o,l];if(Fh(p))return e==null?p:rG(p,e,n)}}}var Fb=1e9,H3e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},PL,ii=!0,pl="[DecimalError] ",am=pl+"Invalid argument: ",CL=pl+"Exponent out of range: ",Ib=Math.floor,Rf=Math.pow,$3e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,bo,xa=1e7,Yr=7,tZ=9007199254740991,nN=Ib(tZ/Yr),$t={};$t.absoluteValue=$t.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};$t.comparedTo=$t.cmp=function(t){var e,n,r,i,s=this;if(t=new s.constructor(t),s.s!==t.s)return s.s||-t.s;if(s.e!==t.e)return s.e>t.e^s.s<0?1:-1;for(r=s.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(s.d[e]!==t.d[e])return s.d[e]>t.d[e]^s.s<0?1:-1;return r===i?0:r>i^s.s<0?1:-1};$t.decimalPlaces=$t.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Yr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};$t.dividedBy=$t.div=function(t){return Lu(this,new this.constructor(t))};$t.dividedToIntegerBy=$t.idiv=function(t){var e=this,n=e.constructor;return Ur(Lu(e,new n(t),0,1),n.precision)};$t.equals=$t.eq=function(t){return!this.cmp(t)};$t.exponent=function(){return qi(this)};$t.greaterThan=$t.gt=function(t){return this.cmp(t)>0};$t.greaterThanOrEqualTo=$t.gte=function(t){return this.cmp(t)>=0};$t.isInteger=$t.isint=function(){return this.e>this.d.length-2};$t.isNegative=$t.isneg=function(){return this.s<0};$t.isPositive=$t.ispos=function(){return this.s>0};$t.isZero=function(){return this.s===0};$t.lessThan=$t.lt=function(t){return this.cmp(t)<0};$t.lessThanOrEqualTo=$t.lte=function(t){return this.cmp(t)<1};$t.logarithm=$t.log=function(t){var e,n=this,r=n.constructor,i=r.precision,s=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(bo))throw Error(pl+"NaN");if(n.s<1)throw Error(pl+(n.s?"NaN":"-Infinity"));return n.eq(bo)?new r(0):(ii=!1,e=Lu(Sy(n,s),Sy(t,s),s),ii=!0,Ur(e,i))};$t.minus=$t.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?iZ(e,t):nZ(e,(t.s=-t.s,t))};$t.modulo=$t.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(pl+"NaN");return n.s?(ii=!1,e=Lu(n,t,0,1).times(t),ii=!0,n.minus(e)):Ur(new r(n),i)};$t.naturalExponential=$t.exp=function(){return rZ(this)};$t.naturalLogarithm=$t.ln=function(){return Sy(this)};$t.negated=$t.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};$t.plus=$t.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?nZ(e,t):iZ(e,(t.s=-t.s,t))};$t.precision=$t.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(am+t);if(e=qi(i)+1,r=i.d.length-1,n=r*Yr+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};$t.squareRoot=$t.sqrt=function(){var t,e,n,r,i,s,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(pl+"NaN")}for(t=qi(l),ii=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=mc(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Ib((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(s=r,r=s.plus(Lu(l,s,o+2)).times(.5),mc(s.d).slice(0,o)===(e=mc(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Ur(s,n+1,0),s.times(s).eq(l)){r=s;break}}else if(e!="9999")break;o+=4}return ii=!0,Ur(r,n)};$t.times=$t.mul=function(t){var e,n,r,i,s,o,l,c,u,d=this,h=d.constructor,p=d.d,m=(t=new h(t)).d;if(!d.s||!t.s)return new h(0);for(t.s*=d.s,n=d.e+t.e,c=p.length,u=m.length,c<u&&(s=p,p=m,m=s,o=c,c=u,u=o),s=[],o=c+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=s[i]+m[r]*p[i-r-1]+e,s[i--]=l%xa|0,e=l/xa|0;s[i]=(s[i]+e)%xa|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,ii?Ur(t,h.precision):t};$t.toDecimalPlaces=$t.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Nc(t,0,Fb),e===void 0?e=r.rounding:Nc(e,0,8),Ur(n,t+qi(n)+1,e))};$t.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Tm(r,!0):(Nc(t,0,Fb),e===void 0?e=i.rounding:Nc(e,0,8),r=Ur(new i(r),t+1,e),n=Tm(r,!0,t+1)),n};$t.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Tm(i):(Nc(t,0,Fb),e===void 0?e=s.rounding:Nc(e,0,8),r=Ur(new s(i),t+qi(i)+1,e),n=Tm(r.abs(),!1,t+qi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};$t.toInteger=$t.toint=function(){var t=this,e=t.constructor;return Ur(new e(t),qi(t)+1,e.rounding)};$t.toNumber=function(){return+this};$t.toPower=$t.pow=function(t){var e,n,r,i,s,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(bo);if(l=new c(l),!l.s){if(t.s<1)throw Error(pl+"Infinity");return l}if(l.eq(bo))return l;if(r=c.precision,t.eq(bo))return Ur(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,s=l.s,o){if((n=d<0?-d:d)<=tZ){for(i=new c(bo),e=Math.ceil(r/Yr+4),ii=!1;n%2&&(i=i.times(l),aG(i.d,e)),n=Ib(n/2),n!==0;)l=l.times(l),aG(l.d,e);return ii=!0,t.s<0?new c(bo).div(i):Ur(i,r)}}else if(s<0)throw Error(pl+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,ii=!1,i=t.times(Sy(l,r+u)),ii=!0,i=rZ(i),i.s=s,i};$t.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=qi(i),r=Tm(i,n<=s.toExpNeg||n>=s.toExpPos)):(Nc(t,1,Fb),e===void 0?e=s.rounding:Nc(e,0,8),i=Ur(new s(i),t,e),n=qi(i),r=Tm(i,t<=n||n<=s.toExpNeg,t)),r};$t.toSignificantDigits=$t.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Nc(t,1,Fb),e===void 0?e=r.rounding:Nc(e,0,8)),Ur(new r(n),t,e)};$t.toString=$t.valueOf=$t.val=$t.toJSON=$t[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=qi(t),n=t.constructor;return Tm(t,e<=n.toExpNeg||e>=n.toExpPos)};function nZ(t,e){var n,r,i,s,o,l,c,u,d=t.constructor,h=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),ii?Ur(e,h):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),s=o-i,s){for(s<0?(r=c,s=-s,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(h/Yr),l=o>l?o+1:l+1,s>l&&(s=l,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for(l=c.length,s=u.length,l-s<0&&(s=l,r=u,u=c,c=r),n=0;s;)n=(c[--s]=c[s]+u[s]+n)/xa|0,c[s]%=xa;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,ii?Ur(e,h):e}function Nc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(am+t)}function mc(t){var e,n,r,i=t.length-1,s="",o=t[0];if(i>0){for(s+=o,e=1;e<i;e++)r=t[e]+"",n=Yr-r.length,n&&(s+=Qd(n)),s+=r;o=t[e],r=o+"",n=Yr-r.length,n&&(s+=Qd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}var Lu=(function(){function t(r,i){var s,o=0,l=r.length;for(r=r.slice();l--;)s=r[l]*i+o,r[l]=s%xa|0,o=s/xa|0;return o&&r.unshift(o),r}function e(r,i,s,o){var l,c;if(s!=o)c=s>o?1:-1;else for(l=c=0;l<s;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,s){for(var o=0;s--;)r[s]-=o,o=r[s]<i[s]?1:0,r[s]=o*xa+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o){var l,c,u,d,h,p,m,b,y,x,v,S,N,T,M,A,k,R,C=r.constructor,P=r.s==i.s?1:-1,U=r.d,F=i.d;if(!r.s)return new C(r);if(!i.s)throw Error(pl+"Division by zero");for(c=r.e-i.e,k=F.length,M=U.length,m=new C(P),b=m.d=[],u=0;F[u]==(U[u]||0);)++u;if(F[u]>(U[u]||0)&&--c,s==null?S=s=C.precision:o?S=s+(qi(r)-qi(i))+1:S=s,S<0)return new C(0);if(S=S/Yr+2|0,u=0,k==1)for(d=0,F=F[0],S++;(u<M||d)&&S--;u++)N=d*xa+(U[u]||0),b[u]=N/F|0,d=N%F|0;else{for(d=xa/(F[0]+1)|0,d>1&&(F=t(F,d),U=t(U,d),k=F.length,M=U.length),T=k,y=U.slice(0,k),x=y.length;x<k;)y[x++]=0;R=F.slice(),R.unshift(0),A=F[0],F[1]>=xa/2&&++A;do d=0,l=e(F,y,k,x),l<0?(v=y[0],k!=x&&(v=v*xa+(y[1]||0)),d=v/A|0,d>1?(d>=xa&&(d=xa-1),h=t(F,d),p=h.length,x=y.length,l=e(h,y,p,x),l==1&&(d--,n(h,k<p?R:F,p))):(d==0&&(l=d=1),h=F.slice()),p=h.length,p<x&&h.unshift(0),n(y,h,x),l==-1&&(x=y.length,l=e(F,y,k,x),l<1&&(d++,n(y,k<x?R:F,x))),x=y.length):l===0&&(d++,y=[0]),b[u++]=d,l&&y[0]?y[x++]=U[T]||0:(y=[U[T]],x=1);while((T++<M||y[0]!==void 0)&&S--)}return b[0]||b.shift(),m.e=c,Ur(m,o?s+qi(m)+1:s)}})();function rZ(t,e){var n,r,i,s,o,l,c=0,u=0,d=t.constructor,h=d.precision;if(qi(t)>16)throw Error(CL+qi(t));if(!t.s)return new d(bo);for(ii=!1,l=h,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Rf(2,u))/Math.LN10*2+5|0,l+=r,n=i=s=new d(bo),d.precision=l;;){if(i=Ur(i.times(t),l),n=n.times(++c),o=s.plus(Lu(i,n,l)),mc(o.d).slice(0,l)===mc(s.d).slice(0,l)){for(;u--;)s=Ur(s.times(s),l);return d.precision=h,e==null?(ii=!0,Ur(s,h)):s}s=o}}function qi(t){for(var e=t.e*Yr,n=t.d[0];n>=10;n/=10)e++;return e}function tP(t,e,n){if(e>t.LN10.sd())throw ii=!0,n&&(t.precision=n),Error(pl+"LN10 precision limit exceeded");return Ur(new t(t.LN10),e)}function Qd(t){for(var e="";t--;)e+="0";return e}function Sy(t,e){var n,r,i,s,o,l,c,u,d,h=1,p=10,m=t,b=m.d,y=m.constructor,x=y.precision;if(m.s<1)throw Error(pl+(m.s?"NaN":"-Infinity"));if(m.eq(bo))return new y(0);if(e==null?(ii=!1,u=x):u=e,m.eq(10))return e==null&&(ii=!0),tP(y,u);if(u+=p,y.precision=u,n=mc(b),r=n.charAt(0),s=qi(m),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=mc(m.d),r=n.charAt(0),h++;s=qi(m),r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1))}else return c=tP(y,u+2,x).times(s+""),m=Sy(new y(r+"."+n.slice(1)),u-p).plus(c),y.precision=x,e==null?(ii=!0,Ur(m,x)):m;for(l=o=m=Lu(m.minus(bo),m.plus(bo),u),d=Ur(m.times(m),u),i=3;;){if(o=Ur(o.times(d),u),c=l.plus(Lu(o,new y(i),u)),mc(c.d).slice(0,u)===mc(l.d).slice(0,u))return l=l.times(2),s!==0&&(l=l.plus(tP(y,u+2,x).times(s+""))),l=Lu(l,new y(h),u),y.precision=x,e==null?(ii=!0,Ur(l,x)):l;l=c,i+=2}}function iG(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=Ib(n/Yr),t.d=[],r=(n+1)%Yr,n<0&&(r+=Yr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Yr;r<i;)t.d.push(+e.slice(r,r+=Yr));e=e.slice(r),r=Yr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),ii&&(t.e>nN||t.e<-nN))throw Error(CL+n)}else t.s=0,t.e=0,t.d=[0];return t}function Ur(t,e,n){var r,i,s,o,l,c,u,d,h=t.d;for(o=1,s=h[0];s>=10;s/=10)o++;if(r=e-o,r<0)r+=Yr,i=e,u=h[d=0];else{if(d=Math.ceil((r+1)/Yr),s=h.length,d>=s)return t;for(u=s=h[d],o=1;s>=10;s/=10)o++;r%=Yr,i=r-Yr+o}if(n!==void 0&&(s=Rf(10,o-i-1),l=u/s%10|0,c=e<0||h[d+1]!==void 0||u%s,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?i>0?u/Rf(10,o-i):0:h[d-1])%10&1||n==(t.s<0?8:7))),e<1||!h[0])return c?(s=qi(t),h.length=1,e=e-s-1,h[0]=Rf(10,(Yr-e%Yr)%Yr),t.e=Ib(-e/Yr)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(r==0?(h.length=d,s=1,d--):(h.length=d+1,s=Rf(10,Yr-r),h[d]=i>0?(u/Rf(10,o-i)%Rf(10,i)|0)*s:0),c)for(;;)if(d==0){(h[0]+=s)==xa&&(h[0]=1,++t.e);break}else{if(h[d]+=s,h[d]!=xa)break;h[d--]=0,s=1}for(r=h.length;h[--r]===0;)h.pop();if(ii&&(t.e>nN||t.e<-nN))throw Error(CL+qi(t));return t}function iZ(t,e){var n,r,i,s,o,l,c,u,d,h,p=t.constructor,m=p.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new p(t),ii?Ur(e,m):e;if(c=t.d,h=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=h.length):(n=h,r=u,l=c.length),i=Math.max(Math.ceil(m/Yr),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=h.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=h[i]){d=c[i]<h[i];break}o=0}for(d&&(n=c,c=h,h=n,e.s=-e.s),l=c.length,i=h.length-l;i>0;--i)c[l++]=0;for(i=h.length;i>o;){if(c[--i]<h[i]){for(s=i;s&&c[--s]===0;)c[s]=xa-1;--c[s],c[i]+=xa}c[i]-=h[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,ii?Ur(e,m):e):new p(0)}function Tm(t,e,n){var r,i=qi(t),s=mc(t.d),o=s.length;return e?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+Qd(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+Qd(-i-1)+s,n&&(r=n-o)>0&&(s+=Qd(r))):i>=o?(s+=Qd(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+Qd(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=Qd(r))),t.s<0?"-"+s:s}function aG(t,e){if(t.length>e)return t.length=e,!0}function aZ(t){var e,n,r;function i(s){var o=this;if(!(o instanceof i))return new i(s);if(o.constructor=i,s instanceof i){o.s=s.s,o.e=s.e,o.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(am+s);if(s>0)o.s=1;else if(s<0)s=-s,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(s===~~s&&s<1e7){o.e=0,o.d=[s];return}return iG(o,s.toString())}else if(typeof s!="string")throw Error(am+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,$3e.test(s))iG(o,s);else throw Error(am+s)}if(i.prototype=$t,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=aZ,i.config=i.set=V3e,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 V3e(t){if(!t||typeof t!="object")throw Error(pl+"Object expected");var e,n,r,i=["precision",1,Fb,"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(Ib(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(am+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(am+n+": "+r);return this}var PL=aZ(H3e);bo=new PL(1);const vr=PL;var G3e=t=>t,sZ={},oZ=t=>t===sZ,sG=t=>function e(){return arguments.length===0||arguments.length===1&&oZ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},lZ=(t,e)=>t===1?e:sG(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var s=r.filter(o=>o!==sZ).length;return s>=t?e(...r):lZ(t-s,sG(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>oZ(d)?l.shift():d);return e(...u,...l)}))}),q3e=t=>lZ(t.length,t),ED=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},W3e=q3e((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),K3e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return G3e;var i=n.reverse(),s=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),s(...arguments))}},TD=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function cZ(t){var e;return t===0?e=1:e=Math.floor(new vr(t).abs().log(10).toNumber())+1,e}function uZ(t,e,n){for(var r=new vr(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var dZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},hZ=(t,e,n)=>{if(t.lte(0))return new vr(0);var r=cZ(t.toNumber()),i=new vr(10).pow(r),s=t.div(i),o=r!==1?.05:.1,l=new vr(Math.ceil(s.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new vr(c.toNumber()):new vr(Math.ceil(c.toNumber()))},X3e=(t,e,n)=>{var r=new vr(1),i=new vr(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new vr(10).pow(cZ(t)-1),i=new vr(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new vr(Math.floor(t)))}else t===0?i=new vr(Math.floor((e-1)/2)):n||(i=new vr(Math.floor(t)));var o=Math.floor((e-1)/2),l=K3e(W3e(c=>i.add(new vr(c-o).mul(r)).toNumber()),ED);return l(0,e)},fZ=function(e,n,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new vr(0),tickMin:new vr(0),tickMax:new vr(0)};var o=hZ(new vr(n).sub(e).div(r-1),i,s),l;e<=0&&n>=0?l=new vr(0):(l=new vr(e).add(n).div(2),l=l.sub(new vr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new vr(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?fZ(e,n,r,i,s+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new vr(c).mul(o)),tickMax:l.add(new vr(u).mul(o))})},Y3e=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(i,2),[l,c]=dZ([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...ED(0,i-1).map(()=>1/0)]:[...ED(0,i-1).map(()=>-1/0),c];return n>r?TD(u):u}if(l===c)return X3e(l,i,s);var{step:d,tickMin:h,tickMax:p}=fZ(l,c,o,s,0),m=uZ(h,p.add(new vr(.1).mul(d)),d);return n>r?TD(m):m},Q3e=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=dZ([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=hZ(new vr(l).sub(o).div(c-1),s,0),d=[...uZ(new vr(o),new vr(l),u),l];return s===!1&&(d=d.map(h=>Math.round(h))),r>i?TD(d):d},mZ=t=>t.rootProps.maxBarSize,Z3e=t=>t.rootProps.barGap,pZ=t=>t.rootProps.barCategoryGap,J3e=t=>t.rootProps.barSize,cv=t=>t.rootProps.stackOffset,gZ=t=>t.rootProps.reverseStackOrder,jL=t=>t.options.chartName,DL=t=>t.rootProps.syncId,bZ=t=>t.rootProps.syncMethod,RL=t=>t.options.eventEmitter,eDe=t=>t.rootProps.baseValue,wi={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},wu={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},po={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},xM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},tDe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:wu.angleAxisId,includeHidden:!1,name:void 0,reversed:wu.reversed,scale:wu.scale,tick:wu.tick,tickCount:void 0,ticks:void 0,type:wu.type,unit:void 0},nDe={allowDataOverflow:po.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:po.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:po.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:po.scale,tick:po.tick,tickCount:po.tickCount,ticks:void 0,type:po.type,unit:void 0},rDe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:wu.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:wu.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:wu.scale,tick:wu.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},iDe={allowDataOverflow:po.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:po.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:po.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:po.scale,tick:po.tick,tickCount:po.tickCount,ticks:void 0,type:"category",unit:void 0},OL=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?rDe:tDe,LL=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?iDe:nDe,yM=t=>t.polarOptions,FL=st([rd,id,aa],pQ),xZ=st([yM,FL],(t,e)=>{if(t!=null)return as(t.innerRadius,e,0)}),yZ=st([yM,FL],(t,e)=>{if(t!=null)return as(t.outerRadius,e,e*.8)}),aDe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},vZ=st([yM],aDe);st([OL,vZ],xM);var wZ=st([FL,xZ,yZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});st([LL,wZ],xM);var _Z=st([Gn,yM,xZ,yZ,rd,id],(t,e,n,r,i,s)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:as(o,i,i/2),cy:as(l,s,s/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),si=(t,e)=>e,uv=(t,e,n)=>n;function vM(t){return t?.id}function SZ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,o=new Map;return t.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=vM(l);u.forEach((h,p)=>{var m=s==null||i?p:String(wr(h,s,null)),b=wr(h,l.dataKey,0),y;o.has(m)?y=o.get(m):y={},Object.assign(y,{[d]:b}),o.set(m,y)})}}),Array.from(o.values())}function wM(t){return t.stackId!=null&&t.dataKey!=null}var _M=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function SM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function sDe(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 la=t=>{var e=Gn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},zb=t=>t.tooltip.settings.axisId;function oG(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 rN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oG(Object(n),!0).forEach(function(r){oDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oDe(t,e,n){return(e=lDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lDe(t){var e=cDe(t,"string");return typeof e=="symbol"?e:e+""}function cDe(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 AD=[0,"auto"],ga={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},NZ=(t,e)=>t.cartesianAxis.xAxis[e],Dc=(t,e)=>{var n=NZ(t,e);return n??ga},ba={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:AD,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:tv},kZ=(t,e)=>t.cartesianAxis.yAxis[e],Rc=(t,e)=>{var n=kZ(t,e);return n??ba},uDe={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:""},IL=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??uDe},di=(t,e,n)=>{switch(e){case"xAxis":return Dc(t,n);case"yAxis":return Rc(t,n);case"zAxis":return IL(t,n);case"angleAxis":return OL(t,n);case"radiusAxis":return LL(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},dDe=(t,e,n)=>{switch(e){case"xAxis":return Dc(t,n);case"yAxis":return Rc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},dv=(t,e,n)=>{switch(e){case"xAxis":return Dc(t,n);case"yAxis":return Rc(t,n);case"angleAxis":return OL(t,n);case"radiusAxis":return LL(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},MZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function zL(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 hv=t=>t.graphicalItems.cartesianItems,hDe=st([si,uv],zL),UL=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),fv=st([hv,di,hDe],UL,{memoizeOptions:{resultEqualityCheck:SM}}),EZ=st([fv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(wM)),TZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),fDe=st([fv],TZ),BL=t=>t.map(e=>e.data).filter(Boolean).flat(1),mDe=st([fv],BL,{memoizeOptions:{resultEqualityCheck:SM}}),HL=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},$L=st([mDe,lv],HL),VL=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:wr(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:wr(i,r)}))):t.map(r=>({value:r})),NM=st([$L,di,fv],VL);function AZ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function G1(t){if(fl(t)||t instanceof Date){var e=Number(t);if(_r(e))return e}}function lG(t){if(Array.isArray(t)){var e=[G1(t[0]),G1(t[1])];return Fh(e)?e:void 0}var n=G1(t);if(n!=null)return[n,n]}function ed(t){return t.map(G1).filter(d2e)}function pDe(t,e,n){return!n||typeof e!="number"||Xs(e)?[]:n.length?ed(n.flatMap(r=>{var i=wr(t,r.dataKey),s,o;if(Array.isArray(i)?[s,o]=i:s=o=i,!(!_r(s)||!_r(o)))return[e-s,e+o]})):[]}var ca=t=>{var e=la(t),n=zb(t);return dv(t,e,n)},mv=st([ca],t=>t?.dataKey),gDe=st([EZ,lv,ca],SZ),CZ=(t,e,n,r)=>{var i={},s=e.reduce((o,l)=>(l.stackId==null||(o[l.stackId]==null&&(o[l.stackId]=[]),o[l.stackId].push(l)),o),i);return Object.fromEntries(Object.entries(s).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(vM);return[l,{stackedData:OTe(t,d,n),graphicalItems:u}]}))},Ny=st([gDe,EZ,cv,gZ],CZ),PZ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var o=zTe(t,i,s);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},bDe=st([di],t=>t.allowDataOverflow),GL=t=>{var e;if(t==null||!("domain"in t))return AD;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=ed(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:AD},qL=st([di],GL),WL=st([qL,bDe],eZ),xDe=st([Ny,qh,si,WL],PZ,{memoizeOptions:{resultEqualityCheck:_M}}),kM=t=>t.errorBars,yDe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>AZ(n,r)),iN=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var s=i.flat(),o=Math.min(...s),l=Math.max(...s);return[o,l]}},KL=(t,e,n,r,i)=>{var s,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,h=(u=r[c.id])===null||u===void 0?void 0:u.filter(v=>AZ(i,v)),p=wr(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=pDe(l,p,h);if(m.length>=2){var b=Math.min(...m),y=Math.max(...m);(s==null||b<s)&&(s=b),(o==null||y>o)&&(o=y)}var x=lG(p);x!=null&&(s=s==null?x[0]:Math.min(s,x[0]),o=o==null?x[1]:Math.max(o,x[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=lG(wr(l,e.dataKey));c!=null&&(s=s==null?c[0]:Math.min(s,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),_r(s)&&_r(o))return[s,o]},vDe=st([$L,di,fDe,kM,si],KL,{memoizeOptions:{resultEqualityCheck:_M}});function wDe(t){var{value:e}=t;if(fl(e)||e instanceof Date)return e}var _De=(t,e,n)=>{var r=t.map(wDe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&qX(r))?yQ(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},jZ=t=>t.referenceElements.dots,Ub=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),SDe=st([jZ,si,uv],Ub),DZ=t=>t.referenceElements.areas,NDe=st([DZ,si,uv],Ub),RZ=t=>t.referenceElements.lines,kDe=st([RZ,si,uv],Ub),OZ=(t,e)=>{var n=ed(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},MDe=st(SDe,si,OZ),LZ=(t,e)=>{var n=ed(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)]},EDe=st([NDe,si],LZ);function TDe(t){var e;if(t.x!=null)return ed([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:ed(n)}function ADe(t){var e;if(t.y!=null)return ed([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:ed(n)}var FZ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?TDe(r):ADe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},CDe=st([kDe,si],FZ),PDe=st(MDe,CDe,EDe,(t,e,n)=>iN(t,n,e)),XL=(t,e,n,r,i,s,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?iN(r,s,i):iN(s,i);return B3e(e,u,t.allowDataOverflow)},jDe=st([di,qL,WL,xDe,vDe,PDe,Gn,si],XL,{memoizeOptions:{resultEqualityCheck:_M}}),DDe=[0,1],YL=(t,e,n,r,i,s,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=jc(e,s);if(u&&l==null){var d;return yQ(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?_De(r,t,u):i==="expand"?DDe:o}},QL=st([di,Gn,$L,NM,cv,si,jDe],YL),IZ=(t,e,n,r,i)=>{if(t!=null){var{scale:s,type:o}=t;if(s==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":o==="category"?"band":"linear";if(typeof s=="string"){var l="scale".concat(Xy(s));return l in m0?l:"point"}}},Bb=st([di,Gn,MZ,jL,si],IZ);function RDe(t){if(t!=null){if(t in m0)return m0[t]();var e="scale".concat(Xy(t));if(e in m0)return m0[e]()}}function ZL(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=RDe(e);if(i!=null){var s=i.domain(n).range(r);return CTe(s),s}}}var JL=(t,e,n)=>{var r=GL(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Fh(t))return Y3e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Fh(t))return Q3e(t,e.tickCount,e.allowDecimals)}},e4=st([QL,dv,Bb],JL),t4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Fh(e)&&Array.isArray(n)&&n.length>0){var i=e[0],s=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,s),Math.max(o,l)]}return e},ODe=st([di,QL,e4,si],t4),LDe=st(NM,di,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(ed(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var s=0;s<r.length-1;s++){var o=r[s+1]-r[s];n=Math.min(n,o)}return n/i}}),zZ=st(LDe,Gn,pZ,aa,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!_r(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var o=as(n,t*s),l=t*s/2;return l-o-(l-o)/s*o}return 0}),FDe=(t,e)=>{var n=Dc(t,e);return n==null||typeof n.padding!="string"?0:zZ(t,"xAxis",e,n.padding)},IDe=(t,e)=>{var n=Rc(t,e);return n==null||typeof n.padding!="string"?0:zZ(t,"yAxis",e,n.padding)},zDe=st(Dc,FDe,(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}}),UDe=st(Rc,IDe,(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}}),BDe=st([aa,zDe,oM,sM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:s}=r;return i?[s.left,n.width-s.right]:[t.left+e.left,t.left+t.width-e.right]}),HDe=st([aa,Gn,UDe,oM,sM,(t,e,n)=>n],(t,e,n,r,i,s)=>{var{padding:o}=i;return s?[r.height-o.bottom,o.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),pv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return BDe(t,n,r);case"yAxis":return HDe(t,n,r);case"zAxis":return(i=IL(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return vZ(t);case"radiusAxis":return wZ(t,n);default:return}},UZ=st([di,pv],xM),Ih=st([di,Bb,ODe,UZ],ZL);st([fv,kM,si],yDe);function BZ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var MM=(t,e)=>e,EM=(t,e,n)=>n,$De=st(iM,MM,EM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BZ)),VDe=st(aM,MM,EM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BZ)),HZ=(t,e)=>({width:t.width,height:e.height}),GDe=(t,e)=>{var n=typeof e.width=="number"?e.width:tv;return{width:n,height:t.height}},$Z=st(aa,Dc,HZ),qDe=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},WDe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},KDe=st(id,aa,$De,MM,EM,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=HZ(e,l);o==null&&(o=qDe(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;s[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),s}),XDe=st(rd,aa,VDe,MM,EM,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=GDe(e,l);o==null&&(o=WDe(e,r,t));var u=r==="left"&&!i||r==="right"&&i;s[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),s}),YDe=(t,e)=>{var n=Dc(t,e);if(n!=null)return KDe(t,n.orientation,n.mirror)},QDe=st([aa,Dc,YDe,(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}}}),ZDe=(t,e)=>{var n=Rc(t,e);if(n!=null)return XDe(t,n.orientation,n.mirror)},JDe=st([aa,Rc,ZDe,(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}}}),VZ=st(aa,Rc,(t,e)=>{var n=typeof e.width=="number"?e.width:tv;return{width:n,height:t.height}}),cG=(t,e,n)=>{switch(e){case"xAxis":return $Z(t,n).width;case"yAxis":return VZ(t,n).height;default:return}},GZ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:o}=n,l=jc(t,r),c=e.map(u=>u.value);if(o&&l&&s==="category"&&i&&qX(c))return c}},n4=st([Gn,NM,di,si],GZ),qZ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,o=jc(t,r);if(o&&(i==="number"||s!=="auto"))return e.map(l=>l.value)}},r4=st([Gn,NM,dv,si],qZ),uG=st([Gn,dDe,Bb,Ih,n4,r4,pv,e4,si],(t,e,n,r,i,s,o,l,c)=>{if(e!=null){var u=jc(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:s,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),eRe=(t,e,n,r,i,s,o,l,c)=>{if(!(e==null||r==null)){var u=jc(t,c),{type:d,ticks:h,tickCount:p}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,b=d==="category"&&r.bandwidth?r.bandwidth()/m:0;b=c==="angleAxis"&&s!=null&&s.length>=2?wa(s[0]-s[1])*2*b:b;var y=h||i;if(y){var x=y.map((v,S)=>{var N=o?o.indexOf(v):v;return{index:S,coordinate:r(N)+b,value:v,offset:b}});return x.filter(v=>_r(v.coordinate))}return u&&l?l.map((v,S)=>({coordinate:r(v)+b,value:v,index:S,offset:b})).filter(v=>_r(v.coordinate)):r.ticks?r.ticks(p).map(v=>({coordinate:r(v)+b,value:v,offset:b})):r.domain().map((v,S)=>({coordinate:r(v)+b,value:o?o[v]:v,index:S,offset:b}))}},WZ=st([Gn,dv,Bb,Ih,e4,pv,n4,r4,si],eRe),tRe=(t,e,n,r,i,s,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=jc(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?wa(r[0]-r[1])*2*u:u,l&&s?s.map((d,h)=>({coordinate:n(d)+u,value:d,index:h,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,h)=>({coordinate:n(d)+u,value:i?i[d]:d,index:h,offset:u}))}},kc=st([Gn,dv,Ih,pv,n4,r4,si],tRe),Mc=st(di,Ih,(t,e)=>{if(!(t==null||e==null))return rN(rN({},t),{},{scale:e})}),nRe=st([di,Bb,QL,UZ],ZL);st((t,e,n)=>IL(t,n),nRe,(t,e)=>{if(!(t==null||e==null))return rN(rN({},t),{},{scale:e})});var rRe=st([Gn,iM,aM],(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}}),KZ=t=>t.options.defaultTooltipEventType,XZ=t=>t.options.validateTooltipEventTypes;function YZ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function i4(t,e){var n=KZ(t),r=XZ(t);return YZ(e,n,r)}function iRe(t){return zt(e=>i4(e,t))}var QZ=(t,e)=>{var n,r=Number(e);if(!(Xs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},aRe=t=>t.tooltip.settings,ah={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},sRe={itemInteraction:{click:ah,hover:ah},axisInteraction:{click:ah,hover:ah},keyboardInteraction:ah,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}},ZZ=Ys({name:"tooltip",initialState:sRe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:ni()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ul(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:ni()},removeTooltipEntrySettings:{reducer(t,e){var n=Ul(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:ni()},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:oRe,replaceTooltipEntrySettings:lRe,removeTooltipEntrySettings:cRe,setTooltipSettingsState:uRe,setActiveMouseOverItemIndex:JZ,mouseLeaveItem:dRe,mouseLeaveChart:eJ,setActiveClickItemIndex:hRe,setMouseOverAxisIndex:tJ,setMouseClickAxisIndex:fRe,setSyncInteraction:CD,setKeyboardInteraction:PD}=ZZ.actions,mRe=ZZ.reducer;function dG(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 o1(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dG(Object(n),!0).forEach(function(r){pRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pRe(t,e,n){return(e=gRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gRe(t){var e=bRe(t,"string");return typeof e=="symbol"?e:e+""}function bRe(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 xRe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function yRe(t){return t.index!=null}var nJ=(t,e,n,r)=>{if(e==null)return ah;var i=xRe(t,e,n);if(i==null)return ah;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var s=t.settings.active===!0;if(yRe(i)){if(s)return o1(o1({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return o1(o1({},ah),{},{coordinate:i.coordinate})};function vRe(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 wRe(t,e){var n=vRe(t),r=e[0],i=e[1];if(n===void 0)return!1;var s=Math.min(r,i),o=Math.max(r,i);return n>=s&&n<=o}function _Re(t,e,n){if(n==null||e==null)return!0;var r=wr(t,e);return r==null||!Fh(n)?!0:wRe(r,n)}var a4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!_r(s))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(s,l)),u=e[c];return u==null||_Re(u,n,r)?String(c):null},rJ=(t,e,n,r,i,s,o,l)=>{if(!(s==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,s);if(u!=null)return u;var d=i?.[Number(s)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},iJ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(s=>{var o;return((o=s.settings)===null||o===void 0?void 0:o.dataKey)===i})},gv=t=>t.options.tooltipPayloadSearcher,Hb=t=>t.tooltip;function hG(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 fG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hG(Object(n),!0).forEach(function(r){SRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SRe(t,e,n){return(e=NRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function NRe(t){var e=kRe(t,"string");return typeof e=="symbol"?e:e+""}function kRe(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 MRe(t,e){return t??e}var aJ=(t,e,n,r,i,s,o)=>{if(!(e==null||s==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,h=[];return t.reduce((p,m)=>{var b,{dataDefinedOnItem:y,settings:x}=m,v=MRe(y,l),S=Array.isArray(v)?BY(v,u,d):v,N=(b=x?.dataKey)!==null&&b!==void 0?b:r,T=x?.nameKey,M;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?M=WX(S,r,i):M=s(S,e,c,T),Array.isArray(M))M.forEach(k=>{var R=fG(fG({},x),{},{name:k.name,unit:k.unit,color:void 0,fill:void 0});p.push(D$({tooltipEntrySettings:R,dataKey:k.dataKey,payload:k.payload,value:wr(k.payload,k.dataKey),name:k.name}))});else{var A;p.push(D$({tooltipEntrySettings:x,dataKey:N,payload:M,value:wr(M,N),name:(A=wr(M,T))!==null&&A!==void 0?A:x?.name}))}return p},h)}},s4=st([ca,Gn,MZ,jL,la],IZ),ERe=st([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),TRe=st([la,zb],zL),bv=st([ERe,ca,TRe],UL,{memoizeOptions:{resultEqualityCheck:SM}}),ARe=st([bv],t=>t.filter(wM)),CRe=st([bv],BL,{memoizeOptions:{resultEqualityCheck:SM}}),$b=st([CRe,qh],HL),PRe=st([ARe,qh,ca],SZ),o4=st([$b,ca,bv],VL),sJ=st([ca],GL),jRe=st([ca],t=>t.allowDataOverflow),oJ=st([sJ,jRe],eZ),DRe=st([bv],t=>t.filter(wM)),RRe=st([PRe,DRe,cv,gZ],CZ),ORe=st([RRe,qh,la,oJ],PZ),LRe=st([bv],TZ),FRe=st([$b,ca,LRe,kM,la],KL,{memoizeOptions:{resultEqualityCheck:_M}}),IRe=st([jZ,la,zb],Ub),zRe=st([IRe,la],OZ),URe=st([DZ,la,zb],Ub),BRe=st([URe,la],LZ),HRe=st([RZ,la,zb],Ub),$Re=st([HRe,la],FZ),VRe=st([zRe,$Re,BRe],iN),GRe=st([ca,sJ,oJ,ORe,FRe,VRe,Gn,la],XL),xv=st([ca,Gn,$b,o4,cv,la,GRe],YL),qRe=st([xv,ca,s4],JL),WRe=st([ca,xv,qRe,la],t4),lJ=t=>{var e=la(t),n=zb(t),r=!1;return pv(t,e,n,r)},cJ=st([ca,lJ],xM),uJ=st([ca,s4,WRe,cJ],ZL),KRe=st([Gn,o4,ca,la],GZ),XRe=st([Gn,o4,ca,la],qZ),YRe=(t,e,n,r,i,s,o,l)=>{if(e){var{type:c}=e,u=jc(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,h=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return h=l==="angleAxis"&&i!=null&&i?.length>=2?wa(i[0]-i[1])*2*h:h,u&&o?o.map((p,m)=>({coordinate:r(p)+h,value:p,index:m,offset:h})):r.domain().map((p,m)=>({coordinate:r(p)+h,value:s?s[p]:p,index:m,offset:h}))}}},sd=st([Gn,ca,s4,uJ,lJ,KRe,XRe,la],YRe),l4=st([KZ,XZ,aRe],(t,e,n)=>YZ(n.shared,t,e)),dJ=t=>t.tooltip.settings.trigger,c4=t=>t.tooltip.settings.defaultIndex,yv=st([Hb,l4,dJ,c4],nJ),zh=st([yv,$b,mv,xv],a4),hJ=st([sd,zh],QZ),u4=st([yv],t=>{if(t)return t.dataKey}),QRe=st([yv],t=>{if(t)return t.graphicalItemId}),fJ=st([Hb,l4,dJ,c4],iJ),ZRe=st([rd,id,Gn,aa,sd,c4,fJ,gv],rJ),JRe=st([yv,ZRe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),eOe=st([yv],t=>t.active),tOe=st([fJ,zh,qh,mv,hJ,gv,l4],aJ),nOe=st([tOe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function mG(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?mG(Object(n),!0).forEach(function(r){rOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rOe(t,e,n){return(e=iOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iOe(t){var e=aOe(t,"string");return typeof e=="symbol"?e:e+""}function aOe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var sOe=()=>zt(ca),oOe=()=>{var t=sOe(),e=zt(sd),n=zt(uJ);return Lh(!t||!n?void 0:pG(pG({},t),{},{scale:n}),e)};function gG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ag(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gG(Object(n),!0).forEach(function(r){lOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lOe(t,e,n){return(e=cOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cOe(t){var e=uOe(t,"string");return typeof e=="symbol"?e:e+""}function uOe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var dOe=(t,e,n,r)=>{var i=e.find(s=>s&&s.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},hOe=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:o}=r;return ag(ag(ag({},r),Hi(r.cx,r.cy,o,s)),{},{angle:s,radius:o})}var l=i.coordinate,{angle:c}=r;return ag(ag(ag({},r),Hi(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 fOe(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 mJ=(t,e,n,r,i)=>{var s,o=-1,l=(s=e?.length)!==null&&s!==void 0?s:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,h=c>=l-1?n[0].coordinate:n[c+1].coordinate,p=void 0;if(wa(d-u)!==wa(h-d)){var m=[];if(wa(h-d)===wa(i[1]-i[0])){p=h;var b=d+i[1]-i[0];m[0]=Math.min(b,(b+u)/2),m[1]=Math.max(b,(b+u)/2)}else{p=u;var y=h+i[1]-i[0];m[0]=Math.min(d,(y+d)/2),m[1]=Math.max(d,(y+d)/2)}var x=[Math.min(d,(p+d)/2),Math.max(d,(p+d)/2)];if(t>x[0]&&t<=x[1]||t>=m[0]&&t<=m[1]){({index:o}=n[c]);break}}else{var v=Math.min(u,h),S=Math.max(u,h);if(t>(v+d)/2&&t<=(S+d)/2){({index:o}=n[c]);break}}}else if(e){for(var N=0;N<l;N++)if(N===0&&t<=(e[N].coordinate+e[N+1].coordinate)/2||N>0&&N<l-1&&t>(e[N].coordinate+e[N-1].coordinate)/2&&t<=(e[N].coordinate+e[N+1].coordinate)/2||N===l-1&&t>(e[N].coordinate+e[N-1].coordinate)/2){({index:o}=e[N]);break}}return o},pJ=()=>zt(jL),d4=(t,e)=>e,gJ=(t,e,n)=>n,h4=(t,e,n,r)=>r,mOe=st(sd,t=>Xk(t,e=>e.coordinate)),f4=st([Hb,d4,gJ,h4],nJ),m4=st([f4,$b,mv,xv],a4),pOe=(t,e,n)=>{if(e!=null){var r=Hb(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},bJ=st([Hb,d4,gJ,h4],iJ),aN=st([rd,id,Gn,aa,sd,h4,bJ,gv],rJ),gOe=st([f4,aN],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),xJ=st([sd,m4],QZ),bOe=st([bJ,m4,qh,mv,xJ,gv,d4],aJ),xOe=st([f4,m4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),yOe=(t,e,n,r,i,s,o)=>{if(!(!t||!n||!r||!i)&&fOe(t,o)){var l=UTe(t,e),c=mJ(l,s,i,n,r),u=dOe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},vOe=(t,e,n,r,i,s,o)=>{if(!(!t||!r||!i||!s||!n)){var l=rPe(t,n);if(l){var c=BTe(l,e),u=mJ(c,o,s,r,i),d=hOe(e,s,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},wOe=(t,e,n,r,i,s,o,l)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?yOe(t,e,r,i,s,o,l):vOe(t,e,n,r,i,s,o)},_Oe=st(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}}),SOe=st(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(wi)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:sDe}});function bG(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?bG(Object(n),!0).forEach(function(r){NOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function NOe(t,e,n){return(e=kOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kOe(t){var e=MOe(t,"string");return typeof e=="symbol"?e:e+""}function MOe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var EOe={},TOe={zIndexMap:Object.values(wi).reduce((t,e)=>xG(xG({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),EOe)},AOe=new Set(Object.values(wi));function COe(t){return AOe.has(t)}var yJ=Ys({name:"zIndex",initialState:TOe,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:ni()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!COe(n)&&delete t.zIndexMap[n])},prepare:ni()},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:ni()},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:ni()}}}),{registerZIndexPortal:POe,unregisterZIndexPortal:jOe,registerZIndexPortalId:DOe,unregisterZIndexPortalId:ROe}=yJ.actions,OOe=yJ.reducer;function ls(t){var{zIndex:e,children:n}=t,r=yAe(),i=r&&e!==void 0&&e!==0,s=sa(),o=Br();_.useLayoutEffect(()=>i?(o(POe({zIndex:e})),()=>{o(jOe({zIndex:e}))}):Yy,[o,e,i]);var l=zt(u=>_Oe(u,e,s));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Su.createPortal(n,c):null}function jD(){return jD=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},jD.apply(null,arguments)}function yG(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 l1(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yG(Object(n),!0).forEach(function(r){LOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LOe(t,e,n){return(e=FOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FOe(t){var e=IOe(t,"string");return typeof e=="symbol"?e:e+""}function IOe(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 zOe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return _.isValidElement(e)?_.cloneElement(e,r):_.createElement(n,r)}function UOe(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,h=n,p=r,m=i;if(!c||!h||d!=="ScatterChart"&&u!=="axis")return null;var b,y,x;if(d==="ScatterChart")b=h,y=xCe,x=wi.cursorLine;else if(d==="BarChart")b=yCe(l,h,s,o),y=mQ,x=wi.cursorRectangle;else if(l==="radial"&&XX(h)){var{cx:v,cy:S,radius:N,startAngle:T,endAngle:M}=gQ(h);b={cx:v,cy:S,startAngle:T,endAngle:M,innerRadius:N,outerRadius:N},y=xQ,x=wi.cursorLine}else b={points:oPe(l,h,s)},y=Ug,x=wi.cursorLine;var A=typeof c=="object"&&"className"in c?c.className:void 0,k=l1(l1(l1(l1({stroke:"#ccc",pointerEvents:"none"},s),b),Nm(c)),{},{payload:p,payloadIndex:m,className:tr("recharts-tooltip-cursor",A)});return _.createElement(ls,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:x},_.createElement(zOe,{cursor:c,cursorComp:y,cursorProps:k}))}function BOe(t){var e=oOe(),n=ZY(),r=Um(),i=pJ();return e==null||n==null||r==null||i==null?null:_.createElement(UOe,jD({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var vJ=_.createContext(null),HOe=()=>_.useContext(vJ),nP={exports:{}},vG;function $Oe(){return vG||(vG=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function s(c,u,d,h,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,h||c,p),b=n?n+u:u;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],m]:c._events[b].push(m):(c._events[b]=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,h;if(this._eventsCount===0)return u;for(h in d=this._events)e.call(d,h)&&u.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,h=this._events[d];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,m=h.length,b=new Array(m);p<m;p++)b[p]=h[p].fn;return b},l.prototype.listenerCount=function(u){var d=n?n+u:u,h=this._events[d];return h?h.fn?1:h.length:0},l.prototype.emit=function(u,d,h,p,m,b){var y=n?n+u:u;if(!this._events[y])return!1;var x=this._events[y],v=arguments.length,S,N;if(x.fn){switch(x.once&&this.removeListener(u,x.fn,void 0,!0),v){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,d),!0;case 3:return x.fn.call(x.context,d,h),!0;case 4:return x.fn.call(x.context,d,h,p),!0;case 5:return x.fn.call(x.context,d,h,p,m),!0;case 6:return x.fn.call(x.context,d,h,p,m,b),!0}for(N=1,S=new Array(v-1);N<v;N++)S[N-1]=arguments[N];x.fn.apply(x.context,S)}else{var T=x.length,M;for(N=0;N<T;N++)switch(x[N].once&&this.removeListener(u,x[N].fn,void 0,!0),v){case 1:x[N].fn.call(x[N].context);break;case 2:x[N].fn.call(x[N].context,d);break;case 3:x[N].fn.call(x[N].context,d,h);break;case 4:x[N].fn.call(x[N].context,d,h,p);break;default:if(!S)for(M=1,S=new Array(v-1);M<v;M++)S[M-1]=arguments[M];x[N].fn.apply(x[N].context,S)}}return!0},l.prototype.on=function(u,d,h){return s(this,u,d,h,!1)},l.prototype.once=function(u,d,h){return s(this,u,d,h,!0)},l.prototype.removeListener=function(u,d,h,p){var m=n?n+u:u;if(!this._events[m])return this;if(!d)return o(this,m),this;var b=this._events[m];if(b.fn)b.fn===d&&(!p||b.once)&&(!h||b.context===h)&&o(this,m);else{for(var y=0,x=[],v=b.length;y<v;y++)(b[y].fn!==d||p&&!b[y].once||h&&b[y].context!==h)&&x.push(b[y]);x.length?this._events[m]=x.length===1?x[0]:x: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})(nP)),nP.exports}var VOe=$Oe();const GOe=gl(VOe);var ky=new GOe,DD="recharts.syncEvent.tooltip",wG="recharts.syncEvent.brush";function TM(t,e){if(e){var n=Number.parseInt(e,10);if(!Xs(n))return t?.[n]}}var qOe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},wJ=Ys({name:"options",initialState:qOe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),WOe=wJ.reducer,{createEventEmitter:KOe}=wJ.actions;function XOe(t){return t.tooltip.syncInteraction}var YOe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},_J=Ys({name:"chartData",initialState:YOe,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:_G,setDataStartEndIndexes:QOe,setComputedData:yQe}=_J.actions,ZOe=_J.reducer,JOe=["x","y"];function SG(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 sg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SG(Object(n),!0).forEach(function(r){eLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eLe(t,e,n){return(e=tLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tLe(t){var e=nLe(t,"string");return typeof e=="symbol"?e:e+""}function nLe(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 rLe(t,e){if(t==null)return{};var n,r,i=iLe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function iLe(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 aLe(){var t=zt(DL),e=zt(RL),n=Br(),r=zt(bZ),i=zt(sd),s=Um(),o=nv(),l=zt(c=>c.rootProps.className);_.useEffect(()=>{if(t==null)return Yy;var c=(u,d,h)=>{if(e!==h&&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:b,y}=m,x=rLe(m,JOe),{x:v,y:S,width:N,height:T}=d.payload.sourceViewBox,M=sg(sg({},x),{},{x:o.x+(N?(b-v)/N:0)*o.width,y:o.y+(T?(y-S)/T:0)*o.height});n(sg(sg({},d),{},{payload:sg(sg({},d.payload),{},{coordinate:M})}))}else n(d);return}if(i!=null){var A;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);A=i[R]}else r==="value"&&(A=i.find(G=>String(G.value)===d.payload.label));var{coordinate:C}=d.payload;if(A==null||d.payload.active===!1||C==null||o==null){n(CD({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:P,y:U}=C,F=Math.min(P,o.x+o.width),B=Math.min(U,o.y+o.height),D={x:s==="horizontal"?A.coordinate:F,y:s==="horizontal"?B:A.coordinate},$=CD({active:d.payload.active,coordinate:D,dataKey:d.payload.dataKey,index:String(A.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n($)}}};return ky.on(DD,c),()=>{ky.off(DD,c)}},[l,n,e,t,r,i,s,o])}function sLe(){var t=zt(DL),e=zt(RL),n=Br();_.useEffect(()=>{if(t==null)return Yy;var r=(i,s,o)=>{e!==o&&t===i&&n(QOe(s))};return ky.on(wG,r),()=>{ky.off(wG,r)}},[n,e,t])}function oLe(){var t=Br();_.useEffect(()=>{t(KOe())},[t]),aLe(),sLe()}function lLe(t,e,n,r,i,s){var o=zt(m=>pOe(m,t,e)),l=zt(RL),c=zt(DL),u=zt(bZ),d=zt(XOe),h=d?.active,p=nv();_.useEffect(()=>{if(!h&&c!=null&&l!=null){var m=CD({active:s,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:p,graphicalItemId:void 0});ky.emit(DD,c,m,l)}},[h,n,o,i,r,l,c,u,s,p])}function NG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function kG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?NG(Object(n),!0).forEach(function(r){cLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):NG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cLe(t,e,n){return(e=uLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uLe(t){var e=dLe(t,"string");return typeof e=="symbol"?e:e+""}function dLe(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 hLe(t){return t.dataKey}function fLe(t,e){return _.isValidElement(t)?_.cloneElement(t,e):typeof t=="function"?_.createElement(t,e):_.createElement(QAe,e)}var MG=[],mLe={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 q1(t){var e,n,r=ui(t,mLe),{active:i,allowEscapeViewBox:s,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:h,payloadUniqBy:p,position:m,reverseDirection:b,useTranslate3d:y,wrapperStyle:x,cursor:v,shared:S,trigger:N,defaultIndex:T,portal:M,axisId:A}=r,k=Br(),R=typeof T=="number"?String(T):T;_.useEffect(()=>{k(uRe({shared:S,trigger:N,axisId:A,active:i,defaultIndex:R}))},[k,S,N,A,i,R]);var C=nv(),P=cQ(),U=iRe(S),{activeIndex:F,isActive:B}=(e=zt(fe=>xOe(fe,U,N,R)))!==null&&e!==void 0?e:{},D=zt(fe=>bOe(fe,U,N,R)),$=zt(fe=>xJ(fe,U,N,R)),G=zt(fe=>gOe(fe,U,N,R)),I=D,K=HOe(),Q=(n=i??B)!==null&&n!==void 0?n:!1,[se,H]=dY([I,Q]),W=U==="axis"?$:void 0;lLe(U,N,G,W,F,Q);var J=M??K;if(J==null||C==null||U==null)return null;var ne=I??MG;Q||(ne=MG),u&&ne.length&&(ne=aY(ne.filter(fe=>fe.value!=null&&(fe.hide!==!0||r.includeHidden)),p,hLe));var xe=ne.length>0,ue=_.createElement(iCe,{allowEscapeViewBox:s,animationDuration:o,animationEasing:l,isAnimationActive:d,active:Q,coordinate:G,hasPayload:xe,offset:h,position:m,reverseDirection:b,useTranslate3d:y,viewBox:C,wrapperStyle:x,lastBoundingBox:se,innerRef:H,hasPortalFromProps:!!M},fLe(c,kG(kG({},r),{},{payload:ne,label:W,active:Q,activeIndex:F,coordinate:G,accessibilityLayer:P})));return _.createElement(_.Fragment,null,Su.createPortal(ue,J),Q&&_.createElement(BOe,{cursor:v,tooltipEventType:U,coordinate:G,payload:ne,index:F}))}var vv=t=>null;vv.displayName="Cell";function pLe(t,e,n){return(e=gLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gLe(t){var e=bLe(t,"string");return typeof e=="symbol"?e:e+""}function bLe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class xLe{constructor(e){pLe(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 EG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yLe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?EG(Object(n),!0).forEach(function(r){vLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):EG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vLe(t,e,n){return(e=wLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wLe(t){var e=_Le(t,"string");return typeof e=="symbol"?e:e+""}function _Le(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 SLe={cacheSize:2e3,enableCache:!0},SJ=yLe({},SLe),TG=new xLe(SJ.cacheSize),NLe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},AG="recharts_measurement_span";function kLe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",s=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(s,"|").concat(o,"|").concat(l)}var CG=(t,e)=>{try{var n=document.getElementById(AG);n||(n=document.createElement("span"),n.setAttribute("id",AG),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,NLe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},C0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Db.isSsr)return{width:0,height:0};if(!SJ.enableCache)return CG(e,n);var r=kLe(e,n),i=TG.get(r);if(i)return i;var s=CG(e,n);return TG.set(r,s),s},PG=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,jG=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,MLe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,ELe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,NJ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},TLe=Object.keys(NJ),Mg="NaN";function ALe(t,e){return t*NJ[e]}class zs{static parse(e){var n,[,r,i]=(n=ELe.exec(e))!==null&&n!==void 0?n:[];return new zs(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Xs(e)&&(this.unit=""),n!==""&&!MLe.test(n)&&(this.num=NaN,this.unit=""),TLe.includes(n)&&(this.num=ALe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new zs(NaN,""):new zs(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new zs(NaN,""):new zs(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new zs(NaN,""):new zs(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new zs(NaN,""):new zs(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Xs(this.num)}}function kJ(t){if(t.includes(Mg))return Mg;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=PG.exec(e))!==null&&n!==void 0?n:[],o=zs.parse(r??""),l=zs.parse(s??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Mg;e=e.replace(PG,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,h,p]=(u=jG.exec(e))!==null&&u!==void 0?u:[],m=zs.parse(d??""),b=zs.parse(p??""),y=h==="+"?m.add(b):m.subtract(b);if(y.isNaN())return Mg;e=e.replace(jG,y.toString())}return e}var DG=/\(([^()]*)\)/;function CLe(t){for(var e=t,n;(n=DG.exec(e))!=null;){var[,r]=n;e=e.replace(DG,kJ(r))}return e}function PLe(t){var e=t.replace(/\s+/g,"");return e=CLe(e),e=kJ(e),e}function jLe(t){try{return PLe(t)}catch{return Mg}}function rP(t){var e=jLe(t.slice(5,-1));return e===Mg?"":e}var DLe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],RLe=["dx","dy","angle","className","breakAll"];function RD(){return RD=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},RD.apply(null,arguments)}function RG(t,e){if(t==null)return{};var n,r,i=OLe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function OLe(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 MJ=/[ \f\n\r\t\v\u2028\u2029]+/,EJ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Jr(e)||(n?i=e.toString().split(""):i=e.toString().split(MJ));var s=i.map(l=>({word:l,width:C0(l,r).width})),o=n?0:C0(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:o}}catch{return null}};function LLe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var TJ=(t,e,n,r)=>t.reduce((i,s)=>{var{word:o,width:l}=s,c=i[i.length-1];if(c&&l!=null&&(e==null||r||c.width+l+n<Number(e)))c.words.push(o),c.width+=l+n;else{var u={words:[o],width:l};i.push(u)}return i},[]),AJ=t=>t.reduce((e,n)=>e.width>n.width?e:n),FLe="…",OG=(t,e,n,r,i,s,o,l)=>{var c=t.slice(0,e),u=EJ({breakAll:n,style:r,children:c+FLe});if(!u)return[!1,[]];var d=TJ(u.wordsWithComputedWidth,s,o,l),h=d.length>i||AJ(d).width>Number(s);return[h,d]},ILe=(t,e,n,r,i)=>{var{maxLines:s,children:o,style:l,breakAll:c}=t,u=Ht(s),d=String(o),h=TJ(e,r,n,i);if(!u||i)return h;var p=h.length>s||AJ(h).width>Number(r);if(!p)return h;for(var m=0,b=d.length-1,y=0,x;m<=b&&y<=d.length-1;){var v=Math.floor((m+b)/2),S=v-1,[N,T]=OG(d,S,c,l,s,r,n,i),[M]=OG(d,v,c,l,s,r,n,i);if(!N&&!M&&(m=v+1),N&&M&&(b=v-1),!N&&M){x=T;break}y++}return x||h},LG=t=>{var e=Jr(t)?[]:t.toString().split(MJ);return[{words:e,width:void 0}]},zLe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:o}=t;if((e||n)&&!Db.isSsr){var l,c,u=EJ({breakAll:s,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:h}=u;l=d,c=h}else return LG(r);return ILe({breakAll:s,children:r,maxLines:o,style:i},l,c,e,!!n)}return LG(r)},CJ="#808080",ULe={angle:0,breakAll:!1,capHeight:"0.71em",fill:CJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},AM=_.forwardRef((t,e)=>{var n=ui(t,ULe),{x:r,y:i,lineHeight:s,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,h=RG(n,DLe),p=_.useMemo(()=>zLe({breakAll:h.breakAll,children:h.children,maxLines:h.maxLines,scaleToFit:c,style:h.style,width:h.width}),[h.breakAll,h.children,h.maxLines,c,h.style,h.width]),{dx:m,dy:b,angle:y,className:x,breakAll:v}=h,S=RG(h,RLe);if(!fl(r)||!fl(i)||p.length===0)return null;var N=Number(r)+(Ht(m)?m:0),T=Number(i)+(Ht(b)?b:0);if(!_r(N)||!_r(T))return null;var M;switch(d){case"start":M=rP("calc(".concat(o,")"));break;case"middle":M=rP("calc(".concat((p.length-1)/2," * -").concat(s," + (").concat(o," / 2))"));break;default:M=rP("calc(".concat(p.length-1," * -").concat(s,")"));break}var A=[];if(c){var k=p[0].width,{width:R}=h;A.push("scale(".concat(Ht(R)&&Ht(k)?R/k:1,")"))}return y&&A.push("rotate(".concat(y,", ").concat(N,", ").concat(T,")")),A.length&&(S.transform=A.join(" ")),_.createElement("text",RD({},Ha(S),{ref:e,x:N,y:T,className:tr("recharts-text",x),textAnchor:u,fill:l.includes("url")?CJ:l}),p.map((C,P)=>{var U=C.words.join(v?"":" ");return _.createElement("tspan",{x:N,dy:P===0?M:s,key:"".concat(U,"-").concat(P)},U)}))});AM.displayName="Text";var BLe=["labelRef"];function HLe(t,e){if(t==null)return{};var n,r,i=$Le(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function $Le(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 FG(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 Mi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FG(Object(n),!0).forEach(function(r){VLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VLe(t,e,n){return(e=GLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GLe(t){var e=qLe(t,"string");return typeof e=="symbol"?e:e+""}function qLe(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 _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)}var PJ=_.createContext(null),jJ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o,children:l}=t,c=_.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o}),[e,n,r,i,s,o]);return _.createElement(PJ.Provider,{value:c},l)},DJ=()=>{var t=_.useContext(PJ),e=nv();return t||QY(e)},WLe=_.createContext(null),KLe=()=>{var t=_.useContext(WLe),e=zt(_Z);return t||e},XLe=t=>{var{value:e,formatter:n}=t,r=Jr(t.children)?e:t.children;return typeof n=="function"?n(r):r},p4=t=>t!=null&&typeof t=="function",YLe=(t,e)=>{var n=wa(e-t),r=Math.min(Math.abs(e-t),360);return n*r},QLe=(t,e,n,r,i)=>{var{offset:s,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:h,endAngle:p,clockWise:m}=i,b=(u+d)/2,y=YLe(h,p),x=y>=0?1:-1,v,S;switch(e){case"insideStart":v=h+x*s,S=m;break;case"insideEnd":v=p-x*s,S=!m;break;case"end":v=p+x*s,S=m;break;default:throw new Error("Unsupported position ".concat(e))}S=y<=0?S:!S;var N=Hi(l,c,b,v),T=Hi(l,c,b,v+(S?1:-1)*359),M="M".concat(N.x,",").concat(N.y,`
- A`).concat(b,",").concat(b,",0,1,").concat(S?0:1,`,
- `).concat(T.x,",").concat(T.y),A=Jr(t.id)?dy("recharts-radial-line-"):t.id;return _.createElement("text",_u({},r,{dominantBaseline:"central",className:tr("recharts-radial-bar-label",o)}),_.createElement("defs",null,_.createElement("path",{id:A,d:M})),_.createElement("textPath",{xlinkHref:"#".concat(A)},n))},ZLe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:h}=Hi(r,i,o+e,u);return{x:d,y:h,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=(s+o)/2,{x:m,y:b}=Hi(r,i,p,u);return{x:m,y:b,textAnchor:"middle",verticalAnchor:"middle"}},OD=t=>"cx"in t&&Ht(t.cx),JLe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!OD(n)&&(s=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,h=o,p=o+(c-u)/2,m=(h+p)/2,b=(c+u)/2,y=h+c/2,x=d>=0?1:-1,v=x*r,S=x>0?"end":"start",N=x>0?"start":"end",T=c>=0?1:-1,M=T*r,A=T>0?"end":"start",k=T>0?"start":"end";if(i==="top"){var R={x:h+c/2,y:l-v,textAnchor:"middle",verticalAnchor:S};return Mi(Mi({},R),s?{height:Math.max(l-s.y,0),width:c}:{})}if(i==="bottom"){var C={x:p+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:N};return Mi(Mi({},C),s?{height:Math.max(s.y+s.height-(l+d),0),width:u}:{})}if(i==="left"){var P={x:m-M,y:l+d/2,textAnchor:A,verticalAnchor:"middle"};return Mi(Mi({},P),s?{width:Math.max(P.x-s.x,0),height:d}:{})}if(i==="right"){var U={x:m+b+M,y:l+d/2,textAnchor:k,verticalAnchor:"middle"};return Mi(Mi({},U),s?{width:Math.max(s.x+s.width-U.x,0),height:d}:{})}var F=s?{width:b,height:d}:{};return i==="insideLeft"?Mi({x:m+M,y:l+d/2,textAnchor:k,verticalAnchor:"middle"},F):i==="insideRight"?Mi({x:m+b-M,y:l+d/2,textAnchor:A,verticalAnchor:"middle"},F):i==="insideTop"?Mi({x:h+c/2,y:l+v,textAnchor:"middle",verticalAnchor:N},F):i==="insideBottom"?Mi({x:p+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:S},F):i==="insideTopLeft"?Mi({x:h+M,y:l+v,textAnchor:k,verticalAnchor:N},F):i==="insideTopRight"?Mi({x:h+c-M,y:l+v,textAnchor:A,verticalAnchor:N},F):i==="insideBottomLeft"?Mi({x:p+M,y:l+d-v,textAnchor:k,verticalAnchor:S},F):i==="insideBottomRight"?Mi({x:p+u-M,y:l+d-v,textAnchor:A,verticalAnchor:S},F):i&&typeof i=="object"&&(Ht(i.x)||Xu(i.x))&&(Ht(i.y)||Xu(i.y))?Mi({x:o+as(i.x,b),y:l+as(i.y,d),textAnchor:"end",verticalAnchor:"end"},F):Mi({x:y,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},F)},e4e={angle:0,offset:5,zIndex:wi.label,position:"middle",textBreakAll:!1};function Zd(t){var e=ui(t,e4e),{viewBox:n,position:r,value:i,children:s,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=KLe(),h=DJ(),p=r==="center"?h:d??h,m,b,y;if(n==null?m=p:OD(n)?m=n:m=QY(n),!m||Jr(i)&&Jr(s)&&!_.isValidElement(o)&&typeof o!="function")return null;var x=Mi(Mi({},e),{},{viewBox:m});if(_.isValidElement(o)){var{labelRef:v}=x,S=HLe(x,BLe);return _.cloneElement(o,S)}if(typeof o=="function"){if(b=_.createElement(o,x),_.isValidElement(b))return b}else b=XLe(e);var N=Ha(e);if(OD(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return QLe(e,r,b,N,m);y=ZLe(m,e.offset,e.position)}else y=JLe(e,m);return _.createElement(ls,{zIndex:e.zIndex},_.createElement(AM,_u({ref:u,className:tr("recharts-label",l)},N,y,{textAnchor:LLe(N.textAnchor)?N.textAnchor:y.textAnchor,breakAll:c}),b))}Zd.displayName="Label";var t4e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?_.createElement(Zd,_u({key:"label-implicit"},r)):fl(t)?_.createElement(Zd,_u({key:"label-implicit",value:t},r)):_.isValidElement(t)?t.type===Zd?_.cloneElement(t,Mi({key:"label-implicit"},r)):_.createElement(Zd,_u({key:"label-implicit",content:t},r)):p4(t)?_.createElement(Zd,_u({key:"label-implicit",content:t},r)):t&&typeof t=="object"?_.createElement(Zd,_u({},t,{key:"label-implicit"},r)):null};function RJ(t){var{label:e,labelRef:n}=t,r=DJ();return t4e(e,r,n)||null}var iP={},aP={},IG;function n4e(){return IG||(IG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(aP)),aP}var sP={},zG;function r4e(){return zG||(zG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(sP)),sP}var UG;function i4e(){return UG||(UG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=n4e(),n=r4e(),r=$O();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(iP)),iP}var oP,BG;function a4e(){return BG||(BG=1,oP=i4e().last),oP}var s4e=a4e();const o4e=gl(s4e);var l4e=["valueAccessor"],c4e=["dataKey","clockWise","id","textBreakAll","zIndex"];function sN(){return sN=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},sN.apply(null,arguments)}function HG(t,e){if(t==null)return{};var n,r,i=u4e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function u4e(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 d4e=t=>Array.isArray(t.value)?o4e(t.value):t.value,OJ=_.createContext(void 0),g4=OJ.Provider,LJ=_.createContext(void 0),h4e=LJ.Provider;function f4e(){return _.useContext(OJ)}function m4e(){return _.useContext(LJ)}function W1(t){var{valueAccessor:e=d4e}=t,n=HG(t,l4e),{dataKey:r,clockWise:i,id:s,textBreakAll:o,zIndex:l}=n,c=HG(n,c4e),u=f4e(),d=m4e(),h=u||d;return!h||!h.length?null:_.createElement(ls,{zIndex:l??wi.label},_.createElement(ci,{className:"recharts-label-list"},h.map((p,m)=>{var b,y=Jr(r)?e(p,m):wr(p&&p.payload,r),x=Jr(s)?{}:{id:"".concat(s,"-").concat(m)};return _.createElement(Zd,sN({key:"label-".concat(m)},Ha(p),c,x,{fill:(b=n.fill)!==null&&b!==void 0?b:p.fill,parentViewBox:p.parentViewBox,value:y,textBreakAll:o,viewBox:p.viewBox,index:m,zIndex:0}))})))}W1.displayName="LabelList";function CM(t){var{label:e}=t;return e?e===!0?_.createElement(W1,{key:"labelList-implicit"}):_.isValidElement(e)||p4(e)?_.createElement(W1,{key:"labelList-implicit",content:e}):typeof e=="object"?_.createElement(W1,sN({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function LD(){return LD=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},LD.apply(null,arguments)}var FJ=t=>{var{cx:e,cy:n,r,className:i}=t,s=tr("recharts-dot",i);return Ht(e)&&Ht(n)&&Ht(r)?_.createElement("circle",LD({},ks(t),HO(t),{className:s,cx:e,cy:n,r})):null},IJ=t=>t.graphicalItems.polarItems,p4e=st([si,uv],zL),PM=st([IJ,di,p4e],UL),g4e=st([PM],BL),jM=st([g4e,AL],HL),b4e=st([jM,di,PM],VL);st([jM,di,PM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,o=wr(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:wr(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var $G=()=>{},x4e=st([jM,di,PM,kM,si],KL),y4e=st([di,qL,WL,$G,x4e,$G,Gn,si],XL),zJ=st([di,Gn,jM,b4e,cv,si,y4e],YL),v4e=st([zJ,di,Bb],JL);st([di,zJ,v4e,si],t4);var w4e={radiusAxis:{},angleAxis:{}},UJ=Ys({name:"polarAxis",initialState:w4e,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:vQe,removeRadiusAxis:wQe,addAngleAxis:_Qe,removeAngleAxis:SQe}=UJ.actions,_4e=UJ.reducer;function VG(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 GG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VG(Object(n),!0).forEach(function(r){S4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function S4e(t,e,n){return(e=N4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function N4e(t){var e=k4e(t,"string");return typeof e=="symbol"?e:e+""}function k4e(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 M4e=(t,e)=>e,b4=st([IJ,M4e],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),E4e=[],x4=(t,e,n)=>n?.length===0?E4e:n,BJ=st([AL,b4,x4],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(s=>GG(GG({},e.presentationProps),s.props))),i!=null)return i}}),T4e=st([BJ,b4,x4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,o=wr(r,e.nameKey,e.name),l;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:$h(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),A4e=st([BJ,b4,x4,aa],(t,e,n,r)=>{if(!(e==null||t==null))return CFe({offset:r,pieSettings:e,displayedData:t,cells:n})}),lP={exports:{}},Er={};var qG;function C4e(){if(qG)return Er;qG=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function b(y){if(typeof y=="object"&&y!==null){var x=y.$$typeof;switch(x){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case p:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case h:case d:return y;case s:return y;default:return x}}case e:return x}}}return Er.ContextConsumer=s,Er.ContextProvider=o,Er.Element=t,Er.ForwardRef=l,Er.Fragment=n,Er.Lazy=h,Er.Memo=d,Er.Portal=e,Er.Profiler=i,Er.StrictMode=r,Er.Suspense=c,Er.SuspenseList=u,Er.isContextConsumer=function(y){return b(y)===s},Er.isContextProvider=function(y){return b(y)===o},Er.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},Er.isForwardRef=function(y){return b(y)===l},Er.isFragment=function(y){return b(y)===n},Er.isLazy=function(y){return b(y)===h},Er.isMemo=function(y){return b(y)===d},Er.isPortal=function(y){return b(y)===e},Er.isProfiler=function(y){return b(y)===i},Er.isStrictMode=function(y){return b(y)===r},Er.isSuspense=function(y){return b(y)===c},Er.isSuspenseList=function(y){return b(y)===u},Er.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===c||y===u||typeof y=="object"&&y!==null&&(y.$$typeof===h||y.$$typeof===d||y.$$typeof===o||y.$$typeof===s||y.$$typeof===l||y.$$typeof===m||y.getModuleId!==void 0)},Er.typeOf=b,Er}var WG;function P4e(){return WG||(WG=1,lP.exports=C4e()),lP.exports}var j4e=P4e(),KG=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",XG=null,cP=null,HJ=t=>{if(t===XG&&Array.isArray(cP))return cP;var e=[];return _.Children.forEach(t,n=>{Jr(n)||(j4e.isFragment(n)?e=e.concat(HJ(n.props.children)):e.push(n))}),cP=e,XG=t,e};function y4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>KG(i)):r=[KG(e)],HJ(t).forEach(i=>{var s=km(i,"type.displayName")||km(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var v4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,uP={},YG;function D4e(){return YG||(YG=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})(uP)),uP}var dP,QG;function R4e(){return QG||(QG=1,dP=D4e().isPlainObject),dP}var O4e=R4e();const L4e=gl(O4e);function ZG(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 JG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZG(Object(n),!0).forEach(function(r){F4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function F4e(t,e,n){return(e=I4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function I4e(t){var e=z4e(t,"string");return typeof e=="symbol"?e:e+""}function z4e(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 oN(){return oN=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},oN.apply(null,arguments)}var eq=(t,e,n,r,i)=>{var s=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-s/2,",").concat(e+i),o+="L ".concat(t+n-s/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},U4e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},B4e=t=>{var e=ui(t,U4e),{x:n,y:r,upperWidth:i,lowerWidth:s,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:h}=e,p=_.useRef(null),[m,b]=_.useState(-1),y=_.useRef(i),x=_.useRef(s),v=_.useRef(o),S=_.useRef(n),N=_.useRef(r),T=Ob(t,"trapezoid-");if(_.useEffect(()=>{if(p.current&&p.current.getTotalLength)try{var D=p.current.getTotalLength();D&&b(D)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||o!==+o||i===0&&s===0||o===0)return null;var M=tr("recharts-trapezoid",l);if(!h)return _.createElement("g",null,_.createElement("path",oN({},Ha(e),{className:M,d:eq(n,r,i,s,o)})));var A=y.current,k=x.current,R=v.current,C=S.current,P=N.current,U="0px ".concat(m===-1?1:m,"px"),F="".concat(m,"px 0px"),B=uQ(["strokeDasharray"],u,c);return _.createElement(Rb,{animationId:T,key:T,canBegin:m>0,duration:u,easing:c,isActive:h,begin:d},D=>{var $=pr(A,i,D),G=pr(k,s,D),I=pr(R,o,D),K=pr(C,n,D),Q=pr(P,r,D);p.current&&(y.current=$,x.current=G,v.current=I,S.current=K,N.current=Q);var se=D>0?{transition:B,strokeDasharray:F}:{strokeDasharray:U};return _.createElement("path",oN({},Ha(e),{className:M,d:eq(K,Q,$,G,I),ref:p,style:JG(JG({},se),e.style)}))})},H4e=["option","shapeType","propTransformer","activeClassName"];function $4e(t,e){if(t==null)return{};var n,r,i=V4e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function V4e(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 tq(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function lN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tq(Object(n),!0).forEach(function(r){G4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function G4e(t,e,n){return(e=q4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q4e(t){var e=W4e(t,"string");return typeof e=="symbol"?e:e+""}function W4e(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 K4e(t,e){return lN(lN({},e),t)}function X4e(t,e){return t==="symbols"}function nq(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return _.createElement(mQ,n);case"trapezoid":return _.createElement(B4e,n);case"sector":return _.createElement(xQ,n);case"symbols":if(X4e(e))return _.createElement(BO,n);break;case"curve":return _.createElement(Ug,n);default:return null}}function Y4e(t){return _.isValidElement(t)?t.props:t}function w4(t){var{option:e,shapeType:n,propTransformer:r=K4e,activeClassName:i="recharts-active-shape"}=t,s=$4e(t,H4e),o;if(_.isValidElement(e))o=_.cloneElement(e,lN(lN({},s),Y4e(e)));else if(typeof e=="function")o=e(s,s.index);else if(L4e(e)&&typeof e!="boolean"){var l=r(e,s);o=_.createElement(nq,{shapeType:n,elementProps:l})}else{var c=s;o=_.createElement(nq,{shapeType:n,elementProps:c})}return s.isActive?_.createElement(ci,{className:i},o):o}var _4=(t,e,n)=>{var r=Br();return(i,s)=>o=>{t?.(i,s,o),r(JZ({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},S4=t=>{var e=Br();return(n,r)=>i=>{t?.(n,r,i),e(dRe())}},N4=(t,e,n)=>{var r=Br();return(i,s)=>o=>{t?.(i,s,o),r(hRe({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function DM(t){var{tooltipEntrySettings:e}=t,n=Br(),r=sa(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(oRe(e)):i.current!==e&&n(lRe({prev:i.current,next:e})),i.current=e)},[e,n,r]),_.useLayoutEffect(()=>()=>{i.current&&(n(cRe(i.current)),i.current=null)},[n]),null}function k4(t){var{legendPayload:e}=t,n=Br(),r=sa(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(sQ(e)):i.current!==e&&n(oQ({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(lQ(i.current)),i.current=null)},[n]),null}function Q4e(t){var{legendPayload:e}=t,n=Br(),r=zt(Gn),i=_.useRef(null);return _.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(sQ(e)):i.current!==e&&n(oQ({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(lQ(i.current)),i.current=null)},[n]),null}var hP,Z4e=()=>{var[t]=_.useState(()=>dy("uid-"));return t},J4e=(hP=rse.useId)!==null&&hP!==void 0?hP:Z4e;function $J(t,e){var n=J4e();return e||(t?"".concat(t,"-").concat(n):n)}var eFe=_.createContext(void 0),RM=t=>{var{id:e,type:n,children:r}=t,i=$J("recharts-".concat(n),e);return _.createElement(eFe.Provider,{value:i},r(i))},tFe={cartesianItems:[],polarItems:[]},VJ=Ys({name:"graphicalItems",initialState:tFe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:ni()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ul(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:ni()},removeCartesianGraphicalItem:{reducer(t,e){var n=Ul(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:ni()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:ni()},removePolarGraphicalItem:{reducer(t,e){var n=Ul(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:ni()}}}),{addCartesianGraphicalItem:nFe,replaceCartesianGraphicalItem:rFe,removeCartesianGraphicalItem:iFe,addPolarGraphicalItem:aFe,removePolarGraphicalItem:sFe}=VJ.actions,oFe=VJ.reducer,lFe=t=>{var e=Br(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(nFe(t)):n.current!==t&&e(rFe({prev:n.current,next:t})),n.current=t},[e,t]),_.useLayoutEffect(()=>()=>{n.current&&(e(iFe(n.current)),n.current=null)},[e]),null},M4=_.memo(lFe);function cFe(t){var e=Br();return _.useLayoutEffect(()=>(e(aFe(t)),()=>{e(sFe(t))}),[e,t]),null}var uFe=["key"],dFe=["onMouseEnter","onClick","onMouseLeave"],hFe=["id"],fFe=["id"];function rq(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 bi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rq(Object(n),!0).forEach(function(r){mFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mFe(t,e,n){return(e=pFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pFe(t){var e=gFe(t,"string");return typeof e=="symbol"?e:e+""}function gFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Uh(){return Uh=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},Uh.apply(null,arguments)}function OM(t,e){if(t==null)return{};var n,r,i=bFe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function bFe(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 xFe(t){var e=_.useMemo(()=>y4(t.children,vv),[t.children]),n=zt(r=>T4e(r,t.id,e));return n==null?null:_.createElement(Q4e,{legendPayload:n})}var yFe=_.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:o,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(h=>h.tooltipPayload),positions:r.map(h=>h.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:o,dataKey:e,nameKey:n,name:$h(l,e),hide:c,type:u,color:o,unit:""}};return _.createElement(DM,{tooltipEntrySettings:d})}),vFe=(t,e)=>t>e?"start":t<e?"end":"middle",wFe=(t,e,n)=>as(typeof e=="function"?e(t):e,n,n*.8),_Fe=(t,e,n)=>{var{top:r,left:i,width:s,height:o}=e,l=pQ(s,o),c=i+as(t.cx,s,s/2),u=r+as(t.cy,o,o/2),d=as(t.innerRadius,l,0),h=wFe(n,t.outerRadius,l),p=t.maxRadius||Math.sqrt(s*s+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:h,maxRadius:p}},SFe=(t,e)=>{var n=wa(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function NFe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var kFe=(t,e)=>{if(_.isValidElement(t))return _.cloneElement(t,e);if(typeof t=="function")return t(e);var n=tr("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=OM(e,uFe);return _.createElement(Ug,Uh({},i,{type:"linear",className:n}))},MFe=(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=tr("recharts-pie-label-text",NFe(t));return _.createElement(AM,Uh({},e,{alignmentBaseline:"middle",className:i}),r)};function EFe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:o}=n;if(!r||!i||!e)return null;var l=ks(n),c=Nm(i),u=Nm(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,h=e.map((p,m)=>{var b=(p.startAngle+p.endAngle)/2,y=Hi(p.cx,p.cy,p.outerRadius+d,b),x=bi(bi(bi(bi({},l),p),{},{stroke:"none"},c),{},{index:m,textAnchor:vFe(y.x,p.cx)},y),v=bi(bi(bi(bi({},l),p),{},{fill:"none",stroke:p.fill},u),{},{index:m,points:[Hi(p.cx,p.cy,p.outerRadius,b),y],key:"line"});return _.createElement(ls,{zIndex:wi.label,key:"label-".concat(p.startAngle,"-").concat(p.endAngle,"-").concat(p.midAngle,"-").concat(m)},_.createElement(ci,null,s&&kFe(s,v),MFe(i,x,wr(p,o))))});return _.createElement(ci,{className:"recharts-pie-labels"},h)}function TFe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?_.createElement(CM,{label:i}):_.createElement(EFe,{sectors:e,props:n,showLabels:r})}function AFe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:o}=t,l=zt(zh),c=zt(u4),u=zt(QRe),{onMouseEnter:d,onClick:h,onMouseLeave:p}=i,m=OM(i,dFe),b=_4(d,i.dataKey,o),y=S4(p),x=N4(h,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 N=u==null||u===o,T=String(S)===l&&(c==null||i.dataKey===c)&&N,M=l?r:null,A=n&&T?n:M,k=bi(bi({},v),{},{stroke:v.stroke,tabIndex:-1,[qY]:S,[WY]:i.dataKey});return _.createElement(ci,Uh({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},Qy(m,v,S),{onMouseEnter:b(v,S),onMouseLeave:y(v,S),onClick:x(v,S)}),_.createElement(w4,Uh({option:s??A,index:S,shapeType:"sector",isActive:T},k)))}))}function CFe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:h}=n,p=Math.abs(n.minAngle),m=SFe(l,c),b=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,x=r.filter(A=>wr(A,u,0)!==0).length,v=(b>=360?x:x-1)*y,S=b-x*p-v,N=r.reduce((A,k)=>{var R=wr(k,u,0);return A+(Ht(R)?R:0)},0),T;if(N>0){var M;T=r.map((A,k)=>{var R=wr(A,u,0),C=wr(A,d,k),P=_Fe(n,s,A),U=(Ht(R)?R:0)/N,F,B=bi(bi({},A),i&&i[k]&&i[k].props);k?F=M.endAngle+wa(m)*y*(R!==0?1:0):F=l;var D=F+wa(m)*((R!==0?p:0)+U*S),$=(F+D)/2,G=(P.innerRadius+P.outerRadius)/2,I=[{name:C,value:R,payload:B,dataKey:u,type:h}],K=Hi(P.cx,P.cy,G,$);return M=bi(bi(bi(bi({},n.presentationProps),{},{percent:U,cornerRadius:typeof o=="string"?parseFloat(o):o,name:C,tooltipPayload:I,midAngle:$,middleRadius:G,tooltipPosition:K},B),P),{},{value:R,dataKey:u,startAngle:F,endAngle:D,payload:B,paddingAngle:wa(m)*y}),M})}return T}function PFe(t){var{showLabels:e,sectors:n,children:r}=t,i=_.useMemo(()=>!e||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,e]);return _.createElement(h4e,{value:e?i:void 0},r)}function jFe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:h,onAnimationEnd:p}=e,m=Ob(e,"recharts-pie-"),b=n.current,[y,x]=_.useState(!1),v=_.useCallback(()=>{typeof p=="function"&&p(),x(!1)},[p]),S=_.useCallback(()=>{typeof h=="function"&&h(),x(!0)},[h]);return _.createElement(PFe,{showLabels:!y,sectors:i},_.createElement(Rb,{animationId:m,begin:o,duration:l,isActive:s,easing:c,onAnimationStart:S,onAnimationEnd:v,key:m},N=>{var T=[],M=i&&i[0],A=M?.startAngle;return i?.forEach((k,R)=>{var C=b&&b[R],P=R>0?km(k,"paddingAngle",0):0;if(C){var U=pr(C.endAngle-C.startAngle,k.endAngle-k.startAngle,N),F=bi(bi({},k),{},{startAngle:A+P,endAngle:A+U+P});T.push(F),A=F.endAngle}else{var{endAngle:B,startAngle:D}=k,$=pr(0,B-D,N),G=bi(bi({},k),{},{startAngle:A+P,endAngle:A+$+P});T.push(G),A=G.endAngle}}),n.current=T,_.createElement(ci,null,_.createElement(AFe,{sectors:T,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),_.createElement(TFe,{showLabels:!y,sectors:i,props:e}),e.children)}var DFe={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:wi.area};function RFe(t){var{id:e}=t,n=OM(t,hFe),{hide:r,className:i,rootTabIndex:s}=t,o=_.useMemo(()=>y4(t.children,vv),[t.children]),l=zt(d=>A4e(d,e,o)),c=_.useRef(null),u=tr("recharts-pie",i);return r||l==null?(c.current=null,_.createElement(ci,{tabIndex:s,className:u})):_.createElement(ls,{zIndex:t.zIndex},_.createElement(yFe,{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(ci,{tabIndex:s,className:u},_.createElement(jFe,{props:bi(bi({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function GJ(t){var e=ui(t,DFe),{id:n}=e,r=OM(e,fFe),i=ks(r);return _.createElement(RM,{id:n,type:"pie"},s=>_.createElement(_.Fragment,null,_.createElement(cFe,{type:"pie",id:s,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),_.createElement(xFe,Uh({},r,{id:s})),_.createElement(RFe,Uh({},r,{id:s}))))}GJ.displayName="Pie";var OFe=["points"];function iq(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 fP(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?iq(Object(n),!0).forEach(function(r){LFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):iq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LFe(t,e,n){return(e=FFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FFe(t){var e=IFe(t,"string");return typeof e=="symbol"?e:e+""}function IFe(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 cN(){return cN=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},cN.apply(null,arguments)}function zFe(t,e){if(t==null)return{};var n,r,i=UFe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function UFe(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 BFe(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=tr(r,typeof e!="boolean"?e.className:""),s=n??{},{points:o}=s,l=zFe(s,OFe);return _.createElement(FJ,cN({},l,{className:i}))}function HFe(t,e){return t==null?!1:e?!0:t.length===1}function qJ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:o,needClip:l,clipPathId:c,zIndex:u=wi.scatter}=t;if(!HFe(e,n))return null;var d=v4(n),h=yMe(n),p=e.map((b,y)=>{var x,v,S=fP(fP(fP({r:3},o),h),{},{index:y,cx:(x=b.x)!==null&&x!==void 0?x:void 0,cy:(v=b.y)!==null&&v!==void 0?v:void 0,dataKey:s,value:b.value,payload:b.payload,points:e});return _.createElement(BFe,{key:"dot-".concat(y),option:n,dotProps:S,className:i})}),m={};return l&&c!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),_.createElement(ls,{zIndex:u},_.createElement(ci,cN({className:r},m),p))}function aq(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 sq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aq(Object(n),!0).forEach(function(r){$Fe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Fe(t,e,n){return(e=VFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VFe(t){var e=GFe(t,"string");return typeof e=="symbol"?e:e+""}function GFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var qFe={xAxis:{},yAxis:{},zAxis:{}},WJ=Ys({name:"cartesianAxis",initialState:qFe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:ni()},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:ni()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:ni()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:ni()},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:ni()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:ni()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:ni()},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:ni()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:ni()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var s=i.widthHistory||[];if(s.length===3&&s[0]===s[2]&&r===s[1]&&r!==i.width&&Math.abs(r-s[0])<=1)return;var o=[...s,r].slice(-3);t.yAxis[n]=sq(sq({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:WFe,replaceXAxis:KFe,removeXAxis:XFe,addYAxis:YFe,replaceYAxis:QFe,removeYAxis:ZFe,addZAxis:NQe,replaceZAxis:kQe,removeZAxis:MQe,updateYAxisWidth:JFe}=WJ.actions,eIe=WJ.reducer,tIe=st([aa],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),nIe=st([tIe,rd,id],(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)}}),LM=()=>zt(nIe),rIe=()=>zt(nOe);function oq(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function mP(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oq(Object(n),!0).forEach(function(r){iIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iIe(t,e,n){return(e=aIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aIe(t){var e=sIe(t,"string");return typeof e=="symbol"?e:e+""}function sIe(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 oIe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:s,clipPath:o}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:s,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=mP(mP(mP({},l),Nm(i)),HO(i)),u;return _.isValidElement(i)?u=_.cloneElement(i,c):typeof i=="function"?u=i(c):u=_.createElement(FJ,c),_.createElement(ci,{className:"recharts-active-dot",clipPath:o},u)};function FD(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:o=wi.activeDot}=t,l=zt(zh),c=rIe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Jr(u)?null:_.createElement(ls,{zIndex:o},_.createElement(oIe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var lIe="Invariant failed";function cIe(t,e){throw new Error(lIe)}var uIe=["x","y"];function ID(){return ID=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},ID.apply(null,arguments)}function lq(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 i0(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lq(Object(n),!0).forEach(function(r){dIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dIe(t,e,n){return(e=hIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hIe(t){var e=fIe(t,"string");return typeof e=="symbol"?e:e+""}function fIe(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 mIe(t,e){if(t==null)return{};var n,r,i=pIe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function pIe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function gIe(t,e){var{x:n,y:r}=t,i=mIe(t,uIe),s="".concat(n),o=parseInt(s,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),h="".concat(e.width||i.width),p=parseInt(h,10);return i0(i0(i0(i0(i0({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:p,name:e.name,radius:e.radius})}function uN(t){return _.createElement(w4,ID({shapeType:"rectangle",propTransformer:gIe,activeClassName:"recharts-active-bar"},t))}var bIe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Ht(e))return e;var s=Ht(r)||Jr(r);return s?e(r,i):(s||cIe(),n)}},xIe={},KJ=Ys({name:"errorBars",initialState:xIe,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(s=>s.dataKey===r.dataKey&&s.direction===r.direction?i:s))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:EQe,replaceErrorBar:TQe,removeErrorBar:AQe}=KJ.actions,yIe=KJ.reducer,vIe=["children"];function wIe(t,e){if(t==null)return{};var n,r,i=_Ie(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _Ie(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 SIe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},NIe=_.createContext(SIe);function XJ(t){var{children:e}=t,n=wIe(t,vIe);return _.createElement(NIe.Provider,{value:n},e)}function FM(t,e){var n,r,i=zt(u=>Dc(u,t)),s=zt(u=>Rc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:ga.allowDataOverflow,l=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:ba.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function E4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=LM(),{needClipX:s,needClipY:o,needClip:l}=FM(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:h}=i;return _.createElement("clipPath",{id:"clipPath-".concat(r)},_.createElement("rect",{x:s?c:c-d/2,y:o?u:u-h/2,width:s?d:d*2,height:o?h:h*2}))}function kIe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&_r(t.zIndex)?t.zIndex:e}var pP={exports:{}},gP={};var cq;function MIe(){if(cq)return gP;cq=1;var t=Sb();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,o=t.useMemo,l=t.useDebugValue;return gP.useSyncExternalStoreWithSelector=function(c,u,d,h,p){var m=i(null);if(m.current===null){var b={hasValue:!1,value:null};m.current=b}else b=m.current;m=o(function(){function x(M){if(!v){if(v=!0,S=M,M=h(M),p!==void 0&&b.hasValue){var A=b.value;if(p(A,M))return N=A}return N=M}if(A=N,n(S,M))return A;var k=h(M);return p!==void 0&&p(A,k)?(S=M,A):(S=M,N=k)}var v=!1,S,N,T=d===void 0?null:d;return[function(){return x(u())},T===null?void 0:function(){return x(T())}]},[u,d,h,p]);var y=r(c,m[0],m[1]);return s(function(){b.hasValue=!0,b.value=y},[y]),l(y),y},gP}var uq;function EIe(){return uq||(uq=1,pP.exports=MIe()),pP.exports}EIe();function TIe(t){t()}function AIe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){TIe(()=>{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 dq={notify(){},get:()=>[]};function CIe(t,e){let n,r=dq,i=0,s=!1;function o(y){d();const x=r.subscribe(y);let v=!1;return()=>{v||(v=!0,x(),h())}}function l(){r.notify()}function c(){b.onStateChange&&b.onStateChange()}function u(){return s}function d(){i++,n||(n=t.subscribe(c),r=AIe())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=dq)}function p(){s||(s=!0,d())}function m(){s&&(s=!1,h())}const b={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:p,tryUnsubscribe:m,getListeners:()=>r};return b}var PIe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",jIe=PIe(),DIe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",RIe=DIe(),OIe=()=>jIe||RIe?_.useLayoutEffect:_.useEffect,LIe=OIe();function hq(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function FIe(t,e){if(hq(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])||!hq(t[n[i]],e[n[i]]))return!1;return!0}var IIe=Symbol.for("react-redux-context"),zIe=typeof globalThis<"u"?globalThis:{};function UIe(){if(!_.createContext)return{};const t=zIe[IIe]??=new Map;let e=t.get(_.createContext);return e||(e=_.createContext(null),t.set(_.createContext,e)),e}var BIe=UIe();function HIe(t){const{children:e,context:n,serverState:r,store:i}=t,s=_.useMemo(()=>{const c=CIe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=_.useMemo(()=>i.getState(),[i]);LIe(()=>{const{subscription:c}=s;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[s,o]);const l=n||BIe;return _.createElement(l.Provider,{value:s},e)}var $Ie=HIe,VIe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function GIe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function wv(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(VIe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!FIe(t[r],e[r]))return!1}else if(!GIe(t[r],e[r]))return!1;return!0}var qIe=["onMouseEnter","onMouseLeave","onClick"],WIe=["value","background","tooltipPosition"],KIe=["id"],XIe=["onMouseEnter","onClick","onMouseLeave"];function td(){return td=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},td.apply(null,arguments)}function fq(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 bs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fq(Object(n),!0).forEach(function(r){YIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YIe(t,e,n){return(e=QIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QIe(t){var e=ZIe(t,"string");return typeof e=="symbol"?e:e+""}function ZIe(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 dN(t,e){if(t==null)return{};var n,r,i=JIe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function JIe(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 e5e=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:$h(n,e),payload:t}]},t5e=_.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:$h(s,e),hide:o,type:c,color:i,unit:l}};return _.createElement(DM,{tooltipEntrySettings:u})});function n5e(t){var e=zt(zh),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=s,u=dN(s,qIe),d=_4(o,r),h=S4(l),p=N4(c,r);if(!i||n==null)return null;var m=Nm(i);return _.createElement(ls,{zIndex:kIe(i,wi.barBackground)},n.map((b,y)=>{var{value:x,background:v,tooltipPosition:S}=b,N=dN(b,WIe);if(!v)return null;var T=d(b,y),M=h(b,y),A=p(b,y),k=bs(bs(bs(bs(bs({option:i,isActive:String(y)===e},N),{},{fill:"#eee"},v),m),Qy(u,b,y)),{},{onMouseEnter:T,onMouseLeave:M,onClick:A,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return _.createElement(uN,td({key:"background-bar-".concat(y)},k))}))}function r5e(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(s=>{var o={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return bs(bs({},o),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:o,fill:s.fill})});return _.createElement(g4,{value:e?i:void 0},n)}function i5e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:o}=t,l=zt(zh),c=zt(u4),u=n&&String(s)===l&&(c==null||o===c),d=u?n:e;return u?_.createElement(ls,{zIndex:wi.activeBar},_.createElement(uN,td({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))):_.createElement(uN,td({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))}function a5e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return _.createElement(uN,td({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function s5e(t){var e,{data:n,props:r}=t,i=(e=ks(r))!==null&&e!==void 0?e:{},{id:s}=i,o=dN(i,KIe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:h,onMouseLeave:p}=r,m=dN(r,XIe),b=_4(d,c),y=S4(p),x=N4(h,c);return n?_.createElement(_.Fragment,null,n.map((v,S)=>_.createElement(ci,td({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(S),className:"recharts-bar-rectangle"},Qy(m,v,S),{onMouseEnter:b(v,S),onMouseLeave:y(v,S),onClick:x(v,S)}),u?_.createElement(i5e,{shape:l,activeBar:u,baseProps:o,entry:v,index:S,dataKey:c}):_.createElement(a5e,{shape:l,baseProps:o,entry:v,index:S,dataKey:c})))):null}function o5e(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,h=n.current,p=Ob(e,"recharts-bar-"),[m,b]=_.useState(!1),y=!m,x=_.useCallback(()=>{typeof u=="function"&&u(),b(!1)},[u]),v=_.useCallback(()=>{typeof d=="function"&&d(),b(!0)},[d]);return _.createElement(r5e,{showLabels:y,rects:r},_.createElement(Rb,{animationId:p,begin:o,duration:l,isActive:s,easing:c,onAnimationEnd:x,onAnimationStart:v,key:p},S=>{var N=S===1?r:r?.map((T,M)=>{var A=h&&h[M];if(A)return bs(bs({},T),{},{x:pr(A.x,T.x,S),y:pr(A.y,T.y,S),width:pr(A.width,T.width,S),height:pr(A.height,T.height,S)});if(i==="horizontal"){var k=pr(0,T.height,S),R=pr(T.stackedBarStart,T.y,S);return bs(bs({},T),{},{y:R,height:k})}var C=pr(0,T.width,S),P=pr(T.stackedBarStart,T.x,S);return bs(bs({},T),{},{width:C,x:P})});return S>0&&(n.current=N??null),N==null?null:_.createElement(ci,null,_.createElement(s5e,{props:e,data:N}))}),_.createElement(CM,{label:e.label}),e.children)}function l5e(t){var e=_.useRef(null);return _.createElement(o5e,{previousRectanglesRef:e,props:t})}var YJ=0,c5e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:wr(t,e)}};class u5e extends _.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=tr("recharts-bar",i),h=u;return _.createElement(ci,{className:d,id:u},l&&_.createElement("defs",null,_.createElement(E4,{clipPathId:h,xAxisId:s,yAxisId:o})),_.createElement(ci,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(h,")"):void 0},_.createElement(n5e,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),_.createElement(l5e,this.props)))}}var d5e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:YJ,xAxisId:0,yAxisId:0,zIndex:wi.bar};function h5e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:h}=FM(e,n),p=Um(),m=sa(),b=y4(t.children,vv),y=zt(S=>U5e(S,e,n,m,t.id,b));if(p!=="vertical"&&p!=="horizontal")return null;var x,v=y?.[0];return v==null||v.height==null||v.width==null?x=0:x=p==="vertical"?v.height/2:v.width/2,_.createElement(XJ,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:c5e,errorBarOffset:x},_.createElement(u5e,td({},t,{layout:p,needClip:h,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function f5e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:h,offset:p,cells:m,parentViewBox:b,dataStartIndex:y}=t,x=e==="horizontal"?l:o,v=d?x.scale.domain():null,S=LTe({numericAxis:x}),N=x.scale(S);return h.map((T,M)=>{var A,k,R,C,P,U;d?A=PTe(d[M+y],v):(A=wr(T,n),Array.isArray(A)||(A=[S,A]));var F=bIe(r,YJ)(A[1],M);if(e==="horizontal"){var B,[D,$]=[l.scale(A[0]),l.scale(A[1])];k=C$({axis:o,ticks:c,bandSize:s,offset:i.offset,entry:T,index:M}),R=(B=$??D)!==null&&B!==void 0?B:void 0,C=i.size;var G=D-$;if(P=Xs(G)?0:G,U={x:k,y:p.top,width:C,height:p.height},Math.abs(F)>0&&Math.abs(P)<Math.abs(F)){var I=wa(P||F)*(Math.abs(F)-Math.abs(P));R-=I,P+=I}}else{var[K,Q]=[o.scale(A[0]),o.scale(A[1])];if(k=K,R=C$({axis:l,ticks:u,bandSize:s,offset:i.offset,entry:T,index:M}),C=Q-K,P=i.size,U={x:p.left,y:R,width:p.width,height:P},Math.abs(F)>0&&Math.abs(C)<Math.abs(F)){var se=wa(C||F)*(Math.abs(F)-Math.abs(C));C+=se}}if(k==null||R==null||C==null||P==null)return null;var H=bs(bs({},T),{},{stackedBarStart:N,x:k,y:R,width:C,height:P,value:d?A:A[1],payload:T,background:U,tooltipPosition:{x:k+C/2,y:R+P/2},parentViewBox:b},m&&m[M]&&m[M].props);return H}).filter(Boolean)}function m5e(t){var e=ui(t,d5e),n=sa();return _.createElement(RM,{id:e.id,type:"bar"},r=>_.createElement(_.Fragment,null,_.createElement(k4,{legendPayload:e5e(e)}),_.createElement(t5e,{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(M4,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:VY(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),_.createElement(ls,{zIndex:e.zIndex},_.createElement(h5e,td({},e,{id:r})))))}var QJ=_.memo(m5e,wv);QJ.displayName="Bar";function mq(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 c1(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mq(Object(n),!0).forEach(function(r){p5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function p5e(t,e,n){return(e=g5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function g5e(t){var e=b5e(t,"string");return typeof e=="symbol"?e:e+""}function b5e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var x5e=(t,e)=>e,y5e=(t,e,n)=>n,v5e=(t,e,n,r)=>r,w5e=(t,e,n,r,i)=>i,_v=st([hv,w5e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),_5e=st([_v],t=>t?.maxBarSize),S5e=(t,e,n,r,i,s)=>s,pq=(t,e,n)=>{var r=n??t;if(!Jr(r))return as(r,e,0)},N5e=st([Gn,hv,x5e,y5e,v5e],(t,e,n,r,i)=>e.filter(s=>t==="horizontal"?s.xAxisId===n:s.yAxisId===r).filter(s=>s.isPanorama===i).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),k5e=(t,e,n,r)=>{var i=Gn(t);return i==="horizontal"?Ny(t,"yAxis",n,r):Ny(t,"xAxis",e,r)},M5e=(t,e,n)=>{var r=Gn(t);return r==="horizontal"?cG(t,"xAxis",e):cG(t,"yAxis",n)},E5e=(t,e,n)=>{var r={},i=t.filter(wM),s=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(o).map(u=>{var[d,h]=u,p=h.map(b=>b.dataKey),m=pq(e,n,h[0].barSize);return{stackId:d,dataKeys:p,barSize:m}}),c=s.map(u=>{var d=[u.dataKey].filter(p=>p!=null),h=pq(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:h}});return[...l,...c]},T5e=st([N5e,J3e,M5e],E5e),A5e=(t,e,n,r,i)=>{var s,o,l=_v(t,e,n,r,i);if(l!=null){var c=Gn(t),u=mZ(t),{maxBarSize:d}=l,h=Jr(d)?u:d,p,m;return c==="horizontal"?(p=Mc(t,"xAxis",e,r),m=kc(t,"xAxis",e,r)):(p=Mc(t,"yAxis",n,r),m=kc(t,"yAxis",n,r)),(s=(o=Lh(p,m,!0))!==null&&o!==void 0?o:h)!==null&&s!==void 0?s:0}},ZJ=(t,e,n,r)=>{var i=Gn(t),s,o;return i==="horizontal"?(s=Mc(t,"xAxis",e,r),o=kc(t,"xAxis",e,r)):(s=Mc(t,"yAxis",n,r),o=kc(t,"yAxis",n,r)),Lh(s,o)};function C5e(t,e,n,r,i){var s=r.length;if(!(s<1)){var o=as(t,n,0,!0),l,c=[];if(_r(r[0].barSize)){var u=!1,d=n/s,h=r.reduce((v,S)=>v+(S.barSize||0),0);h+=(s-1)*o,h>=n&&(h-=(s-1)*o,o=0),h>=n&&d>0&&(u=!0,d*=.9,h=s*d);var p=(n-h)/2>>0,m={offset:p-o,size:0};l=r.reduce((v,S)=>{var N,T={stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:m.offset+m.size+o,size:u?d:(N=S.barSize)!==null&&N!==void 0?N:0}},M=[...v,T];return m=M[M.length-1].position,M},c)}else{var b=as(e,n,0,!0);n-2*b-(s-1)*o<=0&&(o=0);var y=(n-2*b-(s-1)*o)/s;y>1&&(y>>=0);var x=_r(i)?Math.min(y,i):y;l=r.reduce((v,S,N)=>[...v,{stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:b+(y+o)*N+(y-x)/2,size:x}}],c)}return l}}var P5e=(t,e,n,r,i,s,o)=>{var l=Jr(o)?e:o,c=C5e(n,r,i!==s?i:s,t,l);return i!==s&&c!=null&&(c=c.map(u=>c1(c1({},u),{},{position:c1(c1({},u.position),{},{offset:u.position.offset-i/2})}))),c},j5e=st([T5e,mZ,Z3e,pZ,A5e,ZJ,_5e],P5e),D5e=(t,e,n,r)=>Mc(t,"xAxis",e,r),R5e=(t,e,n,r)=>Mc(t,"yAxis",n,r),O5e=(t,e,n,r)=>kc(t,"xAxis",e,r),L5e=(t,e,n,r)=>kc(t,"yAxis",n,r),F5e=st([j5e,_v],(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}}),I5e=(t,e)=>{var n=vM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:s}=i;if(s)return s.find(o=>o.key===n)}}}},z5e=st([k5e,_v],I5e),U5e=st([aa,JO,D5e,R5e,O5e,L5e,F5e,Gn,lv,ZJ,z5e,_v,S5e],(t,e,n,r,i,s,o,l,c,u,d,h,p)=>{var{chartData:m,dataStartIndex:b,dataEndIndex:y}=c;if(!(h==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||s==null||u==null)){var{data:x}=h,v;if(x!=null&&x.length>0?v=x:v=m?.slice(b,y+1),v!=null)return f5e({layout:l,barSettings:h,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:v,offset:t,cells:p,dataStartIndex:b})}}),JJ=t=>{var{chartData:e}=t,n=Br(),r=sa();return _.useEffect(()=>r?()=>{}:(n(_G(e)),()=>{n(_G(void 0))}),[e,n,r]),null},gq={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},eee=Ys({name:"brush",initialState:gq,reducers:{setBrushSettings(t,e){return e.payload==null?gq:e.payload}}}),{setBrushSettings:CQe}=eee.actions,B5e=eee.reducer;function bq(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 u1(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bq(Object(n),!0).forEach(function(r){tee(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tee(t,e,n){return(e=H5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H5e(t){var e=$5e(t,"string");return typeof e=="symbol"?e:e+""}function $5e(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 V5e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return{x:Math.min(n,i),y:Math.min(r,s),width:Math.abs(i-n),height:Math.abs(s-r)}},G5e=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return V5e({x:e,y:n},{x:r,y:i})};class IM{static create(e){return new IM(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var s=this.bandwidth?this.bandwidth():0;return this.scale(e)+s}default:return this.scale(e)}if(n){var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+o}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}tee(IM,"EPS",1e-4);var q5e=t=>{var e=Object.keys(t).reduce((n,r)=>u1(u1({},n),{},{[r]:IM.create(t[r])}),{});return u1(u1({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(s=>{var[o,l]=s;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function W5e(t){return(t%180+180)%180}var K5e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=W5e(i),o=s*Math.PI/180,l=Math.atan(r/n),c=o>l&&o<Math.PI-l?r/Math.sin(o):n/Math.cos(o);return Math.abs(c)},X5e={dots:[],areas:[],lines:[]},nee=Ys({name:"referenceElements",initialState:X5e,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Ul(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=Ul(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=Ul(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:PQe,removeDot:jQe,addArea:DQe,removeArea:RQe,addLine:Y5e,removeLine:Q5e}=nee.actions,Z5e=nee.reducer,ree=_.createContext(void 0),J5e=t=>{var{children:e}=t,[n]=_.useState("".concat(dy("recharts"),"-clip")),r=LM();if(r==null)return null;var{x:i,y:s,width:o,height:l}=r;return _.createElement(ree.Provider,{value:n},_.createElement("defs",null,_.createElement("clipPath",{id:n},_.createElement("rect",{x:i,y:s,height:l,width:o}))),e)},eze=()=>_.useContext(ree);function xq(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 yq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xq(Object(n),!0).forEach(function(r){tze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tze(t,e,n){return(e=nze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nze(t){var e=rze(t,"string");return typeof e=="symbol"?e:e+""}function rze(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 hN(){return hN=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},hN.apply(null,arguments)}var ize=(t,e)=>{var n;if(_.isValidElement(t))n=_.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!_r(e.x1)||!_r(e.y1)||!_r(e.x2)||!_r(e.y2))return null;n=_.createElement("line",hN({},e,{className:"recharts-reference-line-line"}))}return n},aze=(t,e,n,r,i,s)=>{var{x:o,width:l}=s,c=i.y.apply(t,{position:n});if(Xs(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},sze=(t,e,n,r,i,s)=>{var{y:o,height:l}=s,c=i.x.apply(t,{position:n});if(Xs(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},oze=(t,e,n,r)=>{var i=t.map(s=>r.apply(s,{position:n}));return e==="discard"&&i.some(s=>!r.isInRange(s))?null:i},lze=(t,e,n,r,i,s)=>{var{x:o,y:l,segment:c,ifOverflow:u}=s,d=fl(o),h=fl(l);return h?aze(l,u,n,i,t,e):d?sze(o,u,n,r,t,e):c!=null&&c.length===2?oze(c,u,n,t):null};function cze(t){var e=Br();return _.useEffect(()=>(e(Y5e(t)),()=>{e(Q5e(t))})),null}function uze(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,o=sa(),l=eze(),c=zt(A=>Dc(A,e)),u=zt(A=>Rc(A,n)),d=zt(A=>Ih(A,"xAxis",e,o)),h=zt(A=>Ih(A,"yAxis",n,o)),p=nv();if(!l||!p||c==null||u==null||d==null||h==null)return null;var m=q5e({x:d,y:h}),b=lze(m,p,t.position,c.orientation,u.orientation,t);if(!b)return null;var[{x:y,y:x},{x:v,y:S}]=b,N=s==="hidden"?"url(#".concat(l,")"):void 0,T=yq(yq({clipPath:N},Ha(t)),{},{x1:y,y1:x,x2:v,y2:S}),M=G5e({x1:y,y1:x,x2:v,y2:S});return _.createElement(ls,{zIndex:t.zIndex},_.createElement(ci,{className:tr("recharts-reference-line",i)},ize(r,T),_.createElement(jJ,hN({},M,{lowerWidth:M.width,upperWidth:M.width}),_.createElement(RJ,{label:t.label}),t.children)))}var dze={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:wi.line};function p0(t){var e=ui(t,dze);return _.createElement(_.Fragment,null,_.createElement(cze,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),_.createElement(uze,e))}p0.displayName="ReferenceLine";function iee(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e)n.push(t[r]);return n}function hze(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return K5e(r,n)}function fze(t,e,n){var r=n==="width",{x:i,y:s,width:o,height:l}=t;return e===1?{start:r?i:s,end:r?i+o:s+l}:{start:r?i+o:s+l,end:r?i:s}}function fN(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var s=n();return t*(e-t*s/2-r)>=0&&t*(e+t*s/2-i)<=0}function mze(t,e){return iee(t,e+1)}function pze(t,e,n,r,i){for(var s=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,h=function(){var b=r?.[c];if(b===void 0)return{v:iee(r,u)};var y=c,x,v=()=>(x===void 0&&(x=n(b,y)),x),S=b.coordinate,N=c===0||fN(t,S,v,d,l);N||(c=0,d=o,u+=1),N&&(d=S+t*(v()/2+i),c+=u)},p;u<=s.length;)if(p=h(),p)return p.v;return[]}function vq(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 Za(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vq(Object(n),!0).forEach(function(r){gze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gze(t,e,n){return(e=bze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bze(t){var e=xze(t,"string");return typeof e=="symbol"?e:e+""}function xze(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 yze(t,e,n,r,i){for(var s=(r||[]).slice(),o=s.length,{start:l}=e,{end:c}=e,u=function(p){var m=s[p],b,y=()=>(b===void 0&&(b=n(m,p)),b);if(p===o-1){var x=t*(m.coordinate+t*y()/2-c);s[p]=m=Za(Za({},m),{},{tickCoord:x>0?m.coordinate-x*t:m.coordinate})}else s[p]=m=Za(Za({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var v=fN(t,m.tickCoord,y,l,c);v&&(c=m.tickCoord-t*(y()/2+i),s[p]=Za(Za({},m),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return s}function vze(t,e,n,r,i,s){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(s){var d=r[l-1],h=n(d,l-1),p=t*(d.coordinate+t*h/2-u);if(o[l-1]=d=Za(Za({},d),{},{tickCoord:p>0?d.coordinate-p*t:d.coordinate}),d.tickCoord!=null){var m=fN(t,d.tickCoord,()=>h,c,u);m&&(u=d.tickCoord-t*(h/2+i),o[l-1]=Za(Za({},d),{},{isShow:!0}))}}for(var b=s?l-1:l,y=function(S){var N=o[S],T,M=()=>(T===void 0&&(T=n(N,S)),T);if(S===0){var A=t*(N.coordinate-t*M()/2-c);o[S]=N=Za(Za({},N),{},{tickCoord:A<0?N.coordinate-A*t:N.coordinate})}else o[S]=N=Za(Za({},N),{},{tickCoord:N.coordinate});if(N.tickCoord!=null){var k=fN(t,N.tickCoord,M,c,u);k&&(c=N.tickCoord+t*(M()/2+i),o[S]=Za(Za({},N),{},{isShow:!0}))}},x=0;x<b;x++)y(x);return o}function T4(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:h}=t;if(!i||!i.length||!r)return[];if(Ht(c)||Db.isSsr){var p;return(p=mze(i,Ht(c)?c:0))!==null&&p!==void 0?p:[]}var m=[],b=l==="top"||l==="bottom"?"width":"height",y=d&&b==="width"?C0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},x=(N,T)=>{var M=typeof u=="function"?u(N.value,T):N.value;return b==="width"?hze(C0(M,{fontSize:e,letterSpacing:n}),y,h):C0(M,{fontSize:e,letterSpacing:n})[b]},v=i.length>=2?wa(i[1].coordinate-i[0].coordinate):1,S=fze(s,v,b);return c==="equidistantPreserveStart"?pze(v,S,x,i,o):(c==="preserveStart"||c==="preserveStartEnd"?m=vze(v,S,x,i,o,c==="preserveStartEnd"):m=yze(v,S,x,i,o),m.filter(N=>N.isShow))}var wze=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,o=0;if(e){Array.from(e).forEach(d=>{if(d){var h=d.getBoundingClientRect();h.width>o&&(o=h.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+s,u=o+c+l+(n?r:0);return Math.round(u)}return 0},_ze=["axisLine","width","height","className","hide","ticks","axisType"];function Sze(t,e){if(t==null)return{};var n,r,i=Nze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Nze(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 Am(){return Am=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},Am.apply(null,arguments)}function wq(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 Ii(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wq(Object(n),!0).forEach(function(r){kze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kze(t,e,n){return(e=Mze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mze(t){var e=Eze(t,"string");return typeof e=="symbol"?e:e+""}function Eze(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Fu={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:wi.axis};function Tze(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=Ii(Ii(Ii({},c),ks(l)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!o||s==="bottom"&&o);u=Ii(Ii({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var h=+(s==="left"&&!o||s==="right"&&o);u=Ii(Ii({},u),{},{x1:e+h*r,y1:n,x2:e+h*r,y2:n+i})}return _.createElement("line",Am({},u,{className:tr("recharts-cartesian-axis-line",km(l,"className"))}))}function Aze(t,e,n,r,i,s,o,l,c){var u,d,h,p,m,b,y=l?-1:1,x=t.tickSize||o,v=Ht(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":u=d=t.coordinate,p=n+ +!l*i,h=p-y*x,b=h-y*c,m=v;break;case"left":h=p=t.coordinate,d=e+ +!l*r,u=d-y*x,m=u-y*c,b=v;break;case"right":h=p=t.coordinate,d=e+ +l*r,u=d+y*x,m=u+y*c,b=v;break;default:u=d=t.coordinate,p=n+ +l*i,h=p+y*x,b=h+y*c,m=v;break}return{line:{x1:u,y1:h,x2:d,y2:p},tick:{x:m,y:b}}}function Cze(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function Pze(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function jze(t){var{option:e,tickProps:n,value:r}=t,i,s=tr(n.className,"recharts-cartesian-axis-tick-value");if(_.isValidElement(e))i=_.cloneElement(e,Ii(Ii({},n),{},{className:s}));else if(typeof e=="function")i=e(Ii(Ii({},n),{},{className:s}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=tr(o,e?.className)),i=_.createElement(AM,Am({},n,{className:o}),r)}return i}var Dze=_.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:h,x:p,y:m,width:b,height:y,tickSize:x,tickMargin:v,fontSize:S,letterSpacing:N,getTicksConfig:T,events:M,axisType:A}=t,k=T4(Ii(Ii({},T),{},{ticks:n}),S,N),R=Cze(d,h),C=Pze(d,h),P=ks(T),U=Nm(r),F={};typeof i=="object"&&(F=i);var B=Ii(Ii({},P),{},{fill:"none"},F),D=k.map(I=>Ii({entry:I},Aze(I,p,m,b,y,d,x,h,v))),$=D.map(I=>{var{entry:K,line:Q}=I;return _.createElement(ci,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(K.value,"-").concat(K.coordinate,"-").concat(K.tickCoord)},i&&_.createElement("line",Am({},B,Q,{className:tr("recharts-cartesian-axis-tick-line",km(i,"className"))})))}),G=D.map((I,K)=>{var{entry:Q,tick:se}=I,H=Ii(Ii(Ii(Ii({textAnchor:R,verticalAnchor:C},P),{},{stroke:"none",fill:s},U),se),{},{index:K,payload:Q,visibleTicksCount:k.length,tickFormatter:o,padding:c},u);return _.createElement(ci,Am({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},Qy(M,Q,K)),r&&_.createElement(jze,{option:r,tickProps:H,value:"".concat(typeof o=="function"?o(Q.value,K):Q.value).concat(l||"")}))});return _.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(A,"-ticks")},G.length>0&&_.createElement(ls,{zIndex:wi.label},_.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(A,"-tick-labels"),ref:e},G)),$.length>0&&_.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(A,"-tick-lines")},$))}),Rze=_.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:o,ticks:l,axisType:c}=t,u=Sze(t,_ze),[d,h]=_.useState(""),[p,m]=_.useState(""),b=_.useRef(null);_.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var x;return wze({ticks:b.current,label:(x=t.labelRef)===null||x===void 0?void 0:x.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=_.useCallback(x=>{if(x){var v=x.getElementsByClassName("recharts-cartesian-axis-tick-value");b.current=v;var S=v[0];if(S){var N=window.getComputedStyle(S),T=N.fontSize,M=N.letterSpacing;(T!==d||M!==p)&&(h(T),m(M))}}},[d,p]);return o||r!=null&&r<=0||i!=null&&i<=0?null:_.createElement(ls,{zIndex:t.zIndex},_.createElement(ci,{className:tr("recharts-cartesian-axis",s)},_.createElement(Tze,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:ks(t)}),_.createElement(Dze,{ref:y,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(jJ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},_.createElement(RJ,{label:t.label,labelRef:t.labelRef}),t.children)))}),A4=_.forwardRef((t,e)=>{var n=ui(t,Fu);return _.createElement(Rze,Am({},n,{ref:e}))});A4.displayName="CartesianAxis";var Oze=["x1","y1","x2","y2","key"],Lze=["offset"],Fze=["xAxisId","yAxisId"],Ize=["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 ts(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){zze(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 zze(t,e,n){return(e=Uze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Uze(t){var e=Bze(t,"string");return typeof e=="symbol"?e:e+""}function Bze(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 qf(){return qf=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},qf.apply(null,arguments)}function mN(t,e){if(t==null)return{};var n,r,i=Hze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Hze(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 $ze=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:o,ry:l}=t;return _.createElement("rect",{x:r,y:i,ry:l,width:s,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function aee(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:s,y1:o,x2:l,y2:c,key:u}=n,d=mN(n,Oze),h=(i=ks(d))!==null&&i!==void 0?i:{},{offset:p}=h,m=mN(h,Lze);r=_.createElement("line",qf({},m,{x1:s,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function Vze(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=t,l=mN(t,Fze),c=i.map((u,d)=>{var h=ts(ts({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return _.createElement(aee,{key:"line-".concat(d),option:r,lineItemProps:h})});return _.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function Gze(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=t,l=mN(t,Ize),c=i.map((u,d)=>{var h=ts(ts({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return _.createElement(aee,{option:r,lineItemProps:h,key:"line-".concat(d)})});return _.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function qze(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(h=>Math.round(h+i-i)).sort((h,p)=>h-p);i!==u[0]&&u.unshift(0);var d=u.map((h,p)=>{var m=!u[p+1],b=m?i+o-h:u[p+1]-h;if(b<=0)return null;var y=p%e.length;return _.createElement("rect",{key:"react-".concat(p),y:h,x:r,height:b,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function Wze(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(h=>Math.round(h+i-i)).sort((h,p)=>h-p);i!==u[0]&&u.unshift(0);var d=u.map((h,p)=>{var m=!u[p+1],b=m?i+o-h:u[p+1]-h;if(b<=0)return null;var y=p%n.length;return _.createElement("rect",{key:"react-".concat(p),x:h,y:s,width:b,height:l,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var Kze=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return HY(T4(ts(ts(ts({},Fu),n),{},{ticks:$Y(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},Xze=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return HY(T4(ts(ts(ts({},Fu),n),{},{ticks:$Y(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},Yze={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:wi.grid};function pN(t){var e=tL(),n=nL(),r=ZY(),i=ts(ts({},ui(t,Yze)),{},{x:Ht(t.x)?t.x:r.left,y:Ht(t.y)?t.y:r.top,width:Ht(t.width)?t.width:r.width,height:Ht(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:h,horizontalValues:p,verticalValues:m}=i,b=sa(),y=zt(C=>uG(C,"xAxis",s,b)),x=zt(C=>uG(C,"yAxis",o,b));if(!Sc(u)||!Sc(d)||!Ht(l)||!Ht(c))return null;var v=i.verticalCoordinatesGenerator||Kze,S=i.horizontalCoordinatesGenerator||Xze,{horizontalPoints:N,verticalPoints:T}=i;if((!N||!N.length)&&typeof S=="function"){var M=p&&p.length,A=S({yAxis:x?ts(ts({},x),{},{ticks:M?p:x.ticks}):void 0,width:e??u,height:n??d,offset:r},M?!0:h);IS(Array.isArray(A),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof A,"]")),Array.isArray(A)&&(N=A)}if((!T||!T.length)&&typeof v=="function"){var k=m&&m.length,R=v({xAxis:y?ts(ts({},y),{},{ticks:k?m:y.ticks}):void 0,width:e??u,height:n??d,offset:r},k?!0:h);IS(Array.isArray(R),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(T=R)}return _.createElement(ls,{zIndex:i.zIndex},_.createElement("g",{className:"recharts-cartesian-grid"},_.createElement($ze,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),_.createElement(qze,qf({},i,{horizontalPoints:N})),_.createElement(Wze,qf({},i,{verticalPoints:T})),_.createElement(Vze,qf({},i,{offset:r,horizontalPoints:N,xAxis:y,yAxis:x})),_.createElement(Gze,qf({},i,{offset:r,verticalPoints:T,xAxis:y,yAxis:x}))))}pN.displayName="CartesianGrid";var see=(t,e,n,r)=>Mc(t,"xAxis",e,r),oee=(t,e,n,r)=>kc(t,"xAxis",e,r),lee=(t,e,n,r)=>Mc(t,"yAxis",n,r),cee=(t,e,n,r)=>kc(t,"yAxis",n,r),Qze=st([Gn,see,lee,oee,cee],(t,e,n,r,i)=>jc(t,"xAxis")?Lh(e,r,!1):Lh(n,i,!1)),Zze=(t,e,n,r,i)=>i;function Jze(t){return t.type==="line"}var eUe=st([hv,Zze],(t,e)=>t.filter(Jze).find(n=>n.id===e)),tUe=st([Gn,see,lee,oee,cee,eUe,Qze,lv],(t,e,n,r,i,s,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(s==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:h,data:p}=s,m;if(p!=null&&p.length>0?m=p:m=c?.slice(u,d+1),m!=null)return wUe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:h,bandSize:o,displayedData:m})}});function uee(t){var e=Nm(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:s}=e,o=Number(i),l=Number(s);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(l)||l<0)&&(l=r),{r:o,strokeWidth:l}}return{r:n,strokeWidth:r}}var nUe=["id"],rUe=["type","layout","connectNulls","needClip","shape"],iUe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function My(){return My=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},My.apply(null,arguments)}function Sq(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function oc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Sq(Object(n),!0).forEach(function(r){aUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Sq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aUe(t,e,n){return(e=sUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sUe(t){var e=oUe(t,"string");return typeof e=="symbol"?e:e+""}function oUe(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 C4(t,e){if(t==null)return{};var n,r,i=lUe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lUe(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 cUe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:$h(n,e),payload:t}]},uUe=_.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:$h(o,e),hide:l,type:u,color:r,unit:c}};return _.createElement(DM,{tooltipEntrySettings:d})}),dee=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function dUe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var hUe=(t,e,n)=>{var r=n.reduce((h,p)=>h+p);if(!r)return dee(e,t);for(var i=Math.floor(t/r),s=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>s){l=[...n.slice(0,c),s-u];break}var d=l.length%2===0?[0,o]:[o];return[...dUe(n,i),...l,...d].map(h=>"".concat(h,"px")).join(", ")};function fUe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:o}=r,{id:l}=r,c=C4(r,nUe),u=ks(c);return _.createElement(qJ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:u,needClip:o,clipPathId:e})}function mUe(t){var{showLabels:e,children:n,points:r}=t,i=_.useMemo(()=>r?.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return oc(oc({},c),{},{value:s.value,payload:s.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return _.createElement(g4,{value:e?i:void 0},n)}function Nq(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:s}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=s,h=C4(s,rUe),p=oc(oc({},Ha(h)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??s.strokeDasharray});return _.createElement(_.Fragment,null,r?.length>1&&_.createElement(w4,My({shapeType:"curve",option:d},p,{pathRef:n})),_.createElement(fUe,{points:r,clipPathId:e,props:s}))}function pUe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function gUe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:s}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:h,animateNewValues:p,width:m,height:b,onAnimationEnd:y,onAnimationStart:x}=n,v=i.current,S=Ob(o,"recharts-line-"),N=_.useRef(S),[T,M]=_.useState(!1),A=!T,k=_.useCallback(()=>{typeof y=="function"&&y(),M(!1)},[y]),R=_.useCallback(()=>{typeof x=="function"&&x(),M(!0)},[x]),C=pUe(r.current),P=_.useRef(0);N.current!==S&&(P.current=s.current,N.current=S);var U=P.current;return _.createElement(mUe,{points:o,showLabels:A},n.children,_.createElement(Rb,{animationId:S,begin:u,duration:d,isActive:c,easing:h,onAnimationEnd:k,onAnimationStart:R,key:S},F=>{var B=pr(U,C+U,F),D=Math.min(B,C),$;if(c)if(l){var G="".concat(l).split(/[,\s]+/gim).map(Q=>parseFloat(Q));$=hUe(D,C,G)}else $=dee(C,D);else $=l==null?void 0:String(l);if(F>0&&C>0&&(i.current=o,s.current=Math.max(s.current,D)),v){var I=v.length/o.length,K=F===1?o:o.map((Q,se)=>{var H=Math.floor(se*I);if(v[H]){var W=v[H];return oc(oc({},Q),{},{x:pr(W.x,Q.x,F),y:pr(W.y,Q.y,F)})}return p?oc(oc({},Q),{},{x:pr(m*2,Q.x,F),y:pr(b/2,Q.y,F)}):oc(oc({},Q),{},{x:Q.x,y:Q.y})});return i.current=K,_.createElement(Nq,{props:n,points:K,clipPathId:e,pathRef:r,strokeDasharray:$})}return _.createElement(Nq,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:$})}),_.createElement(CM,{label:n.label}))}function bUe(t){var{clipPathId:e,props:n}=t,r=_.useRef(null),i=_.useRef(0),s=_.useRef(null);return _.createElement(gUe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var xUe=(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:wr(t.payload,e)}};class yUe extends _.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:s,yAxisId:o,top:l,left:c,width:u,height:d,id:h,needClip:p,zIndex:m}=this.props;if(e)return null;var b=tr("recharts-line",i),y=h,{r:x,strokeWidth:v}=uee(n),S=v4(n),N=x*2+v,T=p?"url(#clipPath-".concat(S?"":"dots-").concat(y,")"):void 0;return _.createElement(ls,{zIndex:m},_.createElement(ci,{className:b},p&&_.createElement("defs",null,_.createElement(E4,{clipPathId:y,xAxisId:s,yAxisId:o}),!S&&_.createElement("clipPath",{id:"clipPath-dots-".concat(y)},_.createElement("rect",{x:c-N/2,y:l-N/2,width:u+N,height:d+N}))),_.createElement(XJ,{xAxisId:s,yAxisId:o,data:r,dataPointFormatter:xUe,errorBarOffset:0},_.createElement(bUe,{props:this.props,clipPathId:y}))),_.createElement(FD,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:T}))}}var hee={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:wi.line,type:"linear"};function vUe(t){var e=ui(t,hee),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:h,legendType:p,xAxisId:m,yAxisId:b,id:y}=e,x=C4(e,iUe),{needClip:v}=FM(m,b),S=LM(),N=Um(),T=sa(),M=zt(P=>tUe(P,m,b,T,y));if(N!=="horizontal"&&N!=="vertical"||M==null||S==null)return null;var{height:A,width:k,x:R,y:C}=S;return _.createElement(yUe,My({},x,{id:y,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,isAnimationActive:d,hide:u,label:h,legendType:p,xAxisId:m,yAxisId:b,points:M,layout:N,height:A,width:k,left:R,top:C,needClip:v}))}function wUe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var h=wr(u,o);if(e==="horizontal"){var p=FS({axis:n,ticks:i,bandSize:l,entry:u,index:d}),m=Jr(h)?null:r.scale(h);return{x:p,y:m,value:h,payload:u}}var b=Jr(h)?null:n.scale(h),y=FS({axis:r,ticks:s,bandSize:l,entry:u,index:d});return b==null||y==null?null:{x:b,y,value:h,payload:u}}).filter(Boolean)}function _Ue(t){var e=ui(t,hee),n=sa();return _.createElement(RM,{id:e.id,type:"line"},r=>_.createElement(_.Fragment,null,_.createElement(k4,{legendPayload:cUe(e)}),_.createElement(uUe,{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(M4,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),_.createElement(vUe,My({},e,{id:r}))))}var fee=_.memo(_Ue,wv);fee.displayName="Line";var mee=(t,e,n,r)=>Mc(t,"xAxis",e,r),pee=(t,e,n,r)=>kc(t,"xAxis",e,r),gee=(t,e,n,r)=>Mc(t,"yAxis",n,r),bee=(t,e,n,r)=>kc(t,"yAxis",n,r),SUe=st([Gn,mee,gee,pee,bee],(t,e,n,r,i)=>jc(t,"xAxis")?Lh(e,r,!1):Lh(n,i,!1)),NUe=(t,e,n,r,i)=>i,xee=st([hv,NUe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),kUe=(t,e,n,r,i)=>{var s,o=xee(t,e,n,r,i);if(o!=null){var l=Gn(t),c=jc(l,"xAxis"),u;if(c?u=Ny(t,"yAxis",n,r):u=Ny(t,"xAxis",e,r),u!=null){var{stackId:d}=o,h=vM(o);if(!(d==null||h==null)){var p=(s=u[d])===null||s===void 0?void 0:s.stackedData;return p?.find(m=>m.key===h)}}}},MUe=st([Gn,mee,gee,pee,bee,kUe,lv,SUe,xee,eDe],(t,e,n,r,i,s,o,l,c,u)=>{var{chartData:d,dataStartIndex:h,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,b;if(m&&m.length>0?b=m:b=d?.slice(h,p+1),b!=null)return GUe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:c,stackedData:s,displayedData:b,chartBaseValue:u,bandSize:l})}}),EUe=["id"],TUe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function sm(){return sm=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},sm.apply(null,arguments)}function yee(t,e){if(t==null)return{};var n,r,i=AUe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function AUe(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 kq(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 Eg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kq(Object(n),!0).forEach(function(r){CUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function CUe(t,e,n){return(e=PUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PUe(t){var e=jUe(t,"string");return typeof e=="symbol"?e:e+""}function jUe(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 gN(t,e){return t&&t!=="none"?t:e}var DUe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:o}=t;return[{inactive:o,dataKey:e,type:s,color:gN(r,i),value:$h(n,e),payload:t}]},RUe=_.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:$h(o,e),hide:l,type:u,color:gN(r,s),unit:c}};return _.createElement(DM,{tooltipEntrySettings:d})});function OUe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:o}=r,l=ks(r);return _.createElement(qJ,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function LUe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Eg(Eg({},c),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return _.createElement(g4,{value:e?i:void 0},n)}function Mq(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=s,{id:h}=s,p=yee(s,EUe),m=ks(p),b=Ha(p);return _.createElement(_.Fragment,null,e?.length>1&&_.createElement(ci,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},_.createElement(Ug,sm({},b,{id:h,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&_.createElement(Ug,sm({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&_.createElement(Ug,sm({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),_.createElement(OUe,{points:e,props:p,clipPathId:i}))}function FUe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,o=r[r.length-1].y;if(!_r(s)||!_r(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.x||0));return Ht(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Ht(c)?_.createElement("rect",{x:0,y:s<o?s:s-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function IUe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,o=r[r.length-1].x;if(!_r(s)||!_r(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.y||0));return Ht(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Ht(c)?_.createElement("rect",{x:s<o?s:s-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function zUe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?_.createElement(FUe,{alpha:e,points:r,baseLine:i,strokeWidth:s}):_.createElement(IUe,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function UUe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:h,onAnimationStart:p,onAnimationEnd:m}=r,b=_.useMemo(()=>({points:o,baseLine:l}),[o,l]),y=Ob(b,"recharts-area-"),x=xAe(),[v,S]=_.useState(!1),N=!v,T=_.useCallback(()=>{typeof m=="function"&&m(),S(!1)},[m]),M=_.useCallback(()=>{typeof p=="function"&&p(),S(!0)},[p]);if(x==null)return null;var A=i.current,k=s.current;return _.createElement(LUe,{showLabels:N,points:o},r.children,_.createElement(Rb,{animationId:y,begin:u,duration:d,isActive:c,easing:h,onAnimationEnd:T,onAnimationStart:M,key:y},R=>{if(A){var C=A.length/o.length,P=R===1?o:o.map((F,B)=>{var D=Math.floor(B*C);if(A[D]){var $=A[D];return Eg(Eg({},F),{},{x:pr($.x,F.x,R),y:pr($.y,F.y,R)})}return F}),U;return Ht(l)?U=pr(k,l,R):Jr(l)||Xs(l)?U=pr(k,0,R):U=l.map((F,B)=>{var D=Math.floor(B*C);if(Array.isArray(k)&&k[D]){var $=k[D];return Eg(Eg({},F),{},{x:pr($.x,F.x,R),y:pr($.y,F.y,R)})}return F}),R>0&&(i.current=P,s.current=U),_.createElement(Mq,{points:P,baseLine:U,needClip:e,clipPathId:n,props:r})}return R>0&&(i.current=o,s.current=l),_.createElement(ci,null,c&&_.createElement("defs",null,_.createElement("clipPath",{id:"animationClipPath-".concat(n)},_.createElement(zUe,{alpha:R,points:o,baseLine:l,layout:x,strokeWidth:r.strokeWidth}))),_.createElement(ci,{clipPath:"url(#animationClipPath-".concat(n,")")},_.createElement(Mq,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),_.createElement(CM,{label:r.label}))}function BUe(t){var{needClip:e,clipPathId:n,props:r}=t,i=_.useRef(null),s=_.useRef();return _.createElement(UUe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class HUe extends _.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:h,id:p,baseLine:m,zIndex:b}=this.props;if(e)return null;var y=tr("recharts-area",i),x=p,{r:v,strokeWidth:S}=uee(n),N=v4(n),T=v*2+S,M=l?"url(#clipPath-".concat(N?"":"dots-").concat(x,")"):void 0;return _.createElement(ls,{zIndex:b},_.createElement(ci,{className:y},l&&_.createElement("defs",null,_.createElement(E4,{clipPathId:x,xAxisId:c,yAxisId:u}),!N&&_.createElement("clipPath",{id:"clipPath-dots-".concat(x)},_.createElement("rect",{x:o-T/2,y:s-T/2,width:d+T,height:h+T}))),_.createElement(BUe,{needClip:l,clipPathId:x,props:this.props})),_.createElement(FD,{points:r,mainColor:gN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:M}),this.props.isRange&&Array.isArray(m)&&_.createElement(FD,{points:m,mainColor:gN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:M}))}}var vee={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:wi.area};function $Ue(t){var e,n=ui(t,vee),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:h,isAnimationActive:p,legendType:m,stroke:b,xAxisId:y,yAxisId:x}=n,v=yee(n,TUe),S=Um(),N=pJ(),{needClip:T}=FM(y,x),M=sa(),{points:A,isRange:k,baseLine:R}=(e=zt(D=>MUe(D,y,x,M,t.id)))!==null&&e!==void 0?e:{},C=LM();if(S!=="horizontal"&&S!=="vertical"||C==null||N!=="AreaChart"&&N!=="ComposedChart")return null;var{height:P,width:U,x:F,y:B}=C;return!A||!A.length?null:_.createElement(HUe,sm({},v,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,baseLine:R,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:P,hide:h,layout:S,isAnimationActive:p==="auto"?!Db.isSsr:p,isRange:k,legendType:m,needClip:T,points:A,stroke:b,width:U,left:F,top:B,xAxisId:y,yAxisId:x}))}var VUe=(t,e,n,r,i)=>{var s=n??e;if(Ht(s))return s;var o=t==="horizontal"?i:r,l=o.scale.domain();if(o.type==="number"){var c=Math.max(l[0],l[1]),u=Math.min(l[0],l[1]);return s==="dataMin"?u:s==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]};function GUe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:h,yAxisTicks:p,bandSize:m}=t,b=i&&i.length,y=VUe(s,o,n,l,c),x=s==="horizontal",v=!1,S=u.map((T,M)=>{var A;b?A=i[d+M]:(A=wr(T,r),Array.isArray(A)?v=!0:A=[y,A]);var k=A[1]==null||b&&!e&&wr(T,r)==null;return x?{x:FS({axis:l,ticks:h,bandSize:m,entry:T,index:M}),y:k?null:c.scale(A[1]),value:A,payload:T}:{x:k?null:l.scale(A[1]),y:FS({axis:c,ticks:p,bandSize:m,entry:T,index:M}),value:A,payload:T}}),N;return b||v?N=S.map(T=>{var M=Array.isArray(T.value)?T.value[0]:null;return x?{x:T.x,y:M!=null&&T.y!=null?c.scale(M):null,payload:T.payload}:{x:M!=null?l.scale(M):null,y:T.y,payload:T.payload}}):N=x?c.scale(y):l.scale(y),{points:S,baseLine:N,isRange:v}}function qUe(t){var e=ui(t,vee),n=sa();return _.createElement(RM,{id:e.id,type:"area"},r=>_.createElement(_.Fragment,null,_.createElement(k4,{legendPayload:DUe(e)}),_.createElement(RUe,{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(M4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:VY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),_.createElement($Ue,sm({},e,{id:r}))))}var wee=_.memo(qUe,wv);wee.displayName="Area";var WUe=["domain","range"],KUe=["domain","range"];function Eq(t,e){if(t==null)return{};var n,r,i=XUe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function XUe(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 Tq(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 _ee(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=Eq(t,WUe),{domain:s,range:o}=e,l=Eq(e,KUe);return!Tq(n,s)||!Tq(r,o)?!1:wv(i,l)}var YUe=["dangerouslySetInnerHTML","ticks"],QUe=["id"];function zD(){return zD=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},zD.apply(null,arguments)}function Aq(t,e){if(t==null)return{};var n,r,i=ZUe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ZUe(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 JUe(t){var e=Br(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(WFe(t)):n.current!==t&&e(KFe({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(XFe(n.current)),n.current=null)},[e]),null}var eBe=t=>{var{xAxisId:e,className:n}=t,r=zt(JO),i=sa(),s="xAxis",o=zt(x=>Ih(x,s,e,i)),l=zt(x=>WZ(x,s,e,i)),c=zt(x=>$Z(x,e)),u=zt(x=>QDe(x,e)),d=zt(x=>NZ(x,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:h,ticks:p}=t,m=Aq(t,YUe),{id:b}=d,y=Aq(d,QUe);return _.createElement(A4,zD({},m,y,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:tr("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:l,axisType:s}))},tBe={allowDataOverflow:ga.allowDataOverflow,allowDecimals:ga.allowDecimals,allowDuplicatedCategory:ga.allowDuplicatedCategory,angle:ga.angle,axisLine:Fu.axisLine,height:ga.height,hide:!1,includeHidden:ga.includeHidden,interval:ga.interval,minTickGap:ga.minTickGap,mirror:ga.mirror,orientation:ga.orientation,padding:ga.padding,reversed:ga.reversed,scale:ga.scale,tick:ga.tick,tickCount:ga.tickCount,tickLine:Fu.tickLine,tickSize:Fu.tickSize,type:ga.type,xAxisId:0},nBe=t=>{var e=ui(t,tBe);return _.createElement(_.Fragment,null,_.createElement(JUe,{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(eBe,e))},bN=_.memo(nBe,_ee);bN.displayName="XAxis";var rBe=["dangerouslySetInnerHTML","ticks"],iBe=["id"];function UD(){return UD=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},UD.apply(null,arguments)}function Cq(t,e){if(t==null)return{};var n,r,i=aBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function aBe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function sBe(t){var e=Br(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(YFe(t)):n.current!==t&&e(QFe({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(ZFe(n.current)),n.current=null)},[e]),null}var oBe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=_.useRef(null),o=_.useRef(null),l=zt(JO),c=sa(),u=Br(),d="yAxis",h=zt(M=>Ih(M,d,e,c)),p=zt(M=>VZ(M,e)),m=zt(M=>JDe(M,e)),b=zt(M=>WZ(M,d,e,c)),y=zt(M=>kZ(M,e));if(_.useLayoutEffect(()=>{if(!(r!=="auto"||!p||p4(i)||_.isValidElement(i)||y==null)){var M=s.current;if(M){var A=M.getCalculatedWidth();Math.round(p.width)!==Math.round(A)&&u(JFe({id:e,width:A}))}}},[b,p,u,i,e,r,y]),p==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:x,ticks:v}=t,S=Cq(t,rBe),{id:N}=y,T=Cq(y,iBe);return _.createElement(A4,UD({},S,T,{ref:s,labelRef:o,scale:h,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:p.width,height:p.height,className:tr("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:b,axisType:d}))},lBe={allowDataOverflow:ba.allowDataOverflow,allowDecimals:ba.allowDecimals,allowDuplicatedCategory:ba.allowDuplicatedCategory,angle:ba.angle,axisLine:Fu.axisLine,hide:!1,includeHidden:ba.includeHidden,interval:ba.interval,minTickGap:ba.minTickGap,mirror:ba.mirror,orientation:ba.orientation,padding:ba.padding,reversed:ba.reversed,scale:ba.scale,tick:ba.tick,tickCount:ba.tickCount,tickLine:Fu.tickLine,tickSize:Fu.tickSize,type:ba.type,width:ba.width,yAxisId:0},cBe=t=>{var e=ui(t,lBe);return _.createElement(_.Fragment,null,_.createElement(sBe,{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(oBe,e))},xN=_.memo(cBe,_ee);xN.displayName="YAxis";var uBe=(t,e)=>e,P4=st([uBe,Gn,_Z,la,cJ,sd,mOe,aa],wOe),j4=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)}},See=ml("mouseClick"),Nee=ev();Nee.startListening({actionCreator:See,effect:(t,e)=>{var n=t.payload,r=P4(e.getState(),j4(n));r?.activeIndex!=null&&e.dispatch(fRe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var BD=ml("mouseMove"),kee=ev(),d1=null;kee.startListening({actionCreator:BD,effect:(t,e)=>{var n=t.payload;d1!==null&&cancelAnimationFrame(d1);var r=j4(n);d1=requestAnimationFrame(()=>{var i=e.getState(),s=i4(i,i.tooltip.settings.shared);if(s==="axis"){var o=P4(i,r);o?.activeIndex!=null?e.dispatch(tJ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(eJ())}d1=null})}});var Pq={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},Mee=Ys({name:"rootProps",initialState:Pq,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:Pq.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}}}),dBe=Mee.reducer,{updateOptions:hBe}=Mee.actions,Eee=Ys({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:fBe}=Eee.actions,mBe=Eee.reducer,Tee=ml("keyDown"),Aee=ml("focus"),D4=ev();D4.startListening({actionCreator:Tee,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,s=t.payload;if(!(s!=="ArrowRight"&&s!=="ArrowLeft"&&s!=="Enter")){var o=a4(i,$b(n),mv(n),xv(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=sd(n);if(s==="Enter"){var u=aN(n,"axis","hover",String(i.index));e.dispatch(PD({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=rRe(n),h=d==="left-to-right"?1:-1,p=s==="ArrowRight"?1:-1,m=l+p*h;if(!(c==null||m>=c.length||m<0)){var b=aN(n,"axis","hover",String(m));e.dispatch(PD({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:b}))}}}}}});D4.startListening({actionCreator:Aee,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var s="0",o=aN(n,"axis","hover",String(s));e.dispatch(PD({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:o}))}}}});var qo=ml("externalEvent"),Cee=ev(),bP=new Map;Cee.startListening({actionCreator:qo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=bP.get(i);s!==void 0&&cancelAnimationFrame(s);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:JRe(l),activeDataKey:u4(l),activeIndex:zh(l),activeLabel:hJ(l),activeTooltipIndex:zh(l),isTooltipActive:eOe(l)};n(c,r)}finally{bP.delete(i)}});bP.set(i,o)}}});var pBe=st([Hb],t=>t.tooltipItemPayloads),gBe=st([pBe,gv,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:s}=i;if(s!=null){var o=e(s,n);return o}}}),Pee=ml("touchMove"),jee=ev();jee.startListening({actionCreator:Pee,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=i4(r,r.tooltip.settings.shared);if(i==="axis"){var s=P4(r,j4({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(tJ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}else if(i==="item"){var 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(qY),d=(o=c.getAttribute(WY))!==null&&o!==void 0?o:void 0,h=gBe(e.getState(),u,d);e.dispatch(JZ({activeDataKey:d,activeIndex:u,activeCoordinate:h}))}}}});var bBe=fY({brush:B5e,cartesianAxis:eIe,chartData:ZOe,errorBars:yIe,graphicalItems:oFe,layout:kTe,legend:DAe,options:WOe,polarAxis:_4e,polarOptions:mBe,referenceElements:Z5e,rootProps:dBe,tooltip:mRe,zIndex:OOe}),xBe=function(e){return YEe({reducer:bBe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([Nee.middleware,kee.middleware,D4.middleware,Cee.middleware,jee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(TY({type:"raf"}))},devTools:Db.devToolsEnabled})};function Dee(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=sa(),s=_.useRef(null);if(i)return n;s.current==null&&(s.current=xBe(e));var o=VO;return _.createElement($Ie,{context:o,store:s.current},n)}function yBe(t){var{layout:e,margin:n}=t,r=Br(),i=sa();return _.useEffect(()=>{i||(r(_Te(e)),r(wTe(n)))},[r,i,e,n]),null}var Ree=_.memo(yBe,wv);function Oee(t){var e=Br();return _.useEffect(()=>{e(hBe(t))},[e,t]),null}function jq(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=$J("".concat(r).concat(e)),s=Br();return _.useLayoutEffect(()=>(s(DOe({zIndex:e,elementId:i,isPanorama:n})),()=>{s(ROe({zIndex:e,isPanorama:n}))}),[s,e,i,n]),_.createElement("g",{tabIndex:-1,id:i})}function Dq(t){var{children:e,isPanorama:n}=t,r=zt(SOe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),s=r.filter(o=>o>0);return _.createElement(_.Fragment,null,i.map(o=>_.createElement(jq,{key:o,zIndex:o,isPanorama:n})),e,s.map(o=>_.createElement(jq,{key:o,zIndex:o,isPanorama:n})))}var vBe=["children"];function wBe(t,e){if(t==null)return{};var n,r,i=_Be(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _Be(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 yN(){return yN=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},yN.apply(null,arguments)}var SBe={width:"100%",height:"100%",display:"block"},NBe=_.forwardRef((t,e)=>{var n=tL(),r=nL(),i=cQ();if(!Sc(n)||!Sc(r))return null;var{children:s,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),_.createElement(RO,yN({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:SBe,ref:e}),s)}),kBe=t=>{var{children:e}=t,n=zt(oM);if(!n)return null;var{width:r,height:i,y:s,x:o}=n;return _.createElement(RO,{width:r,height:i,x:o,y:s},e)},Rq=_.forwardRef((t,e)=>{var{children:n}=t,r=wBe(t,vBe),i=sa();return i?_.createElement(kBe,null,_.createElement(Dq,{isPanorama:!0},n)):_.createElement(NBe,yN({ref:e},r),_.createElement(Dq,{isPanorama:!1},n))});function MBe(){var t=Br(),[e,n]=_.useState(null),r=zt(HTe);return _.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;_r(s)&&s!==r&&t(NTe(s))}},[e,t,r]),n}function Oq(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 EBe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Oq(Object(n),!0).forEach(function(r){TBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Oq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function TBe(t,e,n){return(e=ABe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ABe(t){var e=CBe(t,"string");return typeof e=="symbol"?e:e+""}function CBe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Cm(){return Cm=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},Cm.apply(null,arguments)}var PBe=()=>(oLe(),null);function vN(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var jBe=_.forwardRef((t,e)=>{var n,r,i=_.useRef(null),[s,o]=_.useState({containerWidth:vN((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:vN((r=t.style)===null||r===void 0?void 0:r.height)}),l=_.useCallback((u,d)=>{o(h=>{var p=Math.round(u),m=Math.round(d);return h.containerWidth===p&&h.containerHeight===m?h:{containerWidth:p,containerHeight:m}})},[]),c=_.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:h}=u.getBoundingClientRect();l(d,h);var p=b=>{var{width:y,height:x}=b[0].contentRect;l(y,x)},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(lM,{width:s.containerWidth,height:s.containerHeight}),_.createElement("div",Cm({ref:c},t)))}),DBe=_.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=_.useState({containerWidth:vN(n),containerHeight:vN(r)}),o=_.useCallback((c,u)=>{s(d=>{var h=Math.round(c),p=Math.round(u);return d.containerWidth===h&&d.containerHeight===p?d:{containerWidth:h,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(lM,{width:i.containerWidth,height:i.containerHeight}),_.createElement("div",Cm({ref:l},t)))}),RBe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return _.createElement(_.Fragment,null,_.createElement(lM,{width:n,height:r}),_.createElement("div",Cm({ref:e},t)))}),OBe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return Xu(n)||Xu(r)?_.createElement(DBe,Cm({},t,{ref:e})):_.createElement(RBe,Cm({},t,{ref:e}))});function LBe(t){return t===!0?jBe:OBe}var FBe=_.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:h,onMouseUp:p,onTouchEnd:m,onTouchMove:b,onTouchStart:y,style:x,width:v,responsive:S,dispatchTouchEvents:N=!0}=t,T=_.useRef(null),M=Br(),[A,k]=_.useState(null),[R,C]=_.useState(null),P=MBe(),U=eL(),F=U?.width>0?U.width:v,B=U?.height>0?U.height:i,D=_.useCallback(oe=>{P(oe),typeof e=="function"&&e(oe),k(oe),C(oe),oe!=null&&(T.current=oe)},[P,e,k,C]),$=_.useCallback(oe=>{M(See(oe)),M(qo({handler:s,reactEvent:oe}))},[M,s]),G=_.useCallback(oe=>{M(BD(oe)),M(qo({handler:u,reactEvent:oe}))},[M,u]),I=_.useCallback(oe=>{M(eJ()),M(qo({handler:d,reactEvent:oe}))},[M,d]),K=_.useCallback(oe=>{M(BD(oe)),M(qo({handler:h,reactEvent:oe}))},[M,h]),Q=_.useCallback(()=>{M(Aee())},[M]),se=_.useCallback(oe=>{M(Tee(oe.key))},[M]),H=_.useCallback(oe=>{M(qo({handler:o,reactEvent:oe}))},[M,o]),W=_.useCallback(oe=>{M(qo({handler:l,reactEvent:oe}))},[M,l]),J=_.useCallback(oe=>{M(qo({handler:c,reactEvent:oe}))},[M,c]),ne=_.useCallback(oe=>{M(qo({handler:p,reactEvent:oe}))},[M,p]),xe=_.useCallback(oe=>{M(qo({handler:y,reactEvent:oe}))},[M,y]),ue=_.useCallback(oe=>{N&&M(Pee(oe)),M(qo({handler:b,reactEvent:oe}))},[M,N,b]),fe=_.useCallback(oe=>{M(qo({handler:m,reactEvent:oe}))},[M,m]),De=LBe(S);return _.createElement(vJ.Provider,{value:A},_.createElement(TX.Provider,{value:R},_.createElement(De,{width:F??x?.width,height:B??x?.height,className:tr("recharts-wrapper",r),style:EBe({position:"relative",cursor:"default",width:F,height:B},x),onClick:$,onContextMenu:H,onDoubleClick:W,onFocus:Q,onKeyDown:se,onMouseDown:J,onMouseEnter:G,onMouseLeave:I,onMouseMove:K,onMouseUp:ne,onTouchEnd:fe,onTouchMove:ue,onTouchStart:xe,ref:D},_.createElement(PBe,null),n)))}),IBe=["width","height","responsive","children","className","style","compact","title","desc"];function zBe(t,e){if(t==null)return{};var n,r,i=UBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function UBe(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 Lee=_.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:o,style:l,compact:c,title:u,desc:d}=t,h=zBe(t,IBe),p=ks(h);return c?_.createElement(_.Fragment,null,_.createElement(lM,{width:n,height:r}),_.createElement(Rq,{otherAttributes:p,title:u,desc:d},s)):_.createElement(FBe,{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(Rq,{otherAttributes:p,title:u,desc:d,ref:e},_.createElement(J5e,null,s)))});function HD(){return HD=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},HD.apply(null,arguments)}var BBe={top:5,right:5,bottom:5,left:5},HBe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:BBe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},R4=_.forwardRef(function(e,n){var r,i=ui(e.categoricalChartProps,HBe),{chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return _.createElement(Dee,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:s},_.createElement(JJ,{chartData:u.data}),_.createElement(Ree,{layout:i.layout,margin:i.margin}),_.createElement(Oee,{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(Lee,HD({},i,{ref:n})))}),$Be=["axis"],VBe=_.forwardRef((t,e)=>_.createElement(R4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:$Be,tooltipPayloadSearcher:TM,categoricalChartProps:t,ref:e})),GBe=["axis","item"],qBe=_.forwardRef((t,e)=>_.createElement(R4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:GBe,tooltipPayloadSearcher:TM,categoricalChartProps:t,ref:e}));function WBe(t){var e=Br();return _.useEffect(()=>{e(fBe(t))},[e,t]),null}var KBe=["layout"];function $D(){return $D=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},$D.apply(null,arguments)}function XBe(t,e){if(t==null)return{};var n,r,i=YBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function YBe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var QBe={top:5,right:5,bottom:5,left:5},Fee={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:QBe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},ZBe=_.forwardRef(function(e,n){var r,i=ui(e.categoricalChartProps,Fee),{layout:s}=i,o=XBe(i,KBe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,h={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return _.createElement(Dee,{preloadedState:{options:h},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},_.createElement(JJ,{chartData:i.data}),_.createElement(Ree,{layout:s,margin:i.margin}),_.createElement(Oee,{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(WBe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),_.createElement(Lee,$D({},o,{ref:n})))});function Lq(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 Fq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Lq(Object(n),!0).forEach(function(r){JBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Lq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JBe(t,e,n){return(e=e8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e8e(t){var e=t8e(t,"string");return typeof e=="symbol"?e:e+""}function t8e(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 n8e=["item"],r8e=Fq(Fq({},Fee),{},{layout:"centric",startAngle:0,endAngle:360}),i8e=_.forwardRef((t,e)=>{var n=ui(t,r8e);return _.createElement(ZBe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:n8e,tooltipPayloadSearcher:TM,categoricalChartProps:n,ref:e})}),a8e=["axis"],s8e=_.forwardRef((t,e)=>_.createElement(R4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:a8e,tooltipPayloadSearcher:TM,categoricalChartProps:t,ref:e}));const Iq=[{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 o8e({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:o="humidity",thresholds:l}){const{t:c}=Yt(),{mode:u}=Fm(),[d,h]=_.useState("24h"),[p,m]=_.useState(o),b=u==="dark",{data:y}=nt({queryKey:["settings"],queryFn:ae.getSettings}),x=y?.time_format||"system";_.useEffect(()=>{if(!t)return;const ne=xe=>{xe.key==="Escape"&&e()};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[t,e]);const v=Iq.find(ne=>ne.value===d)?.hours||24,{data:S,isLoading:N,error:T}=nt({queryKey:["ams-history",n,i,v],queryFn:()=>ae.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const M=S?.data.map(ne=>{const xe=Ui(ne.recorded_at)||new Date,ue={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:xe.getTime(),humidity:ne.humidity,temperature:ne.temperature,timeLabel:xe.toLocaleTimeString([],N0(ue,x))}})||[],A=l?.humidityGood||40,k=l?.humidityFair||60,R=l?.tempGood||30,C=l?.tempFair||35,P=M[M.length-1],U=P?.humidity,F=P?.temperature,B=ne=>{const xe=ne.filter(Fe=>Fe!=null);if(xe.length<4)return"stable";const ue=xe.slice(0,Math.floor(xe.length/4)),fe=xe.slice(-Math.floor(xe.length/4)),De=ue.reduce((Fe,ce)=>Fe+ce,0)/ue.length,Ne=fe.reduce((Fe,ce)=>Fe+ce,0)/fe.length-De;return Math.abs(Ne)<2?"stable":Ne>0?"up":"down"},D=B(M.map(ne=>ne.humidity)),$=B(M.map(ne=>ne.temperature)),G=({trend:ne})=>ne==="up"?a.jsx(Lj,{className:"w-4 h-4 text-red-400"}):ne==="down"?a.jsx(XW,{className:"w-4 h-4 text-green-400"}):a.jsx(Rj,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),I=ne=>ne==null?"#9ca3af":ne<=A?"#22a352":ne<=k?"#d4a017":"#c62828",K=ne=>ne==null?"#9ca3af":ne<=R?"#22a352":ne<=C?"#d4a017":"#c62828",Q=b?"#2d2d2d":"#ffffff",se=b?"#1d1d1d":"#f3f4f6",H=b?"#3d3d3d":"#e5e7eb",W=b?"#ffffff":"#111827",J=b?"#9ca3af":"#4b5563";return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:Q},onClick:ne=>ne.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:H},children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold",style:{color:W},children:[s," ",c("common.history","History")]}),a.jsx("p",{className:"text-sm",style:{color:J},children:r})]}),a.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:J},children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:se},children:[a.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:J}:void 0,children:[a.jsx(WR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),a.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:J}:void 0,children:[a.jsx(Dk,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),a.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:se},children:Iq.map(ne=>a.jsx("button",{onClick:()=>h(ne.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ne.value?"bg-bambu-green text-white":""}`,style:d!==ne.value?{color:J}:void 0,children:ne.label},ne.value))})]}),a.jsx("div",{className:"grid grid-cols-4 gap-4",children:p==="humidity"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:J},children:c("common.current","Current")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-2xl font-bold",style:{color:I(U)},children:U!=null?`${U}%`:"—"}),a.jsx(G,{trend:D})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:J},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:J},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-green-500",children:S?.min_humidity!=null?`${S.min_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:J},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_humidity!=null?`${S.max_humidity}%`:"—"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:J},children:c("common.current","Current")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-2xl font-bold",style:{color:K(F)},children:F!=null?`${F}°C`:"—"}),a.jsx(G,{trend:$})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:J},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:J},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-blue-500",children:S?.min_temperature!=null?`${S.min_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[a.jsx("p",{className:"text-xs",style:{color:J},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_temperature!=null?`${S.max_temperature}°C`:"—"})]})]})}),a.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:N?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:J},children:c("common.loading","Loading...")}):T?a.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):M.length===0?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:J},children:c("common.noData","No data available for this time range")}):a.jsx(V1,{width:"100%",height:300,children:a.jsxs(VBe,{data:M,children:[a.jsx(pN,{strokeDasharray:"3 3",stroke:b?"#3d3d3d":"#e5e7eb"}),a.jsx(bN,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ne=>{const xe=new Date(ne);return v>24?xe.toLocaleDateString([],{day:"numeric",month:"short"}):xe.toLocaleTimeString([],N0({hour:"2-digit",minute:"2-digit"},x))},stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12}}),a.jsx(xN,{stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:p==="humidity"?[0,100]:["auto","auto"],tickFormatter:ne=>p==="humidity"?`${ne}%`:`${ne}°C`}),a.jsx(q1,{contentStyle:{backgroundColor:b?"#2d2d2d":"#ffffff",border:`1px solid ${b?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:b?"#fff":"#000"},labelFormatter:ne=>new Date(ne).toLocaleString(void 0,N0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},x)),formatter:ne=>[p==="humidity"?`${ne??0}%`:`${ne??0}°C`,p==="humidity"?"Humidity":"Temperature"]}),a.jsx(aL,{}),p==="humidity"?a.jsxs(a.Fragment,{children:[a.jsx(p0,{y:A,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(p0,{y:k,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):a.jsxs(a.Fragment,{children:[a.jsx(p0,{y:R,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(p0,{y:C,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),a.jsx(fee,{type:"monotone",dataKey:p,name:p==="humidity"?"Humidity":"Temperature",stroke:p==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),a.jsx("div",{className:"text-xs text-center",style:{color:J},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function xP({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:s}){const{t:o}=Yt(),[l,c]=_.useState(!1),[u,d]=_.useState("top"),[h,p]=_.useState(!1),m=_.useRef(null),b=_.useRef(null),y=_.useRef(null),x=()=>{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&&b.current){const k=m.current.getBoundingClientRect(),R=b.current.offsetHeight,P=k.top-56,U=window.innerHeight-k.bottom;P<R+12&&U>P?d("bottom"):d("top")}},[l]);const S=()=>{n||(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>c(!0),80))},N=()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>c(!1),100)};_.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const T=k=>k<=15?"#ef4444":k<=30?"#f97316":k<=50?"#eab308":"#22c55e",M=k=>{if(!k)return!1;const R=k.replace("#",""),C=parseInt(R.slice(0,2),16),P=parseInt(R.slice(2,4),16),U=parseInt(R.slice(4,6),16);return(.299*C+.587*P+.114*U)/255>.6},A=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return a.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:S,onMouseLeave:N,children:[e,l&&a.jsxs("div",{ref:b,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${u==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[a.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:A||"#3d3d3d"},children:[a.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),a.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${M(A)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),a.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),a.jsxs("div",{className:"p-3 space-y-2.5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("ams.profile")}),a.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("ams.kFactor")}),a.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[a.jsx(WR,{className:"w-3 h-3"}),o("ams.fill")]}),a.jsxs("span",{className:"text-xs text-white font-semibold flex items-center gap-1",children:[t.fillLevel!==null?`${t.fillLevel}%`:"—",t.fillSource==="spoolman"&&t.fillLevel!==null&&a.jsx("span",{className:"text-[9px] text-bambu-gray font-normal",children:o("spoolman.fillSourceLabel")})]})]}),a.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?a.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:T(t.fillLevel)}}):a.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("spoolman.spoolId")}),a.jsxs("button",{onClick:k=>{k.stopPropagation(),x()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[a.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),h?a.jsx(Vi,{className:"w-3 h-3 text-bambu-green"}):a.jsx(Bl,{className:"w-3 h-3"})]})]}),i.linkedSpoolId&&i.spoolmanUrl&&a.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:[a.jsx(Zr,{className:"w-3.5 h-3.5"}),o("spoolman.openInSpoolman")]}),!i.linkedSpoolId&&i.onLinkSpool&&a.jsxs("button",{onClick:k=>{k.stopPropagation(),i.hasUnlinkedSpools!==!1&&i.onLinkSpool?.(t.trayUuid)},disabled:i.hasUnlinkedSpools===!1,className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors ${i.hasUnlinkedSpools===!1?"bg-bambu-gray/10 text-bambu-gray cursor-not-allowed":"bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green"}`,title:i.hasUnlinkedSpools===!1?o("spoolman.noUnlinkedSpools"):o("spoolman.linkToSpoolman"),children:[a.jsx(pc,{className:"w-3.5 h-3.5"}),o("spoolman.linkToSpoolman")]})]}),s?.enabled&&a.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("button",{onClick:k=>{k.stopPropagation(),s.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:o("ams.configureSlot"),children:[a.jsx(Gu,{className:"w-3.5 h-3.5"}),o("ams.configure")]})})]})]}),a.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${u==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function zq({children:t,className:e="",configureSlot:n}){const{t:r}=Yt(),[i,s]=_.useState(!1),o=_.useRef(null),l=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!0),80)},c=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),100)};return _.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),a.jsxs("div",{className:`relative ${e}`,onMouseEnter:l,onMouseLeave:c,children:[t,i&&a.jsxs("div",{className:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[a.jsxs("div",{className:`
- bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg overflow-hidden
- `,children:[a.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:r("ams.emptySlot")}),n?.enabled&&a.jsx("div",{className:"px-2 pb-2",children:a.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:[a.jsx(Gu,{className:"w-3.5 h-3.5"}),r("ams.configure")]})})]}),a.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
- border-l-[5px] border-l-transparent
- border-r-[5px] border-r-transparent
- border-t-[5px] border-t-bambu-dark-tertiary
- `})]})]})}function l8e({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const{t:i}=Yt(),s=nn(),{showToast:o}=kn(),[l,c]=_.useState(null),{data:u,isLoading:d}=nt({queryKey:["unlinked-spools"],queryFn:ae.getUnlinkedSpools,enabled:t}),h=dt({mutationFn:m=>ae.linkSpool(m,n),onSuccess:()=>{s.invalidateQueries({queryKey:["unlinked-spools"]}),s.invalidateQueries({queryKey:["linked-spools"]}),s.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&&h.mutate(l)};return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(pc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("spoolman.linkToSpoolman")})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[r&&a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),a.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),a.jsx("span",{className:"text-white font-medium",children:r.type}),a.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-xs text-bambu-gray mb-1",children:[i("spoolman.spoolId"),":"]}),a.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-sm text-bambu-gray mb-2",children:[i("spoolman.selectSpool"),":"]}),d?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:u.map(m=>a.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:a.jsxs("div",{className:"flex items-center gap-2",children:[m.filament_color_hex&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${m.filament_color_hex}`}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:m.filament_name||"Unknown filament"}),a.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&&a.jsx(Vi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},m.id))}):a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:a.jsx("p",{children:i("spoolman.noUnlinkedSpools")})})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{onClick:p,disabled:!l||h.isPending,children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),i("spoolman.syncing")]}):a.jsxs(a.Fragment,{children:[a.jsx(pc,{className:"w-4 h-4"}),i("spoolman.linkToSpoolman")]})})]}),h.isError&&a.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:h.error.message})]})]})}function c8e(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 Uq(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 u8e=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function Bq(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of u8e){const s=new RegExp(`\\b${i}\\b`,"i");if(s.test(n)){const o=e.split(s),l=o[0]?.trim()||"",c=o[1]?.trim()||"";return{material:i,brand:l,variant:c}}}const r=e.split(/\s+/);return r.length>=2?{material:r[1],brand:r[0],variant:r.slice(2).join(" ")}:{material:e,brand:"",variant:""}}function d8e(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const h8e={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"},f8e=[{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"}],m8e=[{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 p8e(t){const e=t.toLowerCase().trim();return h8e[e]||null}function g8e({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:s}){const{t:o}=Yt(),[l,c]=_.useState(""),[u,d]=_.useState(null),[h,p]=_.useState(""),[m,b]=_.useState(""),[y,x]=_.useState(""),[v,S]=_.useState(!1),[N,T]=_.useState(!1),{data:M,isLoading:A}=nt({queryKey:["cloudSettings"],queryFn:()=>ae.getCloudSettings(),enabled:t}),{data:k,isLoading:R}=nt({queryKey:["localPresets"],queryFn:()=>ae.getLocalPresets(),enabled:t}),{data:C,isLoading:P}=nt({queryKey:["kprofiles",n,i],queryFn:()=>ae.getKProfiles(n,i),enabled:t&&!!n}),U=dt({mutationFn:async()=>{if(!l)throw new Error("No filament preset selected");const H=l.startsWith("local_"),W=H?parseInt(l.replace("local_",""),10):null,J=H?k?.filament.find(X=>X.id===W):null,ne=H?null:M?.filament.find(X=>X.setting_id===l);if(!H&&!ne)throw new Error("Selected preset not found");if(H&&!J)throw new Error("Selected local preset not found");const xe=H?J.name:ne.name,ue=Bq(xe),fe=u?.slot_id??-1,De=h||r.trayColor?.slice(0,6)||"FFFFFF",oe=xe.replace(/@.+$/,"").trim();let Ne,Fe;if(H)Ne="",Fe="";else if(Ne=Uq(l),Fe=l,!l.startsWith("GFS"))try{const X=await ae.getCloudSettingDetail(l);X.filament_id?Ne=X.filament_id:X.base_id&&(Ne=Uq(X.base_id),console.log(`Derived tray_info_idx from base_id: ${X.base_id} -> ${Ne}`))}catch(X){console.warn("Failed to fetch preset detail for filament_id:",X)}let ce=H&&J?.nozzle_temp_min?J.nozzle_temp_min:190,Ve=H&&J?.nozzle_temp_max?J.nozzle_temp_max:230;if(!H||!J?.nozzle_temp_min&&!J?.nozzle_temp_max){const X=(H&&J?.filament_type||ue.material).toUpperCase();X.includes("PLA")?(ce=190,Ve=230):X.includes("PETG")?(ce=220,Ve=260):X.includes("ABS")||X.includes("ASA")?(ce=240,Ve=280):X.includes("TPU")?(ce=200,Ve=240):X.includes("PC")?(ce=260,Ve=300):(X.includes("PA")||X.includes("NYLON"))&&(ce=250,Ve=290)}const V=u?.k_value?parseFloat(u.k_value):0,Y=H?J?.filament_type||ue.material||"PLA":ue.material||"PLA",de=await ae.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:Ne,tray_type:Y,tray_sub_brands:oe,tray_color:De+"FF",nozzle_temp_min:ce,nozzle_temp_max:Ve,cali_idx:fe,nozzle_diameter:i,setting_id:Fe,kprofile_filament_id:u?.filament_id,kprofile_setting_id:u?.setting_id||void 0,k_value:V}),q=H?`local_${W}`:l,re=H?"local":"cloud";try{await ae.saveSlotPreset(n,r.amsId,r.trayId,q,oe,re)}catch(X){console.warn("Failed to save slot preset mapping:",X)}return de},onSuccess:()=>{S(!0),s?.(),setTimeout(()=>{S(!1),e()},1500)}}),F=dt({mutationFn:async()=>ae.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{S(!0),s?.(),setTimeout(()=>{S(!1),e()},1500)}}),B=_.useMemo(()=>{const H=y.toLowerCase(),W=[];if(k?.filament)for(const J of k.filament)(!H||J.name.toLowerCase().includes(H))&&W.push({id:`local_${J.id}`,name:J.name,source:"local",isUser:!1});if(M?.filament)for(const J of M.filament)(!H||J.name.toLowerCase().includes(H))&&W.push({id:J.setting_id,name:J.name,source:"cloud",isUser:d8e(J.setting_id)});return W.sort((J,ne)=>J.source==="local"&&ne.source!=="local"?-1:J.source!=="local"&&ne.source==="local"?1:J.isUser&&!ne.isUser?-1:!J.isUser&&ne.isUser?1:J.name.localeCompare(ne.name))},[M?.filament,k?.filament,y]),D=_.useMemo(()=>{if(!l)return null;let H=null;if(l.startsWith("local_")){const ne=parseInt(l.replace("local_",""),10);H=k?.filament.find(ue=>ue.id===ne)?.name||null}else M?.filament&&(H=M.filament.find(xe=>xe.setting_id===l)?.name||null);if(!H)return null;let W=H.replace(/@.+$/,"").trim();W.startsWith("# ")&&(W=W.slice(2).trim());const J=Bq(W);return{fullName:W,material:J.material,brand:J.brand}},[l,M?.filament,k?.filament]),$=D?.fullName||"",G=_.useMemo(()=>{if(!C?.profiles||!D)return[];const{fullName:H,material:W,brand:J}=D,ne=H.toUpperCase(),xe=W.toUpperCase(),ue=J.toUpperCase();if(!xe||xe.length<2)return[];const fe=C.profiles.filter(oe=>{const Ne=oe.name.toUpperCase();if(ue)return!(!Ne.includes(ue)||!Ne.includes(xe));if(Ne.includes(ne)||Ne.includes(xe))return!0;const ce={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[xe]||[];for(const Ve of ce)if(Ne.includes(Ve))return!0;return!1}),De=new Map;for(const oe of fe){const Ne=`${oe.name}|${oe.k_value}`,Fe=De.get(Ne);Fe?oe.extruder_id===1&&Fe.extruder_id===0&&De.set(Ne,oe):De.set(Ne,oe)}return Array.from(De.values())},[C?.profiles,D]);_.useEffect(()=>{if(t&&M?.filament){if(r.trayInfoIdx){const H=M.filament.find(W=>W.setting_id===r.trayInfoIdx);H&&c(H.setting_id)}}else t||(c(""),d(null),p(""),b(""),x(""),S(!1))},[t,M?.filament,r.trayInfoIdx]),_.useEffect(()=>{G.length>0?d(G[0]):d(null)},[l,G]);const I=_.useCallback(H=>{H.key==="Escape"&&e()},[e]);if(_.useEffect(()=>{if(t)return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[t,I]),!t)return null;const K=A||R||P,Q=l&&!U.isPending,se=h||r.trayColor?.slice(0,6)||"FFFFFF";return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Gu,{className:"w-5 h-5 text-bambu-blue"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[v&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:a.jsxs("div",{className:"text-center space-y-3",children:[a.jsx(Kg,{className:"w-16 h-16 text-bambu-green mx-auto"}),a.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:o("configureAmsSlot.settingsSentToPrinter")})]})}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),a.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),a.jsxs("span",{className:"text-white font-medium",children:[c8e(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&a.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),K?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:o("configureAmsSlot.searchPresets"),value:y,onChange:H=>x(H.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:B.length===0?a.jsx("p",{className:"text-center py-4 text-bambu-gray",children:M?.filament?.length===0&&!k?.filament?.length?"No presets available. Login to Bambu Cloud or import local profiles.":"No matching presets found."}):B.map(H=>a.jsx("button",{onClick:()=>c(H.id),className:`w-full p-2 rounded-lg border text-left transition-colors ${l===H.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-white text-sm truncate",children:H.name}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[H.source==="local"&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/20 text-green-400",children:o("profiles.localProfiles.badge")}),H.isUser&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:o("configureAmsSlot.custom")})]})]})},H.id))})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",$&&a.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",$]})]}),G.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:u?.name||"",onChange:H=>{const W=G.find(J=>J.name===H.target.value);d(W||null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10",children:[a.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),G.map(H=>a.jsxs("option",{value:H.name,children:[H.name," (K=",H.k_value,")"]},`${H.name}-${H.extruder_id}`))]}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):l?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):a.jsx("span",{className:"inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"Select a filament profile first"}),u&&a.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",u.k_value," from printer calibration"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[f8e.map(H=>a.jsx("button",{onClick:()=>{p(H.hex),b(H.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${h===H.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${H.hex}`},title:H.name},H.hex)),a.jsx("button",{onClick:()=>T(!N),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:N?"Show less colors":"Show more colors",children:N?"−":"+"})]}),N&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:m8e.map(H=>a.jsx("button",{onClick:()=>{p(H.hex),b(H.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${h===H.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${H.hex}`},title:H.name},H.hex))}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${se}`}}),a.jsx("input",{type:"text",placeholder:o("configureAmsSlot.colorPlaceholder"),value:m,onChange:H=>{const W=H.target.value;b(W);const J=p8e(W);if(J)p(J);else{const ne=W.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();ne.length===6?p(ne):ne.length===3&&p(ne.split("").map(xe=>xe+xe).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"}),h&&a.jsx("button",{onClick:()=>{p(""),b("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:o("configureAmsSlot.clearCustomColor"),children:"Clear"})]}),h&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",h]})]})]})]}),a.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:()=>F.mutate(),disabled:F.isPending||U.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:F.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Vu,{className:"w-4 h-4"}),"Reset Slot"]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Me,{onClick:()=>U.mutate(),disabled:!Q,children:U.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Gu,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(U.isError||F.isError)&&a.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:U.error?.message||F.error?.message})]})]})}const Hq={"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"},b8e={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 yP(t){if(!t)return null;if(Hq[t])return Hq[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return b8e[n]||null}function vP(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,s=Math.min(e,n,r)/255,o=(i+s)/2;let l=0,c=0;if(i!==s){const u=i-s;c=o>.5?u/(2-i-s):u/(i+s);const d=e/255,h=n/255,p=r/255;i===d?l=((h-p)/u+(h<p?6:0))/6:i===h?l=((p-d)/u+2)/6:l=((d-h)/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":"Pink"}function wP(t){return(t??.02).toFixed(3)}function $q({side:t}){const{mode:e}=Fm(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return a.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function Iee(t){if(!t||t==="00000000"||t.length<6)return null;const e=t.slice(0,2),n=t.slice(2,4),r=t.slice(4,6),i=t.length>=8?parseInt(t.slice(6,8),16)/255:1;return i===0?null:`rgba(${parseInt(e,16)}, ${parseInt(n,16)}, ${parseInt(r,16)}, ${i})`}function x8e(t){if(!t||t.length<6)return!1;const e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return(.299*e+.587*n+.114*r)/255>.6}function zee(t,e){if(!t)return"";if(t.includes("hardened"))return e("printers.nozzleHardenedSteel");if(t.includes("stainless"))return e("printers.nozzleStainlessSteel");if(t.includes("tungsten"))return e("printers.nozzleTungstenCarbide");if(t.length>=4){const n=t.slice(2,4);if(n==="00")return e("printers.nozzleStainlessSteel");if(n==="01")return e("printers.nozzleHardenedSteel");if(n==="05")return e("printers.nozzleTungstenCarbide")}return t==="00"?e("printers.nozzleStainlessSteel"):t==="01"?e("printers.nozzleHardenedSteel"):t==="05"?e("printers.nozzleTungstenCarbide"):t.startsWith("H")?e("printers.nozzleHardenedSteel"):t}function Uee(t,e){return t?t.startsWith("HH")?e("printers.nozzleHighFlow"):t.startsWith("HS")?e("printers.nozzleStandardFlow"):"":""}function Bee({slot:t,index:e,activeStatus:n,filamentName:r,children:i}){const{t:s}=Yt(),[o,l]=_.useState(!1),[c,u]=_.useState("top"),d=_.useRef(null),h=_.useRef(null),p=_.useRef(null),m=!t.nozzle_diameter&&!t.nozzle_type,b=t.stat===1;_.useEffect(()=>{if(o&&d.current&&h.current){const T=d.current.getBoundingClientRect(),M=h.current.offsetHeight,k=T.top-56,R=window.innerHeight-T.bottom;k<M+12&&R>k?u("bottom"):u("top")}},[o]);const y=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>l(!0),80)},x=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>l(!1),100)};_.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const v=Iee(t.filament_color),S=zee(t.nozzle_type,s),N=Uee(t.nozzle_type,s);return a.jsxs("div",{ref:d,className:"relative",onMouseEnter:y,onMouseLeave:x,children:[i,o&&a.jsxs("div",{ref:h,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsx("div",{className:"w-44 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm",children:m?a.jsxs("div",{className:"px-3 py-2 text-xs text-bambu-gray text-center whitespace-nowrap",children:["Slot ",e+1," — Empty"]}):a.jsxs("div",{className:"p-2.5 space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleDiameter")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[t.nozzle_diameter," mm"]})]}),S&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleType")}),a.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[100px]",children:S})]}),N&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleFlow")}),a.jsx("span",{className:"text-xs text-white font-semibold",children:N})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleStatus")}),a.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${n||b?"bg-green-900/50 text-green-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s(n?"printers.nozzleActive":b?"printers.nozzleMounted":"printers.nozzleDocked")})]}),t.wear!=null&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleWear")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[t.wear,"%"]})]}),t.max_temp>0&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleMaxTemp")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[t.max_temp,"°C"]})]}),t.serial_number&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleSerial")}),a.jsx("span",{className:"text-[10px] text-white font-mono truncate max-w-[80px]",children:t.serial_number})]}),(v||t.filament_type)&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:s("printers.nozzleFilament")}),a.jsxs("div",{className:"flex items-center gap-1",children:[v&&a.jsx("div",{className:"w-3 h-3 rounded-sm border border-white/20",style:{backgroundColor:v}}),a.jsx("span",{className:"text-[10px] text-white font-semibold truncate max-w-[100px]",children:r||t.filament_type||t.filament_id||""})]})]})]})}),a.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function y8e({leftSlot:t,rightSlot:e,activeNozzle:n,children:r}){const{t:i}=Yt(),[s,o]=_.useState(!1),[l,c]=_.useState("top"),u=_.useRef(null),d=_.useRef(null),h=_.useRef(null);_.useEffect(()=>{if(s&&u.current&&d.current){const y=u.current.getBoundingClientRect(),x=d.current.offsetHeight,S=y.top-56,N=window.innerHeight-y.bottom;S<x+12&&N>S?c("bottom"):c("top")}},[s]);const p=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>o(!0),80)},m=()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>o(!1),100)};if(_.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]),!t&&!e)return a.jsx(a.Fragment,{children:r});const b=(y,x)=>{const v=n===x,S=zee(y.nozzle_type,i),N=Uee(y.nozzle_type,i);return a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx("div",{className:`text-[10px] font-bold pb-1 border-b border-bambu-dark-tertiary/50 ${v?"text-amber-400":"text-bambu-gray"}`,children:i(x==="L"?"common.left":"common.right")}),y.nozzle_diameter&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleDiameter")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[y.nozzle_diameter," mm"]})]}),S&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleType")}),a.jsx("span",{className:"text-[10px] text-white font-semibold",children:S})]}),N&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleFlow")}),a.jsx("span",{className:"text-[10px] text-white font-semibold",children:N})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleStatus")}),a.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${v?"bg-green-900/50 text-green-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:i(v?"printers.nozzleActive":"printers.nozzleIdle")})]}),y.wear!=null&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleWear")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[y.wear,"%"]})]}),x==="R"&&y.max_temp>0&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleMaxTemp")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[y.max_temp,"°C"]})]}),x==="R"&&y.serial_number&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:i("printers.nozzleSerial")}),a.jsx("span",{className:"text-[10px] text-white font-mono",children:y.serial_number})]})]})};return a.jsxs("div",{ref:u,className:"relative flex-1",onMouseEnter:p,onMouseLeave:m,children:[r,s&&a.jsxs("div",{ref:d,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${l==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsx("div",{className:"w-96 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm",children:a.jsxs("div",{className:"p-2.5 flex gap-3",children:[t&&b(t,"L"),t&&e&&a.jsx("div",{className:"w-px bg-bambu-dark-tertiary/50"}),e&&b(e,"R")]})}),a.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${l==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function v8e({slots:t,filamentInfo:e}){const{t:n}=Yt(),r=t.filter(l=>l.id>=2),i=6,s=r.length>0?Math.min(...r.map(l=>l.id)):16,o=Array.from({length:i},(l,c)=>r.find(u=>u.id===s+c)??{id:-(c+1),nozzle_type:"",nozzle_diameter:"",wear:null,stat:null,max_temp:0,serial_number:"",filament_color:"",filament_id:"",filament_type:""});return a.jsxs("div",{className:"text-center px-2.5 py-1.5 bg-bambu-dark rounded-lg flex-[2_1_190px] flex flex-col justify-center",children:[a.jsx("p",{className:"text-[9px] text-bambu-gray mb-1",children:n("printers.nozzleRack")}),a.jsx("div",{className:"flex gap-[3px] justify-center",children:o.map((l,c)=>{const u=!l.nozzle_diameter&&!l.nozzle_type,d=u?null:Iee(l.filament_color),h=d?x8e(l.filament_color):!1;return a.jsx(Bee,{slot:l,index:c,filamentName:l.filament_id?e?.[l.filament_id]?.name:void 0,children:a.jsx("div",{className:`w-7 h-7 rounded flex items-center justify-center cursor-default transition-colors border-b-2 ${u?"bg-bambu-dark-tertiary/20 border-bambu-dark-tertiary/20":"bg-bambu-dark-tertiary/40 border-bambu-dark-tertiary/40"}`,style:d?{backgroundColor:d}:void 0,children:a.jsx("span",{className:`text-[10px] font-semibold ${u?"text-bambu-gray/30":h?"text-black/80":"text-white"}`,style:d&&!h?{textShadow:"0 1px 3px rgba(0,0,0,0.9)"}:void 0,children:u?"—":l.nozzle_diameter||"?"})})},l.id>=0?l.id:`empty-${c}`)})})]})}function Vq({className:t}){return a.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function w8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),a.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function _8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),a.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function S8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function N8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function k8e({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function _P({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",s=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?a.jsxs("svg",{className:t,style:s,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function Gq({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const s=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(s)?(c="#C3C2C1",u="Unknown"):s<=o?(c="#22a352",u="Good"):s<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(s)||s<=o?d=Vq:s<=l?d=w8e:d=_8e,a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${s}% - ${u}${r?" (click for history)":""}`,children:[a.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[s,"%"]})]})}function qq({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const s=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=s?(l="#22a352",c="Good",u=S8e):t<=o?(l="#d4a017",c="Fair",u=N8e):(l="#c62828",c="Bad",u=k8e),a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[a.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Gd(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,s=r>=128?r-128:r,o=String.fromCharCode(65+s);return i?`HT-${o}`:`AMS-${o}`}function SP(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function NP(t){return!t?.remaining_weight||!t?.filament_weight||t.filament_weight<=0?null:Math.min(100,Math.round(t.remaining_weight/t.filament_weight*100))}function M8e(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function E8e(t,e="system"){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const s=new Date(r);s.setHours(0,0,0,0);const o={hour:"2-digit",minute:"2-digit"};e==="12h"?o.hour12=!0:e==="24h"&&(o.hour12=!1);const l=r.toLocaleTimeString([],o),c=Math.floor((s.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function T8e(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")?"/img/printers/h2d.png":e.includes("h2c")?"/img/printers/h2c.png":e.includes("h2s")?"/img/printers/h2d.png":e.includes("p2s")||e.includes("p1s")?"/img/printers/p1s.png":e.includes("p1p")?"/img/printers/p1p.png":e.includes("a1mini")?"/img/printers/a1mini.png":e.includes("a1")?"/img/printers/a1.png":"/img/printers/default.png"}function A8e(t){return t>=-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 kP(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 C8e({url:t,printName:e}){const{t:n}=Yt(),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.useState(!1),u=_.useMemo(()=>{if(!t)return null;const d=t.includes("?")?"&":"?";return`${t}${d}v=${encodeURIComponent(e||Date.now().toString())}`},[t,e]);return _.useEffect(()=>{i(!1),o(!1)},[u]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${u&&r?"cursor-pointer":""}`,onClick:()=>u&&r&&c(!0),children:u&&!s?a.jsxs(a.Fragment,{children:[a.jsx("img",{src:u,alt:n("printers.printPreview"),className:`w-full h-full object-cover ${r?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>o(!0)}),!r&&a.jsx(zi,{className:"w-8 h-8 text-bambu-gray"})]}):a.jsx(zi,{className:"w-8 h-8 text-bambu-gray"})}),l&&u&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>c(!1),children:a.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[a.jsx("img",{src:u,alt:n("printers.printPreview"),className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&a.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function P8e({printers:t}){const{t:e}=Yt(),n=nn(),r=_.useMemo(()=>{let s=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"?s++:o++:l++}),{printing:s,idle:o,offline:l,loading:c,total:t?.length||0}},[t,n]),[,i]=_.useState(0);return _.useEffect(()=>{let s=!1;const o=n.getQueryCache().subscribe(()=>{s||(s=!0,requestAnimationFrame(()=>{i(l=>l+1),s=!1}))});return()=>o()},[n]),t?.length?a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.printing>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.printing})," ",e("printers.status.printing").toLowerCase()]})]}),r.idle>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.idle})," ",e("printers.status.idle").toLowerCase()]})]}),r.offline>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:r.offline})," ",e("printers.status.offline").toLowerCase()]})]})]}):null}function Wq(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 Kq({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:s,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:u,timeFormat:d="system",cameraViewMode:h="window",onOpenEmbeddedCamera:p,checkPrinterFirmware:m=!0}){const{t:b}=Yt(),y=nn(),x=Pc(),{showToast:v}=kn(),{hasPermission:S}=Rr(),[N,T]=_.useState(!1),[M,A]=_.useState(!1),[k,R]=_.useState(!0),[C,P]=_.useState(!1),[U,F]=_.useState(!1),[B,D]=_.useState(!1),[$,G]=_.useState(!1),[I,K]=_.useState(!1),[Q,se]=_.useState(!1),[H,W]=_.useState(!1),[J,ne]=_.useState(!1),[xe,ue]=_.useState(!1),[fe,De]=_.useState(!1),[oe,Ne]=_.useState(null),[Fe,ce]=_.useState(null),[Ve,V]=_.useState(null),[Y,de]=_.useState(!1),[q,re]=_.useState(null),[X,le]=_.useState(!1),[pe,ee]=_.useState(!1),[z,O]=_.useState(null),[Z,me]=_.useState(!1),[Te,ke]=_.useState(!1),{data:Ee}=nt({queryKey:["printerStatus",t.id],queryFn:()=>ae.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Se}=nt({queryKey:["firmwareUpdate",t.id],queryFn:()=>P1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:m&&S("firmware:read")}),$e=_.useMemo(()=>{const gt=new Set;if(Ee?.ams)for(const Rt of Ee.ams)for(const on of Rt.tray||[])on.tray_info_idx&>.add(on.tray_info_idx);if(Ee?.vt_tray?.tray_info_idx&>.add(Ee.vt_tray.tray_info_idx),Ee?.nozzle_rack)for(const Rt of Ee.nozzle_rack)Rt.filament_id&>.add(Rt.filament_id);return Array.from(gt)},[Ee?.ams,Ee?.vt_tray,Ee?.nozzle_rack]),{data:Qe}=nt({queryKey:["filamentInfo",$e],queryFn:()=>ae.getFilamentInfo($e),enabled:$e.length>0,staleTime:300*1e3}),{data:Ue}=nt({queryKey:["slotPresets",t.id],queryFn:()=>ae.getSlotPresets(t.id),staleTime:120*1e3}),[be,ve]=_.useState(null);_.useEffect(()=>{Ee?.wifi_signal!=null&&ve(Ee.wifi_signal)},[Ee?.wifi_signal]);const ze=Ee?.wifi_signal??be,Ce=_.useRef(void 0);_.useEffect(()=>{Ee?.connected!==void 0&&(Ce.current=Ee.connected)},[Ee?.connected]);const Ge=Ee?.connected??Ce.current,_e=_.useRef({});_.useEffect(()=>{Ee?.ams_extruder_map&&Object.keys(Ee.ams_extruder_map).length>0&&(_e.current=Ee.ams_extruder_map)},[Ee?.ams_extruder_map]);const Je=Ee?.ams_extruder_map&&Object.keys(Ee.ams_extruder_map).length>0?Ee.ams_extruder_map:_e.current,Ae=_.useRef([]);_.useEffect(()=>{Ee?.ams&&Ee.ams.length>0&&(Ae.current=Ee.ams)},[Ee?.ams]);const Ke=Ee?.ams&&Ee.ams.length>0?Ee.ams:Ae.current,je=_.useRef(255),Re=Ee?.tray_now;Re!==void 0&&Re!==255&&(je.current=Re);const we=Re===void 0||Re===255?je.current:Re,{data:qe}=nt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ae.getSmartPlugByPrinter(t.id)}),{data:xt}=nt({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>ae.getScriptPlugsByPrinter(t.id)}),{data:Et}=nt({queryKey:["smartPlugStatus",qe?.id],queryFn:()=>qe?ae.getSmartPlugStatus(qe.id):null,enabled:!!qe,refetchInterval:1e4}),{data:fn}=nt({queryKey:["queue",t.id,"pending"],queryFn:()=>ae.getQueue(t.id,"pending")}),It=fn?.length||0,{data:Oe}=nt({queryKey:["queue",t.id,"printing"],queryFn:()=>ae.getQueue(t.id,"printing"),enabled:Ee?.state==="RUNNING"}),{data:yt}=nt({queryKey:["currentPrintUser",t.id],queryFn:()=>ae.getCurrentPrintUser(t.id),enabled:Ee?.state==="RUNNING"}),Wt=Oe?.[0]?.created_by_username||yt?.username,{data:rn}=nt({queryKey:["archives",t.id,"last"],queryFn:()=>ae.getArchives(t.id,1,0),enabled:Ee?.connected&&Ee?.state!=="RUNNING"}),Qt=rn?.[0],ur=e&&Ge===!1,Lr=dt({mutationFn:gt=>ae.deletePrinter(t.id,gt.deleteArchives),onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["archives"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:gt=>v(gt.message||b("printers.toast.failedToDelete"),"error")}),nr=dt({mutationFn:()=>ae.connectPrinter(t.id),onSuccess:()=>{y.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Xt=dt({mutationFn:gt=>qe?ae.controlSmartPlug(qe.id,gt):Promise.reject("No plug"),onSuccess:()=>{y.invalidateQueries({queryKey:["smartPlugStatus",qe?.id]})}}),Zn=dt({mutationFn:gt=>qe?ae.updateSmartPlug(qe.id,{auto_off:gt}):Promise.reject("No plug"),onSuccess:()=>{y.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),y.invalidateQueries({queryKey:["smart-plugs"]})}}),oi=dt({mutationFn:gt=>ae.controlSmartPlug(gt,"on"),onSuccess:()=>{v(b("printers.toast.scriptTriggered"))},onError:gt=>v(gt.message||b("printers.toast.failedToRunScript"),"error")}),da=dt({mutationFn:()=>ae.stopPrint(t.id),onSuccess:()=>{v(b("printers.toast.printStopped")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:gt=>v(gt.message||b("printers.toast.failedToStopPrint"),"error")}),Pe=dt({mutationFn:()=>ae.pausePrint(t.id),onSuccess:()=>{v(b("printers.toast.printPaused")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:gt=>v(gt.message||b("printers.toast.failedToPausePrint"),"error")}),tt=dt({mutationFn:()=>ae.resumePrint(t.id),onSuccess:()=>{v(b("printers.toast.printResumed")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:gt=>v(gt.message||b("printers.toast.failedToResumePrint"),"error")}),ht=dt({mutationFn:gt=>ae.setChamberLight(t.id,gt),onMutate:async gt=>{await y.cancelQueries({queryKey:["printerStatus",t.id]});const Rt=y.getQueryData(["printerStatus",t.id]);return y.setQueryData(["printerStatus",t.id],on=>({...on,chamber_light:gt})),{previousStatus:Rt}},onSuccess:(gt,Rt)=>{v(`Chamber light ${Rt?"on":"off"}`)},onError:(gt,Rt,on)=>{on?.previousStatus&&y.setQueryData(["printerStatus",t.id],on.previousStatus),v(gt.message||b("printers.toast.failedToControlChamberLight"),"error")}}),mt=dt({mutationFn:gt=>ae.updatePrinter(t.id,{plate_detection_enabled:gt}),onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),v(mt.variables?b("printers.toast.plateCheckEnabled"):b("printers.toast.plateCheckDisabled"))},onError:gt=>v(gt.message||b("printers.toast.failedToUpdateSetting"),"error")}),at=(Ee?.state==="RUNNING"||Ee?.state==="PAUSE"||Ee?.state==="PAUSED")&&(Ee?.printable_objects_count??0)>=2,{data:Dt}=nt({queryKey:["printableObjects",t.id],queryFn:()=>ae.getPrintableObjects(t.id),enabled:fe||at,refetchInterval:fe?5e3:at?3e4:!1}),[he,Ie]=_.useState(null),Xe=_.useRef(!1),He=_.useRef(null),ge=_.useRef(!1),rt=dt({mutationFn:({amsId:gt,slotId:Rt})=>ae.refreshAmsSlot(t.id,gt,Rt),onMutate:({amsId:gt,slotId:Rt})=>{He.current&&clearTimeout(He.current),Xe.current=!1,ge.current=!1,Ie({amsId:gt,slotId:Rt}),setTimeout(()=>{ge.current=!0},2e3),He.current=setTimeout(()=>{Ie(null)},3e4)},onSuccess:gt=>{v(gt.message||b("printers.toast.rfidRereadInitiated"))},onError:gt=>{v(gt.message||b("printers.toast.failedToRereadRfid"),"error"),He.current&&clearTimeout(He.current),Ie(null)}}),[ut,it]=_.useState(null),[Tt,Ut]=_.useState(null),jt=async()=>{try{const gt=await ae.getPlateReferences(t.id);it(gt)}catch{}},Ct=()=>{mt.mutate(!t.plate_detection_enabled)},an=async()=>{le(!0),re(null);const gt=Ee?.chamber_light===!1;ke(gt),gt&&(await ae.setChamberLight(t.id,!0),await new Promise(Rt=>setTimeout(Rt,2500)));try{const Rt=await ae.checkPlateEmpty(t.id,{includeDebugImage:!0});re(Rt),jt()}catch(Rt){v(Rt instanceof Error?Rt.message:b("printers.toast.failedToCheckPlate"),"error"),gt&&(await ae.setChamberLight(t.id,!1),ke(!1))}finally{le(!1)}},Vt=_.useCallback(async()=>{re(null),Te&&(await ae.setChamberLight(t.id,!1),ke(!1))},[Te,t.id]),gn=async gt=>{ee(!0);try{const Rt=await ae.calibratePlateDetection(t.id,{label:gt});if(Rt.success){v(Rt.message||b("printers.toast.calibrationSaved"),"success"),jt();const on=await ae.checkPlateEmpty(t.id,{includeDebugImage:!0});re(on)}else v(Rt.message||b("printers.toast.calibrationFailed"),"error")}catch(Rt){v(Rt instanceof Error?Rt.message:b("printers.toast.calibrationFailed"),"error")}finally{ee(!1)}},Mn=async(gt,Rt)=>{try{await ae.updatePlateReferenceLabel(t.id,gt,Rt),Ut(null),jt()}catch(on){v(on instanceof Error?on.message:b("printers.toast.failedToUpdateLabel"),"error")}},bn=async gt=>{try{await ae.deletePlateReference(t.id,gt),v(b("printers.toast.referenceDeleted"),"success"),jt();const Rt=await ae.checkPlateEmpty(t.id,{includeDebugImage:!0});re(Rt)}catch(Rt){v(Rt instanceof Error?Rt.message:b("printers.toast.failedToDeleteReference"),"error")}},qt=async()=>{if(z){me(!0);try{await ae.updatePrinter(t.id,{plate_detection_roi:z}),v(b("printers.toast.detectionAreaSaved"),"success"),O(null);const gt=await ae.checkPlateEmpty(t.id,{includeDebugImage:!0});re(gt)}catch(gt){v(gt instanceof Error?gt.message:b("printers.toast.failedToSaveDetectionArea"),"error")}finally{me(!1)}}};_.useEffect(()=>{const gt=Rt=>{Rt.key==="Escape"&&q&&Vt()};return window.addEventListener("keydown",gt),()=>window.removeEventListener("keydown",gt)},[q,Vt]);const sn=_.useRef(null);_.useEffect(()=>{if(!he)return;const gt=Ee?.ams_status_main??0;return gt!==0&&(Xe.current=!0,sn.current&&(clearTimeout(sn.current),sn.current=null)),Xe.current&>===0&&(ge.current?(He.current&&clearTimeout(He.current),Ie(null)):sn.current||(sn.current=setTimeout(()=>{He.current&&clearTimeout(He.current),Ie(null)},2e3))),()=>{sn.current&&clearTimeout(sn.current)}},[Ee?.ams_status_main,he]);const[Jt,mr]=_.useState(null);if(ur)return null;const Hr=()=>{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"}},Jn=()=>{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"}},Bn=()=>{switch(i){case 1:return"mb-2";case 2:return"mb-4";case 3:return"mb-5";case 4:return"mb-6";default:return"mb-4"}};return a.jsxs(_t,{className:"relative",children:[a.jsxs(Mt,{className:i>=3?"p-5":"",children:[a.jsxs("div",{className:Bn(),children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("img",{src:T8e(t.model),alt:t.model||b("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Hr()}`}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-semibold text-white ${Jn()}`,children:t.name}),r==="compact"&&a.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Ee?.connected?"bg-status-ok":"bg-status-error"}`,title:Ee?.connected?b("printers.connection.connected"):b("printers.connection.offline")})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&Ee?.nozzles&&Ee.nozzles[0]?.nozzle_diameter&&a.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:Ee.nozzles[0].nozzle_type||"Nozzle",children:["• ",Ee.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&a.jsxs("span",{className:"ml-2 text-bambu-gray",children:[a.jsx(er,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),a.jsxs("div",{className:"relative flex-shrink-0",children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>T(!N),children:a.jsx(ph,{className:"w-4 h-4"})}),N&&a.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-20",children:[a.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")&&(P(!0),T(!1))},title:S("printers:update")?void 0:b("printers.permission.noEdit"),children:[a.jsx(ea,{className:"w-4 h-4"}),b("common.edit")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{nr.mutate(),T(!1)},children:[a.jsx(Ir,{className:"w-4 h-4"}),b("printers.reconnect")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{D(!0),T(!1)},children:[a.jsx(KW,{className:"w-4 h-4"}),b("printers.mqttDebug")]}),a.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")&&(A(!0),T(!1))},title:S("printers:delete")?void 0:b("printers.permission.noDelete"),children:[a.jsx(hn,{className:"w-4 h-4"}),b("common.delete")]})]})]})]}),r==="expanded"&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[a.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${Ee?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[Ee?.connected?a.jsx(Vy,{className:"w-3 h-3"}):a.jsx(ZR,{className:"w-3 h-3"}),Ee?.connected?b("printers.connection.connected"):b("printers.connection.offline")]}),Ee?.connected&&ze!=null&&a.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${ze>=-50||ze>=-60?"bg-status-ok/20 text-status-ok":ze>=-70?"bg-status-warning/20 text-status-warning":ze>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${ze} dBm - ${b(A8e(ze).labelKey)}`,children:[a.jsx(Khe,{className:"w-3 h-3"}),ze,"dBm"]}),Ee?.connected&&(()=>{const gt=Ee.hms_errors?dMe(Ee.hms_errors):[];return a.jsxs("button",{onClick:()=>se(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${gt.length>0?gt.some(Rt=>Rt.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:b("printers.clickToViewHmsErrors"),children:[a.jsx(En,{className:"w-3 h-3"}),gt.length>0?gt.length:"OK"]})})(),n&&a.jsxs("button",{onClick:()=>x("/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`:b("printers.maintenanceUpToDate"),children:[a.jsx(xm,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),It>0&&a.jsxs("button",{onClick:()=>x("/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:b("printers.queue.inQueue",{count:It}),children:[a.jsx(is,{className:"w-3 h-3"}),It]}),Se?.current_version&&Se?.latest_version&&a.jsxs("button",{onClick:()=>de(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs hover:opacity-80 transition-opacity ${Se.update_available?"bg-orange-500/20 text-orange-400":"bg-status-ok/20 text-status-ok"}`,title:Se.update_available?b("printers.firmwareUpdateAvailable",{current:Se.current_version,latest:Se.latest_version}):b("printers.firmwareUpToDate",{version:Se.current_version}),children:[Se.update_available?a.jsx(_i,{className:"w-3 h-3"}):a.jsx(fr,{className:"w-3 h-3"}),Se.current_version]})]})]}),M&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(_t,{className:"w-full max-w-md mx-4",children:a.jsxs(Mt,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:a.jsx(En,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:b("printers.confirm.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:b("printers.confirm.deleteMessage",{name:t.name})})]})]}),a.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k,onChange:gt=>R(gt.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:b("printers.deleteArchives")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:b(k?"printers.confirm.deleteArchivesNote":"printers.confirm.keepArchivesNote")})]})]})}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{A(!1),R(!0)},children:b("common.cancel")}),a.jsx(Me,{variant:"danger",onClick:()=>{Lr.mutate({deleteArchives:k}),A(!1),R(!0)},children:"Delete"})]})]})})}),Ee?.connected&&a.jsxs(a.Fragment,{children:[r==="compact"?a.jsx("div",{className:"mt-2",children:Ee.state==="RUNNING"?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:a.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${Ee.progress||0}%`}})}),a.jsxs("span",{className:"text-xs text-white",children:[Math.round(Ee.progress||0),"%"]})]}):a.jsx("p",{className:"text-xs text-bambu-gray",children:Wq(Ee.state,Ee.stg_cur_name)})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[a.jsxs("button",{onClick:()=>De(!0),disabled:!(Ee.state==="RUNNING"||Ee.state==="PAUSE"||Ee.state==="PAUSED")||(Ee.printable_objects_count??0)<2||!S("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(Ee.state==="RUNNING"||Ee.state==="PAUSE"||Ee.state==="PAUSED")&&(Ee.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")?Ee.state==="RUNNING"||Ee.state==="PAUSE"||Ee.state==="PAUSED"?(Ee.printable_objects_count??0)>=2?b("printers.skipObjects.tooltip"):b("printers.skipObjects.requiresMultiple"):b("printers.skipObjects.onlyWhilePrinting"):b("printers.permission.noControl"),children:[a.jsx(Gk,{className:"w-4 h-4"}),Dt&&Dt.skipped_count>0&&a.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full",children:Dt.skipped_count})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(C8e,{url:Ee.state==="RUNNING"?Ee.cover_url:null,printName:Ee.state==="RUNNING"&&(Ee.subtask_name||Ee.current_print)||void 0}),a.jsx("div",{className:"flex-1 min-w-0",children:Ee.current_print&&Ee.state==="RUNNING"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:Ee.stg_cur_name||"Printing"}),a.jsx("p",{className:"text-white text-sm mb-2 truncate",children:Ee.subtask_name||Ee.current_print}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${Ee.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(Ee.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[Ee.remaining_time!=null&&Ee.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(er,{className:"w-3 h-3"}),M8e(Ee.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:b("printers.estimatedCompletion"),children:["ETA ",E8e(Ee.remaining_time,d)]})]}),Ee.layer_num!=null&&Ee.total_layers!=null&&Ee.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(is,{className:"w-3 h-3"}),Ee.layer_num,"/",Ee.total_layers]}),Wt&&a.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${Wt}`,children:[a.jsx(qu,{className:"w-3 h-3"}),Wt]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:b("printers.sort.status")}),a.jsx("p",{className:"text-white text-sm mb-2",children:Wq(Ee.state,Ee.stg_cur_name)}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),a.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Qt?a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Qt.print_name||Qt.filename,children:["Last: ",Qt.print_name||Qt.filename,Qt.completed_at&&a.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Xg(Qt.completed_at,{month:"short",day:"numeric"})]})]}):a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:b("printers.readyToPrint")})]})})]})]}),a.jsx(pMe,{printerId:t.id,printerState:Ee.state})]}),Ee.temperatures&&r==="expanded"&&(()=>{const gt=Ee.temperatures.nozzle_heating||Ee.temperatures.nozzle_2_heating||!1,Rt=Ee.temperatures.bed_heating||!1,on=Ee.temperatures.chamber_heating||!1,St=t.nozzle_count===2||Ee.temperatures.nozzle_2!==void 0,pn=Ee.active_extruder===1?"L":"R",rr=Ee.nozzle_rack?.find(ei=>ei.id===1),ir=Ee.nozzle_rack?.find(ei=>ei.id===0),gr=ir||rr;return a.jsxs("div",{className:"flex items-stretch gap-1.5 flex-wrap",children:[a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center",children:[a.jsx(_P,{className:"w-3.5 h-3.5 mb-0.5",color:"text-orange-400",isHeating:gt}),Ee.temperatures.nozzle_2!==void 0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(Ee.temperatures.nozzle||0),"° / ",Math.round(Ee.temperatures.nozzle_2||0),"°"]})]}):gr?a.jsx(Bee,{slot:gr,index:0,activeStatus:!0,filamentName:gr.filament_id?Qe?.[gr.filament_id]?.name:void 0,children:a.jsxs("div",{className:"cursor-default",children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.nozzle")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(Ee.temperatures.nozzle||0),"°C"]})]})}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.nozzle")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(Ee.temperatures.nozzle||0),"°C"]})]})]}),a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center",children:[a.jsx(_P,{className:"w-3.5 h-3.5 mb-0.5",color:"text-blue-400",isHeating:Rt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.bed")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(Ee.temperatures.bed||0),"°C"]})]}),Ee.temperatures.chamber!==void 0&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center",children:[a.jsx(_P,{className:"w-3.5 h-3.5 mb-0.5",color:"text-green-400",isHeating:on}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.chamber")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(Ee.temperatures.chamber||0),"°C"]})]}),St&&a.jsx(y8e,{leftSlot:rr,rightSlot:ir,activeNozzle:pn,children:a.jsxs("div",{className:"text-center px-3 py-1.5 bg-bambu-dark rounded-lg h-full flex flex-col justify-center items-center cursor-default",title:b("printers.activeNozzle",{nozzle:b(pn==="L"?"common.left":"common.right")}),children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("span",{className:`text-[11px] font-bold ${pn==="L"?"text-amber-400":"text-gray-500"}`,children:["L",rr?.nozzle_diameter?` ${rr.nozzle_diameter}`:""]}),a.jsx("span",{className:"text-[9px] text-bambu-gray/40",children:"·"}),a.jsxs("span",{className:`text-[11px] font-bold ${pn==="R"?"text-amber-400":"text-gray-500"}`,children:["R",ir?.nozzle_diameter?` ${ir.nozzle_diameter}`:""]})]}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:b("printers.temperatures.nozzle")})]})}),Ee.nozzle_rack&&Ee.nozzle_rack.some(ei=>ei.id>=2)&&a.jsx(v8e,{slots:Ee.nozzle_rack,filamentInfo:Qe})]})})(),r==="expanded"&&(()=>{const gt=Ee.state==="RUNNING",Rt=Ee.state==="PAUSED"||Ee.state==="PAUSE",on=gt||Rt,St=da.isPending||Pe.isPending||tt.isPending,pn=Ee.cooling_fan_speed,rr=Ee.big_fan1_speed,ir=Ee.big_fan2_speed;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:b("printers.controls")}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${pn&&pn>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:b("printers.fans.partCooling"),children:[a.jsx(IW,{className:`w-3.5 h-3.5 ${pn&&pn>0?"text-cyan-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${pn&&pn>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[pn??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${rr&&rr>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:b("printers.fans.auxiliary"),children:[a.jsx(YW,{className:`w-3.5 h-3.5 ${rr&&rr>0?"text-blue-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${rr&&rr>0?"text-blue-400":"text-bambu-gray/50"}`,children:[rr??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${ir&&ir>0?"bg-green-500/10":"bg-bambu-dark"}`,title:b("printers.fans.chamber"),children:[a.jsx(Tce,{className:`w-3.5 h-3.5 ${ir&&ir>0?"text-green-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${ir&&ir>0?"text-green-400":"text-bambu-gray/50"}`,children:[ir??0,"%"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>W(!0),disabled:!on||St||!S("printers:control"),className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${on&&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"}
- `,title:S("printers:control")?b("printers.stop"):b("printers.permission.noControl"),children:[a.jsx(ul,{className:"w-3 h-3"}),b("printers.stop")]}),a.jsxs("button",{onClick:()=>Rt?ue(!0):ne(!0),disabled:!on||St||!S("printers:control"),className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${on&&S("printers:control")?Rt?"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"}
- `,title:S("printers:control")?b(Rt?"printers.resume":"printers.pause"):b("printers.permission.noControl"),children:[Rt?a.jsx(To,{className:"w-3 h-3"}):a.jsx(Ak,{className:"w-3 h-3"}),b(Rt?"printers.resume":"printers.pause")]})]})]})]})})(),Ke&&Ke.length>0&&r==="expanded"&&(()=>{const gt=Ke.filter(St=>St.tray.length>1),Rt=Ke.filter(St=>St.tray.length===1),on=t.nozzle_count===2||Ee?.temperatures?.nozzle_2!==void 0;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:b("printers.filaments")}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"space-y-3",children:[gt.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:gt.map(St=>{const pn=Je[String(St.id)],rr=St.id>=128?St.id-128:St.id,ir=pn!==void 0?pn:rr,gr=ir===1,ei=ir===0;return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-[10px] text-white font-medium",children:Gd(St.id,St.tray.length)}),on&&(gr||ei)&&a.jsx($q,{side:gr?"L":"R"})]}),(St.humidity!=null||St.temp!=null)&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[St.humidity!=null&&a.jsx(Gq,{humidity:St.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>Ne({amsId:St.id,amsLabel:Gd(St.id,St.tray.length),mode:"humidity"}),compact:!0}),St.temp!=null&&a.jsx(qq,{temp:St.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>Ne({amsId:St.id,amsLabel:Gd(St.id,St.tray.length),mode:"temperature"}),compact:!0})]})]}),a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(Zt=>{const Sn=St.tray[Zt]||St.tray.find(Gr=>Gr.id===Zt),ha=Sn?.tray_type&&Sn.remain>=0,us=!Sn?.tray_type,Ma=St.id*4+Zt,Js=we===Ma,yl=Sn?.tray_info_idx?Qe?.[Sn.tray_info_idx]:null,Ci=Ue?.[Ma],ds=Sn?.tray_uuid?.toUpperCase(),Oc=ds?c?.[ds]:void 0,$a=NP(Oc),Ps=ha&&Sn.remain>0?Sn.remain:$a??(ha?Sn.remain:null),Ea=ha&&Sn.remain===0&&$a!==null?"spoolman":"ams",Sr=Sn?.tray_type?{vendor:kP(Sn)?"Bambu Lab":"Generic",profile:yl?.name||Ci?.preset_name||Sn.tray_sub_brands||Sn.tray_type,colorName:yP(Sn.tray_id_name)||vP(Sn.tray_color),colorHex:Sn.tray_color||null,kFactor:wP(Sn.k),fillLevel:Ps,trayUuid:Sn.tray_uuid||null,fillSource:Ea}:null,eo=he?.amsId===St.id&&he?.slotId===Zt,to=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${us?"opacity-50":""} ${Js?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:Sn?.tray_color?`#${Sn.tray_color}`:Sn?.tray_type?"#333":"transparent",borderColor:us?"#666":"rgba(255,255,255,0.1)",borderStyle:us?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Sn?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Ps!==null&&Ps>=0&&Sn?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Ps}%`,backgroundColor:SP(Ps)}}):Sn?.tray_type?a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return a.jsxs("div",{className:"relative group",children:[eo&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Ir,{className:"w-4 h-4 text-bambu-green animate-spin"})}),Ee?.state!=="RUNNING"&&a.jsx("button",{onClick:Gr=>{Gr.stopPropagation(),mr(Jt?.amsId===St.id&&Jt?.slotId===Zt?null:{amsId:St.id,slotId:Zt})},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:b("printers.slotOptions"),children:a.jsx(ph,{className:"w-2.5 h-2.5 text-bambu-gray"})}),Ee?.state!=="RUNNING"&&Jt?.amsId===St.id&&Jt?.slotId===Zt&&a.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${S("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Gr=>{Gr.stopPropagation(),S("printers:ams_rfid")&&(rt.mutate({amsId:St.id,slotId:Zt}),mr(null))},disabled:eo||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:b("printers.permission.noAmsRfid"),children:[a.jsx(Ir,{className:`w-3 h-3 ${eo?"animate-spin":""}`}),b("printers.rfid.reread")]})}),Sr?a.jsx(xP,{data:Sr,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Sr.trayUuid?c?.[Sr.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:u,onLinkSpool:o&&Sr.trayUuid?Gr=>{ce({trayUuid:Gr,trayInfo:{type:Sr.profile,color:Sr.colorHex||"",location:`${Gd(St.id,St.tray.length)} Slot ${Zt+1}`}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>V({amsId:St.id,trayId:Zt,trayCount:St.tray.length,trayType:Sn?.tray_type||void 0,trayColor:Sn?.tray_color||void 0,traySubBrands:Sn?.tray_sub_brands||void 0,trayInfoIdx:Sn?.tray_info_idx||void 0})},children:to}):a.jsx(zq,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>V({amsId:St.id,trayId:Zt,trayCount:St.tray.length})},children:to})]},Zt)})})]},St.id)})}),(Rt.length>0||Ee.vt_tray&&Ee.vt_tray.tray_type)&&a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Rt.map(St=>{const pn=Je[String(St.id)],rr=St.id>=128?St.id-128:St.id,ir=pn!==void 0?pn:rr,gr=ir===1,ei=ir===0,Zt=St.tray[0],Sn=Zt?.tray_type&&Zt.remain>=0,ha=!Zt?.tray_type,us=St.id*4+(Zt?.id??0),Ma=we===us,Js=Zt?.tray_info_idx?Qe?.[Zt.tray_info_idx]:null,yl=Ue?.[us],Ci=Zt?.tray_uuid?.toUpperCase(),ds=Ci?c?.[Ci]:void 0,Oc=NP(ds),$a=Sn&&Zt.remain>0?Zt.remain:Oc??(Sn?Zt.remain:null),Ps=Sn&&Zt.remain===0&&Oc!==null?"spoolman":"ams",Ea=Zt?.tray_type?{vendor:kP(Zt)?"Bambu Lab":"Generic",profile:Js?.name||yl?.preset_name||Zt.tray_sub_brands||Zt.tray_type,colorName:yP(Zt.tray_id_name)||vP(Zt.tray_color),colorHex:Zt.tray_color||null,kFactor:wP(Zt.k),fillLevel:$a,trayUuid:Zt.tray_uuid||null,fillSource:Ps}:null,Sr=Zt?.id??0,eo=he?.amsId===St.id&&he?.slotId===Sr,to=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${ha?"opacity-50":""} ${Ma?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:Zt?.tray_color?`#${Zt.tray_color}`:Zt?.tray_type?"#333":"transparent",borderColor:ha?"#666":"rgba(255,255,255,0.1)",borderStyle:ha?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Zt?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:$a!==null&&$a>=0?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${$a}%`,backgroundColor:SP($a)}}):Zt?.tray_type?a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[a.jsx("span",{className:"text-[10px] text-white font-medium",children:Gd(St.id,St.tray.length)}),on&&(gr||ei)&&a.jsx($q,{side:gr?"L":"R"})]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsxs("div",{className:"relative group flex-1",children:[eo&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Ir,{className:"w-4 h-4 text-bambu-green animate-spin"})}),Ee?.state!=="RUNNING"&&a.jsx("button",{onClick:Gr=>{Gr.stopPropagation(),mr(Jt?.amsId===St.id&&Jt?.slotId===Sr?null:{amsId:St.id,slotId:Sr})},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:b("printers.slotOptions"),children:a.jsx(ph,{className:"w-2.5 h-2.5 text-bambu-gray"})}),Ee?.state!=="RUNNING"&&Jt?.amsId===St.id&&Jt?.slotId===Sr&&a.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-xs flex items-center gap-2 ${S("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Gr=>{Gr.stopPropagation(),S("printers:ams_rfid")&&(rt.mutate({amsId:St.id,slotId:Sr}),mr(null))},disabled:eo||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:b("printers.permission.noAmsRfid"),children:[a.jsx(Ir,{className:`w-3 h-3 ${eo?"animate-spin":""}`}),b("printers.rfid.reread")]})}),Ea?a.jsx(xP,{data:Ea,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Ea.trayUuid?c?.[Ea.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:u,onLinkSpool:o&&Ea.trayUuid?Gr=>{ce({trayUuid:Gr,trayInfo:{type:Ea.profile,color:Ea.colorHex||"",location:Gd(St.id,St.tray.length)}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>V({amsId:St.id,trayId:Sr,trayCount:St.tray.length,trayType:Zt?.tray_type||void 0,trayColor:Zt?.tray_color||void 0,traySubBrands:Zt?.tray_sub_brands||void 0,trayInfoIdx:Zt?.tray_info_idx||void 0})},children:to}):a.jsx(zq,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>V({amsId:St.id,trayId:Sr,trayCount:St.tray.length})},children:to})]}),(St.humidity!=null||St.temp!=null)&&a.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[St.temp!=null&&a.jsx(qq,{temp:St.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>Ne({amsId:St.id,amsLabel:Gd(St.id,St.tray.length),mode:"temperature"}),compact:!0}),St.humidity!=null&&a.jsx(Gq,{humidity:St.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>Ne({amsId:St.id,amsLabel:Gd(St.id,St.tray.length),mode:"humidity"}),compact:!0})]})]})]},St.id)}),Ee.vt_tray&&Ee.vt_tray.tray_type&&(()=>{const St=Ee.vt_tray,pn=we===254,rr=St.tray_info_idx?Qe?.[St.tray_info_idx]:null,ir=Ue?.[1020],gr=St.tray_uuid?.toUpperCase(),ei=gr?c?.[gr]:void 0,Zt=NP(ei),Sn={vendor:kP(St)?"Bambu Lab":"Generic",profile:rr?.name||ir?.preset_name||St.tray_sub_brands||St.tray_type||"Unknown",colorName:yP(St.tray_id_name)||vP(St.tray_color),colorHex:St.tray_color||null,kFactor:wP(St.k),fillLevel:Zt,trayUuid:St.tray_uuid||null,fillSource:Zt!==null?"spoolman":void 0},ha=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${pn?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:St.tray_color?`#${St.tray_color}`:"#333",borderColor:pn?"var(--accent)":"rgba(255,255,255,0.1)"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:St.tray_type||"Spool"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Zt!==null?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Zt}%`,backgroundColor:SP(Zt)}}):a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.jsx("span",{className:"text-[10px] text-white font-medium",children:b("printers.external")})}),a.jsx(xP,{data:Sn,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Sn.trayUuid?c?.[Sn.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:u,onLinkSpool:o&&Sn.trayUuid?us=>{ce({trayUuid:us,trayInfo:{type:Sn.profile,color:Sn.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>V({amsId:255,trayId:0,trayCount:1,trayType:St.tray_type||void 0,trayColor:St.tray_color||void 0,traySubBrands:St.tray_sub_brands||void 0,trayInfoIdx:St.tray_info_idx||void 0})},children:ha})]})})()]})]})]})})()]}),qe&&r==="expanded"&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(Ch,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-sm text-white truncate",children:qe.name}),Et&&a.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Et.state==="ON"?"bg-bambu-green/20 text-bambu-green":Et.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[Et.state||"?",Et.state==="ON"&&Et.energy?.power!=null&&a.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",Et.energy.power,"W"]})]})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("button",{onClick:()=>G(!0),disabled:Xt.isPending||Et?.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")?Et?.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:b("printers.permission.noSmartPlugControl"),children:[a.jsx(nd,{className:"w-3 h-3"}),"On"]}),a.jsxs("button",{onClick:()=>K(!0),disabled:Xt.isPending||Et?.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")?Et?.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:b("printers.permission.noSmartPlugControl"),children:[a.jsx(Ck,{className:"w-3 h-3"}),"Off"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{className:`text-xs hidden sm:inline ${qe.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:qe.auto_off_executed?"Auto-off done":"Auto-off"}),a.jsx("button",{onClick:()=>Zn.mutate(!qe.auto_off),disabled:Zn.isPending||qe.auto_off_executed||!S("smart_plugs:control"),title:S("smart_plugs:control")?qe.auto_off_executed?b("printers.autoOffExecuted"):b("printers.autoOffAfterPrint"):b("printers.permission.noSmartPlugControl"),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${S("smart_plugs:control")?qe.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":qe.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary":"bg-bambu-dark-tertiary/50 cursor-not-allowed"}`,children:a.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${qe.auto_off||qe.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]}),xt&&xt.length>0&&a.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-bambu-dark-tertiary/50",children:[a.jsx($y,{className:"w-3.5 h-3.5 text-blue-400 flex-shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"HA:"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:xt.map(gt=>a.jsxs("button",{onClick:()=>oi.mutate(gt.id),disabled:oi.isPending,title:`Run ${gt.ha_entity_id}`,className:"px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 rounded transition-colors flex items-center gap-1",children:[a.jsx(To,{className:"w-2.5 h-2.5"}),gt.name]},gt.id))})]})]}),r==="expanded"&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[a.jsxs("div",{className:"text-xs text-bambu-gray",children:[a.jsx("p",{children:t.ip_address}),a.jsx("p",{className:"truncate",children:t.serial_number})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>ht.mutate(!Ee?.chamber_light),disabled:!Ee?.connected||ht.isPending||!S("printers:control"),title:S("printers:control")?Ee?.chamber_light?b("printers.chamberLightOff"):b("printers.chamberLightOn"):b("printers.permission.noControl"),className:Ee?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:a.jsx(PO,{on:Ee?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{if(h==="embedded"&&p)p(t.id,t.name);else{const gt=localStorage.getItem("cameraWindowState"),Rt=gt?JSON.parse(gt):{width:640,height:400},on=[`width=${Rt.width}`,`height=${Rt.height}`,Rt.left!==void 0?`left=${Rt.left}`:"",Rt.top!==void 0?`top=${Rt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,on)}},disabled:!Ee?.connected,title:b(h==="embedded"?"printers.openCameraOverlay":"printers.openCameraWindow"),children:a.jsx(JR,{className:"w-4 h-4"})}),a.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:Ct,disabled:!Ee?.connected||mt.isPending||!S("printers:update"),title:S("printers:update")?t.plate_detection_enabled?b("printers.plateDetection.enabledClick"):b("printers.plateDetection.disabledClick"):b("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:mt.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(cS,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:an,disabled:!Ee?.connected||X||!S("printers:update"),title:S("printers:update")?b("printers.plateDetection.manageCalibration"):b("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:X?a.jsx(lt,{className:"w-3 h-3 animate-spin"}):a.jsx(hr,{className:"w-3 h-3"})})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>F(!0),disabled:!S("printers:files"),title:S("printers:files")?b("printers.browseFiles"):b("printers.permission.noFiles"),children:[a.jsx(Eb,{className:"w-4 h-4"}),"Files"]})]})]})]}),U&&a.jsx(rMe,{printerId:t.id,printerName:t.name,onClose:()=>F(!1)}),B&&a.jsx(cMe,{printerId:t.id,printerName:t.name,onClose:()=>D(!1)}),q&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Vt(),children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:gt=>gt.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[q.needs_calibration?a.jsx(cS,{className:"w-5 h-5 text-blue-500"}):q.is_empty?a.jsx(fr,{className:"w-5 h-5 text-green-500"}):a.jsx(Ji,{className:"w-5 h-5 text-yellow-500"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),q.reference_count!==void 0&&q.max_references&&a.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"]})]}),a.jsx("button",{onClick:()=>Vt(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[q.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 rounded-lg bg-blue-500/20 border border-blue-500/50",children:[a.jsx("p",{className:"font-medium text-blue-400",children:b("printers.plateDetection.calibrationRequired")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",dangerouslySetInnerHTML:{__html:b("printers.plateDetection.calibrationInstructions")}})]}),a.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[a.jsx("p",{children:b("printers.plateDetection.calibrationDescription")}),a.jsx("p",{dangerouslySetInnerHTML:{__html:b("printers.plateDetection.calibrationTip")}})]})]}):a.jsxs(a.Fragment,{children:[a.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:[a.jsx("p",{className:`font-medium ${q.is_empty?"text-green-400":"text-yellow-400"}`,children:q.is_empty?b("printers.plateDetection.plateEmpty"):b("printers.plateDetection.objectsDetected")}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:[b("printers.plateDetection.confidence"),": ",Math.round(q.confidence*100),"% | ",b("printers.plateDetection.difference"),": ",q.difference_percent.toFixed(1),"%"]})]}),q.debug_image_url&&a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:b("printers.plateDetection.analysisPreview")}),a.jsx("img",{src:q.debug_image_url,alt:b("printers.plateDetection.analysisPreview"),className:"w-full rounded-lg border border-bambu-dark-tertiary"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:b("printers.plateDetection.analysisLegend")})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:q.message})]}),ut&&ut.references.length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:b("printers.plateDetection.savedReferences",{count:ut.references.length,max:ut.max_references})}),a.jsx("div",{className:"grid grid-cols-5 gap-2",children:ut.references.map(gt=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:ae.getPlateReferenceThumbnailUrl(t.id,gt.index),alt:gt.label||`Reference ${gt.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),a.jsx("button",{onClick:()=>bn(gt.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:b("printers.plateDetection.deleteReference"),children:a.jsx(Lt,{className:"w-3 h-3 text-white"})}),Tt?.index===gt.index?a.jsx("input",{type:"text",value:Tt.label,onChange:Rt=>Ut({...Tt,label:Rt.target.value}),onBlur:()=>Mn(gt.index,Tt.label),onKeyDown:Rt=>{Rt.key==="Enter"&&Mn(gt.index,Tt.label),Rt.key==="Escape"&&Ut(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:b("printers.plateDetection.labelPlaceholder")}):a.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>Ut({index:gt.index,label:gt.label}),title:gt.label?b("printers.plateDetection.clickToEdit",{label:gt.label}):b("printers.plateDetection.clickToAddLabel"),children:gt.label||a.jsx("span",{className:"italic opacity-50",children:b("printers.noLabel")})}),a.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:gt.timestamp?new Date(gt.timestamp).toLocaleDateString():""})]},gt.index))})]}),!q.needs_calibration&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:b("printers.roi.title")}),z?a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>O(null),disabled:Z,children:b("common.cancel")}),a.jsx(Me,{size:"sm",onClick:qt,disabled:Z,children:Z?a.jsx(lt,{className:"w-3 h-3 animate-spin"}):b("common.save")})]}):a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>O(q.roi||{x:.15,y:.35,w:.7,h:.55}),children:[a.jsx(ea,{className:"w-3 h-3 mr-1"}),b("common.edit")]})]}),z?a.jsxs("div",{className:"space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:b("printers.roi.xStart")}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:z.x,onChange:gt=>O({...z,x:parseFloat(gt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.x*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:b("printers.roi.yStart")}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:z.y,onChange:gt=>O({...z,y:parseFloat(gt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.y*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:b("printers.width")}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:z.w,onChange:gt=>O({...z,w:parseFloat(gt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.w*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:b("printers.height")}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:z.h,onChange:gt=>O({...z,h:parseFloat(gt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(z.h*100),"%"]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:b("printers.roi.instruction")})]}):a.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),"%"]})]})]}),a.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:q.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",onClick:()=>Vt(),children:b("common.cancel")}),a.jsx(Me,{onClick:()=>gn(),disabled:pe,children:pe?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",onClick:()=>gn(),disabled:pe,children:pe?"Adding...":`Add Reference (${ut?.references.length||0}/${ut?.max_references||5})`}),a.jsx(Me,{onClick:()=>Vt(),children:"Close"})]})})]})}),$&&qe&&a.jsx(Qn,{title:b("printers.confirm.powerOnTitle"),message:b("printers.confirm.powerOnMessage",{name:t.name}),confirmText:b("printers.confirm.powerOnButton"),variant:"default",onConfirm:()=>{Xt.mutate("on"),G(!1)},onCancel:()=>G(!1)}),I&&qe&&a.jsx(Qn,{title:b("printers.confirm.powerOffTitle"),message:Ee?.state==="RUNNING"?b("printers.confirm.powerOffWarning",{name:t.name}):b("printers.confirm.powerOffMessage",{name:t.name}),confirmText:b("printers.confirm.powerOffButton"),variant:"danger",onConfirm:()=>{Xt.mutate("off"),K(!1)},onCancel:()=>K(!1)}),H&&a.jsx(Qn,{title:b("printers.confirm.stopTitle"),message:b("printers.confirm.stopMessage",{name:t.name}),confirmText:b("printers.confirm.stopButton"),variant:"danger",onConfirm:()=>{da.mutate(),W(!1)},onCancel:()=>W(!1)}),J&&a.jsx(Qn,{title:b("printers.confirm.pauseTitle"),message:b("printers.confirm.pauseMessage",{name:t.name}),confirmText:b("printers.confirm.pauseButton"),variant:"default",onConfirm:()=>{Pe.mutate(),ne(!1)},onCancel:()=>ne(!1)}),xe&&a.jsx(Qn,{title:b("printers.confirm.resumeTitle"),message:b("printers.confirm.resumeMessage",{name:t.name}),confirmText:b("printers.confirm.resumeButton"),variant:"default",onConfirm:()=>{tt.mutate(),ue(!1)},onCancel:()=>ue(!1)}),a.jsx(jO,{printerId:t.id,isOpen:fe,onClose:()=>De(!1)}),Q&&a.jsx(fMe,{printerName:t.name,errors:Ee?.hms_errors||[],onClose:()=>se(!1)}),oe&&a.jsx(o8e,{isOpen:!!oe,onClose:()=>Ne(null),printerId:t.id,printerName:t.name,amsId:oe.amsId,amsLabel:oe.amsLabel,initialMode:oe.mode,thresholds:s}),Fe&&a.jsx(l8e,{isOpen:!!Fe,onClose:()=>ce(null),trayUuid:Fe.trayUuid,trayInfo:Fe.trayInfo}),Ve&&a.jsx(g8e,{isOpen:!!Ve,onClose:()=>V(null),printerId:t.id,slotInfo:Ve,onSuccess:()=>{y.invalidateQueries({queryKey:["slotPresets",t.id]}),y.invalidateQueries({queryKey:["printerStatus",t.id]})}}),C&&a.jsx(R8e,{printer:t,onClose:()=>P(!1)}),Y&&Se&&a.jsx(D8e,{printer:t,firmwareInfo:Se,onClose:()=>de(!1)}),Jt&&a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>mr(null)})]})}function j8e({onClose:t,onAdd:e,existingSerials:n}){const{t:r}=Yt(),[i,s]=_.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",location:"",auto_archive:!0}),[o,l]=_.useState(!1),[c,u]=_.useState([]),[d,h]=_.useState(""),[p,m]=_.useState(!1),[b,y]=_.useState(!1),[x,v]=_.useState([]),[S,N]=_.useState(""),[T,M]=_.useState({scanned:0,total:0});_.useEffect(()=>{Jl.getInfo().then(P=>{y(P.is_docker),P.subnets.length>0&&(v(P.subnets),N(P.subnets[0]))}).catch(()=>{})},[]);const A=c.filter(P=>!n.includes(P.serial)),k=async()=>{h(""),u([]),l(!0),m(!1),M({scanned:0,total:0});try{if(b){await Jl.startSubnetScan(S);const P=setInterval(async()=>{try{const U=await Jl.getScanStatus();M({scanned:U.scanned,total:U.total});const F=await Jl.getDiscoveredPrinters();u(F),U.running||(clearInterval(P),l(!1),m(!0))}catch(U){console.error("Failed to get scan status:",U)}},500)}else{await Jl.startDiscovery(10);const P=setInterval(async()=>{try{const U=await Jl.getDiscoveredPrinters();u(U)}catch(U){console.error("Failed to get discovered printers:",U)}},1e3);setTimeout(async()=>{clearInterval(P);try{await Jl.stopDiscovery()}catch{}l(!1),m(!0);try{const U=await Jl.getDiscoveredPrinters();u(U)}catch(U){console.error("Failed to get final discovered printers:",U)}},1e4)}}catch(P){console.error("Failed to start discovery:",P),h(P instanceof Error?P.message:r("printers.discovery.failedToStart")),l(!1),m(!0)}},R=P=>P?{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"}[P]||P:"",C=P=>{const U=P.serial.startsWith("unknown-")?"":P.serial;s({...i,name:P.name||"",serial_number:U,ip_address:P.ip_address,model:R(P.model)}),u([])};return _.useEffect(()=>()=>{Jl.stopDiscovery().catch(()=>{}),Jl.stopSubnetScan().catch(()=>{})},[]),_.useEffect(()=>{const P=U=>{U.key==="Escape"&&t()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:a.jsx(_t,{className:"w-full max-w-md",onClick:P=>P.stopPropagation(),children:a.jsxs(Mt,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:r("printers.addPrinter")}),a.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[b&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.discovery.subnetToScan")}),x.length>0?a.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",value:S,onChange:P=>N(P.target.value),disabled:o,children:x.map(P=>a.jsx("option",{value:P,children:P},P))}):a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",value:S,onChange:P=>N(P.target.value),placeholder:"192.168.1.0/24",disabled:o}),a.jsx("p",{className:"mt-1 text-xs text-bambu-gray",children:r("printers.discovery.dockerNote")})]}),a.jsx(Me,{type:"button",variant:"secondary",onClick:k,disabled:o,className:"w-full",children:o?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),b&&T.total>0?r("printers.discovery.scanProgress",{scanned:T.scanned,total:T.total}):r("printers.discovery.scanning")]}):a.jsxs(a.Fragment,{children:[a.jsx(Zi,{className:"w-4 h-4"}),r(b?"printers.discovery.scanSubnet":"printers.discovery.discoverNetwork")]})}),d&&a.jsx("div",{className:"mt-2 text-sm text-red-400",children:d}),A.length>0&&a.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:A.map(P=>a.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>C(P),children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-white text-sm truncate",children:P.name||P.serial}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[R(P.model)||r("printers.discovery.unknown")," • ",P.ip_address,P.serial.startsWith("unknown-")&&a.jsxs("span",{className:"text-yellow-500",children:[" • ",r("printers.discovery.serialRequired")]})]})]}),a.jsx(hr,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},P.serial))}),o&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(b?"printers.discovery.scanningSubnet":"printers.discovery.scanningNetwork")}),p&&!o&&c.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(b?"printers.discovery.noPrintersFoundSubnet":"printers.discovery.noPrintersFoundNetwork")}),p&&!o&&c.length>0&&A.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r("printers.discovery.allConfigured")})]}),a.jsxs("form",{onSubmit:P=>{P.preventDefault(),e(i)},className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.name")}),a.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.name,onChange:P=>s({...i,name:P.target.value}),placeholder:r("printers.modal.myPrinter")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.ipAddress")}),a.jsx("input",{type:"text",required:!0,pattern:"(\\d{1,3}(\\.\\d{1,3}){3}|[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*)",className:"w-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:P=>s({...i,ip_address:P.target.value}),placeholder:"192.168.1.100 or printer.local"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.serialNumber")}),a.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.serial_number,onChange:P=>s({...i,serial_number:P.target.value}),placeholder:"01P00A000000000"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.accessCode")}),a.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.access_code,onChange:P=>s({...i,access_code:P.target.value}),placeholder:r("printers.modal.fromPrinterSettings")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.modelOptional")}),a.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.model||"",onChange:P=>s({...i,model:P.target.value}),children:[a.jsx("option",{value:"",children:r("printers.modal.selectModel")}),a.jsxs("optgroup",{label:"H2 Series",children:[a.jsx("option",{value:"H2C",children:"H2C"}),a.jsx("option",{value:"H2D",children:"H2D"}),a.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),a.jsx("option",{value:"H2S",children:"H2S"})]}),a.jsxs("optgroup",{label:"X1 Series",children:[a.jsx("option",{value:"X1E",children:"X1E"}),a.jsx("option",{value:"X1C",children:"X1 Carbon"}),a.jsx("option",{value:"X1",children:"X1"})]}),a.jsxs("optgroup",{label:"P Series",children:[a.jsx("option",{value:"P2S",children:"P2S"}),a.jsx("option",{value:"P1S",children:"P1S"}),a.jsx("option",{value:"P1P",children:"P1P"})]}),a.jsxs("optgroup",{label:"A1 Series",children:[a.jsx("option",{value:"A1",children:"A1"}),a.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.locationGroup")}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i.location||"",onChange:P=>s({...i,location:P.target.value}),placeholder:r("printers.modal.locationPlaceholder")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("printers.locationHelp")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"auto_archive",checked:i.auto_archive,onChange:P=>s({...i,auto_archive:P.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:r("printers.modal.autoArchiveLabel")})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsx(Me,{type:"submit",className:"flex-1",children:r("printers.addPrinter")})]})]})]})})})}function D8e({printer:t,firmwareInfo:e,onClose:n}){const{t:r}=Yt(),i=nn(),{showToast:s}=kn(),{hasPermission:o}=Rr(),l=o("firmware:update"),[c,u]=_.useState(null),[d,h]=_.useState(!1),[p,m]=_.useState(null),{data:b,isLoading:y}=nt({queryKey:["firmwarePrepare",t.id],queryFn:()=>P1.prepareUpload(t.id),staleTime:3e4,enabled:e.update_available&&l}),x=dt({mutationFn:()=>P1.startUpload(t.id),onSuccess:()=>{h(!0);const S=setInterval(async()=>{try{const N=await P1.getUploadStatus(t.id);u(N),(N.status==="complete"||N.status==="error")&&(clearInterval(S),m(null),h(!1),N.status==="complete"&&(s(r("printers.firmwareModal.uploadedToast"),"success"),i.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);m(S)},onError:S=>{s(r("printers.firmwareModal.uploadFailed",{error:S.message}),"error"),h(!1)}});_.useEffect(()=>()=>{p&&clearInterval(p)},[p]);const v=()=>{u(null),x.mutate()};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(_t,{className:"w-full max-w-md mx-4",children:a.jsxs(Mt,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:`p-2 rounded-full ${e.update_available?"bg-orange-500/20":"bg-status-ok/20"}`,children:e.update_available?a.jsx(_i,{className:"w-5 h-5 text-orange-400"}):a.jsx(fr,{className:"w-5 h-5 text-status-ok"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:e.update_available?r("printers.firmwareModal.title"):r("printers.firmwareModal.titleUpToDate")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[a.jsxs("div",{className:"flex justify-between items-center text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.currentVersion")}),a.jsx("span",{className:`font-mono ${e.update_available?"text-white":"text-status-ok"}`,children:e.current_version||r("common.unknown")})]}),e.update_available&&a.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[a.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.latestVersion")}),a.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&a.jsxs("details",{className:"mt-3 text-sm",open:!e.update_available,children:[a.jsx("summary",{className:`cursor-pointer hover:underline ${e.update_available?"text-orange-400":"text-status-ok"}`,children:r("printers.firmwareModal.releaseNotes")}),a.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),e.update_available?y?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),r("printers.firmwareModal.checkingPrereqs")]}):b&&!d&&!c?a.jsx("div",{className:"mb-4",children:b.can_proceed?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[a.jsx(zi,{className:"w-4 h-4"}),r("printers.firmwareModal.sdCardReady")]}):a.jsx("div",{className:"space-y-1",children:b.errors.map((S,N)=>a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Ti,{className:"w-4 h-4 flex-shrink-0"}),S]},N))})}):null:null,(d||c)&&c&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray capitalize",children:c.status}),a.jsxs("span",{className:"text-white",children:[c.progress,"%"]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:`h-2 rounded-full transition-all ${c.status==="error"?"bg-status-error":c.status==="complete"?"bg-status-ok":"bg-orange-500"} ${c.status==="uploading"?"animate-pulse":""}`,style:{width:`${c.progress}%`}})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:c.message}),c.error&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:c.error})]}),c?.status==="complete"&&a.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:r("printers.firmwareModal.uploadedSuccess")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("printers.firmwareModal.applyInstructions")}),a.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step1")}}),a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step2")}}),a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step3")}}),a.jsx("li",{children:r("printers.firmwareModal.step4")})]})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Me,{variant:"secondary",onClick:n,children:c?.status==="complete"?r("printers.firmwareModal.done"):r("common.cancel")}),b?.can_proceed&&!d&&c?.status!=="complete"&&l&&a.jsx(Me,{onClick:v,disabled:x.isPending,children:x.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin mr-2"}),r("printers.firmwareModal.starting")]}):a.jsxs(a.Fragment,{children:[a.jsx(_i,{className:"w-4 h-4 mr-2"}),r("printers.firmwareModal.uploadFirmware")]})})]})]})})})}function R8e({printer:t,onClose:e}){const{t:n}=Yt(),r=nn(),{showToast:i}=kn(),[s,o]=_.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),l=dt({mutationFn:u=>ae.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:s.name,ip_address:s.ip_address,model:s.model||void 0,location:s.location||void 0,auto_archive:s.auto_archive};s.access_code&&(d.access_code=s.access_code),l.mutate(d)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsx(_t,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:a.jsxs(Mt,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:n("printers.editPrinter")}),a.jsxs("form",{onSubmit:c,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.name")}),a.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s.name,onChange:u=>o({...s,name:u.target.value}),placeholder:n("printers.modal.myPrinter")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.ipAddress")}),a.jsx("input",{type:"text",required:!0,pattern:"(\\d{1,3}(\\.\\d{1,3}){3}|[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*)",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s.ip_address,onChange:u=>o({...s,ip_address:u.target.value}),placeholder:"192.168.1.100 or printer.local"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.serialNumber")}),a.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.serialCannotBeChanged")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.accessCode")}),a.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s.access_code,onChange:u=>o({...s,access_code:u.target.value}),placeholder:n("printers.accessCodePlaceholder")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.model")}),a.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s.model,onChange:u=>o({...s,model:u.target.value}),children:[a.jsx("option",{value:"",children:n("printers.modal.selectModel")}),a.jsxs("optgroup",{label:"H2 Series",children:[a.jsx("option",{value:"H2C",children:"H2C"}),a.jsx("option",{value:"H2D",children:"H2D"}),a.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),a.jsx("option",{value:"H2S",children:"H2S"})]}),a.jsxs("optgroup",{label:"X1 Series",children:[a.jsx("option",{value:"X1E",children:"X1E"}),a.jsx("option",{value:"X1C",children:"X1 Carbon"}),a.jsx("option",{value:"X1",children:"X1"})]}),a.jsxs("optgroup",{label:"P Series",children:[a.jsx("option",{value:"P2S",children:"P2S"}),a.jsx("option",{value:"P1S",children:"P1S"}),a.jsx("option",{value:"P1P",children:"P1P"})]}),a.jsxs("optgroup",{label:"A1 Series",children:[a.jsx("option",{value:"A1",children:"A1"}),a.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s.location,onChange:u=>o({...s,location:u.target.value}),placeholder:n("printers.modal.locationPlaceholder")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.locationHelp")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:s.auto_archive,onChange:u=>o({...s,auto_archive:u.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:n("printers.modal.autoArchiveLabel")})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("common.cancel")}),a.jsx(Me,{type:"submit",className:"flex-1",disabled:l.isPending,children:l.isPending?n("common.saving"):n("printers.modal.saveChanges")})]})]})]})})})}function O8e(t){const{data:e}=nt({queryKey:["printerStatus",t],queryFn:()=>ae.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function L8e({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=O8e(t.id),{data:s}=nt({queryKey:["smartPlugStatus",e.id],queryFn:()=>ae.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),s&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${s.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:s.state||"?"})]}),a.jsxs("button",{onClick:()=>n(e.id),disabled:r||s?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${s?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[a.jsx(nd,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function F8e(){const{t}=Yt(),[e,n]=_.useState(!1),[r,i]=_.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[s,o]=_.useState(!1),[l,c]=_.useState(null),[u,d]=_.useState(()=>localStorage.getItem("printerSortBy")||"name"),[h,p]=_.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,b]=_.useState(()=>{const fe=localStorage.getItem("printerCardSize");return fe?parseInt(fe,10):2}),y=m===1?"compact":"expanded",x=nn(),{showToast:v}=kn(),{hasPermission:S}=Rr(),[N,T]=_.useState(()=>{const fe=localStorage.getItem("openEmbeddedCameras");if(fe)try{const De=JSON.parse(fe);return new Map(De.map(oe=>[oe.id,oe]))}catch{return new Map}return new Map});_.useEffect(()=>{const fe=Array.from(N.values());fe.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(fe)):localStorage.removeItem("openEmbeddedCameras")},[N]);const{data:M,isLoading:A}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:k}=nt({queryKey:["settings"],queryFn:ae.getSettings});_.useEffect(()=>{k?.camera_view_mode==="window"&&N.size>0&&T(new Map)},[k?.camera_view_mode,N.size]);const{data:R}=nt({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs}),{data:C}=nt({queryKey:["maintenanceOverview"],queryFn:ae.getMaintenanceOverview,staleTime:60*1e3}),{data:P}=nt({queryKey:["spoolman-status"],queryFn:ae.getSpoolmanStatus,staleTime:60*1e3}),U=P?.enabled&&P?.connected,{data:F}=nt({queryKey:["unlinked-spools"],queryFn:ae.getUnlinkedSpools,enabled:!!U,staleTime:30*1e3}),B=F&&F.length>0,{data:D}=nt({queryKey:["linked-spools"],queryFn:ae.getLinkedSpools,enabled:!!U,staleTime:30*1e3}),$=D?.linked,G=C?.reduce((fe,De)=>(fe[De.printer_id]={due_count:De.due_count,warning_count:De.warning_count,total_print_hours:De.total_print_hours},fe),{})||{},I=R?.reduce((fe,De)=>(De.printer_id&&(fe[De.printer_id]=De),fe),{})||{},K=dt({mutationFn:ae.createPrinter,onSuccess:()=>{x.invalidateQueries({queryKey:["printers"]}),x.invalidateQueries({queryKey:["maintenanceOverview"]}),n(!1)},onError:fe=>v(fe.message||t("printers.toast.failedToAdd"),"error")}),Q=dt({mutationFn:fe=>ae.controlSmartPlug(fe,"on"),onSuccess:()=>{x.invalidateQueries({queryKey:["smart-plugs"]}),c(null)},onError:()=>{c(null)}}),se=()=>{const fe=!r;i(fe),localStorage.setItem("hideDisconnectedPrinters",String(fe))},H=fe=>{d(fe),localStorage.setItem("printerSortBy",fe)},W=()=>{const fe=!h;p(fe),localStorage.setItem("printerSortAsc",String(fe))},J=()=>{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"}},ne=["S","M","L","XL"],xe=_.useMemo(()=>{if(!M)return[];const fe=[...M];switch(u){case"name":fe.sort((De,oe)=>De.name.localeCompare(oe.name));break;case"model":fe.sort((De,oe)=>(De.model||"").localeCompare(oe.model||""));break;case"location":fe.sort((De,oe)=>{const Ne=De.location||"",Fe=oe.location||"";return!Ne&&Fe?1:Ne&&!Fe?-1:Ne.localeCompare(Fe)||De.name.localeCompare(oe.name)});break;case"status":fe.sort((De,oe)=>{const Ne=x.getQueryData(["printerStatus",De.id]),Fe=x.getQueryData(["printerStatus",oe.id]),ce=Ve=>Ve?.connected?Ve.state==="RUNNING"?0:1:2;return ce(Ne)-ce(Fe)});break}return h||fe.reverse(),fe},[M,u,h,x]),ue=_.useMemo(()=>{if(u!=="location")return null;const fe={};return xe.forEach(De=>{const oe=De.location||"Ungrouped";fe[oe]||(fe[oe]=[]),fe[oe].push(De)}),fe},[u,xe]);return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("printers.title")}),a.jsx(P8e,{printers:M})]}),a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("select",{value:u,onChange:fe=>H(fe.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"name",children:t("printers.sort.name")}),a.jsx("option",{value:"status",children:t("printers.sort.status")}),a.jsx("option",{value:"model",children:t("printers.sort.model")}),a.jsx("option",{value:"location",children:t("printers.sort.location")})]}),a.jsx("button",{onClick:W,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t(h?"printers.sort.descending":"printers.sort.ascending"),children:h?a.jsx(qg,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(Y0,{className:"w-4 h-4 text-bambu-gray"})})]}),a.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:ne.map((fe,De)=>{const oe=De+1,Ne=m===oe;return a.jsx("button",{onClick:()=>{b(oe),localStorage.setItem("printerCardSize",String(oe))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${De===0?"rounded-l-lg":""} ${De===ne.length-1?"rounded-r-lg":""} ${Ne?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:t(fe==="S"?"printers.cardSize.small":fe==="M"?"printers.cardSize.medium":fe==="L"?"printers.cardSize.large":"printers.cardSize.extraLarge"),children:fe},fe)})}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:r,onChange:se,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),t("printers.hideOffline")]}),r&&Object.keys(I).length>0&&a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>o(!s),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[a.jsx(nd,{className:"w-4 h-4"}),t("printers.powerOn"),a.jsx(hr,{className:`w-3 h-3 transition-transform ${s?"rotate-180":""}`})]}),s&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>o(!1)}),a.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[a.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:t("printers.offlinePrintersWithPlugs")}),M?.filter(fe=>I[fe.id]).map(fe=>a.jsx(L8e,{printer:fe,plug:I[fe.id],onPowerOn:De=>{c(De),Q.mutate(De)},isPowering:l===I[fe.id]?.id},fe.id)),M?.filter(fe=>I[fe.id]).length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),a.jsxs(Me,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(lr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})]}),A?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):M?.length===0?a.jsx(_t,{children:a.jsxs(Mt,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("printers.noPrintersConfigured")}),a.jsxs(Me,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(lr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})}):ue?a.jsx("div",{className:"space-y-6",children:Object.entries(ue).map(([fe,De])=>a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),fe,a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",De.length,")"]})]}),a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${J()}`,children:De.map(oe=>a.jsx(Kq,{printer:oe,hideIfDisconnected:r,maintenanceInfo:G[oe.id],viewMode:y,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:B,linkedSpools:$,spoolmanUrl:P?.url,timeFormat:k?.time_format||"system",cameraViewMode:k?.camera_view_mode||"window",onOpenEmbeddedCamera:(Ne,Fe)=>T(ce=>new Map(ce).set(Ne,{id:Ne,name:Fe})),checkPrinterFirmware:k?.check_printer_firmware!==!1},oe.id))})]},fe))}):a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${J()}`,children:xe.map(fe=>a.jsx(Kq,{printer:fe,hideIfDisconnected:r,maintenanceInfo:G[fe.id],viewMode:y,cardSize:m,spoolmanEnabled:U,hasUnlinkedSpools:B,linkedSpools:$,spoolmanUrl:P?.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:(De,oe)=>T(Ne=>new Map(Ne).set(De,{id:De,name:oe})),checkPrinterFirmware:k?.check_printer_firmware!==!1},fe.id))}),e&&a.jsx(j8e,{onClose:()=>n(!1),onAdd:fe=>K.mutate(fe),existingSerials:M?.map(fe=>fe.serial_number)||[]}),Array.from(N.values()).map((fe,De)=>a.jsx(lMe,{printerId:fe.id,printerName:fe.name,viewerIndex:De,onClose:()=>T(oe=>{const Ne=new Map(oe);return Ne.delete(fe.id),Ne})},fe.id))]})}function I8e(){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 uc(t,e="bambu_studio"){let n;e==="orcaslicer"?n=`orcaslicer://open?file=${t}`:n=`${I8e()==="windows"?"bambustudio":"bambustudioopen"}://${encodeURIComponent(t)}`;const r=document.createElement("a");r.href=n,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}function O4({archiveId:t,libraryFileId:e,title:n,fileType:r,onClose:i}){const{t:s}=Yt(),{data:o}=nt({queryKey:["settings"],queryFn:ae.getSettings}),l=o?.preferred_slicer||"bambu_studio",c=e!=null,[u,d]=_.useState(null),[h,p]=_.useState(null),[m,b]=_.useState(!0),[y,x]=_.useState(null),[v,S]=_.useState(!1),[N,T]=_.useState(null),[M,A]=_.useState(0),[k,R]=_.useState(!1),[C,P]=_.useState(null),[U,F]=_.useState(!1),[B,D]=_.useState(!1),$=_.useRef(null),G=_.useRef(null),I=10,K=160,Q=240,se=.35;_.useEffect(()=>{const pe=ee=>{ee.key==="Escape"&&i()};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},[i]),_.useEffect(()=>{if(b(!0),c){const pe=(r||"").toLowerCase(),ee=pe==="3mf"||pe==="stl",z=pe==="gcode"||pe==="3mf";p({has_model:ee,has_gcode:z,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d(ee?"3d":z?"gcode":null),b(!1);return}if(!t){p(null),d(null),b(!1);return}ae.getArchiveCapabilities(t).then(pe=>{p(pe),pe.has_model?d("3d"):pe.has_gcode&&d("gcode"),b(!1)}).catch(()=>{p({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d("3d"),b(!1)})},[t,r,c]),_.useEffect(()=>{if(S(!0),T(null),A(0),c){const pe=(r||"").toLowerCase();if(!e||pe!=="3mf"){x(null),S(!1);return}ae.getLibraryFilePlates(e).then(ee=>x(ee)).catch(()=>x(null)).finally(()=>S(!1));return}if(!t){x(null),S(!1);return}ae.getArchivePlates(t).then(pe=>x(pe)).catch(()=>x(null)).finally(()=>S(!1))},[t,r,c,e]);const H=_.useMemo(()=>y?.plates??[],[y]),W=(y?.is_multi_plate??!1)&&H.length>1,J=k&&W,ne=N==null?null:H.find(pe=>pe.index===N)??null,xe=pe=>pe.object_count??pe.objects?.length??0,ue=H.reduce((pe,ee)=>pe+xe(ee),0),fe=ne?xe(ne):ue,De=ne?s("modelViewer.plateNumber",{number:ne.index}):s("modelViewer.allPlates"),oe=H.length>0,Ne=_.useRef(null),Fe=_.useRef(null),[ce,Ve]=_.useState(10),[V,Y]=_.useState(3),de=H.length>ce,q=Math.max(1,Math.ceil(H.length/ce)),re=de?H.slice(M*ce,(M+1)*ce):H;_.useEffect(()=>{if(!J){Ve(10),Y(3);return}const pe=Ne.current,ee=Fe.current;if(!pe||!ee)return;let z=0;const O=()=>{const Te=ee.clientWidth,Ee=Math.floor(Te/210),Se=Math.max(3,Math.min(5,Ee||3));Y(_e=>_e===Se?_e:Se);const $e=window.getComputedStyle(pe),Qe=Number.parseFloat($e.rowGap||"0"),be=pe.querySelector("button")?.getBoundingClientRect().height??44,ve=ee.clientHeight,Ce=Math.max(1,Math.floor((ve+Qe)/(be+Qe)))*Se,Ge=Math.max(1,Ce-1);Ve(_e=>_e===Ge?_e:Ge)},Z=()=>{z&&cancelAnimationFrame(z),z=requestAnimationFrame(O)};Z();const me=new ResizeObserver(Z);return me.observe(ee),me.observe(pe),()=>{z&&cancelAnimationFrame(z),me.disconnect()}},[J,H.length]),_.useEffect(()=>{if(!de){A(0);return}A(pe=>Math.min(pe,q-1))},[H.length,de,q]),_.useEffect(()=>{if(!de||N==null)return;const pe=H.findIndex(z=>z.index===N);if(pe<0)return;const ee=Math.floor(pe/ce);A(z=>z===ee?z:ee)},[H,ce,N,de]),_.useEffect(()=>{if(!J){P(null),D(!1);return}if(B)return;const pe=$.current,ee=G.current;if(!pe||!ee)return;const z=pe.clientHeight;if(!z)return;const O=Math.max(Q,z*se),Z=Math.max(K,z-I-O),me=Math.min(ee.scrollHeight,Z);P(Math.max(K,me))},[J,B,H.length,M,I,K,Q,se]),_.useEffect(()=>{if(!U)return;const pe=z=>{const O=$.current;if(!O)return;const Z=O.getBoundingClientRect(),me=Z.height;if(!me)return;const Te=Math.max(Q,me*se),ke=Math.max(K,me-I-Te),Ee=Math.min(ke,Math.max(K,z.clientY-Z.top));P(Ee)},ee=()=>{F(!1),D(!0)};return document.addEventListener("mousemove",pe),document.addEventListener("mouseup",ee),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",ee),document.body.style.cursor="",document.body.style.userSelect=""}},[U,I,K,Q,se]);const X=c?(r||"").toLowerCase()==="3mf":!0,le=()=>{if(!X)return;const pe=n||"model";if(c){const z=`${window.location.origin}${ae.getLibraryFileDownloadUrl(e)}`;uc(z,l);return}const ee=`${window.location.origin}${ae.getArchiveForSlicer(t,pe)}`;uc(ee,l)};return a.jsx("div",{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 ${k?"p-0":"p-8"}`,onClick:i,children:a.jsxs("div",{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary w-full flex flex-col ${k?"h-full max-w-none rounded-none":"h-[80vh] max-w-4xl rounded-xl"}`,onClick:pe=>pe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1 mr-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white truncate",children:n}),oe&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary/70 px-2 py-1 rounded whitespace-nowrap",children:[De,": ",s("modelViewer.objectCount",{count:fe})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:le,disabled:!X,children:[a.jsx(Zr,{className:"w-4 h-4"}),s("modelViewer.openInSlicer")]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>R(pe=>!pe),title:k?"Exit fullscreen":"Enter fullscreen",children:k?a.jsx(XR,{className:"w-4 h-4"}):a.jsx(KR,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:i,children:a.jsx(Lt,{className:"w-5 h-5"})})]})]}),h&&a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>h.has_model&&d("3d"),disabled:!h.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${u==="3d"?"text-bambu-green border-b-2 border-bambu-green":h.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(zi,{className:"w-4 h-4"}),s("modelViewer.tabs.model"),!h.has_model&&a.jsxs("span",{className:"text-xs",children:["(",s("modelViewer.notAvailable"),")"]})]}),a.jsxs("button",{onClick:()=>h.has_gcode&&d("gcode"),disabled:!h.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${u==="gcode"?"text-bambu-green border-b-2 border-bambu-green":h.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(kue,{className:"w-4 h-4"}),s("modelViewer.tabs.gcode"),!h.has_gcode&&a.jsxs("span",{className:"text-xs",children:["(",s("modelViewer.notSliced"),")"]})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:m?a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(lt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):u==="3d"&&h?a.jsxs("div",{ref:$,className:`w-full h-full flex flex-col ${J?"gap-0 min-h-0":"gap-3"}`,children:[W&&a.jsxs("div",{ref:G,style:J&&C!=null?{height:C}:void 0,className:`rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3 ${J?"flex flex-col shrink-0":""}`,children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray mb-2",children:[a.jsx(is,{className:"w-4 h-4"}),s("modelViewer.plates"),v&&a.jsx(lt,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:J?"flex flex-col min-h-0 flex-1":void 0,children:[a.jsx("div",{ref:Fe,className:J?"min-h-0 overflow-hidden pr-1 flex-1":void 0,children:a.jsxs("div",{ref:Ne,className:J?"grid gap-2":"grid grid-cols-2 md:grid-cols-3 gap-2",style:J?{gridTemplateColumns:`repeat(${V}, minmax(0, 1fr))`}:void 0,children:[a.jsxs("button",{type:"button",onClick:()=>T(null),className:`flex items-center rounded-lg border text-left transition-colors ${J?"gap-1.5 p-1.5 w-full":"gap-2 p-2"} ${N==null?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:`rounded bg-bambu-dark-tertiary flex items-center justify-center ${J?"w-8 h-8":"w-10 h-10"}`,children:a.jsx(is,{className:`${J?"w-4 h-4":"w-5 h-5"} text-bambu-gray`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:`${J?"text-xs":"text-sm"} text-white font-medium truncate`,children:s("modelViewer.allPlates")}),a.jsx("p",{className:`${J?"text-[10px]":"text-xs"} text-bambu-gray truncate`,children:s("modelViewer.plateCount",{count:H.length})})]}),N==null&&a.jsx(Vi,{className:`${J?"w-3.5 h-3.5":"w-4 h-4"} text-bambu-green flex-shrink-0`})]}),re.map(pe=>a.jsxs("button",{type:"button",onClick:()=>T(pe.index),className:`flex items-center rounded-lg border text-left transition-colors ${J?"gap-1.5 p-1.5 w-full":"gap-2 p-2"} ${N===pe.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[pe.has_thumbnail&&pe.thumbnail_url?a.jsx("img",{src:pe.thumbnail_url,alt:`Plate ${pe.index}`,className:`${J?"w-8 h-8":"w-10 h-10"} rounded object-cover bg-bambu-dark-tertiary`}):a.jsx("div",{className:`rounded bg-bambu-dark-tertiary flex items-center justify-center ${J?"w-8 h-8":"w-10 h-10"}`,children:a.jsx(is,{className:`${J?"w-4 h-4":"w-5 h-5"} text-bambu-gray`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:`${J?"text-xs":"text-sm"} text-white font-medium truncate`,children:pe.name||s("modelViewer.plateNumber",{number:pe.index})}),a.jsx("p",{className:`${J?"text-[10px]":"text-xs"} text-bambu-gray truncate`,children:s("modelViewer.objectCount",{count:pe.object_count??pe.objects?.length??0})})]}),N===pe.index&&a.jsx(Vi,{className:`${J?"w-3.5 h-3.5":"w-4 h-4"} text-bambu-green flex-shrink-0`})]},pe.index))]})}),(ne||de)&&a.jsxs("div",{className:"mt-auto pt-3 flex items-center gap-4 text-xs text-bambu-gray overflow-x-auto",children:[ne&&a.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[a.jsx("span",{children:s("modelViewer.plateNumber",{number:ne.index})}),ne.print_time_seconds!=null&&a.jsx("span",{children:s("modelViewer.eta",{minutes:Math.round(ne.print_time_seconds/60)})}),ne.filament_used_grams!=null&&a.jsxs("span",{children:[ne.filament_used_grams.toFixed(1)," g"]}),ne.filaments.length>0&&a.jsx("span",{children:s("modelViewer.filamentCount",{count:ne.filaments.length})})]}),de&&a.jsxs("div",{className:`flex items-center gap-2 whitespace-nowrap ${ne?"ml-auto":""}`,children:[a.jsx("span",{children:s("modelViewer.pagination.pageOf",{current:M+1,total:q})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>A(pe=>Math.max(pe-1,0)),disabled:M===0,className:`px-2 py-1 rounded border text-xs ${M===0?"border-bambu-dark-tertiary text-bambu-gray/40 cursor-not-allowed":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:s("modelViewer.pagination.prev")}),(()=>{let ee=Math.max(0,M-Math.floor(2.5));const z=Math.min(q,ee+5);z-ee<5&&(ee=Math.max(0,z-5));const O=Array.from({length:z-ee},(Z,me)=>ee+me);return a.jsxs(a.Fragment,{children:[ee>0&&a.jsx("button",{type:"button",onClick:()=>A(0),className:`px-2 py-1 rounded border text-xs ${M===0?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:"1"}),ee>1&&a.jsx("span",{className:"px-1",children:"…"}),O.map(Z=>a.jsx("button",{type:"button",onClick:()=>A(Z),className:`px-2 py-1 rounded border text-xs ${M===Z?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:Z+1},Z)),z<q-1&&a.jsx("span",{className:"px-1",children:"…"}),z<q&&a.jsx("button",{type:"button",onClick:()=>A(q-1),className:`px-2 py-1 rounded border text-xs ${M===q-1?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:q})]})})(),a.jsx("button",{type:"button",onClick:()=>A(pe=>Math.min(pe+1,q-1)),disabled:M>=q-1,className:`px-2 py-1 rounded border text-xs ${M>=q-1?"border-bambu-dark-tertiary text-bambu-gray/40 cursor-not-allowed":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:s("modelViewer.pagination.next")})]})]})]})]})]}),J&&a.jsx("div",{role:"separator","aria-orientation":"horizontal",onMouseDown:pe=>{pe.preventDefault(),F(!0),D(!0)},className:`h-2 cursor-row-resize flex items-center justify-center ${U?"bg-bambu-dark-tertiary":"bg-bambu-dark-secondary/60 hover:bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:"w-12 h-1 rounded-full bg-bambu-gray/50"})}),a.jsx("div",{className:`flex-1 ${J?"min-h-0":""}`,children:a.jsx(HK,{url:c?ae.getLibraryFileDownloadUrl(e):h.has_source?ae.getSource3mfDownloadUrl(t):ae.getArchiveDownload(t),fileType:r,buildVolume:h.build_volume,filamentColors:h.filament_colors,selectedPlateId:N,className:"w-full h-full"})})]}):u==="gcode"&&h?a.jsx(NX,{gcodeUrl:c?ae.getLibraryFileGcodeUrl(e):ae.getArchiveGcode(t),filamentColors:h.filament_colors,className:"w-full h-full"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s("modelViewer.noPreview")})})]})})}const Xq={"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 z8e(t){if(!t||t.length<6)return"Unknown";const e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),s=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(s+o)/2;let c=0,u=0;if(s!==o){const d=s-o;u=l>.5?d/(2-s-o):d/(s+o);const h=n/255,p=r/255,m=i/255;s===h?c=((p-m)/d+(p<m?6:0))/6:s===p?c=((m-h)/d+2)/6:c=((h-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":"Pink"}function mb(t){const e=t.replace("#","").toLowerCase().substring(0,6);return Xq[e]?Xq[e]:z8e(t)}function wN(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function vi(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function yc(t,e,n=40){const r=vi(t),i=vi(e);if(!r||!i||r.length<6||i.length<6)return!1;const s=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),l=parseInt(r.substring(4,6),16),c=parseInt(i.substring(0,2),16),u=parseInt(i.substring(2,4),16),d=parseInt(i.substring(4,6),16);return Math.abs(s-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function Hee(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function $ee(t,e,n){return t>=128?t:t*4+e}function U8e(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 Yq(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function L4(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const s=wN(i.tray_color);e.push({type:i.tray_type,color:s,colorName:mb(s),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:Hee(n.id,i.id,r),globalTrayId:$ee(n.id,i.id),trayInfoIdx:i.tray_info_idx||""})}})}),t?.vt_tray?.tray_type){const n=wN(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:mb(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254,trayInfoIdx:t.vt_tray.tray_info_idx||""})}return e}function Qq(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=L4(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=l.tray_info_idx||"",u=n.filter(y=>!r.has(y.globalTrayId));let d,h,p,m;if(c){const y=u.filter(x=>x.trayInfoIdx===c);y.length===1?d=y[0]:y.length>1&&(h=y.find(x=>x.type?.toUpperCase()===l.type?.toUpperCase()&&vi(x.color)===vi(l.color)),h||(p=y.find(x=>x.type?.toUpperCase()===l.type?.toUpperCase()&&yc(x.color,l.color))),!h&&!p&&(m=y.find(x=>x.type?.toUpperCase()===l.type?.toUpperCase())))}!d&&!h&&!p&&!m&&(h=u.find(y=>y.type?.toUpperCase()===l.type?.toUpperCase()&&vi(y.color)===vi(l.color)),h||(p=u.find(y=>y.type?.toUpperCase()===l.type?.toUpperCase()&&yc(y.color,l.color))),!h&&!p&&(m=u.find(y=>y.type?.toUpperCase()===l.type?.toUpperCase())));const b=d||h||p||m||void 0;return b&&r.add(b.globalTrayId),{slot_id:l.slot_id,globalTrayId:b?.globalTrayId??-1}}),s=Math.max(...i.map(l=>l.slot_id||0));if(s<=0)return;const o=new Array(s).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function B8e(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 s=wN(i.tray_color);e.push({type:i.tray_type,color:s,colorName:mb(s),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:Hee(n.id,i.id,r),globalTrayId:$ee(n.id,i.id),trayInfoIdx:i.tray_info_idx||""})}})}),t?.vt_tray?.tray_type){const n=wN(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:mb(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254,trayInfoIdx:t.vt_tray.tray_info_idx||""})}return e},[t])}function Vee(t,e,n){const r=B8e(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 A=n[d],k=r.find(R=>R.globalTrayId===A);if(k){const R=k.type?.toUpperCase()===u.type?.toUpperCase(),C=vi(k.color)===vi(u.color)||yc(k.color,u.color);let P;return R&&C?P="match":R?P="type_only":P="mismatch",{...u,loaded:k,hasFilament:!0,typeMatch:R,colorMatch:C,status:P,isManual:!0}}}const h=u.tray_info_idx||"",p=r.filter(A=>!c.has(A.globalTrayId));let m,b,y,x;if(h){const A=p.filter(k=>k.trayInfoIdx===h);A.length===1?m=A[0]:A.length>1&&(b=A.find(k=>k.type?.toUpperCase()===u.type?.toUpperCase()&&vi(k.color)===vi(u.color)),b||(y=A.find(k=>k.type?.toUpperCase()===u.type?.toUpperCase()&&yc(k.color,u.color))),!b&&!y&&(x=A.find(k=>k.type?.toUpperCase()===u.type?.toUpperCase())))}!m&&!b&&!y&&!x&&(b=p.find(A=>A.type?.toUpperCase()===u.type?.toUpperCase()&&vi(A.color)===vi(u.color)),b||(y=p.find(A=>A.type?.toUpperCase()===u.type?.toUpperCase()&&yc(A.color,u.color))),!b&&!y&&(x=p.find(A=>A.type?.toUpperCase()===u.type?.toUpperCase())));const v=m||b||y||x||void 0;v&&c.add(v.globalTrayId);const S=!!v,N=S,T=!!m||!!b||!!y;let M;return m||b||y?M="match":x?M="type_only":M="mismatch",{...u,loaded:v,hasFilament:S,typeMatch:N,colorMatch:T,status:M,isManual:!1}})},[t,r,n]),s=_.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:s,hasTypeMismatch:o,hasColorMismatch:l}}function H8e(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,s=0;const o=new Set(Object.values(n));for(const u of t){const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const y=n[d],x=e.find(v=>v.globalTrayId===y);if(x){const v=x.type?.toUpperCase()===u.type?.toUpperCase(),S=vi(x.color)===vi(u.color)||yc(x.color,u.color);v&&S?r++:v?i++:s++;continue}}const h=e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&vi(y.color)===vi(u.color)),p=h?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&yc(y.color,u.color)),m=h||p?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()),b=h??p??m;b&&o.add(b.globalTrayId),h||p?r++:m?i++:s++}const l=t.length;let c="full";return s>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:s,totalSlots:l,status:c}}function $8e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=L4(e);if(r.length===0)return;const i=new Set(Object.values(n)),s=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){s.push({slot_id:u,globalTrayId:n[u]});continue}const d=r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()&&vi(b.color)===vi(c.color)),h=d?void 0:r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()&&yc(b.color,c.color)),p=d||h?void 0:r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()),m=d??h??p;m&&i.add(m.globalTrayId),s.push({slot_id:u,globalTrayId:m?.globalTrayId??-1})}const o=Math.max(...s.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return s.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const Zq={useDefault:!0,manualMappings:{},autoConfigured:!1};function V8e(t,e,n,r,i,s){const o=qR({queries:t.map(b=>({queryKey:["printer-status",b],queryFn:()=>ae.getPrinterStatus(b),enabled:t.length>0,staleTime:5e3}))}),l=_.useMemo(()=>t.map((b,y)=>{const x=o[y],v=x?.data,N=e?.find(P=>P.id===b)?.name||`Printer ${b}`,T=L4(v),M=i[b]||Zq,A=Qq(n,v),k=M.useDefault?r:M.manualMappings,R=$8e(n,v,k),C=H8e(n?.filaments,T,k);return{printerId:b,printerName:N,status:v,isLoading:x?.isLoading??!1,loadedFilaments:T,autoMapping:A,finalMapping:R,matchStatus:C.status,exactMatches:C.exactMatches,typeOnlyMatches:C.typeOnlyMatches,missingTypes:C.missingTypes,totalSlots:C.totalSlots,config:M}}),[t,o,e,n,i,r]),c=o.some(b=>b.isLoading),u=(b,y)=>{s(x=>({...x,[b]:{...x[b]||Zq,...y}}))},d=b=>{const y=l.find(S=>S.printerId===b);if(!y||!y.status||!n?.filaments)return;const x=Qq(n,y.status);if(!x)return;const v={};x.forEach((S,N)=>{S!==-1&&(v[N+1]=S)}),u(b,{useDefault:!1,manualMappings:v,autoConfigured:!0})},h=()=>{for(const b of t)d(b)},p=b=>l.find(x=>x.printerId===b)?.finalMapping,m=l.every(b=>b.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:h,autoConfigurePrinter:d,getFinalMapping:p,allPrintersReady:m}}function G8e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=nn(),[i,s]=_.useState(!1),o=(u,d)=>{if(u<=0)return;const h={...t.config.manualMappings};d===""?delete h[u]:h[u]=parseInt(d,10),n({useDefault:!1,manualMappings:h,autoConfigured:!1})},l=async()=>{s(!0);try{await ae.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{s(!1)}},c=e.map(u=>{const d=u.slot_id||0,h=t.config.manualMappings[d];let p,m=!1;if(h!==void 0)p=t.loadedFilaments.find(y=>y.globalTrayId===h),m=!0;else{const y=new Set(Object.values(t.config.manualMappings)),x=t.loadedFilaments.find(N=>!y.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&vi(N.color)===vi(u.color)),v=x?void 0:t.loadedFilaments.find(N=>!y.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&yc(N.color,u.color)),S=x||v?void 0:t.loadedFilaments.find(N=>!y.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase());p=x??v??S}let b="mismatch";if(p){const y=p.type?.toUpperCase()===u.type?.toUpperCase(),x=vi(p.color)===vi(u.color)||yc(p.color,u.color);y&&x?b="match":y&&(b="type_only")}return{req:u,loaded:p,status:b,isManual:m}});return a.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom slot mapping"}),a.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:i,children:[a.jsx(Ir,{className:`w-3 h-3 ${i?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:h,isManual:p},m)=>a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[a.jsx("span",{title:`Required: ${u.type} - ${mb(u.color)}`,children:a.jsx(Tj,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),a.jsxs("span",{className:"text-white truncate",children:[u.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:d?.globalTrayId??"",onChange:b=>o(u.slot_id||0,b.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 ${h==="match"?"border-bambu-green/50 text-bambu-green":h==="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:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(b=>a.jsxs("option",{value:b.globalTrayId,className:"bg-bambu-dark text-white",children:[b.label,": ",b.type," (",b.colorName,")"]},b.globalTrayId))]}),h==="match"?a.jsx(Vi,{className:"w-3 h-3 text-bambu-green"}):h==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(En,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(En,{className:"w-3 h-3 text-orange-400"})})]},m))]})}function q8e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:s=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u,assignmentMode:d="printer",onAssignmentModeChange:h,targetModel:p,onTargetModelChange:m,targetLocation:b,onTargetLocationChange:y,slicedForModel:x}){const[v,S]=_.useState(!1),N=s?t:t.filter(I=>I.is_active),T=_.useMemo(()=>{if(d!=="printer"||!x||v)return N;const I=N.filter(K=>K.model===x);return I.length>0?I:N},[N,d,x,v]),M=N.length-T.length,A=_.useMemo(()=>{const I=N.map(K=>K.model).filter(K=>!!K);return[...new Set(I)].sort()},[N]),k=_.useMemo(()=>{if(!p)return[];const I=N.filter(K=>K.model===p&&K.location).map(K=>K.location).filter(K=>!!K);return[...new Set(I)].sort()},[N,p]),R=h&&m&&A.length>0,C=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(T.length===0)return a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[a.jsx(Ti,{className:"w-4 h-4"}),"No ",s?"":"active ","printers available"]});const P=I=>{i?e.includes(I)?n(e.filter(K=>K!==I)):n([...e,I]):n([I])},U=()=>{n(T.map(I=>I.id))},F=()=>{n([])},B=(I,K,Q)=>{Q.stopPropagation(),!(!c||!u)&&(K?c(I):u(I,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},D=I=>e.includes(I),$=e.length,G=I=>o?.find(K=>K.printerId===I);return a.jsxs("div",{className:"space-y-2 mb-6",children:[R&&a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>{h("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:[a.jsx(Dr,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),a.jsxs("button",{type:"button",onClick:()=>{h("model"),n([]);const I=x&&A.includes(x)?x:A[0];m(I)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="model"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[a.jsx(rh,{className:"w-4 h-4"}),a.jsxs("span",{className:"text-sm",children:["Any ",x||"Model"]})]})]}),d==="model"&&R&&a.jsxs("div",{className:"space-y-3 mb-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Target Model"}),a.jsxs("select",{value:p||"",onChange:I=>{m(I.target.value||null),y&&y(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:[a.jsx("option",{value:"",children:"Select a model..."}),A.map(I=>a.jsx("option",{value:I,children:I},I))]})]}),p&&k.length>0&&y&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Location Filter (optional)"}),a.jsxs("select",{value:b||"",onChange:I=>y(I.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:[a.jsx("option",{value:"",children:"Any location"}),k.map(I=>a.jsx("option",{value:I,children:I},I))]})]}),p&&a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Scheduler will assign to first available idle ",p," printer",b?` in ${b}`:""]})]}),d==="printer"&&i&&T.length>1&&a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[a.jsx("span",{children:$===0?"Select printers":`${$} printer${$!==1?"s":""} selected`}),a.jsxs("div",{className:"flex gap-2",children:[$<T.length&&a.jsx("button",{type:"button",onClick:U,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),$>0&&a.jsx("button",{type:"button",onClick:F,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&T.map(I=>{const K=D(I.id),Q=G(I.id),se=Q&&!Q.config.useDefault;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>P(I.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${K?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${I.is_active?"":"opacity-60"}`,children:[a.jsx("div",{className:`p-2 rounded-lg ${K?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:a.jsx(Dr,{className:`w-5 h-5 ${K?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{className:"text-left flex-1",children:[a.jsxs("p",{className:"text-white font-medium",children:[I.name,!I.is_active&&a.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[I.model||"Unknown model"," • ",I.ip_address]})]}),i&&a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${K?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:K&&a.jsx(Vi,{className:"w-3 h-3 text-white"})})]}),K&&C&&Q&&a.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:H=>H.stopPropagation(),children:[a.jsx("input",{type:"checkbox",checked:se,onChange:H=>B(I.id,H.target.checked,H),className:"w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),a.jsxs("span",{className:`text-xs ml-2 ${Q.matchStatus==="full"?"text-bambu-green":Q.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",Q.exactMatches,"/",Q.totalSlots," matched)"]}),Q.isLoading&&a.jsx(Ir,{className:"w-3 h-3 text-bambu-gray animate-spin"}),se&&a.jsxs("button",{type:"button",onClick:H=>{H.stopPropagation(),c(I.id)},className:"ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",children:[a.jsx(Rfe,{className:"w-3 h-3"}),"Auto"]})]}),se&&a.jsx(G8e,{printerResult:Q,filamentReqs:l.filaments,onUpdateConfig:H=>u(I.id,H)})]})]},I.id)}),d==="printer"&&M>0&&!v&&a.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:[a.jsx(En,{className:"w-3 h-3 text-yellow-400"}),M," other printer",M>1?"s":""," hidden (different model) —",a.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&v&&x&&a.jsx("button",{type:"button",onClick:()=>S(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:a.jsxs("span",{className:"underline",children:["Show only ",x," printers"]})}),d==="printer"&&$===0&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Ti,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!p&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Ti,{className:"w-3 h-3"}),"Select a target printer model"]})]})}function W8e({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(is,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&a.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[a.jsx(En,{className:"w-3 h-3"}),"Selection required"]})]}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>a.jsxs("button",{type:"button",onClick:()=>r(i.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${n===i.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[i.has_thumbnail&&i.thumbnail_url!=null?a.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(is,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:i.name||`Plate ${i.index}`}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[i.objects.length>0?i.objects.slice(0,3).join(", ")+(i.objects.length>3?"...":""):`${i.filaments.length} filament${i.filaments.length!==1?"s":""}`,i.print_time_seconds!=null?` • ${U8e(i.print_time_seconds)}`:""]})]}),n===i.index&&a.jsx(Vi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function K8e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const s=nn(),[o,l]=_.useState(!1),[c,u]=_.useState(i),{data:d}=nt({queryKey:["printer-status",t],queryFn:()=>ae.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:h,filamentComparison:p,hasTypeMismatch:m,hasColorMismatch:b}=Vee(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const x=m?"#f97316":b?"#facc15":"#00ae42",v=(N,T)=>{if(N>0)if(T===""){const M={...n};delete M[N],r(M)}else r({...n,[N]:parseInt(T,10)})},S=async()=>{l(!0);try{await ae.refreshPrinterStatus(t),await new Promise(N=>setTimeout(N,500)),await s.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(Tj,{className:"w-4 h-4",fill:x,stroke:"none"}),a.jsx("span",{children:"Filament Mapping"}),m?a.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):b?a.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):a.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?a.jsx(Hu,{className:"w-4 h-4 ml-auto"}):a.jsx(hr,{className:"w-4 h-4 ml-auto"})]}),c&&a.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),a.jsxs("button",{type:"button",onClick:S,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:o,children:[a.jsx(Ir,{className:`w-3 h-3 ${o?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),p.map((N,T)=>a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[a.jsx("span",{title:`Required: ${N.type} - ${mb(N.color)}`,children:a.jsx(Tj,{className:"w-3 h-3",fill:N.color,stroke:N.color})}),a.jsxs("span",{className:"text-white truncate",children:[N.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",N.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:N.loaded?.globalTrayId??"",onChange:M=>v(N.slot_id||0,M.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${N.status==="match"?"border-bambu-green/50 text-bambu-green":N.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${N.isManual?"ring-1 ring-blue-400/50":""}`,title:N.isManual?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),h.map(M=>a.jsxs("option",{value:M.globalTrayId,className:"bg-bambu-dark text-white",children:[M.label,": ",M.type," (",M.colorName,")"]},M.globalTrayId))]}),N.status==="match"?a.jsx(Vi,{className:"w-3 h-3 text-bambu-green"}):N.status==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(En,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(En,{className:"w-3 h-3 text-orange-400"})})]},T)),m&&a.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const X8e=[{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 Y8e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=_.useState(n),s=o=>{e({...t,[o]:!t[o]})};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(jk,{className:"w-4 h-4"}),a.jsx("span",{children:"Print Options"}),r?a.jsx(Hu,{className:"w-4 h-4 ml-auto"}):a.jsx(hr,{className:"w-4 h-4 ml-auto"})]}),r&&a.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:X8e.map(({key:o,label:l,desc:c})=>a.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:l}),a.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),a.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>s(o),children:a.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${t[o]?"translate-x-5":"translate-x-0.5"}`})})]},o))})]})}function Q8e({options:t,onChange:e,dateFormat:n="system",timeFormat:r="system"}){const[i,s]=_.useState(""),[o,l]=_.useState(""),[c,u]=_.useState(!0),[d,h]=_.useState(!0),p=_.useRef(null),m=_.useRef(!1);_.useEffect(()=>{if(t.scheduleType!=="scheduled"){m.current=!1;return}if(!m.current){m.current=!0;let T;t.scheduledTime?(T=new Date(t.scheduledTime),isNaN(T.getTime())&&(T=new Date,T.setHours(T.getHours()+1,0,0,0))):(T=new Date,T.setHours(T.getHours()+1,0,0,0),e({...t,scheduledTime:Fj(T)})),s(oB(T,n)),l(lB(T,r)),u(!0),h(!0)}},[t.scheduleType,t.scheduledTime,n,r,e,t]);const b=T=>{e({...t,scheduleType:T})},y=(T,M)=>{const A=ime(T,n),k=ame(M);u(!!A),h(!!k),A&&k&&(A.setHours(k.hours,k.minutes,0,0),A>new Date&&e({...t,scheduledTime:Fj(A)}))},x=T=>{s(T),y(T,o)},v=T=>{l(T),y(i,T)},S=T=>{const M=T.target.value;if(M){const A=new Date(M);isNaN(A.getTime())||(s(oB(A,n)),l(lB(A,r)),u(!0),h(!0),e({...t,scheduledTime:M}))}},N=()=>{p.current?.showPicker()};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>b("asap"),children:[a.jsx(er,{className:"w-4 h-4"}),"ASAP"]}),a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>b("scheduled"),children:[a.jsx(Qr,{className:"w-4 h-4"}),"Scheduled"]}),a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>b("manual"),children:[a.jsx(UW,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="scheduled"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"flex-1 relative",children:[a.jsx("input",{type:"text",className:`w-full px-3 py-2 pr-10 bg-bambu-dark border rounded-lg text-white focus:outline-none ${c?"border-bambu-dark-tertiary focus:border-bambu-green":"border-red-500"}`,value:i,onChange:T=>x(T.target.value),placeholder:nme(n)}),a.jsx("button",{type:"button",onClick:N,className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",title:"Open calendar",children:a.jsx(Qr,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"w-32",children:a.jsx("input",{type:"text",className:`w-full px-3 py-2 bg-bambu-dark border rounded-lg text-white focus:outline-none ${d?"border-bambu-dark-tertiary focus:border-bambu-green":"border-red-500"}`,value:o,onChange:T=>v(T.target.value),placeholder:rme(r)})})]}),a.jsx("input",{ref:p,type:"datetime-local",className:"sr-only",value:t.scheduledTime,onChange:S,tabIndex:-1}),(!c||!d)&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:"Please enter a valid date and time"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"requirePrevious",checked:t.requirePreviousSuccess,onChange:T=>e({...t,requirePreviousSuccess:T.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:t.autoOffAfter,onChange:T=>e({...t,autoOffAfter:T.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[a.jsx(nd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:t.scheduleType==="asap"?"Print will start as soon as the printer is idle.":t.scheduleType==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."})]})}const og={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},Z8e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function Iu({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:s,onSuccess:o}){const{t:l}=Yt(),c=nn(),{showToast:u}=kn(),d=!!n&&!e,[h,p]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,b]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[y,x]=_.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??og.bed_levelling,flow_cali:i.flow_cali??og.flow_cali,vibration_cali:i.vibration_cali??og.vibration_cali,layer_inspect:i.layer_inspect??og.layer_inspect,timelapse:i.timelapse??og.timelapse}:og),[v,S]=_.useState(()=>{if(t==="edit-queue-item"&&i){let Ue="asap";i.manual_start?Ue="manual":i.scheduled_time&&!Yq(i.scheduled_time)&&(Ue="scheduled");let be="";if(i.scheduled_time&&!Yq(i.scheduled_time)){const ve=new Date(i.scheduled_time);be=Fj(ve)}return{scheduleType:Ue,scheduledTime:be,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return Z8e}),[N,T]=_.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const Ue={};return i.ams_mapping.forEach((be,ve)=>{be!==-1&&(Ue[ve+1]=be)}),Ue}return{}}),[M,A]=_.useState({}),[k,R]=_.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[C,P]=_.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),[B]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[D]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[$,G]=_.useState(!1),[I,K]=_.useState({current:0,total:0}),[Q,se]=_.useState(new Set),H=h.length,W=h.length>0?h[0]:null,{data:J}=nt({queryKey:["settings"],queryFn:ae.getSettings}),{data:ne,isLoading:xe}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:ue}=nt({queryKey:["archive",e],queryFn:()=>ae.getArchive(e),enabled:!!e&&!d}),{data:fe}=nt({queryKey:["library-file",n],queryFn:()=>ae.getLibraryFile(n),enabled:d&&!!n}),De=ue?.sliced_for_model||fe?.sliced_for_model||null,{data:oe,isError:Ne}=nt({queryKey:["archive-plates",e],queryFn:()=>ae.getArchivePlates(e),enabled:!!e&&!d,retry:!1}),{data:Fe}=nt({queryKey:["library-file-plates",n],queryFn:()=>ae.getLibraryFilePlates(n),enabled:d&&!!n}),ce=d?Fe:oe,{data:Ve,isError:V}=nt({queryKey:["archive-filaments",e,m],queryFn:()=>ae.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!d&&(m!==null||!ce?.is_multi_plate),retry:!1}),{data:Y}=nt({queryKey:["library-file-filaments",n,m],queryFn:()=>ae.getLibraryFileFilamentRequirements(n,m??void 0),enabled:d&&!!n&&(m!==null||!ce?.is_multi_plate)}),de=!d&&(Ne||V),q=d?Y:Ve,{data:re}=nt({queryKey:["printer-status",W],queryFn:()=>ae.getPrinterStatus(W),enabled:!!W}),{amsMapping:X}=Vee(q,re,N),le=V8e(h,ne,q,N,M,A);_.useEffect(()=>{ce?.plates?.length===1&&!m&&b(ce.plates[0].index)},[ce,m]),_.useEffect(()=>{if(t==="edit-queue-item")return;const Ue=ne?.filter(be=>be.is_active)||[];Ue.length===1&&h.length===0&&p([Ue[0].id])},[t,ne,h.length]),_.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(h.sort())!==JSON.stringify(B.sort())||m!==D)&&(T({}),A({}),se(new Set)):(T({}),A({}),se(new Set))},[t,h,m,B,D]),_.useEffect(()=>{if(!J?.per_printer_mapping_expanded||h.length<=1)return;const Ue=h.filter(be=>{if(Q.has(be))return!1;const ve=le.printerResults.find(ze=>ze.printerId===be);return ve&&ve.status&&!ve.isLoading});Ue.length>0&&(se(be=>{const ve=new Set(be);return Ue.forEach(ze=>ve.add(ze)),ve}),Ue.forEach(be=>{le.autoConfigurePrinter(be)}))},[J?.per_printer_mapping_expanded,h,Q,le]),_.useEffect(()=>{const Ue=be=>{be.key==="Escape"&&!$&&s()};return window.addEventListener("keydown",Ue),()=>window.removeEventListener("keydown",Ue)},[s,$]);const pe=ce?.is_multi_plate??!1,ee=ce?.plates??[],z=dt({mutationFn:Ue=>ae.addToQueue(Ue)}),O=dt({mutationFn:Ue=>ae.updateQueueItem(i.id,Ue),onSuccess:()=>{c.invalidateQueries({queryKey:["queue"]}),u("Queue item updated"),o?.(),s()},onError:Ue=>{u(Ue.message||"Failed to update queue item","error")}}),Z=async Ue=>{if(Ue?.preventDefault(),k==="printer"&&h.length===0){u("Please select at least one printer","error");return}if(k==="model"&&!C){u("Please select a target printer model","error");return}G(!0);const be=k==="model"?1:h.length;K({current:0,total:be});const ve={success:0,failed:0,errors:[]},ze=Ge=>{if(h.length>1){const _e=M[Ge];if(_e&&!_e.useDefault)return le.getFinalMapping(Ge)}return X},Ce=Ge=>({printer_id:k==="printer"?Ge:null,target_model:k==="model"?C: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:Ge?ze(Ge):void 0,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():void 0,...y});if(k==="model"){K({current:1,total:1});try{if(t==="reprint"){u("Model-based assignment only works with queue mode","error"),G(!1);return}else if(t==="edit-queue-item"){const Ge={printer_id:null,target_model:C,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,...y};await O.mutateAsync(Ge)}else await z.mutateAsync(Ce(null));ve.success++}catch(Ge){ve.failed++,ve.errors.push(Ge.message)}}else for(let Ge=0;Ge<h.length;Ge++){const _e=h[Ge];K({current:Ge+1,total:h.length});try{if(t==="reprint"){const Je=ze(_e);d?await ae.printLibraryFile(n,_e,{ams_mapping:Je,...y}):await ae.reprintArchive(e,_e,{plate_id:m??void 0,ams_mapping:Je,...y})}else if(t==="edit-queue-item"&&Ge===0){const Je=ze(_e),Ae={printer_id:_e,target_model:null,target_location:null,require_previous_success:v.requirePreviousSuccess,auto_off_after:v.autoOffAfter,manual_start:v.scheduleType==="manual",ams_mapping:Je,plate_id:m,scheduled_time:v.scheduleType==="scheduled"&&v.scheduledTime?new Date(v.scheduledTime).toISOString():null,...y};await O.mutateAsync(Ae)}else await z.mutateAsync(Ce(_e));ve.success++}catch(Je){ve.failed++;const Ae=ne?.find(Ke=>Ke.id===_e)?.name||`Printer ${_e}`;ve.errors.push(`${Ae}: ${Je.message}`)}}if(G(!1),ve.failed===0){if(k==="model")u(t==="edit-queue-item"?"Queue item updated":`Queued for any ${C}`);else{const Ge=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";ve.success===1?u(t==="edit-queue-item"?"Queue item updated":`Print ${Ge} printer`):u(`Print ${Ge} ${ve.success} printers`)}c.invalidateQueries({queryKey:["queue"]}),o?.(),s()}else ve.success===0?u(`Failed: ${ve.errors[0]}`,"error"):(u(`${ve.success} succeeded, ${ve.failed} failed`,"error"),c.invalidateQueries({queryKey:["queue"]}))},me=$||O.isPending,Te=_.useMemo(()=>!(me||k==="printer"&&h.length===0||k==="model"&&!C||k==="model"&&t==="reprint"||!d&&pe&&!m),[h.length,k,C,t,pe,m,me,d]),Ee=(()=>{const Ue=h.length;return t==="reprint"?{title:l(d?"queue.print":"queue.reprint"),icon:Dr,submitText:Ue>1?l("queue.printToPrinters",{count:Ue}):l("queue.print"),submitIcon:Dr,loadingText:I.total>1?l("queue.sendingProgress",{current:I.current,total:I.total}):l("queue.sending")}:t==="add-to-queue"?{title:l("queue.schedulePrint"),icon:Qr,submitText:Ue>1?l("queue.queueToPrinters",{count:Ue}):l("queue.addToQueue"),submitIcon:Qr,loadingText:I.total>1?l("queue.addingProgress",{current:I.current,total:I.total}):l("queue.adding")}:{title:l("queue.editQueueItem"),icon:ea,submitText:l("common.save"),submitIcon:ea,loadingText:I.total>1?l("queue.savingProgress",{current:I.current,total:I.total}):l("common.saving")}})(),Se=Ee.icon,$e=Ee.submitIcon,Qe=W&&(d||(pe?m!==null:!0));return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:$?void 0:s,children:a.jsx(_t,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:Ue=>Ue.stopPropagation(),children:a.jsxs(Mt,{className:t==="reprint"?"":"p-0",children:[a.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Se,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:Ee.title})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:s,disabled:$,children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Z,className:t==="reprint"?"":"p-4 space-y-4",children:[a.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?a.jsxs(a.Fragment,{children:["Send ",a.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),a.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),a.jsx(W8e,{plates:ee,isMultiPlate:pe,selectedPlate:m,onSelect:b}),a.jsx(q8e,{printers:ne||[],selectedPrinterIds:h,onMultiSelect:p,isLoading:xe,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:le.printerResults,filamentReqs:q,onAutoConfigurePrinter:le.autoConfigurePrinter,onUpdatePrinterConfig:le.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":k,onAssignmentModeChange:t!=="reprint"?R:void 0,targetModel:C,onTargetModelChange:t!=="reprint"?P:void 0,targetLocation:U,onTargetLocationChange:t!=="reprint"?F:void 0,slicedForModel:De}),De&&k==="printer"&&h.length===1&&(()=>{const Ue=ne?.find(be=>be.id===h[0]);return Ue&&Ue.model&&De!==Ue.model?a.jsxs("div",{className:"p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2",children:[a.jsx(En,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),a.jsxs("span",{className:"text-sm text-yellow-400",children:["File was sliced for ",De,", but printing on ",Ue.model]})]}):null})(),de&&a.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[a.jsx(Ti,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),Qe&&!de&&h.length===1&&a.jsx(K8e,{printerId:W,filamentReqs:q,manualMappings:N,onManualMappingChange:T,defaultExpanded:J?.per_printer_mapping_expanded??!1}),(t==="reprint"||H>0||k==="model"&&C)&&a.jsx(Y8e,{options:y,onChange:x}),t!=="reprint"&&a.jsx(Q8e,{options:v,onChange:S,dateFormat:J?.date_format||"system",timeFormat:J?.time_format||"system"}),O.isError&&a.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:O.error?.message||"Failed to complete operation"}),a.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:s,className:"flex-1",disabled:$,children:"Cancel"}),a.jsx(Me,{type:"submit",disabled:!Te,className:"flex-1",children:me?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),Ee.loadingText]}):a.jsxs(a.Fragment,{children:[a.jsx($e,{className:"w-4 h-4"}),Ee.submitText]})})]})]})]})})})}function J8e({onClose:t,initialFiles:e}){const{t:n}=Yt(),r=nn(),{showToast:i}=kn(),s=_.useRef(null),[o,l]=_.useState(()=>e?.filter(M=>M.name.endsWith(".3mf")).map(M=>({file:M,status:"pending"}))||[]),[c,u]=_.useState(!1),[d,h]=_.useState(null);_.useEffect(()=>{const M=A=>{A.key==="Escape"&&t()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[t]);const p=dt({mutationFn:M=>ae.uploadArchivesBulk(M),onSuccess:M=>{h(M),r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["archiveStats"]}),l(A=>A.map(k=>{const R=M.results.find(P=>P.filename===k.file.name),C=M.errors.find(P=>P.filename===k.file.name);return R?{...k,status:"success",archiveId:R.id}:C?{...k,status:"error",error:C.error}:k})),M.failed===0?i(`${M.uploaded} file${M.uploaded!==1?"s":""} uploaded`):M.uploaded===0?i(`Failed to upload ${M.failed} file${M.failed!==1?"s":""}`,"error"):i(`${M.uploaded} uploaded, ${M.failed} failed`,"warning")},onError:()=>{l(M=>M.map(A=>({...A,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),m=_.useCallback(M=>{M.preventDefault(),u(!0)},[]),b=_.useCallback(M=>{M.preventDefault(),u(!1)},[]),y=_.useCallback(M=>{M.preventDefault(),u(!1);const A=Array.from(M.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));A.length>0&&l(k=>[...k,...A.map(R=>({file:R,status:"pending"}))])},[]),x=_.useCallback(M=>{const A=Array.from(M.target.files||[]).filter(k=>k.name.endsWith(".3mf"));A.length>0&&l(k=>[...k,...A.map(R=>({file:R,status:"pending"}))]),s.current&&(s.current.value="")},[]),v=_.useCallback(M=>{l(A=>A.filter((k,R)=>R!==M))},[]),S=()=>{if(o.length===0)return;const M=o.filter(A=>A.status==="pending");M.length!==0&&(l(A=>A.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),p.mutate(M.map(A=>A.file)))},N=o.filter(M=>M.status==="pending").length,T=p.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:a.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:n("uploadModal.title")}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"p-4",children:a.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${c?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:m,onDragLeave:b,onDrop:y,children:[a.jsx(Na,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),a.jsx("p",{className:"text-white mb-2",children:n("uploadModal.dragDrop")}),a.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:n("uploadModal.or")}),a.jsx(Me,{variant:"secondary",onClick:()=>s.current?.click(),disabled:T,children:n("uploadModal.browseFiles")}),a.jsx("input",{ref:s,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:x})]})}),a.jsx("div",{className:"px-4 pb-4",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:n("uploadModal.extractionInfo")})}),o.length>0&&a.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:a.jsx("div",{className:"space-y-2",children:o.map((M,A)=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(Nk,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"flex-1 text-white text-sm truncate",children:M.file.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[(M.file.size/(1024*1024)).toFixed(1)," MB"]}),M.status==="pending"&&a.jsx("button",{onClick:()=>v(A),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:T,children:a.jsx(Lt,{className:"w-4 h-4"})}),M.status==="uploading"&&a.jsx(lt,{className:"w-4 h-4 text-bambu-green animate-spin"}),M.status==="success"&&a.jsx(fr,{className:"w-4 h-4 text-bambu-green"}),M.status==="error"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-red-400",children:M.error}),a.jsx(Ti,{className:"w-4 h-4 text-red-400"})]})]},`${M.file.name}-${A}`))})}),d&&a.jsx("div",{className:"px-4 pb-4",children:a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"text-bambu-green",children:d.uploaded})," ",n("uploadModal.uploaded"),d.failed>0&&a.jsxs(a.Fragment,{children:[", ",a.jsx("span",{className:"text-red-400",children:d.failed})," ",n("uploadModal.failed")]})]})})}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:n(d?"common.close":"common.cancel")}),!d&&a.jsx(Me,{onClick:S,disabled:N===0||T,className:"flex-1",children:T?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),n("uploadModal.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(Na,{className:"w-4 h-4"}),n("uploadModal.upload")," ",N>0&&`(${N})`]})})]})]})})})}const e6e=["adhesionFailure","spaghettiDetached","layerShift","cloggedNozzle","filamentRunout","warping","stringing","underExtrusion","powerFailure","userCancelled","other"],t6e=["completed","failed","aborted","printing"];function Gee({archive:t,onClose:e,existingTags:n=[]}){const{t:r}=Yt();_.useEffect(()=>{const oe=Ne=>{Ne.key==="Escape"&&e()};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[e]);const i=nn(),[s,o]=_.useState(t.print_name||""),[l,c]=_.useState(t.printer_id),[u,d]=_.useState(t.project_id??null),[h,p]=_.useState(t.notes||""),[m,b]=_.useState(t.tags||""),[y,x]=_.useState(t.failure_reason||""),[v,S]=_.useState(t.status),[N,T]=_.useState(t.quantity??1),[M,A]=_.useState(t.photos||[]),[k,R]=_.useState(t.external_url||""),[C,P]=_.useState(!1),[U,F]=_.useState(!1),B=_.useRef(null),D=_.useRef(null),$=_.useRef(null),{data:G}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:I}=nt({queryKey:["projects"],queryFn:()=>ae.getProjects()}),{data:K}=nt({queryKey:["tags"],queryFn:ae.getTags,enabled:n.length===0}),Q=n.length>0?n:K?.map(oe=>oe.name)||[],se=m.split(",").map(oe=>oe.trim()).filter(Boolean),H=m.includes(",")?m.substring(m.lastIndexOf(",")+1).trim().toLowerCase():m.trim().toLowerCase(),W=Q.filter(oe=>!se.includes(oe)&&(H===""||oe.toLowerCase().includes(H))),J=oe=>{let Ne;if(H&&!Q.includes(H)?Ne=m.includes(",")?m.substring(0,m.lastIndexOf(",")).split(",").map(Fe=>Fe.trim()).filter(Boolean):[]:Ne=se,!Ne.includes(oe)){const Fe=[...Ne,oe].join(", ");b(Fe)}$.current!==null&&clearTimeout($.current),B.current?.focus()},ne=oe=>{const Ne=se.filter(Fe=>Fe!==oe).join(", ");b(Ne)},xe=dt({mutationFn:oe=>ae.updateArchive(t.id,oe),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),i.invalidateQueries({queryKey:["projects"]}),e()}}),ue=async oe=>{const Ne=oe.target.files?.[0];if(Ne){P(!0);try{const Fe=await ae.uploadArchivePhoto(t.id,Ne);A(Fe.photos),i.invalidateQueries({queryKey:["archives"]})}catch(Fe){console.error("Failed to upload photo:",Fe)}finally{P(!1),D.current&&(D.current.value="")}}},fe=async oe=>{try{const Ne=await ae.deleteArchivePhoto(t.id,oe);A(Ne.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(Ne){console.error("Failed to delete photo:",Ne)}},De=oe=>{oe.preventDefault();const Ne={print_name:s||void 0,printer_id:l,project_id:u,notes:h||void 0,tags:m||void 0,quantity:N,external_url:k||null};v!==t.status&&(Ne.status=v),v==="failed"||v==="aborted"?Ne.failure_reason=y||void 0:(t.status==="failed"||t.status==="aborted")&&(Ne.failure_reason=null),xe.mutate(Ne)};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("editArchive.title")}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:De,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.name")}),a.jsx("input",{type:"text",value:s,onChange:oe=>o(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:r("editArchive.namePlaceholder")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.printer")}),a.jsxs("select",{value:l??"",onChange:oe=>c(oe.target.value?Number(oe.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:r("editArchive.noPrinter")}),G?.map(oe=>a.jsx("option",{value:oe.id,children:oe.name},oe.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(rs,{className:"w-4 h-4 inline mr-1"}),r("editArchive.project")]}),a.jsxs("select",{value:u??"",onChange:oe=>d(oe.target.value?Number(oe.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:r("editArchive.noProject")}),I?.map(oe=>a.jsx("option",{value:oe.id,children:oe.name},oe.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Nde,{className:"w-4 h-4 inline mr-1"}),r("editArchive.itemsPrinted")]}),a.jsx("input",{type:"number",min:1,value:N,onChange:oe=>T(Math.max(1,parseInt(oe.target.value)||1)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.itemsPrintedHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.notes")}),a.jsx("textarea",{value:h,onChange:oe=>p(oe.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")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Vy,{className:"w-4 h-4 inline mr-1"}),r("editArchive.externalLink")]}),a.jsx("input",{type:"url",value:k,onChange:oe=>R(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"https://printables.com/model/..."}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.externalLinkHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.tags")}),se.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:se.map(oe=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[a.jsx(Ah,{className:"w-3 h-3"}),oe,a.jsx("button",{type:"button",onClick:()=>ne(oe),className:"ml-0.5 text-bambu-gray hover:text-white",children:a.jsx(Lt,{className:"w-3 h-3"})})]},oe))}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{ref:B,type:"text",value:m,onChange:oe=>b(oe.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:se.length>0?r("editArchive.addMoreTags"):r("editArchive.tagsPlaceholder")}),U&&W.length>0&&a.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[a.jsxs("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:[H?r("editArchive.matchingTags",{query:H}):r("editArchive.existingTags")," ",r("editArchive.clickToAdd")]}),a.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:W.map(oe=>a.jsx("button",{type:"button",onClick:()=>J(oe),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:oe},oe))})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.status")}),a.jsx("select",{value:v,onChange:oe=>{S(oe.target.value),oe.target.value==="completed"&&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:t6e.map(oe=>a.jsx("option",{value:oe,children:r(`editArchive.statuses.${oe}`)},oe))})]}),(v==="failed"||v==="aborted")&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.failureReason")}),a.jsxs("select",{value:y,onChange:oe=>x(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:[a.jsx("option",{value:"",children:r("editArchive.selectReason")}),e6e.map(oe=>a.jsx("option",{value:r(`editArchive.failureReasons.${oe}`),children:r(`editArchive.failureReasons.${oe}`)},oe))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Wg,{className:"w-4 h-4 inline mr-1"}),r("editArchive.photos")]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[M.map(oe=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:ae.getArchivePhotoUrl(t.id,oe),alt:r("editArchive.printResult"),className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:()=>fe(oe),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(hn,{className:"w-3 h-3 text-white"})})]},oe)),a.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[a.jsx("input",{ref:D,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:ue,className:"hidden",disabled:C}),C?a.jsx(lt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):a.jsx(lr,{className:"w-6 h-6 text-bambu-gray"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("editArchive.photosHelp")})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:r("common.cancel")}),a.jsxs(Me,{type:"submit",disabled:xe.isPending,className:"flex-1",children:[a.jsx(ys,{className:"w-4 h-4"}),xe.isPending?r("common.saving"):r("common.save")]})]})]})]})})}function qee({x:t,y:e,items:n,onClose:r}){const i=_.useRef(null),[s,o]=_.useState(null),l=_.useRef(null),[c,u]=_.useState({x:t,y:e,visible:!1}),[d,h]=_.useState(!1),[p,m]=_.useState({});_.useEffect(()=>{const x=N=>{i.current&&!i.current.contains(N.target)&&r()},v=N=>{N.key==="Escape"&&r()},S=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),document.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",x),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 x=i.current.getBoundingClientRect(),v=window.innerWidth,S=window.innerHeight,N=8;let T=t,M=e;t+x.width>v-N&&(T=Math.max(N,v-x.width-N)),T<N&&(T=N),e+x.height>S-N&&(M=Math.max(N,S-x.height-N)),M<N&&(M=N);const A=180,k=v-T-x.width,R=T;h(k<A&&R>A),u({x:T,y:M,visible:!0})}},[t,e]);const b=(x,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=v.getBoundingClientRect(),N=window.innerHeight,T=300,k=N-S.top-8<T&&S.top>T;m(R=>({...R,[x]:k?"bottom":"top"})),o(x)},y=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return a.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((x,v)=>{if(x.divider)return a.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const S=x.submenu&&x.submenu.length>0;return a.jsxs("div",{className:"relative",onMouseEnter:N=>S&&b(v,N.currentTarget),onMouseLeave:()=>S&&y(),children:[a.jsxs("button",{onMouseEnter:N=>S&&b(v,N.currentTarget.parentElement),onClick:()=>{S?o(s===v?null:v):x.disabled||(x.onClick(),r())},disabled:x.disabled,title:x.title,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${S&&s===v?"bg-bambu-dark-tertiary":""}`,children:[x.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:x.icon}),a.jsx("span",{className:"flex-1",children:x.label}),S&&a.jsx(Ns,{className:"w-4 h-4 text-bambu-gray"})]}),S&&s===v&&a.jsx("div",{className:`absolute min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"} ${p[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>y(),children:x.submenu.map((N,T)=>a.jsxs("button",{onClick:()=>{N.disabled||(N.onClick(),r())},disabled:N.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${N.disabled?"text-bambu-gray cursor-not-allowed":N.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[N.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:N.icon}),N.label]},T))})]},v)})})}function n6e({selectedIds:t,existingTags:e,onClose:n}){const r=nn(),{showToast:i}=kn(),[s,o]=_.useState(""),[l,c]=_.useState(new Set),[u,d]=_.useState("add");_.useEffect(()=>{const y=x=>{x.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const h=dt({mutationFn:async()=>{const y=Array.from(l);let x=0;for(const v of t)try{const S=await ae.getArchive(v),N=S.tags?S.tags.split(",").map(M=>M.trim()).filter(Boolean):[];let T;u==="add"?T=[...new Set([...N,...y])]:T=N.filter(M=>!l.has(M)),await ae.updateArchive(v,{tags:T.join(", ")}),x++}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:x,mode:u,tags:y}},onSuccess:({count:y,mode:x,tags:v})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${x==="add"?"Added":"Removed"} ${v.length} tag${v.length!==1?"s":""} ${x==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),p=y=>{c(x=>{const v=new Set(x);return v.has(y)?v.delete(y):v.add(y),v})},m=()=>{s.trim()&&!l.has(s.trim())&&(c(y=>new Set([...y,s.trim()])),o(""))},b=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-md",children:a.jsxs(Mt,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ah,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),a.jsx(Me,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:s,onChange:y=>o(y.target.value),onKeyDown:b}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:m,disabled:!s.trim(),children:a.jsx(lr,{className:"w-4 h-4"})})]}),e.length>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>a.jsx("button",{onClick:()=>p(y),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),l.size>0&&a.jsxs("div",{children:[a.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(y=>a.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,a.jsx("button",{onClick:()=>p(y),className:"hover:opacity-70",children:a.jsx(Lt,{className:"w-3 h-3"})})]},y))})]})]}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),a.jsx(Me,{onClick:()=>h.mutate(),disabled:l.size===0||h.isPending,className:"flex-1",children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Ah,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function r6e({selectedIds:t,onClose:e}){const n=nn(),{showToast:r}=kn(),{data:i,isLoading:s}=nt({queryKey:["projects"],queryFn:()=>ae.getProjects()});_.useEffect(()=>{const d=h=>{h.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=dt({mutationFn:async d=>(await ae.addArchivesToProject(d,t),d),onSuccess:d=>{const h=i?.find(p=>p.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${h?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=dt({mutationFn:async()=>{for(const d of t)await ae.updateArchive(d,{project_id:null});return t.length},onSuccess:d=>{o(),r(`Removed ${d} archive${d!==1?"s":""} from project`),e()},onError:()=>{r("Failed to remove from project","error")}}),u=l.isPending||c.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:a.jsxs(Mt,{className:"p-0 flex flex-col min-h-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rs,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),s?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("button",{onClick:()=>c.mutate(),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:a.jsx(Ji,{className:"w-4 h-4 text-red-400"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&a.jsx(lt,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&a.jsxs("div",{className:"flex items-center gap-2 py-2",children:[a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>a.jsxs("button",{onClick:()=>l.mutate(d.id),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[a.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{backgroundColor:d.color?`${d.color}20`:"rgb(var(--bambu-green) / 0.2)"},children:a.jsx(rs,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium truncate",children:d.name}),a.jsxs("p",{className:"text-sm text-bambu-gray truncate",children:[d.archive_count," archive",d.archive_count!==1?"s":"",d.status&&` • ${d.status}`]})]}),l.isPending&&l.variables===d.id&&a.jsx(lt,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&a.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),a.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:a.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function i6e(t,e){return new Date(t,e+1,0).getDate()}function a6e(t,e){return new Date(t,e,1).getDay()}const s6e=["January","February","March","April","May","June","July","August","September","October","November","December"],o6e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function l6e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,s]=_.useState(r.getMonth()),[o,l]=_.useState(r.getFullYear()),[c,u]=_.useState(null),[d,h]=_.useState(null),p=_.useMemo(()=>{const M=new Map;return t.forEach(A=>{const k=Ui(A.completed_at||A.created_at)||new Date,R=`${k.getFullYear()}-${String(k.getMonth()+1).padStart(2,"0")}-${String(k.getDate()).padStart(2,"0")}`,C=M.get(R)||[];C.push(A),M.set(R,C)}),M},[t]),m=i6e(o,i),b=a6e(o,i),y=()=>{i===0?(s(11),l(o-1)):s(i-1)},x=()=>{i===11?(s(0),l(o+1)):s(i+1)},v=()=>{s(r.getMonth()),l(r.getFullYear())},S=[];for(let M=0;M<b;M++)S.push(null);for(let M=1;M<=m;M++)S.push(M);const N=c?p.get(c)||[]:[],T=M=>{M!==c&&h(null),u(M)};return a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Th,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:[s6e[i]," ",o]}),a.jsx("button",{onClick:v,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),a.jsx("button",{onClick:x,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ns,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:o6e.map(M=>a.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:M},M))}),a.jsx("div",{className:"grid grid-cols-7 gap-1",children:S.map((M,A)=>{if(M===null)return a.jsx("div",{className:"aspect-square"},`empty-${A}`);const k=`${o}-${String(i+1).padStart(2,"0")}-${String(M).padStart(2,"0")}`,R=p.get(k)||[],C=R.length>0,P=M===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),U=k===c,F=R.filter(D=>D.status==="completed").length,B=R.filter(D=>D.status==="failed").length;return a.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":P?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":C?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[a.jsx("span",{className:`text-sm font-medium ${P&&!U?"text-bambu-green":""}`,children:M}),C&&a.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${B>0&&F===0?"bg-red-400":B>0?"bg-yellow-400":"bg-green-400"}`}),a.jsx("span",{className:"text-xs font-medium",children:R.length})]})]},M)})}),a.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(M=>{const A=new Date(M.completed_at||M.created_at);return A.getMonth()===i&&A.getFullYear()===o}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(M=>{const A=new Date(M.completed_at||M.created_at);return A.getMonth()===i&&A.getFullYear()===o&&M.status==="completed"}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(M=>{const A=new Date(M.completed_at||M.created_at);return A.getMonth()===i&&A.getFullYear()===o&&M.status==="failed"}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),a.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?a.jsxs(a.Fragment,{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(c+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),N.length>0?a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:N.map(M=>{const A=M.id===d||M.id===n;return a.jsxs("button",{onClick:()=>{h(M.id),e?.(M)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${A?"":"hover:bg-bambu-dark-tertiary"}`,style:A?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[M.thumbnail_path?a.jsx("img",{src:ae.getArchiveThumbnail(M.id),alt:"",className:"w-12 h-12 rounded object-cover"}):a.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:M.print_name||M.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:M.status==="failed"?"text-red-400":"text-green-400",children:M.status==="failed"?"Failed":"Completed"}),M.filament_color&&a.jsx("div",{className:"flex gap-0.5",children:M.filament_color.split(",").map((k,R)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:k}},R))})]})]})]},M.id)})}):a.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):a.jsx("div",{className:"text-center py-8",children:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function Wee({archiveId:t,archiveName:e,onClose:n}){const r=ae.getArchiveQRCodeUrl(t,300);_.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=()=>{const s=document.createElement("a");s.href=r,s.download=`${e}_qrcode.png`,s.click()};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 flex flex-col items-center",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),a.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:a.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),a.jsxs(Me,{onClick:i,className:"w-full",children:[a.jsx(_i,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Kee({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,o]=_.useState(0),[l,c]=_.useState(!1);if(_.useEffect(()=>{const m=b=>{b.key==="Escape"&&r(),b.key==="ArrowLeft"&&o(y=>Math.max(0,y-1)),b.key==="ArrowRight"&&o(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),_.useEffect(()=>{s>=n.length&&o(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return r(),null;const u=n[s],d=ae.getArchivePhotoUrl(t,u),h=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${s+1}.jpg`,m.click()},p=()=>{i&&c(!0)};return a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[a.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:h,children:[a.jsx(_i,{className:"w-4 h-4"}),"Download"]}),i&&a.jsx(Me,{variant:"secondary",size:"sm",onClick:p,className:"text-red-400 hover:text-red-300",children:a.jsx(hn,{className:"w-4 h-4"})}),a.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-6 h-6"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&a.jsx("button",{onClick:()=>o(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(Th,{className:"w-8 h-8 text-white"})}),a.jsx("img",{src:d,alt:`Photo ${s+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),s<n.length-1&&a.jsx("button",{onClick:()=>o(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(Ns,{className:"w-8 h-8 text-white"})})]}),n.length>1&&a.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,b)=>a.jsx("button",{onClick:()=>o(b),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${b===s?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:a.jsx("img",{src:ae.getArchivePhotoUrl(t,m),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},m))})]}),l&&a.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 La(t){this.content=t}La.prototype={constructor:La,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new La(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new La(n)},addToStart:function(t,e){return new La([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new La(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new La(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=La.from(t),t.size?new La(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=La.from(t),t.size?new La(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=La.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}};La.from=function(t){if(t instanceof La)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new La(e)};function Xee(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=Xee(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Yee(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),c=o.nodeSize;if(o==l){n-=c,r-=c;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=Yee(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class At{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;if(u>e&&r(c,i+l,s||null,o)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(l,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new At(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let l=this.content[s],c=o+l.nodeSize;c>e&&((o<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=c}return new At(r,i)}cutByIndex(e,n){return e==n?At.empty:e==0&&n==this.content.length?this:new At(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new At(i,s)}addToStart(e){return new At([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new At(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 Xee(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Yee(this,e,n,r)}findIndex(e){if(e==0)return h1(0,e);if(e==this.size)return h1(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?h1(n+1,s):h1(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return At.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new At(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return At.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new At(n||e,r)}static from(e){if(!e)return At.empty;if(e instanceof At)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new At([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}At.empty=new At([],0);const MP={index:0,offset:0};function h1(t,e){return MP.index=t,MP.offset=e,MP}function _N(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(!_N(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!_N(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let zr=class VD{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&_N(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 VD.none;if(e instanceof VD)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};zr.none=[];class SN extends Error{}class Bt{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=Zee(this.content,e+this.openStart,n);return r&&new Bt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Bt(Qee(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 Bt.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 Bt(At.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Bt(e,r,i)}}Bt.empty=new Bt(At.empty,0,0);function Qee(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Qee(s.content,e-i-1,n-i-1)))}function Zee(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=Zee(o.content,e-s-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function c6e(t,e,n){if(n.openStart>t.depth)throw new SN("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new SN("Inconsistent open depths");return Jee(t,e,n,0)}function Jee(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=Jee(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return lm(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=u6e(n,t);return lm(s,tte(t,o,l,e,r))}else return lm(s,NN(t,e,r))}function ete(t,e){if(!e.type.compatibleContent(t.type))throw new SN("Cannot join "+e.type.name+" onto "+t.type.name)}function GD(t,e,n){let r=t.node(n);return ete(r,e.node(n)),r}function om(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 P0(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(om(t.nodeAfter,r),s++));for(let l=s;l<o;l++)om(i.child(l),r);e&&e.depth==n&&e.textOffset&&om(e.nodeBefore,r)}function lm(t,e){return t.type.checkContent(e),t.copy(e)}function tte(t,e,n,r,i){let s=t.depth>i&&GD(t,e,i+1),o=r.depth>i&&GD(n,r,i+1),l=[];return P0(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(ete(s,o),om(lm(s,tte(t,e,n,r,i+1)),l)):(s&&om(lm(s,NN(t,e,i+1)),l),P0(e,n,i,l),o&&om(lm(o,NN(n,r,i+1)),l)),P0(r,null,i,l),new At(l)}function NN(t,e,n){let r=[];if(P0(null,t,n,r),t.depth>n){let i=GD(t,e,n+1);om(lm(i,NN(t,e,n+1)),r)}return P0(e,null,n,r),new At(r)}function u6e(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(At.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Ey{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return zr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new kN(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(s),u=s-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;s=u-1,i+=c+1}return new Ey(n,r,s)}static resolveCached(e,n){let r=Jq.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else Jq.set(e,r=new d6e);let i=r.elts[r.i]=Ey.resolve(e,n);return r.i=(r.i+1)%h6e,i}}class d6e{constructor(){this.elts=[],this.i=0}}const h6e=12,Jq=new WeakMap;class kN{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 f6e=Object.create(null);let Nh=class qD{constructor(e,n,r,i=zr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||At.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&&_N(this.attrs,n||e.defaultAttrs||f6e)&&zr.sameSet(this.marks,r||zr.none)}copy(e=null){return e==this.content?this:new qD(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new qD(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 Bt.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,s.pos-l);return new Bt(u,i.depth-o,s.depth-o)}replace(e,n,r){return c6e(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 Ey.resolveCached(this,e)}resolveNoCache(e){return Ey.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),nte(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=At.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<s;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=zr.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(!zr.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=At.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Nh.prototype.text=void 0;class MN extends Nh{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):nte(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 MN(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new MN(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 nte(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Pm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new m6e(e,n);if(r.next==null)return Pm.empty;let i=rte(r);r.next&&r.err("Unexpected trailing text");let s=w6e(v6e(i));return _6e(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return At.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:h}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let p=s(h,l.concat(d));if(p)return p}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:c}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
- `)}}Pm.empty=new Pm(!0);class m6e{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 rte(t){let e=[];do e.push(p6e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function p6e(t){let e=[];do e.push(g6e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function g6e(t){let e=y6e(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=b6e(t,e);else break;return e}function e7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function b6e(t,e){let n=e7(t),r=n;return t.eat(",")&&(t.next!="}"?r=e7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function x6e(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function y6e(t){if(t.eat("(")){let e=rte(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=x6e(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 v6e(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,c){let u={term:c,to:l};return e[o].push(u),u}function i(o,l){o.forEach(c=>c.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(s(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=s(o.exprs[c],l);if(c==o.exprs.length-1)return u;i(u,l=n())}else if(o.type=="star"){let c=n();return r(l,c),i(s(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(s(o.expr,l),c),i(s(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(s(o.expr,c),d),c=d}if(o.max==-1)i(s(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(s(o.expr,c),d),c=d}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function ite(t,e){return e-t}function t7(t,e){let n=[];return r(e),n.sort(ite);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:l,to:c}=s[o];!l&&n.indexOf(c)==-1&&r(c)}}}function w6e(t){let e=Object.create(null);return n(t7(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]);t7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let s=e[r.join(",")]=new Pm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(ite);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function _6e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),s&&!(c.isText||c.hasRequiredAttrs())&&(s=!1),r.indexOf(u)==-1&&r.push(u)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ate(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 ste(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function ote(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let s=t[i];s.validate&&s.validate(e[i])}}function lte(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new N6e(t,r,e[r]);return n}let n7=class cte{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=lte(e,r.attrs),this.defaultAttrs=ate(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==Pm.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:ste(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Nh(this,this.computeAttrs(e),At.from(n),zr.setFrom(r))}createChecked(e=null,n,r){return n=At.from(n),this.checkContent(n),new Nh(this,this.computeAttrs(e),n,zr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=At.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(At.empty,!0);return s?new Nh(this,e,n.append(s),zr.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){ote(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:zr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new cte(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function S6e(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class N6e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?S6e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class zM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=lte(e,i.attrs),this.excluded=null;let s=ate(this.attrs);this.instance=s?new zr(this,s):null}create(e=null){return!e&&this.instance?this.instance:new zr(this,ste(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new zM(s,i++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){ote(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class ute{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=La.from(e.nodes),n.marks=La.from(e.marks||{}),this.nodes=n7.compile(this.spec.nodes,this),this.marks=zM.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Pm.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?r7(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:r7(this,o.split(" "))}this.nodeFromJSON=i=>Nh.fromJSON(this,i),this.markFromJSON=i=>zr.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 n7){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 MN(r,r.defaultAttrs,e,zr.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],s=t.marks[i],o=s;if(s)n.push(s);else for(let l in t.marks){let c=t.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function k6e(t){return t.tag!=null}function M6e(t){return t.style!=null}let j0=class WD{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(k6e(i))this.tags.push(i);else if(M6e(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new a7(this,n,!1);return r.addAll(e,zr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new a7(this,n,!0);return r.addAll(e,zr.none,n.from,n.to),Bt.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(A6e(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let c=o.getAttrs(n);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=s7(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=s7(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new WD(e,WD.schemaRules(e)))}};const dte={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},E6e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},hte={ol:!0,ul:!0},Ty=1,KD=2,D0=4;function i7(t,e,n){return e!=null?(e?Ty:0)|(e==="full"?KD:0):t&&t.whitespace=="pre"?Ty|KD:n&~D0}class f1{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=zr.none,this.match=s||(o&D0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(At.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&Ty)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=At.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(At.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&&!dte.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class a7{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=i7(null,n.preserveWhitespace,0)|(r?D0:0);i?s=new f1(i.type,i.attrs,zr.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new f1(null,null,zr.none,!0,null,o):s=new f1(e.schema.topNodeType,null,zr.none,!0,null,o),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,s=i.options&KD?"full":this.localPreserveWS||(i.options&Ty)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;hte.hasOwnProperty(o)&&this.parser.normalizeLists&&T6e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:E6e.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(dte.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),u=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let h=c&&c.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),u&&this.sync(s),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(s,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let s,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(s=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}s&&this.sync(l)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,s=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=zr.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):o7(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=i7(e,s,o.options);o.options&D0&&o.content.length==0&&(l|=D0);let c=zr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):o7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new f1(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|=Ty)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=s;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=s?r.node(c-s).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function T6e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&hte.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function A6e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function s7(t){let e={};for(let n in t)e[n]=t[n];return e}function o7(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=l=>{s.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class $m{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=EP(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,c=0;for(;l<s.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(s[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<s.length;)i=s.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(s.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=K1(EP(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&K1(EP(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return K1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $m(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=l7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return l7(e.marks)}}function l7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function EP(t){return t.document||window.document}const c7=new WeakMap;function C6e(t){let e=c7.get(t);return e===void 0&&c7.set(t,e=P6e(t)),e}function P6e(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 K1(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=C6e(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let h in u)if(u[h]!=null){let p=h.indexOf(" ");p>0?c.setAttributeNS(h.slice(0,p),h.slice(p+1),u[h]):h=="style"&&c.style?c.style.cssText=u[h]:c.setAttribute(h,u[h])}}for(let h=d;h<e.length;h++){let p=e[h];if(p===0){if(h<e.length-1||h>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:b}=K1(t,p,n,r);if(c.appendChild(m),b){if(l)throw new RangeError("Multiple content holes");l=b}}}return{dom:c,contentDOM:l}}const fte=65535,mte=Math.pow(2,16);function j6e(t,e){return t+e*mte}function u7(t){return t&fte}function D6e(t){return(t-(t&fte))/mte}const pte=1,gte=2,X1=4,bte=8;class XD{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&bte)>0}get deletedBefore(){return(this.delInfo&(pte|X1))>0}get deletedAfter(){return(this.delInfo&(gte|X1))>0}get deletedAcross(){return(this.delInfo&X1)>0}}class xo{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&xo.empty)return xo.empty}recover(e){let n=0,r=u7(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+D6e(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[l+s],d=this.ranges[l+o],h=c+u;if(e<=h){let p=u?e==c?-1:e==h?1:n:n,m=c+i+(p<0?0:d);if(r)return m;let b=e==(n<0?c:h)?null:j6e(l/3,e-c),y=e==c?gte:e==h?pte:X1;return(n<0?e!=c:e!=h)&&(y|=bte),new XD(m,y,b)}i+=d-u}return r?e+i:new XD(e+i,0,null)}touches(e,n){let r=0,i=u7(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+s],d=c+u;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),c=o+(this.inverted?0:s),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),s+=d-u}}invert(){return new xo(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?xo.empty:new xo(e<0?[0,-e,0]:[0,0,e])}}xo.empty=new xo([]);class Ay{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 Ay(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 Ay;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(s);if(c!=null&&c>s&&c<this.to){s=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new XD(e,i,null)}}const TP=Object.create(null);class cs{getMap(){return xo.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=TP[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 TP)throw new RangeError("Duplicate use of step JSON ID "+e);return TP[e]=n,n.prototype.jsonID=e,n}}class $i{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new $i(e,null)}static fail(e){return new $i(null,e)}static fromReplace(e,n,r,i){try{return $i.ok(e.replace(n,r,i))}catch(s){if(s instanceof SN)return $i.fail(s.message);throw s}}}function F4(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(F4(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return At.fromArray(r)}class dh extends cs{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new Bt(F4(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 $i.fromReplace(e,this.from,this.to,s)}invert(){return new zl(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 dh(n.pos,r.pos,this.mark)}merge(e){return e instanceof dh&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new dh(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 dh(n.from,n.to,e.markFromJSON(n.mark))}}cs.jsonID("addMark",dh);class zl extends cs{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 Bt(F4(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return $i.fromReplace(e,this.from,this.to,r)}invert(){return new dh(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 zl(n.pos,r.pos,this.mark)}merge(e){return e instanceof zl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new zl(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 zl(n.from,n.to,e.markFromJSON(n.mark))}}cs.jsonID("removeMark",zl);class hh extends cs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return $i.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return $i.fromReplace(e,this.pos,this.pos+1,new Bt(At.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 hh(this.pos,n.marks[i]);return new hh(this.pos,this.mark)}}return new jm(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new hh(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 hh(n.pos,e.markFromJSON(n.mark))}}cs.jsonID("addNodeMark",hh);class jm extends cs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return $i.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return $i.fromReplace(e,this.pos,this.pos+1,new Bt(At.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new hh(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new jm(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 jm(n.pos,e.markFromJSON(n.mark))}}cs.jsonID("removeNodeMark",jm);class va extends cs{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&YD(e,this.from,this.to)?$i.fail("Structure replace would overwrite content"):$i.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xo([this.from,this.to-this.from,this.slice.size])}invert(e){return new va(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 va(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof va)||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?Bt.empty:new Bt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new va(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?Bt.empty:new Bt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new va(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 va(n.from,n.to,Bt.fromJSON(e,n.slice),!!n.structure)}}cs.jsonID("replace",va);class _a extends cs{constructor(e,n,r,i,s,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(YD(e,this.from,this.gapFrom)||YD(e,this.gapTo,this.to)))return $i.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return $i.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?$i.fromReplace(e,this.from,this.to,r):$i.fail("Content does not fit in gap")}getMap(){return new xo([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 _a(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new _a(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new _a(n.from,n.to,n.gapFrom,n.gapTo,Bt.fromJSON(e,n.slice),n.insert,!!n.structure)}}cs.jsonID("replaceAround",_a);function YD(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function R6e(t,e,n,r){let i=[],s=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let h=c.marks;if(!r.isInSet(h)&&d.type.allowsMarkType(r.type)){let p=Math.max(u,e),m=Math.min(u+c.nodeSize,n),b=r.addToSet(h);for(let y=0;y<h.length;y++)h[y].isInSet(b)||(o&&o.to==p&&o.mark.eq(h[y])?o.to=m:i.push(o=new zl(p,m,h[y])));l&&l.to==p?l.to=m:s.push(l=new dh(p,m,r))}}),i.forEach(c=>t.step(c)),s.forEach(c=>t.step(c))}function O6e(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;s++;let c=null;if(r instanceof zM){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 h=c[d],p;for(let m=0;m<i.length;m++){let b=i[m];b.step==s-1&&h.eq(i[m].style)&&(p=b)}p?(p.to=u,p.step=s):i.push({style:h,from:Math.max(l,e),to:u,step:s})}}}),i.forEach(o=>t.step(new zl(o.from,o.to,o.style)))}function I4(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<s.childCount;c++){let u=s.child(c),d=l+u.nodeSize,h=r.matchType(u.type);if(!h)o.push(new va(l,d,Bt.empty));else{r=h;for(let p=0;p<u.marks.length;p++)n.allowsMarkType(u.marks[p].type)||t.step(new zl(l,d,u.marks[p]));if(i&&u.isText&&n.whitespace!="pre"){let p,m=/\r?\n|\r/g,b;for(;p=m.exec(u.text);)b||(b=new Bt(At.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new va(l+p.index,l+p.index+p[0].length,b))}}l=d}if(!r.validEnd){let c=r.fillBefore(At.empty,!0);t.replace(l,l,new Bt(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function L6e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Vb(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!L6e(o,l,c))break;l&&(i=1),c<o.childCount&&(s=1)}return null}function F6e(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),c=o,u=l,d=At.empty,h=0;for(let b=s,y=!1;b>n;b--)y||r.index(b)>0?(y=!0,d=At.from(r.node(b).copy(d)),h++):c--;let p=At.empty,m=0;for(let b=s,y=!1;b>n;b--)y||i.after(b+1)<i.end(b)?(y=!0,p=At.from(i.node(b).copy(p)),m++):u++;t.step(new _a(c,u,o,l,new Bt(d.append(p),h,m),d.size-h,!0))}function z4(t,e,n=null,r=t){let i=I6e(t,e),s=i&&z6e(r,e);return s?i.map(d7).concat({type:e,attrs:n}).concat(s.map(d7)):null}function d7(t){return{type:t,attrs:null}}function I6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function z6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:o}function U6e(t,e,n){let r=At.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=At.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new _a(i,s,i,s,new Bt(r,0,0),n.length,!0))}function B6e(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&H6e(t.doc,t.mapping.slice(s).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!b?u=!1:!m&&b&&(u=!0)}u===!1&&yte(t,o,l,s),I4(t,t.mapping.slice(s).map(l,1),r,void 0,u===null);let d=t.mapping.slice(s),h=d.map(l,1),p=d.map(l+o.nodeSize,1);return t.step(new _a(h,p,h+1,p-1,new Bt(At.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&xte(t,o,l,s),!1}})}function xte(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function yte(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
- `))}})}function H6e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function $6e(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new _a(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Bt(At.from(o),0,0),1,!0))}function zu(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>s;u--,d--){let h=i.node(u),p=i.index(u);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(p,h.childCount),b=r&&r[d+1];b&&(m=m.replaceChild(0,b.type.create(b.attrs)));let y=r&&r[d]||h;if(!h.canReplace(p+1,h.childCount)||!y.type.validContent(m))return!1}let l=i.indexAfter(s),c=r&&r[0];return i.node(s).canReplaceWith(l,l,c?c.type:i.node(s+1).type)}function V6e(t,e,n=1,r){let i=t.doc.resolve(e),s=At.empty,o=At.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){s=At.from(i.node(l).copy(s));let d=r&&r[u];o=At.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new va(e,e,new Bt(s.append(o),n,n),!0))}function Wh(t,e){let n=t.resolve(e),r=n.index();return vte(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function G6e(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function vte(t,e){return!!(t&&e&&!t.isLeaf&&G6e(t,e))}function UM(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&vte(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function q6e(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",h=!!o.contentMatch.matchType(i);d&&!h?r=!1:!d&&h&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);yte(t,d.node(),d.before(),l)}o.inlineContent&&I4(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new va(u,c.map(e+n,-1),Bt.empty,!0)),r===!0){let d=t.doc.resolve(u);xte(t,d.node(),d.before(),t.steps.length)}return t}function W6e(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function wte(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,c=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(s==1)d=u.canReplace(c,c,i);else{let h=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=h&&u.canReplaceWith(c,c,h[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function BM(t,e,n=e,r=Bt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return _te(i,s,r)?new va(e,n,r):new K6e(i,s,r).fit()}function _te(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class K6e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=At.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=At.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let c=new Bt(s,o,l);return e>-1?new _a(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new va(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=AP(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,h=null;if(n==1&&(o?u.matchType(o.type)||(h=u.fillBefore(At.from(o),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:h};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:d};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=AP(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Bt(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=AP(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Bt(g0(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Bt(g0(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let y=0;y<s.length;y++)this.openFrontierNode(s[y]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:h,type:p}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));h=h.matchFragment(i)}let m=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),x=h.matchType(y.type);if(!x)break;u++,(u>1||c==0||y.content.size)&&(h=x,d.push(Ste(y.mark(p.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?m:-1)))}let b=u==l.childCount;b||(m=-1),this.placed=b0(this.placed,n,At.from(d)),this.frontier[n].match=h,b&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,x=l;y<m;y++){let v=x.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),x=v.content}this.unplaced=b?e==0?Bt.empty:new Bt(g0(o.content,e-1,1),e-1,m<0?o.openEnd:e-1):new Bt(g0(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||!CP(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=CP(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=CP(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=b0(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=b0(this.placed,this.depth,At.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(At.empty,!0);n.childCount&&(this.placed=b0(this.placed,this.frontier.length,n))}}function g0(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(g0(t.firstChild.content,e-1,n)))}function b0(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(b0(t.lastChild.content,e-1,n)))}function AP(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Ste(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Ste(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(At.empty,!0)))),t.copy(r)}function CP(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!X6e(n,s.content,o)?l:null}function X6e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Y6e(t){return t.spec.defining||t.spec.definingForContent}function Q6e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(_te(i,s,r))return t.step(new va(e,n,r));let o=kte(i,s);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 b=i.node(p).type.spec;if(b.defining||b.definingAsContext||b.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 b=p.firstChild;if(u.push(b),m==r.openStart)break;p=b.content}for(let p=d-1;p>=0;p--){let m=u[p],b=Y6e(m.type);if(b&&!m.sameMarkup(i.node(Math.abs(l)-1)))d=p;else if(b||!m.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let m=(p+d+1)%(r.openStart+1),b=u[m];if(b)for(let y=0;y<o.length;y++){let x=o[(y+c)%o.length],v=!0;x<0&&(v=!1,x=-x);let S=i.node(x-1),N=i.index(x-1);if(S.canReplaceWith(N,N,b.type,b.marks))return t.replace(i.before(x),v?s.after(x):n,new Bt(Nte(r.content,0,r.openStart,m),m,r.openEnd))}}let h=t.steps.length;for(let p=o.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>h));p--){let m=o[p];m<0||(e=i.before(m),n=s.after(m))}}function Nte(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(Nte(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(At.empty,!0))}return t}function Z6e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=W6e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Bt(At.from(r),0,0))}function J6e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=kte(r,i);for(let o=0;o<s.length;o++){let l=s[o],c=o==s.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function kte(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class Hg extends cs{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 $i.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return $i.fromReplace(e,this.pos,this.pos+1,new Bt(At.from(i),0,n.isLeaf?0:1))}getMap(){return xo.empty}invert(e){return new Hg(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 Hg(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 Hg(n.pos,n.attr,n.value)}}cs.jsonID("attr",Hg);class Cy extends cs{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 $i.ok(r)}getMap(){return xo.empty}invert(e){return new Cy(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 Cy(n.attr,n.value)}}cs.jsonID("docAttr",Cy);let pb=class extends Error{};pb=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};pb.prototype=Object.create(Error.prototype);pb.prototype.constructor=pb;pb.prototype.name="TransformError";class Mte{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ay}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new pb(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=Bt.empty){let i=BM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Bt(At.from(r),0,0))}delete(e,n){return this.replace(e,n,Bt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Q6e(this,e,n,r),this}replaceRangeWith(e,n,r){return Z6e(this,e,n,r),this}deleteRange(e,n){return J6e(this,e,n),this}lift(e,n){return F6e(this,e,n),this}join(e,n=1){return q6e(this,e,n),this}wrap(e,n){return U6e(this,e,n),this}setBlockType(e,n=e,r,i=null){return B6e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return $6e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Hg(e,n,r)),this}setDocAttribute(e,n){return this.step(new Cy(e,n)),this}addNodeMark(e,n){return this.step(new hh(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 zr)n.isInSet(r.marks)&&this.step(new jm(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new jm(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return V6e(this,e,n,r),this}addMark(e,n,r){return R6e(this,e,n,r),this}removeMark(e,n,r){return O6e(this,e,n,r),this}clearIncompatible(e,n,r){return I4(this,e,n,r),this}}const PP=Object.create(null);class On{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new eHe(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=Bt.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:u}=o[l],d=e.mapping.slice(s);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Bt.empty:n),l==0&&m7(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);s?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),m7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new wn(e):gg(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=n<0?gg(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):gg(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Mo(e.node(0))}static atStart(e){return gg(e,e,0,0,1)||new Mo(e)}static atEnd(e){return gg(e,e,e.content.size,e.childCount,-1)||new Mo(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=PP[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 PP)throw new RangeError("Duplicate use of selection JSON ID "+e);return PP[e]=n,n.prototype.jsonID=e,n}getBookmark(){return wn.between(this.$anchor,this.$head).getBookmark()}}On.prototype.visible=!0;class eHe{constructor(e,n){this.$from=e,this.$to=n}}let h7=!1;function f7(t){!h7&&!t.parent.inlineContent&&(h7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class wn extends On{constructor(e,n=e){f7(e),f7(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 On.near(r);let i=e.resolve(n.map(this.anchor));return new wn(i.parent.inlineContent?i:r,r)}replace(e,n=Bt.empty){if(super.replace(e,n),n==Bt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof wn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new HM(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 wn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=On.findFrom(n,r,!0)||On.findFrom(n,-r,!0);if(s)n=s.$head;else return On.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(On.findFrom(e,-r,!0)||On.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new wn(e,n)}}On.jsonID("text",wn);class HM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new HM(e.map(this.anchor),e.map(this.head))}resolve(e){return wn.between(e.resolve(this.anchor),e.resolve(this.head))}}class cn extends On{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?On.near(s):new cn(s)}content(){return new Bt(At.from(this.node),0,0)}eq(e){return e instanceof cn&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new U4(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new cn(e.resolve(n.anchor))}static create(e,n){return new cn(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}cn.prototype.visible=!1;On.jsonID("node",cn);class U4{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new HM(r,r):new U4(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&cn.isSelectable(r)?new cn(n):On.near(n)}}class Mo extends On{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Bt.empty){if(n==Bt.empty){e.delete(0,e.doc.content.size);let r=On.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Mo(e)}map(e){return new Mo(e)}eq(e){return e instanceof Mo}getBookmark(){return tHe}}On.jsonID("all",Mo);const tHe={map(){return this},resolve(t){return new Mo(t)}};function gg(t,e,n,r,i,s=!1){if(e.inlineContent)return wn.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&cn.isSelectable(l))return cn.create(t,n-(i<0?l.nodeSize:0))}else{let c=gg(t,l,n+i,i<0?l.childCount:0,i,s);if(c)return c}n+=l.nodeSize*i}return null}function m7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof va||i instanceof _a))return;let s=t.mapping.maps[r],o;s.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(On.near(t.doc.resolve(o),n))}const p7=1,m1=2,g7=4;class nHe extends Mte{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|p7)&~m1,this.storedMarks=null,this}get selectionSet(){return(this.updated&p7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=m1,this}ensureMarks(e){return zr.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&m1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~m1,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)||zr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(On.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|=g7,this}get scrolledIntoView(){return(this.updated&g7)>0}}function b7(t,e){return!e||!t?t:t.bind(e)}class x0{constructor(e,n,r){this.name=e,this.init=b7(n.init,r),this.apply=b7(n.apply,r)}}const rHe=[new x0("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new x0("selection",{init(t,e){return t.selection||On.atStart(e.doc)},apply(t){return t.selection}}),new x0("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new x0("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class jP{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=rHe.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 x0(r.key,r.spec.state,r))})}}class Tg{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,u=i?i[o].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Tg(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new nHe(this)}static create(e){let n=new jP(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Tg(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 jP(this.schema,e.plugins),r=n.fields,i=new Tg(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new jP(e.schema,e.plugins),s=new Tg(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Nh.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=On.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[o.name]=u.fromJSON.call(c,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function Ete(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Ete(i,e,{})),n[r]=i}return n}class hi{constructor(e){this.spec=e,this.props={},e.props&&Ete(e.props,this,this.props),this.key=e.key?e.key.key:Tte("plugin")}getState(e){return e[this.key]}}const DP=Object.create(null);function Tte(t){return t in DP?t+"$"+ ++DP[t]:(DP[t]=0,t+"$")}class ua{constructor(e="key"){this.key=Tte(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const B4=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ate(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Cte=(t,e,n)=>{let r=Ate(t,n);if(!r)return!1;let i=H4(r);if(!i){let o=r.blockRange(),l=o&&Vb(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(zte(t,i,e,-1))return!0;if(r.parent.content.size==0&&(gb(s,"end")||cn.isSelectable(s)))for(let o=r.depth;;o--){let l=BM(t.doc,r.before(o),r.after(o),Bt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(gb(s,"end")?On.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):cn.create(c.doc,i.pos-s.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},iHe=(t,e,n)=>{let r=Ate(t,n);if(!r)return!1;let i=H4(r);return i?Pte(t,i,e):!1},aHe=(t,e,n)=>{let r=Dte(t,n);if(!r)return!1;let i=$4(r);return i?Pte(t,i,e):!1};function Pte(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=BM(t.doc,s,c,Bt.empty);if(!u||u.from!=s||u instanceof va&&u.slice.size>=c-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(wn.create(d.doc,s)),n(d.scrollIntoView())}return!0}function gb(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 jte=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=H4(r)}let o=s&&s.nodeBefore;return!o||!cn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(cn.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function H4(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 Dte(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Rte=(t,e,n)=>{let r=Dte(t,n);if(!r)return!1;let i=$4(r);if(!i)return!1;let s=i.nodeAfter;if(zte(t,i,e,1))return!0;if(r.parent.content.size==0&&(gb(s,"start")||cn.isSelectable(s))){let o=BM(t.doc,r.before(),r.after(),Bt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(gb(s,"start")?On.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):cn.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Ote=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=$4(r)}let o=s&&s.nodeAfter;return!o||!cn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(cn.create(t.doc,s.pos)).scrollIntoView()),!0)};function $4(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 sHe=(t,e)=>{let n=t.selection,r=n instanceof cn,i;if(r){if(n.node.isTextblock||!Wh(t.doc,n.from))return!1;i=n.from}else if(i=UM(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(cn.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},oHe=(t,e)=>{let n=t.selection,r;if(n instanceof cn){if(n.node.isTextblock||!Wh(t.doc,n.to))return!1;r=n.to}else if(r=UM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},lHe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Vb(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},Lte=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function V4(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 cHe=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=V4(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(On.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Fte=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Mo||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=V4(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,s.createAndFill());l.setSelection(wn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Ite=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(zu(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Vb(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function uHe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof cn&&e.selection.node.isBlock)return!r.parentOffset||!zu(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,c=!1,u=!1;for(let 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=V4(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),s.unshift(c&&l?{type:l}:null),o=m;break}else{if(m==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof wn||e.selection instanceof Mo)&&d.deleteSelection();let h=d.mapping.map(r.pos),p=zu(d.doc,h,s.length,s);if(p||(s[0]=l?{type:l}:null,p=zu(d.doc,h,s.length,s)),!p)return!1;if(d.split(h,s.length,s),!c&&u&&r.node(o).type!=l){let m=d.mapping.map(r.before(o)),b=d.doc.resolve(m);l&&r.node(o-1).canReplaceWith(b.index(),b.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const dHe=uHe(),hHe=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(cn.create(t.doc,i))),!0)};function fHe(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Wh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function zte(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,c=i.type.spec.isolating||s.type.spec.isolating;if(!c&&fHe(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(n){let m=e.pos+s.nodeSize,b=At.empty;for(let v=o.length-1;v>=0;v--)b=At.from(o[v].create(null,b));b=At.from(i.copy(b));let y=t.tr.step(new _a(e.pos-1,m,e.pos,m,new Bt(b,1,0),o.length,!0)),x=y.doc.resolve(m+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&Wh(y.doc,x.pos)&&y.join(x.pos),n(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&c?null:On.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),p=h&&Vb(h);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(h,p).scrollIntoView()),!0;if(u&&gb(s,"start",!0)&&gb(i,"end")){let m=i,b=[];for(;b.push(m),!m.isTextblock;)m=m.lastChild;let y=s,x=1;for(;!y.isTextblock;y=y.firstChild)x++;if(m.canReplace(m.childCount,m.childCount,y.content)){if(n){let v=At.empty;for(let N=b.length-1;N>=0;N--)v=At.from(b[N].copy(v));let S=t.tr.step(new _a(e.pos-b.length,e.pos+s.nodeSize,e.pos+x,e.pos+s.nodeSize-x,new Bt(v,b.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function Ute(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(wn.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const mHe=Ute(-1),pHe=Ute(1);function gHe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&z4(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 s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(o,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),h=d.index();i=d.parent.canReplaceWith(h,h+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];s.setBlockType(l,c,t,e)}r(s.scrollIntoView())}return!0}}function G4(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}G4(B4,Cte,jte);G4(B4,Rte,Ote);G4(Lte,Fte,Ite,dHe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function bHe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let l=r?n.tr:null;return xHe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function xHe(t,e,n,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=o.resolve(e.start-2);s=new kN(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new kN(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=z4(s,n,r,e);return l?(t&&yHe(t,e,l,i,n),!0):!1}function yHe(t,e,n,r,i){let s=At.empty;for(let d=n.length-1;d>=0;d--)s=At.from(n[d].type.create(n[d].attrs,s));t.step(new _a(e.start-(r?2:0),e.end,e.start,e.end,new Bt(s,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,h=e.endIndex,p=!0;d<h;d++,p=!1)!p&&zu(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function vHe(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?wHe(e,n,t,s):_He(e,n,s):!0:!1}}function wHe(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new _a(s-1,o,s,o,new Bt(At.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new kN(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Vb(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(s,-1)-1);return Wh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function _He(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,b=n.endIndex-1,y=n.startIndex;b>y;b--)m-=i.child(b).nodeSize,r.delete(m-1,m+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=s.node(-1),d=s.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?At.empty:At.from(i))))return!1;let h=s.pos,p=h+o.nodeSize;return r.step(new _a(h-(l?1:0),p+(c?1:0),h+1,p-1,new Bt((l?At.empty:At.from(i.copy(At.empty))).append(c?At.empty:At.from(i.copy(At.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function SHe(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,c=l.child(o-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=At.from(u?t.create():null),h=new Bt(At.from(t.create(null,At.from(l.type.create(null,d)))),u?3:1,0),p=s.start,m=s.end;n(e.tr.step(new _a(p-(u?3:1),m,p,m,h,1,!0)).scrollIntoView())}return!0}}const Ua=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},bb=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let QD=null;const bu=function(t,e,n){let r=QD||(QD=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},NHe=function(){QD=null},Dm=function(t,e,n,r){return n&&(y7(t,e,n,r,-1)||y7(t,e,n,r,1))},kHe=/^(img|br|input|textarea|hr)$/i;function y7(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:rl(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Sv(t)||kHe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ua(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?rl(t):0}else return!1}}function rl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function MHe(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=rl(t)}else if(t.parentNode&&!Sv(t))e=Ua(t),t=t.parentNode;else return null}}function EHe(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&&!Sv(t))e=Ua(t)+1,t=t.parentNode;else return null}}function THe(t,e,n){for(let r=e==0,i=e==rl(t);r||i;){if(t==n)return!0;let s=Ua(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==rl(t)}}function Sv(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 $M=function(t){return t.focusNode&&Dm(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Uf(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function AHe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function CHe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(rl(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(rl(r.startContainer),r.startOffset)}}}const Ec=typeof navigator<"u"?navigator:null,v7=typeof document<"u"?document:null,Kh=Ec&&Ec.userAgent||"",ZD=/Edge\/(\d+)/.exec(Kh),Bte=/MSIE \d/.exec(Kh),JD=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Kh),Ws=!!(Bte||JD||ZD),kh=Bte?document.documentMode:JD?+JD[1]:ZD?+ZD[1]:0,ll=!Ws&&/gecko\/(\d+)/i.test(Kh);ll&&+(/Firefox\/(\d+)/.exec(Kh)||[0,0])[1];const eR=!Ws&&/Chrome\/(\d+)/.exec(Kh),ns=!!eR,Hte=eR?+eR[1]:0,Es=!Ws&&!!Ec&&/Apple Computer/.test(Ec.vendor),xb=Es&&(/Mobile\/\w+/.test(Kh)||!!Ec&&Ec.maxTouchPoints>2),Qo=xb||(Ec?/Mac/.test(Ec.platform):!1),PHe=Ec?/Win/.test(Ec.platform):!1,Cu=/Android \d/.test(Kh),Nv=!!v7&&"webkitFontSmoothing"in v7.documentElement.style,jHe=Nv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function DHe(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 uu(t,e){return typeof t=="number"?t:t[e]}function RHe(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 w7(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=bb(o);continue}let l=o,c=l==s.body,u=c?DHe(s):RHe(l),d=0,h=0;if(e.top<u.top+uu(r,"top")?h=-(u.top-e.top+uu(i,"top")):e.bottom>u.bottom-uu(r,"bottom")&&(h=e.bottom-e.top>u.bottom-u.top?e.top+uu(i,"top")-u.top:e.bottom-u.bottom+uu(i,"bottom")),e.left<u.left+uu(r,"left")?d=-(u.left-e.left+uu(i,"left")):e.right>u.right-uu(r,"right")&&(d=e.right-u.right+uu(i,"right")),d||h)if(c)s.defaultView.scrollBy(d,h);else{let m=l.scrollLeft,b=l.scrollTop;h&&(l.scrollTop+=h),d&&(l.scrollLeft+=d);let y=l.scrollLeft-m,x=l.scrollTop-b;e={left:e.left-y,top:e.top-x,right:e.right-y,bottom:e.bottom-x}}let p=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:bb(o)}}function OHe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(s,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:$te(t.dom)}}function $te(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=bb(r));return e}function LHe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Vte(n,r==0?0:r-e)}function Vte(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let lg=null;function FHe(t){if(t.setActive)return t.setActive();if(lg)return t.focus(lg);let e=$te(t);t.focus(lg==null?{get preventScroll(){return lg={preventScroll:!0},!0}}:void 0),lg||(lg=!1,Vte(e,0))}function Gte(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=bu(d).getClientRects();else continue;for(let m=0;m<p.length;m++){let b=p[m];if(b.top<=o&&b.bottom>=l){o=Math.max(b.bottom,o),l=Math.min(b.top,l);let y=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,d.nodeType==1&&y&&(s=h+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!c&&b.left<=e.left&&b.right>=e.left&&(c=d,u={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(s=h+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?IHe(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:Gte(n,i)}function IHe(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=Kd(r,1);if(s.top!=s.bottom&&q4(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function q4(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function zHe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function UHe(t,e,n){let{node:r,offset:i}=Gte(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function BHe(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>r.left||c.top>r.top?i=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function qte(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let o=t.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(q4(e,u))return qte(o,e,u)}}if((s=(s+1)%r)==i)break}return t}function HHe(t,e){let n=t.dom.ownerDocument,r,i=0,s=CHe(n,e.left,e.top);s&&({node:r,offset:i}=s);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=t.dom.getBoundingClientRect();if(!q4(e,u)||(o=qte(t.dom,e,u),!o))return null}if(Es)for(let u=o;r&&u;u=bb(u))u.draggable&&(r=void 0);if(o=zHe(o,e),r){if(ll&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],h;d.nodeName=="IMG"&&(h=d.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let u;Nv&&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=BHe(t,r,i,e))}l==null&&(l=UHe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function _7(t){return t.top<t.bottom||t.left<t.right}function Kd(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(_7(r))return r}return Array.prototype.find.call(n,_7)||t.getBoundingClientRect()}const $He=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Wte(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Nv||ll;if(r.nodeType==3)if(o&&($He.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Kd(bu(r,i,i),n);if(ll&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Kd(bu(r,i-1,i-1),-1);if(u.top==c.top){let d=Kd(bu(r,i,i+1),-1);if(d.top!=c.top)return a0(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++,a0(Kd(bu(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==rl(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return RP(c.getBoundingClientRect(),!1)}if(s==null&&i<rl(r)){let c=r.childNodes[i];if(c.nodeType==1)return RP(c.getBoundingClientRect(),!0)}return RP(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==rl(r))){let c=r.childNodes[i-1],u=c.nodeType==3?bu(c,rl(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return a0(Kd(u,1),!1)}if(s==null&&i<rl(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?bu(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return a0(Kd(u,-1),!0)}return a0(Kd(r.nodeType==3?bu(r):r,-n),n>=0)}function a0(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 RP(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 Kte(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 VHe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Kte(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Wte(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=bu(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 GHe=/[\u0590-\u08ac]/;function qHe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!GHe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:Kte(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:h}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:y}=t.domSelectionRange(),x=b&&!m.contains(b.nodeType==1?b:b.parentNode)||c==b&&u==y;try{l.collapse(d,h),c&&(c!=d||u!=h)&&l.extend&&l.extend(c,u)}catch{}return p!=null&&(l.caretBidiLevel=p),x}):r.pos==r.start()||r.pos==r.end()}let S7=null,N7=null,k7=!1;function WHe(t,e,n){return S7==e&&N7==n?k7:(S7=e,N7=n,k7=n=="up"||n=="down"?VHe(t,e,n):qHe(t,e,n))}const cl=0,M7=1,Wf=2,Tc=3;class kv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=cl,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Ua(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof Yte){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Xte&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Ua(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Ua(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let c=this.children[l],u=o+c.size;if(i==-1&&e<=u){let d=o+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=o;for(let h=l;h>0;h--){let p=this.children[h-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=Ua(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 h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=Ua(h.dom);break}n+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let s=Math.min(e,n),o=Math.max(e,n);for(let m=0,b=0;m<this.children.length;m++){let y=this.children[m],x=b+y.size;if(s>b&&o<x)return y.setSelection(e-b-y.border,n-b-y.border,r,i);b=x}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(),h=!1;if((ll||Es)&&e==n){let{node:m,offset:b}=l;if(m.nodeType==3){if(h=!!(b&&m.nodeValue[b-1]==`
- `),h&&b==m.nodeValue.length)for(let y=m,x;y;y=y.parentNode){if(x=y.nextSibling){x.nodeName=="BR"&&(l=c={node:x.parentNode,offset:Ua(x)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=m.childNodes[b-1];h=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(ll&&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||h&&Es)&&Dm(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Dm(c.node,c.offset,d.focusNode,d.focusOffset))return;let p=!1;if((u.extend||e==n)&&!(h&&ll)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),p=!0}catch{}}if(!p){if(e>n){let b=l;l=c,c=b}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 s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,c=o-s.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?Wf:M7,e==l&&n==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Tc:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Wf:Tc}r=o}this.dirty=Wf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Wf:M7;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Xte extends kv{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==cl&&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 KHe extends kv{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 Rm extends kv{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=$m.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Rm(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Tc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Tc&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=cl){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=cl}}slice(e,n,r){let i=Rm.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=nR(s,n,o,r)),e>0&&(s=nR(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Mh extends kv{constructor(e,n,r,i,s,o,l,c,u){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,s,o){let l=s.nodeViews[n.type.name],c,u=l&&l(n,s,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,h=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:h}=$m.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let p=d;return d=Jte(d,r,n),u?c=new XHe(e,n,r,i,d,h||null,p,u,s,o+1):n.isText?new VM(e,n,r,i,d,p,s):new Mh(e,n,r,i,d,h||null,p,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>At.empty)}return e}matchesNode(e,n,r){return this.dirty==cl&&e.eq(this.node)&&EN(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,c=new QHe(this,o&&o.node,e);e$e(this.node,this.innerDeco,(u,d,h)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!h&&c.syncToMarks(d==this.node.childCount?zr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,h,p)=>{c.syncToMarks(u.marks,r,e);let m;c.findNodeMatch(u,d,h,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(u,d,h,m,e)||c.updateNextNode(u,d,h,e,p,i)||c.addNode(u,d,h,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Wf)&&(o&&this.protectLocalComposition(e,o),Qte(this.contentDOM,this.children,e),xb&&t$e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof wn)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=n$e(this.node.content,o,r-n,i-n);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new KHe(this,s,n,i);e.input.compositionNodes.push(o),this.children=nR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Tc||!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=cl}updateOuterDeco(e){if(EN(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Zte(this.dom,this.nodeDOM,tR(this.outerDeco,this.node,n),tR(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 E7(t,e,n,r,i){Jte(r,e,t);let s=new Mh(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class VM extends Mh{constructor(e,n,r,i,s,o,l){super(e,n,r,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Tc||this.dirty!=cl&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=cl||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=cl,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new VM(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Tc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Yte extends kv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==cl&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class XHe extends Mh{constructor(e,n,r,i,s,o,l,c,u,d){super(e,n,r,i,s,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==Tc)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Qte(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=T7(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Rm){let c=r?r.previousSibling:t.lastChild;Qte(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=T7(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const R0=function(t){t&&(this.nodeName=t)};R0.prototype=Object.create(null);const Kf=[new R0];function tR(t,e,n){if(t.length==0)return Kf;let r=n?Kf[0]:new R0,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new R0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new R0(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 Zte(t,e,n,r){if(n==Kf&&r==Kf)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(s){let c;l&&l.nodeName==o.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=Kf[0]),i=c}YHe(i,l||Kf[0],o)}return i}function YHe(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Jte(t,e,n){return Zte(t,t,Kf,tR(e,n,t.nodeType!=1))}function EN(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 T7(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class QHe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ZHe(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=cl,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=Rm.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==Tc&&o.dom==o.contentDOM&&(o.dirty=Wf),o.update(e,n,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Mh){let u=this.preMatch.matched.get(c);if(u!=null&&u!=s)return!1;let d=c.dom,h,p=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Tc&&EN(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&&(h=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=Wf,h.updateChildren(i,o+1),h.dirty=cl),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!EN(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Mh.create(this.top,n,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,n,r,i,s){let o=Mh.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Xte(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Rm;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof VM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Es||ns)&&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 Yte(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 ZHe(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Rm)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function JHe(t,e){return t.type.side-e.type.side}function e$e(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(s,d),u),s+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,h;for(;o<i.length&&i[o].to==s;){let x=i[o++];x.widget&&(d?(h||(h=[d])).push(x):d=x)}if(d)if(h){h.sort(JHe);for(let x=0;x<h.length;x++)n(h[x],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 x=0;x<l.length;x++)l[x].to<=s&&l.splice(x--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let b=s+p.nodeSize;if(p.isText){let x=b;o<i.length&&i[o].from<x&&(x=i[o].from);for(let v=0;v<l.length;v++)l[v].to<x&&(x=l[v].to);x<b&&(c=p.cut(x-s),p=p.cut(0,x-s),b=x,m=-1)}else for(;o<i.length&&i[o].to<b;)o++;let y=p.isInline&&!p.isLeaf?l.filter(x=>!x.inline):l.slice();r(p,y,e.forChild(s,p),m),s=b}}function t$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 n$e(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(s+=u.nodeSize,!u.isText)break;c+=u.text}if(s>=n){if(s>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function nR(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?s.push(c):(u<e&&s.push(c.slice(0,e-u,r)),i&&(s.push(i),i=void 0),d>n&&s.push(c.slice(n-u,c.size,r)))}return s}function W4(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if($M(n)){for(c=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&cn.isSelectable(h)&&i.parent&&!(h.isInline&&THe(n.focusNode,n.focusOffset,i.dom))){let p=i.posBefore;u=new cn(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=o,p=o;for(let m=0;m<n.rangeCount;m++){let b=n.getRangeAt(m);h=Math.min(h,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(h<0)return null;[c,o]=p==t.state.selection.anchor?[p,h]:[h,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 h=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;u=K4(t,d,l,h)}return u}function ene(t){return t.editable?t.hasFocus():nne(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Uu(t,e=!1){let n=t.state.selection;if(tne(t,n),!!ene(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ns){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Dm(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)i$e(t);else{let{anchor:r,head:i}=n,s,o;A7&&!(n instanceof wn)&&(n.$from.parent.inlineContent||(s=C7(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=C7(t,n.to))),t.docView.setSelection(r,i,t,e),A7&&(s&&P7(s),o&&P7(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&r$e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const A7=Es||ns&&Hte<63;function C7(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Es&&i&&i.contentEditable=="false")return OP(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return OP(i);if(s)return OP(s)}}function OP(t){return t.contentEditable="true",Es&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function P7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function r$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(()=>{(!ene(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function i$e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ua(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ws&&kh<=11&&(n.disabled=!0,n.disabled=!1)}function tne(t,e){if(e instanceof cn){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(j7(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else j7(t)}function j7(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function K4(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||wn.between(e,n,r)}function D7(t){return t.editable&&!t.hasFocus()?!1:nne(t)}function nne(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 a$e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Dm(e.node,e.offset,n.anchorNode,n.anchorOffset)}function rR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&On.findFrom(s,e)}function Jd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function R7(t,e,n){let r=t.state.selection;if(r instanceof wn)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Jd(t,new wn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=rR(t.state,e);return i&&i instanceof cn?Jd(t,i):!1}else if(!(Qo&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?cn.isSelectable(s)?Jd(t,new cn(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Nv?Jd(t,new wn(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof cn&&r.node.isInline)return Jd(t,new wn(e>0?r.$to:r.$from));{let i=rR(t.state,e);return i?Jd(t,i):!1}}}function TN(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function O0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function cg(t,e){return e<0?s$e(t):o$e(t)}function s$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(ll&&n.nodeType==1&&r<TN(n)&&O0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(O0(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(rne(n))break;{let l=n.previousSibling;for(;l&&O0(l,-1);)i=n.parentNode,s=Ua(l),l=l.previousSibling;if(l)n=l,r=TN(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?iR(t,n,r):i&&iR(t,i,s)}function o$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=TN(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(O0(l,1))s=n,o=++r;else break}else{if(rne(n))break;{let l=n.nextSibling;for(;l&&O0(l,1);)s=l.parentNode,o=Ua(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=TN(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&iR(t,s,o)}function rne(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function l$e(t,e){for(;t&&e==t.childNodes.length&&!Sv(t);)e=Ua(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 c$e(t,e){for(;t&&!e&&!Sv(t);)e=Ua(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 iR(t,e,n){if(e.nodeType!=3){let s,o;(o=l$e(e,n))?(e=o,n=0):(s=c$e(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if($M(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Uu(t)},50)}function O7(t,e){let n=t.state.doc.resolve(e);if(!(ns||PHe)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function L7(t,e,n){let r=t.state.selection;if(r instanceof wn&&!r.empty||n.indexOf("s")>-1||Qo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=rR(t.state,e);if(o&&o instanceof cn)return Jd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Mo?On.near(o,e):On.findFrom(o,e);return l?Jd(t,l):!1}return!1}function F7(t,e){if(!(t.state.selection instanceof wn))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function I7(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function u$e(t){if(!Es||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;I7(t,r,"true"),setTimeout(()=>I7(t,r,"false"),20)}return!1}function d$e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function h$e(t,e){let n=e.keyCode,r=d$e(e);if(n==8||Qo&&n==72&&r=="c")return F7(t,-1)||cg(t,-1);if(n==46&&!e.shiftKey||Qo&&n==68&&r=="c")return F7(t,1)||cg(t,1);if(n==13||n==27)return!0;if(n==37||Qo&&n==66&&r=="c"){let i=n==37?O7(t,t.state.selection.from)=="ltr"?-1:1:-1;return R7(t,i,r)||cg(t,i)}else if(n==39||Qo&&n==70&&r=="c"){let i=n==39?O7(t,t.state.selection.from)=="ltr"?1:-1:1;return R7(t,i,r)||cg(t,i)}else{if(n==38||Qo&&n==80&&r=="c")return L7(t,-1,r)||cg(t,-1);if(n==40||Qo&&n==78&&r=="c")return u$e(t)||L7(t,1,r)||cg(t,1);if(r==(Qo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function X4(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||$m.fromSchema(t.state.schema),l=cne(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,h=0;for(;u&&u.nodeType==1&&(d=lne[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let b=l.createElement(d[m]);for(;c.firstChild;)b.appendChild(c.firstChild);c.appendChild(b),h++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:c,text:p,slice:e}}function ine(t,e,n,r,i){let s=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||s||!n);if(c){if(t.someProp("transformPastedText",p=>{e=p(e,s||r,t)}),s)return l=new Bt(At.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let h=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(h)l=h;else{let p=i.marks(),{schema:m}=t.state,b=$m.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let x=o.appendChild(document.createElement("p"));y&&x.appendChild(b.serializeNode(m.text(y,p)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),o=g$e(n),Nv&&b$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 h=+d[3];h>0;h--){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")||j0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!f$e.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=x$e(z7(l,+d[1],+d[2]),d[4]);else if(l=Bt.maxOpen(m$e(l.content,i),!0),l.openStart||l.openEnd){let h=0,p=0;for(let m=l.content.firstChild;h<l.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=z7(l,h,p)}return t.someProp("transformPasted",h=>{l=h(l,t,c)}),l}const f$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 m$e(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&s.length&&sne(c,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=one(o[o.length-1],s.length));let d=ane(l,c);o.push(d),i=i.matchType(d.type),s=c}}),o)return At.from(o)}return t}function ane(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,At.from(t));return t}function sne(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=sne(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(At.from(ane(n,t,i+1))))}}function one(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,one(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(At.empty,!0);return t.copy(n.append(r))}function aR(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),i<r-1&&(l=aR(l,e,n,r,i+1,s)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(At.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function z7(t,e,n){return e<t.openStart&&(t=new Bt(aR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Bt(aR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const lne={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 U7=null;function cne(){return U7||(U7=document.implementation.createHTMLDocument("title"))}let LP=null;function p$e(t){let e=window.trustedTypes;return e?(LP||(LP=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),LP.createHTML(t)):t}function g$e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=cne().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&lne[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=p$e(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function b$e(t){let e=t.querySelectorAll(ns?"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 x$e(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:s,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=At.from(c.create(r[l+1],i)),s++,o++}return new Bt(i,s,o)}const Ts={},As={},y$e={touchstart:!0,touchmove:!0};class v$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 w$e(t){for(let e in Ts){let n=Ts[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{S$e(t,r)&&!Y4(t,r)&&(t.editable||!(r.type in As))&&n(t,r)},y$e[e]?{passive:!0}:void 0)}Es&&t.dom.addEventListener("input",()=>null),sR(t)}function fh(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 sR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Y4(t,r))})}function Y4(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function S$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 N$e(t,e){!Y4(t,e)&&Ts[e.type]&&(t.editable||!(e.type in As))&&Ts[e.type](t,e)}As.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!dne(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Cu&&ns&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),xb&&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,Uf(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||h$e(t,n)?n.preventDefault():fh(t,"key")};As.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};As.keypress=(t,e)=>{let n=e;if(dne(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Qo&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof wn)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function GM(t){return{left:t.clientX,top:t.clientY}}function k$e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Q4(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,l=>o>s.depth?l(t,n,s.nodeAfter,s.before(o),i,!0):l(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function $g(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 M$e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&cn.isSelectable(r)?($g(t,new cn(n)),!0):!1}function E$e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof cn&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(cn.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?($g(t,cn.create(t.state.doc,i)),!0):!1}function T$e(t,e,n,r,i){return Q4(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?E$e(t,n):M$e(t,n))}function A$e(t,e,n,r){return Q4(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function C$e(t,e,n,r){return Q4(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||P$e(t,n,r)}function P$e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?($g(t,wn.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)$g(t,wn.create(r,l+1,l+1+o.content.size));else if(cn.isSelectable(o))$g(t,cn.create(r,l));else continue;return!0}}function Z4(t){return AN(t)}const une=Qo?"metaKey":"ctrlKey";Ts.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Z4(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&k$e(n,t.input.lastClick)&&!n[une]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let o=t.posAtCoords(GM(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new j$e(t,o,n,!!r)):(s=="doubleClick"?A$e:C$e)(t,o.pos,o.inside,n)?n.preventDefault():fh(t,"pointer"))};class j$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[une],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);s=d.parent,o=d.depth?d.before():0}const l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof cn&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ll&&!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)),fh(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(()=>Uu(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(GM(e))),this.updateAllowDefault(e),this.allowDefault||!n?fh(this.view,"pointer"):T$e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Es&&this.mightDrag&&!this.mightDrag.node.isAtom||ns&&!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)?($g(this.view,On.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):fh(this.view,"pointer")}move(e){this.updateAllowDefault(e),fh(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)}}Ts.touchstart=t=>{t.input.lastTouch=Date.now(),Z4(t),fh(t,"pointer")};Ts.touchmove=t=>{t.input.lastTouch=Date.now(),fh(t,"pointer")};Ts.contextmenu=t=>Z4(t);function dne(t,e){return t.composing?!0:Es&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const D$e=Cu?5e3:-1;As.compositionstart=As.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof wn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),AN(t,!0),t.markCursor=null;else if(AN(t,!e.selection.empty),ll&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}hne(t,D$e)};As.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++,hne(t,20))};function hne(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>AN(t),e))}function fne(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=O$e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function R$e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=MHe(e.focusNode,e.focusOffset),r=EHe(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function O$e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function AN(t,e=!1){if(!(Cu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),fne(t),e||t.docView&&t.docView.dirty){let n=W4(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 L$e(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 Py=Ws&&kh<15||xb&&jHe<604;Ts.copy=As.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=Py?null:n.clipboardData,o=r.content(),{dom:l,text:c}=X4(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):L$e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function F$e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function I$e(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?jy(t,r.value,null,i,e):jy(t,r.textContent,r.innerHTML,i,e)},50)}function jy(t,e,n,r,i){let s=ine(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,s||Bt.empty)))return!0;if(!s)return!1;let o=F$e(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function mne(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," "):""}As.paste=(t,e)=>{let n=e;if(t.composing&&!Cu)return;let r=Py?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&jy(t,mne(r),r.getData("text/html"),i,n)?n.preventDefault():I$e(t,n)};class pne{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const z$e=Qo?"altKey":"ctrlKey";function gne(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[z$e]}Ts.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(GM(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof cn?i.to-1:i.to))){if(r&&r.mightDrag)o=cn.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(o=cn.create(t.state.doc,h.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=X4(t,l);(!n.dataTransfer.files.length||!ns||Hte>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Py?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Py||n.dataTransfer.setData("text/plain",u),t.dragging=new pne(d,gne(t,n),o)};Ts.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};As.dragover=As.dragenter=(t,e)=>e.preventDefault();As.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(GM(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",b=>{o=b(o,t,!1)}):o=ine(t,mne(n.dataTransfer),Py?null:n.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&gne(t,n));if(t.someProp("handleDrop",b=>b(t,n,o||Bt.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?wte(t.state.doc,s.pos,o):s.pos;c==null&&(c=s.pos);let u=t.state.tr;if(l){let{node:b}=r;b?b.replace(u):u.deleteSelection()}let d=u.mapping.map(c),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,p=u.doc;if(h?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(p))return;let m=u.doc.resolve(d);if(h&&cn.isSelectable(o.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new cn(m));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,x,v,S)=>b=S),u.setSelection(K4(t,m,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Ts.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())&&Uu(t)},20))};Ts.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)};Ts.beforeinput=(t,e)=>{if(ns&&Cu&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,Uf(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 As)Ts[t]=As[t];function Dy(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 CN{constructor(e,n){this.toDOM=e,this.spec=n||cm,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new ws(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof CN&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Dy(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Eh{constructor(e,n){this.attrs=e,this.spec=n||cm}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ws(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Eh&&Dy(this.attrs,e.attrs)&&Dy(this.spec,e.spec)}static is(e){return e.type instanceof Eh}destroy(){}}class J4{constructor(e,n){this.attrs=e,this.spec=n||cm}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new ws(s.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof J4&&Dy(this.attrs,e.attrs)&&Dy(this.spec,e.spec)}destroy(){}}class ws{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ws(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new ws(e,e,new CN(n,r))}static inline(e,n,r,i){return new ws(e,n,new Eh(r,i))}static node(e,n,r,i){return new ws(e,n,new J4(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Eh}get widget(){return this.type instanceof CN}}const bg=[],cm={};class li{constructor(e,n){this.local=e.length?e:bg,this.children=n.length?n:bg}static create(e,n){return n.length?PN(n,e,0,cm):Ja}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,s)}}map(e,n,r){return this==Ja||e.maps.length==0?this:this.mapInner(e,n,0,0,r||cm)}mapInner(e,n,r,i,s){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(n,c)?(o||(o=[])).push(c):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?U$e(this.children,o||[],e,n,r,i,s):o?new li(o.sort(um),bg):Ja}add(e,n){return n.length?this==Ja?li.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,c)=>{let u=c+r,d;if(d=xne(n,l,u)){for(i||(i=this.children.slice());s<i.length&&i[s]<c;)s+=3;i[s]==c?i[s+2]=i[s+2].addInner(l,d,u+1):i.splice(s,0,c,c+l.nodeSize,PN(d,l,u+1,cm)),s+=3}});let o=bne(s?yne(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new li(o.length?this.local.concat(o).sort(um):this.local,i||this.children)}remove(e){return e.length==0||this==Ja?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+n,c=r[s+1]+n;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>l&&h.to<c&&(e[d]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[s+2].removeInner(o,l+1);u!=Ja?r[s+2]=u:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new li(i,r):Ja}forChild(e,n){if(this==Ja)return this;if(n.isLeaf)return li.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>s&&c.type instanceof Eh){let u=Math.max(s,c.from)-s,d=Math.min(o,c.to)-s;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new li(i.sort(um),bg);return r?new sh([l,r]):l}return r||Ja}eq(e){if(this==e)return!0;if(!(e instanceof li)||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 eF(this.localsInner(e))}localsInner(e){if(this==Ja)return bg;if(e.inlineContent||!this.local.some(Eh.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Eh||n.push(this.local[r]);return n}forEachSet(e){e(this)}}li.empty=new li([],[]);li.removeOverlap=eF;const Ja=li.empty;class sh{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,cm));return sh.from(r)}forChild(e,n){if(n.isLeaf)return li.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=Ja&&(s instanceof sh?r=r.concat(s.members):r.push(s))}return sh.from(r)}eq(e){if(!(e instanceof sh)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let o=0;o<s.length;o++)n.push(s[o])}}return n?eF(r?n:n.sort(um)):bg}static from(e){switch(e.length){case 0:return Ja;case 1:return e[0];default:return new sh(e.every(n=>n instanceof li)?e:e.reduce((n,r)=>n.concat(r instanceof li?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function U$e(t,e,n,r,i,s,o){let l=t.slice();for(let u=0,d=s;u<n.maps.length;u++){let h=0;n.maps[u].forEach((p,m,b,y)=>{let x=y-b-(m-p);for(let v=0;v<l.length;v+=3){let S=l[v+1];if(S<0||p>S+d-h)continue;let N=l[v]+d-h;m>=N?l[v+1]=p<=N?-2:-1:p>=d&&x&&(l[v]+=x,l[v+1]+=x)}h+=x}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+s),h=d-i;if(h<0||h>=r.content.size){c=!0;continue}let p=n.map(t[u+1]+s,-1),m=p-i,{index:b,offset:y}=r.content.findIndex(h),x=r.maybeChild(b);if(x&&y==h&&y+x.nodeSize==m){let v=l[u+2].mapInner(n,x,d+1,t[u]+s+1,o);v!=Ja?(l[u]=h,l[u+1]=m,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=B$e(l,t,e,n,i,s,o),d=PN(u,r,0,o);e=d.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,p=0;h<d.children.length;h+=3){let m=d.children[h];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,d.children[h],d.children[h+1],d.children[h+2])}}return new li(e.sort(um),l)}function bne(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new ws(i.from+e,i.to+e,i.type))}return n}function B$e(t,e,n,r,i,s,o){function l(c,u){for(let d=0;d<c.local.length;d++){let h=c.local[d].map(r,i,u);h?n.push(h):o.onRemove&&o.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+s+1);return n}function xne(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function yne(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function PN(t,e,n,r){let i=[],s=!1;e.forEach((l,c)=>{let u=xne(t,l,c+n);if(u){s=!0;let d=PN(u,l,n+c+1,r);d!=Ja&&i.push(c,c+l.nodeSize,d)}});let o=bne(s?yne(t):t,-n).sort(um);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 li(o,i):Ja}function um(t,e){return t.from-e.from||t.to-e.to}function eF(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),B7(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),B7(e,i,r.copy(s.from,r.to)));break}}}return e}function B7(t,e,n){for(;e<t.length&&um(n,t[e])>0;)e++;t.splice(e,0,n)}function FP(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ja&&e.push(r)}),t.cursorWrapper&&e.push(li.create(t.state.doc,[t.cursorWrapper.deco])),sh.from(e)}const H$e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},$$e=Ws&&kh<=11;class V$e{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 G$e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new V$e,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Ws&&kh<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),$$e&&(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,H$e)),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(D7(this.view)){if(this.suppressingSelectionUpdates)return Uu(this.view);if(Ws&&kh<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Dm(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=bb(s))n.add(s);for(let s=e.anchorNode;s;s=bb(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&D7(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let h=this.registerMutation(n[d],c);h&&(s=s<0?h.from:Math.min(h.from,s),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(l=!0))}if(ll&&c.length){let d=c.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,p]=d;h.parentNode&&h.parentNode.parentNode==p.parentNode?p.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let p of d){let m=p.parentNode;m&&m.nodeName=="LI"&&(!h||K$e(e,h)!=m)&&p.remove()}}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&$M(r)&&(u=W4(e))&&u.eq(On.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Uu(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),q$e(e)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Uu(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 h=e.addedNodes[d];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Ws&&kh<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:p}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p)}let o=i&&i.parentNode==e.target?Ua(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?Ua(s):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let H7=new WeakMap,$7=!1;function q$e(t){if(!H7.has(t)&&(H7.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=ll,$7)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."),$7=!0}}function V7(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Dm(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function W$e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return V7(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?V7(t,n):null}function K$e(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 X$e(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],$M(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ns&&t.input.lastKeyCode===8)for(let x=s;x>i;x--){let v=r.childNodes[x-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){s=x;break}if(!S||S.size)break}let h=t.state.doc,p=t.someProp("domParser")||j0.fromSchema(t.state.schema),m=h.resolve(o),b=null,y=p.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Y$e,context:m});if(u&&u[0].pos!=null){let x=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=x),b={anchor:x+o,head:v+o}}return{doc:y,sel:b,from:o,to:l}}function Y$e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Es&&/^(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||Es&&/^(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 Q$e=/^(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 Z$e(t,e,n,r,i){let s=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=W4(t,k);if(R&&!t.state.selection.eq(R)){if(ns&&Cu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",P=>P(t,Uf(13,"Enter"))))return;let C=t.state.tr.setSelection(R);k=="pointer"?C.setMeta("pointer",!0):k=="key"&&C.scrollIntoView(),s&&C.setMeta("composition",s),t.dispatch(C)}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=X$e(t,e,n),d=t.state.doc,h=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 b=tVe(h.content,u.doc.content,u.from,p,m);if(b&&t.input.domChangeCount++,(xb&&t.input.lastIOSEnter>Date.now()-225||Cu)&&i.some(k=>k.nodeType==1&&!Q$e.test(k.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",k=>k(t,Uf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&c instanceof wn&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let k=G7(t,t.state.doc,u.sel);if(k&&!k.eq(t.state.selection)){let R=t.state.tr.setSelection(k);s&&R.setMeta("composition",s),t.dispatch(R)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof wn&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),Ws&&kh<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)==" "&&(b.start--,b.endA--,b.endB--);let y=u.doc.resolveNoCache(b.start-u.from),x=u.doc.resolveNoCache(b.endB-u.from),v=d.resolve(b.start),S=y.sameParent(x)&&y.parent.inlineContent&&v.end()>=b.endA;if((xb&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!S&&y.pos<u.doc.content.size&&(!y.sameParent(x)||!y.parent.inlineContent)&&y.pos<x.pos&&!/\S/.test(u.doc.textBetween(y.pos,x.pos,"","")))&&t.someProp("handleKeyDown",k=>k(t,Uf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&eVe(d,b.start,b.endA,y,x)&&t.someProp("handleKeyDown",k=>k(t,Uf(8,"Backspace")))){Cu&&ns&&t.domObserver.suppressSelectionUpdates();return}ns&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),Cu&&!S&&y.start()!=x.start()&&x.parentOffset==0&&y.depth==x.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,x=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(k){return k(t,Uf(13,"Enter"))})},20));let N=b.start,T=b.endA,M=k=>{let R=k||t.state.tr.replace(N,T,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let C=G7(t,R.doc,u.sel);C&&!(ns&&t.composing&&C.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==N||C.head==R.mapping.map(T)-1)||Ws&&C.empty&&C.head==N)&&R.setSelection(C)}return s&&R.setMeta("composition",s),R.scrollIntoView()},A;if(S)if(y.pos==x.pos){Ws&&kh<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Uu(t),20));let k=M(t.state.tr.delete(N,T)),R=d.resolve(b.start).marksAcross(d.resolve(b.endA));R&&k.ensureMarks(R),t.dispatch(k)}else if(b.endA==b.endB&&(A=J$e(y.parent.content.cut(y.parentOffset,x.parentOffset),v.parent.content.cut(v.parentOffset,b.endA-v.start())))){let k=M(t.state.tr);A.type=="add"?k.addMark(N,T,A.mark):k.removeMark(N,T,A.mark),t.dispatch(k)}else if(y.parent.child(y.index()).isText&&y.index()==x.index()-(x.textOffset?0:1)){let k=y.parent.textBetween(y.parentOffset,x.parentOffset),R=()=>M(t.state.tr.insertText(k,N,T));t.someProp("handleTextInput",C=>C(t,N,T,k,R))||t.dispatch(R())}else t.dispatch(M());else t.dispatch(M())}function G7(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:K4(t,e.resolve(n.anchor),e.resolve(n.head))}function J$e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,l,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)s=n[d].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(At.from(u).eq(t))return{mark:l,type:o}}function eVe(t,e,n,r,i){if(n-e<=i.pos-r.pos||IP(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(IP(s,!0,!0));return!o.parent.isTextblock||o.pos>n||IP(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function IP(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function tVe(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,s-Math.min(o,l));r-=o+c-s}if(o<s&&t.size<e.size){let c=r<=s&&r>=o?s-r:0;s-=c,s&&s<e.size&&q7(e.textBetween(s-1,s+1))&&(s+=c?1:-1),l=s+(l-o),o=s}else if(l<s){let c=r<=s&&r>=l?s-r:0;s-=c,s&&s<t.size&&q7(t.textBetween(s-1,s+1))&&(s+=c?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function q7(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 vne{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 v$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(Q7),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=X7(this),K7(this),this.nodeViews=Y7(this),this.docView=E7(this.state.doc,W7(this),FP(this),this.dom,this),this.domObserver=new G$e(this,(r,i,s,o)=>Z$e(this,r,i,s,o)),this.domObserver.start(),w$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&&sR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Q7),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(fne(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=Y7(this);rVe(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&sR(this),this.editable=X7(this),K7(this);let c=FP(this),u=W7(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,u,c);(h||!e.selection.eq(i.selection))&&(o=!0);let p=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&OHe(this);if(o){this.domObserver.stop();let m=h&&(Ws||ns)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&nVe(i.selection,e.selection);if(h){let b=ns?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=R$e(this)),(s||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=E7(e.doc,u,c,this.dom,this)),b&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&a$e(this))?Uu(this,m):(tne(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&&LHe(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 cn){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&w7(this,n.getBoundingClientRect(),e)}else w7(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new pne(e.slice,e.move,i<0?void 0:cn.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Ws){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&FHe(this.dom),Uu(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 HHe(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 WHe(this,n||this.state,e)}pasteHTML(e,n){return jy(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return jy(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return X4(this,e)}destroy(){this.docView&&(_$e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],FP(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,NHe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return N$e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Es&&this.root.nodeType===11&&AHe(this.dom.ownerDocument)==this.dom&&W$e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}vne.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function W7(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[ws.node(0,t.state.doc.content.size,e)]}function K7(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:ws.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function X7(t){return!t.someProp("editable",e=>e(t.state)===!1)}function nVe(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 Y7(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 rVe(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 Q7(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 Bh={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:"'"},jN={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},iVe=typeof navigator<"u"&&/Mac/.test(navigator.platform),aVe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ba=0;Ba<10;Ba++)Bh[48+Ba]=Bh[96+Ba]=String(Ba);for(var Ba=1;Ba<=24;Ba++)Bh[Ba+111]="F"+Ba;for(var Ba=65;Ba<=90;Ba++)Bh[Ba]=String.fromCharCode(Ba+32),jN[Ba]=String.fromCharCode(Ba);for(var zP in Bh)jN.hasOwnProperty(zP)||(jN[zP]=Bh[zP]);function sVe(t){var e=iVe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||aVe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?jN:Bh)[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 oVe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),lVe=typeof navigator<"u"&&/Win/.test(navigator.platform);function cVe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))oVe?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function uVe(t){let e=Object.create(null);for(let n in t)e[cVe(n)]=t[n];return e}function UP(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 dVe(t){return new hi({props:{handleKeyDown:wne(t)}})}function wne(t){let e=uVe(t);return function(n,r){let i=sVe(r),s,o=e[UP(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[UP(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(lVe&&r.ctrlKey&&r.altKey)&&(s=Bh[r.keyCode])&&s!=i){let l=e[UP(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var hVe=Object.defineProperty,tF=(t,e)=>{for(var n in e)hVe(t,n,{get:e[n],enumerable:!0})};function qM(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var WM=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),o.every(h=>h===!0)),d={...Object.fromEntries(Object.entries(n).map(([h,p])=>[h,(...b)=>{const y=this.buildProps(c,e),x=p(...b)(y);return o.push(x),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:t,editor:r,view:s,state:qM({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}},_ne={};tF(_ne,{blur:()=>fVe,clearContent:()=>mVe,clearNodes:()=>pVe,command:()=>gVe,createParagraphNear:()=>bVe,cut:()=>xVe,deleteCurrentNode:()=>yVe,deleteNode:()=>vVe,deleteRange:()=>wVe,deleteSelection:()=>_Ve,enter:()=>SVe,exitCode:()=>NVe,extendMarkRange:()=>kVe,first:()=>MVe,focus:()=>TVe,forEach:()=>AVe,insertContent:()=>CVe,insertContentAt:()=>DVe,joinBackward:()=>LVe,joinDown:()=>OVe,joinForward:()=>FVe,joinItemBackward:()=>IVe,joinItemForward:()=>zVe,joinTextblockBackward:()=>UVe,joinTextblockForward:()=>BVe,joinUp:()=>RVe,keyboardShortcut:()=>$Ve,lift:()=>VVe,liftEmptyBlock:()=>GVe,liftListItem:()=>qVe,newlineInCode:()=>WVe,resetAttributes:()=>KVe,scrollIntoView:()=>XVe,selectAll:()=>YVe,selectNodeBackward:()=>QVe,selectNodeForward:()=>ZVe,selectParentNode:()=>JVe,selectTextblockEnd:()=>eGe,selectTextblockStart:()=>tGe,setContent:()=>nGe,setMark:()=>vGe,setMeta:()=>wGe,setNode:()=>_Ge,setNodeSelection:()=>SGe,setTextDirection:()=>NGe,setTextSelection:()=>kGe,sinkListItem:()=>MGe,splitBlock:()=>EGe,splitListItem:()=>TGe,toggleList:()=>AGe,toggleMark:()=>CGe,toggleNode:()=>PGe,toggleWrap:()=>jGe,undoInputRule:()=>DGe,unsetAllMarks:()=>RGe,unsetMark:()=>OGe,unsetTextDirection:()=>LGe,updateAttributes:()=>FGe,wrapIn:()=>IGe,wrapInList:()=>zGe});var fVe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),mVe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),pVe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,h=u.resolve(d.map(c)),p=u.resolve(d.map(c+l.nodeSize)),m=h.blockRange(p);if(!m)return;const b=Vb(m);if(l.type.isTextblock){const{defaultType:y}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(m.start,y)}(b||b===0)&&e.lift(m,b)})}),!0},gVe=t=>e=>t(e),bVe=()=>({state:t,dispatch:e})=>Fte(t,e),xVe=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new wn(r.doc.resolve(Math.max(o-1,0)))),!0},yVe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),c=i.after(s);t.delete(l,c).scrollIntoView()}return!0}return!1};function Wi(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 vVe=t=>({tr:e,state:n,dispatch:r})=>{const i=Wi(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const c=s.before(o),u=s.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},wVe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},_Ve=()=>({state:t,dispatch:e})=>B4(t,e),SVe=()=>({commands:t})=>t.keyboardShortcut("Enter"),NVe=()=>({state:t,dispatch:e})=>cHe(t,e);function nF(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function DN(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:nF(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Sne(t,e,n={}){return t.find(r=>r.type===e&&DN(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function Z7(t,e,n={}){return!!Sne(t,e,n)}function rF(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),!Sne([...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&&Z7([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&Z7([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function od(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 kVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=od(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const h=rF(c,s,e);if(h&&h.from<=u&&h.to>=d){const p=wn.create(o,h.from,h.to);n.setSelection(p)}}return!0},MVe=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 Nne(t){return t instanceof wn}function Xf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function kne(t,e=null){if(!e)return null;const n=On.atStart(t),r=On.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?wn.create(t,Xf(0,i,s),Xf(t.content.size,i,s)):wn.create(t,Xf(e,i,s),Xf(e,i,s))}function EVe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function iF(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var TVe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(iF()||EVe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!Nne(n.state.selection))return o(),!0;const l=kne(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return s&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},AVe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),CVe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Mne=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&&Mne(r)}return t};function p1(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 Mne(n)}function Ry(t,e,n){if(t instanceof Nh||t instanceof At)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 At.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),Ry("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new ute({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?j0.fromSchema(c).parseSlice(p1(t),n.parseOptions):j0.fromSchema(c).parse(p1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=j0.fromSchema(e);return n.slice?s.parseSlice(p1(t),n.parseOptions).content:s.parse(p1(t),n.parseOptions)}return Ry("",e,n)}function PVe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof va||i instanceof _a))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(On.near(t.doc.resolve(o),n))}var jVe=t=>!("type"in t),DVe=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=x=>{s.emit("contentError",{editor:s,error:x,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Ry(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(x){c(x)}try{l=Ry(e,s.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(x){return c(x),!1}let{from:d,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,m=!0;if((jVe(l)?l:[l]).forEach(x=>{x.check(),p=p?x.isText&&x.marks.length===0:!1,m=m?x.isBlock:!1}),d===h&&m){const{parent:x}=r.doc.resolve(d);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(d-=1,h+=1)}let y;if(p){if(Array.isArray(e))y=e.map(x=>x.text||"").join("");else if(e instanceof At){let x="";e.forEach(v=>{v.text&&(x+=v.text)}),y=x}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,h)}else{y=l;const x=r.doc.resolve(d),v=x.node(),S=x.parentOffset===0,N=v.isText||v.isTextblock,T=v.content.size>0;S&&N&&T&&(d=Math.max(0,d-1)),r.replaceWith(d,h,y)}n.updateSelection&&PVe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},RVe=()=>({state:t,dispatch:e})=>sHe(t,e),OVe=()=>({state:t,dispatch:e})=>oHe(t,e),LVe=()=>({state:t,dispatch:e})=>Cte(t,e),FVe=()=>({state:t,dispatch:e})=>Rte(t,e),IVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=UM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},zVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=UM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},UVe=()=>({state:t,dispatch:e})=>iHe(t,e),BVe=()=>({state:t,dispatch:e})=>aHe(t,e);function Ene(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function HVe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))iF()||Ene()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var $Ve=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=HVe(t).split(/-(?!$)/),o=s.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Hh(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?Wi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(h,p)=>{if(h.isText)return;const m=Math.max(r,p),b=Math.min(i,p+h.nodeSize);l.push({node:h,from:m,to:b})});const c=i-r,u=l.filter(h=>o?o.name===h.node.type.name:!0).filter(h=>DN(h.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((h,p)=>h+p.to-p.from,0)>=c}var VVe=(t,e={})=>({state:n,dispatch:r})=>{const i=Wi(t,n.schema);return Hh(n,i,e)?lHe(n,r):!1},GVe=()=>({state:t,dispatch:e})=>Ite(t,e),qVe=t=>({state:e,dispatch:n})=>{const r=Wi(t,e.schema);return vHe(r)(e,n)},WVe=()=>({state:t,dispatch:e})=>Lte(t,e);function KM(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function J7(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 KVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=KM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=Wi(t,r.schema)),l==="mark"&&(o=od(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,h)=>{s&&s===d.type&&(c=!0,i&&n.setNodeMarkup(h,void 0,J7(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(p=>{o===p.type&&(c=!0,i&&n.addMark(h,h+d.nodeSize,o.create(J7(p.attrs,e))))})})}),c},XVe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),YVe=()=>({tr:t,dispatch:e})=>{if(e){const n=new Mo(t.doc);t.setSelection(n)}return!0},QVe=()=>({state:t,dispatch:e})=>jte(t,e),ZVe=()=>({state:t,dispatch:e})=>Ote(t,e),JVe=()=>({state:t,dispatch:e})=>hHe(t,e),eGe=()=>({state:t,dispatch:e})=>pHe(t,e),tGe=()=>({state:t,dispatch:e})=>mHe(t,e);function oR(t,e,n={},r={}){return Ry(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var nGe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:c}=s;if(r.preserveWhitespace!=="full"){const u=oR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Tne(t,e){const n=od(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function Ane(t,e){const n=new Mte(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function rGe(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 iGe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function aGe(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 XM(t){return e=>aGe(e.$from,t)}function tn(t,e,n){return t.config[e]===void 0&&t.parent?tn(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?tn(t.parent,e,n):null}):t.config[e]}function aF(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=tn(e,"addExtensions",n);return r?[e,...aF(r())]:e}).flat(10)}function sF(t,e){const n=$m.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Cne(t){return typeof t=="function"}function yr(t,e=void 0,...n){return Cne(t)?e?t.bind(e)(...n):t(...n):t}function sGe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function yb(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 Pne(t){const e=[],{nodeExtensions:n,markExtensions:r}=yb(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},c=tn(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(h=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...s,...m}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=tn(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,h])=>{const p={...s,...h};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 Si(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[h,p]=d.split(":").map(m=>m.trim());u.set(h,p)}),l.forEach(d=>{const[h,p]=d.split(":").map(m=>m.trim());u.set(h,p)}),r[i]=Array.from(u.entries()).map(([d,h])=>`${d}: ${h}`).join("; ")}else r[i]=s}),r},{})}function RN(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)=>Si(n,r),{})}function oGe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function e9(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):oGe(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function t9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&sGe(n)?!1:n!=null))}function n9(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 lGe(t,e){var n;const r=Pne(t),{nodeExtensions:i,markExtensions:s}=yb(t),o=(n=i.find(u=>tn(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((v,S)=>{const N=tn(S,"extendNodeSchema",h);return{...v,...N?N(u):{}}},{}),m=t9({...p,content:yr(tn(u,"content",h)),marks:yr(tn(u,"marks",h)),group:yr(tn(u,"group",h)),inline:yr(tn(u,"inline",h)),atom:yr(tn(u,"atom",h)),selectable:yr(tn(u,"selectable",h)),draggable:yr(tn(u,"draggable",h)),code:yr(tn(u,"code",h)),whitespace:yr(tn(u,"whitespace",h)),linebreakReplacement:yr(tn(u,"linebreakReplacement",h)),defining:yr(tn(u,"defining",h)),isolating:yr(tn(u,"isolating",h)),attrs:Object.fromEntries(d.map(n9))}),b=yr(tn(u,"parseHTML",h));b&&(m.parseDOM=b.map(v=>e9(v,d)));const y=tn(u,"renderHTML",h);y&&(m.toDOM=v=>y({node:v,HTMLAttributes:RN(v,d)}));const x=tn(u,"renderText",h);return x&&(m.toText=x),[u.name,m]})),c=Object.fromEntries(s.map(u=>{const d=r.filter(x=>x.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((x,v)=>{const S=tn(v,"extendMarkSchema",h);return{...x,...S?S(u):{}}},{}),m=t9({...p,inclusive:yr(tn(u,"inclusive",h)),excludes:yr(tn(u,"excludes",h)),group:yr(tn(u,"group",h)),spanning:yr(tn(u,"spanning",h)),code:yr(tn(u,"code",h)),attrs:Object.fromEntries(d.map(n9))}),b=yr(tn(u,"parseHTML",h));b&&(m.parseDOM=b.map(x=>e9(x,d)));const y=tn(u,"renderHTML",h);return y&&(m.toDOM=x=>y({mark:x,HTMLAttributes:RN(x,d)})),[u.name,m]}));return new ute({topNode:o,nodes:l,marks:c})}function cGe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function oF(t){return t.sort((n,r)=>{const i=tn(n,"priority")||100,s=tn(r,"priority")||100;return i>s?-1:i<s?1:0})}function jne(t){const e=oF(aF(t)),n=cGe(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 Dne(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
- `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,h)=>{var p;c.isBlock&&u>r&&(l+=s);const m=o?.[c.type.name];if(m)return d&&(l+=m({node:c,pos:u,parent:d,index:h,range:e})),!1;c.isText&&(l+=(p=c?.text)==null?void 0:p.slice(Math.max(r,u)-u,i-u))}),l}function uGe(t,e){const n={from:0,to:t.content.size};return Dne(t,n,e)}function Rne(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function dGe(t,e){const n=Wi(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function One(t,e){const n=KM(typeof e=="string"?e:e.name,t.schema);return n==="node"?dGe(t,e):n==="mark"?Tne(t,e):{}}function hGe(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 fGe(t){const e=hGe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function Lne(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[s];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(s).map(l,-1),d=e.slice(s).map(c),h=e.invert().map(u,-1),p=e.invert().map(d);r.push({oldRange:{from:h,to:p},newRange:{from:u,to:d}})})}),fGe(r)}function lF(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=rF(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var mGe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function BP(t,e){return e.nodes[t]||e.marks[t]||null}function Y1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var pGe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-s))}),n};function lR(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?od(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>s?s.name===h.type.name:!0).find(h=>DN(h.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:h,$to:p})=>{const m=h.pos,b=p.pos;t.doc.nodesBetween(m,b,(y,x)=>{if(!y.isText&&!y.marks.length)return;const v=Math.max(m,x),S=Math.min(b,x+y.nodeSize),N=S-v;o+=N,l.push(...y.marks.map(T=>({mark:T,from:v,to:S})))})}),o===0)return!1;const c=l.filter(h=>s?s.name===h.mark.type.name:!0).filter(h=>DN(h.mark.attrs,n,{strict:!1})).reduce((h,p)=>h+p.to-p.from,0),u=l.filter(h=>s?h.mark.type!==s&&h.mark.type.excludes(s):!0).reduce((h,p)=>h+p.to-p.from,0);return(c>0?c+u:c)>=o}function gGe(t,e,n={}){if(!e)return Hh(t,null,n)||lR(t,null,n);const r=KM(e,t.schema);return r==="node"?Hh(t,e,n):r==="mark"?lR(t,e,n):!1}var bGe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=XM(l=>l.type.name===e)(t.selection);if(!s)return!1;const o=t.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},xGe=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 i9(t,e){const{nodeExtensions:n}=yb(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=yr(tn(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function YM(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(s=>{i!==!1&&(YM(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Fne(t){return t instanceof cn}function yGe(t,e,n){var r;const{selection:i}=e;let s=null;if(Nne(i)&&(s=i.$cursor),s){const l=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,h,p)=>{if(u)return!1;if(d.isInline){const m=!p||p.type.allowsMarkType(n),b=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=m&&b}return!u}),u})}var vGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,c=od(t,r.schema);if(i)if(o){const u=Tne(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;r.doc.nodesBetween(d,h,(p,m)=>{const b=Math.max(m,d),y=Math.min(m+p.nodeSize,h);p.marks.find(v=>v.type===c)?p.marks.forEach(v=>{c===v.type&&n.addMark(b,y,c.create({...v.attrs,...e}))}):n.addMark(b,y,c.create(e))})});return yGe(r,n,c)},wGe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),_Ge=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=Wi(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>x7(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>x7(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},SGe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Xf(t,0,r.content.size),s=cn.create(r,i);e.setSelection(s)}return!0},NGe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},kGe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=wn.atStart(r).from,l=wn.atEnd(r).to,c=Xf(i,o,l),u=Xf(s,o,l),d=wn.create(r,c,u);e.setSelection(d)}return!0},MGe=t=>({state:e,dispatch:n})=>{const r=Wi(t,e.schema);return SHe(r)(e,n)};function a9(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 EGe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:c}=s,u=i.extensionManager.attributes,d=Y1(u,l.node().type.name,l.node().attrs);if(s instanceof cn&&s.node.isBlock)return!l.parentOffset||!zu(o,l.pos)?!1:(r&&(t&&a9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,p=l.depth===0?void 0:rGe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let m=h&&p?[{type:p,attrs:d}]:void 0,b=zu(e.doc,e.mapping.map(l.pos),1,m);if(!m&&!b&&zu(e.doc,e.mapping.map(l.pos),1,p?[{type:p}]:void 0)&&(b=!0,m=p?[{type:p,attrs:d}]:void 0),r){if(b&&(s instanceof wn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,m),p&&!h&&!l.parentOffset&&l.parent.type!==p)){const y=e.mapping.map(l.before()),x=e.doc.resolve(y);l.node(-1).canReplaceWith(x.index(),x.index()+1,p)&&e.setNodeMarkup(e.mapping.map(l.before()),p)}t&&a9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},TGe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=Wi(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 h=c.node(-1);if(h.type!==l)return!1;const p=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let v=At.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=At.from(c.node(R).copy(v));const N=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,T={...Y1(p,c.node().type.name,c.node().attrs),...e},M=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(T))||void 0;v=v.append(At.from(l.createAndFill(null,M)||void 0));const A=c.before(c.depth-(S-1));n.replace(A,c.after(-N),new Bt(v,4-S,0));let k=-1;n.doc.nodesBetween(A,n.doc.content.size,(R,C)=>{if(k>-1)return!1;R.isTextblock&&R.content.size===0&&(k=C+1)}),k>-1&&n.setSelection(wn.near(n.doc.resolve(k))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?h.contentMatchAt(0).defaultType:null,b={...Y1(p,h.type.name,h.attrs),...e},y={...Y1(p,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const x=m?[{type:l,attrs:b},{type:m,attrs:y}]:[{type:l,attrs:b}];if(!zu(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:S}=r,{splittableMarks:N}=s.extensionManager,T=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,x).scrollIntoView(),!T||!i)return!0;const M=T.filter(A=>N.includes(A.type.name));n.ensureMarks(M)}return!0},HP=(t,e)=>{const n=XM(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&&Wh(t.doc,n.pos)&&t.join(n.pos),!0},$P=(t,e)=>{const n=XM(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&&Wh(t.doc,r)&&t.join(r),!0},AGe=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:h,splittableMarks:p}=i.extensionManager,m=Wi(t,o.schema),b=Wi(e,o.schema),{selection:y,storedMarks:x}=o,{$from:v,$to:S}=y,N=v.blockRange(S),T=x||y.$to.parentOffset&&y.$from.marks();if(!N)return!1;const M=XM(A=>i9(A.type.name,h))(y);if(N.depth>=1&&M&&N.depth-M.depth<=1){if(M.node.type===m)return u.liftListItem(b);if(i9(M.node.type.name,h)&&m.validContent(M.node.content)&&l)return c().command(()=>(s.setNodeMarkup(M.pos,m),!0)).command(()=>HP(s,m)).command(()=>$P(s,m)).run()}return!n||!T||!l?c().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>HP(s,m)).command(()=>$P(s,m)).run():c().command(()=>{const A=d().wrapInList(m,r),k=T.filter(R=>p.includes(R.type.name));return s.ensureMarks(k),A?!0:u.clearNodes()}).wrapInList(m,r).command(()=>HP(s,m)).command(()=>$P(s,m)).run()},CGe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=od(t,r.schema);return lR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},PGe=(t,e,n={})=>({state:r,commands:i})=>{const s=Wi(t,r.schema),o=Wi(e,r.schema),l=Hh(r,s,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(s,{...c,...n})},jGe=(t,e={})=>({state:n,commands:r})=>{const i=Wi(t,n.schema);return Hh(n,i,e)?r.lift(i):r.wrapIn(i,e)},DGe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const o=t.tr,l=s.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(s.text){const c=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,c))}else o.delete(s.from,s.to)}return!0}}return!1},RGe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},OGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=od(t,r.schema),{$from:u,empty:d,ranges:h}=l;if(!i)return!0;if(d&&o){let{from:p,to:m}=l;const b=(s=u.marks().find(x=>x.type===c))==null?void 0:s.attrs,y=rF(u,c,b);y&&(p=y.from,m=y.to),n.removeMark(p,m,c)}else h.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},LGe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,o;return typeof t=="number"?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},FGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=KM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=Wi(t,r.schema)),l==="mark"&&(o=od(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;let p,m,b,y;n.selection.empty?r.doc.nodesBetween(d,h,(x,v)=>{s&&s===x.type&&(c=!0,b=Math.max(v,d),y=Math.min(v+x.nodeSize,h),p=v,m=x)}):r.doc.nodesBetween(d,h,(x,v)=>{v<d&&s&&s===x.type&&(c=!0,b=Math.max(v,d),y=Math.min(v+x.nodeSize,h),p=v,m=x),v>=d&&v<=h&&(s&&s===x.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...x.attrs,...e})),o&&x.marks.length&&x.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const N=Math.max(v,d),T=Math.min(v+x.nodeSize,h);n.addMark(N,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(x=>{o===x.type&&i&&n.addMark(b,y,o.create({...x.attrs,...e}))}))}),c},IGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Wi(t,n.schema);return gHe(i,e)(n,r)},zGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Wi(t,n.schema);return bHe(i,e)(n,r)},UGe=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={}}},QM=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},BGe=(t,e)=>{if(nF(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 g1(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:l}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(p=>p.type.spec.code))return!1;let d=!1;const h=pGe(u)+s;return o.forEach(p=>{if(d)return;const m=BGe(h,p.find);if(!m)return;const b=c.state.tr,y=qM({state:c.state,transaction:b}),x={from:r-(m[0].length-s.length),to:i},{commands:v,chain:S,can:N}=new WM({editor:n,state:y});p.handler({state:y,range:x,match:m,commands:v,chain:S,can:N})===null||!b.steps.length||(p.undoable&&b.setMeta(l,{transform:b,from:r,to:i,text:s}),c.dispatch(b),d=!0)}),d}function HGe(t){const{editor:e,rules:n}=t,r=new hi({state:{init(){return null},apply(i,s,o){const l=i.getMeta(r);if(l)return l;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=sF(At.from(d),o.schema);const{from:h}=c,p=h+d.length;g1({editor:e,from:h,to:p,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return g1({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&g1({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?g1({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function $Ge(t){return Object.prototype.toString.call(t).slice(8,-1)}function b1(t){return $Ge(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Ine(t,e){const n={...t};return b1(t)&&b1(e)&&Object.keys(e).forEach(r=>{b1(e[r])&&b1(t[r])?n[r]=Ine(t[r],e[r]):n[r]=e[r]}),n}var cF=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{...yr(tn(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...yr(tn(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Ine(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}},Xh=class zne extends cF{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new zne(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 VGe(t){return typeof t=="number"}var GGe=class{constructor(t){this.find=t.find,this.handler=t.handler}},qGe=(t,e,n)=>{if(nF(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function WGe(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new WM({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,i,(m,b)=>{var y,x,v,S,N;if((x=(y=m.type)==null?void 0:y.spec)!=null&&x.code||!(m.isText||m.isTextblock||m.isInline))return;const T=(N=(S=(v=m.content)==null?void 0:v.size)!=null?S:m.nodeSize)!=null?N:0,M=Math.max(r,b),A=Math.min(i,b+T);if(M>=A)return;const k=m.isText?m.text||"":m.textBetween(M-b,A-b,void 0,"");qGe(k,s.find,o).forEach(C=>{if(C.index===void 0)return;const P=M+C.index+1,U=P+C[0].length,F={from:n.tr.mapping.map(P),to:n.tr.mapping.map(U)},B=s.handler({state:n,range:F,match:C,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});h.push(B)})}),h.every(m=>m!==null)}var x1=null,KGe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function XGe(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:h,to:p,rule:m,pasteEvt:b})=>{const y=d.tr,x=qM({state:d,transaction:y});if(!(!WGe({editor:e,state:x,from:Math.max(h-1,0),to:p.b-1,rule:m,pasteEvent:b,dropEvent:l})||!y.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new hi({view(h){const p=b=>{var y;r=(y=h.dom.parentElement)!=null&&y.contains(b.target)?h.dom.parentElement:null,r&&(x1=e)},m=()=>{x1&&(x1=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(h,p)=>{if(s=r===h.dom.parentElement,l=p,!s){const m=x1;m?.isEditable&&setTimeout(()=>{const b=m.state.selection;b&&m.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(h,p)=>{var m;const b=(m=p.clipboardData)==null?void 0:m.getData("text/html");return o=p,i=!!b?.includes("data-pm-slice"),!1}}},appendTransaction:(h,p,m)=>{const b=h[0],y=b.getMeta("uiEvent")==="paste"&&!i,x=b.getMeta("uiEvent")==="drop"&&!s,v=b.getMeta("applyPasteRules"),S=!!v;if(!y&&!x&&!S)return;if(S){let{text:M}=v;typeof M=="string"?M=M:M=sF(At.from(M),m.schema);const{from:A}=v,k=A+M.length,R=KGe(M);return c({rule:d,state:m,from:A,to:{b:k},pasteEvt:R})}const N=p.doc.content.findDiffStart(m.doc.content),T=p.doc.content.findDiffEnd(m.doc.content);if(!(!VGe(N)||!T||N===T.b))return c({rule:d,state:m,from:N,to:T,pasteEvt:o})}}))}var ZM=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=jne(t),this.schema=lGe(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:BP(e.name,this.schema)},r=tn(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return oF([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:BP(r.name,this.schema)},s=[],o=tn(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&tn(r,"exitable",i)&&(l.ArrowRight=()=>Xh.handleExit({editor:t,mark:r})),o){const p=Object.fromEntries(Object.entries(o()).map(([m,b])=>[m,()=>b({editor:t})]));l={...l,...p}}const c=dVe(l);s.push(c);const u=tn(r,"addInputRules",i);if(r9(r,t.options.enableInputRules)&&u){const p=u();if(p&&p.length){const m=HGe({editor:t,rules:p}),b=Array.isArray(m)?m:[m];s.push(...b)}}const d=tn(r,"addPasteRules",i);if(r9(r,t.options.enablePasteRules)&&d){const p=d();if(p&&p.length){const m=XGe({editor:t,rules:p});s.push(...m)}}const h=tn(r,"addProseMirrorPlugins",i);if(h){const p=h();s.push(...p)}return s})}get attributes(){return Pne(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=yb(this.extensions);return Object.fromEntries(e.filter(n=>!!tn(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:Wi(n.name,this.schema)},s=tn(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const l=(c,u,d,h,p)=>{const m=RN(c,r);return o({node:c,view:u,getPos:d,decorations:h,innerDecorations:p,editor:t,extension:n,HTMLAttributes:m})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=yb(this.extensions);return Object.fromEntries(e.filter(n=>!!tn(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:od(n.name,this.schema)},s=tn(n,"addMarkView",i);if(!s)return[];const o=(l,c,u)=>{const d=RN(l,r);return s()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:h=>{uqe(l,t,h)}})};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:BP(e.name,this.schema)};e.type==="mark"&&((n=yr(tn(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=tn(e,"onBeforeCreate",r),s=tn(e,"onCreate",r),o=tn(e,"onUpdate",r),l=tn(e,"onSelectionUpdate",r),c=tn(e,"onTransaction",r),u=tn(e,"onFocus",r),d=tn(e,"onBlur",r),h=tn(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),h&&this.editor.on("destroy",h)})}};ZM.resolve=jne;ZM.sort=oF;ZM.flatten=aF;var YGe={};tF(YGe,{ClipboardTextSerializer:()=>Bne,Commands:()=>Hne,Delete:()=>$ne,Drop:()=>Vne,Editable:()=>Gne,FocusEvents:()=>Wne,Keymap:()=>Kne,Paste:()=>Xne,Tabindex:()=>Yne,TextDirection:()=>Qne,focusEventsPluginKey:()=>qne});var Or=class Une extends cF{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Une(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Bne=Or.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new hi({key:new ua("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(d=>d.$from.pos)),l=Math.max(...s.map(d=>d.$to.pos)),c=Rne(n);return Dne(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Hne=Or.create({name:"commands",addCommands(){return{..._ne}}}),$ne=Or.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var o,l,c,u;if((u=(c=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=Ane(t.before,[t,...e]);Lne(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,(b,y)=>{const x=y+b.nodeSize-2,v=m.oldRange.from<=y&&x<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:y,to:x,newFrom:d.mapping.map(y),newTo:d.mapping.map(x),deletedRange:m.oldRange,newRange:m.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const p=d.mapping;d.steps.forEach((m,b)=>{var y,x;if(m instanceof zl){const v=p.slice(b).map(m.from,-1),S=p.slice(b).map(m.to),N=p.invert().map(v,-1),T=p.invert().map(S),M=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(k=>k.eq(m.mark)),A=(x=d.doc.nodeAt(S))==null?void 0:x.marks.some(k=>k.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:N,to:T},newRange:{from:v,to:S},partial:!!(A||M),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),Vne=Or.create({name:"drop",addProseMirrorPlugins(){return[new hi({key:new ua("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Gne=Or.create({name:"editable",addProseMirrorPlugins(){return[new hi({key:new ua("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qne=new ua("focusEvents"),Wne=Or.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new hi({key:qne,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}}}})]}}),Kne=Or.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:h}=c,{pos:p,parent:m}=h,b=h.parent.isTextblock&&p>0?l.doc.resolve(p-1):h,y=b.parent.type.spec.isolating,x=h.pos-h.parentOffset,v=y&&b.parent.childCount===1?x===h.pos:On.atStart(u).from===p;return!d||!m.type.isTextblock||m.textContent.length||!v||v&&h.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return iF()||Ene()?s:i},addProseMirrorPlugins(){return[new hi({key:new ua("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,c=On.atStart(e.doc).from,u=On.atEnd(e.doc).to;if(s||!(o===c&&l===u)||!YM(n.doc))return;const p=n.tr,m=qM({state:n,transaction:p}),{commands:b}=new WM({editor:this.editor,state:m});if(b.clearNodes(),!!p.steps.length)return p}})]}}),Xne=Or.create({name:"paste",addProseMirrorPlugins(){return[new hi({key:new ua("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Yne=Or.create({name:"tabindex",addProseMirrorPlugins(){return[new hi({key:new ua("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Qne=Or.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=yb(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 hi({key:new ua("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),QGe=class xg{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 xg(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 xg(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 xg(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,o=this.pos+r+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const c=new xg(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new xg(l,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(s[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(c=>n[c]===o.node.attrs[c])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},ZGe=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function JGe(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 eqe=class extends UGe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=kne(e,this.options.autofocus);this.editorState=Tg.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=JGe(ZGe,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=Cne(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const s=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(s))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[Gne,Bne.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Hne,Wne,Kne,Yne,Vne,Xne,$ne,Qne.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 ZM(r,this)}createCommandManager(){this.commandManager=new WM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=oR(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=oR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new vne(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=o?.getMeta("focus"),c=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),c&&this.emit("blur",{editor:this,event:c.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return One(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return gGe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return sF(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return uGe(this.state.doc,{blockSeparator:e,textSerializers:{...Rne(this.schema),...n}})}get isEmpty(){return YM(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 QGe(e,this)}get $doc(){return this.$pos(0)}};function vb(t){return new QM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=yr(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),u=n.from+l.indexOf(o),d=u+o.length;if(lF(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>u).length)return null;d<n.to&&s.delete(d,n.to),u>n.from&&s.delete(n.from+c,u);const p=n.from+c+o.length;s.addMark(n.from+c,p,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function Zne(t){return new QM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=yr(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=o+u;d>l?d=l:l=d+r[1].length;const h=r[0][r[0].length-1];s.insertText(h,o+r[0].length-1),s.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;s.insert(u,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function cR(t){return new QM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=yr(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function wb(t){return new QM({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=yr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&z4(c,t.type,s);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:h,storedMarks:p}=e,{splittableMarks:m}=t.editor.extensionManager,b=p||h.$to.parentOffset&&h.$from.marks();if(b){const y=b.filter(x=>m.includes(x.type.name));o.ensureMarks(y)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(h,s).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Wh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var tqe=t=>"touches"in t,nqe=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const o=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(o,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,s;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(s=t.options)!=null&&s.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,tqe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,s,o;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function rqe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof cn){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var iqe={};tF(iqe,{createAtomBlockMarkdownSpec:()=>aqe,createBlockMarkdownSpec:()=>sqe,createInlineMarkdownSpec:()=>cqe,parseAttributes:()=>uF,parseIndentedBlocks:()=>uR,renderNestedMarkdownContent:()=>hF,serializeAttributes:()=>dF});function uF(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var h;const p=parseInt(((h=d.match(/__QUOTED_(\d+)__/))==null?void 0:h[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 dF(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 aqe(t){const{nodeName:e,name:n,parseAttributes:r=uF,serializeAttributes:i=dF,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const h={};return l.forEach(p=>{p in d&&(h[p]=d[p])}),h};return{parseMarkdown:(d,h)=>{const p={...s,...d.attributes};return h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(d){var h;const p=new RegExp(`^:::${c}(?:\\s|$)`,"m"),m=(h=d.match(p))==null?void 0:h.index;return m!==void 0?m:-1},tokenize(d,h,p){const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=d.match(m);if(!b)return;const y=b[1]||"",x=r(y);if(!o.find(S=>!(S in x)))return{type:e,raw:b[0],attributes:x}}},renderMarkdown:d=>{const h=u(d.attrs||{}),p=i(h),m=p?` {${p}}`:"";return`:::${c}${m} :::`}}}function sqe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=uF,serializeAttributes:s=dF,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=h=>{if(!c)return h;const p={};return c.forEach(m=>{m in h&&(p[m]=h[m])}),p};return{parseMarkdown:(h,p)=>{let m;if(r){const y=r(h);m=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?m=p.parseChildren(h.tokens||[]):m=p.parseInline(h.tokens||[]);const b={...o,...h.attributes};return p.createNode(e,b,m)},markdownTokenizer:{name:e,level:"block",start(h){var p;const m=new RegExp(`^:::${u}`,"m"),b=(p=h.match(m))==null?void 0:p.index;return b!==void 0?b:-1},tokenize(h,p,m){var b;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=h.match(y);if(!x)return;const[v,S=""]=x,N=i(S);let T=1;const M=v.length;let A="";const k=/^:::([\w-]*)(\s.*)?/gm,R=h.slice(M);for(k.lastIndex=0;;){const C=k.exec(R);if(C===null)break;const P=C.index,U=C[1];if(!((b=C[2])!=null&&b.endsWith(":::"))){if(U)T+=1;else if(T-=1,T===0){const F=R.slice(0,P);A=F.trim();const B=h.slice(0,M+P+C[0].length);let D=[];if(A)if(l==="block")for(D=m.blockTokens(F),D.forEach($=>{$.text&&(!$.tokens||$.tokens.length===0)&&($.tokens=m.inlineTokens($.text))});D.length>0;){const $=D[D.length-1];if($.type==="paragraph"&&(!$.text||$.text.trim()===""))D.pop();else break}else D=m.inlineTokens(A);return{type:e,raw:B,attributes:N,content:A,tokens:D}}}}}},renderMarkdown:(h,p)=>{const m=d(h.attrs||{}),b=s(m),y=b?` {${b}}`:"",x=p.renderChildren(h.content||[],`
- `);return`:::${u}${y}
- ${x}
- :::`}}}function oqe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,o]=r;e[i]=s||o,r=n.exec(t)}return e}function lqe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function cqe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=oqe,serializeAttributes:s=lqe,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=p=>{if(!c)return p;const m={};return c.forEach(b=>{b in p&&(m[b]=p[b])}),m},h=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,m)=>{const b={...o,...p.attributes};if(l)return m.createNode(e,b);const y=r?r(p):p.content||"";return y?m.createNode(e,b,[m.createTextNode(y)]):m.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(p){const m=l?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),b=p.match(m),y=b?.index;return y!==void 0?y:-1},tokenize(p,m,b){const y=l?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),x=p.match(y);if(!x)return;let v="",S="";if(l){const[,T]=x;S=T}else{const[,T,M]=x;S=T,v=M||""}const N=i(S.trim());return{type:e,raw:x[0],content:v.trim(),attributes:N}}},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 b=d(p.attrs||{}),y=s(b),x=y?` ${y}`:"";return l?`[${u}${x}]`:`[${u}${x}]${m}[/${u}]`}}}function uR(t,e,n){var r,i,s,o;const l=t.split(`
- `),c=[];let u="",d=0;const h=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}
- `;continue}else return}const b=e.extractItemData(m),{indentLevel:y,mainContent:x}=b;u=`${u}${p}
- `;const v=[x];for(d+=1;d<l.length;){const M=l[d];if(M.trim()===""){const k=l.slice(d+1).findIndex(P=>P.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)>y){v.push(M),u=`${u}${M}
- `,d+=1;continue}else break}if((((o=(s=M.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>y)v.push(M),u=`${u}${M}
- `,d+=1;else break}let S;const N=v.slice(1);if(N.length>0){const M=N.map(A=>A.slice(y+h)).join(`
- `);M.trim()&&(e.customNestedParser?S=e.customNestedParser(M):S=n.blockTokens(M))}const T=e.createToken(b,S);c.push(T)}if(c.length!==0)return{items:c,raw:u}}function hF(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...o]=t.content,l=e.renderChildren([s]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const h=d.split(`
- `).map(p=>p?e.indent(p):"").join(`
- `);c.push(h)}}),c.join(`
- `)}function uqe(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((l,c)=>{const u=s.mapping.map(c),d=s.mapping.map(c)+l.nodeSize;let h=null;if(l.marks.forEach(m=>{if(m!==o)return!1;h=m}),!h)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==h.attrs[m]&&(p=!0)}),p){const m=t.type.create({...t.attrs,...n});s.removeMark(u,d,t.type),s.addMark(u,d,m)}}),s.docChanged&&e.view.dispatch(s)}var Qs=class Jne extends cF{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Jne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Om(t){return new GGe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=yr(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),h=n.from+c.indexOf(l),p=h+l.length;if(lF(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(x=>x===t.type&&x!==b.mark.type)).filter(b=>b.to>h).length)return null;p<n.to&&o.delete(p,n.to),h>n.from&&o.delete(n.from+d,h),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}var VP,s9;function dqe(){return s9||(s9=1,VP=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var o=s[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),VP}var hqe=dqe();const fqe=gl(hqe);var mqe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},pqe=({contentComponent:t})=>{const e=PR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(e)})};function gqe(){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 bqe=class extends ri.Component{constructor(t){var e;super(t),this.editorContentRef=ri.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=gqe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:mqe(e,this.editorContentRef),...n}),t?.contentComponent&&a.jsx(pqe,{contentComponent:t.contentComponent})]})}},xqe=_.forwardRef((t,e)=>{const n=ri.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ri.createElement(bqe,{key:n,innerRef:e,...t})}),yqe=ri.memo(xqe),vqe=typeof window<"u"?_.useLayoutEffect:_.useEffect,wqe=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 _qe(t){var e;const[n]=_.useState(()=>new wqe(t.editor)),r=sY.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:fqe);return vqe(()=>n.watch(t.editor),[t.editor,n]),_.useDebugValue(r),r}var Sqe=!1,dR=typeof window>"u",Nqe=dR||!!(typeof window<"u"&&window.next),kqe=class ere{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?dR||Nqe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new eqe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,s)=>{var o;return i===((o=n.extensions)==null?void 0:o[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?ere.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 Mqe(t={},e=[]){const n=_.useRef(t);n.current=t;const[r]=_.useState(()=>new kqe(n)),i=PR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return _.useDebugValue(i),_.useEffect(r.onRender(e)),_qe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var Eqe=_.createContext({editor:null});Eqe.Consumer;var Tqe=_.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Aqe=()=>_.useContext(Tqe);ri.forwardRef((t,e)=>{const{onDragStart:n}=Aqe(),r=t.as||"div";return a.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ri.createContext({markViewContentRef:()=>{}});var ON=(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]},Cqe=/^\s*>\s$/,Pqe=Qs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return ON("blockquote",{...Si(this.options.HTMLAttributes,t),children:ON("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(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[wb({find:Cqe,type:this.type})]}}),jqe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Dqe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Rqe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Oqe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Lqe=Xh.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 ON("strong",{...Si(this.options.HTMLAttributes,t),children:ON("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[vb({find:jqe,type:this.type}),vb({find:Rqe,type:this.type})]},addPasteRules(){return[Om({find:Dqe,type:this.type}),Om({find:Oqe,type:this.type})]}}),Fqe=/(^|[^`])`([^`]+)`(?!`)$/,Iqe=/(^|[^`])`([^`]+)`(?!`)/g,zqe=Xh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Si(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[vb({find:Fqe,type:this.type})]},addPasteRules(){return[Om({find:Iqe,type:this.type})]}}),GP=4,Uqe=/^```([a-z]+)?[\s\n]$/,Bqe=/^~~~([a-z]+)?[\s\n]$/,Hqe=Qs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:GP,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Si(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):r=`\`\`\`${i}
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:GP,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,m=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(b=>l+b).join(`
- `);return c.replaceWith(u,d,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:GP,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=s,d=s.start(),h=s.end(),m=r.doc.textBetween(d,h,`
- `,`
- `).split(`
- `);let b=0,y=0;const x=u-d;for(let A=0;A<m.length;A+=1){if(y+m[A].length>=x){b=A;break}y+=m[A].length+1}const S=((c=m[b].match(/^ */))==null?void 0:c[0])||"",N=Math.min(S.length,n);if(N===0)return!0;let T=d;for(let A=0;A<b;A+=1)T+=m[A].length+1;return l.delete(T,T+N),u-T<=N&&l.setSelection(wn.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,p=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(m=>{var b;const y=((b=m.match(/^ */))==null?void 0:b[0])||"",x=Math.min(y.length,n);return m.slice(x)}).join(`
- `);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 s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
- `);return!s||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(On.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[cR({find:Uqe,type:this.type,getAttributes:t=>({language:t[1]})}),cR({find:Bqe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new hi({key:new ua("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!n||!s)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
- `));return o.replaceSelectionWith(this.type.create({language:s},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(wn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),$qe=Qs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),Vqe=Qs.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",Si(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const h=c.filter(p=>l.includes(p.type.name));u.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Gqe=Qs.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]}`,Si(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=>cR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),qqe=Qs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Si(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!rqe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Fne(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(wn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(cn.create(o.doc,c.pos)):o.setSelection(wn.create(o.doc,c.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,h=d?.create();h&&(o.insert(u,h),o.setSelection(wn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Zne({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Wqe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Kqe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Xqe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Yqe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Qqe=Xh.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",Si(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[vb({find:Wqe,type:this.type}),vb({find:Xqe,type:this.type})]},addPasteRules(){return[Om({find:Kqe,type:this.type}),Om({find:Yqe,type:this.type})]}});const Zqe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Jqe="ελ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",hR="numeric",fR="ascii",mR="alpha",L0="asciinumeric",y0="alphanumeric",pR="domain",tre="emoji",e7e="scheme",t7e="slashscheme",qP="whitespace";function n7e(t,e){return t in e||(e[t]=[]),e[t]}function Yf(t,e,n){e[hR]&&(e[L0]=!0,e[y0]=!0),e[fR]&&(e[L0]=!0,e[mR]=!0),e[L0]&&(e[y0]=!0),e[mR]&&(e[y0]=!0),e[y0]&&(e[pR]=!0),e[tre]&&(e[pR]=!0);for(const r in e){const i=n7e(r,n);i.indexOf(t)<0&&i.push(t)}}function r7e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Hs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Hs.groups={};Hs.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Hs.groups;let i;return e&&e.j?i=e:(i=new Hs(e),n&&r&&Yf(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Hs.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new Hs,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Hs,s){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(r7e(o.t,r),n);Yf(s,c,r)}else n&&Yf(s,n,r);o.t=s}return i.j[t]=o,o}};const Pn=(t,e,n,r,i)=>t.ta(e,n,r,i),pi=(t,e,n,r,i)=>t.tr(e,n,r,i),o9=(t,e,n,r,i)=>t.ts(e,n,r,i),Pt=(t,e,n,r,i)=>t.tt(e,n,r,i),gu="WORD",gR="UWORD",nre="ASCIINUMERICAL",rre="ALPHANUMERICAL",Oy="LOCALHOST",bR="TLD",xR="UTLD",Q1="SCHEME",yg="SLASH_SCHEME",fF="NUM",yR="WS",mF="NL",F0="OPENBRACE",I0="CLOSEBRACE",LN="OPENBRACKET",FN="CLOSEBRACKET",IN="OPENPAREN",zN="CLOSEPAREN",UN="OPENANGLEBRACKET",BN="CLOSEANGLEBRACKET",HN="FULLWIDTHLEFTPAREN",$N="FULLWIDTHRIGHTPAREN",VN="LEFTCORNERBRACKET",GN="RIGHTCORNERBRACKET",qN="LEFTWHITECORNERBRACKET",WN="RIGHTWHITECORNERBRACKET",KN="FULLWIDTHLESSTHAN",XN="FULLWIDTHGREATERTHAN",YN="AMPERSAND",QN="APOSTROPHE",ZN="ASTERISK",eh="AT",JN="BACKSLASH",ek="BACKTICK",tk="CARET",oh="COLON",pF="COMMA",nk="DOLLAR",rc="DOT",rk="EQUALS",gF="EXCLAMATION",Ko="HYPHEN",z0="PERCENT",ik="PIPE",ak="PLUS",sk="POUND",U0="QUERY",bF="QUOTE",ire="FULLWIDTHMIDDLEDOT",xF="SEMI",ic="SLASH",B0="TILDE",ok="UNDERSCORE",are="EMOJI",lk="SYM";var sre=Object.freeze({__proto__:null,ALPHANUMERICAL:rre,AMPERSAND:YN,APOSTROPHE:QN,ASCIINUMERICAL:nre,ASTERISK:ZN,AT:eh,BACKSLASH:JN,BACKTICK:ek,CARET:tk,CLOSEANGLEBRACKET:BN,CLOSEBRACE:I0,CLOSEBRACKET:FN,CLOSEPAREN:zN,COLON:oh,COMMA:pF,DOLLAR:nk,DOT:rc,EMOJI:are,EQUALS:rk,EXCLAMATION:gF,FULLWIDTHGREATERTHAN:XN,FULLWIDTHLEFTPAREN:HN,FULLWIDTHLESSTHAN:KN,FULLWIDTHMIDDLEDOT:ire,FULLWIDTHRIGHTPAREN:$N,HYPHEN:Ko,LEFTCORNERBRACKET:VN,LEFTWHITECORNERBRACKET:qN,LOCALHOST:Oy,NL:mF,NUM:fF,OPENANGLEBRACKET:UN,OPENBRACE:F0,OPENBRACKET:LN,OPENPAREN:IN,PERCENT:z0,PIPE:ik,PLUS:ak,POUND:sk,QUERY:U0,QUOTE:bF,RIGHTCORNERBRACKET:GN,RIGHTWHITECORNERBRACKET:WN,SCHEME:Q1,SEMI:xF,SLASH:ic,SLASH_SCHEME:yg,SYM:lk,TILDE:B0,TLD:bR,UNDERSCORE:ok,UTLD:xR,UWORD:gR,WORD:gu,WS:yR});const du=/[a-z]/,s0=new RegExp("\\p{L}","u"),WP=new RegExp("\\p{Emoji}","u"),hu=/\d/,KP=/\s/,l9="\r",XP=`
- `,i7e="️",a7e="",YP="";let y1=null,v1=null;function s7e(t=[]){const e={};Hs.groups=e;const n=new Hs;y1==null&&(y1=c9(Zqe)),v1==null&&(v1=c9(Jqe)),Pt(n,"'",QN),Pt(n,"{",F0),Pt(n,"}",I0),Pt(n,"[",LN),Pt(n,"]",FN),Pt(n,"(",IN),Pt(n,")",zN),Pt(n,"<",UN),Pt(n,">",BN),Pt(n,"(",HN),Pt(n,")",$N),Pt(n,"「",VN),Pt(n,"」",GN),Pt(n,"『",qN),Pt(n,"』",WN),Pt(n,"<",KN),Pt(n,">",XN),Pt(n,"&",YN),Pt(n,"*",ZN),Pt(n,"@",eh),Pt(n,"`",ek),Pt(n,"^",tk),Pt(n,":",oh),Pt(n,",",pF),Pt(n,"$",nk),Pt(n,".",rc),Pt(n,"=",rk),Pt(n,"!",gF),Pt(n,"-",Ko),Pt(n,"%",z0),Pt(n,"|",ik),Pt(n,"+",ak),Pt(n,"#",sk),Pt(n,"?",U0),Pt(n,'"',bF),Pt(n,"/",ic),Pt(n,";",xF),Pt(n,"~",B0),Pt(n,"_",ok),Pt(n,"\\",JN),Pt(n,"・",ire);const r=pi(n,hu,fF,{[hR]:!0});pi(r,hu,r);const i=pi(r,du,nre,{[L0]:!0}),s=pi(r,s0,rre,{[y0]:!0}),o=pi(n,du,gu,{[fR]:!0});pi(o,hu,i),pi(o,du,o),pi(i,hu,i),pi(i,du,i);const l=pi(n,s0,gR,{[mR]:!0});pi(l,du),pi(l,hu,s),pi(l,s0,l),pi(s,hu,s),pi(s,du),pi(s,s0,s);const c=Pt(n,XP,mF,{[qP]:!0}),u=Pt(n,l9,yR,{[qP]:!0}),d=pi(n,KP,yR,{[qP]:!0});Pt(n,YP,d),Pt(u,XP,c),Pt(u,YP,d),pi(u,KP,d),Pt(d,l9),Pt(d,XP),pi(d,KP,d),Pt(d,YP,d);const h=pi(n,WP,are,{[tre]:!0});Pt(h,"#"),pi(h,WP,h),Pt(h,i7e,h);const p=Pt(h,a7e);Pt(p,"#"),pi(p,WP,h);const m=[[du,o],[hu,i]],b=[[du,null],[s0,l],[hu,s]];for(let y=0;y<y1.length;y++)qd(n,y1[y],bR,gu,m);for(let y=0;y<v1.length;y++)qd(n,v1[y],xR,gR,b);Yf(bR,{tld:!0,ascii:!0},e),Yf(xR,{utld:!0,alpha:!0},e),qd(n,"file",Q1,gu,m),qd(n,"mailto",Q1,gu,m),qd(n,"http",yg,gu,m),qd(n,"https",yg,gu,m),qd(n,"ftp",yg,gu,m),qd(n,"ftps",yg,gu,m),Yf(Q1,{scheme:!0,ascii:!0},e),Yf(yg,{slashscheme:!0,ascii:!0},e),t=t.sort((y,x)=>y[0]>x[0]?1:-1);for(let y=0;y<t.length;y++){const x=t[y][0],S=t[y][1]?{[e7e]:!0}:{[t7e]:!0};x.indexOf("-")>=0?S[pR]=!0:du.test(x)?hu.test(x)?S[L0]=!0:S[fR]=!0:S[hR]=!0,o9(n,x,x,S)}return o9(n,"localhost",Oy,{ascii:!0}),n.jd=new Hs(lk),{start:n,tokens:Object.assign({groups:e},sre)}}function ore(t,e){const n=o7e(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,h=-1,p=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(h=0,p=0,d=l):h>=0&&(h+=n[o].length,p++),u+=n[o].length,s+=n[o].length,o++;s-=h,o-=p,u-=h,i.push({t:d.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function o7e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function qd(t,e,n,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?s=t.j[c]:(s=new Hs(r),s.jr=i.slice(),t.j[c]=s),t=s}return s=new Hs(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function c9(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const Ly={defaultProtocol:"http",events:null,format:u9,formatHref:u9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function yF(t,e=null){let n=Object.assign({},Ly);t&&(n=Object.assign(n,t instanceof yF?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}yF.prototype={o:Ly,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]:Ly[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 u9(t){return t}function lre(t,e){this.t="token",this.v=t,this.tk=e}lre.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=Ly.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),c&&(o.target=c),u&&(o.rel=u),d&&Object.assign(o,d),{tagName:i,attributes:o,content:s,eventListeners:h}}};function JM(t,e){class n extends lre{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const d9=JM("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),h9=JM("text"),l7e=JM("nl"),w1=JM("url",{isLink:!0,toHref(t=Ly.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Oy&&t[1].t===oh}}),Go=t=>new Hs(t);function c7e({groups:t}){const e=t.domain.concat([YN,ZN,eh,JN,ek,tk,nk,rk,Ko,fF,z0,ik,ak,sk,ic,lk,B0,ok]),n=[QN,oh,pF,rc,gF,z0,U0,bF,xF,UN,BN,F0,I0,FN,LN,IN,zN,HN,$N,VN,GN,qN,WN,KN,XN],r=[YN,QN,ZN,JN,ek,tk,nk,rk,Ko,F0,I0,z0,ik,ak,sk,U0,ic,lk,B0,ok],i=Go(),s=Pt(i,B0);Pn(s,r,s),Pn(s,t.domain,s);const o=Go(),l=Go(),c=Go();Pn(i,t.domain,o),Pn(i,t.scheme,l),Pn(i,t.slashscheme,c),Pn(o,r,s),Pn(o,t.domain,o);const u=Pt(o,eh);Pt(s,eh,u),Pt(l,eh,u),Pt(c,eh,u);const d=Pt(s,rc);Pn(d,r,s),Pn(d,t.domain,s);const h=Go();Pn(u,t.domain,h),Pn(h,t.domain,h);const p=Pt(h,rc);Pn(p,t.domain,h);const m=Go(d9);Pn(p,t.tld,m),Pn(p,t.utld,m),Pt(u,Oy,m);const b=Pt(h,Ko);Pt(b,Ko,b),Pn(b,t.domain,h),Pn(m,t.domain,h),Pt(m,rc,p),Pt(m,Ko,b);const y=Pt(m,oh);Pn(y,t.numeric,d9);const x=Pt(o,Ko),v=Pt(o,rc);Pt(x,Ko,x),Pn(x,t.domain,o),Pn(v,r,s),Pn(v,t.domain,o);const S=Go(w1);Pn(v,t.tld,S),Pn(v,t.utld,S),Pn(S,t.domain,o),Pn(S,r,s),Pt(S,rc,v),Pt(S,Ko,x),Pt(S,eh,u);const N=Pt(S,oh),T=Go(w1);Pn(N,t.numeric,T);const M=Go(w1),A=Go();Pn(M,e,M),Pn(M,n,A),Pn(A,e,M),Pn(A,n,A),Pt(S,ic,M),Pt(T,ic,M);const k=Pt(l,oh),R=Pt(c,oh),C=Pt(R,ic),P=Pt(C,ic);Pn(l,t.domain,o),Pt(l,rc,v),Pt(l,Ko,x),Pn(c,t.domain,o),Pt(c,rc,v),Pt(c,Ko,x),Pn(k,t.domain,M),Pt(k,ic,M),Pt(k,U0,M),Pn(P,t.domain,M),Pn(P,e,M),Pt(P,ic,M);const U=[[F0,I0],[LN,FN],[IN,zN],[UN,BN],[HN,$N],[VN,GN],[qN,WN],[KN,XN]];for(let F=0;F<U.length;F++){const[B,D]=U[F],$=Pt(M,B);Pt(A,B,$),Pt($,D,M);const G=Go(w1);Pn($,e,G);const I=Go();Pn($,n),Pn(G,e,G),Pn(G,n,I),Pn(I,e,G),Pn(I,n,I),Pt(G,D,M),Pt(I,D,M)}return Pt(i,Oy,S),Pt(i,mF,l7e),{start:i,tokens:sre}}function u7e(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,h=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,h=l):p>=0&&p++,i++,d++;if(p<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(QP(h9,e,o)),o=[]),i-=p,d-=p;const m=h.t,b=n.slice(i-d,i);s.push(QP(m,e,b))}}return o.length>0&&s.push(QP(h9,e,o)),s}function QP(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const d7e=typeof console<"u"&&console&&console.warn||(()=>{}),h7e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Xr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function f7e(){return Hs.groups={},Xr.scanner=null,Xr.parser=null,Xr.tokenQueue=[],Xr.pluginQueue=[],Xr.customSchemes=[],Xr.initialized=!1,Xr}function f9(t,e=!1){if(Xr.initialized&&d7e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${h7e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);Xr.customSchemes.push([t,e])}function m7e(){Xr.scanner=s7e(Xr.customSchemes);for(let t=0;t<Xr.tokenQueue.length;t++)Xr.tokenQueue[t][1]({scanner:Xr.scanner});Xr.parser=c7e(Xr.scanner.tokens);for(let t=0;t<Xr.pluginQueue.length;t++)Xr.pluginQueue[t][1]({scanner:Xr.scanner,parser:Xr.parser});return Xr.initialized=!0,Xr}function vF(t){return Xr.initialized||m7e(),u7e(Xr.parser.start,t,ore(Xr.scanner.start,t))}vF.scan=ore;function cre(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 yF(n),i=vF(t),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var wF="[\0- -\u2029 ]",p7e=new RegExp(wF),g7e=new RegExp(`${wF}$`),b7e=new RegExp(wF,"g");function x7e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function y7e(t){return new hi({key:new ua("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),s=e.some(u=>u.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=Ane(n.doc,[...e]);if(Lne(l).forEach(({newRange:u})=>{const d=iGe(r.doc,u,m=>m.isTextblock);let h,p;if(d.length>1)h=d[0],p=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(u.from,u.to," "," ");if(!g7e.test(m))return;h=d[0],p=r.doc.textBetween(h.pos,u.to,void 0," ")}if(h&&p){const m=p.split(p7e).filter(Boolean);if(m.length<=0)return!1;const b=m[m.length-1],y=h.pos+p.lastIndexOf(b);if(!b)return!1;const x=vF(b).map(v=>v.toObject(t.defaultProtocol));if(!x7e(x))return!1;x.filter(v=>v.isLink).map(v=>({...v,from:y+v.start+1,to:y+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=>{lF(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 v7e(t){return new hi({key:new ua("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const h=[];for(;d.nodeName!=="DIV";)h.push(d),d=d.parentNode;o=h.find(p=>p.nodeName==="A")}if(!o)return!1;const l=One(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(s=o?.target)!=null?s:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function w7e(t){return new hi({key:new ua("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=cre(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 Ef(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(b7e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var ure=Xh.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"){f9(t);return}f9(t.scheme,t.optionalSlashes)})},onDestroy(){f7e()},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)=>!!Ef(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=>!!Ef(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=>!!Ef(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Si(this.options.HTMLAttributes,t),0]:["a",Si(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=>!!Ef(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=>!!Ef(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[Om({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=cre(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!Ef(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(y7e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ef(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(v7e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(w7e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),_7e=ure,S7e=Object.defineProperty,N7e=(t,e)=>{for(var n in e)S7e(t,n,{get:e[n],enumerable:!0})},k7e="listItem",m9="textStyle",p9=/^\s*([-+*])\s$/,dre=Qs.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",Si(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(k7e,this.editor.getAttributes(m9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=wb({find:p9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=wb({find:p9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(m9),editor:this.editor})),[t]}}),hre=Qs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Si(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)=>hF(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)}}}),M7e={};N7e(M7e,{findListItemPos:()=>Mv,getNextListDepth:()=>_F,handleBackspace:()=>vR,handleDelete:()=>wR,hasListBefore:()=>fre,hasListItemAfter:()=>E7e,hasListItemBefore:()=>mre,listItemHasSubList:()=>pre,nextListIsDeeper:()=>gre,nextListIsHigher:()=>bre});var Mv=(t,e)=>{const{$from:n}=e.selection,r=Wi(t,e.schema);let i=null,s=n.depth,o=n.pos,l=null;for(;s>0&&l===null;)i=n.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},_F=(t,e)=>{const n=Mv(t,e);if(!n)return!1;const[,r]=mGe(e,t,n.$pos.pos+4);return r},fre=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},mre=(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)},pre=(t,e,n)=>{if(!n)return!1;const r=Wi(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},vR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Hh(t.state,e)&&fre(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 h=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},h.end()).joinForward().run()}if(!Hh(t.state,e)||!xGe(t.state))return!1;const r=Mv(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=pre(e,t.state,s);return mre(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},gre=(t,e)=>{const n=_F(t,e),r=Mv(t,e);return!r||!n?!1:n>r.depth},bre=(t,e)=>{const n=_F(t,e),r=Mv(t,e);return!r||!n?!1:n<r.depth},wR=(t,e)=>{if(!Hh(t.state,e)||!bGe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:gre(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():bre(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},E7e=(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)},xre=Or.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&&wR(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&&wR(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&&vR(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&&vR(t,n,r)&&(e=!0)}),e}}}}),g9=/^(\s*)(\d+)\.\s+(.*)$/,T7e=/^\s/;function A7e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(g9);if(!s)break;const[,o,l,c]=s,u=o.length;let d=c,h=n+1;const p=[i];for(;h<t.length;){const m=t[h];if(m.match(g9))break;if(m.trim()==="")p.push(m),d+=`
- `,h+=1;else if(m.match(T7e))p.push(m),d+=`
- ${m.slice(u+2)}`,h+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:p.join(`
- `)}),r=h,n=h}return[e,r]}function yre(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const o=t[s];if(o.indent===e){const l=o.content.split(`
- `),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(`
- `).trim();if(d){const m=n.blockTokens(d);u.push(...m)}let h=s+1;const p=[];for(;h<t.length&&t[h].indent>e;)p.push(t[h]),h+=1;if(p.length>0){const m=Math.min(...p.map(y=>y.indent)),b=yre(p,m,n);u.push({type:"list",ordered:!0,start:p[0].number,items:b,raw:p.map(y=>y.raw).join(`
- `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),s=h}else s+=1}return i}function C7e(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var P7e="listItem",b9="textStyle",x9=/^(\d+)\.\s$/,vre=Qs.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",Si(this.options.HTMLAttributes,n),0]:["ol",Si(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?C7e(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[s,o]=A7e(i);if(s.length===0)return;const l=yre(s,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(P7e,this.editor.getAttributes(b9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=wb({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=wb({find:x9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(b9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),j7e=/^\s*(\[([( |x])?\])\s$/,D7e=Qs.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",Si(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 hF(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var h,p;l.ariaLabel=((p=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:p.call(h,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:h}=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 b=p.doc.nodeAt(m);return p.setNodeMarkup(m,void 0,{...b?.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,h])=>{i.setAttribute(d,h)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,c),Object.entries(e).forEach(([d,h])=>{i.setAttribute(d,h)}),{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[wb({find:j7e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),R7e=Qs.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",Si(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=s=>{const o=uR(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(s)},i=uR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Or.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(dre.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(hre.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(xre.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(vre.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(D7e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(R7e.configure(this.options.taskList)),t}});var O7e=Qs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Si(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()}}}),L7e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,F7e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,I7e=Xh.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",Si(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[vb({find:L7e,type:this.type})]},addPasteRules(){return[Om({find:F7e,type:this.type})]}}),z7e=Qs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),wre=Xh.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",Si(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),U7e=wre;function B7e(t={}){return new hi({view(e){return new H7e(e,t)}})}class H7e{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(n){let h=e.nodeBefore,p=e.nodeAfter;if(h||p){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let b=m.getBoundingClientRect(),y=h?b.bottom:b.top;h&&p&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:b.left,right:b.right,top:y-x,bottom:y+x}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:h.left-p,right:h.left+p,top:h.top,bottom:h.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 h=c.getBoundingClientRect(),p=h.width/c.offsetWidth,m=h.height/c.offsetHeight;u=h.left-c.scrollLeft*p,d=h.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,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=wte(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 xi extends On{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return xi.valid(r)?new xi(r):On.near(r)}content(){return Bt.empty}eq(e){return e instanceof xi&&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 xi(e.resolve(n.pos))}getBookmark(){return new SF(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!$7e(e)||!V7e(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&&xi.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let c=e.doc.resolve(i);if(xi.valid(c))return c}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!cn.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let l=e.doc.resolve(i);if(xi.valid(l))return l}return null}}}xi.prototype.visible=!1;xi.findFrom=xi.findGapCursorFrom;On.jsonID("gapcursor",xi);class SF{constructor(e){this.pos=e}map(e){return new SF(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return xi.valid(n)?new xi(n):On.near(n)}}function _re(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function $7e(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||_re(i.type))return!0;if(i.inlineContent)return!1}}return!0}function V7e(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||_re(i.type))return!0;if(i.inlineContent)return!1}}return!0}function G7e(){return new hi({props:{decorations:X7e,createSelectionBetween(t,e,n){return e.pos==n.pos&&xi.valid(n)?new xi(n):null},handleClick:W7e,handleKeyDown:q7e,handleDOMEvents:{beforeinput:K7e}}})}const q7e=wne({ArrowLeft:_1("horiz",-1),ArrowRight:_1("horiz",1),ArrowUp:_1("vert",-1),ArrowDown:_1("vert",1)});function _1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof wn){if(!s.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=xi.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new xi(u))),!0):!1}}function W7e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!xi.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&cn.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new xi(r))),!0)}function K7e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof xi))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=At.empty;for(let o=r.length-1;o>=0;o--)i=At.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new Bt(i,0,0));return s.setSelection(wn.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function X7e(t){if(!(t.selection instanceof xi))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",li.create(t.doc,[ws.widget(t.selection.head,e,{key:"gapcursor"})])}var ck=200,Sa=function(){};Sa.prototype.append=function(e){return e.length?(e=Sa.from(e),!this.length&&e||e.length<ck&&this.leafAppend(e)||this.length<ck&&e.leafPrepend(this)||this.appendInner(e)):this};Sa.prototype.prepend=function(e){return e.length?Sa.from(e).append(this):this};Sa.prototype.appendInner=function(e){return new Y7e(this,e)};Sa.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Sa.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Sa.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Sa.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)};Sa.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};Sa.from=function(e){return e instanceof Sa?e:e&&e.length?new Sre(e):Sa.empty};var Sre=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var c=s;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var c=s-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ck)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ck)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})(Sa);Sa.empty=new Sre([]);var Y7e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Sa);const Q7e=500;class Ll{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((h,p)=>{if(!h.step){i||(i=this.remapping(r,p+1),s=i.maps.length),s--,d.push(h);return}if(i){d.push(new ac(h.map));let m=h.step.map(i.slice(s)),b;m&&o.maybeStep(m).doc&&(b=o.mapping.maps[o.mapping.maps.length-1],u.push(new ac(b,void 0,void 0,u.length+d.length))),s--,b&&i.appendMap(b,s)}else o.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(s)):h.selection,c=new Ll(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,n,r,i){let s=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let h=e.steps[d].invert(e.docs[d]),p=new ac(e.mapping.maps[d],h,n),m;(m=c&&c.merge(p))&&(p=m,d?s.pop():l=l.slice(0,l.length-1)),s.push(p),n&&(o++,n=void 0),i||(c=p)}let u=o-r.depth;return u>J7e&&(l=Z7e(l,u),o-=u),new Ll(l.append(s),o)}remapping(e,n){let r=new Ay;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ll(this.items.append(e.map(n=>new ac(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let c=n;this.items.forEach(p=>{let m=s.getMirror(--c);if(m==null)return;o=Math.min(o,m);let b=s.maps[m];if(p.step){let y=e.steps[m].invert(e.docs[m]),x=p.selection&&p.selection.map(s.slice(c+1,m));x&&l++,r.push(new ac(b,y,x))}else r.push(new ac(b))},i);let u=[];for(let p=n;p<o;p++)u.push(new ac(s.maps[p]));let d=this.items.slice(0,i).append(u).append(r),h=new Ll(d,l);return h.emptyItemCount()>Q7e&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let c=o.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=o.selection&&o.selection.map(n.slice(r));d&&s++;let h=new ac(u.invert(),c,d),p,m=i.length-1;(p=i.length&&i[m].merge(h))?i[m]=p:i.push(h)}}else o.map&&r--},this.items.length,0),new Ll(Sa.from(i.reverse()),s)}}Ll.empty=new Ll(Sa.empty,0);function Z7e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class ac{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 ac(n.getMap().invert(),n,this.selection)}}}class th{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const J7e=20;function e9e(t,e,n,r){let i=n.getMeta(dm),s;if(i)return i.historyState;n.getMeta(r9e)&&(t=new th(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(dm))return o.getMeta(dm).redo?new th(t.done.addTransform(n,void 0,r,Z1(e)),t.undone,y9(n.mapping.maps),t.prevTime,t.prevComposition):new th(t.done,t.undone.addTransform(n,void 0,r,Z1(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||!t9e(n,t.prevRanges)),u=o?ZP(t.prevRanges,n.mapping):y9(n.mapping.maps);return new th(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,Z1(e)),Ll.empty,u,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new th(t.done.rebased(n,s),t.undone.rebased(n,s),ZP(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new th(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ZP(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function t9e(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function y9(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,o)=>e.push(s,o));return e}function ZP(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function n9e(t,e,n){let r=Z1(e),i=dm.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),c=new th(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(dm,{redo:n,historyState:c})}let JP=!1,v9=null;function Z1(t){let e=t.plugins;if(v9!=e){JP=!1,v9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){JP=!0;break}}return JP}const dm=new ua("history"),r9e=new ua("closeHistory");function i9e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new hi({key:dm,state:{init(){return new th(Ll.empty,Ll.empty,null,0,-1)},apply(e,n,r){return e9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?kre:r=="historyRedo"?Mre:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Nre(t,e){return(n,r)=>{let i=dm.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=n9e(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const kre=Nre(!1,!0),Mre=Nre(!0,!0);Or.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 hi({key:new ua("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-i,l=0,c=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=s-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var a9e=Or.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[B7e(this.options)]}});Or.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new hi({key:new ua("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return li.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(ws.node(u,u+c.nodeSize,{class:this.options.className}))}),li.create(t,s)}}})]}});var s9e=Or.create({name:"gapCursor",addProseMirrorPlugins(){return[G7e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=yr(tn(t,"allowGapCursor",n)))!=null?e:null}}});Or.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new hi({key:new ua("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const s=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&YM(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const h=ws.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(h)}return this.options.includeChildren}),li.create(t,i)}}})]}});Or.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new hi({key:new ua("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Fne(n.selection)||t.view.dragging?null:li.create(n.doc,[ws.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function w9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var o9e=Or.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ua(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 hi({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),h=l.content.size,p=u.nodes[n];if(d)return c.insert(h,p.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!w9({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!w9({node:o,types:r})}}})]}}),l9e=Or.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>kre(t,e),redo:()=>({state:t,dispatch:e})=>Mre(t,e)}},addProseMirrorPlugins(){return[i9e(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()}}}),c9e=Or.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(Lqe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(Pqe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(dre.configure(this.options.bulletList)),this.options.code!==!1&&i.push(zqe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(Hqe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push($qe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(a9e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(s9e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(Vqe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(Gqe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(l9e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(qqe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(Qqe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(hre.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(xre.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(ure.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(vre.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(O7e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(I7e.configure(this.options.strike)),this.options.text!==!1&&i.push(z7e.configure(this.options.text)),this.options.underline!==!1&&i.push(wre.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(o9e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),u9e=c9e,d9e=Or.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")}}}),h9e=d9e,f9e=20,Ere=(t,e=0)=>{const n=[];return!t.children.length||e>f9e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Ere(r,e+1))}),n},m9e=t=>{if(!t.children.length)return;const e=Ere(t);e&&e.forEach(n=>{var r,i;const s=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${s}`)})},Tre=Xh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&m9e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Si(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),p9e=Or.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Are=Or.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),g9e=Or.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()}}}),b9e=Or.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()}}}),x9e=Or.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()}}});Or.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(p9e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Are.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(g9e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(b9e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(x9e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Tre.configure(this.options.textStyle)),t}});var y9e=Are,v9e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,w9e=Qs.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",Si(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,s,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,h])=>{if(h!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,h);break}}),l.src=o.src;const c=new nqe({element:l,node:i,getPos:s,onResize:(d,h)=>{l.style.width=`${d}px`,l.style.height=`${h}px`},onCommit:(d,h)=>{const p=s();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:d,height:h}).run()},onUpdate:(d,h,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[Zne({find:v9e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),_9e=w9e;function _R({content:t,onChange:e,placeholder:n}){const{t:r}=Yt(),i=Mqe({extensions:[u9e.configure({heading:!1,codeBlock:!1,code:!1}),U7e,_7e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),h9e.configure({types:["paragraph"]}),Tre,y9e,_9e.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:l})=>{e(l.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(!i)return null;const s=({onClick:l,isActive:c=!1,children:u,title:d})=>a.jsx("button",{type:"button",onClick:l,title:d,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${c?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:u}),o=()=>{const l=window.prompt("Enter URL:");l&&i.chain().focus().setLink({href:l}).run()};return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[a.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[a.jsx(s,{onClick:()=>i.chain().focus().toggleBold().run(),isActive:i.isActive("bold"),title:r("richTextEditor.bold"),children:a.jsx($ce,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().toggleItalic().run(),isActive:i.isActive("italic"),title:r("richTextEditor.italic"),children:a.jsx(Rde,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().toggleUnderline().run(),isActive:i.isActive("underline"),title:r("richTextEditor.underline"),children:a.jsx(Sfe,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(s,{onClick:()=>i.chain().focus().toggleBulletList().run(),isActive:i.isActive("bulletList"),title:r("richTextEditor.bulletList"),children:a.jsx(Tk,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().toggleOrderedList().run(),isActive:i.isActive("orderedList"),title:r("richTextEditor.numberedList"),children:a.jsx(BW,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(s,{onClick:()=>i.chain().focus().setTextAlign("left").run(),isActive:i.isActive({textAlign:"left"}),title:r("richTextEditor.alignLeft"),children:a.jsx(pfe,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().setTextAlign("center").run(),isActive:i.isActive({textAlign:"center"}),title:r("richTextEditor.alignCenter"),children:a.jsx(dfe,{className:"w-4 h-4"})}),a.jsx(s,{onClick:()=>i.chain().focus().setTextAlign("right").run(),isActive:i.isActive({textAlign:"right"}),title:r("richTextEditor.alignRight"),children:a.jsx(ffe,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(s,{onClick:o,isActive:i.isActive("link"),title:r("richTextEditor.addLink"),children:a.jsx(Vy,{className:"w-4 h-4"})}),i.isActive("link")&&a.jsx(s,{onClick:()=>i.chain().focus().unsetLink().run(),title:r("richTextEditor.removeLink"),children:a.jsx(ZR,{className:"w-4 h-4"})})]}),a.jsx(yqe,{editor:i})]})}function Cre({archiveId:t,archiveName:e,onClose:n}){const r=nn(),[i,s]=_.useState(!1),[o,l]=_.useState(null),[c,u]=_.useState({}),{data:d,isLoading:h,error:p}=nt({queryKey:["archive-project-page",t],queryFn:()=>ae.getArchiveProjectPage(t)}),m=dt({mutationFn:M=>ae.updateArchiveProjectPage(t,M),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),u({})}});_.useEffect(()=>{const M=A=>{A.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[o,i,n]);const b=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),s(!0)},x=()=>{m.mutate(c)},v=()=>{s(!1),u({})},S=M=>{const A=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],k=new DOMParser().parseFromString(M,"text/html"),R=C=>{if(C.nodeType===Node.TEXT_NODE)return C.textContent||"";if(C.nodeType===Node.ELEMENT_NODE){const P=C,U=P.tagName.toLowerCase();if(!A.includes(U))return Array.from(P.childNodes).map(R).join("");let F="";if(U==="a"&&P.getAttribute("href")){const D=P.getAttribute("href");D?.toLowerCase().startsWith("http")&&(F=` href="${D}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const D=P.getAttribute("src");if(!D?.toLowerCase().startsWith("http"))return"";F=` src="${D}" style="max-width: 100%; height: auto;"`}const B=Array.from(P.childNodes).map(R).join("");return["br","img"].includes(U)?`<${U}${F} />`:`<${U}${F}>${B}</${U}>`}return""};return Array.from(k.body.childNodes).map(R).join("")},N=d&&(d.title||d.description||d.designer||d.profile_title||b.length>0),T=M=>{M.target===M.currentTarget&&n()};return a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:T,children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(xs,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&a.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!i&&N&&a.jsxs(Me,{variant:"ghost",size:"sm",onClick:y,children:[a.jsx(pm,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),a.jsxs(Me,{variant:"primary",size:"sm",onClick:x,disabled:m.isPending,children:[a.jsx(ys,{className:"w-4 h-4 mr-1"}),"Save"]})]}),a.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[h&&a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),p&&a.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!N&&a.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[a.jsx(xs,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"No project page data found in this 3MF file."}),a.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&N&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[i?a.jsx("input",{type:"text",value:c.title||"",onChange:M=>u({...c,title:M.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&a.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),a.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qu,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.designer||"",onChange:M=>u({...c,designer:M.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(qu,{className:"w-4 h-4"}),a.jsx("span",{children:d.designer}),d.designer_user_id&&a.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:a.jsx(Zr,{className:"w-3 h-3"})})]}),d.creation_date&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(Qr,{className:"w-4 h-4"}),a.jsx("span",{children:d.creation_date})]}),i?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xs,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.license||"",onChange:M=>u({...c,license:M.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(xs,{className:"w-4 h-4"}),a.jsx("span",{children:d.license})]}),d.origin&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?a.jsx(_R,{content:c.description||"",onChange:M=>u({...c,description:M}),placeholder:"Enter description..."}):a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&a.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?a.jsxs("div",{className:"space-y-2",children:[a.jsx("input",{type:"text",value:c.profile_title||"",onChange:M=>u({...c,profile_title:M.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),a.jsx(_R,{content:c.profile_description||"",onChange:M=>u({...c,profile_description:M}),placeholder:"Profile description..."})]}):a.jsxs(a.Fragment,{children:[d.profile_title&&a.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(d.profile_description)}}),d.profile_user_name&&a.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),b.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[a.jsx($u,{className:"w-4 h-4"}),"Images (",b.length,")"]}),a.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:b.map((M,A)=>a.jsx("button",{onClick:()=>l(A),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:a.jsx("img",{src:M.url,alt:M.name,className:"w-full h-full object-cover"})},M.path))})]}),d.design_model_id&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[a.jsx(Zr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&b[o]&&a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[a.jsx("button",{onClick:M=>{M.stopPropagation(),l(Math.max(0,o-1))},disabled:o===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:a.jsx(Th,{className:"w-6 h-6 text-white"})}),a.jsx("img",{src:b[o].url,alt:b[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:M=>M.stopPropagation()}),a.jsx("button",{onClick:M=>{M.stopPropagation(),l(Math.min(b.length-1,o+1))},disabled:o===b.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:a.jsx(Ns,{className:"w-6 h-6 text-white"})}),a.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:a.jsx(Lt,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",b.length]})]})]})}const S9e=[.25,.5,.75,1,1.5,2,3,4];function ug(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function N9e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=kn(),s=_.useRef(null),o=_.useRef(null),[l,c]=_.useState(!1),[u,d]=_.useState(0),[h,p]=_.useState(0),[m,b]=_.useState(0),[y,x]=_.useState(0),[v,S]=_.useState(1),[N,T]=_.useState(null),[M,A]=_.useState(null),[k,R]=_.useState(.8),[C,P]=_.useState(!1),{data:U,isLoading:F}=nt({queryKey:["timelapse-info",t],queryFn:()=>ae.getTimelapseInfo(t)}),{data:B}=nt({queryKey:["timelapse-thumbnails",t],queryFn:()=>ae.getTimelapseThumbnails(t,15)}),D=dt({mutationFn:()=>ae.processTimelapse(t,{trimStart:m,trimEnd:y,speed:v,saveMode:"replace"},N||void 0),onSuccess:H=>{i(H.message,"success"),r?.(),n()},onError:H=>{i(H.message||"Processing failed","error")}});_.useEffect(()=>{U?.duration&&y===0&&x(U.duration)},[U?.duration,y]),_.useEffect(()=>{const H=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[n]),_.useEffect(()=>{const H=s.current;if(!H)return;const W=()=>{const ue=H.currentTime;d(ue),ue>=y&&(H.currentTime=m)},J=()=>{p(H.duration),y===0&&x(H.duration)},ne=()=>c(!0),xe=()=>c(!1);return H.addEventListener("timeupdate",W),H.addEventListener("durationchange",J),H.addEventListener("play",ne),H.addEventListener("pause",xe),()=>{H.removeEventListener("timeupdate",W),H.removeEventListener("durationchange",J),H.removeEventListener("play",ne),H.removeEventListener("pause",xe)}},[m,y]),_.useEffect(()=>{const H=o.current,W=s.current;!H||!W||!M||(H.currentTime=W.currentTime,H.playbackRate=W.playbackRate,l&&!C?H.play().catch(()=>{}):H.pause())},[l,M,C]),_.useEffect(()=>{o.current&&(o.current.volume=C?0:k)},[k,C]),_.useEffect(()=>{s.current&&(s.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const $=_.useCallback(()=>{const H=s.current;H&&(l?H.pause():(H.currentTime<m&&(H.currentTime=m),H.play()))},[l,m]),G=H=>{const W=s.current;W&&(W.currentTime=Math.max(m,Math.min(y,H)))},I=H=>{const W=H.target.files?.[0];W&&(M&&URL.revokeObjectURL(M),T(W),A(URL.createObjectURL(W)))},K=()=>{M&&URL.revokeObjectURL(M),T(null),A(null)};_.useEffect(()=>()=>{M&&URL.revokeObjectURL(M)},[M]);const Q=y-m,se=Q/v;return F?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:a.jsxs("div",{className:"flex items-center gap-3 text-white",children:[a.jsx(lt,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:a.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(gh,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"primary",size:"sm",onClick:()=>D.mutate(),disabled:D.isPending,children:D.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ys,{className:"w-4 h-4"}),"Save"]})}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[a.jsxs("div",{className:"relative",children:[a.jsx("video",{ref:s,src:e,className:"w-full rounded-lg bg-black",onClick:$,muted:!!M}),!l&&a.jsx("button",{onClick:$,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:a.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:a.jsx(To,{className:"w-8 h-8 text-white"})})}),M&&a.jsx("audio",{ref:o,src:M,loop:!0})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(zhe,{className:"w-4 h-4"}),a.jsx("span",{children:"Trim"}),a.jsxs("span",{className:"ml-auto",children:[ug(m)," - ",ug(y)," (",ug(Q),")"]})]}),a.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("div",{className:"absolute inset-0 flex",children:B?.thumbnails.map((H,W)=>a.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${H})`}},W))}),a.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${m/h*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(h-y)/h*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${m/h*100}%`,right:`${(h-y)/h*100}%`}}),a.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/h*100}%`}}),a.jsx("input",{type:"range",min:0,max:h,step:.1,value:m,onChange:H=>{const W=parseFloat(H.target.value);W<y-1&&(b(W),s.current&&s.current.currentTime<W&&(s.current.currentTime=W))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),a.jsx("input",{type:"range",min:0,max:h,step:.1,value:y,onChange:H=>{const W=parseFloat(H.target.value);W>m+1&&x(W)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),a.jsx("input",{type:"range",min:0,max:h,step:.1,value:u,onChange:H=>G(parseFloat(H.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("div",{className:"flex items-center justify-center gap-2",children:a.jsx("button",{onClick:$,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(Ak,{className:"w-5 h-5 text-white"}):a.jsx(To,{className:"w-5 h-5 text-white"})})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Mk,{className:"w-4 h-4"}),a.jsx("span",{children:"Speed"}),a.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",ug(se),")"]})]}),a.jsx("div",{className:"flex gap-1",children:S9e.map(H=>a.jsxs("button",{onClick:()=>S(H),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===H?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[H,"x"]},H))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Oj,{className:"w-4 h-4"}),a.jsx("span",{children:"Music Overlay"})]}),N?a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(Oj,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:N.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(N.size/1024/1024).toFixed(1)," MB"]})]}),a.jsx("button",{onClick:()=>P(!C),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:C?a.jsx(jfe,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(Cfe,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("input",{type:"range",min:0,max:1,step:.1,value:k,onChange:H=>R(parseFloat(H.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),a.jsx("button",{onClick:K,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:a.jsx(hn,{className:"w-4 h-4 text-red-400"})})]}):a.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[a.jsx(Na,{className:"w-8 h-8 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),a.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),a.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:I,className:"hidden"})]})]}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Original:"})," ",ug(h)," @ ",U?.width,"x",U?.height]}),a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Output:"})," ",ug(se)," @ ",v,"x speed",N&&" + music overlay"]})]})]}),D.isPending&&a.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[a.jsx(lt,{className:"w-12 h-12 text-bambu-green animate-spin"}),a.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const k9e=[.25,.5,.75,1,1.5,2,3,4];function Pre({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:s}){const o=_.useRef(null),[l,c]=_.useState(!0),[u,d]=_.useState(1),[h,p]=_.useState(0),[m,b]=_.useState(0),[y,x]=_.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),C=()=>b(k.duration),P=()=>c(!0),U=()=>c(!1);return k.addEventListener("timeupdate",R),k.addEventListener("durationchange",C),k.addEventListener("play",P),k.addEventListener("pause",U),()=>{k.removeEventListener("timeupdate",R),k.removeEventListener("durationchange",C),k.removeEventListener("play",P),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))},N=()=>{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))},M=k=>{const R=Math.floor(k/60),C=Math.floor(k%60);return`${R}:${C.toString().padStart(2,"0")}`},A=()=>{const k=document.createElement("a");k.href=t,k.download=n,k.click()};return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[a.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(gh,{className:"w-5 h-5 text-bambu-green"}),e]}),a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>x(!0),children:[a.jsx(ea,{className:"w-4 h-4"}),"Edit"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:A,children:[a.jsx(_i,{className:"w-4 h-4"}),"Download"]}),a.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"p-4",children:[a.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),a.jsxs("div",{className:"mt-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:M(h)}),a.jsx("input",{type:"range",min:0,max:m||100,value:h,onChange:S,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("span",{className:"text-xs text-bambu-gray w-12",children:M(m)})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:N,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:a.jsx(Yhe,{className:"w-5 h-5 text-bambu-gray"})}),a.jsx("button",{onClick:v,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(Ak,{className:"w-5 h-5 text-white"}):a.jsx(To,{className:"w-5 h-5 text-white"})}),a.jsx("button",{onClick:T,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:a.jsx(QR,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),a.jsx("div",{className:"flex gap-1",children:k9e.map(k=>a.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))})]})]})]})]})]}),y&&r&&a.jsx(N9e,{archiveId:r,timelapseSrc:t,onClose:()=>x(!1),onSave:s})]})}function M9e({archiveIds:t,onClose:e}){_.useEffect(()=>{const s=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e]);const{data:n,isLoading:r,error:i}=nt({queryKey:["archive-comparison",t],queryFn:()=>ae.compareArchives(t)});return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?a.jsxs("div",{className:"text-center py-12 text-red-400",children:[a.jsx(En,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"Failed to load comparison"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?a.jsx(E9e,{comparison:n}):null}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx(Me,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function E9e({comparison:t}){return a.jsxs("div",{className:"space-y-6",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>a.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[a.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),a.jsx("div",{className:`text-xs ${e.status==="completed"?"text-status-ok":e.status==="failed"?"text-status-error":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),a.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>a.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[a.jsx("td",{className:"py-2 pr-4 text-sm",children:a.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&a.jsx(En,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),a.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>a.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??a.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&a.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&a.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[a.jsx(En,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),a.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>a.jsxs("li",{children:[a.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&a.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[a.jsx(Vi,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[a.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),a.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?a.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>a.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[a.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",a.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):a.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):a.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:a.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function T9e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function A9e(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const s=Math.floor(i/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function C9e({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:s}){const[o,l]=_.useState(!1),[c,u]=_.useState(t.tags||""),[d,h]=_.useState(t.notes||""),[p,m]=_.useState(t.project_id),[b,y]=_.useState(!1);return a.jsx(_t,{children:a.jsxs(Mt,{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Qf,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:t.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx("span",{children:T9e(t.file_size)}),a.jsx("span",{children:"·"}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(er,{className:"w-3 h-3"}),A9e(t.uploaded_at)]}),t.source_ip&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?a.jsx(Hu,{className:"w-5 h-5"}):a.jsx(hr,{className:"w-5 h-5"})}),a.jsx(Me,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:p||void 0}),disabled:i,children:i?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(wo,{className:"w-4 h-4"}),"Archive"]})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:s,children:s?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(hn,{className:"w-4 h-4 text-red-400"})})]})]}),b&&a.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),y(!1)},onCancel:()=>y(!1)}),o&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),a.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),a.jsx("textarea",{value:d,onChange:x=>h(x.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),a.jsxs("select",{value:p||"",onChange:x=>m(x.target.value?Number(x.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[a.jsx("option",{value:"",children:"No project"}),e.map(x=>a.jsx("option",{value:x.id,children:x.name},x.id))]})]})]})]})})}function P9e(){const t=nn(),{showToast:e}=kn(),[n,r]=_.useState(!1),[i,s]=_.useState(!1),[o,l]=_.useState(new Set),[c,u]=_.useState(new Set),{data:d,isLoading:h}=nt({queryKey:["pending-uploads"],queryFn:fg.list,refetchInterval:1e4}),{data:p}=nt({queryKey:["projects"],queryFn:()=>ae.getProjects()}),m=dt({mutationFn:({id:v,data:S})=>fg.archive(v,S),onMutate:({id:v})=>{l(S=>new Set(S).add(v))},onSettled:(v,S,{id:N})=>{l(T=>{const M=new Set(T);return M.delete(N),M})},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")}}),b=dt({mutationFn:v=>fg.discard(v),onMutate:v=>{u(S=>new Set(S).add(v))},onSettled:(v,S,N)=>{u(T=>{const M=new Set(T);return M.delete(N),M})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=dt({mutationFn:fg.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")}}),x=dt({mutationFn:fg.discardAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${v.discarded} files`)},onError:v=>{e(v.message||"Failed to discard all","error")}});return h?a.jsx(_t,{children:a.jsx(Mt,{className:"py-8 flex justify-center",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:a.jsxs("div",{className:"mb-6",children:[a.jsxs(_t,{className:"border-l-4 border-l-yellow-500",children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Na,{className:"w-5 h-5 text-yellow-500"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(wo,{className:"w-4 h-4"}),"Archive All"]})}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>s(!0),disabled:x.isPending,children:x.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(hn,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),a.jsxs(Mt,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"These files were uploaded via the virtual printer. Review and archive them to add to your collection."}),a.jsx("div",{className:"space-y-3",children:d.map(v=>a.jsx(C9e,{upload:v,projects:p||[],onArchive:(S,N)=>m.mutate({id:S,data:N}),onDiscard:S=>b.mutate(S),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&a.jsx(Qn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{y.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&a.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:()=>{x.mutate(),s(!1)},onCancel:()=>s(!1)})]})}function j9e({onClose:t}){const e=nn(),{showToast:n}=kn(),[r,i]=_.useState(""),[s,o]=_.useState(null),[l,c]=_.useState(""),[u,d]=_.useState(null),[h,p]=_.useState("count");_.useEffect(()=>{const C=P=>{P.key==="Escape"&&(s?o(null):u?d(null):t())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t,s,u]);const{data:m,isLoading:b}=nt({queryKey:["tags"],queryFn:ae.getTags}),y=dt({mutationFn:({oldName:C,newName:P})=>ae.renameTag(C,P),onSuccess:(C,{oldName:P,newName:U})=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Renamed "${P}" to "${U}" in ${C.affected} archive${C.affected!==1?"s":""}`),o(null)},onError:C=>{n(C.message||"Failed to rename tag","error")}}),x=dt({mutationFn:C=>ae.deleteTag(C),onSuccess:(C,P)=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Deleted "${P}" from ${C.affected} archive${C.affected!==1?"s":""}`),d(null)},onError:C=>{n(C.message||"Failed to delete tag","error")}}),v=C=>{o(C.name),c(C.name),d(null)},S=()=>{o(null),c("")},N=()=>{if(!s||!l.trim())return;const C=l.trim();if(C===s){S();return}y.mutate({oldName:s,newName:C})},T=C=>{C.key==="Enter"?(C.preventDefault(),N()):C.key==="Escape"&&(C.preventDefault(),S())},M=C=>{d(C),o(null)},A=()=>{u&&x.mutate(u)},k=m?.filter(C=>C.name.toLowerCase().includes(r.toLowerCase())).sort((C,P)=>h==="count"&&P.count-C.count||C.name.localeCompare(P.name)),R=m?.reduce((C,P)=>C+P.count,0)||0;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:a.jsxs(Mt,{className:"p-0 flex flex-col min-h-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ah,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Manage Tags"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search tags...",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:r,onChange:C=>i(C.target.value)})]}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:h,onChange:C=>p(C.target.value),children:[a.jsx("option",{value:"count",children:"Sort by Count"}),a.jsx("option",{value:"name",children:"Sort by Name"})]})]}),m&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[m.length," tag",m.length!==1?"s":""," across ",R," usage",R!==1?"s":""]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 p-4",children:b?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):k?.length?a.jsx("div",{className:"space-y-2",children:k.map(C=>a.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors group",children:s===C.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx("input",{type:"text",className:"flex-1 px-2 py-1 bg-bambu-dark-tertiary border border-bambu-green rounded text-white text-sm focus:outline-none",value:l,onChange:P=>c(P.target.value),onKeyDown:T,autoFocus:!0}),a.jsx(Me,{size:"sm",variant:"primary",onClick:N,disabled:!l.trim()||y.isPending,className:"p-1.5",children:y.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Vi,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:S,className:"p-1.5",children:a.jsx(Lt,{className:"w-4 h-4"})})]}):u===C.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx(En,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),a.jsxs("span",{className:"text-sm text-bambu-gray-light flex-1",children:['Delete "',C.name,'" from ',C.count," archive",C.count!==1?"s":"","?"]}),a.jsx(Me,{size:"sm",variant:"danger",onClick:A,disabled:x.isPending,className:"p-1.5",children:x.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(hn,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>d(null),className:"p-1.5",children:a.jsx(Lt,{className:"w-4 h-4"})})]}):a.jsxs(a.Fragment,{children:[a.jsx(Ah,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-white flex-1 truncate",children:C.name}),a.jsx("span",{className:"px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs",children:C.count}),a.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.jsx("button",{onClick:()=>v(C),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename tag",children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>M(C.name),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete tag",children:a.jsx(hn,{className:"w-4 h-4"})})]})]})},C.name))}):a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:r?"No tags match your search":"No tags found"})}),a.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function uk(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function o0(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Bf(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function jre(t){if(!t)return;const e=t.toLowerCase();return e.endsWith(".3mf")?"3mf":e.endsWith(".stl")?"stl":e.endsWith(".gcode")||e.includes(".gcode.")?"gcode":e.split(".").pop()}function D9e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,timeFormat:l="system",preferredSlicer:c="bambu_studio",t:u}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const d=nn(),{showToast:h}=kn(),{hasPermission:p,canModify:m}=Rr(),b=nO(),[y,x]=_.useState(!1),[v,S]=_.useState(!1),[N,T]=_.useState(!1),[M,A]=_.useState(!1),[k,R]=_.useState(!1),[C,P]=_.useState(!1),[U,F]=_.useState([]),[B,D]=_.useState(!1),[$,G]=_.useState(!1),[I,K]=_.useState(!1),[Q,se]=_.useState(!1),[H,W]=_.useState(!1),[J,ne]=_.useState(!1),[xe,ue]=_.useState(null),[fe,De]=_.useState(null),[oe,Ne]=_.useState(!1),Fe=_.useRef(null),ce=_.useRef(null),{data:Ve}=nt({queryKey:["archive-plates",t.id],queryFn:()=>ae.getArchivePlates(t.id),enabled:oe,staleTime:300*1e3}),V=Ve?.plates??[],Y=Ve?.is_multi_plate??!1,de=fe??0,q=dt({mutationFn:Se=>ae.uploadSource3mf(t.id,Se),onSuccess:Se=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.source3mfAttached",{filename:Se.filename}))},onError:Se=>{h(Se.message||u("archives.toast.failedUploadSource3mf"),"error")}}),re=dt({mutationFn:()=>ae.deleteSource3mf(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.source3mfRemoved"))},onError:Se=>{h(Se.message||u("archives.toast.failedRemoveSource3mf"),"error")}}),X=dt({mutationFn:Se=>ae.uploadF3d(t.id,Se),onSuccess:Se=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.f3dAttached",{filename:Se.filename}))},onError:Se=>{h(Se.message||u("archives.toast.failedUploadF3d"),"error")}}),le=dt({mutationFn:()=>ae.deleteF3d(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.f3dRemoved"))},onError:Se=>{h(Se.message||u("archives.toast.failedRemoveF3d"),"error")}}),pe=dt({mutationFn:()=>ae.scanArchiveTimelapse(t.id),onSuccess:Se=>{Se.status==="attached"?(d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.timelapseAttached",{filename:Se.filename}))):Se.status==="exists"?h(u("archives.toast.timelapseAlreadyAttached")):Se.status==="not_found"&&Se.available_files&&Se.available_files.length>0?(F(Se.available_files),P(!0)):h(Se.message||u("archives.toast.noMatchingTimelapse"),"warning")},onError:Se=>{h(Se.message||u("archives.toast.failedScanTimelapse"),"error")}}),ee=dt({mutationFn:Se=>ae.selectArchiveTimelapse(t.id,Se),onSuccess:Se=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.timelapseAttached",{filename:Se.filename})),P(!1),F([])},onError:Se=>{h(Se.message||u("archives.toast.failedAttachTimelapse"),"error")}}),z=dt({mutationFn:()=>ae.deleteArchive(t.id),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.archiveDeleted"))},onError:()=>{h(u("archives.toast.failedDeleteArchive"),"error")}}),O=dt({mutationFn:()=>ae.toggleFavorite(t.id),onSuccess:Se=>{d.invalidateQueries({queryKey:["archives"]}),h(Se.is_favorite?u("archives.toast.addedToFavorites"):u("archives.toast.removedFromFavorites"))}}),{data:Z}=nt({queryKey:["archive-folders",t.id],queryFn:()=>ae.getLibraryFoldersByArchive(t.id)}),me=dt({mutationFn:Se=>ae.updateArchive(t.id,{project_id:Se}),onSuccess:()=>{d.invalidateQueries({queryKey:["archives"]}),d.invalidateQueries({queryKey:["projects"]}),h(u("archives.toast.projectUpdated"))},onError:()=>{h(u("archives.toast.failedUpdateProject"),"error")}}),Te=Se=>{Se.preventDefault(),ue({x:Se.clientX,y:Se.clientY})},Ee=[...Bf(t.filename)?[{label:u("archives.menu.print"),icon:a.jsx(Dr,{className:"w-4 h-4"}),onClick:()=>S(!0),disabled:!m("archives","reprint",t.created_by_id),title:m("archives","reprint",t.created_by_id)?void 0:u("archives.permission.noReprint")},{label:u("archives.menu.schedule"),icon:a.jsx(Qr,{className:"w-4 h-4"}),onClick:()=>se(!0),disabled:!p("queue:create"),title:p("queue:create")?void 0:u("archives.permission.noAddToQueue")},{label:u("archives.menu.openInBambuStudio"),icon:a.jsx(Zr,{className:"w-4 h-4"}),onClick:()=>{const Se=t.print_name||t.filename||"model",$e=`${window.location.origin}${ae.getArchiveForSlicer(t.id,Se)}`;uc($e,c)}}]:[{label:u("archives.menu.slice"),icon:a.jsx(Zr,{className:"w-4 h-4"}),onClick:()=>{const Se=t.print_name||t.filename||"model",$e=`${window.location.origin}${ae.getArchiveForSlicer(t.id,Se)}`;uc($e,c)}}],{label:t.external_url?u("archives.menu.externalLink"):u("archives.menu.viewOnMakerWorld"),icon:a.jsx(bh,{className:"w-4 h-4"}),onClick:()=>{const Se=t.external_url||t.makerworld_url;Se&&window.open(Se,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:u("archives.menu.preview3d"),icon:a.jsx(zi,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:u("archives.menu.viewTimelapse"),icon:a.jsx(gh,{className:"w-4 h-4"}),onClick:()=>R(!0),disabled:!t.timelapse_path},{label:u("archives.menu.scanForTimelapse"),icon:a.jsx(cS,{className:"w-4 h-4"}),onClick:()=>pe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||pe.isPending||!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?u("archives.menu.downloadSource3mf"):u("archives.menu.uploadSource3mf"),icon:a.jsx(sS,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?ae.downloadSource3mf(t.id).catch(Se=>{console.error("Source 3MF download failed:",Se)}):Fe.current?.click()},disabled:!t.source_3mf_path&&!m("archives","update",t.created_by_id),title:!t.source_3mf_path&&!m("archives","update",t.created_by_id)?u("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:u("archives.menu.replaceSource3mf"),icon:a.jsx(Na,{className:"w-4 h-4"}),onClick:()=>Fe.current?.click(),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},{label:u("archives.menu.removeSource3mf"),icon:a.jsx(hn,{className:"w-4 h-4"}),onClick:()=>W(!0),danger:!0,disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?u("archives.menu.replaceF3d"):u("archives.menu.uploadF3d"),icon:a.jsx(zi,{className:"w-4 h-4"}),onClick:()=>ce.current?.click(),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:u("archives.menu.downloadF3d"),icon:a.jsx(_i,{className:"w-4 h-4"}),onClick:()=>{ae.downloadF3d(t.id).catch(Se=>{console.error("F3D download failed:",Se)})}},{label:u("archives.menu.removeF3d"),icon:a.jsx(hn,{className:"w-4 h-4"}),onClick:()=>ne(!0),danger:!0,disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:u("archives.menu.download"),icon:a.jsx(_i,{className:"w-4 h-4"}),onClick:()=>{ae.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(Se=>{console.error("Archive download failed:",Se)})},disabled:!p("archives:read"),title:p("archives:read")?void 0:u("archives.permission.noDownload")},{label:u("archives.menu.copyDownloadLink"),icon:a.jsx(Bl,{className:"w-4 h-4"}),onClick:()=>{const Se=`${window.location.origin}${ae.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(Se).then(()=>{h(u("archives.toast.linkCopied"))}).catch(()=>{h(u("archives.toast.failedCopyLink"),"error")})},disabled:!p("archives:read"),title:p("archives:read")?void 0:u("archives.permission.noCopyLink")},{label:u("archives.menu.qrCode"),icon:a.jsx(VW,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:t.photos?.length?u("archives.menu.viewPhotosCount",{count:t.photos.length}):u("archives.menu.viewPhotos"),icon:a.jsx(Wg,{className:"w-4 h-4"}),onClick:()=>G(!0),disabled:!t.photos?.length},{label:u("archives.menu.projectPage"),icon:a.jsx(xs,{className:"w-4 h-4"}),onClick:()=>K(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?u("archives.menu.removeFromFavorites"):u("archives.menu.addToFavorites"),icon:a.jsx(gm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>O.mutate(),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},{label:u("archives.menu.edit"),icon:a.jsx(ea,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:u("archives.menu.goToProject",{name:t.project_name}),icon:a.jsx(rs,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:u("archives.menu.addToProject"),icon:a.jsx(rs,{className:"w-4 h-4"}),onClick:()=>{},disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?void 0:u("archives.permission.noUpdateArchives"),submenu:(()=>{const Se=[];if(t.project_id&&Se.push({label:u("archives.menu.removeFromProject"),icon:a.jsx(Lt,{className:"w-4 h-4"}),onClick:()=>me.mutate(null),disabled:!m("archives","update",t.created_by_id)}),!s)Se.push({label:u("archives.menu.loading"),icon:a.jsx(lt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const $e=s.filter(Qe=>Qe.status==="active");$e.length===0?Se.push({label:u("archives.menu.noProjectsAvailable"),icon:a.jsx(rs,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):$e.forEach(Qe=>{Se.push({label:Qe.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Qe.color||"#888"}}),onClick:()=>me.mutate(Qe.id),disabled:t.project_id===Qe.id||!m("archives","update",t.created_by_id)})})}return Se})()},{label:u(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(Ks,{className:"w-4 h-4"}):a.jsx(ul,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:u("archives.menu.delete"),icon:a.jsx(hn,{className:"w-4 h-4"}),onClick:()=>T(!0),danger:!0,disabled:!m("archives","delete",t.created_by_id),title:m("archives","delete",t.created_by_id)?void 0:u("archives.permission.noDelete")}];return a.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:Te,onClick:i?()=>r(t.id):void 0,children:[i&&a.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:Se=>{Se.stopPropagation(),r(t.id)},children:n?a.jsx(Ks,{className:"w-5 h-5 text-bambu-green"}):a.jsx(ul,{className:"w-5 h-5 text-white"})}),a.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",onMouseEnter:()=>Ne(!0),onMouseLeave:()=>Ne(!1),children:[t.thumbnail_path?a.jsx("img",{src:fe!==null&&V.length>0?ae.getArchivePlateThumbnail(t.id,V[de]?.index??0):ae.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx($u,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),Y&&V.length>1&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:`absolute left-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${b?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:Se=>{Se.stopPropagation(),De($e=>{const Qe=$e??0;return Qe>0?Qe-1:V.length-1})},title:u("archives.card.previousPlate"),children:a.jsx(Th,{className:"w-4 h-4 text-white"})}),a.jsx("button",{className:`absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${b?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:Se=>{Se.stopPropagation(),De($e=>{const Qe=$e??0;return Qe<V.length-1?Qe+1:0})},title:u("archives.card.nextPlate"),children:a.jsx(Ns,{className:"w-4 h-4 text-white"})}),a.jsx("div",{className:`absolute bottom-1 left-1/2 -translate-x-1/2 flex gap-1 px-2 py-1 rounded-full bg-black/50 transition-all ${b?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:V.map((Se,$e)=>a.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${$e===de?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:Qe=>{Qe.stopPropagation(),De($e)},title:Se.name||u("archives.card.plateNumber",{index:Se.index})},Se.index))})]}),a.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${b?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:Se=>{Se.stopPropagation();const $e=Se.currentTarget.getBoundingClientRect();ue({x:$e.left,y:$e.bottom+4})},title:u("archives.card.moreOptions"),children:a.jsx(ph,{className:"w-5 h-5 text-white"})}),a.jsx("button",{className:`absolute top-2 right-2 p-1 rounded transition-colors ${m("archives","update",t.created_by_id)?"bg-black/50 hover:bg-black/70":"bg-black/30 cursor-not-allowed"}`,onClick:Se=>{Se.stopPropagation(),m("archives","update",t.created_by_id)&&O.mutate()},disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?t.is_favorite?u("archives.card.removeFromFavorites"):u("archives.card.addToFavorites"):u("archives.permission.noUpdateArchives"),children:a.jsx(gm,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"} ${m("archives","update",t.created_by_id)?"":"opacity-50"}`})}),(t.status==="failed"||t.status==="aborted")&&a.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-status-error/80 text-white",children:t.status==="aborted"?u("archives.card.cancelled"):u("archives.card.failed")}),t.duplicate_count>0&&a.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:u("archives.card.duplicateTitle"),children:[a.jsx(Bl,{className:"w-3 h-3"}),u("archives.card.duplicate")]}),t.source_3mf_path&&a.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Se=>{Se.stopPropagation();const $e=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Qe=`${window.location.origin}${ae.getSource3mfForSlicer(t.id,$e)}`;uc(Qe,c)},title:u("archives.card.openSource3mf"),children:a.jsx(sS,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&a.jsx("button",{className:`absolute bottom-2 ${t.source_3mf_path?"left-12":"left-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:Se=>{Se.stopPropagation(),ae.downloadF3d(t.id).catch($e=>{console.error("F3D download failed:",$e)})},title:u("archives.card.downloadF3d"),children:a.jsx(zi,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&a.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Se=>{Se.stopPropagation(),R(!0)},title:u("archives.card.viewTimelapse"),children:a.jsx(gh,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&a.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:Se=>{Se.stopPropagation(),G(!0)},title:t.photos.length===1?u("archives.card.viewPhoto"):u("archives.card.viewPhotos",{count:t.photos.length}),children:[a.jsx(Wg,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&a.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]}),Z&&Z.length>0&&a.jsx(Us,{to:`/files?folder=${Z[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Se=>Se.stopPropagation(),title:u("archives.card.openFolder",{name:Z[0].name}),style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:a.jsx(Hl,{className:"w-4 h-4 text-yellow-400"})})]}),a.jsxs(Mt,{className:"p-4 flex-1 flex flex-col",children:[a.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:e}),a.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Bf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:Bf(t.filename)?u("archives.card.slicedFile"):u("archives.card.sourceFile"),children:Bf(t.filename)?u("archives.card.gcode"):u("archives.card.source")}),t.project_name&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${s?.find(Se=>Se.id===t.project_id)?.color||"#6b7280"}20`,color:s?.find(Se=>Se.id===t.project_id)?.color||"#6b7280"},title:u("archives.card.project",{name:t.project_name}),children:t.project_name})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${o0(t.print_time_seconds||0)}
- Actual: ${o0(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${o0(t.actual_time_seconds)}`:`Estimated: ${o0(t.print_time_seconds||0)}`,children:[a.jsx(er,{className:"w-3 h-3"}),o0(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&a.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(wc,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(is,{className:"w-3 h-3"}),t.total_layers&&a.jsx("span",{children:t.total_layers===1?u("archives.card.layer",{count:t.total_layers}):u("archives.card.layers",{count:t.total_layers})}),t.total_layers&&t.layer_height&&a.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&a.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.object_count===1?u("archives.card.object",{count:t.object_count}):u("archives.card.objects",{count:t.object_count}),children:[a.jsx(zi,{className:"w-3 h-3"}),t.object_count===1?u("archives.card.object",{count:t.object_count}):u("archives.card.objects",{count:t.object_count})]}),t.sliced_for_model&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:u("archives.card.slicedFor",{model:t.sliced_for_model}),children:[a.jsx(Dr,{className:"w-3 h-3"}),t.sliced_for_model]}),t.filament_type&&a.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[a.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&a.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((Se,$e)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:Se},title:Se},$e))})]})]}),(t.tags||t.notes)&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&a.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs",title:t.notes,children:a.jsx(qW,{className:"w-3 h-3"})}),t.tags?.split(",").map((Se,$e)=>a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:Se.trim()},$e))]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[a.jsx("span",{children:Yg(t.created_at,l)}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1",title:u("archives.card.uploadedBy",{name:t.created_by_username}),children:[a.jsx(qu,{className:"w-3 h-3"}),t.created_by_username]}),a.jsx("span",{children:uk(t.file_size)})]})]}),a.jsxs("div",{className:"flex gap-1 mt-3",children:[Bf(t.filename)?a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>S(!0),disabled:!m("archives","reprint",t.created_by_id),title:m("archives","reprint",t.created_by_id)?void 0:u("archives.card.noPermissionReprint"),children:[a.jsx(Dr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:u("archives.card.reprint")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",className:"flex-1 min-w-0",onClick:()=>se(!0),disabled:!p("queue:create"),title:p("queue:create")?u("archives.card.schedulePrint"):u("archives.permission.noAddToQueue"),children:[a.jsx(Qr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:u("archives.card.schedule")})]}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const Se=t.print_name||t.filename||"model",$e=`${window.location.origin}${ae.getArchiveForSlicer(t.id,Se)}`;uc($e,c)},title:u("archives.card.openInBambuStudio"),children:a.jsx(Zr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):a.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const Se=t.print_name||t.filename||"model",$e=`${window.location.origin}${ae.getArchiveForSlicer(t.id,Se)}`;uc($e,c)},title:u("archives.card.openInBambuStudioToSlice"),children:[a.jsx(Zr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:u("archives.card.slice")})]}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const Se=t.external_url||t.makerworld_url;Se&&window.open(Se,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?u("archives.card.externalLink"):t.makerworld_url?u("archives.card.makerWorld",{designer:t.designer||u("archives.card.viewProject")}):u("archives.card.noExternalLink"),children:a.jsx(bh,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:u("archives.card.preview3d"),children:a.jsx(zi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{ae.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(Se=>{console.error("Archive download failed:",Se)})},title:u("archives.card.download"),children:a.jsx(_i,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>A(!0),disabled:!m("archives","update",t.created_by_id),title:m("archives","update",t.created_by_id)?u("archives.card.edit"):u("archives.card.noPermissionEdit"),children:a.jsx(ea,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>T(!0),disabled:!m("archives","delete",t.created_by_id),title:m("archives","delete",t.created_by_id)?u("archives.card.delete"):u("archives.card.noPermissionDelete"),children:a.jsx(hn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),M&&a.jsx(Gee,{archive:t,onClose:()=>A(!1)}),y&&a.jsx(O4,{archiveId:t.id,title:t.print_name||t.filename,fileType:jre(t.filename),onClose:()=>x(!1)}),v&&a.jsx(Iu,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>S(!1)}),N&&a.jsx(Qn,{title:u("archives.modal.deleteArchive"),message:u("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{z.mutate(),T(!1)},onCancel:()=>T(!1)}),H&&a.jsx(Qn,{title:u("archives.modal.removeSource3mf"),message:u("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{re.mutate(),W(!1)},onCancel:()=>W(!1)}),J&&a.jsx(Qn,{title:u("archives.modal.removeF3d"),message:u("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:u("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{le.mutate(),ne(!1)},onCancel:()=>ne(!1)}),xe&&a.jsx(qee,{x:xe.x,y:xe.y,items:Ee,onClose:()=>ue(null)}),k&&t.timelapse_path&&a.jsx(Pre,{src:ae.getArchiveTimelapse(t.id),title:u("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>R(!1),onEdit:()=>{d.invalidateQueries({queryKey:["archives"]}),R(!1)}}),C&&U.length>0&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),a.jsx("button",{onClick:()=>{P(!1),F([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:U.map(Se=>a.jsxs("button",{onClick:()=>ee.mutate(Se.name),disabled:ee.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[a.jsx(gh,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:Se.name}),a.jsxs("p",{className:"text-sm text-gray-400",children:[uk(Se.size),Se.mtime&&` • ${Yg(Se.mtime,l)}`]})]})]},Se.name))}),a.jsx("div",{className:"p-4 border-t border-gray-700",children:a.jsx(Me,{variant:"secondary",onClick:()=>{P(!1),F([])},className:"w-full",children:"Cancel"})})]})}),B&&a.jsx(Wee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),$&&t.photos&&t.photos.length>0&&a.jsx(Kee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>G(!1),onDelete:async Se=>{try{await ae.deleteArchivePhoto(t.id,Se),d.invalidateQueries({queryKey:["archives"]}),h(u("archives.toast.photoDeleted"))}catch{h(u("archives.toast.failedDeletePhoto"),"error")}}}),I&&a.jsx(Cre,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>K(!1)}),Q&&a.jsx(Iu,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>se(!1)}),a.jsx("input",{ref:Fe,type:"file",accept:".3mf",className:"hidden",onChange:Se=>{const $e=Se.target.files?.[0];$e&&q.mutate($e),Se.target.value=""}}),a.jsx("input",{ref:ce,type:"file",accept:".f3d",className:"hidden",onChange:Se=>{const $e=Se.target.files?.[0];$e&&X.mutate($e),Se.target.value=""}})]})}function R9e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,preferredSlicer:l="bambu_studio",t:c}){const u=nn(),{showToast:d}=kn(),{hasPermission:h,canModify:p}=Rr(),[m,b]=_.useState(!1),[y,x]=_.useState(!1),[v,S]=_.useState(!1),[N,T]=_.useState(!1),[M,A]=_.useState(!1),[k,R]=_.useState(!1),[C,P]=_.useState(!1),[U,F]=_.useState([]),[B,D]=_.useState(!1),[$,G]=_.useState(!1),[I,K]=_.useState(!1),[Q,se]=_.useState(!1),[H,W]=_.useState(!1),[J,ne]=_.useState(null),xe=_.useRef(null),ue=_.useRef(null),fe=dt({mutationFn:le=>ae.uploadSource3mf(t.id,le),onSuccess:le=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfAttached",{filename:le.filename}))},onError:le=>{d(le.message||c("archives.toast.failedUploadSource3mf"),"error")}}),De=dt({mutationFn:()=>ae.deleteSource3mf(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfRemoved"))},onError:le=>{d(le.message||c("archives.toast.failedRemoveSource3mf"),"error")}}),oe=dt({mutationFn:le=>ae.uploadF3d(t.id,le),onSuccess:le=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dAttached",{filename:le.filename}))},onError:le=>{d(le.message||c("archives.toast.failedUploadF3d"),"error")}}),Ne=dt({mutationFn:()=>ae.deleteF3d(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dRemoved"))},onError:le=>{d(le.message||c("archives.toast.failedRemoveF3d"),"error")}}),Fe=dt({mutationFn:()=>ae.scanArchiveTimelapse(t.id),onSuccess:le=>{le.status==="attached"?(u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:le.filename}))):le.status==="exists"?d(c("archives.toast.timelapseAlreadyAttached")):le.status==="not_found"&&le.available_files&&le.available_files.length>0?(F(le.available_files),P(!0)):d(le.message||c("archives.toast.noMatchingTimelapse"),"warning")},onError:le=>{d(le.message||c("archives.toast.failedScanTimelapse"),"error")}}),ce=dt({mutationFn:le=>ae.selectArchiveTimelapse(t.id,le),onSuccess:le=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:le.filename})),P(!1),F([])},onError:le=>{d(le.message||c("archives.toast.failedAttachTimelapse"),"error")}}),Ve=dt({mutationFn:()=>ae.deleteArchive(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.archiveDeleted"))},onError:()=>{d(c("archives.toast.failedDeleteArchive"),"error")}}),V=dt({mutationFn:()=>ae.toggleFavorite(t.id),onSuccess:le=>{u.invalidateQueries({queryKey:["archives"]}),d(le.is_favorite?c("archives.toast.addedToFavorites"):c("archives.toast.removedFromFavorites"))}}),{data:Y}=nt({queryKey:["archive-folders",t.id],queryFn:()=>ae.getLibraryFoldersByArchive(t.id)}),de=dt({mutationFn:le=>ae.updateArchive(t.id,{project_id:le}),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),u.invalidateQueries({queryKey:["projects"]}),d(c("archives.toast.projectUpdated"))},onError:()=>{d(c("archives.toast.failedUpdateProject"),"error")}}),q=le=>{le.preventDefault(),ne({x:le.clientX,y:le.clientY})},X=[...Bf(t.filename)?[{label:c("archives.menu.print"),icon:a.jsx(Dr,{className:"w-4 h-4"}),onClick:()=>S(!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:a.jsx(Qr,{className:"w-4 h-4"}),onClick:()=>T(!0),disabled:!h("queue:create"),title:h("queue:create")?void 0:c("archives.permission.noAddToQueue")},{label:c("archives.menu.openInBambuStudio"),icon:a.jsx(Zr,{className:"w-4 h-4"}),onClick:()=>{const le=t.print_name||t.filename||"model",pe=`${window.location.origin}${ae.getArchiveForSlicer(t.id,le)}`;uc(pe,l)}}]:[{label:c("archives.menu.slice"),icon:a.jsx(Zr,{className:"w-4 h-4"}),onClick:()=>{const le=t.print_name||t.filename||"model",pe=`${window.location.origin}${ae.getArchiveForSlicer(t.id,le)}`;uc(pe,l)}}],{label:t.external_url?c("archives.menu.externalLink"):c("archives.menu.viewOnMakerWorld"),icon:a.jsx(bh,{className:"w-4 h-4"}),onClick:()=>{const le=t.external_url||t.makerworld_url;le&&window.open(le,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.preview3d"),icon:a.jsx(zi,{className:"w-4 h-4"}),onClick:()=>A(!0)},{label:c("archives.menu.viewTimelapse"),icon:a.jsx(gh,{className:"w-4 h-4"}),onClick:()=>R(!0),disabled:!t.timelapse_path},{label:c("archives.menu.scanForTimelapse"),icon:a.jsx(cS,{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:a.jsx(sS,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?ae.downloadSource3mf(t.id).catch(le=>{console.error("Source 3MF download failed:",le)}):xe.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:a.jsx(Na,{className:"w-4 h-4"}),onClick:()=>xe.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:a.jsx(hn,{className:"w-4 h-4"}),onClick:()=>se(!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:a.jsx(zi,{className:"w-4 h-4"}),onClick:()=>ue.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:a.jsx(_i,{className:"w-4 h-4"}),onClick:()=>{ae.downloadF3d(t.id).catch(le=>{console.error("F3D download failed:",le)})}},{label:c("archives.menu.removeF3d"),icon:a.jsx(hn,{className:"w-4 h-4"}),onClick:()=>W(!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:a.jsx(_i,{className:"w-4 h-4"}),onClick:()=>{ae.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(le=>{console.error("Archive download failed:",le)})},disabled:!h("archives:read"),title:h("archives:read")?void 0:c("archives.permission.noDownload")},{label:c("archives.menu.copyDownloadLink"),icon:a.jsx(Bl,{className:"w-4 h-4"}),onClick:()=>{const le=`${window.location.origin}${ae.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(le).then(()=>{d(c("archives.toast.linkCopied"))}).catch(()=>{d(c("archives.toast.failedCopyLink"),"error")})},disabled:!h("archives:read"),title:h("archives:read")?void 0:c("archives.permission.noCopyLink")},{label:c("archives.menu.qrCode"),icon:a.jsx(VW,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:t.photos?.length?c("archives.menu.viewPhotosCount",{count:t.photos.length}):c("archives.menu.viewPhotos"),icon:a.jsx(Wg,{className:"w-4 h-4"}),onClick:()=>G(!0),disabled:!t.photos?.length},{label:c("archives.menu.projectPage"),icon:a.jsx(xs,{className:"w-4 h-4"}),onClick:()=>K(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?c("archives.menu.removeFromFavorites"):c("archives.menu.addToFavorites"),icon:a.jsx(gm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>V.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:a.jsx(ea,{className:"w-4 h-4"}),onClick:()=>b(!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:a.jsx(rs,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:c("archives.menu.addToProject"),icon:a.jsx(rs,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const le=[];if(t.project_id&&le.push({label:c("archives.menu.removeFromProject"),icon:a.jsx(Lt,{className:"w-4 h-4"}),onClick:()=>de.mutate(null)}),!s)le.push({label:c("archives.menu.loading"),icon:a.jsx(lt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const pe=s.filter(ee=>ee.status==="active");pe.length===0?le.push({label:c("archives.menu.noProjectsAvailable"),icon:a.jsx(rs,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):pe.forEach(ee=>{le.push({label:ee.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:ee.color||"#888"}}),onClick:()=>de.mutate(ee.id),disabled:t.project_id===ee.id})})}return le})()},{label:c(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(Ks,{className:"w-4 h-4"}):a.jsx(ul,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.delete"),icon:a.jsx(hn,{className:"w-4 h-4"}),onClick:()=>x(!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 a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-archive-id":t.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?"bg-bambu-green/10":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"-4px"}:void 0,onContextMenu:q,children:[a.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&a.jsx("button",{onClick:()=>r(t.id),children:n?a.jsx(Ks,{className:"w-4 h-4 text-bambu-green"}):a.jsx(ul,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?a.jsx("img",{src:ae.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):a.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:a.jsx($u,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),a.jsxs("div",{className:"col-span-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&a.jsx("span",{title:c("archives.list.hasTimelapse"),children:a.jsx(gh,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),Y&&Y.length>0&&a.jsx(Us,{to:`/files?folder=${Y[0].id}`,className:"flex-shrink-0",title:c("archives.card.openFolder",{name:Y[0].name}),onClick:le=>le.stopPropagation(),children:a.jsx(Hl,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),(t.filament_type||t.sliced_for_model)&&a.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.sliced_for_model&&a.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",title:c("archives.card.slicedFor",{model:t.sliced_for_model}),children:[a.jsx(Dr,{className:"w-2.5 h-2.5"}),t.sliced_for_model]}),t.sliced_for_model&&t.filament_type&&a.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.filament_type&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&a.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((le,pe)=>a.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:le},title:le},pe))})]})]}),a.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),a.jsxs("div",{className:"col-span-2 text-sm text-bambu-gray",children:[a.jsx("div",{children:Xg(t.created_at)}),t.created_by_username&&a.jsxs("div",{className:"flex items-center gap-1 text-xs opacity-75",title:c("archives.card.uploadedBy",{name:t.created_by_username}),children:[a.jsx(qu,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:uk(t.file_size)}),a.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const le=t.print_name||t.filename||"model",pe=`${window.location.origin}${ae.getArchiveForSlicer(t.id,le)}`;uc(pe,l)},title:c("archives.card.openInBambuStudio"),children:a.jsx(Zr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?c("archives.card.externalLink"):"MakerWorld",children:a.jsx(bh,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{ae.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(le=>{console.error("Archive download failed:",le)})},title:c("archives.card.download"),children:a.jsx(_i,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>b(!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:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>x(!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:a.jsx(hn,{className:"w-4 h-4 text-red-400"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:le=>{const pe=le.currentTarget.getBoundingClientRect();ne({x:pe.left,y:pe.bottom+4})},title:c("archives.card.moreOptions"),children:a.jsx(ph,{className:"w-4 h-4"})})]})]}),m&&a.jsx(Gee,{archive:t,onClose:()=>b(!1)}),M&&a.jsx(O4,{archiveId:t.id,title:t.print_name||t.filename,fileType:jre(t.filename),onClose:()=>A(!1)}),v&&a.jsx(Iu,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>S(!1)}),y&&a.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:()=>{Ve.mutate(),x(!1)},onCancel:()=>x(!1)}),Q&&a.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:()=>{De.mutate(),se(!1)},onCancel:()=>se(!1)}),H&&a.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:()=>{Ne.mutate(),W(!1)},onCancel:()=>W(!1)}),J&&a.jsx(qee,{x:J.x,y:J.y,items:X,onClose:()=>ne(null)}),k&&t.timelapse_path&&a.jsx(Pre,{src:ae.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:()=>R(!1),onEdit:()=>{u.invalidateQueries({queryKey:["archives"]}),R(!1)}}),C&&U.length>0&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),a.jsx("button",{onClick:()=>{P(!1),F([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:U.map(le=>a.jsxs("button",{onClick:()=>ce.mutate(le.name),disabled:ce.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[a.jsx("div",{className:"font-medium text-white",children:le.name}),a.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[a.jsx("span",{children:uk(le.size)}),le.mtime&&a.jsx("span",{children:Xg(le.mtime)})]})]},le.name))})]})}),B&&a.jsx(Wee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),$&&t.photos&&a.jsx(Kee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>G(!1),onDelete:async le=>{try{await ae.deleteArchivePhoto(t.id,le),u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.photoDeleted"))}catch{d(c("archives.toast.failedDeletePhoto"),"error")}}}),I&&a.jsx(Cre,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>K(!1)}),N&&a.jsx(Iu,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>T(!1)}),a.jsx("input",{ref:xe,type:"file",accept:".3mf",className:"hidden",onChange:le=>{const pe=le.target.files?.[0];pe&&fe.mutate(pe),le.target.value=""}}),a.jsx("input",{ref:ue,type:"file",accept:".f3d",className:"hidden",onChange:le=>{const pe=le.target.files?.[0];pe&&oe.mutate(pe),le.target.value=""}})]})}const O9e=[{id:"all",label:"All Archives",icon:a.jsx(Hl,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:a.jsx(er,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:a.jsx(Qr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:a.jsx(Qr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:a.jsx(gm,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:a.jsx(Ti,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:a.jsx(Bl,{className:"w-4 h-4"})}];function L9e(){const{t}=Yt(),e=nn(),{showToast:n}=kn(),{hasPermission:r,hasAnyPermission:i}=Rr(),s=_.useRef(null),[o,l]=_.useState(""),[c,u]=_.useState(()=>{const we=localStorage.getItem("archiveFilterPrinter");return we?Number(we):null}),[d,h]=_.useState(()=>localStorage.getItem("archiveFilterMaterial")),[p,m]=_.useState(()=>{const we=localStorage.getItem("archiveFilterColors");return we?new Set(JSON.parse(we)):new Set}),[b,y]=_.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[x,v]=_.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[S,N]=_.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[T,M]=_.useState(()=>localStorage.getItem("archiveFilterTag")),[A,k]=_.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[R,C]=_.useState(!1),[P,U]=_.useState([]),[F,B]=_.useState(!1),[D,$]=_.useState(new Set),[G,I]=_.useState(!1),[K,Q]=_.useState(!1),[se,H]=_.useState(!1),[W,J]=_.useState(!1),[ne,xe]=_.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[ue,fe]=_.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[De,oe]=_.useState(()=>localStorage.getItem("archiveCollection")||"all"),[Ne,Fe]=_.useState(!1),[ce,Ve]=_.useState(!1),[V,Y]=_.useState(!1),[de,q]=_.useState(!1),[re,X]=_.useState(null);_.useEffect(()=>{if(re){const we=setTimeout(()=>{const xt=document.querySelector(`[data-archive-id="${re}"]`);xt&&xt.scrollIntoView({behavior:"smooth",block:"center"})},100),qe=setTimeout(()=>X(null),5e3);return()=>{clearTimeout(we),clearTimeout(qe)}}},[re]);const{data:le,isLoading:pe}=nt({queryKey:["archives",c],queryFn:()=>ae.getArchives(c||void 0)}),{data:ee}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:z}=nt({queryKey:["projects"],queryFn:()=>ae.getProjects()}),{data:O}=nt({queryKey:["settings"],queryFn:ae.getSettings}),Z=O?.time_format||"system",me=O?.preferred_slicer||"bambu_studio",Te=dt({mutationFn:async we=>(await Promise.all(we.map(qe=>ae.deleteArchive(qe))),we.length),onSuccess:we=>{e.invalidateQueries({queryKey:["archives"]}),$(new Set),n(`${we} archive${we!==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",b)},[b]),_.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",x.toString())},[x]),_.useEffect(()=>{localStorage.setItem("archiveHideFailed",S.toString())},[S]),_.useEffect(()=>{T?localStorage.setItem("archiveFilterTag",T):localStorage.removeItem("archiveFilterTag")},[T]),_.useEffect(()=>{localStorage.setItem("archiveFilterFileType",A)},[A]),_.useEffect(()=>{localStorage.setItem("archiveViewMode",ne)},[ne]),_.useEffect(()=>{localStorage.setItem("archiveSortBy",ue)},[ue]),_.useEffect(()=>{localStorage.setItem("archiveCollection",De)},[De]);const ke=new Map(ee?.map(we=>[we.id,we.name])||[]),Ee=[...new Set(le?.flatMap(we=>we.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),Se=[...new Set(le?.flatMap(we=>we.filament_color?.split(",")||[]).filter(Boolean)||[])],$e=[...new Set(le?.flatMap(we=>we.tags?.split(",").map(qe=>qe.trim())||[]).filter(Boolean)||[])].sort(),Qe=le?.filter(we=>{const qe=new Date,xt=Ui(we.created_at)||new Date(0);let Et=!0;switch(De){case"recent":Et=qe.getTime()-xt.getTime()<1440*60*1e3;break;case"this-week":Et=qe.getTime()-xt.getTime()<10080*60*1e3;break;case"this-month":Et=xt.getMonth()===qe.getMonth()&&xt.getFullYear()===qe.getFullYear();break;case"favorites":Et=we.is_favorite===!0;break;case"failed":Et=we.status==="failed"||we.status==="aborted";break;case"duplicates":Et=we.duplicate_count>0;break}const fn=(we.print_name||we.filename).toLowerCase().includes(o.toLowerCase()),It=!d||we.filament_type?.split(", ").includes(d),Oe=we.filament_color?.split(",")||[],yt=p.size===0||(b==="or"?Oe.some(Xt=>p.has(Xt)):[...p].every(Xt=>Oe.includes(Xt))),Wt=De==="favorites"||!x||we.is_favorite,rn=De==="failed"||!S||we.status!=="failed"&&we.status!=="aborted",Qt=we.tags?.split(",").map(Xt=>Xt.trim())||[],ur=!T||Qt.includes(T),Lr=Bf(we.filename);return Et&&fn&&It&&yt&&Wt&&rn&&ur&&(A==="all"||A==="gcode"&&Lr||A==="source"&&!Lr)}).sort((we,qe)=>{switch(ue){case"date-desc":return(Ui(qe.created_at)?.getTime()||0)-(Ui(we.created_at)?.getTime()||0);case"date-asc":return(Ui(we.created_at)?.getTime()||0)-(Ui(qe.created_at)?.getTime()||0);case"name-asc":return(we.print_name||we.filename).localeCompare(qe.print_name||qe.filename);case"name-desc":return(qe.print_name||qe.filename).localeCompare(we.print_name||we.filename);case"size-desc":return qe.file_size-we.file_size;case"size-asc":return we.file_size-qe.file_size;default:return 0}}),Ue=G||D.size>0,be=we=>{$(qe=>{const xt=new Set(qe);return xt.has(we)?xt.delete(we):xt.add(we),xt})},ve=()=>{Qe&&$(new Set(Qe.map(we=>we.id)))},ze=()=>{$(new Set),I(!1)},Ce=we=>{m(qe=>{const xt=new Set(qe);return xt.has(we)?xt.delete(we):xt.add(we),xt})},Ge=()=>{m(new Set)},_e=()=>{l(""),u(null),h(null),v(!1),N(!1),M(null),k("all")},Je=o||c||d||x||S||T||A!=="all",Ae=_.useCallback(we=>{we.preventDefault(),we.dataTransfer.types.includes("Files")&&B(!0)},[]),Ke=_.useCallback(we=>{we.preventDefault(),we.currentTarget===we.target&&B(!1)},[]),je=_.useCallback(we=>{we.preventDefault(),B(!1);const qe=Array.from(we.dataTransfer.files).filter(xt=>xt.name.endsWith(".3mf"));qe.length>0?(U(qe),C(!0)):we.dataTransfer.files.length>0&&n(t("archives.page.only3mfSupported"),"warning")},[n,t]),Re=_.useCallback(we=>{const qe=we.target;if(qe.tagName==="INPUT"||qe.tagName==="TEXTAREA"||qe.isContentEditable){we.key==="Escape"&&qe.blur();return}switch(we.key){case"/":we.preventDefault(),s.current?.focus();break;case"u":case"U":!we.metaKey&&!we.ctrlKey&&(we.preventDefault(),C(!0));break;case"Escape":Ue&&ze();break}},[Ue]);return _.useEffect(()=>(document.addEventListener("keydown",Re),()=>document.removeEventListener("keydown",Re)),[Re]),a.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:Ae,onDragLeave:Ke,onDrop:je,children:[F&&a.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:a.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[a.jsx(Na,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),a.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),a.jsx("p",{className:"text-bambu-gray",children:t("archives.releaseToUpload")})]})}),Ue&&a.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:ze,children:[a.jsx(Lt,{className:"w-4 h-4"}),"Close"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs("span",{className:"text-white font-medium",children:[D.size," selected"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:ve,children:"Select All"}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>H(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[a.jsx(Ah,{className:"w-4 h-4"}),"Tags"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>J(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[a.jsx(rs,{className:"w-4 h-4"}),"Project"]}),a.jsxs(Me,{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 we=Array.from(D);Promise.all(we.map(qe=>ae.toggleFavorite(qe))).then(()=>{e.invalidateQueries({queryKey:["archives"]}),n(`Toggled favorites for ${we.length} archive${we.length!==1?"s":""}`)}).catch(()=>{n(t("archives.toast.failedUpdateFavorites"),"error")})},children:[a.jsx(gm,{className:"w-4 h-4"}),"Favorite"]}),a.jsxs(Me,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Q(!0),disabled:!i("archives:delete_own","archives:delete_all"),title:i("archives:delete_own","archives:delete_all")?void 0:t("archives.permission.noDelete"),children:[a.jsx(hn,{className:"w-4 h-4"}),"Delete"]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),a.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:De,onChange:we=>oe(we.target.value),children:O9e.map(we=>a.jsx("option",{value:we.id,children:we.label},we.id))})]}),a.jsxs("p",{className:"text-bambu-gray",children:[Qe?.length||0," of ",le?.length||0," prints"]})]}),a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[a.jsxs("div",{className:"relative",children:[a.jsxs(Me,{variant:"secondary",onClick:()=>Fe(!Ne),disabled:ce,children:[ce?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(oS,{className:"w-4 h-4"}),"Export"]}),Ne&&a.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{Fe(!1),Ve(!0);try{const{blob:we,filename:qe}=await ae.exportArchives({format:"csv",printerId:c||void 0,status:De==="failed"?"failed":void 0,search:o||void 0}),xt=URL.createObjectURL(we),Et=document.createElement("a");Et.href=xt,Et.download=qe,Et.click(),URL.revokeObjectURL(xt),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ve(!1)}},children:[a.jsx(xs,{className:"w-4 h-4"}),"Export as CSV"]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{Fe(!1),Ve(!0);try{const{blob:we,filename:qe}=await ae.exportArchives({format:"xlsx",printerId:c||void 0,status:De==="failed"?"failed":void 0,search:o||void 0}),xt=URL.createObjectURL(we),Et=document.createElement("a");Et.href=xt,Et.download=qe,Et.click(),URL.revokeObjectURL(xt),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ve(!1)}},children:[a.jsx(oS,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),D.size>=2&&D.size<=5&&a.jsxs(Me,{variant:"secondary",onClick:()=>Y(!0),children:[a.jsx(Cg,{className:"w-4 h-4"}),"Compare (",D.size,")"]}),!Ue&&a.jsxs(Me,{variant:"secondary",onClick:()=>I(!0),children:[a.jsx(Ks,{className:"w-4 h-4"}),"Select"]}),a.jsxs(Me,{onClick:()=>C(!0),disabled:!r("archives:create"),title:r("archives:create")?void 0:t("archives.permission.noCreate"),children:[a.jsx(Na,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),a.jsx(_t,{className:"mb-6",children:a.jsxs(Mt,{className:"py-4",children:[a.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[a.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{ref:s,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:we=>l(we.target.value)})]}),a.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(kk,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c||"",onChange:we=>u(we.target.value?Number(we.target.value):null),children:[a.jsx("option",{value:"",children:"All Printers"}),ee?.map(we=>a.jsx("option",{value:we.id,children:we.name},we.id))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(wc,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:d||"",onChange:we=>h(we.target.value||null),children:[a.jsx("option",{value:"",children:"All Materials"}),Ee.map(we=>a.jsx("option",{value:we,children:we},we))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(sS,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:A,onChange:we=>k(we.target.value),children:[a.jsx("option",{value:"all",children:"All Files"}),a.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),a.jsx("option",{value:"source",children:"Source Only"})]})]}),a.jsxs("button",{onClick:()=>v(!x),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${x?"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(x?"archives.showAll":"archives.showFavoritesOnly"),children:[a.jsx(gm,{className:`w-4 h-4 ${x?"fill-yellow-400":""}`}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),a.jsxs("button",{onClick:()=>N(!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:[a.jsx(Ti,{className:"w-4 h-4 "}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),$e.length>0&&a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(Ah,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:T||"",onChange:we=>M(we.target.value||null),children:[a.jsx("option",{value:"",children:"All Tags"}),$e.map(we=>a.jsx("option",{value:we,children:we},we))]}),a.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:a.jsx(jk,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(OW,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:ue,onChange:we=>fe(we.target.value),children:[a.jsx("option",{value:"date-desc",children:t("archives.sortNewest")}),a.jsx("option",{value:"date-asc",children:t("archives.sortOldest")}),a.jsxs("option",{value:"name-asc",children:[t("archives.sortName")," A-Z"]}),a.jsxs("option",{value:"name-desc",children:[t("archives.sortName")," Z-A"]}),a.jsx("option",{value:"size-desc",children:t("archives.sortLargest")}),a.jsx("option",{value:"size-asc",children:t("archives.sortSmallest")})]})]}),a.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[a.jsx("button",{className:`p-2 ${ne==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>xe("grid"),title:t("archives.gridView"),children:a.jsx(Ek,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${ne==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>xe("list"),title:t("archives.listView"),children:a.jsx(Tk,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${ne==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>xe("calendar"),title:t("archives.calendarView"),children:a.jsx(nue,{className:"w-4 h-4"})})]})]}),Je&&a.jsxs(Me,{variant:"ghost",size:"sm",onClick:_e,className:"text-bambu-gray hover:text-white",children:[a.jsx(Lt,{className:"w-4 h-4"}),"Reset"]})]}),Se.length>0&&a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),p.size>1&&a.jsx("button",{onClick:()=>y(we=>we==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${b==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:b==="or"?"Match ANY selected color":"Match ALL selected colors",children:b.toUpperCase()}),a.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:Se.map(we=>a.jsx("button",{onClick:()=>Ce(we),className:`w-6 h-6 rounded-full border-2 transition-all ${p.has(we)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:we},title:we},we))}),p.size>0&&a.jsxs("button",{onClick:Ge,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[a.jsx(Lt,{className:"w-3 h-3"}),"Clear"]})]})]})}),a.jsx(P9e,{}),pe?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("archives.loadingArchives")}):Qe?.length===0?a.jsx(_t,{children:a.jsxs(Mt,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray",children:t(o?"archives.noArchivesSearch":"archives.noArchivesYet")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):ne==="calendar"?a.jsx(_t,{className:"p-6",children:a.jsx(l6e,{archives:Qe||[],onArchiveClick:we=>{l(""),xe("grid"),X(we.id)},highlightedArchiveId:re})}):ne==="grid"?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Qe?.map(we=>a.jsx(D9e,{archive:we,printerName:we.printer_id?ke.get(we.printer_id)||"Unknown":we.sliced_for_model?`Sliced for ${we.sliced_for_model}`:"No Printer",isSelected:D.has(we.id),onSelect:be,selectionMode:Ue,projects:z,isHighlighted:we.id===re,timeFormat:Z,preferredSlicer:me,t},we.id))}):ne==="list"?a.jsx(_t,{children:a.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[a.jsx("div",{className:"col-span-1"}),a.jsx("div",{className:"col-span-4",children:"Name"}),a.jsx("div",{className:"col-span-2",children:"Printer"}),a.jsx("div",{className:"col-span-2",children:"Date"}),a.jsx("div",{className:"col-span-1",children:"Size"}),a.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),Qe?.map(we=>a.jsx(R9e,{archive:we,printerName:we.printer_id?ke.get(we.printer_id)||"Unknown":we.sliced_for_model?`Sliced for ${we.sliced_for_model}`:"No Printer",isSelected:D.has(we.id),onSelect:be,selectionMode:Ue,projects:z,isHighlighted:we.id===re,preferredSlicer:me,t},we.id))]})}):null,R&&a.jsx(J8e,{onClose:()=>{C(!1),U([])},initialFiles:P}),K&&a.jsx(Qn,{title:t("archives.modal.deleteArchives"),message:t("archives.modal.deleteArchivesConfirm",{count:D.size}),confirmText:t("archives.modal.deleteCount",{count:D.size}),variant:"danger",onConfirm:()=>{Te.mutate(Array.from(D)),Q(!1)},onCancel:()=>Q(!1)}),se&&a.jsx(n6e,{selectedIds:Array.from(D),existingTags:$e,onClose:()=>H(!1)}),W&&a.jsx(r6e,{selectedIds:Array.from(D),onClose:()=>J(!1)}),V&&D.size>=2&&D.size<=5&&a.jsx(M9e,{archiveIds:Array.from(D),onClose:()=>{Y(!1),$(new Set),I(!1)}}),de&&a.jsx(j9e,{onClose:()=>q(!1)})]})}function F9e(){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 e2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Gb(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function NF(t){return"nodeType"in t}function Zs(t){var e,n;return t?Gb(t)?t:NF(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function kF(t){const{Document:e}=Zs(t);return t instanceof e}function Ev(t){return Gb(t)?!1:t instanceof Zs(t).HTMLElement}function Dre(t){return t instanceof Zs(t).SVGElement}function qb(t){return t?Gb(t)?t.document:NF(t)?kF(t)?t:Ev(t)||Dre(t)?t.ownerDocument:document:document:document}const Ac=e2?_.useLayoutEffect:_.useEffect;function MF(t){const e=_.useRef(t);return Ac(()=>{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 I9e(){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 Fy(t,e){e===void 0&&(e=[t]);const n=_.useRef(t);return Ac(()=>{n.current!==t&&(n.current=t)},e),n}function Tv(t,e){const n=_.useRef();return _.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function dk(t){const e=MF(t),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function SR(t){const e=_.useRef();return _.useEffect(()=>{e.current=t},[t]),e.current}let ej={};function Av(t,e){return _.useMemo(()=>{if(e)return e;const n=ej[t]==null?0:ej[t]+1;return ej[t]=n,t+"-"+n},[t,e])}function Rre(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=s[c];d!=null&&(s[c]=d+t*u)}return s},{...e})}}const Vg=Rre(1),Iy=Rre(-1);function z9e(t){return"clientX"in t&&"clientY"in t}function EF(t){if(!t)return!1;const{KeyboardEvent:e}=Zs(t.target);return e&&t instanceof e}function U9e(t){if(!t)return!1;const{TouchEvent:e}=Zs(t.target);return e&&t instanceof e}function NR(t){if(U9e(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 z9e(t)?{x:t.clientX,y:t.clientY}:null}const _b=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[_b.Translate.toString(t),_b.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),_9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function B9e(t){return t.matches(_9)?t:t.querySelector(_9)}const H9e={display:"none"};function $9e(t){let{id:e,value:n}=t;return ri.createElement("div",{id:e,style:H9e},n)}function V9e(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 ri.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function G9e(){const[t,e]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Ore=_.createContext(null);function q9e(t){const e=_.useContext(Ore);_.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function W9e(){const[t]=_.useState(()=>new Set),e=_.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[_.useCallback(r=>{let{type:i,event:s}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,s)})},[t]),e]}const K9e={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},X9e={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 Y9e(t){let{announcements:e=X9e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=K9e}=t;const{announce:s,announcement:o}=G9e(),l=Av("DndLiveRegion"),[c,u]=_.useState(!1);if(_.useEffect(()=>{u(!0)},[]),q9e(_.useMemo(()=>({onDragStart(h){let{active:p}=h;s(e.onDragStart({active:p}))},onDragMove(h){let{active:p,over:m}=h;e.onDragMove&&s(e.onDragMove({active:p,over:m}))},onDragOver(h){let{active:p,over:m}=h;s(e.onDragOver({active:p,over:m}))},onDragEnd(h){let{active:p,over:m}=h;s(e.onDragEnd({active:p,over:m}))},onDragCancel(h){let{active:p,over:m}=h;s(e.onDragCancel({active:p,over:m}))}}),[s,e])),!c)return null;const d=ri.createElement(ri.Fragment,null,ri.createElement($9e,{id:r,value:i.draggable}),ri.createElement(V9e,{id:l,announcement:o}));return n?Su.createPortal(d,n):d}var Qi;(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"})(Qi||(Qi={}));function hk(){}function fk(t,e){return _.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Lre(){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 Vl=Object.freeze({x:0,y:0});function Fre(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Ire(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function Q9e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function S9(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 zre(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function N9(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 Ure=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=N9(e,e.left,e.top),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Fre(N9(c),i);s.push({id:l,data:{droppableContainer:o,value:u}})}}return s.sort(Ire)},Z9e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=S9(e),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=S9(c),d=i.reduce((p,m,b)=>p+Fre(u[b],m),0),h=Number((d/4).toFixed(4));s.push({id:l,data:{droppableContainer:o,value:h}})}}return s.sort(Ire)};function J9e(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=s-n;if(r<i&&n<s){const c=e.width*e.height,u=t.width*t.height,d=o*l,h=d/(c+u-d);return Number(h.toFixed(4))}return 0}const eWe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=J9e(l,e);c>0&&i.push({id:o,data:{droppableContainer:s,value:c}})}}return i.sort(Q9e)};function tWe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Bre(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Vl}function nWe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];return i.reduce((o,l)=>({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...n})}}const rWe=nWe(1);function iWe(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 aWe(t,e,n){const r=iWe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,h=s?t.height/s:t.height;return{width:d,height:h,top:u,right:c+d,bottom:u+h,left:c}}const sWe={ignoreTransform:!1};function Wb(t,e){e===void 0&&(e=sWe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Zs(t).getComputedStyle(t);u&&(n=aWe(n,u,d))}const{top:r,left:i,width:s,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:s,height:o,bottom:l,right:c}}function k9(t){return Wb(t,{ignoreTransform:!0})}function oWe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function lWe(t,e){return e===void 0&&(e=Zs(t).getComputedStyle(t)),e.position==="fixed"}function cWe(t,e){e===void 0&&(e=Zs(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=e[i];return typeof s=="string"?n.test(s):!1})}function t2(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(kF(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ev(i)||Dre(i)||n.includes(i))return n;const s=Zs(t).getComputedStyle(i);return i!==t&&cWe(i,s)&&n.push(i),lWe(i,s)?n:r(i.parentNode)}return t?r(t):n}function Hre(t){const[e]=t2(t,1);return e??null}function tj(t){return!e2||!t?null:Gb(t)?t:NF(t)?kF(t)||t===qb(t).scrollingElement?window:Ev(t)?t:null:null}function $re(t){return Gb(t)?t.scrollX:t.scrollLeft}function Vre(t){return Gb(t)?t.scrollY:t.scrollTop}function kR(t){return{x:$re(t),y:Vre(t)}}var ya;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ya||(ya={}));function Gre(t){return!e2||!t?!1:t===document.scrollingElement}function qre(t){const e={x:0,y:0},n=Gre(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,s=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:s,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const uWe={x:.2,y:.2};function dWe(t,e,n,r,i){let{top:s,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=uWe);const{isTop:u,isBottom:d,isLeft:h,isRight:p}=qre(t),m={x:0,y:0},b={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&s<=e.top+y.height?(m.y=ya.Backward,b.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&c>=e.bottom-y.height&&(m.y=ya.Forward,b.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!p&&l>=e.right-y.width?(m.x=ya.Forward,b.x=r*Math.abs((e.right-y.width-l)/y.width)):!h&&o<=e.left+y.width&&(m.x=ya.Backward,b.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:m,speed:b}}function hWe(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:o}=window;return{top:0,left:0,right:s,bottom:o,width:s,height:o}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function Wre(t){return t.reduce((e,n)=>Vg(e,kR(n)),Vl)}function fWe(t){return t.reduce((e,n)=>e+$re(n),0)}function mWe(t){return t.reduce((e,n)=>e+Vre(n),0)}function pWe(t,e){if(e===void 0&&(e=Wb),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);Hre(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const gWe=[["x",["left","right"],fWe],["y",["top","bottom"],mWe]];class TF{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=t2(n),i=Wre(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,o,l]of gWe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[s]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class H0{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 bWe(t){const{EventTarget:e}=Zs(t);return t instanceof e?t:qb(t)}function nj(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 Zo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Zo||(Zo={}));function M9(t){t.preventDefault()}function xWe(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 Kre={start:[Yn.Space,Yn.Enter],cancel:[Yn.Esc],end:[Yn.Space,Yn.Enter,Yn.Tab]},yWe=(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 n2{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 H0(qb(n)),this.windowListeners=new H0(Zs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Zo.Resize,this.handleCancel),this.windowListeners.add(Zo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Zo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&pWe(r),n(Vl)}handleKeyDown(e){if(EF(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=Kre,coordinateGetter:o=yWe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(s.end.includes(c)){this.handleEnd(e);return}if(s.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Vl;this.referenceCoordinates||(this.referenceCoordinates=d);const h=o(e,{active:n,context:r.current,currentCoordinates:d});if(h){const p=Iy(h,d),m={x:0,y:0},{scrollableAncestors:b}=r.current;for(const y of b){const x=e.code,{isTop:v,isRight:S,isLeft:N,isBottom:T,maxScroll:M,minScroll:A}=qre(y),k=hWe(y),R={x:Math.min(x===Yn.Right?k.right-k.width/2:k.right,Math.max(x===Yn.Right?k.left:k.left+k.width/2,h.x)),y:Math.min(x===Yn.Down?k.bottom-k.height/2:k.bottom,Math.max(x===Yn.Down?k.top:k.top+k.height/2,h.y))},C=x===Yn.Right&&!S||x===Yn.Left&&!N,P=x===Yn.Down&&!T||x===Yn.Up&&!v;if(C&&R.x!==h.x){const U=y.scrollLeft+p.x,F=x===Yn.Right&&U<=M.x||x===Yn.Left&&U>=A.x;if(F&&!p.y){y.scrollTo({left:U,behavior:l});return}F?m.x=y.scrollLeft-U:m.x=x===Yn.Right?y.scrollLeft-M.x:y.scrollLeft-A.x,m.x&&y.scrollBy({left:-m.x,behavior:l});break}else if(P&&R.y!==h.y){const U=y.scrollTop+p.y,F=x===Yn.Down&&U<=M.y||x===Yn.Up&&U>=A.y;if(F&&!p.x){y.scrollTo({top:U,behavior:l});return}F?m.y=y.scrollTop-U:m.y=x===Yn.Down?y.scrollTop-M.y:y.scrollTop-A.y,m.y&&y.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,Vg(Iy(h,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()}}n2.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Kre,onActivation:i}=e,{active:s}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=s.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function E9(t){return!!(t&&"distance"in t)}function T9(t){return!!(t&&"delay"in t)}class AF{constructor(e,n,r){var i;r===void 0&&(r=bWe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:s}=e,{target:o}=s;this.props=e,this.events=n,this.document=qb(o),this.documentListeners=new H0(this.document),this.listeners=new H0(r),this.windowListeners=new H0(Zs(o)),this.initialCoordinates=(i=NR(s))!=null?i:Vl,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(Zo.Resize,this.handleCancel),this.windowListeners.add(Zo.DragStart,M9),this.windowListeners.add(Zo.VisibilityChange,this.handleCancel),this.windowListeners.add(Zo.ContextMenu,M9),this.documentListeners.add(Zo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(T9(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(E9(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(Zo.Click,xWe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Zo.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!i)return;const c=(n=NR(e))!=null?n:Vl,u=Iy(i,c);if(!r&&l){if(E9(l)){if(l.tolerance!=null&&nj(u,l.tolerance))return this.handleCancel();if(nj(u,l.distance))return this.handleStart()}if(T9(l)&&nj(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 vWe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class r2 extends AF{constructor(e){const{event:n}=e,r=qb(n.target);super(e,vWe,r)}}r2.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 wWe={move:{name:"mousemove"},end:{name:"mouseup"}};var MR;(function(t){t[t.RightClick=2]="RightClick"})(MR||(MR={}));class _We extends AF{constructor(e){super(e,wWe,qb(e.event.target))}}_We.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===MR.RightClick?!1:(r?.({event:n}),!0)}}];const rj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class SWe extends AF{constructor(e){super(e,rj)}static setup(){return window.addEventListener(rj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(rj.move.name,e)};function e(){}}}SWe.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 $0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})($0||($0={}));var mk;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(mk||(mk={}));function NWe(t){let{acceleration:e,activator:n=$0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:o=5,order:l=mk.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:h,threshold:p}=t;const m=MWe({delta:h,disabled:!s}),[b,y]=I9e(),x=_.useRef({x:0,y:0}),v=_.useRef({x:0,y:0}),S=_.useMemo(()=>{switch(n){case $0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case $0.DraggableRect:return i}},[n,i,c]),N=_.useRef(null),T=_.useCallback(()=>{const A=N.current;if(!A)return;const k=x.current.x*v.current.x,R=x.current.y*v.current.y;A.scrollBy(k,R)},[]),M=_.useMemo(()=>l===mk.TreeOrder?[...u].reverse():u,[l,u]);_.useEffect(()=>{if(!s||!u.length||!S){y();return}for(const A of M){if(r?.(A)===!1)continue;const k=u.indexOf(A),R=d[k];if(!R)continue;const{direction:C,speed:P}=dWe(A,R,S,e,p);for(const U of["x","y"])m[U][C[U]]||(P[U]=0,C[U]=0);if(P.x>0||P.y>0){y(),N.current=A,b(T,o),x.current=P,v.current=C;return}}x.current={x:0,y:0},v.current={x:0,y:0},y()},[e,T,r,y,s,o,JSON.stringify(S),JSON.stringify(m),b,u,M,d,JSON.stringify(p)])}const kWe={x:{[ya.Backward]:!1,[ya.Forward]:!1},y:{[ya.Backward]:!1,[ya.Forward]:!1}};function MWe(t){let{delta:e,disabled:n}=t;const r=SR(e);return Tv(i=>{if(n||!r||!i)return kWe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[ya.Backward]:i.x[ya.Backward]||s.x===-1,[ya.Forward]:i.x[ya.Forward]||s.x===1},y:{[ya.Backward]:i.y[ya.Backward]||s.y===-1,[ya.Forward]:i.y[ya.Forward]||s.y===1}}},[n,e,r])}function EWe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Tv(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function TWe(t,e){return _.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...s]},[]),[t,e])}var zy;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(zy||(zy={}));var ER;(function(t){t.Optimized="optimized"})(ER||(ER={}));const A9=new Map;function AWe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,o]=_.useState(null),{frequency:l,measure:c,strategy:u}=i,d=_.useRef(t),h=x(),p=Fy(h),m=_.useCallback(function(v){v===void 0&&(v=[]),!p.current&&o(S=>S===null?v:S.concat(v.filter(N=>!S.includes(N))))},[p]),b=_.useRef(null),y=Tv(v=>{if(h&&!n)return A9;if(!v||v===A9||d.current!==t||s!=null){const S=new Map;for(let N of t){if(!N)continue;if(s&&s.length>0&&!s.includes(N.id)&&N.rect.current){S.set(N.id,N.rect.current);continue}const T=N.node.current,M=T?new TF(c(T),T):null;N.rect.current=M,M&&S.set(N.id,M)}return S}return v},[t,s,n,h,c]);return _.useEffect(()=>{d.current=t},[t]),_.useEffect(()=>{h||m()},[n,h]),_.useEffect(()=>{s&&s.length>0&&o(null)},[JSON.stringify(s)]),_.useEffect(()=>{h||typeof l!="number"||b.current!==null||(b.current=setTimeout(()=>{m(),b.current=null},l))},[l,h,m,...r]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:s!=null};function x(){switch(u){case zy.Always:return!1;case zy.BeforeDragging:return n;default:return!n}}}function Xre(t,e){return Tv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function CWe(t,e){return Xre(t,e)}function PWe(t){let{callback:e,disabled:n}=t;const r=MF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function i2(t){let{callback:e,disabled:n}=t;const r=MF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function jWe(t){return new TF(Wb(t),t)}function C9(t,e,n){e===void 0&&(e=jWe);const[r,i]=_.useState(null);function s(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=PWe({callback(c){if(t)for(const u of c){const{type:d,target:h}=u;if(d==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),l=i2({callback:s});return Ac(()=>{s(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function DWe(t){const e=Xre(t);return Bre(t,e)}const P9=[];function RWe(t){const e=_.useRef(t),n=Tv(r=>t?r&&r!==P9&&t&&e.current&&t.parentNode===e.current.parentNode?r:t2(t):P9,[t]);return _.useEffect(()=>{e.current=t},[t]),n}function OWe(t){const[e,n]=_.useState(null),r=_.useRef(t),i=_.useCallback(s=>{const o=tj(s.target);o&&n(l=>l?(l.set(o,kR(o)),new Map(l)):null)},[]);return _.useEffect(()=>{const s=r.current;if(t!==s){o(s);const l=t.map(c=>{const u=tj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,kR(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(s)};function o(l){l.forEach(c=>{const u=tj(c);u?.removeEventListener("scroll",i)})}},[i,t]),_.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,o)=>Vg(s,o),Vl):Wre(t):Vl,[t,e])}function j9(t,e){e===void 0&&(e=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},e),_.useEffect(()=>{const r=t!==Vl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?Iy(t,n.current):Vl}function LWe(t){_.useEffect(()=>{if(!e2)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 FWe(t,e){return _.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=o=>{s(o,e)},n},{}),[t,e])}function Yre(t){return _.useMemo(()=>t?oWe(t):null,[t])}const D9=[];function IWe(t,e){e===void 0&&(e=Wb);const[n]=t,r=Yre(n?Zs(n):null),[i,s]=_.useState(D9);function o(){s(()=>t.length?t.map(c=>Gre(c)?r:new TF(e(c),c)):D9)}const l=i2({callback:o});return Ac(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function zWe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Ev(e)?e:t}function UWe(t){let{measure:e}=t;const[n,r]=_.useState(null),i=_.useCallback(u=>{for(const{target:d}of u)if(Ev(d)){r(h=>{const p=e(d);return h?{...h,width:p.width,height:p.height}:p});break}},[e]),s=i2({callback:i}),o=_.useCallback(u=>{const d=zWe(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[l,c]=dk(o);return _.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const BWe=[{sensor:r2,options:{}},{sensor:n2,options:{}}],HWe={current:{}},J1={draggable:{measure:k9},droppable:{measure:k9,strategy:zy.WhileDragging,frequency:ER.Optimized},dragOverlay:{measure:Wb}};class V0 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const $We={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new V0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:hk},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:J1,measureDroppableContainers:hk,windowRect:null,measuringScheduled:!1},VWe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:hk,draggableNodes:new Map,over:null,measureDroppableContainers:hk},a2=_.createContext(VWe),Qre=_.createContext($We);function GWe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new V0}}}function qWe(t,e){switch(e.type){case Qi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Qi.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 Qi.DragEnd:case Qi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Qi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new V0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Qi.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const o=new V0(t.droppable.containers);return o.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Qi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new V0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function WWe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=_.useContext(a2),s=SR(r),o=SR(n?.id);return _.useEffect(()=>{if(!e&&!r&&s&&o!=null){if(!EF(s)||document.activeElement===s.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const h=B9e(d);if(h){h.focus();break}}})}},[r,e,i,o,s]),null}function KWe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function XWe(t){return _.useMemo(()=>({draggable:{...J1.draggable,...t?.draggable},droppable:{...J1.droppable,...t?.droppable},dragOverlay:{...J1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function YWe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=_.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Ac(()=>{if(!o&&!l||!e){s.current=!1;return}if(s.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),h=Bre(d,r);if(o||(h.x=0),l||(h.y=0),s.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const p=Hre(u);p&&p.scrollBy({top:h.y,left:h.x})}},[e,o,l,r,n])}const Zre=_.createContext({...Vl,scaleX:1,scaleY:1});var nh;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(nh||(nh={}));const Jre=_.memo(function(e){var n,r,i,s;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=BWe,collisionDetection:h=eWe,measuring:p,modifiers:m,...b}=e;const y=_.useReducer(qWe,void 0,GWe),[x,v]=y,[S,N]=W9e(),[T,M]=_.useState(nh.Uninitialized),A=T===nh.Initialized,{draggable:{active:k,nodes:R,translate:C},droppable:{containers:P}}=x,U=k!=null?R.get(k):null,F=_.useRef({initial:null,translated:null}),B=_.useMemo(()=>{var Ke;return k!=null?{id:k,data:(Ke=U?.data)!=null?Ke:HWe,rect:F}:null},[k,U]),D=_.useRef(null),[$,G]=_.useState(null),[I,K]=_.useState(null),Q=Fy(b,Object.values(b)),se=Av("DndDescribedBy",o),H=_.useMemo(()=>P.getEnabled(),[P]),W=XWe(p),{droppableRects:J,measureDroppableContainers:ne,measuringScheduled:xe}=AWe(H,{dragging:A,dependencies:[C.x,C.y],config:W.droppable}),ue=EWe(R,k),fe=_.useMemo(()=>I?NR(I):null,[I]),De=Ae(),oe=CWe(ue,W.draggable.measure);YWe({activeNode:k!=null?R.get(k):null,config:De.layoutShiftCompensation,initialRect:oe,measure:W.draggable.measure});const Ne=C9(ue,W.draggable.measure,oe),Fe=C9(ue?ue.parentElement:null),ce=_.useRef({activatorEvent:null,active:null,activeNode:ue,collisionRect:null,collisions:null,droppableRects:J,draggableNodes:R,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ve=P.getNodeFor((n=ce.current.over)==null?void 0:n.id),V=UWe({measure:W.dragOverlay.measure}),Y=(r=V.nodeRef.current)!=null?r:ue,de=A?(i=V.rect)!=null?i:Ne:null,q=!!(V.nodeRef.current&&V.rect),re=DWe(q?null:Ne),X=Yre(Y?Zs(Y):null),le=RWe(A?Ve??ue:null),pe=IWe(le),ee=KWe(m,{transform:{x:C.x-re.x,y:C.y-re.y,scaleX:1,scaleY:1},activatorEvent:I,active:B,activeNodeRect:Ne,containerNodeRect:Fe,draggingNodeRect:de,over:ce.current.over,overlayNodeRect:V.rect,scrollableAncestors:le,scrollableAncestorRects:pe,windowRect:X}),z=fe?Vg(fe,C):null,O=OWe(le),Z=j9(O),me=j9(O,[Ne]),Te=Vg(ee,Z),ke=de?rWe(de,ee):null,Ee=B&&ke?h({active:B,collisionRect:ke,droppableRects:J,droppableContainers:H,pointerCoordinates:z}):null,Se=zre(Ee,"id"),[$e,Qe]=_.useState(null),Ue=q?ee:Vg(ee,me),be=tWe(Ue,(s=$e?.rect)!=null?s:null,Ne),ve=_.useRef(null),ze=_.useCallback((Ke,je)=>{let{sensor:Re,options:we}=je;if(D.current==null)return;const qe=R.get(D.current);if(!qe)return;const xt=Ke.nativeEvent,Et=new Re({active:D.current,activeNode:qe,event:xt,options:we,context:ce,onAbort(It){if(!R.get(It))return;const{onDragAbort:yt}=Q.current,Wt={id:It};yt?.(Wt),S({type:"onDragAbort",event:Wt})},onPending(It,Oe,yt,Wt){if(!R.get(It))return;const{onDragPending:Qt}=Q.current,ur={id:It,constraint:Oe,initialCoordinates:yt,offset:Wt};Qt?.(ur),S({type:"onDragPending",event:ur})},onStart(It){const Oe=D.current;if(Oe==null)return;const yt=R.get(Oe);if(!yt)return;const{onDragStart:Wt}=Q.current,rn={activatorEvent:xt,active:{id:Oe,data:yt.data,rect:F}};Su.unstable_batchedUpdates(()=>{Wt?.(rn),M(nh.Initializing),v({type:Qi.DragStart,initialCoordinates:It,active:Oe}),S({type:"onDragStart",event:rn}),G(ve.current),K(xt)})},onMove(It){v({type:Qi.DragMove,coordinates:It})},onEnd:fn(Qi.DragEnd),onCancel:fn(Qi.DragCancel)});ve.current=Et;function fn(It){return async function(){const{active:yt,collisions:Wt,over:rn,scrollAdjustedTranslate:Qt}=ce.current;let ur=null;if(yt&&Qt){const{cancelDrop:Lr}=Q.current;ur={activatorEvent:xt,active:yt,collisions:Wt,delta:Qt,over:rn},It===Qi.DragEnd&&typeof Lr=="function"&&await Promise.resolve(Lr(ur))&&(It=Qi.DragCancel)}D.current=null,Su.unstable_batchedUpdates(()=>{v({type:It}),M(nh.Uninitialized),Qe(null),G(null),K(null),ve.current=null;const Lr=It===Qi.DragEnd?"onDragEnd":"onDragCancel";if(ur){const nr=Q.current[Lr];nr?.(ur),S({type:Lr,event:ur})}})}}},[R]),Ce=_.useCallback((Ke,je)=>(Re,we)=>{const qe=Re.nativeEvent,xt=R.get(we);if(D.current!==null||!xt||qe.dndKit||qe.defaultPrevented)return;const Et={active:xt};Ke(Re,je.options,Et)===!0&&(qe.dndKit={capturedBy:je.sensor},D.current=we,ze(Re,je))},[R,ze]),Ge=TWe(d,Ce);LWe(d),Ac(()=>{Ne&&T===nh.Initializing&&M(nh.Initialized)},[Ne,T]),_.useEffect(()=>{const{onDragMove:Ke}=Q.current,{active:je,activatorEvent:Re,collisions:we,over:qe}=ce.current;if(!je||!Re)return;const xt={active:je,activatorEvent:Re,collisions:we,delta:{x:Te.x,y:Te.y},over:qe};Su.unstable_batchedUpdates(()=>{Ke?.(xt),S({type:"onDragMove",event:xt})})},[Te.x,Te.y]),_.useEffect(()=>{const{active:Ke,activatorEvent:je,collisions:Re,droppableContainers:we,scrollAdjustedTranslate:qe}=ce.current;if(!Ke||D.current==null||!je||!qe)return;const{onDragOver:xt}=Q.current,Et=we.get(Se),fn=Et&&Et.rect.current?{id:Et.id,rect:Et.rect.current,data:Et.data,disabled:Et.disabled}:null,It={active:Ke,activatorEvent:je,collisions:Re,delta:{x:qe.x,y:qe.y},over:fn};Su.unstable_batchedUpdates(()=>{Qe(fn),xt?.(It),S({type:"onDragOver",event:It})})},[Se]),Ac(()=>{ce.current={activatorEvent:I,active:B,activeNode:ue,collisionRect:ke,collisions:Ee,droppableRects:J,draggableNodes:R,draggingNode:Y,draggingNodeRect:de,droppableContainers:P,over:$e,scrollableAncestors:le,scrollAdjustedTranslate:Te},F.current={initial:de,translated:ke}},[B,ue,Ee,ke,R,Y,de,J,P,$e,le,Te]),NWe({...De,delta:C,draggingRect:ke,pointerCoordinates:z,scrollableAncestors:le,scrollableAncestorRects:pe});const _e=_.useMemo(()=>({active:B,activeNode:ue,activeNodeRect:Ne,activatorEvent:I,collisions:Ee,containerNodeRect:Fe,dragOverlay:V,draggableNodes:R,droppableContainers:P,droppableRects:J,over:$e,measureDroppableContainers:ne,scrollableAncestors:le,scrollableAncestorRects:pe,measuringConfiguration:W,measuringScheduled:xe,windowRect:X}),[B,ue,Ne,I,Ee,Fe,V,R,P,J,$e,ne,le,pe,W,xe,X]),Je=_.useMemo(()=>({activatorEvent:I,activators:Ge,active:B,activeNodeRect:Ne,ariaDescribedById:{draggable:se},dispatch:v,draggableNodes:R,over:$e,measureDroppableContainers:ne}),[I,Ge,B,Ne,v,se,R,$e,ne]);return ri.createElement(Ore.Provider,{value:N},ri.createElement(a2.Provider,{value:Je},ri.createElement(Qre.Provider,{value:_e},ri.createElement(Zre.Provider,{value:be},u)),ri.createElement(WWe,{disabled:l?.restoreFocus===!1})),ri.createElement(Y9e,{...l,hiddenTextDescribedById:se}));function Ae(){const Ke=$?.autoScrollEnabled===!1,je=typeof c=="object"?c.enabled===!1:c===!1,Re=A&&!Ke&&!je;return typeof c=="object"?{...c,enabled:Re}:{enabled:Re}}}),QWe=_.createContext(null),R9="button",ZWe="Draggable";function JWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=Av(ZWe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:h,over:p}=_.useContext(a2),{role:m=R9,roleDescription:b="draggable",tabIndex:y=0}=i??{},x=c?.id===e,v=_.useContext(x?Zre:QWe),[S,N]=dk(),[T,M]=dk(),A=FWe(o,e),k=Fy(n);Ac(()=>(h.set(e,{id:e,key:s,node:S,activatorNode:T,data:k}),()=>{const C=h.get(e);C&&C.key===s&&h.delete(e)}),[h,e]);const R=_.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":r,"aria-pressed":x&&m===R9?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,m,y,x,b,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:R,isDragging:x,listeners:r?void 0:A,node:S,over:p,setNodeRef:N,setActivatorNodeRef:M,transform:v}}function eKe(){return _.useContext(Qre)}const tKe="Droppable",nKe={timeout:25};function rKe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=Av(tKe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=_.useContext(a2),d=_.useRef({disabled:n}),h=_.useRef(!1),p=_.useRef(null),m=_.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:x}={...nKe,...i},v=Fy(y??r),S=_.useCallback(()=>{if(!h.current){h.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),m.current=null},x)},[x]),N=i2({callback:S,disabled:b||!o}),T=_.useCallback((R,C)=>{N&&(C&&(N.unobserve(C),h.current=!1),R&&N.observe(R))},[N]),[M,A]=dk(T),k=Fy(e);return _.useEffect(()=>{!N||!M.current||(N.disconnect(),h.current=!1,N.observe(M.current))},[M,N]),_.useEffect(()=>(l({type:Qi.RegisterDroppable,element:{id:r,key:s,disabled:n,node:M,rect:p,data:k}}),()=>l({type:Qi.UnregisterDroppable,key:s,id:r})),[r]),_.useEffect(()=>{n!==d.current.disabled&&(l({type:Qi.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,l]),{active:o,rect:p,isOver:c?.id===r,node:M,over:c,setNodeRef:A}}function s2(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function iKe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function S1(t){return t!==null&&t>=0}function aKe(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 sKe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const CF=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=s2(e,r,n),o=e[i],l=s[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},N1={scaleX:1,scaleY:1},oKe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:o}=t;const l=(e=s[n])!=null?e:r;if(!l)return null;if(i===n){const u=s[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...N1}:null}const c=lKe(s,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...N1}:i<n&&i>=o?{x:0,y:l.height+c,...N1}:{x:0,y:0,...N1}};function lKe(t,e,n){const r=t[e],i=t[e-1],s=t[e+1];return r?n<e?i?r.top-(i.top+i.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const eie="Sortable",tie=ri.createContext({activeIndex:-1,containerId:eie,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:CF,disabled:{draggable:!1,droppable:!1}});function nie(t){let{children:e,id:n,items:r,strategy:i=CF,disabled:s=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=eKe(),h=Av(eie,n),p=l.rect!==null,m=_.useMemo(()=>r.map(A=>typeof A=="object"&&"id"in A?A.id:A),[r]),b=o!=null,y=o?m.indexOf(o.id):-1,x=u?m.indexOf(u.id):-1,v=_.useRef(m),S=!aKe(m,v.current),N=x!==-1&&y===-1||S,T=sKe(s);Ac(()=>{S&&b&&d(m)},[S,m,b,d]),_.useEffect(()=>{v.current=m},[m]);const M=_.useMemo(()=>({activeIndex:y,containerId:h,disabled:T,disableTransforms:N,items:m,overIndex:x,useDragOverlay:p,sortedRects:iKe(m,c),strategy:i}),[y,h,T.draggable,T.droppable,N,m,x,c,p,i]);return ri.createElement(tie.Provider,{value:M},e)}const cKe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return s2(n,r,i).indexOf(e)},uKe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==s&&i===o?!1:n?!0:o!==i&&e===c},dKe={duration:200,easing:"ease"},rie="transform",hKe=_b.Transition.toString({property:rie,duration:0,easing:"linear"}),fKe={roleDescription:"sortable"};function mKe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,o]=_.useState(null),l=_.useRef(n);return Ac(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Wb(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(()=>{s&&o(null)},[s]),s}function iie(t){let{animateLayoutChanges:e=uKe,attributes:n,disabled:r,data:i,getNewIndex:s=cKe,id:o,strategy:l,resizeObserverConfig:c,transition:u=dKe}=t;const{items:d,containerId:h,activeIndex:p,disabled:m,disableTransforms:b,sortedRects:y,overIndex:x,useDragOverlay:v,strategy:S}=_.useContext(tie),N=pKe(r,m),T=d.indexOf(o),M=_.useMemo(()=>({sortable:{containerId:h,index:T,items:d},...i}),[h,i,T,d]),A=_.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:k,node:R,isOver:C,setNodeRef:P}=rKe({id:o,data:M,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:A,...c}}),{active:U,activatorEvent:F,activeNodeRect:B,attributes:D,setNodeRef:$,listeners:G,isDragging:I,over:K,setActivatorNodeRef:Q,transform:se}=JWe({id:o,data:M,attributes:{...fKe,...n},disabled:N.draggable}),H=F9e(P,$),W=!!U,J=W&&!b&&S1(p)&&S1(x),ne=!v&&I,xe=ne&&J?se:null,fe=J?xe??(l??S)({rects:y,activeNodeRect:B,activeIndex:p,overIndex:x,index:T}):null,De=S1(p)&&S1(x)?s({id:o,items:d,activeIndex:p,overIndex:x}):T,oe=U?.id,Ne=_.useRef({activeId:oe,items:d,newIndex:De,containerId:h}),Fe=d!==Ne.current.items,ce=e({active:U,containerId:h,isDragging:I,isSorting:W,id:o,index:T,items:d,newIndex:Ne.current.newIndex,previousItems:Ne.current.items,previousContainerId:Ne.current.containerId,transition:u,wasDragging:Ne.current.activeId!=null}),Ve=mKe({disabled:!ce,index:T,node:R,rect:k});return _.useEffect(()=>{W&&Ne.current.newIndex!==De&&(Ne.current.newIndex=De),h!==Ne.current.containerId&&(Ne.current.containerId=h),d!==Ne.current.items&&(Ne.current.items=d)},[W,De,h,d]),_.useEffect(()=>{if(oe===Ne.current.activeId)return;if(oe!=null&&Ne.current.activeId==null){Ne.current.activeId=oe;return}const Y=setTimeout(()=>{Ne.current.activeId=oe},50);return()=>clearTimeout(Y)},[oe]),{active:U,activeIndex:p,attributes:D,data:M,rect:k,index:T,newIndex:De,items:d,isOver:C,isSorting:W,isDragging:I,listeners:G,node:R,overIndex:x,over:K,setNodeRef:H,setActivatorNodeRef:Q,setDroppableNodeRef:P,setDraggableNodeRef:$,transform:Ve??fe,transition:V()};function V(){if(Ve||Fe&&Ne.current.newIndex===T)return hKe;if(!(ne&&!EF(F)||!u)&&(W||ce))return _b.Transition.toString({...u,property:rie})}}function pKe(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 pk(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 gKe=[Yn.Down,Yn.Right,Yn.Up,Yn.Left],aie=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:o,scrollableAncestors:l}}=e;if(gKe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const p=i.get(h.id);if(p)switch(t.code){case Yn.Down:r.top<p.top&&c.push(h);break;case Yn.Up:r.top>p.top&&c.push(h);break;case Yn.Left:r.left>p.left&&c.push(h);break;case Yn.Right:r.left<p.left&&c.push(h);break}});const u=Z9e({collisionRect:r,droppableRects:i,droppableContainers:c});let d=zre(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const h=s.get(n.id),p=s.get(d),m=p?i.get(p.id):null,b=p?.node.current;if(b&&m&&h&&p){const x=t2(b).some((A,k)=>l[k]!==A),v=sie(h,p),S=bKe(h,p),N=x||!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 N.x&&N.y?T:Iy(T,N)}}}};function sie(t,e){return!pk(t)||!pk(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function bKe(t,e){return!pk(t)||!pk(e)||!sie(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function oie(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 xKe(t,e="system",n){if(!t)return n?.("queue.time.asap")??"ASAP";const r=Ui(t);if(!r)return n?.("queue.time.asap")??"ASAP";const i=new Date,s=r.getTime()-i.getTime();return s<-6e4?n?.("queue.time.overdue")??"Overdue":s<0?n?.("queue.time.now")??"Now":s<6e4?n?.("queue.time.lessThanMinute")??"In less than a minute":s<36e5?n?.("queue.time.inMinutes",{count:Math.round(s/6e4)})??`In ${Math.round(s/6e4)} min`:s<864e5?n?.("queue.time.inHours",{count:Math.round(s/36e5)})??`In ${Math.round(s/36e5)} hours`:Yg(t,e)}function yKe({status:t,waitingReason:e,printerState:n,t:r}){if(t==="pending"&&e)return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-purple-400 bg-purple-400/10 border-purple-400/20",children:[a.jsx(er,{className:"w-3.5 h-3.5"}),r("queue.status.waiting")]});if(t==="printing"&&(n==="PAUSE"||n==="PAUSED"))return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-yellow-400 bg-yellow-400/10 border-yellow-400/20",children:[a.jsx(Ak,{className:"w-3.5 h-3.5"}),r("queue.status.paused")]});const i={pending:{icon:er,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:r("queue.status.pending")},printing:{icon:To,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:r("queue.status.printing")},completed:{icon:fr,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:r("queue.status.completed")},failed:{icon:Ji,color:"text-status-error bg-status-error/10 border-status-error/20",label:r("queue.status.failed")},skipped:{icon:QR,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:r("queue.status.skipped")},cancelled:{icon:Lt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:r("queue.status.cancelled")}},{icon:s,color:o,label:l}=i[t];return a.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${o}`,children:[a.jsx(s,{className:"w-3.5 h-3.5"}),l]})}function vKe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,t:s}){const[o,l]=_.useState("unchanged"),[c,u]=_.useState("unchanged"),[d,h]=_.useState("unchanged"),[p,m]=_.useState("unchanged"),[b,y]=_.useState("unchanged"),[x,v]=_.useState("unchanged"),[S,N]=_.useState("unchanged"),[T,M]=_.useState("unchanged"),[A,k]=_.useState("unchanged"),[R,C]=_.useState("unchanged"),P=()=>{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),b!=="unchanged"&&(F.bed_levelling=b),x!=="unchanged"&&(F.flow_cali=x),S!=="unchanged"&&(F.vibration_cali=S),T!=="unchanged"&&(F.layer_inspect=T),A!=="unchanged"&&(F.timelapse=A),R!=="unchanged"&&(F.use_ams=R),n(F)},U=o!=="unchanged"||c!=="unchanged"||d!=="unchanged"||p!=="unchanged"||b!=="unchanged"||x!=="unchanged"||S!=="unchanged"||T!=="unchanged"||A!=="unchanged"||R!=="unchanged";return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:s("queue.bulkEdit.title",{count:t})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:s("queue.bulkEdit.description")}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printer")}),a.jsxs("select",{value:o===null?"null":o==="unchanged"?"unchanged":String(o),onChange:F=>{const B=F.target.value;l(B==="unchanged"?"unchanged":B==="null"?null:Number(B))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"unchanged",children:s("queue.bulkEdit.noChange")}),a.jsx("option",{value:"null",children:s("queue.filter.unassigned")}),e.map(F=>a.jsx("option",{value:F.id,children:F.name},F.id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.queueOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(fu,{label:s("queue.bulkEdit.staged"),value:c,onChange:u,t:s}),a.jsx(fu,{label:s("queue.bulkEdit.autoPowerOff"),value:d,onChange:h,t:s}),a.jsx(fu,{label:s("queue.bulkEdit.requirePrevious"),value:p,onChange:m,t:s})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(fu,{label:s("queue.bulkEdit.bedLevelling"),value:b,onChange:y,t:s}),a.jsx(fu,{label:s("queue.bulkEdit.flowCalibration"),value:x,onChange:v,t:s}),a.jsx(fu,{label:s("queue.bulkEdit.vibrationCalibration"),value:S,onChange:N,t:s}),a.jsx(fu,{label:s("queue.bulkEdit.layerInspection"),value:T,onChange:M,t:s}),a.jsx(fu,{label:s("queue.bulkEdit.timelapse"),value:A,onChange:k,t:s}),a.jsx(fu,{label:s("queue.bulkEdit.useAms"),value:R,onChange:C,t:s})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Me,{variant:"secondary",onClick:r,children:s("common.cancel")}),a.jsx(Me,{onClick:P,disabled:!U||i,children:s(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function fu({label:t,value:e,onChange:n,t:r}){return a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[a.jsx("button",{onClick:()=>n("unchanged"),className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"}`,children:"—"}),a.jsx("button",{onClick:()=>n(!1),className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"}`,children:r("common.off")}),a.jsx("button",{onClick:()=>n(!0),className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"}`,children:r("common.on")})]})]})}function ij({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d,hasPermission:h,canModify:p,printerState:m,t:b}){const y=h("queue:reorder"),{attributes:x,listeners:v,setNodeRef:S,transform:N,transition:T,isDragging:M}=iie({id:t.id,disabled:t.status!=="pending"||!y}),A={transform:_b.Transform.toString(N),transition:T},k=t.status==="printing",R=t.status==="pending",C=["completed","failed","skipped","cancelled"].includes(t.status);return a.jsx("div",{ref:S,style:A,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${M?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${k?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:a.jsxs("div",{className:"flex items-center gap-4 p-4",children:[R&&d&&a.jsx("button",{onClick:P=>{P.stopPropagation(),d()},className:`flex items-center justify-center w-6 h-6 rounded border transition-colors ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&a.jsx(Vi,{className:"w-4 h-4"})}),R?a.jsx("div",{...x,...v,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:a.jsx(Zf,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?a.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):a.jsx("div",{className:"w-8"}),a.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?a.jsx("img",{src:t.plate_id!=null?ae.getArchivePlateThumbnail(t.archive_id,t.plate_id):ae.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?a.jsx("img",{src:t.plate_id!=null?ae.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):ae.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(is,{className:"w-6 h-6"})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`}),t.archive_id?a.jsx(Us,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:b("queue.viewArchive"),children:a.jsx(Zr,{className:"w-3.5 h-3.5"})}):t.library_file_id?a.jsx(Us,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:b("queue.viewInFileManager"),children:a.jsx(Zr,{className:"w-3.5 h-3.5"})}):null]}),a.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[a.jsxs("span",{className:`flex items-center gap-1.5 ${t.printer_id===null&&!t.target_model?"text-orange-400":""} ${t.target_model?"text-blue-400":""}`,children:[a.jsx(Dr,{className:"w-3.5 h-3.5"}),t.target_model?`${b("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?b("queue.filter.unassigned"):t.printer_name||`${b("common.printer")} #${t.printer_id}`]}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Nu,{className:"w-3.5 h-3.5"}),oie(t.print_time_seconds)]}),t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1.5",title:b("queue.addedBy",{name:t.created_by_username}),children:[a.jsx(qu,{className:"w-3.5 h-3.5"}),t.created_by_username]}),R&&!t.manual_start&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(er,{className:"w-3.5 h-3.5"}),xKe(t.scheduled_time,c,b)]})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&a.jsxs("span",{className:"text-xs px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[a.jsx(UW,{className:"w-3 h-3"}),b("queue.badges.staged")]}),t.require_previous_success&&a.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:b("queue.badges.requiresPrevious")}),t.auto_off_after&&a.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[a.jsx(nd,{className:"w-3 h-3"}),b("queue.badges.autoPowerOff")]})]}),k&&a.jsxs("div",{className:"mt-3",children:[a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:b("queue.printingInProgress")})]}),t.waiting_reason&&t.status==="pending"&&a.jsxs("p",{className:"text-xs text-purple-400 mt-2 flex items-start gap-1",children:[a.jsx(Ti,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),a.jsx("span",{children:t.waiting_reason})]}),t.error_message&&a.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[a.jsx(Ti,{className:"w-3 h-3"}),t.error_message]})]}),a.jsx(yKe,{status:t.status,waitingReason:t.waiting_reason,printerState:m,t:b}),a.jsxs("div",{className:"flex items-center gap-1",children:[k&&a.jsx(Me,{variant:"ghost",size:"sm",onClick:s,disabled:!h("printers:control"),title:h("printers:control")?b("queue.actions.stopPrint"):b("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(yue,{className:"w-4 h-4"})}),R&&a.jsxs(a.Fragment,{children:[t.manual_start&&a.jsx(Me,{variant:"ghost",size:"sm",onClick:l,disabled:!h("printers:control"),title:h("printers:control")?b("queue.actions.startPrint"):b("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:a.jsx(To,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:n,disabled:!p("queue","update",t.created_by_id),title:p("queue","update",t.created_by_id)?b("common.edit"):b("queue.permissions.noEdit"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:r,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?b("common.cancel"):b("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(Lt,{className:"w-4 h-4"})})]}),C&&a.jsxs(a.Fragment,{children:[a.jsx(Me,{variant:"ghost",size:"sm",onClick:o,disabled:!h("queue:create"),title:h("queue:create")?b("queue.actions.requeue"):b("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:a.jsx(Ir,{className:"w-4 h-4"})}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:i,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?b("common.remove"):b("queue.permissions.noRemove"),children:a.jsx(hn,{className:"w-4 h-4"})})]})]})]})})}function wKe(){const{t}=Yt(),e=nn(),{showToast:n}=kn(),{hasPermission:r,hasAnyPermission:i,canModify:s}=Rr(),[o,l]=_.useState(null),[c,u]=_.useState(""),[d,h]=_.useState(""),[p,m]=_.useState(!1),[b,y]=_.useState(null),[x,v]=_.useState(null),[S,N]=_.useState(null),[T,M]=_.useState([]),[A,k]=_.useState(!1),[R,C]=_.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[P,U]=_.useState(()=>{const ee=localStorage.getItem("queue.historySortAsc");return ee!==null?ee==="true":!1}),[F,B]=_.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[D,$]=_.useState(()=>{const ee=localStorage.getItem("queue.pendingSortAsc");return ee!==null?ee==="true":!0});_.useEffect(()=>{localStorage.setItem("queue.historySortBy",R)},[R]),_.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(P))},[P]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",F)},[F]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(D))},[D]);const G=Lre(fk(r2,{activationConstraint:{distance:8}}),fk(n2,{coordinateGetter:aie})),{data:I}=nt({queryKey:["settings"],queryFn:ae.getSettings}),K=I?.time_format||"system",{data:Q,isLoading:se}=nt({queryKey:["queue",o,c],queryFn:()=>ae.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:H}=nt({queryKey:["printers"],queryFn:()=>ae.getPrinters()}),W=dt({mutationFn:ee=>ae.cancelQueueItem(ee),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),J=dt({mutationFn:ee=>ae.removeFromQueue(ee),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),ne=dt({mutationFn:ee=>ae.stopQueueItem(ee),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),xe=dt({mutationFn:ee=>ae.startQueueItem(ee),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),ue=dt({mutationFn:ee=>ae.reorderQueue(ee),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),fe=dt({mutationFn:async()=>{const ee=Q?.filter(z=>["completed","failed","skipped","cancelled"].includes(z.status))||[];for(const z of ee)await ae.removeFromQueue(z.id);return ee.length},onSuccess:ee=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:ee}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),De=dt({mutationFn:ee=>ae.bulkUpdateQueue(ee),onSuccess:ee=>{e.invalidateQueries({queryKey:["queue"]}),M([]),k(!1),n(ee.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),oe=dt({mutationFn:async ee=>{for(const z of ee)await ae.cancelQueueItem(z);return ee.length},onSuccess:ee=>{e.invalidateQueries({queryKey:["queue"]}),M([]),n(t("queue.toast.bulkCancelled",{count:ee}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),Ne=ee=>{M(z=>z.includes(ee)?z.filter(O=>O!==ee):[...z,ee])},Fe=_.useMemo(()=>{const ee=new Set;return H?.forEach(z=>{z.location&&ee.add(z.location)}),Q?.forEach(z=>{z.target_location&&ee.add(z.target_location)}),Array.from(ee).sort()},[H,Q]),ce=_.useCallback(ee=>d?ee.target_location?ee.target_location===d:ee.printer_id?H?.find(O=>O.id===ee.printer_id)?.location===d:!1:!0,[d,H]),Ve=_.useMemo(()=>{let ee=Q?.filter(O=>O.status==="pending")||[];d&&(ee=ee.filter(ce));const z=O=>{if(!O.scheduled_time)return 0;const Z=new Date(O.scheduled_time).getTime(),me=Date.now()+4320*60*60*1e3;return Z>me?0:Z};return[...ee].sort((O,Z)=>{let me;if(F==="name"){const Te=O.archive_name||O.library_file_name||"",ke=Z.archive_name||Z.library_file_name||"";me=Te.localeCompare(ke)}else F==="printer"?me=(O.printer_name||"").localeCompare(Z.printer_name||""):F==="time"?me=z(O)-z(Z):me=O.position-Z.position;return D?me:-me})},[Q,F,D,ce,d]),V=()=>{const ee=Ve.map(z=>z.id);T.length===ee.length?M([]):M(ee)},Y=_.useMemo(()=>{let ee=Q?.filter(z=>z.status==="printing")||[];return d&&(ee=ee.filter(ce)),ee},[Q,d,ce]),de=_.useMemo(()=>{const ee=new Set;return Y.forEach(z=>{z.printer_id&&ee.add(z.printer_id)}),Array.from(ee)},[Y]),q=qR({queries:de.map(ee=>({queryKey:["printerStatus",ee],queryFn:()=>ae.getPrinterStatus(ee),refetchInterval:5e3}))}),re=_.useMemo(()=>{const ee={};return de.forEach((z,O)=>{const Z=q[O];Z?.data?.state&&(ee[z]=Z.data.state)}),ee},[de,q]),X=_.useMemo(()=>{let ee=Q?.filter(z=>["completed","failed","skipped","cancelled"].includes(z.status))||[];return d&&(ee=ee.filter(ce)),[...ee].sort((z,O)=>{let Z;if(R==="name"){const me=z.archive_name||z.library_file_name||"",Te=O.archive_name||O.library_file_name||"";Z=me.localeCompare(Te)}else R==="printer"?Z=(z.printer_name||"").localeCompare(O.printer_name||""):Z=new Date(O.completed_at||O.created_at).getTime()-new Date(z.completed_at||z.created_at).getTime();return P?-Z:Z})},[Q,R,P,ce,d]),le=_.useMemo(()=>Ve.reduce((ee,z)=>ee+(z.print_time_seconds||0),0),[Ve]),pe=ee=>{const{active:z,over:O}=ee;if(!O||z.id===O.id)return;const Z=Ve.findIndex(Te=>Te.id===z.id),me=Ve.findIndex(Te=>Te.id===O.id);if(Z!==-1&&me!==-1){const ke=s2(Ve,Z,me).map((Ee,Se)=>({id:Ee.id,position:Se+1}));ue.mutate(ke)}};return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsx("div",{className:"flex items-center justify-between mb-8",children:a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx(BW,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[a.jsx(_t,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:a.jsx(Mt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:a.jsx(To,{className:"w-5 h-5 text-blue-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Y.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.printing")})]})]})})}),a.jsx(_t,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:a.jsx(Mt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:a.jsx(er,{className:"w-5 h-5 text-yellow-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Ve.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.queued")})]})]})})}),a.jsx(_t,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:a.jsx(Mt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:a.jsx(Nu,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:oie(le)}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.totalTime")})]})]})})}),a.jsx(_t,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:a.jsx(Mt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:a.jsx(fr,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:X.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.history")})]})]})})})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o===-1?"unassigned":o||"",onChange:ee=>{const z=ee.target.value;l(z==="unassigned"?-1:z===""?null:Number(z))},children:[a.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),a.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),H?.map(ee=>a.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:ee=>u(ee.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allStatus")}),a.jsx("option",{value:"pending",children:t("queue.status.pending")}),a.jsx("option",{value:"printing",children:t("queue.status.printing")}),a.jsx("option",{value:"completed",children:t("queue.status.completed")}),a.jsx("option",{value:"failed",children:t("queue.status.failed")}),a.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),a.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),Fe.length>0&&a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:d,onChange:ee=>h(ee.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allLocations")}),Fe.map(ee=>a.jsx("option",{value:ee,children:ee},ee))]}),a.jsx("div",{className:"flex-1"}),X.length>0&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>m(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[a.jsx(hn,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),se?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):Q?.length===0?a.jsxs(_t,{className:"p-12 text-center border-dashed",children:[a.jsx(Qr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),a.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:t("queue.empty.title")}),a.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):a.jsxs("div",{className:"space-y-8",children:[Y.length>0&&a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),t("queue.sections.currentlyPrinting")]}),a.jsx("div",{className:"space-y-3",children:Y.map(ee=>a.jsx(ij,{item:ee,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>N({type:"stop",item:ee}),onRequeue:()=>{},onStart:()=>{},timeFormat:K,hasPermission:r,canModify:s,printerState:ee.printer_id?re[ee.printer_id]:null,t},ee.id))})]}),Ve.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(er,{className:"w-5 h-5 text-yellow-400"}),t("queue.sections.queued"),a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Ve.length}),")"]}),a.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:F,onChange:ee=>B(ee.target.value),children:[a.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),a.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>$(!D),title:t(D?"common.ascending":"common.descending"),className:"px-2",children:D?a.jsx(qg,{className:"w-4 h-4"}):a.jsx(Y0,{className:"w-4 h-4"})})]})]}),a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[a.jsxs(Me,{variant:"ghost",size:"sm",onClick:V,className:"flex items-center gap-2",children:[T.length===Ve.length&&Ve.length>0?a.jsx(Ks,{className:"w-4 h-4 text-bambu-green"}):a.jsx(ul,{className:"w-4 h-4"}),T.length===Ve.length&&Ve.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),T.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:T.length})}),a.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),a.jsxs(Me,{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:[a.jsx(ea,{className:"w-4 h-4"}),t("queue.bulkEdit.editSelected")]}),a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>oe.mutate(T),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:oe.isPending||!i("queue:delete_own","queue:delete_all"),title:i("queue:delete_own","queue:delete_all")?void 0:t("queue.permissions.noCancelItems"),children:[a.jsx(Lt,{className:"w-4 h-4"}),t("queue.bulkEdit.cancelSelected")]})]})]}),a.jsx(Jre,{sensors:G,collisionDetection:Ure,onDragEnd:pe,children:a.jsx(nie,{items:Ve.map(ee=>ee.id),strategy:oKe,children:a.jsx("div",{className:"space-y-3",children:Ve.map((ee,z)=>a.jsx(ij,{item:ee,position:z+1,onEdit:()=>y(ee),onCancel:()=>N({type:"cancel",item:ee}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>xe.mutate(ee.id),timeFormat:K,isSelected:T.includes(ee.id),onToggleSelect:()=>Ne(ee.id),hasPermission:r,canModify:s,t},ee.id))})})})]}),X.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(fr,{className:"w-5 h-5 text-bambu-gray"}),t("queue.sections.history"),a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:X.length}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:R,onChange:ee=>C(ee.target.value),children:[a.jsx("option",{value:"date",children:t("queue.sort.byDate")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>U(!P),title:t(P?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:P?a.jsx(qg,{className:"w-4 h-4"}):a.jsx(Y0,{className:"w-4 h-4"})})]})]}),a.jsx("div",{className:"space-y-3",children:X.slice(0,20).map((ee,z)=>a.jsx(ij,{item:ee,position:z+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>N({type:"remove",item:ee}),onStop:()=>{},onRequeue:()=>v(ee),onStart:()=>{},timeFormat:K,hasPermission:r,canModify:s,t},ee.id))})]})]}),b&&a.jsx(Iu,{mode:"edit-queue-item",archiveId:b.archive_id??void 0,libraryFileId:b.library_file_id??void 0,archiveName:b.archive_name||b.library_file_name||`File #${b.archive_id||b.library_file_id}`,queueItem:b,onClose:()=>y(null)}),x&&a.jsx(Iu,{mode:"add-to-queue",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}`,onClose:()=>v(null)}),S&&a.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"?W.mutate(S.item.id):S.type==="stop"?ne.mutate(S.item.id):J.mutate(S.item.id),N(null)},onCancel:()=>N(null)}),p&&a.jsx(Qn,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:X.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{fe.mutate(),m(!1)},onCancel:()=>m(!1)}),A&&a.jsx(vKe,{selectedCount:T.length,printers:H?.map(ee=>({id:ee.id,name:ee.name}))||[],onSave:ee=>{Object.keys(ee).length>0&&De.mutate({item_ids:T,...ee})},onClose:()=>k(!1),isSaving:De.isPending,t})]})}function _Ke({printDates:t,months:e=3}){const n=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{const S=n.current;if(!S)return;const N=new ResizeObserver(T=>{const M=T[0]?.contentRect.width||0;i(M)});return N.observe(S),()=>N.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=_.useMemo(()=>{const S={};t.forEach(U=>{const F=U.split("T")[0];S[F]=(S[F]||0)+1});const N=new Date,T=new Date(N);T.setMonth(T.getMonth()-e),T.setDate(T.getDate()-T.getDay());const M=[],A=[];let k=[],R=-1;const C=new Date(T);let P=0;for(;C<=N;)C.getDay()===0&&k.length>0&&(M.push(k),k=[],P++),C.getMonth()!==R&&(A.push({month:C.toLocaleDateString("en-US",{month:"short"}),weekIndex:P}),R=C.getMonth()),k.push(new Date(C)),C.setDate(C.getDate()+1);return k.length>0&&M.push(k),{weeks:M,monthLabels:A,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const N=S/c;return N<=.25?"bg-bambu-green/30":N<=.5?"bg-bambu-green/50":N<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=s.length,p=32,m=2,b=r-p-16,y=h>0?Math.floor((b-(h-1)*m)/h):12,x=Math.max(8,Math.min(20,y)),v=x<=10?10:12;return a.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&a.jsxs("div",{children:[a.jsx("div",{className:"flex mb-1",style:{marginLeft:p+4},children:o.map(({month:S,weekIndex:N},T)=>a.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:T===0?0:`${(N-(o[T-1]?.weekIndex||0))*(x+m)-24}px`},children:S},T))}),a.jsxs("div",{className:"flex",style:{gap:m},children:[a.jsx("div",{className:"flex flex-col",style:{gap:m,marginRight:4,width:p},children:d.map((S,N)=>a.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:p,height:x,fontSize:v,visibility:N%2===1?"visible":"hidden"},children:S},S))}),s.map((S,N)=>a.jsx("div",{className:"flex flex-col",style:{gap:m},children:[0,1,2,3,4,5,6].map(T=>{const M=S.find(C=>C.getDay()===T);if(!M)return a.jsx("div",{style:{width:x,height:x}},T);const A=M.toISOString().split("T")[0],k=l[A]||0,R=A===new Date().toISOString().split("T")[0];return a.jsx("div",{className:`rounded-sm ${u(k)} ${R?"ring-1 ring-white":""}`,style:{width:x,height:x},title:`${M.toLocaleDateString()}: ${k} print${k!==1?"s":""}`},T)})},N))]}),a.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[a.jsx("span",{children:"Less"}),a.jsxs("div",{className:"flex",style:{gap:m},children:[a.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:x,height:x}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:x,height:x}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:x,height:x}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:x,height:x}}),a.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:x,height:x}})]}),a.jsx("span",{children:"More"})]})]})})}const k1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function SKe(t){const e=new Date;switch(t){case"7d":return new Date(e.getTime()-10080*60*1e3);case"30d":return new Date(e.getTime()-720*60*60*1e3);case"90d":return new Date(e.getTime()-2160*60*60*1e3);case"365d":return new Date(e.getTime()-365*24*60*60*1e3);case"all":return new Date(0)}}function NKe({archives:t,currency:e="$"}){const[n,r]=_.useState("30d"),i=_.useMemo(()=>{const m=SKe(n);return t.filter(b=>(Ui(b.completed_at||b.created_at)||new Date(0))>=m)},[t,n]),s=_.useMemo(()=>{const m=new Map;return i.forEach(b=>{const y=Ui(b.completed_at||b.created_at)||new Date,x=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=m.get(x)||{date:x,filament:0,cost:0,prints:0};v.filament+=b.filament_used_grams||0,v.cost+=b.cost||0,v.prints+=b.quantity||1,m.set(x,v)}),Array.from(m.values()).sort((b,y)=>b.date.localeCompare(y.date)).map(b=>({...b,dateLabel:new Date(b.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=_.useMemo(()=>{if(n==="7d"||n==="30d")return s;const m=new Map;return i.forEach(b=>{const y=Ui(b.completed_at||b.created_at)||new Date,x=new Date(y);x.setDate(y.getDate()-y.getDay());const v=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,S=m.get(v)||{week:v,filament:0,cost:0,prints:0};S.filament+=b.filament_used_grams||0,S.cost+=b.cost||0,S.prints+=b.quantity||1,m.set(v,S)}),Array.from(m.values()).sort((b,y)=>b.week.localeCompare(y.week)).map(b=>({date:b.week,dateLabel:`Week of ${new Date(b.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...b}))},[i,s,n]),l=_.useMemo(()=>{const m=new Map;return i.forEach(b=>{const x=(b.filament_type||"Unknown").split(", ");x.forEach(v=>{const S=(b.filament_used_grams||0)/x.length;m.set(v,(m.get(v)||0)+S)})}),Array.from(m.entries()).map(([b,y])=>({name:b,value:Math.round(y)})).sort((b,y)=>y.value-b.value)},[i]),c=_.useMemo(()=>{const m=new Date,b=[];for(let y=5;y>=0;y--){const x=new Date(m.getFullYear(),m.getMonth()-y,1),v=new Date(m.getFullYear(),m.getMonth()-y+1,0),S=x.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),N=t.filter(T=>{const M=Ui(T.completed_at||T.created_at)||new Date(0);return M>=x&&M<=v});b.push({month:S,filament:Math.round(N.reduce((T,M)=>T+(M.filament_used_grams||0),0)),cost:N.reduce((T,M)=>T+(M.cost||0),0),prints:N.reduce((T,M)=>T+(M.quantity||1),0)})}return b},[t]),u=n==="7d"||n==="30d"?s:o,d=i.reduce((m,b)=>m+(b.filament_used_grams||0),0),h=i.reduce((m,b)=>m+(b.cost||0),0),p=i.reduce((m,b)=>m+(b.quantity||1),0);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),a.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(m=>a.jsx("button",{onClick:()=>r(m),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===m?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:m==="all"?"All":m.replace("d","D")},m))})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,h.toFixed(2)]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[p," prints"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[p>0?(d/p).toFixed(0):0,"g"]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,p>0?(h/p).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),a.jsx(V1,{width:"100%",height:250,children:a.jsxs(s8e,{data:u,children:[a.jsx("defs",{children:a.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[a.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),a.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),a.jsx(pN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(bN,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),a.jsx(xN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(q1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),a.jsx(wee,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):a.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(V1,{width:160,height:160,children:a.jsxs(i8e,{children:[a.jsx(GJ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,b)=>a.jsx(vv,{fill:k1[b%k1.length]},`cell-${b}`))}),a.jsx(q1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m??0}g`,"Usage"]})]})}),a.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,b)=>{const y=l.reduce((v,S)=>v+S.value,0),x=y>0?(m.value/y*100).toFixed(0):0;return a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:k1[b%k1.length]}}),a.jsx("span",{className:"text-white truncate flex-1",children:m.name}),a.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[x,"%"]})]},m.name)})})]}):a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),a.jsx(V1,{width:"100%",height:200,children:a.jsxs(qBe,{data:c,children:[a.jsx(pN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(bN,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),a.jsx(xN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(q1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,b)=>[b==="filament"?`${m??0}g`:b==="cost"?`${e}${Number(m??0).toFixed(2)}`:m??0,b==="filament"?"Filament":b==="cost"?"Cost":"Prints"]}),a.jsx(aL,{}),a.jsx(QJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function kKe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:h,isDragging:p}=iie({id:t}),m={transform:_b.Transform.toString(d),transition:h,opacity:p?.5:1};return r?null:a.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:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:a.jsx(Zf,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),a.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?a.jsx(XR,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):a.jsx(KR,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),a.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:a.jsx(Sk,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),a.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function MKe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:s}){const o=()=>{const T={};return t.forEach(M=>{T[M.id]=M.defaultSize||4}),T},[l,c]=_.useState(()=>{const T=localStorage.getItem(e);if(T)try{const M=JSON.parse(T);return M.sizes||(M.sizes=o()),M}catch{}return{order:t.map(M=>M.id),hidden:t.filter(M=>M.defaultVisible===!1).map(M=>M.id),sizes:o()}}),[u,d]=_.useState(!1);_.useEffect(()=>{const T=()=>d(M=>!M);return window.addEventListener("toggle-hidden-panel",T),()=>window.removeEventListener("toggle-hidden-panel",T)},[]),_.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),_.useEffect(()=>{const M=t.map(A=>A.id).filter(A=>!l.order.includes(A));M.length>0&&c(A=>({...A,order:[...A.order,...M]}))},[t,l.order]);const h=Lre(fk(r2,{activationConstraint:{distance:8}}),fk(n2,{coordinateGetter:aie})),p=T=>{const{active:M,over:A}=T;A&&M.id!==A.id&&c(k=>{const R=k.order.indexOf(M.id),C=k.order.indexOf(A.id);return{...k,order:s2(k.order,R,C)}})},m=T=>{c(M=>({...M,hidden:M.hidden.includes(T)?M.hidden.filter(A=>A!==T):[...M.hidden,T]}))},b=T=>{c(M=>{const A=M.sizes[T]||4,k=A===1?2:A===2?4:1;return{...M,sizes:{...M.sizes,[T]:k}}})},y=()=>{const T={order:t.map(M=>M.id),hidden:t.filter(M=>M.defaultVisible===!1).map(M=>M.id),sizes:o()};c(T),i?.()},x=l.order.map(T=>t.find(M=>M.id===T)).filter(Boolean),v=x.filter(T=>!l.hidden.includes(T.id)),S=x.filter(T=>l.hidden.includes(T.id)),N=s?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return a.jsxs("div",{className:"space-y-4",children:[N,!r&&!s&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:y,children:[a.jsx(Vu,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[a.jsx(vc,{className:"w-4 h-4"}),S.length," Hidden"]})]}),u&&S.length>0&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:S.map(T=>a.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:[a.jsx(vc,{className:"w-3 h-3"}),T.title]},T.id))})]}),a.jsx(Jre,{sensors:h,collisionDetection:Ure,onDragEnd:p,children:a.jsx(nie,{items:v.map(T=>T.id),strategy:CF,children:a.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(T=>a.jsx(kKe,{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:()=>b(T.id)},T.id))})})}),v.length===0&&a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx("p",{children:"All widgets are hidden."}),a.jsx(Me,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}const EKe={USD:"$",EUR:"€",GBP:"£",CHF:"Fr.",JPY:"¥",CNY:"¥",CAD:"$",AUD:"$",INR:"₹",HKD:"HK$",KRW:"₩",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"zł",BRL:"R$",TWD:"NT$",SGD:"S$",NZD:"NZ$",MXN:"MX$",CZK:"Kč",THB:"฿",ZAR:"R",TRY:"₺",RUB:"₽"};function xu(t){return EKe[t.toUpperCase()]||t}const TKe=[{code:"USD",label:"USD ($)"},{code:"EUR",label:"EUR (€)"},{code:"GBP",label:"GBP (£)"},{code:"CHF",label:"CHF (Fr.)"},{code:"JPY",label:"JPY (¥)"},{code:"CNY",label:"CNY (¥)"},{code:"CAD",label:"CAD ($)"},{code:"AUD",label:"AUD ($)"},{code:"INR",label:"INR (₹)"},{code:"HKD",label:"HKD (HK$)"},{code:"KRW",label:"KRW (₩)"},{code:"SEK",label:"SEK (kr)"},{code:"NOK",label:"NOK (kr)"},{code:"DKK",label:"DKK (kr)"},{code:"PLN",label:"PLN (zł)"},{code:"BRL",label:"BRL (R$)"},{code:"TWD",label:"TWD (NT$)"},{code:"SGD",label:"SGD (S$)"},{code:"NZD",label:"NZD (NZ$)"},{code:"MXN",label:"MXN (MX$)"},{code:"CZK",label:"CZK (Kč)"},{code:"THB",label:"THB (฿)"},{code:"ZAR",label:"ZAR (R)"},{code:"TRY",label:"TRY (₺)"},{code:"RUB",label:"RUB (₽)"}];function AKe({stats:t,currency:e,t:n}){return a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(wc,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.totalPrints")}),a.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:a.jsx(er,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.printTime")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:a.jsx(wc,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:a.jsx(Aj,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:a.jsx(Ch,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyUsed")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:a.jsx(Aj,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function CKe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,s=n===1?112:n===2?128:144,o=s/2-8,l=o*2*Math.PI;return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:s,height:s},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i/100*l} ${l}`})]}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i,"%"]})})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(fr,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.successful")}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ji,{className:"w-4 h-4 text-status-error flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),a.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([c,u])=>a.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(c)||`${r("common.printer")} ${c}`}),a.jsx("span",{className:"text-white font-medium",children:u})]},c))})]})]})]})}function PKe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.average_time_accuracy;if(i==null)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,i))-50)/100*100,c=(y=>y>=95&&y<=105?"#00ae42":y>105?"#3b82f6":"#f97316")(i),u=i-100,d=n===1?112:n===2?128:144,h=d/2-8,p=h*2*Math.PI,m=n===1?3:n===2?6:999,b=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,m):[];return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:d,height:d},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*p} ${p}`})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i.toFixed(0),"%"]}),a.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.toFixed(0),"%"]})]})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx(WW,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{children:r("stats.perfectEstimate")})]}),b.length>0&&a.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:b.map(([y,x])=>a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(y)||`${r("common.printer")} ${y}`}),a.jsxs("span",{className:`font-medium ${x>=95&&x<=105?"text-status-ok":x>105?"text-blue-400":"text-status-warning"}`,children:[x.toFixed(0),"%"]})]},y))})]})]})}function jKe({stats:t,size:e=1,t:n}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children: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,s=r.slice(0,i),o=r.length>i;return e===4&&s.length>4?a.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white truncate max-w-[120px]",children:l}),a.jsx("span",{className:"text-bambu-gray",children:c})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)})}):a.jsxs("div",{className:"space-y-3",children:[s.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white",children:l}),a.jsxs("span",{className:"text-bambu-gray",children:[c," ",n("common.prints")]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)}),o&&a.jsx("p",{className:"text-xs text-bambu-gray text-center pt-1",children:n("common.more",{count:r.length-i})})]})}function DKe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return a.jsx(_Ke,{printDates:t,months:n})}function RKe({stats:t,printerMap:e,t:n}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrinterData")}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([r,i])=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:a.jsx(Dr,{className:"w-4 h-4 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-sm",children:e.get(r)||`${n("common.printer")} ${r}`}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," ",n("common.prints")]})]})]},r))})}function OKe({archives:t,currency:e,t:n}){return!t||t.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrintData")}):a.jsx(NKe,{archives:t,currency:e})}function LKe({size:t=1,t:e}){const{data:n,isLoading:r}=nt({queryKey:["failureAnalysis"],queryFn:()=>ae.getFailureAnalysis({days:30})});if(r)return a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!n||n.total_prints===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:e("stats.noPrintDataLast30Days")});const i=t===1?5:t===2?8:999,s=Object.entries(n.failures_by_reason).sort(([,c],[,u])=>u-c),o=s.slice(0,i),l=s.length>i;return a.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[a.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[a.jsx("div",{className:"flex items-center gap-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(En,{className:`w-5 h-5 ${n.failure_rate>20?"text-status-error":n.failure_rate>10?"text-status-warning":"text-status-ok"}`}),a.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[n.failure_rate.toFixed(1),"%"]})]})}),a.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&&a.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(XW,{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"}`}),a.jsx("span",{className:"text-bambu-gray",children:e("stats.lastWeekRate",{rate:n.trend[n.trend.length-1].failure_rate.toFixed(1)})})]})})]}),o.length>0&&a.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?e("stats.failureReasons"):e("stats.topFailureReasons")}),a.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:o.map(([c,u])=>a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:c||e("common.unknown")}),a.jsx("span",{className:"text-bambu-gray ml-2",children:u})]},c))}),l&&a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:e("common.more",{count:s.length-i})})]})]})}function FKe(){const{t}=Yt(),{showToast:e}=kn(),{hasPermission:n}=Rr(),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.useState(0),[u,d]=_.useState(0),[h,p]=_.useState(!1);_.useEffect(()=>{const C=()=>{try{const U=localStorage.getItem("bambusy-dashboard-layout");if(U){const F=JSON.parse(U);d(F.hidden?.length||0)}}catch{d(0)}};C(),window.addEventListener("storage",C);const P=setInterval(C,500);return()=>{window.removeEventListener("storage",C),clearInterval(P)}},[l]);const{data:m,isLoading:b,refetch:y}=nt({queryKey:["archiveStats"],queryFn:ae.getArchiveStats}),{data:x}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:v}=nt({queryKey:["archives"],queryFn:()=>ae.getArchives(void 0,void 0,1e3,0)}),{data:S}=nt({queryKey:["settings"],queryFn:ae.getSettings}),N=async C=>{o(!1),i(!0);try{const{blob:P,filename:U}=await ae.exportStats({format:C,days:90}),F=URL.createObjectURL(P),B=document.createElement("a");B.href=F,B.download=U,B.click(),URL.revokeObjectURL(F),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},T=async()=>{p(!0);try{const C=await ae.recalculateCosts();await y(),e(t("stats.recalculatedCosts",{count:C.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{p(!1)}},M=xu(S?.currency||"USD"),A=new Map(x?.map(C=>[String(C.id),C.name])||[]),k=v?.map(C=>C.created_at)||[];if(b)return a.jsx("div",{className:"p-4 md:p-8",children:a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const R=[{id:"quick-stats",title:t("stats.quickStats"),component:a.jsx(AKe,{stats:m,currency:M,t}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:C=>a.jsx(CKe,{stats:m,printerMap:A,size:C,t}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:C=>a.jsx(PKe,{stats:m,printerMap:A,size:C,t}),defaultSize:1},{id:"filament-types",title:t("stats.filamentTypes"),component:C=>a.jsx(jKe,{stats:m,size:C,t}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:C=>a.jsx(LKe,{size:C,t}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:C=>a.jsx(DKe,{printDates:k,size:C}),defaultSize:2},{id:"prints-by-printer",title:t("stats.printsByPrinter"),component:a.jsx(RKe,{stats:m,printerMap:A,t}),defaultSize:2},{id:"filament-trends",title:t("stats.filamentTrends"),component:a.jsx(OKe,{archives:v||[],currency:M,t}),defaultSize:4}];return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u>0&&a.jsxs(Me,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[a.jsx(vc,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),a.jsxs(Me,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),c(C=>C+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[a.jsx(Vu,{className:"w-4 h-4"}),t("stats.resetLayout")]}),a.jsxs(Me,{variant:"secondary",onClick:T,disabled:h||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[h?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(eue,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),a.jsxs("div",{className:"relative",children:[a.jsxs(Me,{variant:"secondary",onClick:()=>o(!s),disabled:r,children:[r?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(oS,{className:"w-4 h-4"}),t("stats.exportStats")]}),s&&a.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>N("csv"),children:[a.jsx(xs,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>N("xlsx"),children:[a.jsx(oS,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]})]})]}),a.jsx(MKe,{widgets:R,storageKey:"bambusy-dashboard-layout",hideControls:!0},l)]})}function IKe({plug:t,onEdit:e}){const{t:n}=Yt(),r=nn(),{showToast:i}=kn(),[s,o]=_.useState(!1),[l,c]=_.useState(!1),[u,d]=_.useState(!1),[h,p]=_.useState(!1),{data:m,isLoading:b}=nt({queryKey:["smart-plug-status",t.id],queryFn:()=>ae.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:y}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),x=y?.find(P=>P.id===t.printer_id),v=dt({mutationFn:P=>ae.controlSmartPlug(t.id,P),onMutate:async P=>{await r.cancelQueries({queryKey:["smart-plug-status",t.id]});const U=r.getQueryData(["smart-plug-status",t.id]),F=P==="on"?"ON":P==="off"||m?.state==="ON"?"OFF":"ON";return r.setQueryData(["smart-plug-status",t.id],B=>({...B,state:F})),{previousStatus:U}},onError:(P,U,F)=>{F?.previousStatus&&r.setQueryData(["smart-plug-status",t.id],F.previousStatus),i(`Failed to turn ${U} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:["smart-plug-status",t.id]}),r.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),S=dt({mutationFn:P=>ae.updateSmartPlug(t.id,P),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&(r.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]}))}}),N=dt({mutationFn:()=>ae.deleteSmartPlug(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),T=m?.state==="ON",M=t.plug_type==="mqtt"&&m?.energy?.power!==null&&m?.energy?.power!==void 0,A=(m?.reachable??!1)||M,k=v.isPending,C=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const P=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${P}/`:`http://${P}/`})();return a.jsxs(a.Fragment,{children:[a.jsx(_t,{className:"relative",children:a.jsxs(Mt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?A?"bg-teal-500/20":"bg-red-500/20":A?T?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?a.jsx(YR,{className:`w-5 h-5 ${A?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?a.jsx($y,{className:`w-5 h-5 ${A?T?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):a.jsx(sl,{className:`w-5 h-5 ${A?T?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",title:t.plug_type==="mqtt"?t.mqtt_topic??void 0:t.plug_type==="homeassistant"?t.ha_entity_id??void 0:t.ip_address??void 0,children:t.plug_type==="mqtt"?t.mqtt_topic:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[b?a.jsx(lt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?a.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[a.jsx("span",{className:"px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0",children:"MQTT"}),A&&a.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),a.jsx("span",{className:A?T?"text-status-ok":"text-bambu-gray":"text-status-error",children:A?m?.state||"?":"Offline"})]}):A?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx(Pg,{className:"w-4 h-4 text-status-ok"}),a.jsx("span",{className:T?"text-status-ok":"text-bambu-gray",children:m?.state||"Unknown"})]}):a.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[a.jsx(bm,{className:"w-4 h-4"}),a.jsx("span",{children:n("smartPlugs.offline")})]}),C&&a.jsxs("a",{href:C,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:n("smartPlugs.openPlugAdminPage"),children:[a.jsx(Zr,{className:"w-3 h-3"}),n("smartPlugs.admin")]})]})]}),x&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),a.jsx("span",{className:"text-sm text-white",children:x.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full",children:[a.jsx(vc,{className:"w-3 h-3"}),"Monitor Only"]}),t.power_alert_enabled&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[a.jsx(Ag,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[a.jsx(Qr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),t.plug_type!=="mqtt"&&a.jsxs("div",{className:"flex gap-2 mb-3",children:[a.jsxs(Me,{size:"sm",variant:T?"primary":"secondary",disabled:!A||k,onClick:()=>c(!0),className:"flex-1",children:[k?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(nd,{className:"w-4 h-4"}),"On"]}),a.jsxs(Me,{size:"sm",variant:T?"secondary":"primary",disabled:!A||k,onClick:()=>d(!0),className:"flex-1",children:[k?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ck,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&m?.energy&&a.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[m.energy.power!==null&&m.energy.power!==void 0&&a.jsxs("div",{className:"flex-1 text-center",children:[a.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(m.energy.power),"W"]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),m.energy.today!==null&&m.energy.today!==void 0&&a.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-lg font-semibold text-white",children:m.energy.today.toFixed(2)}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),a.jsxs("button",{onClick:()=>p(!h),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(Gu,{className:"w-4 h-4"}),t.plug_type==="mqtt"?"Settings":"Automation Settings"]}),a.jsx("span",{children:h?"-":"+"})]}),h&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ek,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:P=>S.mutate({show_in_switchbar:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.plug_type!=="mqtt"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.enabled,onChange:P=>S.mutate({enabled:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto On"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:P=>S.mutate({auto_on:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:P=>S.mutate({auto_off:P.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&a.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>S.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(er,{className:"w-4 h-4"}),"Time"]}),a.jsxs("button",{onClick:()=>S.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(Dk,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),a.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:P=>S.mutate({off_delay_minutes:parseInt(P.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),a.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:P=>S.mutate({off_temp_threshold:parseInt(P.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(wg,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>o(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(hn,{className:"w-4 h-4"})})]})]})]})}),s&&a.jsx(Qn,{title:n("smartPlugs.deleteSmartPlug"),message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{N.mutate(),o(!1)},onCancel:()=>o(!1)}),l&&a.jsx(Qn,{title:n("smartPlugs.turnOnSmartPlug"),message:`Are you sure you want to turn on "${t.name}"?`,confirmText:n("smartPlugs.turnOn"),variant:"default",onConfirm:()=>{v.mutate("on"),c(!1)},onCancel:()=>c(!1)}),u&&a.jsx(Qn,{title:n("smartPlugs.turnOffSmartPlug"),message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:n("smartPlugs.turnOff"),variant:"danger",onConfirm:()=>{v.mutate("off"),d(!1)},onCancel:()=>d(!1)})]})}function zKe({plug:t,onClose:e}){const{t:n}=Yt(),r=nn(),i=!!t,[s,o]=_.useState(t?.plug_type||"tasmota"),[l,c]=_.useState(t?.name||""),[u,d]=_.useState(t?.ip_address||""),[h,p]=_.useState(t?.username||""),[m,b]=_.useState(t?.password||""),[y,x]=_.useState(t?.ha_entity_id||""),[v,S]=_.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[N,T]=_.useState(t?.mqtt_power_path||""),[M,A]=_.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[k,R]=_.useState(t?.mqtt_energy_topic||""),[C,P]=_.useState(t?.mqtt_energy_path||""),[U,F]=_.useState((t?.mqtt_energy_multiplier??1).toString()),[B,D]=_.useState(t?.mqtt_state_topic||""),[$,G]=_.useState(t?.mqtt_state_path||""),[I,K]=_.useState(t?.mqtt_state_on_value||""),[Q,se]=_.useState(t?.ha_power_entity||""),[H,W]=_.useState(t?.ha_energy_today_entity||""),[J,ne]=_.useState(t?.ha_energy_total_entity||""),[xe,ue]=_.useState(""),[fe,De]=_.useState(""),[oe,Ne]=_.useState(!1),Fe=_.useRef(null),[ce,Ve]=_.useState(""),[V,Y]=_.useState(!1),de=_.useRef(null),[q,re]=_.useState(""),[X,le]=_.useState(!1),pe=_.useRef(null),[ee,z]=_.useState(""),[O,Z]=_.useState(!1),me=_.useRef(null),[Te,ke]=_.useState(t?.printer_id||null),[Ee,Se]=_.useState(null),[$e,Qe]=_.useState(null),[Ue,be]=_.useState(t?.power_alert_enabled||!1),[ve,ze]=_.useState(t?.power_alert_high?.toString()||""),[Ce,Ge]=_.useState(t?.power_alert_low?.toString()||""),[_e,Je]=_.useState(t?.schedule_enabled||!1),[Ae,Ke]=_.useState(t?.schedule_on_time||""),[je,Re]=_.useState(t?.schedule_off_time||""),[we,qe]=_.useState(t?.show_in_switchbar||!1),[xt,Et]=_.useState(t?.show_on_printer_card??!0),[fn,It]=_.useState(!1),[Oe,yt]=_.useState({scanned:0,total:0}),[Wt,rn]=_.useState([]),Qt=_.useRef(null),{data:ur}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:Lr}=nt({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs}),{data:nr}=nt({queryKey:["settings"],queryFn:ae.getSettings}),Xt=!!(nr?.ha_enabled&&nr?.ha_url&&nr?.ha_token);_.useEffect(()=>{const ge=setTimeout(()=>{De(xe)},300);return()=>clearTimeout(ge)},[xe]),_.useEffect(()=>{const ge=rt=>{Fe.current&&!Fe.current.contains(rt.target)&&Ne(!1),de.current&&!de.current.contains(rt.target)&&Y(!1),pe.current&&!pe.current.contains(rt.target)&&le(!1),me.current&&!me.current.contains(rt.target)&&Z(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[]);const{data:Zn,isLoading:oi,error:da}=nt({queryKey:["ha-entities",fe],queryFn:()=>ae.getHAEntities(fe||void 0),enabled:s==="homeassistant"&&Xt,retry:!1,staleTime:0}),{data:Pe}=nt({queryKey:["ha-sensor-entities"],queryFn:ae.getHASensorEntities,enabled:s==="homeassistant"&&Xt,retry:!1,staleTime:0});_.useEffect(()=>{const ge=rt=>{rt.key==="Escape"&&e()};return window.addEventListener("keydown",ge),()=>{window.removeEventListener("keydown",ge),Qt.current&&clearInterval(Qt.current)}},[e]);const tt=async()=>{It(!0),rn([]),yt({scanned:0,total:0}),Qe(null);try{await ae.startTasmotaScan();const ge=async()=>{try{const rt=await ae.getTasmotaScanStatus();yt({scanned:rt.scanned,total:rt.total});const ut=await ae.getDiscoveredTasmotaDevices();rn(ut),rt.running||(It(!1),Qt.current&&(clearInterval(Qt.current),Qt.current=null))}catch(rt){console.error("Polling error:",rt)}};await ge(),Qt.current=setInterval(ge,500)}catch(ge){It(!1);const rt=ge instanceof Error?ge.message:typeof ge=="string"?ge:JSON.stringify(ge);Qe(rt||"Failed to start scan")}},ht=async()=>{try{await ae.stopTasmotaScan()}catch{}It(!1),Qt.current&&(clearInterval(Qt.current),Qt.current=null)},mt=ge=>{d(ge.ip_address),c(ge.name),Se(null)},at=dt({mutationFn:()=>ae.testSmartPlugConnection(u,h||null,m||null),onSuccess:ge=>{Se(ge),Qe(null),!l&&ge.device_name&&c(ge.device_name)},onError:ge=>{Se(null),Qe(ge.message)}}),Dt=dt({mutationFn:ge=>ae.createSmartPlug(ge),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:ge=>{Qe(ge.message)}}),he=dt({mutationFn:ge=>ae.updateSmartPlug(t.id,ge),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:ge=>{Qe(ge.message)}}),Ie=ur?.filter(ge=>s==="tasmota"?!Lr?.some(ut=>ut.printer_id===ge.id&&ut.id!==t?.id&&ut.plug_type==="tasmota"):!0),Xe=ge=>{if(ge.preventDefault(),Qe(null),!l.trim()){Qe("Name is required");return}if(s==="tasmota"&&!u.trim()){Qe("IP address is required for Tasmota plugs");return}if(s==="homeassistant"&&!y){Qe("Entity is required for Home Assistant plugs");return}if(s==="mqtt"){const ut=v.trim(),it=k.trim(),Tt=B.trim();if(!ut&&!it&&!Tt){Qe("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const rt={name:l.trim(),plug_type:s,ip_address:s==="tasmota"?u.trim():null,ha_entity_id:s==="homeassistant"?y:null,ha_power_entity:s==="homeassistant"&&Q||null,ha_energy_today_entity:s==="homeassistant"&&H||null,ha_energy_total_entity:s==="homeassistant"&&J||null,mqtt_power_topic:s==="mqtt"&&v.trim()||null,mqtt_power_path:s==="mqtt"&&N.trim()||null,mqtt_power_multiplier:s==="mqtt"&&parseFloat(M)||1,mqtt_energy_topic:s==="mqtt"&&k.trim()||null,mqtt_energy_path:s==="mqtt"&&C.trim()||null,mqtt_energy_multiplier:s==="mqtt"&&parseFloat(U)||1,mqtt_state_topic:s==="mqtt"&&B.trim()||null,mqtt_state_path:s==="mqtt"&&$.trim()||null,mqtt_state_on_value:s==="mqtt"&&I.trim()||null,username:s==="tasmota"&&h.trim()||null,password:s==="tasmota"&&m.trim()||null,printer_id:Te,power_alert_enabled:Ue,power_alert_high:ve?parseFloat(ve):null,power_alert_low:Ce?parseFloat(Ce):null,schedule_enabled:_e,schedule_on_time:Ae||null,schedule_off_time:je||null,show_in_switchbar:we,show_on_printer_card:xt};i?he.mutate(rt):Dt.mutate(rt)},He=Dt.isPending||he.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:ge=>ge.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Smart Plug":"Add Smart Plug"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Xe,className:"p-6 space-y-4 overflow-y-auto",children:[$e&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:$e}),!i&&a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsxs("button",{type:"button",onClick:()=>{o("tasmota"),Se(null),Qe(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(sl,{className:"w-4 h-4"}),"Tasmota"]}),a.jsxs("button",{type:"button",onClick:()=>{o("homeassistant"),Se(null),Qe(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx($y,{className:"w-4 h-4"}),"HA"]}),a.jsxs("button",{type:"button",onClick:()=>{o("mqtt"),Se(null),Qe(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${s==="mqtt"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(YR,{className:"w-4 h-4"}),"MQTT"]})]}),!i&&s==="tasmota"&&a.jsxs("div",{className:"space-y-3",children:[fn?a.jsxs(Me,{type:"button",variant:"secondary",onClick:ht,className:"w-full",children:[a.jsx(Lt,{className:"w-4 h-4"}),"Stop Scanning"]}):a.jsxs(Me,{type:"button",variant:"primary",onClick:tt,className:"w-full",children:[a.jsx(Zi,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),fn&&Oe.total>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:n("smartPlugs.addSmartPlug.scanningNetwork")}),a.jsxs("span",{children:[Oe.scanned," / ",Oe.total]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Oe.scanned/Oe.total*100}%`}})})]}),Wt.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Wt.length," device(s) - click to select:"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Wt.map(ge=>a.jsxs("button",{type:"button",onClick:()=>mt(ge),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(sl,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:ge.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:ge.ip_address})]})]}),ge.state&&a.jsxs("span",{className:`flex items-center gap-1 text-xs ${ge.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[a.jsx(nd,{className:"w-3 h-3"}),ge.state]})]},ge.ip_address))})]}),!fn&&Wt.length===0&&Oe.total>0&&a.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),s==="homeassistant"&&a.jsxs("div",{className:"space-y-3",children:[!Xt&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),a.jsx("select",{disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50",children:a.jsx("option",{children:n("smartPlugs.addSmartPlug.chooseEntity")})})]})]}),Xt&&a.jsxs(a.Fragment,{children:[oi&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[a.jsx(lt,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),da&&a.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",da.message]}),(()=>{const ge=Lr?.filter(it=>it.ha_entity_id&&it.id!==t?.id).map(it=>it.ha_entity_id)||[],rt=(Zn||[]).filter(it=>!ge.includes(it.entity_id)),ut=Zn?.find(it=>it.entity_id===y);return a.jsxs("div",{ref:Fe,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),a.jsxs("div",{className:"relative",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:oe?xe:ut?`${ut.friendly_name} (${ut.entity_id})`:"",onChange:it=>{ue(it.target.value),oe||Ne(!0)},onFocus:()=>{Ne(!0),ue("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEntities"),className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),y&&!oe&&a.jsx("button",{type:"button",onClick:()=>{x(""),ue("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),oi&&a.jsx(lt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),oe&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[oi&&a.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!oi&&rt.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:fe?`No entities found matching "${fe}"`:"No entities available"}),!oi&&rt.map(it=>a.jsxs("button",{type:"button",onClick:()=>{x(it.entity_id),Ne(!1),ue(""),l||c(it.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${it.entity_id===y?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:it.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[a.jsx("span",{children:it.entity_id}),a.jsx("span",{className:it.state==="on"?"text-bambu-green":"",children:it.state})]})]},it.entity_id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:fe?`Searching all entities (${rt.length} found)`:`Showing switch, light, input_boolean (${rt.length} available)`})]})})(),y&&Pe&&Pe.length>0&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const ge=Pe.filter(it=>it.unit_of_measurement==="W"||it.unit_of_measurement==="kW"||it.unit_of_measurement==="mW"),rt=ce?ge.filter(it=>it.entity_id.toLowerCase().includes(ce.toLowerCase())||it.friendly_name.toLowerCase().includes(ce.toLowerCase())):ge,ut=Pe.find(it=>it.entity_id===Q);return a.jsxs("div",{ref:de,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:V?ce:ut?`${ut.friendly_name} (${ut.state} ${ut.unit_of_measurement})`:"",onChange:it=>{Ve(it.target.value),V||Y(!0)},onFocus:()=>{Y(!0),Ve("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchPowerSensors"),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&&!V&&a.jsx("button",{type:"button",onClick:()=>{se(""),Ve("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),V&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{se(""),Y(!1),Ve("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),rt.map(it=>a.jsxs("button",{type:"button",onClick:()=>{se(it.entity_id),Y(!1),Ve("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${it.entity_id===Q?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:it.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[it.entity_id," • ",it.state," ",it.unit_of_measurement]})]},it.entity_id)),rt.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const ge=Pe.filter(it=>it.unit_of_measurement==="kWh"||it.unit_of_measurement==="Wh"||it.unit_of_measurement==="MWh"),rt=q?ge.filter(it=>it.entity_id.toLowerCase().includes(q.toLowerCase())||it.friendly_name.toLowerCase().includes(q.toLowerCase())):ge,ut=Pe.find(it=>it.entity_id===H);return a.jsxs("div",{ref:pe,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:X?q:ut?`${ut.friendly_name} (${ut.state} ${ut.unit_of_measurement})`:"",onChange:it=>{re(it.target.value),X||le(!0)},onFocus:()=>{le(!0),re("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),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"}),H&&!X&&a.jsx("button",{type:"button",onClick:()=>{W(""),re("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),X&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{W(""),le(!1),re("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),rt.map(it=>a.jsxs("button",{type:"button",onClick:()=>{W(it.entity_id),le(!1),re("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${it.entity_id===H?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:it.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[it.entity_id," • ",it.state," ",it.unit_of_measurement]})]},it.entity_id)),rt.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const ge=Pe.filter(it=>it.unit_of_measurement==="kWh"||it.unit_of_measurement==="Wh"||it.unit_of_measurement==="MWh"),rt=ee?ge.filter(it=>it.entity_id.toLowerCase().includes(ee.toLowerCase())||it.friendly_name.toLowerCase().includes(ee.toLowerCase())):ge,ut=Pe.find(it=>it.entity_id===J);return a.jsxs("div",{ref:me,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:O?ee:ut?`${ut.friendly_name} (${ut.state} ${ut.unit_of_measurement})`:"",onChange:it=>{z(it.target.value),O||Z(!0)},onFocus:()=>{Z(!0),z("")},placeholder:n("smartPlugs.addSmartPlug.placeholders.searchEnergySensors"),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"}),J&&!O&&a.jsx("button",{type:"button",onClick:()=>{ne(""),z("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),O&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{ne(""),Z(!1),z("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),rt.map(it=>a.jsxs("button",{type:"button",onClick:()=>{ne(it.entity_id),Z(!1),z("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${it.entity_id===J?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:it.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[it.entity_id," • ",it.state," ",it.unit_of_measurement]})]},it.entity_id)),rt.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),s==="mqtt"&&a.jsxs("div",{className:"space-y-3",children:[!nr?.mqtt_broker&&a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["MQTT broker not configured. Set broker address in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → MQTT Publishing"})," ","(you don't need to enable publishing, just fill in the broker details)."]}),nr?.mqtt_broker&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),a.jsx("p",{className:"text-xs opacity-80",children:"MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system."})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:v,onChange:ge=>S(ge.target.value),placeholder:"zigbee2mqtt/shelly-working-room",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:N,onChange:ge=>T(ge.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:M,onChange:ge=>A(ge.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:['JSON path extracts value from JSON payload (e.g., "power_l1"). Leave empty if topic publishes raw numeric values.',a.jsx("br",{}),"Use multiplier 0.001 for mW→W, 1000 for kW→W."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["Energy Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:k,onChange:ge=>R(ge.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:C,onChange:ge=>P(ge.target.value),placeholder:"energy_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:U,onChange:ge=>F(ge.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),"Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["State Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:B,onChange:ge=>D(ge.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:$,onChange:ge=>G(ge.target.value),placeholder:"state_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"ON Value"}),a.jsx("input",{type:"text",value:I,onChange:ge=>K(ge.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.mqttStateOnValue"),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),'ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).']})]})]})]}),s==="tasmota"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:u,onChange:ge=>{d(ge.target.value),Se(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>at.mutate(),disabled:!u.trim()||at.isPending,children:[at.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Pg,{className:"w-4 h-4"}),"Test"]})]})]}),s==="tasmota"&&Ee&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${Ee.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:Ee.success?a.jsxs(a.Fragment,{children:[a.jsx(fr,{className:"w-5 h-5"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium",children:"Connected!"}),a.jsxs("p",{className:"text-sm opacity-80",children:[Ee.device_name&&`Device: ${Ee.device_name} - `,"State: ",Ee.state]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(bm,{className:"w-5 h-5"}),a.jsx("span",{children:n("smartPlugs.addSmartPlug.connectionFailed")})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:l,onChange:ge=>c(ge.target.value),placeholder:n("smartPlugs.addSmartPlug.placeholders.plugName"),className:"w-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==="tasmota"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),a.jsx("input",{type:"text",value:h,onChange:ge=>p(ge.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),a.jsx("input",{type:"password",value:m,onChange:ge=>b(ge.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),s!=="mqtt"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),a.jsxs("select",{value:Te??"",onChange:ge=>ke(ge.target.value?Number(ge.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"No printer (manual control only)"}),Ie?.map(ge=>a.jsx("option",{value:ge.id,children:ge.name},ge.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ag,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Ue,onChange:ge=>be(ge.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),Ue&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),a.jsx("input",{type:"number",value:ve,onChange:ge=>ze(ge.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),a.jsx("input",{type:"number",value:Ce,onChange:ge=>Ge(ge.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),s!=="mqtt"&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(er,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:_e,onChange:ge=>Je(ge.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),_e&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),a.jsx("input",{type:"time",value:Ae,onChange:ge=>Ke(ge.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),a.jsx("input",{type:"time",value:je,onChange:ge=>Re(ge.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ek,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:we,onChange:ge=>qe(ge.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),s==="homeassistant"&&a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(vc,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show on Printer Card"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Display button on printer card"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:xt,onChange:ge=>Et(ge.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Me,{type:"submit",disabled:He,className:"flex-1",children:[He?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(ys,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function zn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return a.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:a.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const UKe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function BKe({provider:t,onEdit:e}){const n=nn(),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.useState(null),{data:u}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),d=u?.find(y=>y.id===t.printer_id),h=dt({mutationFn:y=>ae.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=dt({mutationFn:()=>ae.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=dt({mutationFn:()=>ae.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),b=y=>y||"";return a.jsxs(a.Fragment,{children:[a.jsx(_t,{className:"relative",children:a.jsxs(Mt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:a.jsx(Ag,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-white",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray",children:UKe[t.provider_type]||t.provider_type})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&a.jsxs("span",{className:"text-xs text-status-ok hidden sm:inline",children:["Last: ",Xg(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Ui(t.last_error_at)?.getTime()||0)>(Ui(t.last_success)?.getTime()||0))&&a.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),a.jsx(zn,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]})]}),d&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),a.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&a.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),a.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_plate_not_empty&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:"Plate Check"}),t.on_print_complete&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&a.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&a.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&a.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&a.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&a.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[a.jsx(lS,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[a.jsx(Qr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),a.jsx("div",{className:"mb-3",children:a.jsxs(Me,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{c(null),m.mutate()},className:"w-full",children:[m.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Pk,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&a.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?a.jsx(fr,{className:"w-4 h-4"}):a.jsx(Ji,{className:"w-4 h-4"}),a.jsx("span",{children:l.message})]}),a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(Gu,{className:"w-4 h-4"}),"Event Settings"]}),s?a.jsx(Hu,{className:"w-4 h-4"}):a.jsx(hr,{className:"w-4 h-4"})]}),s&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),a.jsx(zn,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Started"}),a.jsx(zn,{checked:t.on_print_start,onChange:y=>h.mutate({on_print_start:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),a.jsx(zn,{checked:t.on_plate_not_empty??!0,onChange:y=>h.mutate({on_plate_not_empty:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),a.jsx(zn,{checked:t.on_print_complete,onChange:y=>h.mutate({on_print_complete:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),a.jsx(zn,{checked:t.on_print_failed,onChange:y=>h.mutate({on_print_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),a.jsx(zn,{checked:t.on_print_stopped,onChange:y=>h.mutate({on_print_stopped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),a.jsx(zn,{checked:t.on_print_progress,onChange:y=>h.mutate({on_print_progress:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),a.jsx(zn,{checked:t.on_printer_offline,onChange:y=>h.mutate({on_printer_offline:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),a.jsx(zn,{checked:t.on_printer_error,onChange:y=>h.mutate({on_printer_error:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(zn,{checked:t.on_filament_low,onChange:y=>h.mutate({on_filament_low:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),a.jsx(zn,{checked:t.on_maintenance_due??!1,onChange:y=>h.mutate({on_maintenance_due:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_humidity_high??!1,onChange:y=>h.mutate({on_ams_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_temperature_high??!1,onChange:y=>h.mutate({on_ams_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>h.mutate({on_ams_ht_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),a.jsx(zn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>h.mutate({on_ams_ht_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Queue"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Added"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job added to queue"})]}),a.jsx(zn,{checked:t.on_queue_job_added??!1,onChange:y=>h.mutate({on_queue_job_added:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Assigned"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Model-based job assigned to printer"})]}),a.jsx(zn,{checked:t.on_queue_job_assigned??!1,onChange:y=>h.mutate({on_queue_job_assigned:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Started"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Queue job started printing"})]}),a.jsx(zn,{checked:t.on_queue_job_started??!1,onChange:y=>h.mutate({on_queue_job_started:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Waiting"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job waiting for filament"})]}),a.jsx(zn,{checked:t.on_queue_job_waiting??!0,onChange:y=>h.mutate({on_queue_job_waiting:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Skipped"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job skipped (previous failed)"})]}),a.jsx(zn,{checked:t.on_queue_job_skipped??!0,onChange:y=>h.mutate({on_queue_job_skipped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Failed"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job failed to start"})]}),a.jsx(zn,{checked:t.on_queue_job_failed??!0,onChange:y=>h.mutate({on_queue_job_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Queue Complete"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"All queue jobs finished"})]}),a.jsx(zn,{checked:t.on_queue_completed??!1,onChange:y=>h.mutate({on_queue_completed:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(lS,{className:"w-4 h-4 text-purple-400"}),a.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),a.jsx(zn,{checked:t.quiet_hours_enabled,onChange:y=>h.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(er,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:[b(t.quiet_hours_start)||"22:00"," - ",b(t.quiet_hours_end)||"07:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Qr,{className:"w-4 h-4 text-emerald-400"}),a.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),a.jsx(zn,{checked:t.daily_digest_enabled,onChange:y=>h.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(er,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:["Send at ",b(t.daily_digest_time)||"08:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(wg,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(hn,{className:"w-4 h-4"})})]})]})]})}),r&&a.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 O9=[{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 HKe({provider:t,onClose:e}){const n=nn(),r=!!t,[i,s]=_.useState(t?.name||""),[o,l]=_.useState(t?.provider_type||"email"),[c,u]=_.useState(t?.printer_id||null),[d,h]=_.useState(t?.quiet_hours_enabled||!1),[p,m]=_.useState(t?.quiet_hours_start||"22:00"),[b,y]=_.useState(t?.quiet_hours_end||"07:00"),[x,v]=_.useState(t?.daily_digest_enabled||!1),[S,N]=_.useState(t?.daily_digest_time||"08:00"),[T,M]=_.useState(t?.on_print_start??!1),[A,k]=_.useState(t?.on_print_complete??!0),[R,C]=_.useState(t?.on_print_failed??!0),[P,U]=_.useState(t?.on_print_stopped??!0),[F,B]=_.useState(t?.on_print_progress??!1),[D,$]=_.useState(t?.on_printer_offline??!1),[G,I]=_.useState(t?.on_printer_error??!1),[K,Q]=_.useState(t?.on_filament_low??!1),[se,H]=_.useState(t?.on_maintenance_due??!1),[W,J]=_.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([q,re])=>[q,String(re)])):{}),[ne,xe]=_.useState(null),[ue,fe]=_.useState(null),{data:De}=nt({queryKey:["printers"],queryFn:ae.getPrinters});_.useEffect(()=>{const q=re=>{re.key==="Escape"&&e()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[e]);const oe=dt({mutationFn:()=>ae.testNotificationConfig({provider_type:o,config:W}),onSuccess:q=>{xe(q),fe(null)},onError:q=>{xe({success:!1,message:q.message})}}),Ne=dt({mutationFn:q=>ae.createNotificationProvider(q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{fe(q.message)}}),Fe=dt({mutationFn:q=>ae.updateNotificationProvider(t.id,q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{fe(q.message)}}),ce=q=>{if(q.preventDefault(),fe(null),!i.trim()){fe("Name is required");return}const re=Y(o);for(const le of re)if(!W[le.key]?.trim()){fe(`${le.label} is required`);return}const X={name:i.trim(),provider_type:o,config:W,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?p:null,quiet_hours_end:d?b:null,daily_digest_enabled:x,daily_digest_time:x?S:null,on_print_start:T,on_print_complete:A,on_print_failed:R,on_print_stopped:P,on_print_progress:F,on_printer_offline:D,on_printer_error:G,on_filament_low:K,on_maintenance_due:se};r?Fe.mutate(X):Ne.mutate(X)},Ve=Ne.isPending||Fe.isPending,V=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:re=>re.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:re=>re.payload_format!=="slack"}];default:return[]}},Y=q=>V(q).filter(re=>re.required),de=V(o);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:q=>q.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:ce,className:"p-6 space-y-4",children:[ue&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:ue}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:i,onChange:q=>s(q.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),a.jsx("select",{value:o,onChange:q=>{l(q.target.value),J({}),xe(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:O9.map(q=>a.jsx("option",{value:q.value,children:q.label},q.value))}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:O9.find(q=>q.value===o)?.description})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),de.filter(q=>!("showIf"in q)||q.showIf?.(W)!==!1).map(q=>a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[q.label," ",q.required&&"*"]}),q.type==="select"&&"options"in q&&q.options?a.jsx("select",{value:W[q.key]||q.options[0]?.value||"",onChange:re=>{J({...W,[q.key]:re.target.value}),xe(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(re=>a.jsx("option",{value:re.value,children:re.label},re.value))}):a.jsx("input",{type:q.type,value:W[q.key]||"",onChange:re=>{J({...W,[q.key]:re.target.value}),xe(null)},placeholder:q.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},q.key))]}),a.jsx("div",{className:"flex gap-2",children:a.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>{xe(null),oe.mutate()},disabled:oe.isPending||!W[Y(o)[0]?.key],className:"flex-1",children:[oe.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Pk,{className:"w-4 h-4"}),"Test Configuration"]})}),ne&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ne.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ne.success?a.jsxs(a.Fragment,{children:[a.jsx(fr,{className:"w-5 h-5"}),a.jsx("span",{children:ne.message})]}):a.jsxs(a.Fragment,{children:[a.jsx(Ji,{className:"w-5 h-5"}),a.jsx("span",{children:ne.message})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),a.jsxs("select",{value:c??"",onChange:q=>u(q.target.value?Number(q.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"All printers"}),De?.map(q=>a.jsx("option",{value:q.id,children:q.name},q.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),a.jsx(zn,{checked:d,onChange:h})]}),d&&a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),a.jsx("input",{type:"time",value: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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),a.jsx("input",{type:"time",value:b,onChange:q=>y(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),a.jsx(zn,{checked:x,onChange:v})]}),x&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),a.jsx("input",{type:"time",value:S,onChange:q=>N(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Start"}),a.jsx(zn,{checked:T,onChange:M})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Complete"}),a.jsx(zn,{checked:A,onChange:k})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Failed"}),a.jsx(zn,{checked:R,onChange:C})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Stopped"}),a.jsx(zn,{checked:P,onChange:U})]}),a.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Progress"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),a.jsx(zn,{checked:F,onChange:B})]})]})]}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Offline"}),a.jsx(zn,{checked:D,onChange:$})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Error"}),a.jsx(zn,{checked:G,onChange:I})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(zn,{checked:K,onChange:Q})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),a.jsx(zn,{checked:se,onChange:H})]})]})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Me,{type:"submit",disabled:Ve,className:"flex-1",children:[Ve?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(ys,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function $Ke({template:t,onClose:e}){const n=nn(),r=_.useRef(null),[i,s]=_.useState(t.title_template),[o,l]=_.useState(t.body_template),[c,u]=_.useState(null),[d,h]=_.useState(!0),{data:p}=nt({queryKey:["template-variables"],queryFn:ae.getTemplateVariables}),m=p?.find(M=>M.event_type===t.event_type),{data:b,isLoading:y}=nt({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>ae.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});_.useEffect(()=>{const M=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e]);const x=dt({mutationFn:M=>ae.updateNotificationTemplate(t.id,M),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:M=>{u(M.message)}}),v=dt({mutationFn:()=>ae.resetNotificationTemplate(t.id),onSuccess:M=>{s(M.title_template),l(M.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:M=>{u(M.message)}}),S=M=>{if(M.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}x.mutate({title_template:i,body_template:o})},N=M=>{const A=r.current;if(!A)return;const k=A.selectionStart,R=A.selectionEnd,C=o,P=C.substring(0,k),U=C.substring(R),F=P+`{${M}}`+U;l(F),setTimeout(()=>{A.focus();const B=k+M.length+2;A.setSelectionRange(B,B)},0)},T=i!==t.title_template||o!==t.body_template;return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),a.jsx("input",{type:"text",value:i,onChange:M=>s(M.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),a.jsx("textarea",{ref:r,value:o,onChange:M=>l(M.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&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(M=>a.jsxs("button",{type:"button",onClick:()=>N(M),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(lr,{className:"w-3 h-3"}),M]},M))}),a.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[a.jsx(vc,{className:"w-4 h-4"}),"Live Preview"]}),a.jsx("button",{type:"button",onClick:()=>h(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&a.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):b?a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),a.jsx("div",{className:"text-white font-medium",children:b.title})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),a.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:b.body})]})]}):a.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[a.jsxs(Me,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Vu,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsxs(Me,{onClick:S,disabled:x.isPending||!T,children:[x.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(ys,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const VKe={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},GKe={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 qKe({onClose:t}){const e=nn(),{showToast:n}=kn(),[r,i]=_.useState(7),[s,o]=_.useState(null),[l,c]=_.useState(!1),{data:u}=nt({queryKey:["settings"],queryFn:ae.getSettings}),d=u?.time_format||"system",{data:h,isLoading:p,refetch:m,isRefetching:b}=nt({queryKey:["notification-logs",r,l],queryFn:()=>ae.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=nt({queryKey:["notification-log-stats",r],queryFn:()=>ae.getNotificationLogStats(r)}),x=dt({mutationFn:()=>ae.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),v=S=>{const N=Ui(S);if(!N)return"";const M=new Date().getTime()-N.getTime();return M<6e4?"Just now":M<36e5?`${Math.floor(M/6e4)}m ago`:M<864e5?`${Math.floor(M/36e5)}h ago`:N.toLocaleDateString()+" "+sme(N,d)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Q0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),y&&a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:a.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[a.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",a.jsx("span",{className:"text-white font-medium",children:y.total})," notifications"]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(fr,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(Ji,{className:"w-4 h-4"}),y.failure_count," failed"]})]})}),a.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[a.jsxs("select",{value:r,onChange:S=>i(Number(S.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[a.jsx("option",{value:1,children:"Last 24 hours"}),a.jsx("option",{value:7,children:"Last 7 days"}),a.jsx("option",{value:30,children:"Last 30 days"}),a.jsx("option",{value:90,children:"Last 90 days"})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:S=>c(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),a.jsx("div",{className:"flex-1"}),a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>m(),disabled:b,children:[b?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),"Refresh"]}),a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(hn,{className:"w-4 h-4"}),"Clear Old"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:p?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):h&&h.length>0?a.jsx("div",{className:"space-y-2",children:h.map(S=>a.jsx(WKe,{log:S,isExpanded:s===S.id,onToggle:()=>o(s===S.id?null:S.id),formatDate:v,formatFullDate:N=>Yg(N,d)},S.id))}):a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(Q0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function WKe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return a.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[a.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?a.jsx(fr,{className:"w-4 h-4 text-bambu-green shrink-0"}):a.jsx(Ji,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-xs font-medium ${GKe[t.event_type]||"text-bambu-gray"}`,children:VKe[t.event_type]||t.event_type}),a.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),a.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?a.jsx(Hu,{className:"w-4 h-4 text-bambu-gray shrink-0"}):a.jsx(hr,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&a.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),a.jsx("p",{className:"text-sm text-white",children:t.title})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),a.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),a.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),a.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[a.jsxs("span",{children:["Provider: ",t.provider_type]}),a.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}function KKe({formData:t,setFormData:e,groups:n,onClose:r,onCreate:i,isCreating:s,isCreateButtonDisabled:o}){const{t:l}=Yt();_.useEffect(()=>{const u=d=>{d.key==="Escape"&&r()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r]);const c=u=>{e({...t,group_ids:t.group_ids.includes(u)?t.group_ids.filter(d=>d!==u):[...t.group_ids,u]})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:r,children:a.jsxs(_t,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:l("users.modal.createUser")})]}),a.jsx("p",{className:"text-sm text-bambu-gray ml-7",children:l("users.modal.advancedAuthSubtitle")||"with Advanced Authentication"})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Mt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.username")," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",value:t.username,onChange:u=>e({...t,username:u.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:l("users.form.usernamePlaceholder"),autoComplete:"username",required:!0})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[l("users.form.email")||"Email"," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"email",value:t.email,onChange:u=>e({...t,email:u.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:l("users.form.emailPlaceholder")||"user@example.com",required:!0})]}),a.jsx("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3",children:a.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.form.autoGeneratedPassword")||"A secure password will be automatically generated and emailed to the user."})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:l("users.form.groups")}),a.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[n.map(u=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.group_ids.includes(u.id),onChange:()=>c(u.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:u.name}),u.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",l("users.system"),")"]})]},u.id)),n.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:l("users.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:r,children:l("users.modal.cancel")}),a.jsx(Me,{onClick:i,disabled:o,children:s?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),l("users.modal.creating")]}):a.jsxs(a.Fragment,{children:[a.jsx(lr,{className:"w-4 h-4"}),l("users.modal.createUser")]})})]})]})]})})}function XKe(){const{t}=Yt(),e=nn(),{showToast:n}=kn(),[r,i]=_.useState(!1),[s,o]=_.useState(""),[l,c]=_.useState("auto"),[u,d]=_.useState(!1),[h,p]=_.useState(!0),[m,b]=_.useState("all"),[y,x]=_.useState(!1),[v,S]=_.useState(!1),{data:N,isLoading:T}=nt({queryKey:["spoolman-settings"],queryFn:ae.getSpoolmanSettings}),{data:M,isLoading:A,refetch:k}=nt({queryKey:["spoolman-status"],queryFn:ae.getSpoolmanStatus,refetchInterval:3e4}),{data:R}=nt({queryKey:["printers"],queryFn:ae.getPrinters});_.useEffect(()=>{N&&(i(N.spoolman_enabled==="true"),o(N.spoolman_url||""),c(N.spoolman_sync_mode||"auto"),d(N.spoolman_disable_weight_sync==="true"),p(N.spoolman_report_partial_usage!=="false"),x(!0))},[N]),_.useEffect(()=>{if(!y||!N)return;if(N.spoolman_enabled==="true"!==r||(N.spoolman_url||"")!==s||(N.spoolman_sync_mode||"auto")!==l||N.spoolman_disable_weight_sync==="true"!==u||N.spoolman_report_partial_usage!=="false"!==h){const Q=setTimeout(()=>{C.mutate()},500);return()=>clearTimeout(Q)}},[r,s,l,u,h,y]);const C=dt({mutationFn:()=>ae.updateSpoolmanSettings({spoolman_enabled:r?"true":"false",spoolman_url:s,spoolman_sync_mode:l,spoolman_disable_weight_sync:u?"true":"false",spoolman_report_partial_usage:h?"true":"false"}),onSuccess:()=>{e.invalidateQueries({queryKey:["spoolman-settings"]}),e.invalidateQueries({queryKey:["spoolman-status"]}),n(t("settings.toast.settingsSaved"))}}),P=dt({mutationFn:ae.connectSpoolman,onSuccess:()=>{k()}}),U=dt({mutationFn:ae.disconnectSpoolman,onSuccess:()=>{k()}}),F=dt({mutationFn:ae.syncAllPrintersAms,onSuccess:K=>{K.success}}),B=dt({mutationFn:K=>ae.syncPrinterAms(K),onSuccess:K=>{K.success}}),D=()=>{m==="all"?F.mutate():B.mutate(m)},$=F.isPending||B.isPending,G=m==="all"?F.data:B.data,I=m==="all"?F.isSuccess:B.isSuccess;return T?a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ju,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),a.jsx(Mt,{children:a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ju,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),C.isPending&&a.jsx(lt,{className:"w-4 h-4 text-bambu-green animate-spin"})]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(yo,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-xs text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),a.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[a.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),a.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),a.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),a.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),a.jsx("p",{className:"text-blue-300/80",children:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".'})]})]})}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable Spoolman"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:r,onChange:K=>i(K.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),a.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:s,onChange:K=>o(K.target.value),disabled:!r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),a.jsxs("select",{value:l,onChange:K=>c(K.target.value),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:[a.jsx("option",{value:"auto",children:"Automatic"}),a.jsx("option",{value:"manual",children:"Manual Only"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:l==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),l==="auto"&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:t("spoolman.disableWeightSync")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.disableWeightSyncDesc")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:K=>d(K.target.checked),disabled:!r,className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),u&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:t("spoolman.reportPartialUsage")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("spoolman.reportPartialUsageDesc")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:h,onChange:K=>p(K.target.checked),disabled:!r,className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),r&&a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),A?a.jsx(lt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):M?.connected?a.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[a.jsx(Vi,{className:"w-4 h-4"}),"Connected"]}):a.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[a.jsx(Lt,{className:"w-4 h-4"}),"Disconnected"]})]}),a.jsx("div",{className:"flex gap-2",children:M?.connected?a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>U.mutate(),disabled:U.isPending,children:[U.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ude,{className:"w-4 h-4"}),"Disconnect"]}):a.jsxs(Me,{size:"sm",onClick:()=>P.mutate(),disabled:P.isPending||!s,children:[P.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(pc,{className:"w-4 h-4"}),"Connect"]})})]}),P.isError&&a.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:P.error.message}),M?.connected&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsxs("select",{value:m,onChange:K=>b(K.target.value==="all"?"all":Number(K.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"all",children:"All Printers"}),R?.map(K=>a.jsx("option",{value:K.id,children:K.name},K.id))]}),a.jsx(hr,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:D,disabled:$,children:[$?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),"Sync"]})]})]}),I&&G&&a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsx("div",{className:`p-2 rounded text-sm ${G.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:G.success?`Synced ${G.synced_count} spool${G.synced_count!==1?"s":""} successfully`:`Synced ${G.synced_count} spool${G.synced_count!==1?"s":""} with ${G.errors.length} error${G.errors.length!==1?"s":""}`}),G.skipped_count>0&&a.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(En,{className:"w-3.5 h-3.5"}),a.jsxs("span",{className:"font-medium",children:[G.skipped_count," spool",G.skipped_count!==1?"s":""," skipped"]})]}),G.skipped_count>5&&a.jsx("button",{onClick:()=>S(!v),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:v?"Show less":"Show all"})]}),a.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(v?G.skipped:G.skipped.slice(0,5)).map((K,Q)=>a.jsxs("li",{className:"flex items-center gap-2",children:[K.color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${K.color}`}}),a.jsx("span",{children:K.location}),a.jsxs("span",{className:"text-amber-300/60",children:["- ",K.reason]})]},Q)),!v&&G.skipped_count>5&&a.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",G.skipped_count-5," more"]})]})]}),G.errors.length>0&&a.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[a.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),a.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:G.errors.map((K,Q)=>a.jsx("li",{children:K},Q))})]})]})]})]})]})}function YKe({link:t,onClose:e}){const{t:n}=Yt(),r=nn(),i=!!t,s=_.useRef(null),[o,l]=_.useState(t?.name||""),[c,u]=_.useState(t?.url||""),[d,h]=_.useState(t?.icon||"link"),[p,m]=_.useState(t?.open_in_new_tab||!1),[b,y]=_.useState(!!t?.custom_icon),[x,v]=_.useState(t?.custom_icon?ae.getExternalLinkIconUrl(t.id):null),[S,N]=_.useState(null),[T,M]=_.useState(null);_.useEffect(()=>{const B=D=>{D.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const A=dt({mutationFn:async B=>{const D=await ae.createExternalLink(B);return S?await ae.uploadExternalLinkIcon(D.id,S):D},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:B=>{M(B.message)}}),k=dt({mutationFn:async B=>{let D=await ae.updateExternalLink(t.id,B);return S?D=await ae.uploadExternalLinkIcon(t.id,S):!b&&t?.custom_icon&&(D=await ae.deleteExternalLinkIcon(t.id)),D},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:B=>{M(B.message)}}),R=B=>{const D=B.target.files?.[0];if(D){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(D.type)){M("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(D.size>1024*1024){M("Image file must be less than 1MB");return}N(D),y(!0);const G=new FileReader;G.onload=I=>{v(I.target?.result)},G.readAsDataURL(D)}},C=()=>{N(null),v(null),y(!1),s.current&&(s.current.value="")},P=B=>{if(B.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 D={name:o.trim(),url:c.trim(),icon:d,open_in_new_tab:p};i?k.mutate(D):A.mutate(D)},U=A.isPending||k.isPending,F=Rk(d);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:B=>B.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:b&&x?a.jsx("img",{src:x,alt:"",className:"w-5 h-5 rounded"}):a.jsx(F,{className:"w-5 h-5"})}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:P,className:"p-6 space-y-4",children:[T&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:T}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:o,onChange:B=>l(B.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),a.jsx("input",{type:"text",value:c,onChange:B=>u(B.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm text-bambu-gray",children:n("externalLinks.openInNewTab")}),a.jsx("button",{type:"button",onClick:()=>m(!p),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${p?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${p?"translate-x-6":"translate-x-1"}`})})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),a.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),a.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:R}),b&&x?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:x,alt:"Custom icon",className:"w-8 h-8 rounded border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:C,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:a.jsx(hn,{className:"w-4 h-4"})})]}):a.jsxs(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[a.jsx(Na,{className:"w-4 h-4"}),"Upload"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!b&&a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),a.jsx(Wfe,{value:d,onChange:h})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Me,{type:"submit",disabled:U,className:"flex-1",children:[U?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(ys,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function QKe(){const{t}=Yt(),e=nn(),[n,r]=_.useState(!1),[i,s]=_.useState(null),[o,l]=_.useState(null),[c,u]=_.useState(null),{data:d,isLoading:h}=nt({queryKey:["external-links"],queryFn:ae.getExternalLinks}),p=dt({mutationFn:N=>ae.deleteExternalLink(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),m=dt({mutationFn:N=>ae.reorderExternalLinks(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),b=(N,T)=>{u(T),N.dataTransfer.effectAllowed="move"},y=N=>{N.preventDefault(),N.dataTransfer.dropEffect="move"},x=(N,T)=>{if(N.preventDefault(),c===null||c===T||!d)return;const M=d.map(C=>C.id),A=M.indexOf(c),k=M.indexOf(T);if(A===-1||k===-1)return;const R=[...M];R.splice(A,1),R.splice(k,0,c),m.mutate(R),u(null)},v=N=>{l(N)},S=()=>{o&&(p.mutate(o.id),l(null))};return a.jsxs(a.Fragment,{children:[a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(pc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),a.jsxs(Me,{size:"sm",onClick:()=>r(!0),children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Link"]})]})}),a.jsxs(Mt,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),h?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):d&&d.length>0?a.jsx("div",{className:"space-y-2",children:d.map(N=>{const T=Rk(N.icon);return a.jsxs("div",{draggable:!0,onDragStart:M=>b(M,N.id),onDragOver:y,onDrop:M=>x(M,N.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${c===N.id?"opacity-50":""}`,children:[a.jsx(Zf,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(T,{className:"w-4 h-4"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-white font-medium truncate",children:N.name}),a.jsx(Zr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),a.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:N.url})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.jsx("button",{onClick:()=>s(N),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:t("common.edit"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>v(N),disabled:p.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:t("externalLinks.deleteLink"),children:a.jsx(hn,{className:"w-4 h-4"})})]})]},N.id)})}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(pc,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:t("externalLinks.noLinksConfigured")}),a.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(n||i)&&a.jsx(YKe,{link:i,onClose:()=>{r(!1),s(null)}}),o&&a.jsx(Qn,{title:"Delete Link",message:`Are you sure you want to delete "${o.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:S,onCancel:()=>l(null)})]})}function ZKe(){const{t}=Yt(),e=nn(),{showToast:n}=kn(),[r,i]=_.useState(!1),[s,o]=_.useState(""),[l,c]=_.useState("immediate"),[u,d]=_.useState("3DPrinter-X1-Carbon"),[h,p]=_.useState(null),[m,b]=_.useState(""),[y,x]=_.useState(!1),[v,S]=_.useState(null),{data:N,isLoading:T}=nt({queryKey:["virtual-printer-settings"],queryFn:C1.getSettings,refetchInterval:1e4}),{data:M}=nt({queryKey:["virtual-printer-models"],queryFn:C1.getModels}),{data:A}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:k}=nt({queryKey:["network-interfaces"],queryFn:()=>ae.getNetworkInterfaces().then(I=>I.interfaces),enabled:r});_.useEffect(()=>{if(N){i(N.enabled);let I=N.mode==="queue"?"review":N.mode;I!=="immediate"&&I!=="review"&&I!=="print_queue"&&I!=="proxy"&&(I="immediate"),c(I),d(N.model),p(N.target_printer_id),b(N.remote_interface_ip||"")}},[N]);const R=dt({mutationFn:I=>C1.updateSettings(I),onSuccess:()=>{e.invalidateQueries({queryKey:["virtual-printer-settings"]}),n(t("virtualPrinter.toast.updated")),S(null)},onError:I=>{if(n(I.message||t("virtualPrinter.toast.failedToUpdate"),"error"),N){i(N.enabled);const K=N.mode==="queue"?"review":N.mode;c(["immediate","review","print_queue","proxy"].includes(K)?K:"immediate"),d(N.model),p(N.target_printer_id)}S(null)}}),C=()=>{const I=!r;if(I){if(l==="proxy"){if(!h){n(t("virtualPrinter.toast.targetPrinterRequired"),"error");return}}else if(!s&&!N?.access_code_set){n(t("virtualPrinter.toast.accessCodeRequired"),"error");return}}i(I),S("toggle"),R.mutate({enabled:I,access_code:l!=="proxy"&&s||void 0,mode:l,target_printer_id:l==="proxy"?h??void 0:void 0})},P=()=>{if(!s){n(t("virtualPrinter.toast.accessCodeEmpty"),"error");return}if(s.length!==8){n(t("virtualPrinter.toast.accessCodeLength"),"error");return}S("accessCode"),R.mutate({access_code:s}),o("")},U=I=>{c(I),S("mode"),R.mutate({mode:I})},F=I=>{p(I),S("targetPrinter"),R.mutate({target_printer_id:I})},B=I=>{d(I),S("model"),R.mutate({model:I})},D=I=>{b(I),S("remoteInterface"),R.mutate({remote_interface_ip:I})};if(T)return a.jsx(_t,{children:a.jsx(Mt,{className:"py-8 flex justify-center",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const $=N?.status,G=$?.running||!1;return a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Dr,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("virtualPrinter.title")})]}),$&&a.jsxs("div",{className:`flex items-center gap-2 text-sm ${G?"text-green-400":"text-bambu-gray"}`,children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${G?"bg-green-400 animate-pulse":"bg-gray-500"}`}),t(G?"virtualPrinter.running":"virtualPrinter.stopped")]})]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t(l==="proxy"?"virtualPrinter.description.proxy":"virtualPrinter.description.default")}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.enable.title")}),a.jsx("div",{className:"text-sm text-bambu-gray",children:G?l==="proxy"?t("virtualPrinter.enable.proxyingTo",{name:A?.find(I=>I.id===h)?.name||"printer"}):t("virtualPrinter.enable.visibleInSlicer"):t("virtualPrinter.enable.notActive")})]}),a.jsx("button",{onClick:C,disabled:v==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${r?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${v==="toggle"?"opacity-50":""}`,children:a.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${r?"translate-x-6":""}`})})]}),l!=="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.model.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:t("virtualPrinter.model.description")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:u,onChange:I=>B(I.target.value),disabled:v==="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:M?.models&&Object.entries(M.models).sort(([,I],[,K])=>I.localeCompare(K)).map(([I,K])=>a.jsx("option",{value:I,children:K},I))}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),r&&G&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[a.jsx(yo,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.model.restartWarning")]})]}),l!=="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.accessCode.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:N?.access_code_set?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Vi,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.isSet")]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(En,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.notSet")]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:y?"text":"password",value:s,onChange:I=>o(I.target.value),placeholder:N?.access_code_set?t("virtualPrinter.accessCode.placeholderChange"):t("virtualPrinter.accessCode.placeholder"),maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),a.jsx("button",{onClick:()=>x(!y),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:y?a.jsx(Sk,{className:"w-4 h-4"}):a.jsx(vc,{className:"w-4 h-4"})})]}),a.jsx(Me,{onClick:P,disabled:!s||v==="accessCode",variant:"primary",children:v==="accessCode"?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):t("common.save")})]}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[t("virtualPrinter.accessCode.hint"),s&&a.jsxs("span",{className:s.length===8?"text-green-400":"text-yellow-400",children:[" ",t("virtualPrinter.accessCode.charCount",{count:s.length})]})]})]}),l==="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.targetPrinter.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:h?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Vi,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.configured")]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(En,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.notConfigured")]})}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:h??"",onChange:I=>{const K=parseInt(I.target.value,10);isNaN(K)||F(K)},disabled:v==="targetPrinter",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:[a.jsx("option",{value:"",children:t("virtualPrinter.targetPrinter.placeholder")}),A?.map(I=>a.jsxs("option",{value:I.id,children:[I.name," (",I.ip_address,")"]},I.id))]}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:t("virtualPrinter.targetPrinter.hint")}),!A?.length&&a.jsxs("p",{className:"text-xs text-yellow-400 mt-2",children:[a.jsx(En,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.targetPrinter.noPrinters")]})]}),r&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.remoteInterface.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:m?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Vi,{className:"w-4 h-4"}),t("virtualPrinter.remoteInterface.configured")]}):a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(yo,{className:"w-4 h-4"}),t("virtualPrinter.remoteInterface.optional")]})}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:m,onChange:I=>D(I.target.value),disabled:v==="remoteInterface",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:[a.jsx("option",{value:"",children:t("virtualPrinter.remoteInterface.placeholder")}),k?.map(I=>a.jsxs("option",{value:I.ip,children:[I.name," (",I.ip,") - ",I.subnet]},I.ip))]}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:t("virtualPrinter.remoteInterface.hint")})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.mode.title")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("button",{onClick:()=>U("immediate"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.archive")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.archiveDesc")})]}),a.jsxs("button",{onClick:()=>U("review"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="review"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.review")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.reviewDesc")})]}),a.jsxs("button",{onClick:()=>U("print_queue"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="print_queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.queue")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.queueDesc")})]}),a.jsxs("button",{onClick:()=>U("proxy"),disabled:v==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="proxy"?"border-blue-500 bg-blue-500/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-white font-medium",children:[a.jsx(eB,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.proxyDesc")})]})]})]})]})]})}),a.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[a.jsx(_t,{className:"border-l-4 border-l-yellow-500",children:a.jsx(Mt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(En,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-white font-medium mb-2",children:t("virtualPrinter.setupRequired.title")}),a.jsx("p",{className:"text-bambu-gray mb-3",children:t("virtualPrinter.setupRequired.description")}),a.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[a.jsx(Zr,{className:"w-4 h-4"}),t("virtualPrinter.setupRequired.readGuide")]})]})]})})}),a.jsx(_t,{children:a.jsx(Mt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(yo,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:a.jsxs("strong",{className:"text-white",children:[t(l==="proxy"?"virtualPrinter.howItWorks.titleProxy":"virtualPrinter.howItWorks.title"),":"]})}),l==="proxy"?a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep1")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep2")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep3")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep4")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep5")})]}):a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:t("virtualPrinter.howItWorks.step1")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step2")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step3")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step4")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step5")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step6")})]})]})]})})}),$&&G&&a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsx("h3",{className:"text-md font-semibold text-white",children:t("virtualPrinter.status.title")})}),a.jsx(Mt,{children:$.mode==="proxy"&&$.proxy?a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.targetPrinter")}),a.jsx("div",{className:"text-white",children:A?.find(I=>I.id===h)?.name||$.proxy.target_host}),a.jsx("div",{className:"text-xs text-bambu-gray font-mono",children:$.proxy.target_host})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),a.jsxs("div",{className:"text-white flex items-center gap-1.5",children:[a.jsx(eB,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpPort")}),a.jsx("div",{className:"text-white font-mono",children:$.proxy.ftp_port})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttPort")}),a.jsx("div",{className:"text-white font-mono",children:$.proxy.mqtt_port})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpConnections")}),a.jsx("div",{className:"text-white",children:$.proxy.ftp_connections??0})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttConnections")}),a.jsx("div",{className:"text-white",children:$.proxy.mqtt_connections??0})]})]}):a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.printerName")}),a.jsx("div",{className:"text-white",children:$.name})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.model")}),a.jsx("div",{className:"text-white",children:$.model_name||$.model})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.serialNumber")}),a.jsx("div",{className:"text-white font-mono",children:$.serial})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),a.jsx("div",{className:"text-white capitalize",children:$.mode})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.pendingFiles")}),a.jsx("div",{className:"text-white",children:$.pending_files})]})]})})]})]})]})}function L9({status:t}){if(!t)return null;const e={success:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",skipped:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400"},n={success:a.jsx(fr,{className:"w-3 h-3"}),failed:a.jsx(Ji,{className:"w-3 h-3"}),skipped:a.jsx(QR,{className:"w-3 h-3"}),running:a.jsx(lt,{className:"w-3 h-3 animate-spin"})};return a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${e[t]||"bg-gray-500/20 text-gray-400"}`,children:[n[t],t.charAt(0).toUpperCase()+t.slice(1)]})}function JKe(t){return t?new Date(t).toLocaleString():"-"}function F9(t){if(!t)return"-";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime(),i=Math.round(r/6e4);if(i<0){const s=Math.abs(i);if(s<60)return`${s}m ago`;const o=Math.floor(s/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}else{if(i<60)return`in ${i}m`;const s=Math.floor(i/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}}function eXe(){const t=nn(),{showToast:e}=kn(),{t:n}=Yt(),[r,i]=_.useState(""),[s,o]=_.useState(""),[l,c]=_.useState("main"),[u,d]=_.useState(!1),[h,p]=_.useState("daily"),[m,b]=_.useState(!0),[y,x]=_.useState(!0),[v,S]=_.useState(!1),[N,T]=_.useState(!0),[M,A]=_.useState(!1),[k,R]=_.useState(!1),[C,P]=_.useState(""),[U,F]=_.useState(!1),[B,D]=_.useState(null),[$,G]=_.useState(null),I=_.useRef(null);_.useEffect(()=>{if(M||k){const z=O=>(O.preventDefault(),O.returnValue="A backup operation is in progress. Are you sure you want to leave?",O.returnValue);return window.addEventListener("beforeunload",z),()=>window.removeEventListener("beforeunload",z)}},[M,k]);const[K,Q]=_.useState(!1),[se,H]=_.useState(null),W=_.useRef(null),J=_.useRef(!1),{data:ne,isLoading:xe}=nt({queryKey:["github-backup-config"],queryFn:ae.getGitHubBackupConfig}),{data:ue}=nt({queryKey:["github-backup-status"],queryFn:ae.getGitHubBackupStatus,refetchInterval:ee=>ee.state.data?.is_running?500:1e4}),{data:fe}=nt({queryKey:["github-backup-logs"],queryFn:()=>ae.getGitHubBackupLogs(20)}),{data:De}=nt({queryKey:["cloud-status"],queryFn:ae.getCloudStatus}),{data:oe}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),Ne=qR({queries:(oe??[]).map(ee=>({queryKey:["printerStatus",ee.id],queryFn:()=>ae.getPrinterStatus(ee.id),staleTime:1e4,refetchInterval:3e4}))}),Fe=(oe??[]).map((ee,z)=>({printer:ee,connected:Ne[z]?.data?.connected??!1})),ce=Fe.length,Ve=Fe.filter(ee=>ee.connected).length,V=ce>0&&Ve===0,Y=Ve>0&&Ve<ce;_.useEffect(()=>{ne&&(i(ne.repository_url),c(ne.branch),d(ne.schedule_enabled),p(ne.schedule_type),b(ne.backup_kprofiles),x(ne.backup_cloud_profiles),S(ne.backup_settings),T(ne.enabled),o(""),setTimeout(()=>{J.current=!0},100))},[ne]);const de=_.useCallback(async(ee=!1)=>{if(ne?.has_token)try{ee&&s?(await ae.saveGitHubBackupConfig({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:m,backup_cloud_profiles:y,backup_settings:v,enabled:N}),o(""),e("Token updated")):(await ae.updateGitHubBackupConfig({repository_url:r,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:m,backup_cloud_profiles:y,backup_settings:v,enabled:N}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(z){e(`Failed to save: ${z.message}`,"error")}},[ne?.has_token,r,s,l,u,h,m,y,v,N,t,e]);_.useEffect(()=>{if(!(!J.current||!ne?.has_token))return W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{de(!1)},500),()=>{W.current&&clearTimeout(W.current)}},[r,l,u,h,m,y,v,N,de,ne?.has_token]),_.useEffect(()=>{if(!(!J.current||!ne?.has_token||!s))return W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{de(!0)},1e3),()=>{W.current&&clearTimeout(W.current)}},[s,de,ne?.has_token]);const q=dt({mutationFn:ee=>ae.saveGitHubBackupConfig(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),o(""),J.current=!0},onError:ee=>{e(`Failed to save: ${ee.message}`,"error")}}),re=dt({mutationFn:ae.triggerGitHubBackup,onSuccess:ee=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),ee.success?ee.files_changed>0?e(`Backup complete - ${ee.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${ee.message}`,"error")},onError:ee=>{e(`Backup failed: ${ee.message}`,"error")}}),X=dt({mutationFn:()=>ae.clearGitHubBackupLogs(0),onSuccess:ee=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${ee.deleted} logs`)},onError:ee=>{e(`Failed to clear logs: ${ee.message}`,"error")}}),le=async()=>{Q(!0),H(null);try{let ee;if(s){if(!r){e("Enter repository URL","error"),Q(!1);return}ee=await ae.testGitHubConnection(r,s)}else if(ne?.has_token)ee=await ae.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),Q(!1);return}H({success:ee.success,message:ee.message})}catch(ee){H({success:!1,message:ee.message})}finally{Q(!1)}},pe=()=>{if(!r){e("Repository URL is required","error");return}if(!s){e("Access token is required","error");return}q.mutate({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:m,backup_cloud_profiles:y,backup_settings:v,enabled:N})};return xe?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Cj,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),ne&&De?.is_authenticated&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Enabled"}),a.jsx(zn,{checked:N,onChange:T})]})]})}),a.jsx(Mt,{className:"space-y-4",children:De?.is_authenticated?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically sync your profiles to a private GitHub repository for backup and version history."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Repository URL"}),a.jsx("input",{type:"text",value:r,onChange:ee=>{i(ee.target.value),H(null)},placeholder:"https://github.com/username/bambuddy-backup",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",ne?.has_token&&a.jsx("span",{className:"text-green-400",children:"(saved)"})]}),a.jsx("input",{type:"password",value:s,onChange:ee=>{o(ee.target.value),H(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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Fine-grained token with Contents read/write permission"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Branch"}),a.jsx("input",{type:"text",value:l,onChange:ee=>c(ee.target.value),placeholder:"main",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Auto-backup"}),a.jsxs("select",{value:u?h:"disabled",onChange:ee=>{ee.target.value==="disabled"?d(!1):(d(!0),p(ee.target.value))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"disabled",children:"Manual only"}),a.jsx("option",{value:"hourly",children:"Hourly"}),a.jsx("option",{value:"daily",children:"Daily"}),a.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:`flex items-start gap-2 ${V?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[a.jsx("input",{type:"checkbox",checked:m,onChange:ee=>b(ee.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:V}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`text-sm ${V?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),V&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(En,{className:"w-3 h-3"}),"No printers connected"]}),Y&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(En,{className:"w-3 h-3"}),Ve,"/",ce," connected"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Pressure advance calibration from connected printers"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:y,onChange:ee=>x(ee.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}),a.jsxs("div",{children:[a.jsx("span",{className:`text-sm ${De?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:v,onChange:ee=>S(ee.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white text-sm",children:"App Settings"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Bambuddy configuration (complete database)"})]})]})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[ue?.configured&&a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:ue.last_backup_at?a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:["Last backup: ",F9(ue.last_backup_at)]}),a.jsx(L9,{status:ue.last_backup_status})]}):a.jsx("span",{children:"No backups yet"})}),ue.next_scheduled_run&&a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx(er,{className:"w-3 h-3 inline mr-1"}),"Next: ",F9(ue.next_scheduled_run)]})]}),se&&a.jsxs("div",{className:`text-sm flex items-center gap-1 ${se.success?"text-green-400":"text-red-400"}`,children:[se.success?a.jsx(fr,{className:"w-4 h-4"}):a.jsx(Ji,{className:"w-4 h-4"}),se.message]}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:ue?.configured?a.jsx(a.Fragment,{children:re.isPending||ue.is_running?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:ue.progress||"Starting backup..."})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>re.mutate(),disabled:!ne?.enabled,children:[a.jsx(To,{className:"w-4 h-4"}),"Backup Now"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:le,disabled:K,children:[K?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),"Test"]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"primary",size:"sm",onClick:pe,disabled:q.isPending||!r||!s,children:[q.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(fr,{className:"w-4 h-4"}),"Enable Backup"]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:le,disabled:K||!r||!s,children:[K?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),"Test Connection"]})]})})]})]}):a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(En,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm text-yellow-400",children:"Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup."})]})})]}),fe&&fe.length>0&&a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Q0,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),a.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>X.mutate(),disabled:X.isPending,children:[a.jsx(hn,{className:"w-4 h-4"}),"Clear"]})]})}),a.jsx(Mt,{children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left py-2 px-2",children:"Date"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Status"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Commit"})]})}),a.jsx("tbody",{children:fe.slice(0,10).map(ee=>a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[a.jsx("td",{className:"py-2 px-2 text-white",children:JKe(ee.started_at)}),a.jsx("td",{className:"py-2 px-2",children:a.jsx(L9,{status:ee.status})}),a.jsx("td",{className:"py-2 px-2",children:ee.commit_sha?a.jsxs("a",{href:`${ne?.repository_url}/commit/${ee.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[ee.commit_sha.substring(0,7),a.jsx(Zr,{className:"w-3 h-3"})]}):a.jsx("span",{className:"text-bambu-gray",children:"-"})})]},ee.id))})]})})})]})]}),a.jsx("div",{className:"space-y-6",children:a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ju,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Create a complete backup of your Bambuddy data including the database, archives, uploads, and all files."}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Download Backup"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Complete backup: database + all files (ZIP)"})]}),a.jsxs(Me,{variant:"secondary",size:"sm",disabled:M||k,onClick:async()=>{A(!0),P("Preparing backup...");try{P("Creating backup archive... This may take a while for large archives.");const{blob:ee,filename:z}=await ae.exportBackup();P("Downloading backup file...");const O=URL.createObjectURL(ee),Z=document.createElement("a");Z.href=O,Z.download=z,Z.click(),URL.revokeObjectURL(O),e("Backup downloaded successfully")}catch(ee){e(`Failed to create backup: ${ee instanceof Error?ee.message:"Unknown error"}`,"error")}finally{A(!1),P("")}},children:[a.jsx(_i,{className:"w-4 h-4"}),"Download"]})]}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:n("backup.restoreBackup")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.restoreDescription")}),a.jsx("p",{className:"text-xs text-bambu-gray-light mt-1",children:n("backup.restoreNote")})]}),a.jsx("input",{ref:I,type:"file",accept:".zip",className:"hidden",onChange:ee=>{const z=ee.target.files?.[0];z&&(D(z),F(!0)),ee.target.value=""}}),a.jsxs(Me,{variant:"secondary",size:"sm",disabled:k||M,onClick:()=>I.current?.click(),children:[a.jsx(Na,{className:"w-4 h-4"}),"Restore"]})]}),$&&a.jsx("div",{className:`p-3 rounded-lg ${$.success?"bg-green-500/10 border border-green-500/30":"bg-red-500/10 border border-red-500/30"}`,children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[$.success?a.jsx(fr,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):a.jsx(Ji,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:$.success?"text-green-200":"text-red-200",children:[$.message,$.success&&a.jsx("div",{className:"mt-2",children:a.jsxs(Me,{size:"sm",onClick:()=>window.location.reload(),children:[a.jsx(Vu,{className:"w-3 h-3"}),"Reload Now"]})})]})]})}),a.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(En,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-yellow-200",children:[a.jsx("span",{className:"font-medium",children:"Restore replaces all data."})," ",a.jsx("span",{className:"text-yellow-200/70",children:"Your current database and files will be completely replaced. A restart is required after restore."})]})]})})]})]})}),U&&B&&a.jsx(Qn,{title:"Restore Backup",message:`Are you sure you want to restore from "${B.name}"? This will completely replace your current database and all files. The application will need to be restarted after restore.`,confirmText:"Restore Backup",variant:"danger",onConfirm:async()=>{F(!1),R(!0),G(null);try{P("Uploading backup file...");const ee=await ae.importBackup(B);G(ee),ee.success?e("Backup restored. Please restart Bambuddy.","success"):e(ee.message,"error")}catch(ee){const z=ee instanceof Error?ee.message:"Failed to restore backup";G({success:!1,message:z}),e(z,"error")}finally{R(!1),P(""),D(null)}},onCancel:()=>{F(!1),D(null)}}),(M||k)&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),a.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:M?"Creating Backup":"Restoring Backup"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:C||(M?"Preparing...":"Processing...")}),a.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(En,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-yellow-200 text-left",children:"Please do not close this page or navigate away. This operation may take several minutes for large backups."})]})})]})})]})}function tXe(){const{t}=Yt(),{showToast:e}=kn(),n=nn(),[r,i]=_.useState({smtp_host:"",smtp_port:587,smtp_username:"",smtp_password:"",smtp_security:"starttls",smtp_auth_enabled:!0,smtp_from_email:"",smtp_from_name:"BamBuddy"}),[s,o]=_.useState(""),{data:l,isLoading:c}=nt({queryKey:["smtpSettings"],queryFn:()=>ae.getSMTPSettings()}),{data:u}=nt({queryKey:["advancedAuthStatus"],queryFn:()=>ae.getAdvancedAuthStatus()});_.useEffect(()=>{l&&i({...l,smtp_password:""})},[l]);const d=dt({mutationFn:x=>ae.saveSMTPSettings(x),onSuccess:()=>{n.invalidateQueries({queryKey:["smtpSettings"]}),n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(t("settings.email.success.settingsSaved"),"success")},onError:x=>{e(x.message,"error")}}),h=dt({mutationFn:x=>ae.testSMTP(x),onSuccess:x=>{e(x.message,x.success?"success":"error")},onError:x=>{e(x.message,"error")}}),p=dt({mutationFn:x=>x?ae.enableAdvancedAuth():ae.disableAdvancedAuth(),onSuccess:x=>{n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(x.message,"success")},onError:x=>{e(x.message,"error")}}),m=()=>{if(!r.smtp_host||!r.smtp_from_email){e(t("settings.email.errors.requiredFields"),"error");return}if(r.smtp_auth_enabled&&!r.smtp_username){e(t("settings.email.errors.usernameRequired"),"error");return}d.mutate(r)},b=()=>{if(!s){e(t("settings.email.errors.enterTestEmail"),"error");return}if(!r.smtp_host||!r.smtp_from_email){e(t("settings.email.errors.smtpServerAndEmail"),"error");return}if(r.smtp_auth_enabled&&(!r.smtp_username||!r.smtp_password)){e(t("settings.email.errors.usernamePasswordRequired"),"error");return}h.mutate({smtp_host:r.smtp_host,smtp_port:r.smtp_port,smtp_username:r.smtp_username,smtp_password:r.smtp_password,smtp_security:r.smtp_security,smtp_auth_enabled:r.smtp_auth_enabled,smtp_from_email:r.smtp_from_email,test_recipient:s})},y=()=>{if(!u?.advanced_auth_enabled&&!u?.smtp_configured){e(t("settings.email.errors.configureSmtpFirst"),"error");return}p.mutate(!u?.advanced_auth_enabled)};return c?a.jsx("div",{className:"flex items-center justify-center p-12",children:a.jsx(lt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):a.jsxs("div",{className:"space-y-6",children:[u?.smtp_configured&&a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Z0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.advancedAuth")||"Advanced Authentication"})]}),a.jsx(Me,{onClick:y,disabled:p.isPending,variant:u?.advanced_auth_enabled?"danger":"primary",children:u?.advanced_auth_enabled?a.jsxs(a.Fragment,{children:[a.jsx(A1,{className:"w-4 h-4"}),t("settings.email.disable")||"Disable"]}):a.jsxs(a.Fragment,{children:[a.jsx(Tf,{className:"w-4 h-4"}),t("settings.email.enable")||"Enable"]})})]})}),a.jsx(Mt,{children:a.jsx("div",{className:"space-y-4",children:u?.advanced_auth_enabled?a.jsx("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(fr,{className:"w-5 h-5 text-green-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-white font-medium",children:t("settings.email.advancedAuthEnabled")||"Advanced Authentication is enabled"}),a.jsxs("ul",{className:"text-sm text-green-300 space-y-1 list-disc list-inside",children:[a.jsx("li",{children:t("settings.email.feature1")||"Passwords are auto-generated and emailed to new users"}),a.jsx("li",{children:t("settings.email.feature2")||"Users can login with username or email"}),a.jsx("li",{children:t("settings.email.feature3")||"Forgot password feature is available"}),a.jsx("li",{children:t("settings.email.feature4")||"Admins can reset user passwords via email"})]})]})]})}):a.jsx("div",{className:"bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(En,{className:"w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-white font-medium",children:t("settings.email.advancedAuthDisabled")||"Advanced Authentication is disabled"}),a.jsx("p",{className:"text-sm text-yellow-300",children:t("settings.email.advancedAuthDisabledDesc")||"Enable advanced authentication to activate email-based features for user management."})]})]})})})})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.smtpSettings")||"SMTP Configuration"})}),a.jsx(Mt,{children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[t("settings.email.smtpHost")||"SMTP Server"," *"]}),a.jsx("input",{type:"text",value:r.smtp_host,onChange:x=>i({...r,smtp_host:x.target.value}),placeholder:"smtp.gmail.com",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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.smtpPort")||"SMTP Port"}),a.jsx("input",{type:"number",value:r.smtp_port,onChange:x=>i({...r,smtp_port:parseInt(x.target.value)||587}),placeholder:"587",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"})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.security")||"Security"}),a.jsxs("select",{value:r.smtp_security,onChange:x=>i({...r,smtp_security:x.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[a.jsx("option",{value:"starttls",children:t("settings.email.securityOptions.starttls")}),a.jsx("option",{value:"ssl",children:t("settings.email.securityOptions.ssl")}),a.jsx("option",{value:"none",children:t("settings.email.securityOptions.none")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.authentication")||"Authentication"}),a.jsxs("select",{value:r.smtp_auth_enabled?"true":"false",onChange:x=>i({...r,smtp_auth_enabled:x.target.value==="true"}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[a.jsx("option",{value:"true",children:t("settings.email.authOptions.enabled")}),a.jsx("option",{value:"false",children:t("settings.email.authOptions.disabled")})]})]})]}),r.smtp_auth_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.username")||"Username"}),a.jsx("input",{type:"text",value:r.smtp_username||"",onChange:x=>i({...r,smtp_username:x.target.value}),placeholder:"your.email@gmail.com",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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.password")||"Password"}),a.jsx("input",{type:"password",value:r.smtp_password||"",onChange:x=>i({...r,smtp_password:x.target.value}),placeholder:l?"••••••••":"App password",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"})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[t("settings.email.fromEmail")||"From Email"," *"]}),a.jsx("input",{type:"email",value:r.smtp_from_email,onChange:x=>i({...r,smtp_from_email:x.target.value}),placeholder:"your@email.com",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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.fromName")||"From Name"}),a.jsx("input",{type:"text",value:r.smtp_from_name,onChange:x=>i({...r,smtp_from_name:x.target.value}),placeholder:"BamBuddy",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"})]})]}),a.jsx("div",{className:"flex gap-2",children:a.jsx(Me,{onClick:m,disabled:d.isPending,className:"flex-1",children:d.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),t("settings.email.saving")||"Saving..."]}):t("settings.email.save")||"Save Settings"})})]})})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.testConnection")||"Test SMTP Connection"})}),a.jsx(Mt,{children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:t("settings.email.testRecipient")||"Test Recipient Email"}),a.jsx("input",{type:"email",value:s,onChange:x=>o(x.target.value),placeholder:"test@example.com",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"})]}),a.jsx(Me,{onClick:b,disabled:h.isPending,variant:"secondary",children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),t("settings.email.sending")||"Sending..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Pk,{className:"w-4 h-4"}),t("settings.email.sendTest")||"Send Test Email"]})})]})})]})]})}const nXe={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 rXe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function v0(t,e,n=0){if(n>5)return"...";if(e.$ref)return v0(t,rXe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const s=v0(t,i,n+1);typeof s=="object"&&s!==null&&Object.assign(r,s)}return r}if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"string";case"integer":case"number":return 0;case"boolean":return!1;case"array":return e.items?[v0(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,s]of Object.entries(e.properties))r[i]=v0(t,s,n+1);return r}return{};default:return null}}function iXe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[s,o]=_.useState(!1),[l,c]=_.useState({}),[u,d]=_.useState(""),[h,p]=_.useState(null),[m,b]=_.useState(!1),[y,x]=_.useState(!1);_.useEffect(()=>{if(s&&n.parameters){const R={};for(const C of n.parameters)C.schema?.default!==void 0&&(R[C.name]=String(C.schema.default));c(C=>({...R,...C}))}},[s,n.parameters]),_.useEffect(()=>{if(s&&n.requestBody?.content?.["application/json"]?.schema&&!u){const R=n.requestBody.content["application/json"].schema,C=v0(r,R);d(JSON.stringify(C,null,2))}},[s,n.requestBody,r,u]);const S=(()=>{const R=[];for(const C of n.parameters||[])if(C.in==="path"||C.required){const P=l[C.name];(P===void 0||P==="")&&R.push(C.name)}return R})(),N=async()=>{if(S.length>0){p({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}b(!0),p(null);try{let R=t;const C=new URLSearchParams;for(const se of n.parameters||[]){const H=l[se.name];H!==void 0&&H!==""&&(se.in==="path"?R=R.replace(`{${se.name}}`,encodeURIComponent(H)):se.in==="query"&&C.append(se.name,H))}const P=C.toString(),U=`${R}${P?`?${P}`:""}`,F={"Content-Type":"application/json"};i&&(F["X-API-Key"]=i);const B={method:e.toUpperCase(),headers:F};["post","put","patch"].includes(e)&&u&&(B.body=u);const D=performance.now(),$=await fetch(U,B),G=Math.round(performance.now()-D),I={};$.headers.forEach((se,H)=>{I[H]=se});let K;$.headers.get("content-type")?.includes("application/json")?K=await $.json():K=await $.text(),p({status:$.status,statusText:$.statusText,headers:I,body:K,duration:G})}catch(R){p({status:0,statusText:"Network Error",headers:{},body:R instanceof Error?R.message:"Unknown error",duration:0})}finally{b(!1)}},T=async()=>{if(h){const R=typeof h.body=="string"?h.body:JSON.stringify(h.body,null,2);try{await navigator.clipboard.writeText(R),x(!0),setTimeout(()=>x(!1),2e3)}catch{const C=document.createElement("textarea");C.value=R,C.style.position="fixed",C.style.left="-999999px",document.body.appendChild(C),C.select(),document.execCommand("copy"),document.body.removeChild(C),x(!0),setTimeout(()=>x(!1),2e3)}}},M=(n.parameters||[]).filter(R=>R.in==="path"),A=(n.parameters||[]).filter(R=>R.in==="query"),k=["post","put","patch"].includes(e)&&n.requestBody;return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[s?a.jsx(hr,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):a.jsx(Ns,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${nXe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),a.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&a.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),s&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&a.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),M.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),a.jsx("div",{className:"space-y-2",children:M.map(R=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),a.jsx("input",{type:"text",value:l[R.name]||"",onChange:C=>c(P=>({...P,[R.name]:C.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))})]}),A.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),a.jsx("div",{className:"space-y-2",children:A.map(R=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),R.schema?.enum?a.jsxs("select",{value:l[R.name]||"",onChange:C=>c(P=>({...P,[R.name]:C.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"-- Select --"}),R.schema.enum.map(C=>a.jsx("option",{value:C,children:C},C))]}):a.jsx("input",{type:"text",value:l[R.name]||"",onChange:C=>c(P=>({...P,[R.name]:C.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&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),a.jsx("textarea",{value:u,onChange: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..."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{onClick:N,disabled:m,children:[m?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(To,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&a.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[a.jsx(Ti,{className:"w-3 h-3"}),"Fill in: ",S.join(", ")]})]}),h&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",a.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${h.status>=200&&h.status<300?"bg-green-500/20 text-green-400":h.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[h.status," ",h.statusText]}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[h.duration,"ms"]})]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:T,children:y?a.jsx(fr,{className:"w-3 h-3 text-green-400"}):a.jsx(Bl,{className:"w-3 h-3"})})]}),a.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof h.body=="string"?h.body:JSON.stringify(h.body,null,2)})]})]})]})}function aXe({apiKey:t=""}){const[e,n]=_.useState(null),[r,i]=_.useState(!0),[s,o]=_.useState(null),[l,c]=_.useState(new Set),[u,d]=_.useState("");if(_.useEffect(()=>{async function x(){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)}}x()},[]),r)return a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(s||!e)return a.jsx(_t,{children:a.jsx(Mt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-red-400",children:[a.jsx(Ti,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),a.jsx("p",{children:"Failed to load API schema"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s})]})})});const h={};for(const[x,v]of Object.entries(e.paths))for(const[S,N]of Object.entries(v)){if(S==="parameters")continue;const T=N.tags||["Other"];for(const M of T)h[M]||(h[M]=[]),h[M].push({path:x,method:S,spec:N})}const p=Object.entries(h).map(([x,v])=>{if(!u)return{tag:x,endpoints:v};const S=v.filter(({path:N,method:T,spec:M})=>{const A=u.toLowerCase();return N.toLowerCase().includes(A)||T.toLowerCase().includes(A)||(M.summary?.toLowerCase()||"").includes(A)||(M.description?.toLowerCase()||"").includes(A)});return{tag:x,endpoints:S}}).filter(({endpoints:x})=>x.length>0).sort((x,v)=>x.tag.localeCompare(v.tag)),m=x=>{c(v=>{const S=new Set(v);return S.has(x)?S.delete(x):S.add(x),S})},b=()=>{c(new Set(p.map(x=>x.tag)))},y=()=>{c(new Set)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("div",{className:"flex-1",children:a.jsx("input",{type:"text",value:u,onChange:x=>d(x.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:b,children:"Expand All"}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:y,children:"Collapse All"}),a.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[a.jsx(Zr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[p.reduce((x,v)=>x+v.endpoints.length,0)," endpoints in ",p.length," categories"]}),a.jsx("div",{className:"space-y-3",children:p.map(({tag:x,endpoints:v})=>a.jsxs(_t,{children:[a.jsx("button",{onClick:()=>m(x),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:a.jsxs("div",{className:"flex items-center gap-2",children:[l.has(x)?a.jsx(hr,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(Ns,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:x.replace(/-/g," ")}),a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:v.length})]})}),l.has(x)&&a.jsx(Mt,{className:"pt-0 space-y-2",children:v.map(({path:S,method:N,spec:T})=>a.jsx(iXe,{path:S,method:N,spec:T,schema:e,apiKey:t},`${N}-${S}`))})]},x))})]})}const sXe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function oXe(){const t=nn(),e=Pc(),[n,r]=zR(),{t:i,i18n:s}=Yt(),{showToast:o}=kn(),{authEnabled:l,user:c,refreshAuth:u}=Rr(),{mode:d,darkStyle:h,darkBackground:p,darkAccent:m,lightStyle:b,lightBackground:y,lightAccent:x,setDarkStyle:v,setDarkBackground:S,setDarkAccent:N,setLightStyle:T,setLightBackground:M,setLightAccent:A}=Fm(),[k,R]=_.useState(null),[C,P]=_.useState(!1),[U,F]=_.useState(null),[B,D]=_.useState(!1),[$,G]=_.useState(null),[I,K]=_.useState(null),[Q,se]=_.useState(!1),[H,W]=_.useState(tK()),J=n.get("tab"),ne=J==="email",xe=ne?"users":J&&sXe.includes(J)?J:"general",[ue,fe]=_.useState(xe),[De,oe]=_.useState(ne?"email":"users"),Ne=ie=>{fe(ie),ie==="users"&&oe("users"),ie==="general"?n.delete("tab"):n.set("tab",ie),r(n,{replace:!0})},[Fe,ce]=_.useState(!1),[Ve,V]=_.useState(""),[Y,de]=_.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[q,re]=_.useState(null),[X,le]=_.useState(null),[pe,ee]=_.useState(""),[z,O]=_.useState(!1),[Z,me]=_.useState(!1),[Te,ke]=_.useState(null),[Ee,Se]=_.useState(!1),[$e,Qe]=_.useState(!1),[Ue,be]=_.useState(!1),[ve,ze]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[Ce,Ge]=_.useState(!1),[_e,Je]=_.useState(!1),[Ae,Ke]=_.useState(!1),[je,Re]=_.useState(null),[we,qe]=_.useState(null),[xt,Et]=_.useState(null),[fn,It]=_.useState(!1),[Oe,yt]=_.useState({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),[Wt,rn]=_.useState(!1),[Qt,ur]=_.useState(null),[Lr,nr]=_.useState(null),[Xt,Zn]=_.useState({name:"",description:"",permissions:[]}),[oi,da]=_.useState(new Set),[Pe,tt]=_.useState(null),[ht,mt]=_.useState(!1),[at,Dt]=_.useState({}),[he,Ie]=_.useState({}),Xe=ie=>{W(ie),eme(ie),o(i("settings.toast.settingsSaved"),"success")},He=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:ge,isLoading:rt}=nt({queryKey:["settings"],queryFn:ae.getSettings}),{data:ut,isLoading:it}=nt({queryKey:["smart-plugs"],queryFn:ae.getSmartPlugs}),{data:Tt,isLoading:Ut}=nt({queryKey:["smart-plugs-energy",ut?.map(ie=>ie.id)],queryFn:async()=>{if(!ut||ut.length===0)return null;const ie=await Promise.all(ut.filter(hs=>hs.enabled).map(async hs=>{try{const Ga=await ae.getSmartPlugStatus(hs.id);return{plug:hs,status:Ga}}catch{return{plug:hs,status:null}}}));let kt=0,In=0,Kn=0,jo=0,cd=0;for(const{plug:hs,status:Ga}of ie){const l2=hs.plug_type==="mqtt"&&Ga?.energy?.power!=null;(Ga?.reachable||l2)&&Ga?.energy&&(cd++,Ga.energy?.power!=null&&(kt+=Ga.energy.power),Ga.energy?.today!=null&&(In+=Ga.energy.today),Ga.energy?.yesterday!=null&&(Kn+=Ga.energy.yesterday),Ga.energy?.total!=null&&(jo+=Ga.energy.total))}return{totalPower:kt,totalToday:In,totalYesterday:Kn,totalLifetime:jo,reachableCount:cd,totalPlugs:ut.filter(hs=>hs.enabled).length}},enabled:ue==="plugs"&&!!ut&&ut.length>0,refetchInterval:ue==="plugs"?1e4:!1}),{data:jt,isLoading:Ct}=nt({queryKey:["notification-providers"],queryFn:ae.getNotificationProviders}),{data:an,isLoading:Vt}=nt({queryKey:["api-keys"],queryFn:ae.getAPIKeys}),gn=dt({mutationFn:ie=>ae.createAPIKey(ie),onSuccess:ie=>{re(ie.key||null),ce(!1),V(""),t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyCreated"))},onError:ie=>{o(`Failed to create API key: ${ie.message}`,"error")}}),Mn=dt({mutationFn:ie=>ae.deleteAPIKey(ie),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyDeleted"))},onError:ie=>{o(`Failed to delete API key: ${ie.message}`,"error")}}),{data:bn}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:qt,isLoading:sn}=nt({queryKey:["notification-templates"],queryFn:ae.getNotificationTemplates}),{data:Jt}=nt({queryKey:["virtual-printer-settings"],queryFn:C1.getSettings,refetchInterval:1e4}),mr=Jt?.status?.running??!1,{data:Hr}=nt({queryKey:["ffmpeg-status"],queryFn:ae.checkFfmpeg}),{data:Jn}=nt({queryKey:["version"],queryFn:ae.getVersion}),{data:Bn,refetch:gt,isRefetching:Rt}=nt({queryKey:["updateCheck"],queryFn:ae.checkForUpdates,staleTime:300*1e3}),{data:on,refetch:St}=nt({queryKey:["updateStatus"],queryFn:ae.getUpdateStatus,refetchInterval:ie=>{const kt=ie.state.data;return kt?.status==="downloading"||kt?.status==="installing"?1e3:!1}}),{data:pn}=nt({queryKey:["mqtt-status"],queryFn:ae.getMQTTStatus,refetchInterval:ue==="network"?5e3:!1}),{data:rr}=nt({queryKey:["github-backup-status"],queryFn:ae.getGitHubBackupStatus}),{data:ir}=nt({queryKey:["cloud-status"],queryFn:ae.getCloudStatus}),{data:gr={advanced_auth_enabled:!1,smtp_configured:!1}}=nt({queryKey:["advancedAuthStatus"],queryFn:()=>ae.getAdvancedAuthStatus()}),{hasPermission:ei}=Rr(),{data:Zt=[],isLoading:Sn}=nt({queryKey:["users"],queryFn:()=>ae.getUsers(),enabled:l&&ei("users:read")}),{data:ha=[],isLoading:us}=nt({queryKey:["groups"],queryFn:()=>ae.getGroups(),enabled:l&&ei("groups:read")}),{data:Ma}=nt({queryKey:["permissions"],queryFn:()=>ae.getPermissions(),enabled:l&&ei("groups:read")}),Js=dt({mutationFn:ie=>ae.createUser(ie),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Je(!1),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userCreated"))},onError:ie=>{o(ie.message,"error")}}),yl=dt({mutationFn:({id:ie,data:kt})=>ae.updateUser(ie,kt),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Ke(!1),Re(null),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userUpdated"))},onError:ie=>{o(ie.message,"error")}}),Ci=dt({mutationFn:({id:ie,deleteItems:kt})=>ae.deleteUser(ie,kt),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(i("settings.toast.userDeleted")),qe(null),Et(null)},onError:ie=>{o(ie.message,"error")}}),ds=dt({mutationFn:ie=>ae.resetUserPassword({user_id:ie}),onSuccess:ie=>{o(ie.message,"success")},onError:ie=>{o(ie.message,"error")}}),Oc=async ie=>{qe(ie),It(!0);try{const kt=await ae.getUserItemsCount(ie);Et(kt)}catch{Et({archives:0,queue_items:0,library_files:0})}finally{It(!1)}},$a=dt({mutationFn:ie=>ae.createGroup(ie),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),rn(!1),Wl(),o(i("settings.toast.groupCreated"))},onError:ie=>{o(ie.message,"error")}}),Ps=dt({mutationFn:({id:ie,data:kt})=>ae.updateGroup(ie,kt),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),ur(null),Wl(),o(i("settings.toast.groupUpdated"))},onError:ie=>{o(ie.message,"error")}}),Ea=dt({mutationFn:ie=>ae.deleteGroup(ie),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(i("settings.toast.groupDeleted"))},onError:ie=>{o(ie.message,"error")}}),Sr=()=>{const ie=gr?.advanced_auth_enabled||!1;if(!Oe.username){o(i("settings.toast.fillRequiredFields"),"error");return}if(ie&&!Oe.email){o("Email is required when advanced authentication is enabled","error");return}if(!ie){if(!Oe.password){o(i("settings.toast.fillRequiredFields"),"error");return}if(Oe.password!==Oe.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(Oe.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}Js.mutate({username:Oe.username,password:ie?void 0:Oe.password,email:Oe.email||void 0,role:Oe.role,group_ids:Oe.group_ids.length>0?Oe.group_ids:void 0})},eo=ie=>{if(Oe.password){if(Oe.password!==Oe.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(Oe.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}const kt={username:Oe.username||void 0,password:Oe.password||void 0,role:Oe.role,group_ids:Oe.group_ids};kt.password||delete kt.password,yl.mutate({id:ie,data:kt})},to=ie=>{Re(ie.id),yt({username:ie.username,password:"",email:ie.email||"",confirmPassword:"",role:ie.role,group_ids:ie.groups?.map(kt=>kt.id)||[]}),Ke(!0)},Gr=ie=>{yt(kt=>({...kt,group_ids:kt.group_ids.includes(ie)?kt.group_ids.filter(In=>In!==ie):[...kt.group_ids,ie]}))},Wl=()=>{Zn({name:"",description:"",permissions:[]}),da(new Set)},Vm=()=>{if(!Xt.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}$a.mutate({name:Xt.name,description:Xt.description||void 0,permissions:Xt.permissions})},Cv=()=>{if(Qt){if(!Xt.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}Ps.mutate({id:Qt.id,data:{name:Xt.name!==Qt.name?Xt.name:void 0,description:Xt.description,permissions:Xt.permissions}})}},Gm=ie=>{ur(ie),Zn({name:ie.name,description:ie.description||"",permissions:ie.permissions});const kt=new Set;Ma?.categories.forEach(In=>{In.permissions.some(Kn=>ie.permissions.includes(Kn.value))&&kt.add(In.name)}),da(kt)},qm=ie=>{da(kt=>{const In=new Set(kt);return In.has(ie)?In.delete(ie):In.add(ie),In})},Pv=ie=>{Zn(kt=>{const In=kt.permissions.includes(ie)?kt.permissions.filter(Kn=>Kn!==ie):[...kt.permissions,ie];return{...kt,permissions:In}})},Va=(ie,kt)=>{Zn(In=>{const Kn=ie.permissions.map(hs=>hs.value),jo=In.permissions.filter(hs=>!Kn.includes(hs)),cd=kt?[...jo,...Kn]:jo;return{...In,permissions:cd}})},vl=ie=>ie.permissions.every(kt=>Xt.permissions.includes(kt.value)),Yh=ie=>{const kt=ie.permissions.filter(In=>Xt.permissions.includes(In.value));return kt.length>0&&kt.length<ie.permissions.length},Lc=dt({mutationFn:ae.applyUpdate,onSuccess:ie=>{ie.is_docker?o(ie.message,"error"):St()}}),[ld,Qh]=_.useState(null),Zh=dt({mutationFn:ae.testAllNotificationProviders,onSuccess:ie=>{Qh(ie),t.invalidateQueries({queryKey:["notification-providers"]}),ie.failed===0?o(`All ${ie.tested} providers tested successfully!`,"success"):o(`${ie.success}/${ie.tested} providers succeeded`,ie.failed>0?"error":"success")},onError:ie=>{o(`Failed to test providers: ${ie.message}`,"error")}}),wl=dt({mutationFn:async ie=>{if(!ut)return{success:0,failed:0};const kt=ut.filter(Kn=>Kn.enabled),In=await Promise.all(kt.map(async Kn=>{try{return await ae.controlSmartPlug(Kn.id,ie),{success:!0}}catch{return{success:!1}}}));return{success:In.filter(Kn=>Kn.success).length,failed:In.filter(Kn=>!Kn.success).length}},onSuccess:(ie,kt)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),ie.failed===0?o(`All ${ie.success} plugs turned ${kt}`,"success"):o(`${ie.success} plugs turned ${kt}, ${ie.failed} failed`,"error")},onError:ie=>{o(`Failed: ${ie.message}`,"error")}}),Kl=_.useRef(null),Jh=_.useRef(!1),jv=_.useRef(!0);_.useEffect(()=>{if(ge&&!k){const ie={...ge,external_url:ge.external_url||window.location.origin};R(ie),setTimeout(()=>{jv.current=!1},100)}},[ge,k]);const Dv=dt({mutationFn:ae.updateSettings,onSuccess:ie=>{t.setQueryData(["settings"],ie),R(ie),t.invalidateQueries({queryKey:["archiveStats"]}),o(i("settings.toast.settingsSaved"),"success")},onError:ie=>{o(`Failed to save: ${ie.message}`,"error")},onSettled:()=>{Jh.current=!1}}),Rv=dt({mutationFn:({id:ie,data:kt})=>ae.updatePrinter(ie,kt),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(i("settings.toast.cameraSettingsSaved"),"success")},onError:ie=>{o(`Failed to update printer: ${ie.message}`,"error")}});_.useEffect(()=>{if(!(jv.current||!k||!ge||!(ge.auto_archive!==k.auto_archive||ge.save_thumbnails!==k.save_thumbnails||ge.capture_finish_photo!==k.capture_finish_photo||ge.default_filament_cost!==k.default_filament_cost||ge.currency!==k.currency||ge.energy_cost_per_kwh!==k.energy_cost_per_kwh||ge.energy_tracking_mode!==k.energy_tracking_mode||ge.check_updates!==k.check_updates||(ge.check_printer_firmware??!0)!==(k.check_printer_firmware??!0)||ge.notification_language!==k.notification_language||ge.ams_humidity_good!==k.ams_humidity_good||ge.ams_humidity_fair!==k.ams_humidity_fair||ge.ams_temp_good!==k.ams_temp_good||ge.ams_temp_fair!==k.ams_temp_fair||ge.ams_history_retention_days!==k.ams_history_retention_days||ge.per_printer_mapping_expanded!==k.per_printer_mapping_expanded||ge.date_format!==k.date_format||ge.time_format!==k.time_format||ge.default_printer_id!==k.default_printer_id||ge.ftp_retry_enabled!==k.ftp_retry_enabled||ge.ftp_retry_count!==k.ftp_retry_count||ge.ftp_retry_delay!==k.ftp_retry_delay||ge.ftp_timeout!==k.ftp_timeout||ge.mqtt_enabled!==k.mqtt_enabled||ge.mqtt_broker!==k.mqtt_broker||ge.mqtt_port!==k.mqtt_port||ge.mqtt_username!==k.mqtt_username||ge.mqtt_password!==k.mqtt_password||ge.mqtt_topic_prefix!==k.mqtt_topic_prefix||ge.mqtt_use_tls!==k.mqtt_use_tls||ge.external_url!==k.external_url||ge.ha_enabled!==k.ha_enabled||ge.ha_url!==k.ha_url||ge.ha_token!==k.ha_token||(ge.library_archive_mode??"ask")!==(k.library_archive_mode??"ask")||Number(ge.library_disk_warning_gb??5)!==Number(k.library_disk_warning_gb??5)||(ge.camera_view_mode??"window")!==(k.camera_view_mode??"window")||(ge.preferred_slicer??"bambu_studio")!==(k.preferred_slicer??"bambu_studio")||ge.prometheus_enabled!==k.prometheus_enabled||ge.prometheus_token!==k.prometheus_token))&&!Jh.current)return Kl.current&&clearTimeout(Kl.current),Kl.current=setTimeout(()=>{if(Jh.current)return;Jh.current=!0;const kt={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,preferred_slicer:k.preferred_slicer,prometheus_enabled:k.prometheus_enabled,prometheus_token:k.prometheus_token};Dv.mutate(kt)},500),()=>{Kl.current&&clearTimeout(Kl.current)}},[k,ge,Dv]);const xn=_.useCallback((ie,kt)=>{R(In=>In?{...In,[ie]:kt}:null)},[]),o2=async(ie,kt,In)=>{if(!kt){o(i("settings.toast.enterCameraUrl"),"error");return}Ie(Kn=>({...Kn,[ie]:!0})),Dt(Kn=>({...Kn,[ie]:null}));try{const Kn=await ae.testExternalCamera(ie,kt,In);Dt(jo=>({...jo,[ie]:Kn})),Kn.success?o(i("settings.toast.cameraConnected",{resolution:Kn.resolution||""}),"success"):o(Kn.error||i("settings.toast.connectionFailed"),"error")}catch(Kn){const jo=Kn instanceof Error?Kn.message:i("settings.toast.testFailed");Dt(cd=>({...cd,[ie]:{success:!1,error:jo}})),o(jo,"error")}finally{Ie(Kn=>({...Kn,[ie]:!1}))}},[Kb,Ov]=_.useState({}),Xb=_.useRef({}),Lv=_.useRef(new Set);_.useEffect(()=>{if(bn){const ie={};bn.forEach(kt=>{kt.external_camera_url&&!Lv.current.has(kt.id)&&(ie[kt.id]=kt.external_camera_url,Lv.current.add(kt.id))}),Object.keys(ie).length>0&&Ov(kt=>({...kt,...ie}))}},[bn]);const Fv=(ie,kt)=>{Ov(In=>({...In,[ie]:kt})),Xb.current[ie]&&clearTimeout(Xb.current[ie]),Xb.current[ie]=setTimeout(()=>{Rv.mutate({id:ie,data:{external_camera_url:kt||null}})},800)},Iv=(ie,kt)=>{const In={};kt.type!==void 0&&(In.external_camera_type=kt.type||null),kt.enabled!==void 0&&(In.external_camera_enabled=kt.enabled),Rv.mutate({id:ie,data:In})};return rt||!k?a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:i("settings.title")}),a.jsx("p",{className:"text-bambu-gray",children:i("settings.configureBambuddy")})]}),a.jsxs("div",{className:"flex flex-wrap gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>Ne("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${ue==="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")}),a.jsxs("button",{onClick:()=>Ne("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(sl,{className:"w-4 h-4"}),i("settings.tabs.smartPlugs"),ut&&ut.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ut.length})]}),a.jsxs("button",{onClick:()=>Ne("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Ag,{className:"w-4 h-4"}),i("settings.tabs.notifications"),jt&&jt.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:jt.length})]}),a.jsxs("button",{onClick:()=>Ne("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Lue,{className:"w-4 h-4"}),i("settings.tabs.filament")]}),a.jsxs("button",{onClick:()=>Ne("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Pg,{className:"w-4 h-4"}),i("settings.tabs.network"),a.jsx("span",{className:`w-2 h-2 rounded-full ${pn?.enabled?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>Ne("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Yo,{className:"w-4 h-4"}),i("settings.tabs.apiKeys"),an&&an.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:an.length})]}),a.jsxs("button",{onClick:()=>Ne("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Dr,{className:"w-4 h-4"}),i("settings.tabs.virtualPrinter"),a.jsx("span",{className:`w-2 h-2 rounded-full ${mr?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>Ne("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(rh,{className:"w-4 h-4"}),i("settings.tabs.users"),l&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]}),a.jsxs("button",{onClick:()=>Ne("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(ju,{className:"w-4 h-4"}),i("settings.tabs.backup"),a.jsx("span",{className:`w-2 h-2 rounded-full ${ir?.is_authenticated&&rr?.configured&&rr?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),ue==="general"&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(bh,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:s.language,onChange:ie=>{s.changeLanguage(ie.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:OU.map(ie=>a.jsxs("option",{value:ie.code,children:[ie.nativeName," (",ie.name,")"]},ie.code))}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:H,onChange:ie=>Xe(ie.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:ey.map(ie=>a.jsx("option",{value:ie.to,children:i(ie.labelKey)},ie.id))}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.defaultViewDescription")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:k.date_format||"system",onChange:ie=>xn("date_format",ie.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:i("settings.systemDefault")}),a.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),a.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),a.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:k.time_format||"system",onChange:ie=>xn("time_format",ie.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:i("settings.systemDefault")}),a.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),a.jsx("option",{value:"24h",children:"24-hour (15:30)"})]}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:k.default_printer_id??"",onChange:ie=>xn("default_printer_id",ie.target.value?Number(ie.target.value):null),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"",children:i("settings.noDefaultPrinter")}),bn?.map(ie=>a.jsx("option",{value:ie.id,children:ie.name},ie.id))]}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.preferredSlicer")}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:k.preferred_slicer??"bambu_studio",onChange:ie=>xn("preferred_slicer",ie.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"bambu_studio",children:"Bambu Studio"}),a.jsx("option",{value:"orcaslicer",children:"OrcaSlicer"})]}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.preferredSlicerDescription")})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.sidebarOrder")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:He,children:[a.jsx(Vu,{className:"w-4 h-4"}),"Reset"]})]})]})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx($W,{className:"w-5 h-5"}),"Appearance"]})}),a.jsxs(Mt,{className:"space-y-6",children:[a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",d==="dark"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:p,onChange:ie=>{S(ie.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:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"}),a.jsx("option",{value:"oled",children:"OLED Black"}),a.jsx("option",{value:"slate",children:"Slate Blue"}),a.jsx("option",{value:"forest",children:"Forest Green"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:m,onChange:ie=>{N(ie.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:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:h,onChange:ie=>{v(ie.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:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",d==="light"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:y,onChange:ie=>{M(ie.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:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:x,onChange:ie=>{A(ie.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:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:b,onChange:ie=>{T(ie.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:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.archiveSettings")})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Auto-archive prints"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.auto_archive,onChange:ie=>xn("auto_archive",ie.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.saveThumbnails")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.save_thumbnails,onChange:ie=>xn("save_thumbnails",ie.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.captureFinishPhoto")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.capture_finish_photo,onChange:ie=>xn("capture_finish_photo",ie.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.capture_finish_photo&&Hr&&!Hr.installed&&a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(En,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),a.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(JR,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),a.jsxs("select",{value:k.camera_view_mode??"window",onChange:ie=>xn("camera_view_mode",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:[a.jsx("option",{value:"window",children:i("settings.newWindow")}),a.jsx("option",{value:"embedded",children:i("settings.embeddedOverlay")})]}),a.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"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:i("settings.externalCameras")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Configure external cameras to replace the built-in printer camera. Supports MJPEG streams, RTSP, HTTP snapshots, and USB cameras (V4L2). When enabled, the external camera is used for live view and finish photos."}),bn&&bn.length>0?a.jsx("div",{className:"space-y-3",children:bn.map(ie=>a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-white font-medium text-sm",children:ie.name}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:ie.external_camera_enabled,onChange:kt=>Iv(ie.id,{enabled:kt.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),ie.external_camera_enabled&&a.jsxs("div",{className:"space-y-2 mt-2",children:[a.jsx("input",{type:"text",placeholder:ie.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:Kb[ie.id]??ie.external_camera_url??"",onChange:kt=>Fv(ie.id,kt.target.value),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:ie.external_camera_type||"mjpeg",onChange:kt=>Iv(ie.id,{type:kt.target.value}),className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),a.jsx("option",{value:"rtsp",children:"RTSP Stream"}),a.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),a.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>o2(ie.id,Kb[ie.id]??ie.external_camera_url??"",ie.external_camera_type||"mjpeg"),disabled:he[ie.id]||!(Kb[ie.id]??ie.external_camera_url),children:he[ie.id]?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):"Test"})]}),at[ie.id]&&a.jsx("div",{className:`text-xs flex items-center gap-1 ${at[ie.id]?.success?"text-green-500":"text-red-500"}`,children:at[ie.id]?.success?a.jsxs(a.Fragment,{children:[a.jsx(fr,{className:"w-3 h-3"}),"Connected",at[ie.id]?.resolution&&` (${at[ie.id]?.resolution})`]}):a.jsxs(a.Fragment,{children:[a.jsx(Ji,{className:"w-3 h-3"}),at[ie.id]?.error||i("settings.toast.connectionFailed")]})})]})]},ie.id))}):a.jsx("p",{className:"text-xs text-bambu-gray italic",children:i("settings.noPrintersConfigured")})]})]})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.costTracking")})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),a.jsx("select",{value:k.currency,onChange:ie=>xn("currency",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:TKe.map(ie=>a.jsx("option",{value:ie.code,children:ie.label},ie.code))})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:xu(k.currency)}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:k.default_filament_cost,onChange:ie=>xn("default_filament_cost",parseFloat(ie.target.value)||0),style:{paddingLeft:`${Math.max(2,xu(k.currency).length*.6+1)}rem`},className:"w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:xu(k.currency)}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:k.energy_cost_per_kwh,onChange:ie=>xn("energy_cost_per_kwh",parseFloat(ie.target.value)||0),style:{paddingLeft:`${Math.max(2,xu(k.currency).length*.6+1)}rem`},className:"w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),a.jsxs("select",{value:k.energy_tracking_mode||"total",onChange:ie=>xn("energy_tracking_mode",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:[a.jsx("option",{value:"print",children:i("settings.printsOnly")}),a.jsx("option",{value:"total",children:i("settings.totalConsumption")})]}),a.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"})]})]})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(xs,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),a.jsxs("select",{value:k.library_archive_mode??"ask",onChange:ie=>xn("library_archive_mode",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:[a.jsx("option",{value:"always",children:i("settings.archiveMode.always")}),a.jsx("option",{value:"never",children:i("settings.archiveMode.never")}),a.jsx("option",{value:"ask",children:i("settings.archiveMode.ask")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:k.library_disk_warning_gb??5,onChange:ie=>xn("library_disk_warning_gb",parseFloat(ie.target.value)||5),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[a.jsx(QKe,{}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.checkForUpdatesLabel")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.check_updates,onChange:ie=>xn("check_updates",ie.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.checkPrinterFirmware")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Check for printer firmware updates from Bambu Lab"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.check_printer_firmware??!0,onChange:ie=>xn("check_printer_firmware",ie.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.currentVersion")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Jn?.version||"..."]})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>gt(),disabled:Rt,children:[Rt?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ir,{className:"w-4 h-4"}),"Check now"]})]}),Bn?.update_available?a.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Bn.latest_version]}),Bn.release_name&&Bn.release_name!==Bn.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Bn.release_name})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[Bn.release_notes&&a.jsx("button",{onClick:()=>Se(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Bn.release_url&&a.jsx("a",{href:Bn.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:i("settings.viewReleaseOnGitHub"),children:a.jsx(Zr,{className:"w-4 h-4"})})]})]}),on?.status==="downloading"||on?.status==="installing"?a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{children:on.message})]}),a.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${on.progress}%`}})})]}):on?.status==="complete"?a.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:on.message}):on?.status==="error"?a.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:on.error||on.message}):Bn?.is_docker?a.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),a.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):a.jsxs(Me,{className:"mt-3",onClick:()=>Lc.mutate(),disabled:Lc.isPending,children:[Lc.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(_i,{className:"w-4 h-4"}),"Install Update"]})]}):Bn?.error?a.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",Bn.error]}):Bn&&!Bn.update_available?a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.dataManagement")})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.clearNotificationLogs")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.clearNotificationLogsDescription")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>O(!0),children:[a.jsx(hn,{className:"w-4 h-4"}),i("common.clear")]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.resetUiPreferences")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.resetUiPreferencesDescription")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>me(!0),children:[a.jsx(hn,{className:"w-4 h-4"}),"Reset"]})]}),a.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Backup & Restore"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Export/import settings and configure GitHub backup"})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Ne("backup"),children:[a.jsx(ju,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),ue==="network"&&k&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(bh,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),a.jsx("input",{type:"text",value:k.external_url??"",onChange:ie=>xn("external_url",ie.target.value),placeholder:"http://192.168.1.100:8000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ir,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Retry FTP operations when printer WiFi is unreliable. Applies to 3MF downloads, print uploads, timelapse downloads, and firmware updates."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.enableRetry")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.ftp_retry_enabled??!0,onChange:ie=>xn("ftp_retry_enabled",ie.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.ftp_retry_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),a.jsxs("div",{className:"relative w-44",children:[a.jsx("select",{value:k.ftp_retry_count??3,onChange:ie=>xn("ftp_retry_count",parseInt(ie.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:[1,2,3,4,5,6,7,8,9,10].map(ie=>a.jsxs("option",{value:ie,children:[ie," ",ie===1?"time":"times"]},ie))}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),a.jsxs("div",{className:"relative w-44",children:[a.jsx("select",{value:k.ftp_retry_delay??2,onChange:ie=>xn("ftp_retry_delay",parseInt(ie.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:[1,2,3,5,10,15,20,30].map(ie=>a.jsxs("option",{value:ie,children:[ie," ",ie===1?"second":"seconds"]},ie))}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),a.jsxs("div",{className:"relative w-44",children:[a.jsx("select",{value:k.ftp_timeout??30,onChange:ie=>xn("ftp_timeout",parseInt(ie.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:[10,15,20,30,45,60,90,120].map(ie=>a.jsxs("option",{value:ie,children:[ie," seconds"]},ie))}),a.jsx(hr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Increase for printers with weak WiFi"})]})]})]})]})]}),a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx($y,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),k.ha_enabled&&Pe&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Pe.success?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${Pe.success?"text-green-400":"text-red-400"}`,children:Pe.success?"Connected":"Disconnected"})]})]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, input_boolean, and script entities."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-white",children:i("settings.enableHomeAssistant")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.homeAssistantDescription")}),k.ha_env_managed&&a.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[a.jsx(Tf,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:i("settings.autoEnabledViaEnv")})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.ha_enabled??!1,onChange:ie=>xn("ha_enabled",ie.target.checked),disabled:k.ha_env_managed,className:"sr-only peer"}),a.jsx("div",{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green ${k.ha_env_managed?"opacity-60 cursor-not-allowed":""}`})]})]}),k.ha_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Home Assistant URL",k.ha_url_from_env&&a.jsx("span",{className:"ml-2 text-xs text-bambu-green",children:i("settings.environmentManagedLabel")})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",value:k.ha_url??"",onChange:ie=>xn("ha_url",ie.target.value),placeholder:"http://192.168.1.100:8123",disabled:k.ha_url_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${k.ha_url_from_env?"opacity-60 cursor-not-allowed":""}`}),k.ha_url_from_env&&a.jsx(Tf,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),k.ha_url_from_env&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.urlFromEnvReadOnly")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Long-Lived Access Token",k.ha_token_from_env&&a.jsx("span",{className:"ml-2 text-xs text-bambu-green",children:i("settings.environmentManagedLabel")})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"password",value:k.ha_token??"",onChange:ie=>xn("ha_token",ie.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",disabled:k.ha_token_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${k.ha_token_from_env?"opacity-60 cursor-not-allowed":""}`}),k.ha_token_from_env&&a.jsx(Tf,{className:"absolute right-3 top-2.5 w-4 h-4 text-bambu-gray"})]}),k.ha_token_from_env?a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.tokenFromEnvReadOnly")}):a.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&&a.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:a.jsxs(Me,{variant:"secondary",size:"sm",disabled:ht,onClick:async()=>{mt(!0),tt(null);try{const ie=await ae.testHAConnection(k.ha_url,k.ha_token);tt(ie)}catch(ie){tt({success:!1,message:null,error:ie instanceof Error?ie.message:i("common.unknownError")})}finally{mt(!1)}},children:[ht?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Pg,{className:"w-4 h-4"}),i("settings.testConnection")]})})]})]})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Pg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),pn?.enabled&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${pn.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${pn.connected?"text-green-400":"text-red-400"}`,children:pn.connected?"Connected":"Disconnected"})]})]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish BamBuddy events to an external MQTT broker for integration with Node-RED, Home Assistant, and other automation systems."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.enableMqtt")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.mqtt_enabled??!1,onChange:ie=>xn("mqtt_enabled",ie.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.mqtt_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),a.jsx("input",{type:"text",value:k.mqtt_broker??"",onChange:ie=>xn("mqtt_broker",ie.target.value),placeholder:"mqtt.example.com or 192.168.1.100",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-end gap-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),a.jsx("input",{type:"number",min:"1",max:"65535",value:k.mqtt_port??1883,onChange:ie=>xn("mqtt_port",Math.min(65535,Math.max(1,parseInt(ie.target.value)||1883))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.mqtt_use_tls??!1,onChange:ie=>{const kt=ie.target.checked;xn("mqtt_use_tls",kt);const In=k.mqtt_port??1883;kt&&In===1883?xn("mqtt_port",8883):!kt&&In===8883&&xn("mqtt_port",1883)},className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]}),a.jsx("span",{className:"text-white text-sm",children:i("settings.useTls")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),a.jsx("input",{type:"text",value:k.mqtt_username??"",onChange:ie=>xn("mqtt_username",ie.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),a.jsx("input",{type:"password",value:k.mqtt_password??"",onChange:ie=>xn("mqtt_password",ie.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),a.jsx("input",{type:"text",value:k.mqtt_topic_prefix??"bambuddy",onChange:ie=>xn("mqtt_topic_prefix",ie.target.value),placeholder:"bambuddy",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",k.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),pn&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${pn.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:"text-bambu-gray",children:pn.connected?a.jsxs(a.Fragment,{children:[i("settings.mqttConnectedTo")," ",a.jsxs("span",{className:"text-white",children:[pn.broker,":",pn.port]})]}):i("settings.spoolmanDisconnected")})]})})]})]})]})]}),a.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Lj,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Expose printer metrics at ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"/api/v1/metrics"})," for Prometheus/Grafana monitoring."]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.enableMetricsEndpoint")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.prometheusDescription")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.prometheus_enabled??!1,onChange:ie=>xn("prometheus_enabled",ie.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),k.prometheus_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bearer Token (optional)"}),a.jsx("input",{type:"password",value:k.prometheus_token??"",onChange:ie=>xn("prometheus_token",ie.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"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["If set, requests must include ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"Authorization: Bearer <token>"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-white mb-2",children:i("settings.availableMetrics")}),a.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - Connection status"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - Printer state (idle/printing/etc)"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - Print progress 0-100%"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - Bed temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - Nozzle temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - Total prints by result"]}),a.jsx("p",{className:"text-bambu-gray/70 italic",children:"...and more (layers, fans, queue, filament usage)"})]})]})]})]})]})})]}),Pe&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[Pe.success?a.jsx(fr,{className:"w-8 h-8 text-green-400"}):a.jsx(Ji,{className:"w-8 h-8 text-red-400"}),a.jsx("h3",{className:"text-lg font-medium text-white",children:Pe.success?"Connection Successful":"Connection Failed"})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:Pe.success?Pe.message||"Successfully connected to Home Assistant.":Pe.error||"Failed to connect to Home Assistant."}),a.jsx("div",{className:"flex justify-end",children:a.jsx(Me,{variant:"primary",onClick:()=>tt(null),children:"OK"})})]})}),ue==="plugs"&&a.jsxs("div",{className:"max-w-4xl",children:[a.jsxs("div",{className:"flex items-start justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(sl,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers."})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ut&&ut.filter(ie=>ie.enabled).length>1&&a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ke("on"),disabled:wl.isPending,title:i("settings.turnAllPlugsOn"),children:[wl.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(nd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),a.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ke("off"),disabled:wl.isPending,title:i("settings.turnAllPlugsOff"),children:[wl.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ck,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),a.jsxs(Me,{className:"whitespace-nowrap",onClick:()=>{F(null),P(!0)},children:[a.jsx(lr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ut&&ut.length>0&&a.jsxs(_t,{className:"mb-6",children:[a.jsx(Cn,{children:a.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[a.jsx(Ch,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Ut&&a.jsx(lt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),a.jsx(Mt,{children:Tt?a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(Ch,{className:"w-3 h-3"}),"Current Power"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Tt.totalPower.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Tt.reachableCount,"/",Tt.totalPlugs," plugs online"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(Qr,{className:"w-3 h-3"}),"Today"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Tt.totalToday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(k?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Tt.totalToday*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",xu(k?.currency||"USD")]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(Lj,{className:"w-3 h-3"}),"Yesterday"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Tt.totalYesterday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(k?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Tt.totalYesterday*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",xu(k?.currency||"USD")]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(Aj,{className:"w-3 h-3"}),"Total"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Tt.totalLifetime.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),(k?.energy_cost_per_kwh??0)>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Tt.totalLifetime*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",xu(k?.currency||"USD")]})]})]}):Ut?null:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),it?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ut&&ut.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ut.map(ie=>a.jsx(IKe,{plug:ie,onEdit:kt=>{F(kt),P(!0)}},ie.id))}):a.jsx(_t,{children:a.jsx(Mt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(sl,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.noSmartPlugsTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.noSmartPlugsDescription")}),a.jsxs(Me,{onClick:()=>{F(null),P(!0)},children:[a.jsx(lr,{className:"w-4 h-4"}),i("settings.addFirstSmartPlug")]})]})})})]}),ue==="notifications"&&a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ag,{className:"w-5 h-5 text-bambu-green"}),i("settings.providers")]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>se(!0),children:[a.jsx(Q0,{className:"w-4 h-4"}),i("settings.log")]}),jt&&jt.length>0&&a.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>{Qh(null),Zh.mutate()},disabled:Zh.isPending,children:[Zh.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Pk,{className:"w-4 h-4"}),i("settings.testAll")]}),a.jsxs(Me,{size:"sm",onClick:()=>{G(null),D(!0)},children:[a.jsx(lr,{className:"w-4 h-4"}),"Add"]})]})]}),a.jsx(_t,{className:"mb-4",children:a.jsx(Mt,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.notificationLanguage")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),a.jsx("select",{value:k.notification_language||"en",onChange:ie=>xn("notification_language",ie.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:OU.map(ie=>a.jsx("option",{value:ie.code,children:ie.nativeName},ie.code))})]})})}),ld&&a.jsx(_t,{className:"mb-4",children:a.jsxs(Mt,{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm font-medium text-white",children:i("settings.testResults")}),a.jsx("button",{onClick:()=>Qh(null),className:"text-bambu-gray hover:text-white text-xs",children:i("common.dismiss")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(fr,{className:"w-4 h-4"}),i("settings.testPassedCount",{count:ld.success})]}),ld.failed>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(Ji,{className:"w-4 h-4"}),i("settings.testFailedCount",{count:ld.failed})]})]}),ld.results.filter(ie=>!ie.success).length>0&&a.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:ld.results.filter(ie=>!ie.success).map(ie=>a.jsxs("div",{className:"text-xs text-red-400",children:[a.jsxs("span",{className:"font-medium",children:[ie.provider_name,":"]})," ",ie.message]},ie.provider_id))})]})}),Ct?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):jt&&jt.length>0?a.jsx("div",{className:"space-y-3",children:jt.map(ie=>a.jsx(BKe,{provider:ie,onEdit:kt=>{G(kt),D(!0)}},ie.id))}):a.jsx(_t,{children:a.jsx(Mt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Ag,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:i("settings.noProvidersTitle")}),a.jsx("p",{className:"text-xs mb-3",children:i("settings.noProvidersDescription")}),a.jsxs(Me,{size:"sm",onClick:()=>{G(null),D(!0)},children:[a.jsx(lr,{className:"w-4 h-4"}),i("settings.addProvider")]})]})})})]}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[a.jsx(xs,{className:"w-5 h-5 text-bambu-green"}),i("settings.messageTemplates")]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:i("settings.messageTemplatesDescription")}),sn?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):qt&&qt.length>0?a.jsx("div",{className:"space-y-2",children:qt.map(ie=>a.jsx(_t,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>K(ie),children:a.jsx(Mt,{className:"py-2.5 px-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium text-sm truncate",children:ie.name}),a.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:ie.title_template})]}),a.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:kt=>{kt.stopPropagation(),K(ie)},children:a.jsx(wg,{className:"w-4 h-4 text-bambu-gray"})})]})})},ie.id))}):a.jsx(_t,{children:a.jsx(Mt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(xs,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:i("settings.noTemplatesAvailable")})]})})})]})]}),ue==="apikeys"&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Yo,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiKeys")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiKeysDescription")})]}),a.jsxs(Me,{size:"sm",onClick:()=>ce(!0),className:"flex-shrink-0",children:[a.jsx(lr,{className:"w-4 h-4"}),i("settings.createKey")]})]}),q&&a.jsx(_t,{className:"mb-6 border-bambu-green",children:a.jsx(Mt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(fr,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:i("settings.apiKeyCreated")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:i("settings.apiKeyCopyWarning")}),a.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[a.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:q}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(q);else{const ie=document.createElement("textarea");ie.value=q,ie.style.position="fixed",ie.style.left="-999999px",document.body.appendChild(ie),ie.select(),document.execCommand("copy"),document.body.removeChild(ie)}o(i("settings.toast.keyCopied"))}catch{o(i("settings.toast.copyFailed"),"error")}},children:a.jsx(Bl,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{ee(q),o(i("settings.toast.keyAddedToBrowser"))},children:i("settings.useInApiBrowser")}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>re(null),children:i("common.dismiss")})]})]})]})})}),Fe&&a.jsxs(_t,{className:"mb-6",children:[a.jsx(Cn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.createNewApiKey")})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keyName")}),a.jsx("input",{type:"text",value:Ve,onChange:ie=>V(ie.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("common.permissions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Y.can_read_status,onChange:ie=>de(kt=>({...kt,can_read_status:ie.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.readStatus")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.readStatusDescription")})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Y.can_queue,onChange:ie=>de(kt=>({...kt,can_queue:ie.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.manageQueue")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.manageQueueDescription")})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Y.can_control_printer,onChange:ie=>de(kt=>({...kt,can_control_printer:ie.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:i("settings.controlPrinter")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.controlPrinterDescription")})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsxs(Me,{onClick:()=>gn.mutate({name:Ve||i("settings.unnamedKey"),...Y}),disabled:gn.isPending,children:[gn.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(lr,{className:"w-4 h-4"}),i("settings.createKey")]}),a.jsx(Me,{variant:"secondary",onClick:()=>ce(!1),children:i("common.cancel")})]})]})]}),Vt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):an&&an.length>0?a.jsx("div",{className:"space-y-3",children:an.map(ie=>a.jsx(_t,{children:a.jsx(Mt,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Yo,{className:`w-5 h-5 ${ie.enabled?"text-bambu-green":"text-bambu-gray"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:ie.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[ie.key_prefix,"••••••••",ie.last_used&&` · ${i("settings.lastUsed")}: ${Xg(ie.last_used)}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex gap-1 text-xs",children:[ie.can_read_status&&a.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:i("settings.read")}),ie.can_queue&&a.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:i("queue.title")}),ie.can_control_printer&&a.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:i("settings.control")})]}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>le(ie.id),children:a.jsx(hn,{className:"w-4 h-4 text-red-400"})})]})]})})},ie.id))}):a.jsx(_t,{children:a.jsx(Mt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Yo,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.apiKeysEmptyTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.apiKeysEmptyDescription")}),a.jsxs(Me,{onClick:()=>ce(!0),children:[a.jsx(lr,{className:"w-4 h-4"}),i("settings.createFirstKey")]})]})})}),a.jsxs(_t,{className:"mt-6",children:[a.jsx(Cn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.webhookEndpoints")})}),a.jsxs(Mt,{className:"space-y-3 text-sm",children:[a.jsx("p",{className:"text-bambu-gray",children:i("settings.webhookApiKeyHint")}),a.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getAllStatus")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getSpecificStatus")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-green-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.addToQueue")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.pausePrint")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.resumePrint")]})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-red-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),a.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.stopPrint")]})]})]})]})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(bh,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiBrowser")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiBrowserDescription")})]}),a.jsx(_t,{className:"mb-4",children:a.jsxs(Mt,{className:"py-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("settings.apiKeyForTesting")}),a.jsx("input",{type:"text",value:pe,onChange:ie=>ee(ie.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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:i("settings.apiKeyHint")})]})}),a.jsx(aXe,{apiKey:pe})]})]}),ue==="virtual-printer"&&a.jsx(ZKe,{}),ue==="filament"&&k&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsx("div",{className:"flex-1 lg:max-w-xl",children:a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.amsDisplayThresholds")})}),a.jsxs(Mt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.amsThresholdsDescription")}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(WR,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"font-medium",children:i("settings.humidity")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodGreen")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:k.ams_humidity_good??40,onChange:ie=>xn("ams_humidity_good",parseInt(ie.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:k.ams_humidity_fair??60,onChange:ie=>xn("ams_humidity_fair",parseInt(ie.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairBad")})]}),a.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Dk,{className:"w-4 h-4 text-orange-400"}),a.jsx("span",{className:"font-medium",children:i("settings.temperature")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodBlue")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:k.ams_temp_good??28,onChange:ie=>xn("ams_temp_good",parseFloat(ie.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:k.ams_temp_fair??35,onChange:ie=>xn("ams_temp_fair",parseFloat(ie.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairHot")})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(ju,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"font-medium",children:i("settings.historyRetention")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keepSensorHistory")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"365",value:k.ams_history_retention_days??30,onChange:ie=>xn("ams_history_retention_days",parseInt(ie.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:i("common.days")})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.historyRetentionDescription")})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Dr,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"font-medium",children:i("settings.printModal")})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-white",children:i("settings.expandCustomMapping")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:i("settings.expandCustomMappingDescription")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.per_printer_mapping_expanded??!1,onChange:ie=>xn("per_printer_mapping_expanded",ie.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})]})]})]})}),a.jsx("div",{className:"flex-1 lg:max-w-xl",children:a.jsx(XKe,{})})]}),X!==null&&a.jsx(Qn,{title:i("settings.deleteApiKeyTitle"),message:i("settings.deleteApiKeyMessage"),confirmText:i("settings.deleteKey"),variant:"danger",onConfirm:()=>{Mn.mutate(X),le(null)},onCancel:()=>le(null)}),C&&a.jsx(zKe,{plug:U,onClose:()=>{P(!1),F(null)}}),B&&a.jsx(HKe,{provider:$,onClose:()=>{D(!1),G(null)}}),I&&a.jsx($Ke,{template:I,onClose:()=>K(null)}),Q&&a.jsx(qKe,{onClose:()=>se(!1)}),z&&a.jsx(Qn,{title:i("settings.clearNotificationLogs"),message:i("settings.clearLogsMessage"),confirmText:i("settings.clearLogs"),variant:"warning",onConfirm:async()=>{O(!1);try{const ie=await ae.clearNotificationLogs(30);o(ie.message,"success")}catch{o(i("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>O(!1)}),Z&&a.jsx(Qn,{title:i("settings.resetUiPreferences"),message:i("settings.resetUiPreferencesMessage"),confirmText:i("settings.resetPreferences"),variant:"default",onConfirm:()=>{me(!1),localStorage.clear(),o(i("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>me(!1)}),Te&&a.jsx(Qn,{title:`Turn All Plugs ${Te==="on"?"On":"Off"}`,message:`This will turn ${Te==="on"?"ON":"OFF"} all ${ut?.filter(ie=>ie.enabled).length||0} enabled smart plugs. ${Te==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${Te==="on"?"On":"Off"}`,variant:Te==="off"?"danger":"warning",onConfirm:()=>{const ie=Te;ke(null),wl.mutate(ie)},onCancel:()=>ke(null)}),Ee&&Bn?.release_notes&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Se(!1),children:a.jsxs(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:ie=>ie.stopPropagation(),children:[a.jsxs(Cn,{className:"flex flex-row items-center justify-between shrink-0",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",Bn.latest_version]}),Bn.release_name&&Bn.release_name!==Bn.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray",children:Bn.release_name})]}),a.jsx("button",{onClick:()=>Se(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsx(Mt,{className:"overflow-y-auto flex-1",children:a.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Bn.release_notes})}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Bn.release_url&&a.jsx("a",{href:Bn.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:a.jsxs(Me,{variant:"secondary",className:"w-full",children:[a.jsx(Zr,{className:"w-4 h-4"}),"View on GitHub"]})}),a.jsx(Me,{onClick:()=>Se(!1),className:"flex-1",children:"Close"})]})]})}),ue==="users"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex gap-1 border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>oe("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${De==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(rh,{className:"w-4 h-4"}),i("settings.tabs.users")]}),a.jsxs("button",{onClick:()=>oe("email"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${De==="email"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Z0,{className:"w-4 h-4"}),i("settings.tabs.emailAuth")||"Email Authentication",gr?.advanced_auth_enabled&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]})]}),De==="users"&&a.jsxs(a.Fragment,{children:[a.jsx(_t,{children:a.jsx(Mt,{className:"py-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?a.jsx(Tf,{className:"w-5 h-5 text-green-400"}):a.jsx(A1,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-white font-medium",children:i("settings.authentication")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i(l?"settings.authEnabledDescription":"settings.authDisabledDescription")})]})]}),l?c?.is_admin&&a.jsxs(Me,{variant:"secondary",onClick:()=>Qe(!0),children:[a.jsx(A1,{className:"w-4 h-4"}),i("common.disable")]}):a.jsxs(Me,{onClick:()=>e("/setup"),children:[a.jsx(Tf,{className:"w-4 h-4"}),i("common.enable")]})]})})}),gr?.advanced_auth_enabled&&a.jsx(_t,{className:"border-blue-500/30 bg-blue-500/5",children:a.jsx(Mt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0",children:a.jsx(Z0,{className:"w-5 h-5 text-blue-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-white font-medium",children:i("settings.email.advancedAuthEnabled")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.email.advancedAuthEnabledDesc")})]})]})})}),l&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[c&&a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(rh,{className:"w-5 h-5 text-bambu-green"}),i("settings.currentUser")]}),a.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>be(!0),children:[a.jsx(Yo,{className:"w-4 h-4"}),i("settings.changePassword")]})]})}),a.jsx(Mt,{children:a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-lg",children:c.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[c.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),c.groups?.map(ie=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${ie.name==="Administrators"?"bg-purple-500/20 text-purple-300":ie.name==="Operators"?"bg-blue-500/20 text-blue-300":ie.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:ie.name},ie.id))]})]})})})]}),a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(rh,{className:"w-5 h-5 text-bambu-green"}),i("settings.users")]}),ei("users:create")&&a.jsxs(Me,{size:"sm",onClick:()=>{Je(!0),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:[a.jsx(lr,{className:"w-4 h-4"}),i("settings.addUser")]})]})}),a.jsx(Mt,{children:Sn?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Zt.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noUsersFound")}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:Zt.map(ie=>a.jsxs("div",{className:"py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:ie.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[ie.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),ie.groups?.map(kt=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${kt.name==="Administrators"?"bg-purple-500/20 text-purple-300":kt.name==="Operators"?"bg-blue-500/20 text-blue-300":kt.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:kt.name},kt.id))]})]}),a.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[ei("users:update")&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>to(ie),children:a.jsx(wg,{className:"w-4 h-4"})}),ei("users:delete")&&ie.id!==c?.id&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>Oc(ie.id),children:a.jsx(hn,{className:"w-4 h-4"})})]})]},ie.id))})})]})]}),a.jsx("div",{children:a.jsxs(_t,{children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(xT,{className:"w-5 h-5 text-bambu-green"}),i("settings.groups")]}),ei("groups:create")&&a.jsxs(Me,{size:"sm",onClick:()=>{rn(!0),Wl()},children:[a.jsx(lr,{className:"w-4 h-4"}),i("settings.addGroup")]})]})}),a.jsx(Mt,{children:us?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):ha.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noGroupsFound")}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:ha.map(ie=>a.jsxs("div",{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xT,{className:`w-4 h-4 ${ie.name==="Administrators"?"text-purple-400":ie.name==="Operators"?"text-blue-400":ie.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),a.jsx("span",{className:"text-white font-medium",children:ie.name}),ie.is_system&&a.jsx("span",{className:"px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:i("settings.system")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[ei("groups:update")&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>Gm(ie),children:a.jsx(wg,{className:"w-4 h-4"})}),ei("groups:delete")&&!ie.is_system&&a.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>nr(ie.id),children:a.jsx(hn,{className:"w-4 h-4"})})]})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:ie.description||i("settings.noDescription")}),a.jsxs("div",{className:"flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray",children:[a.jsx("span",{children:i("settings.userCount",{count:ie.user_count})}),a.jsx("span",{children:i("settings.permissionCount",{count:ie.permissions.length})})]})]},ie.id))})})]})})]}),!l&&a.jsx(_t,{children:a.jsx(Mt,{className:"py-6",children:a.jsxs("div",{className:"text-center",children:[a.jsx(A1,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:i("settings.authDisabledTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4 max-w-md mx-auto",children:i("settings.authDisabledMessage")}),a.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto",children:[a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(fr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature1")})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(fr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature2")})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(fr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature3")})]})]}),a.jsxs(Me,{onClick:()=>e("/setup"),children:[a.jsx(Tf,{className:"w-4 h-4"}),i("settings.enableAuthentication")]})]})})})]}),De==="email"&&a.jsx("div",{className:"max-w-2xl",children:a.jsx(tXe,{})})]}),_e&&!gr?.advanced_auth_enabled&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Je(!1),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:ie=>ie.stopPropagation(),children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.createUser")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{Je(!1),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Mt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.username")}),a.jsx("input",{type:"text",value:Oe.username,onChange:ie=>yt({...Oe,username:ie.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.password")}),a.jsx("input",{type:"password",value:Oe.password,onChange:ie=>yt({...Oe,password:ie.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),a.jsx("input",{type:"password",value:Oe.confirmPassword,onChange:ie=>yt({...Oe,confirmPassword:ie.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 ${Oe.confirmPassword&&Oe.password!==Oe.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),Oe.confirmPassword&&Oe.password!==Oe.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),a.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[ha.map(ie=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Oe.group_ids.includes(ie.id),onChange:()=>Gr(ie.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:ie.name}),ie.is_system&&a.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},ie.id)),ha.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{Je(!1),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),a.jsx(Me,{onClick:Sr,disabled:Js.isPending||!Oe.username||!Oe.password||Oe.password!==Oe.confirmPassword||Oe.password.length<6,children:Js.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(lr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),_e&&gr?.advanced_auth_enabled&&a.jsx(KKe,{formData:Oe,setFormData:yt,groups:ha,onClose:()=>{Je(!1),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},onCreate:Sr,isCreating:Js.isPending,isCreateButtonDisabled:Js.isPending||!Oe.username||!Oe.email}),Ae&&je!==null&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Ke(!1),Re(null),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:ie=>ie.stopPropagation(),children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(wg,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.editUser")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{Ke(!1),Re(null),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Mt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[i("settings.username")," ",gr?.advanced_auth_enabled&&a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",value:Oe.username,onChange:ie=>yt({...Oe,username:ie.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"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[i("users.form.email")||"Email"," ",gr?.advanced_auth_enabled?a.jsx("span",{className:"text-red-400",children:"*"}):a.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",i("users.form.optional")||"optional",")"]})]}),a.jsx("input",{type:"email",value:Oe.email,onChange:ie=>yt({...Oe,email:ie.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("users.form.emailPlaceholder")||"user@example.com",required:gr?.advanced_auth_enabled})]}),!gr?.advanced_auth_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:[i("users.form.password")||"Password"," ",a.jsxs("span",{className:"text-bambu-gray font-normal",children:["(",i("users.form.leaveBlankToKeep")||"leave blank to keep current",")"]})]}),a.jsx("input",{type:"password",value:Oe.password,onChange:ie=>yt({...Oe,password:ie.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})]}),Oe.password&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),a.jsx("input",{type:"password",value:Oe.confirmPassword,onChange:ie=>yt({...Oe,confirmPassword:ie.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 ${Oe.confirmPassword&&Oe.password!==Oe.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),Oe.confirmPassword&&Oe.password!==Oe.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),gr?.advanced_auth_enabled&&a.jsxs("div",{className:"bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("users.form.passwordManagedByAdvancedAuth")||'Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.'}),a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>je&&ds.mutate(je),disabled:ds.isPending||!Oe.email,className:"w-full",children:ds.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),i("users.form.resettingPassword")||"Resetting Password..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Vu,{className:"w-4 h-4"}),i("users.form.resetPassword")||"Reset Password"]})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("users.form.groups")||"Groups"}),a.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:ha.map(ie=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Oe.group_ids.includes(ie.id),onChange:()=>Gr(ie.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:ie.name}),ie.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",i("users.system")||"System",")"]})]},ie.id))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{Ke(!1),Re(null),yt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:i("users.modal.cancel")||"Cancel"}),a.jsx(Me,{onClick:()=>eo(je),disabled:yl.isPending||!Oe.username||gr?.advanced_auth_enabled&&!Oe.email||!!(!gr?.advanced_auth_enabled&&Oe.password&&(Oe.password!==Oe.confirmPassword||Oe.password.length<6)),children:yl.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),i("users.modal.saving")||"Saving..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ys,{className:"w-4 h-4"}),i("users.modal.saveChanges")||"Save Changes"]})})]})]})]})}),we!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{qe(null),Et(null)},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:ie=>ie.stopPropagation(),children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[a.jsx(hn,{className:"w-5 h-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:i("settings.deleteUserTitle")})]})}),a.jsx(Mt,{className:"space-y-4",children:fn?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent"})}):xt&&xt.archives+xt.queue_items+xt.library_files>0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:i("settings.userHasCreated")}),a.jsxs("ul",{className:"list-disc list-inside text-bambu-gray space-y-1",children:[xt.archives>0&&a.jsxs("li",{children:[xt.archives," archive",xt.archives!==1?"s":""]}),xt.queue_items>0&&a.jsxs("li",{children:[xt.queue_items," queue item",xt.queue_items!==1?"s":""]}),xt.library_files>0&&a.jsxs("li",{children:[xt.library_files," library file",xt.library_files!==1?"s":""]})]}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.userItemsQuestion")}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Me,{variant:"danger",onClick:()=>Ci.mutate({id:we,deleteItems:!0}),disabled:Ci.isPending,className:"justify-center",children:"Delete user AND their items"}),a.jsx(Me,{variant:"secondary",onClick:()=>Ci.mutate({id:we,deleteItems:!1}),disabled:Ci.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),a.jsx(Me,{variant:"ghost",onClick:()=>{qe(null),Et(null)},disabled:Ci.isPending,className:"justify-center",children:"Cancel"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:i("settings.deleteUserConfirm")}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.actionCannotBeUndone")}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Me,{variant:"ghost",onClick:()=>{qe(null),Et(null)},disabled:Ci.isPending,children:"Cancel"}),a.jsx(Me,{variant:"danger",onClick:()=>Ci.mutate({id:we,deleteItems:!1}),disabled:Ci.isPending,children:"Delete User"})]})]})})]})}),(Wt||Qt)&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{rn(!1),ur(null),Wl()},children:a.jsxs(_t,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:ie=>ie.stopPropagation(),children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xT,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:Qt?"Edit Group":"Create Group"})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{rn(!1),ur(null),Wl()},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Mt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.groupName")}),a.jsx("input",{type:"text",value:Xt.name,onChange:ie=>Zn({...Xt,name:ie.target.value}),disabled:Qt?.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")}),Qt?.is_system&&a.jsx("p",{className:"text-xs text-yellow-400 mt-1",children:i("settings.systemGroupWarning")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Description"}),a.jsx("textarea",{value:Xt.description,onChange:ie=>Zn({...Xt,description:ie.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")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Permissions (",Xt.permissions.length," selected)"]}),a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:Ma?.categories.map(ie=>a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary cursor-pointer hover:bg-bambu-dark-tertiary transition-colors",onClick:()=>qm(ie.name),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:kt=>{kt.stopPropagation(),Va(ie,!vl(ie))},className:`w-5 h-5 rounded border flex items-center justify-center transition-colors ${vl(ie)?"bg-bambu-green border-bambu-green":Yh(ie)?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:(vl(ie)||Yh(ie))&&a.jsx(Vi,{className:"w-3 h-3 text-white"})}),a.jsx("span",{className:"text-white font-medium",children:ie.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",ie.permissions.filter(kt=>Xt.permissions.includes(kt.value)).length,"/",ie.permissions.length,")"]})]}),oi.has(ie.name)?a.jsx(hr,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(Ns,{className:"w-4 h-4 text-bambu-gray"})]}),oi.has(ie.name)&&a.jsx("div",{className:"p-3 bg-bambu-dark space-y-2",children:ie.permissions.map(kt=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Xt.permissions.includes(kt.value),onChange:()=>Pv(kt.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:kt.label})]},kt.value))})]},ie.name))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{rn(!1),ur(null),Wl()},children:"Cancel"}),a.jsx(Me,{onClick:Qt?Cv:Vm,disabled:$a.isPending||Ps.isPending||!Xt.name.trim(),children:$a.isPending||Ps.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),Qt?"Saving...":"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ys,{className:"w-4 h-4"}),Qt?"Save Changes":"Create Group"]})})]})]})]})}),Lr!==null&&a.jsx(Qn,{title:i("settings.deleteGroupTitle"),message:i("settings.deleteGroupMessage"),confirmText:i("settings.deleteGroup"),variant:"danger",onConfirm:()=>{Ea.mutate(Lr),nr(null)},onCancel:()=>nr(null)}),ue==="backup"&&a.jsx(eXe,{}),$e&&a.jsx(Qn,{title:i("settings.disableAuthenticationTitle"),message:i("settings.disableAuthenticationMessage"),confirmText:i("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await ae.disableAuth(),o(i("settings.toast.authDisabled"),"success"),await u(),Qe(!1),window.location.href="/"}catch(ie){const kt=ie instanceof Error?ie.message:i("settings.toast.authDisableFailed");o(kt,"error")}},onCancel:()=>Qe(!1)}),Ue&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{be(!1),ze({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:ie=>ie.stopPropagation(),children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yo,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.changePassword")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{be(!1),ze({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Mt,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Current Password"}),a.jsx("input",{type:"password",value:ve.currentPassword,onChange:ie=>ze({...ve,currentPassword:ie.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),a.jsx("input",{type:"password",value:ve.newPassword,onChange:ie=>ze({...ve,newPassword:ie.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),a.jsx("input",{type:"password",value:ve.confirmPassword,onChange:ie=>ze({...ve,confirmPassword:ie.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&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>{be(!1),ze({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),a.jsx(Me,{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}Ge(!0);try{await ae.changePassword(ve.currentPassword,ve.newPassword),o(i("settings.toast.passwordChanged"),"success"),be(!1),ze({currentPassword:"",newPassword:"",confirmPassword:""})}catch(ie){const kt=ie instanceof Error?ie.message:"Failed to change password";o(kt,"error")}finally{Ge(!1)}},disabled:Ce||!ve.currentPassword||!ve.newPassword||ve.newPassword!==ve.confirmPassword||ve.newPassword.length<6,children:Ce?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Yo,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const lie=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},lXe=t=>t.startsWith("HH")?"HF":"S",cXe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},TR=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const r of e)if(t.startsWith(r))return t.slice(r.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function aj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:o}){const l=lXe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&s?s():e()};return a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?a.jsx(Ks,{className:"w-4 h-4 text-bambu-green"}):a.jsx(ul,{className:"w-4 h-4"})}),a.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:lie(t.k_value)}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&a.jsx("span",{title:"Has note",children:a.jsx(qW,{className:"w-3 h-3 text-yellow-500"})}),a.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&a.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&a.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:a.jsx(Bl,{className:"w-4 h-4"})})]})}function sj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u,hasPermission:d}){const{t:h}=Yt(),{showToast:p}=kn(),[m,b]=_.useState(t?.name||""),[y,x]=_.useState(t?.k_value?lie(t.k_value):"0.020"),[v,S]=_.useState(t?.filament_id||""),[N,T]=_.useState(t?.nozzle_id?cXe(t.nozzle_id):"HH00"),[M,A]=_.useState(t?.nozzle_diameter||n),[k,R]=_.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,P]=_.useState(!1),[U,F]=_.useState({current:0,total:0}),[B,D]=_.useState(s),$=ri.useMemo(()=>{const W=new Map;for(const J of r)if(J.filament_id&&!W.has(J.filament_id)){const ne=TR(J.name||"");W.set(J.filament_id,{id:J.filament_id,name:ne||J.filament_id})}return Array.from(W.values()).sort((J,ne)=>J.name.localeCompare(ne.name))},[r]),G=dt({mutationFn:W=>(console.log("[KProfile] Calling API..."),ae.setKProfile(e,W)),onSuccess:W=>{if(console.log("[KProfile] Save success:",W),p(h("kProfiles.toast.profileSaved")),u&&B!==s){let J;B===""&&o?J=o:t&&t.slot_id>0?J=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:J=`name_${m}_${v}`,u(J,B)}P(!0),setTimeout(()=>{P(!1),c()},2500)},onError:W=>{console.error("[KProfile] Save error:",W),p(W.message,"error"),P(!1)}}),I=dt({mutationFn:W=>(console.log("[KProfile] Deleting profile..."),ae.deleteKProfile(e,W)),onSuccess:W=>{console.log("[KProfile] Delete success:",W),p(h("kProfiles.toast.profileDeleted")),P(!0),setTimeout(()=>{P(!1),l()},4e3)},onError:W=>{console.error("[KProfile] Delete error:",W),p(W.message,"error"),P(!1)}}),[K,Q]=_.useState(!1),se=()=>{t&&I.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})},H=async W=>{if(W.preventDefault(),i&&!t&&k.length===0){p(h("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const J=parseFloat(y).toFixed(6),ne=`${N}-${M}`;if(t||k.length===1){const ue={name:m,k_value:J,filament_id:v,nozzle_id:ne,nozzle_diameter:M,extruder_id:t?t.extruder_id:k[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ue),G.mutate(ue);return}P(!0),F({current:1,total:k.length});const xe=k.map(ue=>({name:m,k_value:J,filament_id:v,nozzle_id:ne,nozzle_diameter:M,extruder_id:ue,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${xe.length} profiles in batch:`,xe);try{if(await ae.setKProfilesBatch(e,xe),p(h("kProfiles.toast.profilesSaved",{count:k.length})),u&&B){const ue=`name_${m}_${v}`;u(ue,B)}}catch(ue){console.error("[KProfile] Failed to save batch:",ue),p(h("kProfiles.toast.failedToSaveBatch"),"error"),P(!1),F({current:0,total:0});return}F({current:k.length,total:k.length}),setTimeout(()=>{P(!1),F({current:0,total:0}),c()},3e3)};return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[a.jsxs(_t,{className:"w-full max-w-md relative",children:[C&&a.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:U.total>1?h("kProfiles.modal.savingExtruder",{current:U.current,total:U.total}):h("kProfiles.modal.syncing")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:h("kProfiles.modal.pleaseWait")})]}),a.jsxs(Mt,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:h(t?"kProfiles.modal.editTitle":"kProfiles.modal.addTitle")}),a.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:C,children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:H,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.profileName")}),a.jsx("input",{type:"text",value:m,onChange:W=>b(W.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:h("kProfiles.modal.profileNamePlaceholder"),required:!t})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.kValue")}),a.jsx("input",{type:"text",inputMode:"decimal",value:y,onChange:W=>{const J=W.target.value;(J===""||/^\d*\.?\d*$/.test(J))&&x(J)},onBlur:W=>{const J=parseFloat(W.target.value);isNaN(J)||x((Math.trunc(J*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:h("kProfiles.modal.kValuePlaceholder"),required:!0}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:h("kProfiles.modal.kValueHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.filament")}),a.jsxs("select",{value:v,onChange:W=>{const J=W.target.value;if(S(J),!t&&J&&!m){const ne=$.find(xe=>xe.id===J);ne&&b(`${N==="HH00"?"HF":"S"} ${ne.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[a.jsx("option",{value:"",children:h("kProfiles.modal.selectFilament")}),t?.filament_id&&a.jsx("option",{value:t.filament_id,children:$.find(W=>W.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&$.map(W=>a.jsx("option",{value:W.id,children:W.name},W.id))]}),!t&&$.length===0&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:h("kProfiles.modal.noFilamentsHelp")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.flowType")}),a.jsxs("select",{value:N,onChange:W=>{const J=W.target.value;if(T(J),!t&&v&&!m){const ne=$.find(xe=>xe.id===v);ne&&b(`${J==="HS00"?"HF":"S"} ${ne.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[a.jsx("option",{value:"HH00",children:h("kProfiles.modal.highFlow")}),a.jsx("option",{value:"HS00",children:h("kProfiles.modal.standard")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.nozzleSize")}),a.jsxs("select",{value:M,onChange:W=>A(W.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h(t?"kProfiles.modal.extruder":"kProfiles.modal.extruders")}),t?a.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?h("kProfiles.modal.left"):h("kProfiles.modal.right")}):a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.includes(1),onChange:W=>{W.target.checked?R([...k,1]):R(k.filter(J=>J!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),a.jsx("span",{className:"text-white",children:h("kProfiles.modal.left")})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.includes(0),onChange:W=>{W.target.checked?R([...k,0]):R(k.filter(J=>J!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),a.jsx("span",{className:"text-white",children:h("kProfiles.modal.right")})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.notes")}),a.jsx("textarea",{value:B,onChange:W=>D(W.target.value),placeholder:h("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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:h("kProfiles.modal.notesHelp")})]}),a.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&a.jsx(Me,{type:"button",variant:"secondary",onClick:()=>Q(!0),disabled:I.isPending||C||!d("kprofiles:delete"),title:d("kprofiles:delete")?void 0:h("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:I.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(hn,{className:"w-4 h-4"})}),a.jsx(Me,{type:"button",variant:"secondary",onClick:l,disabled:C,className:"flex-1",children:h("common.cancel")}),a.jsxs(Me,{type:"submit",disabled:G.isPending||C||!d(t?"kprofiles:update":"kprofiles:create"),title:d(t?"kprofiles:update":"kprofiles:create")?void 0:h(t?"kProfiles.permission.noUpdate":"kProfiles.permission.noCreate"),className:"flex-1",children:[G.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Mk,{className:"w-4 h-4"}),h("common.save")]})]})]})]})]}),K&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.jsx(_t,{className:"w-full max-w-sm",children:a.jsxs(Mt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(hn,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:h("kProfiles.deleteConfirm.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:h("kProfiles.deleteConfirm.cannotUndo")})]})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:h("kProfiles.deleteConfirm.message",{name:t?.name})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>Q(!1),className:"flex-1",children:h("common.cancel")}),a.jsxs(Me,{onClick:()=>{Q(!1),se()},disabled:I.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[I.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(hn,{className:"w-4 h-4"}),h("common.delete")]})]})]})})})]})}const M1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function uXe(){const{t}=Yt(),{showToast:e}=kn(),{hasPermission:n}=Rr(),[r,i]=_.useState(null),[s,o]=_.useState(()=>localStorage.getItem(M1.NOZZLE_DIAMETER)||"0.4"),[l,c]=_.useState(null),[u,d]=_.useState(!1),[h,p]=_.useState(null),[m,b]=_.useState(""),[y,x]=_.useState("all"),[v,S]=_.useState("all"),[N,T]=_.useState(()=>localStorage.getItem(M1.SORT_OPTION)||"name"),[M,A]=_.useState(!1),[k,R]=_.useState(new Set),[C,P]=_.useState(!1),[U,F]=_.useState(!1),B=_.useCallback(X=>`${X.slot_id}_${X.extruder_id}`,[]);_.useEffect(()=>{localStorage.setItem(M1.NOZZLE_DIAMETER,s)},[s]),_.useEffect(()=>{localStorage.setItem(M1.SORT_OPTION,N)},[N]);const{data:D,isLoading:$}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:G,isLoading:I,isFetching:K,error:Q,refetch:se}=nt({queryKey:["kprofiles",r,s],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",s);const X=await ae.getKProfiles(r,s);return console.log("[KProfiles] Received profiles:",X?.profiles?.length||0,"profiles"),X},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:H}=nt({queryKey:["kprofiles",r,"0.4"],queryFn:()=>ae.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:W,refetch:J}=nt({queryKey:["kprofile-notes",r],queryFn:()=>ae.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),ne=Q?.message?.includes("not connected");_.useEffect(()=>{if(!r&&D&&D.length>0){const X=D.find(le=>le.is_active);X&&i(X.id)}},[r,D]),_.useEffect(()=>{if(r){const X=setTimeout(()=>{se()},150);return()=>clearTimeout(X)}},[r,s]);const xe=D?.filter(X=>X.is_active)||[],ue=ri.useMemo(()=>G?.profiles?G.profiles.filter(le=>{const pe=m.toLowerCase(),ee=!pe||le.name.toLowerCase().includes(pe)||le.filament_id.toLowerCase().includes(pe),z=y==="all"||y==="left"&&le.extruder_id===1||y==="right"&&le.extruder_id===0,O=v==="all"||v==="hf"&&le.nozzle_id.startsWith("HH")||v==="s"&&le.nozzle_id.startsWith("HS");return ee&&z&&O}).sort((le,pe)=>{switch(N){case"k_value":return parseFloat(le.k_value)-parseFloat(pe.k_value);case"filament":return TR(le.name).localeCompare(TR(pe.name));case"name":default:return le.name.localeCompare(pe.name)}}):[],[G?.profiles,m,y,v,N]),fe=D?.find(X=>X.id===r),De=fe?.nozzle_count===2;_.useEffect(()=>{const X=le=>{le.target instanceof HTMLInputElement||le.target instanceof HTMLTextAreaElement||le.target instanceof HTMLSelectElement||l||u||h||(le.key==="r"||le.key==="R"?(le.preventDefault(),se()):le.key==="n"||le.key==="N"?(le.preventDefault(),d(!0)):le.key==="Escape"&&M&&(le.preventDefault(),A(!1),R(new Set)))};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[l,u,h,M,se]);const oe=_.useCallback(()=>{if(!G?.profiles||G.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const X={version:1,exported_at:new Date().toISOString(),printer:fe?.name||"Unknown",nozzle_diameter:s,profiles:G.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}))},le=new Blob([JSON.stringify(X,null,2)],{type:"application/json"}),pe=URL.createObjectURL(le),ee=document.createElement("a");ee.href=pe,ee.download=`kprofiles_${fe?.name||"printer"}_${s}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(pe),e(t("kProfiles.toast.exportedProfiles",{count:G.profiles.length}))},[G?.profiles,fe,s,e,t]),Ne=_.useCallback(()=>{const X=document.createElement("input");X.type="file",X.accept=".json",X.onchange=async le=>{const pe=le.target.files?.[0];if(pe)try{const ee=await pe.text(),z=JSON.parse(ee);if(!z.profiles||!Array.isArray(z.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let O=0;for(const Z of z.profiles)if(!(!Z.name||!Z.k_value||!Z.filament_id))try{await ae.setKProfile(r,{name:Z.name,k_value:parseFloat(Z.k_value).toFixed(6),filament_id:Z.filament_id,nozzle_id:Z.nozzle_id||`HH00-${s}`,nozzle_diameter:Z.nozzle_diameter||s,extruder_id:Z.extruder_id??0,slot_id:0}),O++,await new Promise(me=>setTimeout(me,500))}catch(me){console.error("Failed to import profile:",Z.name,me)}e(t("kProfiles.toast.importedProfiles",{count:O,total:z.profiles.length})),se()}catch(ee){console.error("Import error:",ee),e(t("kProfiles.toast.failedToParseImport"),"error")}},X.click()},[r,s,e,se,t]),Fe=_.useCallback(X=>{R(le=>{const pe=new Set(le);return pe.has(X)?pe.delete(X):pe.add(X),pe})},[]),ce=_.useCallback(()=>{R(new Set(ue.map(X=>B(X))))},[ue,B]),Ve=_.useCallback(()=>{k.size!==0&&P(!0)},[k.size]),V=_.useCallback(async()=>{const X=ue.filter(pe=>k.has(B(pe)));F(!0);let le=0;for(const pe of X)try{await ae.deleteKProfile(r,{slot_id:pe.slot_id,extruder_id:pe.extruder_id,nozzle_id:pe.nozzle_id,nozzle_diameter:pe.nozzle_diameter,filament_id:pe.filament_id,setting_id:pe.setting_id}),le++,await new Promise(ee=>setTimeout(ee,300))}catch(ee){console.error("Failed to delete profile:",pe.name,ee)}e(t("kProfiles.toast.profilesDeleted",{count:le})),F(!1),P(!1),A(!1),R(new Set),se()},[r,k,ue,e,se,B,t]),Y=_.useCallback(X=>{const le=[];return X.setting_id&&le.push(X.setting_id),le.push(`slot_${X.slot_id}_${X.filament_id}_${X.extruder_id}`),le.push(`name_${X.name}_${X.filament_id}`),le},[]),de=_.useCallback(async(X,le)=>{if(r)try{await ae.setKProfileNote(r,X,le),J()}catch(pe){console.error("Failed to save note:",pe),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,J,e,t]),q=_.useCallback(X=>{if(!W?.notes)return{note:"",key:null};const le=Y(X);for(const pe of le)if(W.notes[pe])return{note:W.notes[pe],key:pe};return{note:"",key:null}},[W,Y]),re=_.useCallback(X=>q(X).note,[q]);return $?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!D||D.length===0?a.jsx(_t,{children:a.jsxs(Mt,{className:"py-12 text-center",children:[a.jsx(Ti,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noPrintersConfigured")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.addPrinterInSettings")})]})}):xe.length===0?a.jsx(_t,{children:a.jsxs(Mt,{className:"py-12 text-center",children:[a.jsx(Dr,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noActivePrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.enablePrinterConnection")})]})}):a.jsxs(a.Fragment,{children:[K&&!I&&a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[a.jsx(lt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:t("kProfiles.loadingProfiles")})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1 min-w-48",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.printer")}),a.jsx("select",{value:r||"",onChange:X=>i(parseInt(X.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:xe.map(X=>a.jsx("option",{value:X.id,children:X.name},X.id))})]}),a.jsxs("div",{className:"w-32",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.nozzle")}),a.jsxs("select",{value:s,onChange:X=>o(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:()=>se(),disabled:K||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[a.jsx(Ir,{className:`w-4 h-4 ${K?"animate-spin":""}`}),t("kProfiles.refresh")]}),a.jsxs(Me,{onClick:()=>d(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[a.jsx(lr,{className:"w-4 h-4"}),t("kProfiles.addProfile")]})]})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[a.jsxs("div",{className:"flex-1 min-w-48 relative",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:m,onChange:X=>b(X.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"})]}),De&&a.jsx("div",{className:"w-36",children:a.jsxs("select",{value:y,onChange:X=>x(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:t("kProfiles.allExtruders")}),a.jsx("option",{value:"left",children:t("kProfiles.leftOnly")}),a.jsx("option",{value:"right",children:t("kProfiles.rightOnly")})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:v,onChange:X=>S(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:t("kProfiles.allFlow")}),a.jsx("option",{value:"hf",children:t("kProfiles.hfOnly")}),a.jsx("option",{value:"s",children:t("kProfiles.sOnly")})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:N,onChange:X=>T(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"name",children:t("kProfiles.sortName")}),a.jsx("option",{value:"k_value",children:t("kProfiles.sortKValue")}),a.jsx("option",{value:"filament",children:t("kProfiles.sortFilament")})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[a.jsxs(Me,{variant:"secondary",onClick:oe,disabled:!G?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[a.jsx(_i,{className:"w-4 h-4"}),t("kProfiles.export")]}),a.jsxs(Me,{variant:"secondary",onClick:Ne,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[a.jsx(Na,{className:"w-4 h-4"}),t("kProfiles.import")]}),a.jsx("div",{className:"flex-1"}),M?a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",onClick:ce,children:[a.jsx(Ks,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),a.jsxs(Me,{variant:"secondary",onClick:Ve,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:[a.jsx(hn,{className:"w-4 h-4"}),t("kProfiles.delete")," (",k.size,")"]}),a.jsxs(Me,{variant:"secondary",onClick:()=>{A(!1),R(new Set)},children:[a.jsx(Lt,{className:"w-4 h-4"}),t("common.cancel")]})]}):a.jsxs(Me,{variant:"secondary",onClick:()=>A(!0),disabled:!ue.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[a.jsx(Ks,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),I?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ne?a.jsx(_t,{children:a.jsxs(Mt,{className:"py-12 text-center",children:[a.jsx(bm,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.printerOffline")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.printerOfflineDesc")}),a.jsxs(Me,{variant:"secondary",onClick:()=>se(),children:[a.jsx(Ir,{className:"w-4 h-4"}),t("common.refresh")]})]})}):ue.length>0?De?a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.leftExtruder")}),a.jsx("div",{className:"space-y-1",children:ue.filter(X=>X.extruder_id===1).map(X=>a.jsx(aj,{profile:X,onEdit:()=>c(X),onCopy:()=>p(X),selectionMode:M,isSelected:k.has(B(X)),onToggleSelect:()=>Fe(B(X)),note:re(X)},B(X)))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.rightExtruder")}),a.jsx("div",{className:"space-y-1",children:ue.filter(X=>X.extruder_id===0).map(X=>a.jsx(aj,{profile:X,onEdit:()=>c(X),onCopy:()=>p(X),selectionMode:M,isSelected:k.has(B(X)),onToggleSelect:()=>Fe(B(X)),note:re(X)},B(X)))})]})]}):a.jsx("div",{className:"space-y-1",children:ue.map(X=>a.jsx(aj,{profile:X,onEdit:()=>c(X),onCopy:()=>p(X),selectionMode:M,isSelected:k.has(B(X)),onToggleSelect:()=>Fe(B(X)),note:re(X)},B(X)))}):m||y!=="all"||v!=="all"?a.jsx(_t,{children:a.jsxs(Mt,{className:"py-12 text-center",children:[a.jsx(Zi,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noMatchingProfiles")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.noMatchingProfilesDesc")})]})}):a.jsx(_t,{children:a.jsxs(Mt,{className:"py-12 text-center",children:[a.jsx(Mk,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noKProfiles")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.noKProfilesDesc",{diameter:s})}),a.jsxs(Me,{onClick:()=>d(!0),children:[a.jsx(lr,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:X,key:le}=q(l);return a.jsx(sj,{profile:l,printerId:r,nozzleDiameter:s,existingProfiles:H?.profiles||G?.profiles,isDualNozzle:De,initialNote:X,initialNoteKey:le,onSaveNote:de,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),se()},onSave:()=>{c(null),se()}})})(),u&&r&&a.jsx(sj,{printerId:r,nozzleDiameter:s,existingProfiles:H?.profiles||G?.profiles,isDualNozzle:De,onSaveNote:de,hasPermission:n,onClose:()=>{d(!1),se()},onSave:()=>{d(!1),se()}}),h&&r&&a.jsx(sj,{printerId:r,nozzleDiameter:s,existingProfiles:H?.profiles||G?.profiles,isDualNozzle:De,onSaveNote:de,hasPermission:n,profile:{...h,slot_id:0,name:`${h.name} (Copy)`},onClose:()=>{p(null),se()},onSave:()=>{p(null),se()}}),C&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-sm",children:a.jsxs(Mt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(hn,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:t("kProfiles.bulkDelete.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("kProfiles.bulkDelete.cannotUndo")})]})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:t("kProfiles.bulkDelete.message",{count:k.size})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Me,{variant:"secondary",onClick:()=>P(!1),disabled:U,className:"flex-1",children:t("common.cancel")}),a.jsxs(Me,{onClick:V,disabled:U,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[U?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(hn,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}const cie=["PLA","PETG","ABS","ASA","TPU","PC","PA","PVA","HIPS","PP","PET","NYLON"],dXe={PLA:"E8E8E8",PETG:"4A90D9",ABS:"E67E22",ASA:"D35400",TPU:"9B59B6",PC:"BDC3C7",PA:"2ECC71",NYLON:"2ECC71",PVA:"F1C40F",HIPS:"95A5A6",PP:"ECF0F1",PET:"3498DB"};function hXe(t){const e=t.toUpperCase();for(const n of cie)if(new RegExp(`\\b${n}\\b`).test(e))return n;return null}function fXe(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const r of cie){const i=n.indexOf(r);if(i>0){const s=e.slice(0,i).trim();if(s&&s.length>1)return s}}return null}function oj({preset:t,onDelete:e,onExpand:n,isExpanded:r}){const{t:i}=Yt(),{hasPermission:s}=Rr(),o=t.filament_type||hXe(t.name),l=t.filament_vendor||fXe(t.name);let c=null,u=!1;if(t.default_filament_colour)try{const d=JSON.parse(t.default_filament_colour),h=Array.isArray(d)?d[0]:d;typeof h=="string"&&/^#?[0-9a-fA-F]{6,8}$/.test(h.replace("#",""))&&(c=h.replace("#","").slice(0,6),u=!0)}catch{const d=t.default_filament_colour;/^#?[0-9a-fA-F]{6,8}$/.test(d.replace("#",""))&&(c=d.replace("#","").slice(0,6),u=!0)}return!c&&o&&(c=dXe[o.toUpperCase()]||null),a.jsx(_t,{className:"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors",children:a.jsxs(Mt,{className:"p-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.preset_type==="filament"&&a.jsx("div",{className:`w-4 h-4 rounded-full border border-white/20 flex-shrink-0 ${!u&&!c?"opacity-25":u?"":"opacity-50"}`,style:{backgroundColor:c?`#${c}`:"#666"}}),a.jsx("span",{className:"text-sm font-medium text-white truncate",children:t.name})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:o}),l&&a.jsx("span",{className:"text-xs text-bambu-gray",children:l}),a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400",children:i("profiles.localProfiles.badge")})]})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s("settings:update")&&a.jsx("button",{onClick:()=>e(t.id),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",title:i("profiles.localProfiles.delete"),children:a.jsx(hn,{className:"w-3.5 h-3.5"})}),a.jsx("button",{onClick:()=>n(r?null:t.id),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:r?a.jsx(Hu,{className:"w-3.5 h-3.5"}):a.jsx(hr,{className:"w-3.5 h-3.5"})})]})]}),r&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary text-xs space-y-1.5",children:[o&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.filamentType")}),a.jsx("span",{className:"text-white",children:o})]}),l&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.vendor")}),a.jsx("span",{className:"text-white",children:l})]}),t.nozzle_temp_min!=null&&t.nozzle_temp_max!=null&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.nozzleTemp")}),a.jsxs("span",{className:"text-white",children:[t.nozzle_temp_min,"–",t.nozzle_temp_max,"°C"]})]}),t.filament_cost&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.cost")}),a.jsx("span",{className:"text-white",children:t.filament_cost})]}),t.filament_density&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.density")}),a.jsxs("span",{className:"text-white",children:[t.filament_density," g/cm³"]})]}),t.pressure_advance&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.pressureAdvance")}),a.jsx("span",{className:"text-white",children:t.pressure_advance})]}),t.compatible_printers&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.compatiblePrinters")}),a.jsx("span",{className:"text-white truncate ml-2",children:(()=>{try{return JSON.parse(t.compatible_printers).join(", ")}catch{return t.compatible_printers}})()})]}),t.inherits&&t.inherits!==t.name&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.inheritsFrom")}),a.jsx("span",{className:"text-white truncate ml-2",children:t.inherits})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-bambu-gray",children:i("profiles.localProfiles.source")}),a.jsx("span",{className:"text-white capitalize",children:t.source})]})]})]})})}function mXe(){const{t}=Yt(),{hasPermission:e}=Rr(),n=nn(),{showToast:r}=kn(),[i,s]=_.useState(""),[o,l]=_.useState(null),[c,u]=_.useState(!1),[d,h]=_.useState(null),{data:p,isLoading:m}=nt({queryKey:["localPresets"],queryFn:()=>ae.getLocalPresets()}),b=dt({mutationFn:async k=>{const R=[];for(const C of Array.from(k)){const P=new FormData;P.append("file",C),R.push(await ae.importLocalPresets(P))}return R},onSuccess:k=>{n.invalidateQueries({queryKey:["localPresets"]});let R=0,C=0,P=0;for(const U of k)R+=U.imported,C+=U.skipped,P+=U.errors.length;R>0&&r(t("profiles.localProfiles.toast.importSuccess",{count:R})),C>0&&r(t("profiles.localProfiles.toast.importSkipped",{count:C}),"warning"),P>0&&r(t("profiles.localProfiles.toast.importError",{count:P}),"error")},onError:k=>{r(k.message,"error")}}),y=dt({mutationFn:k=>ae.deleteLocalPreset(k),onSuccess:()=>{n.invalidateQueries({queryKey:["localPresets"]}),h(null),r(t("profiles.localProfiles.toast.deleted"))}}),x=_.useCallback(k=>{!k||k.length===0||b.mutate(k)},[b]),v=_.useCallback(k=>{k.preventDefault(),u(!1),x(k.dataTransfer.files)},[x]),S=_.useCallback(k=>{if(!i)return k;const R=i.toLowerCase();return k.filter(C=>C.name.toLowerCase().includes(R)||C.filament_type?.toLowerCase().includes(R)||C.filament_vendor?.toLowerCase().includes(R))},[i]),N=_.useMemo(()=>S(p?.filament||[]),[p?.filament,S]),T=_.useMemo(()=>S(p?.printer||[]),[p?.printer,S]),M=_.useMemo(()=>S(p?.process||[]),[p?.process,S]),A=N.length+T.length+M.length;return m?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"space-y-6",children:[e("settings:update")&&a.jsxs("div",{onDragOver:k=>{k.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:v,className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors ${c?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("input",{type:"file",accept:".json,.zip,.orca_filament,.bbscfg,.bbsflmt",multiple:!0,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",onChange:k=>x(k.target.files)}),b.isPending?a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(lt,{className:"w-5 h-5 text-bambu-green animate-spin"}),a.jsx("span",{className:"text-bambu-gray",children:t("profiles.localProfiles.importing")})]}):a.jsxs(a.Fragment,{children:[a.jsx(Na,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-white font-medium",children:t("profiles.localProfiles.import")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("profiles.localProfiles.importDesc")})]})]}),A>0&&a.jsxs("div",{className:"relative",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:i,onChange:k=>s(k.target.value),placeholder:t("profiles.localProfiles.search"),className:"w-full pl-9 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),A===0&&!m&&a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Eb,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50"}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.localProfiles.noPresets")}),a.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:t("profiles.localProfiles.importDesc")})]}),A>0&&a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[N.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(_k,{className:"w-4 h-4 text-bambu-green"}),a.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",N.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:N.map(k=>a.jsx(oj,{preset:k,onDelete:R=>h(R),onExpand:l,isExpanded:o===k.id},k.id))})]}),M.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(is,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",M.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:M.map(k=>a.jsx(oj,{preset:k,onDelete:R=>h(R),onExpand:l,isExpanded:o===k.id},k.id))})]}),T.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Gu,{className:"w-4 h-4 text-orange-400"}),a.jsx("h3",{className:"text-sm font-medium text-white",children:t("profiles.localProfiles.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",T.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:T.map(k=>a.jsx(oj,{preset:k,onDelete:R=>h(R),onExpand:l,isExpanded:o===k.id},k.id))})]})]}),d!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-6 max-w-sm mx-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Ti,{className:"w-5 h-5 text-red-400"}),a.jsx("h3",{className:"text-white font-medium",children:t("profiles.localProfiles.deleteConfirmTitle")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:t("profiles.localProfiles.deleteConfirm")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>h(null),children:t("profiles.localProfiles.cancel")}),a.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>y.mutate(d),disabled:y.isPending,children:[y.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(hn,{className:"w-4 h-4"}),t("profiles.localProfiles.delete")]})]})]})})]})}function PF(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=s?(s[1]||s[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:o,layerHeight:c,filamentType:d}}function Uy(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function pXe(t,e){const n=Ui(t);if(!n)return"";const i=new Date().getTime()-n.getTime(),s=Math.floor(i/6e4),o=Math.floor(i/36e5),l=Math.floor(i/864e5);return s<1?e("profiles.time.justNow"):s<60?e("profiles.time.minsAgo",{count:s}):o<24?e("profiles.time.hoursAgo",{count:o}):l<7?e("profiles.time.daysAgo",{count:l}):n.toLocaleDateString()}function gXe({onSuccess:t,t:e}){const{showToast:n}=kn(),[r,i]=_.useState("email"),[s,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(""),[h,p]=_.useState(""),[m,b]=_.useState("global"),[y,x]=_.useState(null),[v,S]=_.useState(null),N=dt({mutationFn:()=>ae.cloudLogin(s,l,m),onSuccess:R=>{R.success?(n(e("profiles.login.toast.loggedIn")),t()):R.needs_verification?(x(R.verification_type||"email"),S(R.tfa_key||null),R.verification_type==="totp"?n(e("profiles.login.toast.enterTotp")):n(e("profiles.login.toast.codeSent")),i("code")):n(R.message,"error")},onError:R=>n(R.message,"error")}),T=dt({mutationFn:()=>ae.cloudVerify(s,u,v||void 0),onSuccess:R=>{R.success?(n(e("profiles.login.toast.loggedIn")),t()):n(R.message,"error")},onError:R=>n(R.message,"error")}),M=dt({mutationFn:()=>ae.cloudSetToken(h),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:R=>n(R.message,"error")}),A=R=>{R.preventDefault(),r==="email"?N.mutate():r==="code"?T.mutate():r==="token"&&M.mutate()},k=N.isPending||T.isPending||M.isPending;return a.jsx(_t,{className:"max-w-md mx-auto",children:a.jsxs(Mt,{children:[a.jsxs("div",{className:"text-center mb-6",children:[a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:a.jsx(wk,{className:"w-6 h-6 text-bambu-green"})}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:e("profiles.login.title")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:e("profiles.login.subtitle")})]}),a.jsxs("form",{onSubmit:A,className:"space-y-4",children:[r==="email"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.email")}),a.jsx("input",{type:"email",value:s,onChange:R=>o(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.password")}),a.jsx("input",{type:"password",value:l,onChange:R=>c(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.region")}),a.jsxs("select",{value:m,onChange:R=>b(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"global",children:e("profiles.login.regionGlobal")}),a.jsx("option",{value:"china",children:e("profiles.login.regionChina")})]})]})]}),r==="code"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e(y==="totp"?"profiles.login.totpCode":"profiles.login.verificationCode")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:y==="totp"?e("profiles.login.enterTotpHint"):e("profiles.login.checkEmail",{email:s})}),a.jsx("input",{type:"text",value:u,onChange:R=>d(R.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"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.accessToken")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:e("profiles.login.accessTokenHint")}),a.jsx("textarea",{value:h,onChange:R=>p(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),a.jsxs("div",{className:"flex gap-2",children:[r==="code"&&a.jsx(Me,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:e("profiles.login.back")}),a.jsxs(Me,{type:"submit",disabled:k,className:"flex-1",children:[k?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(tB,{className:"w-4 h-4"}),e(r==="email"?"profiles.login.loginButton":r==="code"?"profiles.login.verifyButton":"profiles.login.setTokenButton")]})]}),r==="email"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(Yo,{className:"w-4 h-4"}),e("profiles.login.useToken")]})}),r==="token"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(tB,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function dg({label:t,value:e,options:n,onChange:r}){const[i,s]=_.useState(!1),o=n.find(l=>l.value===e);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),a.jsx("span",{children:o?.label||"All"}),a.jsx(hr,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),a.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(l=>a.jsxs("button",{onClick:()=>{r(l.value),s(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[a.jsx("span",{children:l.label}),l.count!==void 0&&a.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function bXe(){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?a.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:a.jsx(qg,{className:"w-5 h-5"})}):null}function lj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:o,t:l}){const c=PF(t.name),u=Uy(t.setting_id);return a.jsxs("div",{className:"flex items-center gap-2 group",children:[a.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&a.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&u&&a.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:l("profiles.presets.myPreset")}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),c.filamentType&&t.type==="filament"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.filamentType}),c.layerHeight&&t.type==="process"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.layerHeight}),c.printer&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.printer})]})}),a.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:a.jsx(Bl,{className:"w-4 h-4"})})]})}function AR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(s=>n+" "+s).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+AR(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+AR(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function xXe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s,t:o}){const{showToast:l}=kn(),c=nn(),[u,d]=_.useState(!1),{data:h,isLoading:p}=nt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ae.getCloudSettingDetail(t.setting_id)}),m=dt({mutationFn:()=>ae.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>l(x.message,"error")}),b=Uy(t.setting_id),y=PF(t.name,h?.setting?.inherits);return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(Mt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),b&&a.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")})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[a.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),y.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:y.printer})]})]})]}),a.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:p?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:AR(h)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?a.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[a.jsx(En,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>d(!1),disabled:m.isPending,className:"flex-1",children:o("common.cancel")}),a.jsxs(Me,{variant:"danger",onClick:()=>m.mutate(),disabled:m.isPending,className:"flex-1",children:[m.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(hn,{className:"w-4 h-4"}),o("common.delete")]})]})]}):a.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),a.jsxs(Me,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[a.jsx(Bl,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),b&&a.jsxs(a.Fragment,{children:[a.jsxs(Me,{variant:"secondary",onClick:i,disabled:p||!h||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[a.jsx(ea,{className:"w-4 h-4"}),o("common.edit")]}),a.jsx(Me,{variant:"danger",onClick:()=>d(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:a.jsx(hn,{className:"w-4 h-4"})})]})]})})]})})})}function uie(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function die(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function yXe({onClose:t,onApply:e,t:n}){const{showToast:r}=kn(),[i,s]=_.useState(uie),[o,l]=_.useState("all"),[c,u]=_.useState(null),[d,h]=_.useState(""),[p,m]=_.useState(""),[b,y]=_.useState("{}"),[x,v]=_.useState(null),[S,N]=_.useState(null),T=o==="all"?i:i.filter(B=>B.type===o),M=B=>{s(B),die(B)},A=B=>{const D=i.filter($=>$.id!==B);M(D),N(null),r(n("profiles.templates.toast.deleted"))},k=B=>{u(B.id),h(B.name),m(B.description),y(JSON.stringify(B.settings,null,2)),v(null)},R=()=>{if(!(!c||!d.trim()))try{const B=JSON.parse(b),D=i.map($=>$.id===c?{...$,name:d.trim(),description:p.trim(),settings:B}:$);M(D),u(null),r(n("profiles.templates.toast.updated"))}catch(B){v(B.message)}},C=()=>{u(null),h(""),m(""),y("{}"),v(null)},P=B=>{const D=i.map($=>$.id===B?{...$,showInModal:!$.showInModal}:$);M(D)},U={filament:{label:n("profiles.presets.types.filament"),icon:_k,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:Gu,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Dr,color:"text-purple-400"}},F=S?i.find(B=>B.id===S):null;return _.useEffect(()=>{const B=D=>{D.key==="Escape"&&(S?N(null):c?C():t())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[S,c,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(_t,{className:"w-full max-w-md",children:a.jsxs(Mt,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:a.jsx(En,{className:"w-6 h-6 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),a.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:F.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),a.jsxs(Me,{onClick:()=>A(S),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(hn,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),a.jsx(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(J0,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(B=>a.jsx("button",{onClick:()=>l(B),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:B==="all"?n("common.all"):U[B].label},B))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(J0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:n("profiles.templates.noTemplates")}),a.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):a.jsx("div",{className:"space-y-2",children:T.map(B=>{const D=U[B.type],$=D.icon;return c===B.id?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[a.jsx("input",{type:"text",value:d,onChange:G=>h(G.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}),a.jsx("input",{type:"text",value:p,onChange:G=>m(G.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"})]}),a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),a.jsx("textarea",{value:b,onChange:G=>{y(G.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 ${x?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),x&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:x})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{size:"sm",onClick:R,disabled:!d.trim(),children:[a.jsx(ys,{className:"w-4 h-4"}),"Save"]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:C,children:"Cancel"})]})]},B.id):a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[a.jsx($,{className:`w-5 h-5 ${D.color} flex-shrink-0`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:B.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:B.description})]}),a.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(B.settings).length})}),a.jsx("button",{onClick:()=>P(B.id),className:`p-1 transition-colors ${B.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:B.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:B.showInModal?a.jsx(vc,{className:"w-4 h-4"}):a.jsx(Sk,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(B),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")}),a.jsx("button",{onClick:()=>k(B),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(B.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:a.jsx(hn,{className:"w-4 h-4"})})]},B.id)})})})]})})]})}function hie({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:s}){const[o,l]=_.useState("changes"),[c,u]=_.useState(""),d=_.useMemo(()=>{const b=new Set([...Object.keys(e),...Object.keys(n)]),y=[];for(const x of b){if(x==="inherits"||x==="version")continue;const v=e[x],S=n[x],N=x in e,T=x in n;let M;!N&&T?M="added":N&&!T?M="removed":JSON.stringify(v)!==JSON.stringify(S)?M="changed":M="same",y.push({key:x,left:v,right:S,status:M})}return y.sort((x,v)=>{const S={changed:0,added:1,removed:2,same:3};return S[x.status]!==S[v.status]?S[x.status]-S[v.status]:x.key.localeCompare(v.key)})},[e,n]),h=_.useMemo(()=>{let b=[...d];if(o==="changes"&&(b=b.filter(y=>y.status!=="same")),c){const y=c.toLowerCase();b=b.filter(x=>x.key.toLowerCase().includes(y)||String(x.left).toLowerCase().includes(y)||String(x.right).toLowerCase().includes(y))}return b},[d,o,c]),p=_.useMemo(()=>({added:d.filter(b=>b.status==="added").length,removed:d.filter(b=>b.status==="removed").length,changed:d.filter(b=>b.status==="changed").length,same:d.filter(b=>b.status==="same").length}),[d]),m=b=>{if(b===void 0)return"—";if(b===null)return"null";if(Array.isArray(b))return b.length===0?"[]":b.length===1?String(b[0]):b.join(", ");if(typeof b=="object")return JSON.stringify(b);const y=String(b);if(y.includes("\\n")||y.length>100){const x=y.split("\\n").length;if(x>1)return`[${x} lines of G-code/script]`;if(y.length>100)return y.substring(0,100)+"…"}return y};return _.useEffect(()=>{const b=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(Mt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Cg,{className:"w-5 h-5 text-blue-400"}),s("profiles.diff.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.left")}),a.jsx("p",{className:"text-white font-medium truncate",children:r})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:s("profiles.diff.right")}),a.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(lr,{className:"w-3.5 h-3.5"}),p.added," ",s("profiles.diff.added")]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(Rj,{className:"w-3.5 h-3.5"}),p.removed," ",s("profiles.diff.removed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(Ej,{className:"w-3.5 h-3.5"}),p.changed," ",s("profiles.diff.changed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(bT,{className:"w-3.5 h-3.5"}),p.same," ",s("profiles.diff.same")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(Zi,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c,onChange:b=>u(b.target.value),placeholder:s("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&&a.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[a.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:s("profiles.diff.changes")}),a.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:s("common.all")})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(bT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:s(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:a.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left p-3 w-1/3",children:s("profiles.diff.field")}),a.jsx("th",{className:"text-left p-3 w-1/3",children:r}),a.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),a.jsx("tbody",{children:h.map(b=>{const y={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[b.status],x={added:a.jsx(lr,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(Rj,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(Ej,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(bT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[b.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${y}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[x,a.jsx("span",{className:"text-sm text-white font-mono",children:b.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${b.status==="removed"?"text-red-300":b.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(b.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${b.status==="added"?"text-green-300":b.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(b.right)})})]},b.key)})})]})})]})})})}function vXe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=kn(),s=nn(),o=!!e?.setting_id,[l,c]=_.useState("common"),[u,d]=_.useState(e?.type||"filament"),[h,p]=_.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[m,b]=_.useState(e?.base_id||""),[y,x]=_.useState(""),[v,S]=_.useState(e?.setting||{inherits:""}),[N,T]=_.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[M,A]=_.useState(null),[k,R]=_.useState(""),[C,P]=_.useState(!1),[U,F]=_.useState(""),[B,D]=_.useState(!1),[$,G]=_.useState(uie),[I,K]=_.useState(!1),[Q,se]=_.useState(""),[H,W]=_.useState(""),[J,ne]=_.useState(!0),[xe,ue]=_.useState(null),[fe,De]=_.useState(!1),oe=_.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),Ne=_.useMemo(()=>oe.filter(ve=>Uy(ve.setting_id)),[oe]),{data:Fe}=nt({queryKey:["cloudFields",u],queryFn:()=>ae.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:ce}=nt({queryKey:["allPresetDetails",u,Ne.map(ve=>ve.setting_id).join(",")],queryFn:async()=>{const ve={};for(let Ce=0;Ce<Ne.length;Ce+=5){const Ge=Ne.slice(Ce,Ce+5);(await Promise.all(Ge.map(async Je=>{try{const Ae=await ae.getCloudSettingDetail(Je.setting_id);return{id:Je.setting_id,detail:Ae}}catch{return null}}))).forEach(Je=>{Je&&(ve[Je.id]=Je.detail)})}return ve},enabled:Ne.length>0,staleTime:1e3*60*10}),{data:Ve,isLoading:V}=nt({queryKey:["cloudSettingDetail",m],queryFn:()=>ae.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(ze=>!Uy(ze.setting_id)).sort((ze,Ce)=>ze.name.localeCompare(Ce.name)),[n,u]);_.useEffect(()=>{if(!m)return;const ve=Y.find(ze=>ze.setting_id===m);ve&&(x(ve.name),o||(S({inherits:ve.name}),T(JSON.stringify({inherits:ve.name},null,2))))},[m,Y,o]);const de=_.useMemo(()=>{const ve=Fe?.fields||[],ze=new Set(ve.map(Je=>Je.key)),Ce=new Set,Ge=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);ce&&Object.values(ce).forEach(Je=>{Je?.setting&&Object.keys(Je.setting).forEach(Ae=>{!ze.has(Ae)&&!Ge.has(Ae)&&Ce.add(Ae)})}),Object.keys(v).forEach(Je=>{!ze.has(Je)&&!Ge.has(Je)&&Ce.add(Je)});const _e=Array.from(Ce).sort().map(Je=>({key:Je,label:Je.replace(/_/g," ").replace(/\b\w/g,Ae=>Ae.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...ve,..._e]},[Fe,ce,v,r]),q=de.filter(ve=>ve.label.toLowerCase().includes(k.toLowerCase())||ve.key.toLowerCase().includes(k.toLowerCase())),re=()=>{if(U.trim()){const ve=U.trim().toLowerCase().replace(/\s+/g,"_");X(ve,""),F(""),D(!1),i(r("profiles.presets.toast.fieldAdded",{key:ve}))}},X=(ve,ze)=>{S(Ce=>{const Ge={...Ce};return ze===""||ze===void 0?delete Ge[ve]:Ge[ve]=ze,Ge})},le=ve=>{S(ze=>({...ze,...ve.settings})),ue(ve.name),i(r("profiles.templates.toast.applied"))},pe=()=>{if(!Q.trim())return;const ve={...v};if(delete ve.inherits,Object.keys(ve).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const ze={id:Date.now().toString(),name:Q.trim(),description:H.trim()||r("profiles.presets.customTemplate"),type:u,settings:ve,showInModal:J},Ce=[...$,ze];G(Ce),die(Ce),K(!1),se(""),W(""),ne(!0),i(r("profiles.templates.toast.created"))},ee=_.useMemo(()=>$.filter(ve=>ve.type===u&&ve.showInModal),[u,$]),z=ve=>{T(ve);try{const ze=JSON.parse(ve);S(ze),A(null)}catch(ze){A(ze.message)}},O=ve=>{ve.preventDefault(),P(!1);const ze=ve.dataTransfer.files[0];if(ze&&ze.name.endsWith(".json")){const Ce=new FileReader;Ce.onload=Ge=>{try{const _e=Ge.target?.result,Je=JSON.parse(_e),Ae=Je.setting||Je;S(Ke=>({...Ke,...Ae})),T(JSON.stringify({...v,...Ae},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},Ce.readAsText(ze)}},Z=dt({mutationFn:()=>{const ve={...v},ze=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";ve[ze]=`"${h}"`;const Ce={type:u,name:h,base_id:m,setting:ve};return ae.createCloudSetting(Ce)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ve=>i(ve.message,"error")}),me=dt({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return ae.updateCloudSetting(e.setting_id,{name:h,setting:v})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ve=>i(ve.message,"error")}),Te=o?me:Z,ke=Ve?.setting?.inherits,Ee=ke?Y.find(ve=>ve.name===ke):void 0,{data:Se}=nt({queryKey:["cloudSettingDetail",Ee?.setting_id],queryFn:()=>ae.getCloudSettingDetail(Ee.setting_id),enabled:!!Ee?.setting_id}),$e=_.useMemo(()=>{const ve=Se?.setting||{},ze=Ve?.setting||{},Ce=m&&ce?.[m]?.setting?ce[m].setting:{};return{...ve,...ze,...Ce}},[m,Ve,Se,ce]),Qe=ve=>{if(ve==null)return"";if(Array.isArray(ve)){const ze=[...new Set(ve.map(Ce=>String(Ce)))];return ze.length===1?ze[0]:ve.join(", ")}return String(ve)},Ue=ve=>{const ze=v[ve.key],Ce=$e[ve.key],Ge=Qe(Ce),_e=V?r("common.loading"):Ge||"",Je="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(ve.type==="boolean"){const Ae=ze==="1"||ze===void 0&&Ce==="1";return a.jsx("button",{type:"button",onClick:()=>X(ve.key,ze==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ae?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Ae?"translate-x-3.5":"translate-x-0.5"}`})})}return ve.type==="select"?a.jsxs("select",{value:ze||"",onChange:Ae=>X(ve.key,Ae.target.value),className:Je,children:[a.jsx("option",{value:"",children:_e}),ve.options?.map(Ae=>a.jsx("option",{value:Ae.value,children:Ae.label},Ae.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:ve.type==="number"?"number":"text",value:ze!==void 0?String(ze):"",onChange:Ae=>X(ve.key,Ae.target.value),step:ve.step,min:ve.min,max:ve.max,placeholder:_e,className:Je}),ve.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ve.unit})]})},be=_.useMemo(()=>Ve?.setting?Ve.setting:{},[Ve]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ve=>{ve.preventDefault(),P(!0)},onDragLeave:()=>P(!1),onDrop:O,children:[fe&&m&&a.jsx(hie,{onClose:()=>De(!1),leftPreset:be,rightPreset:v,leftLabel:r("profiles.presets.baseLabel",{name:y||m}),rightLabel:r("profiles.presets.currentLabel",{name:h||r("profiles.presets.newPreset")}),t:r}),a.jsx(_t,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:a.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[m&&a.jsxs("button",{onClick:()=>De(!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:[a.jsx(Cg,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),a.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]})]}),C&&a.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(Na,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),a.jsxs("select",{value:u,onChange:ve=>{d(ve.target.value),b("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),a.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),a.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),a.jsxs("select",{value:m,onChange:ve=>b(ve.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),Y.map(ve=>a.jsx("option",{value:ve.setting_id,children:ve.name},ve.setting_id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),a.jsx("input",{type:"text",value:h,onChange:ve=>p(ve.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")})]})]}),y&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Vi,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",a.jsx("span",{className:"text-white",children:y}),V&&a.jsx(lt,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>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:[a.jsx(nB,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),a.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:[a.jsx(Tk,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),a.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:[a.jsx(FW,{className:"w-4 h-4"}),"JSON",M&&a.jsx(Ti,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("button",{onClick:()=>{const ve={name:h,type:u,base_id:m,setting:v},ze=new Blob([JSON.stringify(ve,null,2)],{type:"application/json"}),Ce=URL.createObjectURL(ze),Ge=document.createElement("a");Ge.href=Ce,Ge.download=`${h||"preset"}.json`,document.body.appendChild(Ge),Ge.click(),document.body.removeChild(Ge),URL.revokeObjectURL(Ce),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:[a.jsx(_i,{className:"w-4 h-4"}),r("common.download")]}),a.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.importFromJson"),children:[a.jsx(Na,{className:"w-4 h-4"}),r("common.upload")]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ve=>{const ze=ve.target.files?.[0];if(ze){const Ce=new FileReader;Ce.onload=Ge=>{try{const _e=JSON.parse(Ge.target?.result),Je=_e.setting||_e;S(Ae=>({...Ae,...Je})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},Ce.readAsText(ze)}}})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[l==="common"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(J0,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(v).filter(ve=>ve!=="inherits").length>0&&a.jsxs("button",{onClick:()=>K(!I),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(ys,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),I&&a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("input",{type:"text",value:Q,onChange:ve=>se(ve.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}),a.jsx("input",{type:"text",value:H,onChange:ve=>W(ve.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"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{size:"sm",onClick:pe,disabled:!Q.trim(),children:[a.jsx(ys,{className:"w-3 h-3"}),r("common.save")]}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>K(!1),children:r("common.cancel")})]}),a.jsxs("button",{onClick:()=>ne(!J),className:`flex items-center gap-1.5 text-xs transition-colors ${J?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[J?a.jsx(vc,{className:"w-3.5 h-3.5"}):a.jsx(Sk,{className:"w-3.5 h-3.5"}),r(J?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),xe&&a.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[a.jsx(Vi,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",a.jsx("span",{className:"font-medium",children:xe})]}),a.jsx("button",{onClick:()=>ue(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Lt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[ee.map(ve=>a.jsxs("button",{onClick:()=>le(ve),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:ve.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ve.description})]},ve.id)),ee.length===0&&a.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),a.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:de.slice(0,10).map(ve=>a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:ve.label}),a.jsx("div",{className:"w-48",children:Ue(ve)})]},ve.key))})]}),Object.keys(v).length>1&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([ve])=>ve!=="inherits").map(([ve,ze])=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[ve,": ",String(ze).slice(0,20),a.jsx("button",{onClick:()=>X(ve,void 0),className:"hover:text-white",children:a.jsx(Lt,{className:"w-3 h-3"})})]},ve))})]})]}),l==="fields"&&a.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:ce?r("profiles.templates.fieldsCount",{count:de.length}):r("common.loading")})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:k,onChange:ve=>R(ve.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"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[q.filter(ve=>!(ve.key in v)).map(ve=>{const ze=$e[ve.key],Ce=Qe(ze);return a.jsxs("div",{onClick:()=>{S(Ge=>({...Ge,[ve.key]:Ce||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white truncate",children:ve.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ve.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Ce&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Ce,children:[Ce.slice(0,20),Ce.length>20?"...":""]}),a.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:a.jsx(lr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ve.key)}),q.filter(ve=>!(ve.key in v)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(k?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:B?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:U,onChange:ve=>F(ve.target.value),onKeyDown:ve=>ve.key==="Enter"&&re(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx(Me,{size:"sm",onClick:re,disabled:!U.trim(),children:a.jsx(lr,{className:"w-4 h-4"})}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{D(!1),F("")},children:a.jsx(Lt,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>D(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(lr,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(v).filter(ve=>ve!=="inherits").length})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([ve])=>ve!=="inherits").map(([ve,ze])=>{const Ce=de.find(Ge=>Ge.key===ve);return a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-white",children:Ce?.label||ve}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ve})]}),a.jsx("button",{onClick:()=>X(ve,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Lt,{className:"w-4 h-4"})})]}),Ce?Ue(Ce):a.jsx("input",{type:"text",value:String(ze),onChange:Ge=>X(ve,Ge.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"})]},ve)}),Object.keys(v).filter(ve=>ve!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(nB,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),a.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(v).filter(ve=>ve!=="inherits").length>0&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsxs("button",{onClick:()=>{K(!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:[a.jsx(ys,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&a.jsxs("div",{className:"space-y-2",children:[M&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Ti,{className:"w-4 h-4"}),M]}),a.jsx("textarea",{value:N,onChange:ve=>z(ve.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 ${M?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsxs(Me,{onClick:()=>Te.mutate(),disabled:Te.isPending||!h.trim()||!o&&!m||!!M,className:"flex-1",children:[Te.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):o?a.jsx(ys,{className:"w-4 h-4"}):a.jsx(lr,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function wXe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s,t:o}){const[l,c]=_.useState(""),[u,d]=_.useState("all"),[h,p]=_.useState("all"),[m,b]=_.useState("all"),[y,x]=_.useState("all"),[v,S]=_.useState("all"),[N,T]=_.useState("all"),[M,A]=_.useState(null),[k,R]=_.useState(!1),[C,P]=_.useState(!1),[U,F]=_.useState(null),[B,D]=_.useState(null),[$,G]=_.useState(null),[I,K]=_.useState(!1),[Q,se]=_.useState([null,null]),[H,W]=_.useState(!1),[J,ne]=_.useState(null),xe=nn(),ue=_.useMemo(()=>[...t.filament.map(re=>({...re,type:"filament"})),...t.printer.map(re=>({...re,type:"printer"})),...t.process.map(re=>({...re,type:"process"}))].map(re=>({...re,meta:PF(re.name)})),[t]),fe=_.useMemo(()=>{const q=new Set,re=new Set,X=new Set;return ue.forEach(le=>{le.meta.nozzle&&q.add(le.meta.nozzle),le.meta.filamentType&&re.add(le.meta.filamentType),le.meta.layerHeight&&X.add(le.meta.layerHeight)}),{printers:i.map(le=>({id:le.id.toString(),name:le.name})),nozzles:Array.from(q).sort((le,pe)=>parseFloat(le)-parseFloat(pe)),filaments:Array.from(re).sort(),layerHeights:Array.from(X).sort((le,pe)=>parseFloat(le)-parseFloat(pe))}},[ue,i]),De=_.useMemo(()=>m==="all"?null:i.find(re=>re.id.toString()===m)?.model||null,[m,i]),oe=_.useMemo(()=>ue.filter(q=>u==="all"||q.type===u).filter(q=>{if(h==="all")return!0;const re=Uy(q.setting_id);return h==="custom"?re:!re}).filter(q=>{if(m==="all"||!De)return!0;const re=q.meta.printer?.toLowerCase()||"",X=De.toLowerCase();return re.includes(X)||X.includes(re)}).filter(q=>y==="all"||q.meta.nozzle===y).filter(q=>v==="all"||q.meta.filamentType===v).filter(q=>N==="all"||q.meta.layerHeight===N).filter(q=>l===""||q.name.toLowerCase().includes(l.toLowerCase())).sort((q,re)=>q.name.localeCompare(re.name)),[ue,u,h,m,De,y,v,N,l]),Ne=q=>{if(I){const re=Q[0]?.setting_id===q.setting_id,X=Q[1]?.setting_id===q.setting_id;if(re)se([Q[1],null]);else if(X)se([Q[0],null]);else if(!Q[0])se([q,null]);else if(Q[1]){if(Q[0].type!==q.type)return;se([Q[0],q])}else{if(Q[0].type!==q.type)return;se([Q[0],q])}}else A(q)},Fe=q=>{if(Q[0]?.setting_id===q.setting_id)return 0;if(Q[1]?.setting_id===q.setting_id)return 1},ce=async q=>{try{const re=await ae.getCloudSettingDetail(q.setting_id),X=q.type==="process"?"print":q.type;F({type:X,name:q.name,base_id:re.base_id||"GFSA00",setting:re.setting||{}}),A(null)}catch(re){console.error("Failed to fetch preset details for duplication:",re)}},Ve=async q=>{try{xe.removeQueries({queryKey:["cloudSettingDetail",q.setting_id]});const re=await ae.getCloudSettingDetail(q.setting_id),X=q.type==="process"?"print":q.type;D({type:X,name:q.name,base_id:re.base_id||"GFSA00",setting:re.setting||{},setting_id:q.setting_id}),A(null)}catch(re){console.error("Failed to fetch preset details for editing:",re)}},V=()=>{d("all"),p("all"),b("all"),x("all"),S("all"),T("all"),c("")},Y=u!=="all"||h!=="all"||m!=="all"||y!=="all"||v!=="all"||N!=="all"||l!=="",de=t.filament.length+t.printer.length+t.process.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.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"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:I?"primary":"secondary",onClick:()=>{I?(K(!1),se([null,null])):K(!0)},children:[a.jsx(Cg,{className:"w-4 h-4"}),o(I?"common.cancel":"profiles.presets.compare")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>P(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[a.jsx(J0,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),a.jsxs(Me,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[a.jsx(Ir,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),a.jsxs(Me,{onClick:()=>R(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[a.jsx(lr,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(kk,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(dg,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:de},{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)}),a.jsx(dg,{label:o("profiles.cloudView.filters.owner"),value:h,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)}),fe.printers.length>0&&a.jsx(dg,{label:o("profiles.cloudView.filters.printer"),value:m,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...fe.printers.map(q=>({value:q.id,label:q.name}))],onChange:b}),fe.nozzles.length>0&&a.jsx(dg,{label:o("profiles.cloudView.filters.nozzle"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...fe.nozzles.map(q=>({value:q,label:q}))],onChange:x}),fe.filaments.length>0&&(u==="all"||u==="filament")&&a.jsx(dg,{label:o("profiles.cloudView.filters.filament"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...fe.filaments.map(q=>({value:q,label:q}))],onChange:S}),fe.layerHeights.length>0&&(u==="all"||u==="process")&&a.jsx(dg,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...fe.layerHeights.map(q=>({value:q,label:q}))],onChange:T}),Y&&a.jsx("button",{onClick:V,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),I&&a.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Cg,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),a.jsx("span",{className:"text-bambu-gray",children:Q[0]?o("profiles.cloudView.selectAnotherPreset",{type:Q[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Q[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Q[0]?Q[0].name:o("profiles.cloudView.selectFirst")}),a.jsx(Ej,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Q[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Q[1]?Q[1].name:o("profiles.cloudView.selectSecond")})]}),Q[0]&&Q[1]&&a.jsxs(Me,{size:"sm",onClick:async()=>{try{const[q,re]=await Promise.all([ae.getCloudSettingDetail(Q[0].setting_id),ae.getCloudSettingDetail(Q[1].setting_id)]);ne([q.setting||{},re.setting||{}]),W(!0)}catch{}},children:[a.jsx(Cg,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(er,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",pXe(e.toISOString(),o)]}),a.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:oe.length,total:de})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),a.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),oe.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(is,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),a.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),Y&&a.jsx("button",{onClick:V,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(_k,{className:"w-4 h-4 text-amber-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",oe.filter(q=>q.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[oe.filter(q=>q.type==="filament").map(q=>a.jsx(lj,{setting:q,onClick:()=>Ne(q),onDuplicate:()=>ce(q),compareMode:I,isCompareSelected:Fe(q)!==void 0,compareIndex:Fe(q),compareDisabled:I&&!!Q[0]&&Q[0].type!==q.type,t:o},q.setting_id)),oe.filter(q=>q.type==="filament").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Gu,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",oe.filter(q=>q.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[oe.filter(q=>q.type==="process").map(q=>a.jsx(lj,{setting:q,onClick:()=>Ne(q),onDuplicate:()=>ce(q),compareMode:I,isCompareSelected:Fe(q)!==void 0,compareIndex:Fe(q),compareDisabled:I&&!!Q[0]&&Q[0].type!==q.type,t:o},q.setting_id)),oe.filter(q=>q.type==="process").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Dr,{className:"w-4 h-4 text-purple-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",oe.filter(q=>q.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[oe.filter(q=>q.type==="printer").map(q=>a.jsx(lj,{setting:q,onClick:()=>Ne(q),onDuplicate:()=>ce(q),compareMode:I,isCompareSelected:Fe(q)!==void 0,compareIndex:Fe(q),compareDisabled:I&&!!Q[0]&&Q[0].type!==q.type,t:o},q.setting_id)),oe.filter(q=>q.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),M&&a.jsx(xXe,{setting:M,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>ce(M),onEdit:()=>Ve(M),hasPermission:s,t:o}),(k||U||B||$)&&a.jsx(vXe,{onClose:()=>{R(!1),F(null),D(null),G(null)},initialData:B||U||($?{type:$.type,name:"",base_id:"",setting:$.setting}:void 0),allPresets:t,t:o}),C&&a.jsx(yXe,{onClose:()=>P(!1),onApply:q=>{G({type:q.type,setting:q.settings}),P(!1)},t:o}),H&&J&&Q[0]&&Q[1]&&a.jsx(hie,{onClose:()=>{W(!1),ne(null)},leftPreset:J[0],rightPreset:J[1],leftLabel:Q[0].name,rightLabel:Q[1].name,t:o})]})}function _Xe(){const{t}=Yt(),e=nn(),{showToast:n}=kn(),{hasPermission:r}=Rr(),[i,s]=_.useState("cloud"),[o,l]=_.useState(),{data:c,isLoading:u}=nt({queryKey:["cloudStatus"],queryFn:ae.getCloudStatus}),{data:d=[]}=nt({queryKey:["printers"],queryFn:ae.getPrinters}),{data:h,isLoading:p,refetch:m,dataUpdatedAt:b}=nt({queryKey:["cloudSettings"],queryFn:()=>ae.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});_.useEffect(()=>{b&&l(new Date(b))},[b]);const y=dt({mutationFn:ae.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),x=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-6 lg:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[a.jsxs("button",{onClick:()=>s("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:[a.jsx(wk,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),a.jsxs("button",{onClick:()=>s("local"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="local"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(Eb,{className:"w-4 h-4"}),t("profiles.tabs.local")]}),a.jsxs("button",{onClick:()=>s("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:[a.jsx(Mk,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&a.jsxs(a.Fragment,{children:[c?.is_authenticated&&a.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",a.jsx("span",{className:"text-white",children:c.email})]})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>y.mutate(),disabled:y.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[a.jsx(Dj,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?p?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx(wXe,{settings:h,lastSyncTime:o,onRefresh:()=>m(),isRefreshing:p,printers:d,hasPermission:r,t}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),a.jsx(Me,{onClick:()=>m(),children:t("profiles.retry")})]}):a.jsx(gXe,{onSuccess:x,t})]}),i==="local"&&a.jsx(mXe,{}),i==="kprofiles"&&a.jsx(uXe,{}),a.jsx(bXe,{})]})}const w0={Droplet:_k,Flame:rde,Ruler:Ohe,Sparkles:J0,Square:ul,Cable:Zce,Wrench:xm,Calendar:Qr,Timer:Nu,Cog:Cue,Fan:IW,Zap:Ch,Wind:YW,Thermometer:Dk,Layers:is,Box:zi,Target:WW,RefreshCw:Ir,Settings:jk,Filter:kk,CircleDot:bue};function G0(t){return t&&w0[t]||xm}function hg(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 cj(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 SXe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,h=n.includes("P2S");switch(t){case"Lubricate Linear Rails":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":h?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/general/lead-screws-lubrication";case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":s||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":h?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":h?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":s||o||d||h?null:"https://wiki.bambulab.com/en/general/carbon-rods-clearance";case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":s||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function NXe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const s=G0(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",h=()=>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:hg(Math.abs(m),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:hg(m,"days",i)}):i("maintenance.timeLeft",{duration:hg(m,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:hg(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:hg(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:hg(t.hours_until_due,"hours",i)})};return a.jsx("div",{className:`rounded-xl border p-4 transition-all ${h()}`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[a.jsx(s,{className:`w-5 h-5 ${u()}`}),t.enabled&&(t.is_due||t.is_warning)&&a.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&a.jsx("span",{title:i("maintenance.timeBasedInterval"),children:a.jsx(Qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const m=t.maintenance_type_wiki_url||SXe(t.maintenance_type_name,t.printer_model);return m?a.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:b=>b.stopPropagation(),children:a.jsx(Zr,{className:"w-3.5 h-3.5"})}):null})()]}),a.jsx("div",{className:"mt-2 mb-1.5",children:a.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d()}`,style:{width:`${c}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&a.jsx(En,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(er,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Vi,{className:"w-3 h-3"}),p()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:a.jsx(zn,{checked:t.enabled,onChange:m=>n(t.id,m),disabled:!r("maintenance:update")})}),a.jsxs(Me,{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:[a.jsx(Vu,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function kXe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:s}){const[o,l]=_.useState(!0),[c,u]=_.useState(!1),[d,h]=_.useState(t.total_print_hours.toFixed(1)),p=[...t.maintenance_items].sort((y,x)=>y.is_due&&!x.is_due?-1:!y.is_due&&x.is_due?1:y.is_warning&&!x.is_warning?-1:!y.is_warning&&x.is_warning?1:y.maintenance_type_id-x.maintenance_type_id),m=p.find(y=>y.enabled&&(y.is_due||y.is_warning)),b=()=>{const y=parseFloat(d);!isNaN(y)&&y>=0&&(r(t.printer_id,y),u(!1))};return a.jsxs(_t,{className:"overflow-hidden",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(En,{className:"w-3 h-3"}),s("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(er,{className:"w-3 h-3"}),s("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&a.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Vi,{className:"w-3 h-3"}),s("maintenance.allGood")]})]})]}),a.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?a.jsx(Hu,{className:"w-4 h-4"}):a.jsx(hr,{className:"w-4 h-4"}),s(o?"common.collapse":"common.expand")]})]}),a.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:a.jsx(Nu,{className:"w-4 h-4 text-bambu-gray"})}),c?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",value:d,onChange:y=>h(y.target.value),onKeyDown:y=>{y.key==="Enter"&&b(),y.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}),a.jsx("span",{className:"text-xs text-bambu-gray",children:s("common.hours")}),a.jsx(Me,{size:"sm",onClick:b,children:s("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:s("common.cancel")})]}):a.jsxs("button",{onClick:()=>{i("maintenance:update")&&(h(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:s("maintenance.noPermissionEditHours"),children:[a.jsxs("div",{className:`text-sm font-medium text-white ${i("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",s("common.hours"),a.jsx(pm,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:s("maintenance.totalPrintTime")})]})]}),a.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),m&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${m.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const y=G0(m.maintenance_type_icon);return a.jsx(y,{className:`w-4 h-4 ${m.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${m.is_due?"text-red-400":"text-amber-400"}`,children:m.maintenance_type_name}),a.jsx("div",{className:`text-xs ${m.is_due?"text-red-400/70":"text-amber-400/70"}`,children:m.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&a.jsx(Mt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:a.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:p.map(y=>a.jsx(NXe,{item:y,onPerform:e,onToggle:n,hasPermission:i,t:s},y.id))})})]})}function MXe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onAssignType:o,onRemoveItem:l,hasPermission:c,t:u}){const[d,h]=_.useState(null),[p,m]=_.useState(""),[b,y]=_.useState("hours"),[x,v]=_.useState(!1),[S,N]=_.useState(""),[T,M]=_.useState("100"),[A,k]=_.useState("hours"),[R,C]=_.useState("Wrench"),[P,U]=_.useState(""),[F,B]=_.useState(new Set),[D,$]=_.useState(null),G=_.useMemo(()=>t?t.map(X=>({id:X.printer_id,name:X.printer_name})):[],[t]),I=X=>t?t.filter(le=>le.maintenance_items.some(pe=>pe.maintenance_type_id===X)).map(le=>({printerId:le.printer_id,printerName:le.printer_name,itemId:le.maintenance_items.find(pe=>pe.maintenance_type_id===X)?.id})):[],K=X=>{if(!t)return[];const le=new Set(I(X).map(pe=>pe.printerId));return G.filter(pe=>!le.has(pe.id))},[Q,se]=_.useState(null),[H,W]=_.useState(""),[J,ne]=_.useState(""),[xe,ue]=_.useState("hours"),[fe,De]=_.useState("Wrench"),[oe,Ne]=_.useState(""),Fe=X=>{se(X),W(X.name),ne(X.default_interval_hours.toString()),ue(X.interval_type||"hours"),De(X.icon||"Wrench"),Ne(X.wiki_url||"")},ce=()=>{Q&&H.trim()&&parseFloat(J)>0&&(i(Q.id,{name:H.trim(),default_interval_hours:parseFloat(J),interval_type:xe,icon:fe,wiki_url:oe.trim()||null}),se(null))},Ve=(X,le,pe)=>{const ee=parseFloat(p);if(!isNaN(ee)&&ee>0){const z=Math.abs(ee-le)<.01?null:ee;n(X,{custom_interval_hours:z,custom_interval_type:b!==pe?b:null})}h(null)},V=X=>{X.preventDefault(),S.trim()&&parseFloat(T)>0&&F.size>0&&(r({name:S.trim(),default_interval_hours:parseFloat(T),interval_type:A,icon:R,wiki_url:P.trim()||null},Array.from(F)),N(""),M("100"),k("hours"),U(""),B(new Set),v(!1))},Y=X=>{B(le=>{const pe=new Set(le);return pe.has(X)?pe.delete(X):pe.add(X),pe})},de=t?.map(X=>({printerId:X.printer_id,printerName:X.printer_name,items:X.maintenance_items.sort((le,pe)=>le.maintenance_type_id-pe.maintenance_type_id)})).sort((X,le)=>X.printerName.localeCompare(le.printerName))||[],q=e.filter(X=>X.is_system),re=e.filter(X=>!X.is_system);return a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.maintenanceTypes")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.maintenanceTypesDescription")})]}),a.jsxs(Me,{onClick:()=>v(!x),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionEditTypes"),children:[a.jsx(lr,{className:"w-4 h-4"}),u("maintenance.addCustomType")]})]}),x&&a.jsx(_t,{className:"mb-6",children:a.jsx(Mt,{className:"py-4",children:a.jsxs("form",{onSubmit:V,children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"lg:col-span-2",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("common.name")}),a.jsx("input",{type:"text",value:S,onChange:X=>N(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:u("maintenance.exampleName"),autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalType")}),a.jsxs("select",{value:A,onChange:X=>{k(X.target.value),X.target.value==="days"?M("30"):M("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:u("maintenance.printHours")}),a.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalValue",{type:A==="days"?u("maintenance.calendarDays").toLowerCase():u("common.hours")})}),a.jsx("input",{type:"number",value:T,onChange:X=>M(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),a.jsx("div",{className:"mt-4 flex items-end justify-between",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.icon")}),a.jsx("div",{className:"flex gap-1",children:Object.keys(w0).map(X=>{const le=w0[X];return a.jsx("button",{type:"button",onClick:()=>C(X),className:`p-2 rounded-lg transition-colors ${R===X?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(le,{className:"w-4 h-4"})},X)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.documentationLink")}),a.jsx("input",{type:"url",value:P,onChange:X=>U(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.assignToPrinters")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:G.map(X=>a.jsx("button",{type:"button",onClick:()=>Y(X.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${F.has(X.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:X.name},X.id))}),F.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:u("maintenance.selectAtLeastOnePrinter")})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:()=>{v(!1),B(new Set)},children:u("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!S.trim()||F.size===0,children:u("maintenance.addType")})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[q.map(X=>{const le=G0(X.icon),pe=X.interval_type||"hours";return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:a.jsx(le,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-white truncate",children:X.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[pe==="days"?a.jsx(Qr,{className:"w-3 h-3"}):a.jsx(Nu,{className:"w-3 h-3"}),cj(X.default_interval_hours,pe,u)]})]})]})},X.id)}),re.map(X=>{const le=G0(X.icon),pe=X.interval_type||"hours";if(Q?.id===X.id)return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("input",{type:"text",value:H,onChange:me=>W(me.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}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:xe,onChange:me=>ue(me.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:u("maintenance.printHours")}),a.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:J,onChange:me=>ne(me.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(w0).map(me=>{const Te=w0[me];return a.jsx("button",{type:"button",onClick:()=>De(me),className:`p-1.5 rounded transition-colors ${fe===me?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx(Te,{className:"w-3.5 h-3.5"})},me)})}),a.jsx("input",{type:"url",value:oe,onChange:me=>Ne(me.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")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{size:"sm",onClick:ce,disabled:!H.trim(),children:u("common.save")}),a.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>se(null),children:u("common.cancel")})]})]})},X.id);const z=I(X.id),O=K(X.id),Z=D===X.id;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:a.jsx(le,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-white truncate",children:X.name}),a.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")})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[pe==="days"?a.jsx(Qr,{className:"w-3 h-3"}):a.jsx(Nu,{className:"w-3 h-3"}),cj(X.default_interval_hours,pe,u)]})]}),a.jsxs("button",{onClick:()=>$(Z?null:X.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:[a.jsx(Dr,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:z.length}),a.jsx(hr,{className:`w-3 h-3 transition-transform ${Z?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>Fe(X),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:a.jsx(pm,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(u("maintenance.deleteTypeConfirm",{name:X.name}))&&s(X.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:a.jsx(hn,{className:"w-4 h-4"})})]}),Z&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:u("maintenance.assignedToPrinters")}),z.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:u("maintenance.noPrintersAssigned")}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:z.map(me=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[me.printerName,a.jsx("button",{onClick:()=>me.itemId&&l(me.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:"×"})]},me.printerId))}),O.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:u("maintenance.addPrinterShort")}),O.map(me=>a.jsxs("button",{onClick:()=>o(me.id,X.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:["+ ",me.name]},me.id))]})]})]},X.id)})]})]}),de.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.intervalOverrides")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.intervalOverridesDescription")})]}),a.jsx("div",{className:"space-y-4",children:de.map(X=>a.jsx(_t,{children:a.jsxs(Mt,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:X.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:X.items.map(le=>{const pe=G0(le.maintenance_type_icon),ee=e.find(Te=>Te.id===le.maintenance_type_id),z=ee?.default_interval_hours||le.interval_hours,O=ee?.interval_type||"hours",Z=le.interval_type||"hours",me=d===le.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(pe,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:le.maintenance_type_name}),me?a.jsxs("div",{className:"flex items-center gap-1",children:[b==="days"?a.jsx(Qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(Nu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:b,onChange:Te=>y(Te.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[a.jsx("option",{value:"hours",children:u("maintenance.printHours")}),a.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:p,onChange:Te=>m(Te.target.value),onKeyDown:Te=>{Te.key==="Enter"&&Ve(le.id,z,O),Te.key==="Escape"&&h(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),a.jsx(Me,{size:"sm",onClick:()=>Ve(le.id,z,O),children:"OK"})]}):a.jsxs("button",{onClick:()=>{c("maintenance:update")&&(h(le.id),m(le.interval_hours.toString()),y(Z))},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:[Z==="days"?a.jsx(Qr,{className:"w-3 h-3"}):a.jsx(Nu,{className:"w-3 h-3"}),cj(le.interval_hours,Z,u),a.jsx(pm,{className:"w-3 h-3 text-bambu-gray"})]})]},le.id)})})]})},X.printerId))})]}),de.length===0&&a.jsx(_t,{children:a.jsxs(Mt,{className:"text-center py-12",children:[a.jsx(er,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:u("common.noPrinters")}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:u("maintenance.intervalOverridesDescription")})]})})]})}function EXe(){const{t}=Yt(),e=nn(),{showToast:n}=kn(),{hasPermission:r}=Rr(),[i,s]=_.useState("status"),{data:o,isLoading:l}=nt({queryKey:["maintenanceOverview"],queryFn:ae.getMaintenanceOverview}),{data:c}=nt({queryKey:["maintenanceTypes"],queryFn:ae.getMaintenanceTypes}),u=dt({mutationFn:({id:M,notes:A})=>ae.performMaintenance(M,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:M=>{n(M.message,"error")}}),d=dt({mutationFn:({id:M,data:A})=>ae.updateMaintenanceItem(M,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{n(M.message,"error")}}),h=dt({mutationFn:({id:M,data:A})=>ae.updateMaintenanceType(M,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:M=>{n(M.message,"error")}}),p=dt({mutationFn:ae.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:M=>{n(M.message,"error")}}),m=dt({mutationFn:({printerId:M,hours:A})=>ae.setPrinterHours(M,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:M=>{n(M.message,"error")}}),b=dt({mutationFn:({printerId:M,typeId:A})=>ae.assignMaintenanceType(M,A),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:M=>{n(M.message,"error")}}),y=dt({mutationFn:ae.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:M=>{n(M.message,"error")}}),x=M=>{u.mutate({id:M})},v=(M,A)=>{d.mutate({id:M,data:{enabled:A}})},S=(M,A)=>{m.mutate({printerId:M,hours:A})};if(l)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const N=o?.reduce((M,A)=>M+A.due_count,0)||0,T=o?.reduce((M,A)=>M+A.warning_count,0)||0;return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?a.jsxs(a.Fragment,{children:[N>0&&a.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:N})}),N>0&&T>0&&" · ",T>0&&a.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:T})}),N===0&&T===0&&a.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>s("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")}),a.jsx("button",{onClick:()=>s("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"?a.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((M,A)=>{const k=M.due_count*10+M.warning_count,R=A.due_count*10+A.warning_count;return k!==R?R-k:M.printer_name.localeCompare(A.printer_name)}).map(M=>a.jsx(kXe,{overview:M,onPerform:x,onToggle:v,onSetHours:S,hasPermission:r,t},M.printer_id)):a.jsx(_t,{children:a.jsxs(Mt,{className:"text-center py-16",children:[a.jsx(xm,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):a.jsx(MXe,{overview:o,types:c||[],onUpdateInterval:(M,A)=>d.mutate({id:M,data:A}),onAddType:async(M,A)=>{const k=await ae.createMaintenanceType(M);for(const R of A)await ae.assignMaintenanceType(R,k.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(M,A)=>h.mutate({id:M,data:A}),onDeleteType:M=>p.mutate(M),onAssignType:(M,A)=>b.mutate({printerId:M,typeId:A}),onRemoveItem:M=>y.mutate(M),hasPermission:r,t})]})}const I9=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function fie({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=_.useState(t?.name||""),[l,c]=_.useState(t?.description||""),[u,d]=_.useState(t?.color||I9[0]),[h,p]=_.useState(t?.target_count?.toString()||""),[m,b]=_.useState(t?.target_parts_count?.toString()||""),[y,x]=_.useState(t?.status||"active"),[v,S]=_.useState(t?.tags||""),[N,T]=_.useState(t?.due_date?.split("T")[0]||""),[M,A]=_.useState(t?.priority||"normal"),k=R=>{R.preventDefault(),n({name:s.trim(),description:l.trim()||void 0,color:u,target_count:h?parseInt(h,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:v.trim()||void 0,due_date:N||void 0,priority:M,...t&&{status:y}})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i(t?"projects.editProject":"projects.newProject")})}),a.jsxs("form",{onSubmit:k,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.name")}),a.jsx("input",{type:"text",value:s,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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),a.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:I9.map(R=>a.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))})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetPlates")}),a.jsx("input",{type:"number",value:h,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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),a.jsx("input",{type:"number",value:m,onChange:R=>b(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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),a.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")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.dueDate")}),a.jsx("input",{type:"date",value:N,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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.priority")}),a.jsxs("select",{value:M,onChange:R=>A(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:[a.jsx("option",{value:"low",children:i("projects.priorityLow")}),a.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),a.jsx("option",{value:"high",children:i("projects.priorityHigh")}),a.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),a.jsxs("select",{value:y,onChange:R=>x(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:[a.jsx("option",{value:"active",children:i("projects.statusActive")}),a.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),a.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function TXe({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:s}){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,h]=_.useState(!1),m=c?{icon:Kg,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:wo,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:er,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:rs,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return a.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[a.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),a.jsxs("div",{className:"p-5 pl-6",children:[a.jsxs("div",{className:"flex items-start justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg ${m.bg} flex-shrink-0`,children:a.jsx(m.icon,{className:`w-5 h-5 ${m.color}`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",s("projects.parts")]}):t.target_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",s("projects.plates")]}):t.completed_count>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," ",s("projects.parts")]}):null,c&&a.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.done")}),u&&a.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.statusArchived")})]}),t.description&&a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const b=t.archives.map(S=>S.filament_type).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(Boolean),y=[...new Set(b)],x=t.archives.map(S=>S.filament_color).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(S=>S.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(S)),v=[...new Set(x)];return y.length===0&&v.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[y.slice(0,3).map(S=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:S},S)),v.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[v.slice(0,5).map(S=>a.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&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",v.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:b=>b.stopPropagation(),children:[a.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>h(!d),children:a.jsx(ph,{className:"w-4 h-4"})}),d&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!1)}),a.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:update")&&(n(),h(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:s("projects.noEditPermission"),children:[a.jsx(pm,{className:"w-4 h-4"}),s("common.edit")]}),a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:delete")&&(r(),h(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:s("projects.noDeletePermission"),children:[a.jsx(hn,{className:"w-4 h-4"}),s("common.delete")]})]})]})]})]}),a.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?a.jsxs("div",{className:"space-y-3",children:[t.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.plates")}),a.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(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&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:s("projects.parts")}),a.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(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&&a.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",s("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?a.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(wo,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.completed")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[a.jsx(En,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.failed_count," ",s("projects.failed")]})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[a.jsx(er,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.queue_count," ",s("projects.inQueue")]})]})]}):a.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:s("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(b=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:b.print_name||"Unknown",children:[b.thumbnail_path?a.jsx("img",{src:ae.getArchiveThumbnail(b.id),alt:b.print_name||"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:a.jsx(wc,{className:"w-6 h-6"})}),b.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(En,{className:"w-4 h-4 text-white"})})]},b.id))}),t.archive_count>4&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:s("common.more",{count:t.archive_count-4})})]}),a.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.printJobs"),children:[a.jsx(is,{className:"w-3.5 h-3.5 text-blue-400"}),a.jsxs("span",{children:[t.archive_count," ",s("projects.plates")]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.partsPrinted"),children:[a.jsx(wc,{className:"w-3.5 h-3.5 text-bambu-green"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.parts")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:s("projects.failedParts"),children:[a.jsx(En,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:s("projects.inQueue"),children:[a.jsx(jj,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(Ns,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function AXe(){const{t}=Yt(),e=Pc(),n=nn(),{showToast:r}=kn(),{hasPermission:i}=Rr(),[s,o]=_.useState(!1),[l,c]=_.useState(),[u,d]=_.useState("active"),[h,p]=_.useState(null),{data:m,isLoading:b}=nt({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>ae.getProjects(u==="all"?void 0:u)}),y=dt({mutationFn:B=>ae.createProject(B),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:B=>{r(B.message,"error")}}),x=dt({mutationFn:({id:B,data:D})=>ae.updateProject(B,D),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:B=>{r(B.message,"error")}}),v=dt({mutationFn:B=>ae.deleteProject(B),onSuccess:()=>{p(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:B=>{p(null),r(B.message,"error")}}),S=dt({mutationFn:B=>ae.importProject(B),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:B=>{r(B.message,"error")}}),N=_.useRef(null),T=async()=>{try{const B=await ae.getProjects(),D=await Promise.all(B.map(async K=>await ae.exportProjectJson(K.id))),$=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),G=URL.createObjectURL($),I=document.createElement("a");I.href=G,I.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,I.click(),URL.revokeObjectURL(G),r(t("projects.toast.exported"),"success")}catch(B){r(B.message,"error")}},M=()=>{N.current?.click()},A=async B=>{const D=B.target.files?.[0];if(D){try{if(D.name.toLowerCase().endsWith(".zip"))await ae.importProjectFile(D),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const G=await D.text(),I=JSON.parse(G),K=Array.isArray(I)?I:[I];for(const Q of K)await S.mutateAsync(Q);K.length>1&&r(t("projects.toast.multipleImported",{count:K.length}),"success")}}catch($){r(`${t("projects.toast.importFailed")}: ${$.message}`,"error")}B.target.value=""}},k=B=>{l?x.mutate({id:l.id,data:B}):y.mutate(B)},R=B=>{c(B),o(!0)},C=B=>{e(`/projects/${B.id}`)},P=B=>{p(B)},U=()=>{h!==null&&v.mutate(h)},F=m?.reduce((B,D)=>(B[D.status]=(B[D.status]||0)+1,B.all=(B.all||0)+1,B),{})||{};return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsx("input",{ref:N,type:"file",accept:".json,.zip",onChange:A,className:"hidden"}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(rs,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:M,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[a.jsx(Na,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),a.jsxs(Me,{variant:"secondary",onClick:T,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[a.jsx(_i,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),a.jsxs(Me,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(lr,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),a.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:er},{key:"completed",label:t("projects.statusCompleted"),icon:Kg},{key:"archived",label:t("projects.statusArchived"),icon:wo},{key:"all",label:t("common.all"),icon:rs}].map(({key:B,label:D,icon:$})=>a.jsxs("button",{onClick:()=>d(B),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===B?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx($,{className:"w-4 h-4"}),a.jsx("span",{children:D}),F[B]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===B?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:F[B]})]},B))}),b?a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(lt,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):m?.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(rs,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),a.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"&&a.jsxs(Me,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(lr,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:m?.map(B=>a.jsx(TXe,{project:B,onClick:()=>C(B),onEdit:()=>R(B),onDelete:()=>P(B.id),hasPermission:i,t},B.id))}),h!==null&&a.jsx(Qn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:U,onCancel:()=>p(null)}),s&&a.jsx(fie,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:k,isLoading:y.isPending||x.isPending,t})]})}function CXe(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 PXe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function jXe({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 a.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function z9({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(_t,{children:a.jsx(Mt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",title:i,children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function DXe({archives:t,t:e}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(wc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:e("projectDetail.noPrints")})]}):a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(n=>a.jsxs(Us,{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?a.jsx("img",{src:ae.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(wc,{className:"w-8 h-8"})}),n.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:a.jsx(Ji,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(fr,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function RXe({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 a.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&a.jsx(En,{className:"w-3 h-3"}),i]})}function OXe(t){return t?Xg(t,{year:"numeric",month:"short",day:"numeric"}):""}function uj(t,e){if(!t)return null;const n=Ui(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 LXe(){const{id:t}=xk(),e=Pc(),{t:n}=Yt(),r=nn(),{showToast:i}=kn(),{hasPermission:s}=Rr(),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,h]=_.useState(""),p=parseInt(t||"0",10),{data:m,isLoading:b,error:y}=nt({queryKey:["project",p],queryFn:()=>ae.getProject(p),enabled:p>0}),{data:x,isLoading:v}=nt({queryKey:["project-archives",p],queryFn:()=>ae.getProjectArchives(p),enabled:p>0}),{data:S,isLoading:N}=nt({queryKey:["project-bom",p],queryFn:()=>ae.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:M}=nt({queryKey:["project-timeline",p],queryFn:()=>ae.getProjectTimeline(p,20),enabled:p>0}),{data:A}=nt({queryKey:["settings"],queryFn:ae.getSettings}),{data:k}=nt({queryKey:["project-folders",p],queryFn:()=>ae.getLibraryFoldersByProject(p),enabled:p>0}),R=xu(A?.currency||"USD"),C=A?.time_format||"system",P=dt({mutationFn:Ce=>ae.updateProject(p,Ce),onSuccess:()=>{r.invalidateQueries({queryKey:["project",p]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:Ce=>{i(Ce.message,"error")}}),U=()=>{h(m?.notes||""),u(!0)},F=()=>{P.mutate({notes:d})},B=()=>{u(!1),h("")},[D,$]=_.useState(""),[G,I]=_.useState(1),[K,Q]=_.useState(""),[se,H]=_.useState(""),[W,J]=_.useState(""),[ne,xe]=_.useState(!1),[ue,fe]=_.useState(!1),[De,oe]=_.useState(null),[Ne,Fe]=_.useState(""),[ce,Ve]=_.useState(1),[V,Y]=_.useState(""),[de,q]=_.useState(""),[re,X]=_.useState(""),[le,pe]=_.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),ee=dt({mutationFn:Ce=>ae.createBOMItem(p,Ce),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),$(""),I(1),Q(""),H(""),J(""),xe(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:Ce=>i(Ce.message,"error")}),z=dt({mutationFn:({itemId:Ce,data:Ge})=>ae.updateBOMItem(p,Ce,Ge),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),oe(null)},onError:Ce=>i(Ce.message,"error")}),O=dt({mutationFn:Ce=>ae.deleteBOMItem(p,Ce),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:Ce=>i(Ce.message,"error")}),Z=Ce=>{Ce.preventDefault(),D.trim()&&ee.mutate({name:D.trim(),quantity_needed:G,unit_price:K?parseFloat(K):void 0,sourcing_url:se.trim()||void 0,remarks:W.trim()||void 0})},me=Ce=>{const Ge=Ce.is_complete?0:Ce.quantity_needed;z.mutate({itemId:Ce.id,data:{quantity_acquired:Ge}})},Te=(Ce,Ge)=>{pe({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Ge}),onConfirm:()=>{pe(_e=>({..._e,isOpen:!1})),O.mutate(Ce)}})},ke=Ce=>{oe(Ce),Fe(Ce.name),Ve(Ce.quantity_needed),Y(Ce.unit_price?.toString()||""),q(Ce.sourcing_url||""),X(Ce.remarks||"")},Ee=Ce=>{Ce.preventDefault(),!(!De||!Ne.trim())&&z.mutate({itemId:De.id,data:{name:Ne.trim(),quantity_needed:ce,unit_price:V?parseFloat(V):void 0,sourcing_url:de.trim()||void 0,remarks:re.trim()||void 0}})},Se=()=>{oe(null)},$e=async()=>{try{const{blob:Ce,filename:Ge}=await ae.exportProjectZip(Number(p)),_e=URL.createObjectURL(Ce),Je=document.createElement("a");Je.href=_e,Je.download=Ge||`${m?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,Je.click(),URL.revokeObjectURL(_e),i(n("projectDetail.toast.projectExported"),"success")}catch(Ce){i(Ce.message,"error")}},Qe=dt({mutationFn:()=>ae.createTemplateFromProject(p),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:Ce=>i(Ce.message,"error")}),Ue=Ce=>Yg(Ce,C,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(b)return a.jsx("div",{className:"flex items-center justify-center py-24",children:a.jsx(lt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(y||!m)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:y?`${n("common.error")}: ${y.message}`:n("projectDetail.notFound")}),a.jsx(Me,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const be=m.stats,ve=be?.progress_percent??0,ze=be?.parts_progress_percent??0;return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Us,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),a.jsx(Ns,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:m.name})]}),a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:a.jsx(Rce,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:m.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:m.name}),m.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:m.description})]})]}),a.jsx(jXe,{status:m.status,t:n})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",onClick:$e,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[a.jsx(_i,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),a.jsxs(Me,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[a.jsx(pm,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(m.target_count||m.target_parts_count)&&a.jsx(_t,{children:a.jsxs(Mt,{className:"p-4 space-y-4",children:[m.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[be?.total_archives||0," / ",m.target_count," ",n("projectDetail.progress.printJobs")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(ve,100)}%`,backgroundColor:ve>=100?"#22c55e":m.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:ve.toFixed(0)})}),be?.remaining_prints!=null&&be.remaining_prints>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:be.remaining_prints})})]})]}),m.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[be?.completed_prints||0," / ",m.target_parts_count," ",n("projectDetail.progress.parts")]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(ze,100)}%`,backgroundColor:ze>=100?"#22c55e":m.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:ze.toFixed(0)})}),be?.remaining_parts!=null&&be.remaining_parts>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:be.remaining_parts})})]})]})]})}),be&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(_t,{children:a.jsx(Mt,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(wc,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),a.jsxs("p",{className:"text-xl font-semibold text-white",children:[be.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),be.failed_prints>0&&a.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:be.failed_prints})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:be.completed_prints})})]})]})})}),a.jsx(z9,{icon:er,label:n("projectDetail.stats.printTime"),value:CXe(be.total_print_time_hours),color:"text-yellow-400"}),a.jsx(z9,{icon:Dr,label:n("projectDetail.stats.filamentUsed"),value:PXe(be.total_filament_grams),color:"text-purple-400"})]}),be&&(be.estimated_cost>0||m.budget)&&a.jsx(_t,{children:a.jsxs(Mt,{className:"p-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[R,be.estimated_cost.toFixed(2)]})]}),be.total_energy_kwh>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[be.total_energy_kwh.toFixed(2)," kWh",be.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",R,be.total_energy_cost.toFixed(2),")"]})]})]}),m.budget&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[R,m.budget.toFixed(2)]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),a.jsxs("p",{className:`text-lg font-semibold ${m.budget-be.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[R,(m.budget-be.estimated_cost).toFixed(2)]})]})]})]})]})}),m.children&&m.children.length>0&&a.jsx(_t,{children:a.jsxs(Mt,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(cde,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:m.children.length})]}),a.jsx("div",{className:"space-y-2",children:m.children.map(Ce=>a.jsxs(Us,{to:`/projects/${Ce.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Ce.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:Ce.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Ce.status==="completed"?"bg-status-ok/20 text-status-ok":Ce.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Ce.status})]}),Ce.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[Ce.progress_percent.toFixed(0),"%"]})]},Ce.id))})]})}),m.parent_id&&m.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(is,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),a.jsx(Us,{to:`/projects/${m.parent_id}`,className:"text-bambu-green hover:underline",children:m.parent_name})]}),(m.tags||m.due_date||m.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[m.priority&&m.priority!=="normal"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),a.jsx(RXe,{priority:m.priority,t:n})]}),m.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:OXe(m.due_date)}),uj(m.due_date,n)&&a.jsxs("span",{className:`text-xs ${uj(m.due_date,n).color}`,children:["(",uj(m.due_date,n).label,")"]})]}),m.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ah,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:m.tags.split(",").map((Ce,Ge)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Ce.trim()},Ge))})]})]}),a.jsx(_t,{children:a.jsxs(Mt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(xs,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Me,{variant:"secondary",size:"sm",onClick:B,disabled:P.isPending,children:[a.jsx(Lt,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),a.jsxs(Me,{size:"sm",onClick:F,disabled:P.isPending,children:[P.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(ys,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:U,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[a.jsx(pm,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?a.jsx(_R,{content:d,onChange:h,placeholder:n("projectDetail.notes.placeholder")}):m.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:m.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),a.jsx(_t,{children:a.jsxs(Mt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Hl,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(Us,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),k&&k.length>0?a.jsx("div",{className:"space-y-2",children:k.map(Ce=>a.jsxs(Us,{to:`/files?folder=${Ce.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx(Hl,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:Ce.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:Ce.file_count})})]})]}),a.jsx(Ns,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Ce.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),a.jsx(_t,{children:a.jsxs(Mt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(GW,{className:"w-5 h-5"}),n("projectDetail.bom.title"),be&&be.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:be.bom_completed_items,total:be.bom_total_items}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[S&&S.some(Ce=>Ce.is_complete)&&a.jsx("button",{onClick:()=>fe(!ue),className:`text-xs px-2 py-1 rounded transition-colors ${ue?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(ue?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!ne&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>xe(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[a.jsx(lr,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),ne&&a.jsxs("form",{onSubmit:Z,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:D,onChange:Ce=>$(Ce.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}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:G,onChange:Ce=>I(parseInt(Ce.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")}),a.jsx("input",{type:"number",step:"0.01",value:K,onChange:Ce=>Q(Ce.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})})]})]}),a.jsx("input",{type:"url",value:se,onChange:Ce=>H(Ce.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")}),a.jsx("input",{type:"text",value:W,onChange:Ce=>J(Ce.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")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>xe(!1),children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!D.trim()||ee.isPending,children:ee.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),N?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?a.jsxs("div",{className:"space-y-2",children:[S.filter(Ce=>!ue||!Ce.is_complete).map(Ce=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${Ce.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:De?.id===Ce.id?a.jsxs("form",{onSubmit:Ee,className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:Ne,onChange:Ge=>Fe(Ge.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}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:ce,onChange:Ge=>Ve(parseInt(Ge.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")}),a.jsx("input",{type:"number",step:"0.01",value:V,onChange:Ge=>Y(Ge.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})})]})]}),a.jsx("input",{type:"url",value:de,onChange:Ge=>q(Ge.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")}),a.jsx("input",{type:"text",value:re,onChange:Ge=>X(Ge.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")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:Se,children:n("common.cancel")}),a.jsx(Me,{type:"submit",size:"sm",disabled:!Ne.trim()||z.isPending,children:z.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("button",{onClick:()=>s("projects:update")&&me(Ce),disabled:z.isPending||!s("projects:update"),title:s("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 ${Ce.is_complete?"bg-status-ok border-status-ok text-white":s("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:Ce.is_complete&&a.jsx(fr,{className:"w-3 h-3"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("p",{className:`text-sm font-medium ${Ce.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Ce.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Ce.quantity_needed]})]}),Ce.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[R,(Ce.unit_price*Ce.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s("projects:update")&&ke(Ce),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("projects:update")&&Te(Ce.id,Ce.name),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:a.jsx(hn,{className:"w-4 h-4"})})]})]}),Ce.sourcing_url&&a.jsxs("a",{href:Ce.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:Ge=>Ge.stopPropagation(),children:[a.jsx(Zr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Ce.sourcing_url).hostname.replace("www.","")}catch{return Ce.sourcing_url}})()})]}),Ce.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Ce.remarks})]})]})},Ce.id)),S.some(Ce=>Ce.unit_price!==null)&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),a.jsxs("span",{className:"text-white font-medium",children:[R,S.reduce((Ce,Ge)=>Ce+(Ge.unit_price||0)*Ge.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),a.jsx(_t,{children:a.jsxs(Mt,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Q0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),M?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?a.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((Ce,Ge)=>a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${Ce.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":Ce.event_type==="print_failed"?"bg-status-error/20 text-status-error":Ce.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Ce.event_type==="print_completed"&&a.jsx(fr,{className:"w-4 h-4"}),Ce.event_type==="print_failed"&&a.jsx(Ji,{className:"w-4 h-4"}),Ce.event_type==="print_started"&&a.jsx(Dr,{className:"w-4 h-4"}),Ce.event_type==="queued"&&a.jsx(jj,{className:"w-4 h-4"}),Ce.event_type==="project_created"&&a.jsx(lr,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:Ce.title}),Ce.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Ce.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:Ue(Ce.timestamp)})]})]},Ge))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!m.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Qe.mutate(),disabled:Qe.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[Qe.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Bl,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),be&&(be.queued_prints>0||be.in_progress_prints>0)&&a.jsx(_t,{children:a.jsxs(Mt,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(jj,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),a.jsx(Us,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[be.in_progress_prints>0&&a.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:be.in_progress_prints})}),be.queued_prints>0&&a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:be.queued_prints})})]})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-4",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(wc,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:x?.length||0})]})}),v?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(DXe,{archives:x||[],t:n})]}),o&&a.jsx(fie,{t:n,project:{...m,archive_count:be?.total_archives||0,total_items:be?.total_items||0,completed_count:be?.completed_prints||0,failed_count:be?.failed_prints||0,queue_count:be?.queued_prints||0,progress_percent:be?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:Ce=>P.mutate(Ce),isLoading:P.isPending}),le.isOpen&&a.jsx(Qn,{title:le.title,message:le.message,confirmText:n("common.delete"),variant:"danger",onConfirm:le.onConfirm,onCancel:()=>pe(Ce=>({...Ce,isOpen:!1}))})]})}function vg(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 FXe(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 IXe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=_.useState(""),l=c=>{c.preventDefault(),n({name:s.trim(),parent_id:t})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("fileManager.newFolder")})}),a.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("fileManager.folderName")}),a.jsx("input",{type:"text",value:s,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function zXe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:s}){const[o,l]=_.useState(e),c=u=>{u.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),a.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:s("common.name")}),a.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})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),a.jsx(Me,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function UXe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s,t:o}){const[l,c]=_.useState(null),u=(h,p=0)=>{const m=[];for(const b of h)m.push({id:b.id,name:b.name,depth:p}),b.children.length>0&&m.push(...u(b.children,p+1));return m},d=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...u(t)];return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(h=>a.jsxs("button",{onClick:()=>c(h.id),disabled:h.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===h.id?"bg-bambu-green/20 text-bambu-green":h.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+h.depth*16}px`},children:[a.jsx(Hl,{className:"w-4 h-4"}),h.name,h.id===n&&a.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},h.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Me,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Me,{onClick:()=>i(l),disabled:s,children:s?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function BXe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[s,o]=_.useState("project"),[l,c]=_.useState(t.project_id||t.archive_id||null);_.useState(()=>{t.archive_id&&o("archive")});const{data:u}=nt({queryKey:["projects"],queryFn:()=>ae.getProjects()}),{data:d}=nt({queryKey:["archives-for-link"],queryFn:()=>ae.getArchives(void 0,void 0,100)}),h=()=>{n(s==="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 a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(pc,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("fileManager.linkFolderDescription",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.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 ${s==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(LW,{className:"w-4 h-4"}),i("fileManager.project")]}),a.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 ${s==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(wo,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:s==="project"?u&&u.length>0?u.map(b=>a.jsxs("button",{onClick:()=>c(b.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===b.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:b.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:b.name})]},b.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):d&&d.length>0?d.map(b=>a.jsxs("button",{onClick:()=>c(b.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===b.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(Qf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:b.print_name||b.filename})]},b.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&a.jsxs(Me,{variant:"danger",onClick:p,disabled:r,children:[a.jsx(ZR,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),a.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[a.jsx(Me,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Me,{onClick:h,disabled:!l||r,children:r?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function HXe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,s]=_.useState([]),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,h]=_.useState(!0),[p,m]=_.useState(!1),[b,y]=_.useState(!0),x=_.useRef(null),v=$=>{$.preventDefault(),l(!0)},S=$=>{$.preventDefault(),l(!1)},N=$=>{$.preventDefault(),l(!1);const G=Array.from($.dataTransfer.files);M(G)},T=$=>{$.target.files&&M(Array.from($.target.files))},M=$=>{const G=$.map(I=>({file:I,status:"pending",isZip:I.name.toLowerCase().endsWith(".zip"),is3mf:I.name.toLowerCase().endsWith(".3mf")}));s(I=>[...I,...G])},A=$=>{s(G=>G.filter((I,K)=>K!==$))},k=i.some($=>$.isZip&&$.status==="pending"),R=i.some($=>$.file.name.toLowerCase().endsWith(".stl")&&$.status==="pending"),C=i.some($=>$.is3mf&&$.status==="pending"),P=async()=>{if(i.length!==0){u(!0);for(let $=0;$<i.length;$++)if(i[$].status==="pending"){s(G=>G.map((I,K)=>K===$?{...I,status:"uploading"}:I));try{if(i[$].isZip){const G=await ae.extractZipFile(i[$].file,t,d,p,b);s(I=>I.map((K,Q)=>Q===$?{...K,status:G.errors.length>0&&G.extracted===0?"error":"success",extractedCount:G.extracted,error:G.errors.length>0?`${G.errors.length} files failed`:void 0}:K))}else await ae.uploadLibraryFile(i[$].file,t,b),s(G=>G.map((I,K)=>K===$?{...I,status:"success"}:I))}catch(G){s(I=>I.map((K,Q)=>Q===$?{...K,status:"error",error:G instanceof Error?G.message:"Upload failed"}:K))}}u(!1),n(),e()}},U=i.filter($=>$.status==="pending").length,F=i.filter($=>$.status==="success").length,B=i.filter($=>$.status==="error").length,D=i.length>0&&U===0&&!c;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("fileManager.uploadFiles")}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:v,onDragLeave:S,onDrop:N,onClick:()=>x.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:[a.jsx(Na,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),a.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),a.jsx("input",{ref:x,type:"file",multiple:!0,className:"hidden",onChange:T}),k&&a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(wo,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-blue-300 font-medium",children:r("fileManager.zipFilesDetected")}),a.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:d,onChange:$=>h($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:$=>m($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.createFolderFromZip")})]})]})]})}),C&&a.jsx("div",{className:"p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Dr,{className:"w-5 h-5 text-purple-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-purple-300 font-medium",children:r("fileManager.threemfDetected")}),a.jsx("p",{className:"text-xs text-purple-300/70 mt-1",children:r("fileManager.threemfExtractionInfo")})]})]})}),(R||k)&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx($u,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium",children:r("fileManager.stlThumbnailGeneration")}),a.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(k&&!R?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:b,onChange:$=>y($.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map(($,G)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[$.isZip?a.jsx(wo,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(Nk,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:$.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[($.file.size/1024/1024).toFixed(2)," MB",$.isZip&&$.status==="pending"&&a.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),$.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:$.extractedCount})]})]})]}),$.status==="pending"&&a.jsx("button",{onClick:()=>A(G),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray"})}),$.status==="uploading"&&a.jsx(lt,{className:"w-4 h-4 text-bambu-green animate-spin"}),$.status==="success"&&a.jsx(fr,{className:"w-4 h-4 text-green-500"}),$.status==="error"&&a.jsx("span",{title:$.error,children:a.jsx(Ji,{className:"w-4 h-4 text-red-500"})})]},G))}),D&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:F}),B>0&&a.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:B})]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Me,{variant:"secondary",onClick:e,children:r(D?"common.close":"common.cancel")}),!D&&a.jsx(Me,{onClick:P,disabled:U===0||c,children:c?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(Na,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",U>0?`(${U})`:""]})})]})]})})}function mie({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,h]=_.useState(!0),[p,m]=_.useState(!1),b=t.children.length>0,y=t.project_id||t.archive_id;return a.jsxs("div",{children:[a.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[b?a.jsx("button",{onClick:x=>{x.stopPropagation(),h(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ns,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(Hl,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),a.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),y&&a.jsxs("button",{onClick:x=>{x.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[a.jsx(pc,{className:"w-3 h-3"}),t.project_name?a.jsx(LW,{className:"w-3 h-3"}):a.jsx(wo,{className:"w-3 h-3"})]}),t.file_count>0&&a.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!y&&a.jsx("button",{onClick:x=>{x.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:a.jsx(pc,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),a.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:x=>x.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>m(!p),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(ph,{className:"w-3.5 h-3.5 text-bambu-gray"})}),p&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!1)}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[a.jsx(ea,{className:"w-3.5 h-3.5"}),u("common.rename")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(i(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionLinkFolder"),children:[a.jsx(pc,{className:"w-3.5 h-3.5"}),u(y?"fileManager.changeLink":"fileManager.linkTo")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),m(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:u("fileManager.noPermissionDeleteFolder"),children:[a.jsx(hn,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),b&&d&&a.jsx("div",{children:t.children.map(x=>a.jsx(mie,{folder:x,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:u},x.id))})]})}function CR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function $Xe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:u,onGenerateThumbnail:d,thumbnailVersion:h,hasPermission:p,canModify:m,authEnabled:b,t:y}){const[x,v]=_.useState(!1);return a.jsxs("div",{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[a.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?a.jsx("img",{src:`${ae.getLibraryFileThumbnailUrl(t.id)}${h?`?v=${h}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(Qf,{className:"w-12 h-12 text-bambu-gray/30"}),a.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[a.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[a.jsx("span",{children:vg(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(er,{className:"w-3 h-3"}),FXe(t.print_time_seconds)]})]}),t.sliced_for_model&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(Dr,{className:"w-3 h-3"}),t.sliced_for_model]}),t.print_count>0&&a.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:y("fileManager.printedCount",{count:t.print_count})}),b&&t.created_by_username&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(qu,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:S=>S.stopPropagation(),children:[a.jsx("button",{onClick:()=>v(!x),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(ph,{className:"w-4 h-4 text-bambu-gray"})}),x&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>v(!1)}),a.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&CR(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("printers:control")&&(l(t),v(!1))},disabled:!p("printers:control"),title:p("printers:control")?void 0:y("fileManager.noPermissionPrint"),children:[a.jsx(Dr,{className:"w-3.5 h-3.5"}),y("common.print")]}),o&&CR(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("queue:create")&&(o(t.id),v(!1))},disabled:!p("queue:create"),title:p("queue:create")?void 0:y("fileManager.noPermissionAddToQueue"),children:[a.jsx(er,{className:"w-3.5 h-3.5"}),y("fileManager.schedulePrint")]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(c(t),v(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:"You do not have permission to preview files",children:[a.jsx(zi,{className:"w-3.5 h-3.5"}),"3D Preview"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(s(t.id),v(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:y("fileManager.noPermissionDownload"),children:[a.jsx(_i,{className:"w-3.5 h-3.5"}),y("common.download")]}),u&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library","update",t.created_by_id)&&(u(t),v(!1))},disabled:!m("library","update",t.created_by_id),title:m("library","update",t.created_by_id)?void 0:y("fileManager.noPermissionRenameFile"),children:[a.jsx(ea,{className:"w-3.5 h-3.5"}),y("common.rename")]}),d&&t.file_type==="stl"&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library","update",t.created_by_id)&&(d(t),v(!1))},disabled:!m("library","update",t.created_by_id),title:m("library","update",t.created_by_id)?void 0:y("fileManager.noPermissionGenerateThumbnail"),children:[a.jsx($u,{className:"w-3.5 h-3.5"}),y("fileManager.generateThumbnail")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library","delete",t.created_by_id)&&(i(t.id),v(!1))},disabled:!m("library","delete",t.created_by_id),title:m("library","delete",t.created_by_id)?void 0:y("fileManager.noPermissionDeleteFile"),children:[a.jsx(hn,{className:"w-3.5 h-3.5"}),y("common.delete")]})]})]})]}),a.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function VXe(){const{t}=Yt(),e=nn(),{showToast:n}=kn(),{hasPermission:r,hasAnyPermission:i,canModify:s,authEnabled:o}=Rr(),[l]=zR(),c=l.get("folder"),u=c?parseInt(c,10):null,[d,h]=_.useState(u),[p,m]=_.useState([]),[b,y]=_.useState(!1),[x,v]=_.useState(!1),[S,N]=_.useState(!1),[T,M]=_.useState(null),[A,k]=_.useState(null),[R,C]=_.useState(null),[P,U]=_.useState(null),[F,B]=_.useState(null),[D,$]=_.useState(null),[G,I]=_.useState({}),[K,Q]=_.useState(null),[se,H]=_.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[W,J]=_.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[ne,xe]=_.useState(()=>{const Oe=localStorage.getItem("library-sidebar-width");return Oe?parseInt(Oe,10):256}),[ue,fe]=_.useState(!1),De=_.useRef(null);_.useEffect(()=>{if(!ue)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Oe=Wt=>{if(!De.current)return;const rn=De.current.parentElement?.getBoundingClientRect();if(!rn)return;const Qt=Wt.clientX-rn.left,ur=Math.min(500,Math.max(200,Qt));xe(ur)},yt=()=>{fe(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(ne))};return document.addEventListener("mousemove",Oe),document.addEventListener("mouseup",yt),()=>{document.removeEventListener("mousemove",Oe),document.removeEventListener("mouseup",yt),document.body.style.userSelect="",document.body.style.cursor=""}},[ue,ne]);const[oe,Ne]=_.useState(""),[Fe,ce]=_.useState("all"),[Ve,V]=_.useState(""),[Y,de]=_.useState(()=>localStorage.getItem("library-sort-field")||"name"),[q,re]=_.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),X=nO();_.useEffect(()=>{const Oe=l.get("folder");if(Oe){const yt=parseInt(Oe,10);h(yt)}},[l]);const{data:le}=nt({queryKey:["settings"],queryFn:()=>ae.getSettings()}),{data:pe,isLoading:ee}=nt({queryKey:["library-folders"],queryFn:()=>ae.getLibraryFolders()}),{data:z,isLoading:O}=nt({queryKey:["library-files",d],queryFn:()=>ae.getLibraryFiles(d,d===null)}),{data:Z}=nt({queryKey:["library-stats"],queryFn:()=>ae.getLibraryStats()}),{data:me}=nt({queryKey:["users"],queryFn:()=>ae.getUsers()}),Te=_.useMemo(()=>{if(!z)return[];const Oe=new Set(z.map(yt=>yt.file_type));return Array.from(Oe).sort()},[z]),ke=_.useMemo(()=>{if(!z)return[];let Oe=[...z];if(oe.trim()){const yt=oe.toLowerCase();Oe=Oe.filter(Wt=>Wt.filename.toLowerCase().includes(yt)||Wt.print_name&&Wt.print_name.toLowerCase().includes(yt))}if(Fe!=="all"&&(Oe=Oe.filter(yt=>yt.file_type===Fe)),Ve.trim()){const yt=Ve.toLowerCase();Oe=Oe.filter(Wt=>Wt.created_by_username&&Wt.created_by_username.toLowerCase().includes(yt))}return Oe.sort((yt,Wt)=>{let rn=0;switch(Y){case"name":rn=(yt.print_name||yt.filename).localeCompare(Wt.print_name||Wt.filename);break;case"date":rn=new Date(yt.created_at).getTime()-new Date(Wt.created_at).getTime();break;case"size":rn=yt.file_size-Wt.file_size;break;case"type":rn=yt.file_type.localeCompare(Wt.file_type);break;case"prints":rn=yt.print_count-Wt.print_count;break}return q==="asc"?rn:-rn}),Oe},[z,oe,Fe,Ve,Y,q]),Ee=_.useMemo(()=>{if(!Z||!le)return!1;const Oe=(le.library_disk_warning_gb||5)*1024*1024*1024;return Z.disk_free_bytes<Oe},[Z,le]),Se=dt({mutationFn:Oe=>ae.createLibraryFolder(Oe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),y(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:Oe=>n(Oe.message,"error")}),$e=dt({mutationFn:Oe=>ae.deleteLibraryFolder(Oe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),d===A?.id&&h(null),k(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:Oe=>{k(null),n(Oe.message,"error")}}),Qe=dt({mutationFn:Oe=>ae.deleteLibraryFile(Oe),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),m(Oe=>Oe.filter(yt=>yt!==A?.id)),k(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:Oe=>{k(null),n(Oe.message,"error")}}),Ue=dt({mutationFn:Oe=>ae.bulkDeleteLibrary(Oe,[]),onSuccess:(Oe,yt)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:yt.length}),"success"),m([]),k(null)},onError:Oe=>{k(null),n(Oe.message,"error")}}),be=dt({mutationFn:({fileIds:Oe,folderId:yt})=>ae.moveLibraryFiles(Oe,yt),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),m([]),v(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:Oe=>n(Oe.message,"error")}),ve=dt({mutationFn:({id:Oe,data:yt})=>ae.updateLibraryFolder(Oe,yt),onSuccess:(Oe,yt)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),M(null);const Wt=yt.data.project_id===0&&yt.data.archive_id===0;n(t(Wt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:Oe=>n(Oe.message,"error")}),ze=dt({mutationFn:({id:Oe,filename:yt})=>ae.updateLibraryFile(Oe,{filename:yt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),$(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:Oe=>{$(null),n(Oe.message,"error")}}),Ce=dt({mutationFn:({id:Oe,name:yt})=>ae.updateLibraryFolder(Oe,{name:yt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),$(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:Oe=>{$(null),n(Oe.message,"error")}}),Ge=dt({mutationFn:()=>ae.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:Oe=>{if(e.invalidateQueries({queryKey:["library-files"]}),Oe.succeeded>0){const yt=Date.now(),Wt={};Oe.results.forEach(rn=>{rn.success&&(Wt[rn.file_id]=yt)}),I(rn=>({...rn,...Wt}))}Oe.succeeded>0&&Oe.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:Oe.succeeded}),"success"):Oe.succeeded>0&&Oe.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:Oe.succeeded,failed:Oe.failed}),"success"):Oe.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:Oe.results[0]?.error||"Unknown error"}),"error")},onError:Oe=>n(Oe.message,"error")}),_e=dt({mutationFn:Oe=>ae.batchGenerateStlThumbnails({file_ids:[Oe]}),onSuccess:Oe=>{if(e.invalidateQueries({queryKey:["library-files"]}),Oe.succeeded>0){const yt=Oe.results[0]?.file_id;yt&&I(Wt=>({...Wt,[yt]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:Oe.results[0]?.error||"Unknown error"}),"error")},onError:Oe=>n(Oe.message,"error")}),Je=_.useCallback(Oe=>{const yt=Oe.toLowerCase();return yt.endsWith(".gcode")||yt.includes(".gcode.")},[]),Ae=_.useMemo(()=>z?z.filter(Oe=>p.includes(Oe.id)&&Je(Oe.filename)):[],[z,p,Je]),Ke=_.useCallback(Oe=>{m(yt=>yt.includes(Oe)?yt.filter(Wt=>Wt!==Oe):[...yt,Oe])},[]),je=_.useCallback(()=>{ke.length>0&&m(ke.map(Oe=>Oe.id))},[ke]),Re=_.useCallback(()=>{m([])},[]),we=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},qe=Oe=>{ae.downloadLibraryFile(Oe).catch(yt=>{console.error("Library file download failed:",yt)})},xt=()=>{A&&(A.type==="file"?Qe.mutate(A.id):A.type==="folder"?$e.mutate(A.id):A.type==="bulk"&&Ue.mutate(p))},Et=$e.isPending||Qe.isPending||Ue.isPending,fn=Oe=>{H(Oe),localStorage.setItem("library-view-mode",Oe)},It=ee||O;return a.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(Hl,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[a.jsx("button",{onClick:()=>fn("grid"),className:`p-1.5 rounded transition-colors ${se==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:a.jsx(Ek,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>fn("list"),className:`p-1.5 rounded transition-colors ${se==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:a.jsx(Tk,{className:"w-4 h-4"})})]}),a.jsxs(Me,{variant:"secondary",onClick:()=>Ge.mutate(),disabled:Ge.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[Ge.isPending?a.jsx(lt,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx($u,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),a.jsxs(Me,{variant:"secondary",onClick:()=>y(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[a.jsx(ode,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),a.jsxs(Me,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(Na,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),Ee&&Z&&le&&a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[a.jsx(En,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),a.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:vg(Z.disk_free_bytes),total:vg(Z.disk_total_bytes),threshold:le.library_disk_warning_gb})})]})]}),Z&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Nk,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),a.jsx("span",{className:"text-white font-medium",children:Z.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Hl,{className:"w-4 h-4 text-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),a.jsx("span",{className:"text-white font-medium",children:Z.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Eb,{className:"w-4 h-4 text-amber-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),a.jsx("span",{className:"text-white font-medium",children:vg(Z.total_size_bytes)})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),a.jsx("span",{className:`font-medium ${Ee?"text-amber-500":"text-white"}`,children:vg(Z.disk_free_bytes)})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[a.jsx("div",{className:"lg:hidden",children:a.jsxs("select",{value:d??"",onChange:Oe=>h(Oe.target.value?parseInt(Oe.target.value,10):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[a.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),pe&&(()=>{const Oe=(yt,Wt=0)=>{const rn=[];for(const Qt of yt)rn.push({id:Qt.id,name:Qt.name,fileCount:Qt.file_count,depth:Wt}),Qt.children.length>0&&rn.push(...Oe(Qt.children,Wt+1));return rn};return Oe(pe).map(yt=>a.jsxs("option",{value:yt.id,children:["│ ".repeat(yt.depth),"📂 ",yt.name," ",yt.fileCount>0?`(${yt.fileCount})`:""]},yt.id))})()]})}),a.jsxs("div",{ref:De,className:"hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${ne}px`},children:[a.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${ue?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:Oe=>{Oe.preventDefault(),fe(!0)},onDoubleClick:()=>{xe(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:a.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${ue?"opacity-100":""}`,children:[a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),a.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),a.jsx("button",{onClick:()=>{const Oe=!W;J(Oe),localStorage.setItem("library-wrap-folders",String(Oe))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${W?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(W?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[a.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${d===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>h(null),children:[a.jsx(Qf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),pe?.map(Oe=>a.jsx(mie,{folder:Oe,selectedFolderId:d,onSelect:h,onDelete:yt=>k({type:"folder",id:yt}),onLink:M,onRename:yt=>$({type:"folder",id:yt.id,name:yt.name}),wrapNames:W,hasPermission:r,t},Oe.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[z&&z.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[a.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[a.jsx(Zi,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:oe,onChange:Oe=>Ne(Oe.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(kk,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:Fe,onChange:Oe=>ce(Oe.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"all",children:t("fileManager.allTypes")}),Te.map(Oe=>a.jsx("option",{value:Oe,children:Oe.toUpperCase()},Oe))]})]}),o&&a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:Ve,onChange:Oe=>V(Oe.target.value),list:"usernames-list",className:`w-32 sm:w-40 px-2 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 ${Ve?"pr-7":""}`,style:Ve?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),Ve&&a.jsx("button",{onClick:()=>V(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:a.jsx(Lt,{className:"w-3 h-3"})}),a.jsx("datalist",{id:"usernames-list",children:me?.map(Oe=>a.jsx("option",{value:Oe.username},Oe.id))})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:Y,onChange:Oe=>{const yt=Oe.target.value;de(yt),localStorage.setItem("library-sort-field",yt)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"name",children:t("common.name")}),a.jsx("option",{value:"date",children:t("common.date")}),a.jsx("option",{value:"size",children:t("fileManager.size")}),a.jsx("option",{value:"type",children:t("common.type")}),a.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),a.jsx("button",{onClick:()=>re(Oe=>{const yt=Oe==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",yt),yt}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(q==="asc"?"fileManager.ascending":"fileManager.descending"),children:q==="asc"?a.jsx(zce,{className:"w-4 h-4 text-white"}):a.jsx(Pce,{className:"w-4 h-4 text-white"})})]}),(oe||Fe!=="all"||Ve)&&a.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:ke.length,total:z.length})})]}),ke.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[p.length===ke.length&&p.length>0?a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Re,children:[a.jsx(ul,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):a.jsxs(Me,{variant:"secondary",size:"sm",onClick:je,children:[a.jsx(Ks,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),p.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:p.length})}),a.jsx("div",{className:"hidden sm:block flex-1"}),a.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[Ae.length===1&&a.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>U(Ae[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[a.jsx(To,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),Ae.length===1&&a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>B(Ae[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[a.jsx(er,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[a.jsx(mhe,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),a.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>{p.length===1?k({type:"file",id:p[0]}):k({type:"bulk",id:0,count:p.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[a.jsx(hn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),a.jsxs(Me,{variant:"secondary",size:"sm",onClick:Re,children:[a.jsx(Lt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),It?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(lt,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):z?.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(Qf,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(d!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(d!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),a.jsxs(Me,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(lr,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):ke.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(Zi,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),a.jsx(Me,{variant:"secondary",onClick:()=>{Ne(""),ce("all")},children:t("fileManager.clearFilters")})]}):se==="grid"?a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:ke.map(Oe=>a.jsx($Xe,{file:Oe,isSelected:p.includes(Oe.id),isMobile:X,t,onSelect:Ke,onDelete:yt=>k({type:"file",id:yt}),onDownload:qe,onAddToQueue:yt=>{const Wt=z?.find(rn=>rn.id===yt);Wt&&B(Wt)},onPrint:C,onPreview3d:Q,onRename:yt=>$({type:"file",id:yt.id,name:yt.filename}),onGenerateThumbnail:yt=>_e.mutate(yt.id),thumbnailVersion:G[Oe.id],hasPermission:r,canModify:s,authEnabled:o},Oe.id))})}):a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("div",{className:`hidden sm:grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"grid-cols-[auto_1fr_100px_100px_100px_80px]"} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[a.jsx("div",{className:"w-6"}),a.jsx("div",{children:t("common.name")}),o&&a.jsx("div",{children:t("fileManager.uploadedBy",{defaultValue:"Uploaded By"})}),a.jsx("div",{children:t("common.type")}),a.jsx("div",{children:t("fileManager.size")}),a.jsx("div",{children:t("fileManager.prints")}),a.jsx("div",{})]}),ke.map(Oe=>a.jsxs("div",{className:`grid ${o?"grid-cols-[auto_1fr_120px_100px_100px_100px_80px]":"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 ${p.includes(Oe.id)?"bg-bambu-green/10":""}`,onClick:()=>Ke(Oe.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${p.includes(Oe.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:p.includes(Oe.id)&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsxs("div",{className:"relative group/thumb",children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:Oe.thumbnail_path?a.jsx("img",{src:`${ae.getLibraryFileThumbnailUrl(Oe.id)}${G[Oe.id]?`?v=${G[Oe.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(Qf,{className:"w-5 h-5 text-bambu-gray/50"})})}),Oe.thumbnail_path&&a.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:a.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:a.jsx("img",{src:`${ae.getLibraryFileThumbnailUrl(Oe.id)}${G[Oe.id]?`?v=${G[Oe.id]}`:""}`,alt:Oe.filename,className:"w-full h-full object-contain"})})})]}),a.jsx("div",{className:"min-w-0",children:a.jsx("div",{className:"text-sm text-white truncate",children:Oe.print_name||Oe.filename})})]}),o&&a.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:Oe.created_by_username?a.jsxs(a.Fragment,{children:[a.jsx(qu,{className:"w-3 h-3"}),a.jsx("span",{className:"truncate",children:Oe.created_by_username})]}):"-"}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${Oe.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":Oe.file_type==="gcode"?"bg-blue-500/20 text-blue-400":Oe.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:Oe.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:vg(Oe.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Oe.print_count>0?`${Oe.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:yt=>yt.stopPropagation(),children:[CR(Oe.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>r("printers:control")&&C(Oe),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:a.jsx(Dr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{r("queue:create")&&B(Oe)},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.schedulePrint"):t("fileManager.noPermissionAddToQueue"),disabled:!r("queue:create"),children:a.jsx(er,{className:"w-4 h-4"})})]}),(Oe.file_type==="3mf"||Oe.file_type==="gcode"||Oe.file_type==="stl")&&a.jsx("button",{onClick:()=>r("library:read")&&Q(Oe),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!r("library:read"),children:a.jsx(zi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("library:read")&&qe(Oe.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:a.jsx(_i,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","update",Oe.created_by_id)&&$({type:"file",id:Oe.id,name:Oe.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",Oe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Oe.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",Oe.created_by_id),children:a.jsx(ea,{className:"w-4 h-4"})}),Oe.file_type==="stl"&&a.jsx("button",{onClick:()=>s("library","update",Oe.created_by_id)&&_e.mutate(Oe.id),className:`p-1.5 rounded transition-colors ${s("library","update",Oe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",Oe.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:_e.isPending||!s("library","update",Oe.created_by_id),children:a.jsx($u,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","delete",Oe.created_by_id)&&k({type:"file",id:Oe.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",Oe.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","delete",Oe.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",Oe.created_by_id),children:a.jsx(hn,{className:"w-4 h-4"})})]})]},Oe.id))]})})]})]}),b&&a.jsx(IXe,{parentId:d,onClose:()=>y(!1),onSave:Oe=>Se.mutate(Oe),isLoading:Se.isPending,t}),x&&pe&&a.jsx(UXe,{folders:pe,selectedFiles:p,currentFolderId:d,onClose:()=>v(!1),onMove:Oe=>be.mutate({fileIds:p,folderId:Oe}),isLoading:be.isPending,t}),S&&a.jsx(HXe,{folderId:d,onClose:()=>N(!1),onUploadComplete:we,t}),T&&a.jsx(BXe,{folder:T,onClose:()=>M(null),onLink:Oe=>ve.mutate({id:T.id,data:Oe}),isLoading:ve.isPending,t}),A&&a.jsx(Qn,{title:A.type==="folder"?t("fileManager.deleteFolder"):A.type==="bulk"?t("fileManager.deleteFilesCount",{count:A.count}):t("fileManager.deleteFile"),message:A.type==="folder"?t("fileManager.deleteFolderConfirm"):A.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:A.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:Et,loadingText:t("fileManager.deleting"),onConfirm:xt,onCancel:()=>k(null)}),R&&a.jsx(Iu,{mode:"reprint",libraryFileId:R.id,archiveName:R.print_name||R.filename,onClose:()=>C(null),onSuccess:()=>{C(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),P&&a.jsx(Iu,{mode:"reprint",libraryFileId:P.id,archiveName:P.print_name||P.filename,onClose:()=>U(null),onSuccess:()=>{U(null),m([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),F&&a.jsx(Iu,{mode:"add-to-queue",libraryFileId:F.id,archiveName:F.print_name||F.filename,onClose:()=>B(null),onSuccess:()=>{B(null),m([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),K&&a.jsx(O4,{libraryFileId:K.id,title:K.print_name||K.filename,fileType:K.file_type,onClose:()=>Q(null)}),D&&a.jsx(zXe,{type:D.type,currentName:D.name,onClose:()=>$(null),onSave:Oe=>{D.type==="file"?ze.mutate({id:D.id,filename:Oe}):Ce.mutate({id:D.id,name:Oe})},isLoading:ze.isPending||Ce.isPending,t})]})}const dj=5,GXe=2e3,qXe=3e4,WXe=5e3;function KXe(){const{t}=Yt(),e=nn(),{showToast:n}=kn(),{hasPermission:r}=Rr(),{printerId:i}=xk(),s=parseInt(i||"0",10),[o,l]=_.useState("stream"),[c,u]=_.useState(!1),[d,h]=_.useState(!1),[p,m]=_.useState(!0),[b,y]=_.useState(Date.now()),[x,v]=_.useState(!1),[S,N]=_.useState(!1),[T,M]=_.useState(0),[A,k]=_.useState(!1),[R,C]=_.useState(0),[P,U]=_.useState(1),[F,B]=_.useState({x:0,y:0}),[D,$]=_.useState(!1),[G,I]=_.useState({x:0,y:0}),[K,Q]=_.useState(null),[se,H]=_.useState(null),W=_.useRef(null),J=_.useRef(null),ne=_.useRef(null),xe=_.useRef(null),ue=_.useRef(null),{data:fe}=nt({queryKey:["printer",s],queryFn:()=>ae.getPrinter(s),enabled:s>0}),{data:De}=nt({queryKey:["printerStatus",s],queryFn:()=>ae.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),oe=dt({mutationFn:be=>ae.setChamberLight(s,be),onMutate:async be=>{await e.cancelQueries({queryKey:["printerStatus",s]});const ve=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],ze=>({...ze,chamber_light:be})),{previousStatus:ve}},onSuccess:(be,ve)=>{n(`Chamber light ${ve?"on":"off"}`)},onError:(be,ve,ze)=>{ze?.previousStatus&&e.setQueryData(["printerStatus",s],ze.previousStatus),n(be.message||t("printers.toast.failedToControlChamberLight"),"error")}}),Ne=(De?.state==="RUNNING"||De?.state==="PAUSE"||De?.state==="PAUSED")&&(De?.printable_objects_count??0)>=2;_.useEffect(()=>(fe&&(document.title=`${fe.name} - Camera`),()=>{document.title="Bambuddy"}),[fe]);const Fe=_.useRef(!1);_.useEffect(()=>{const be=`/api/v1/printers/${s}/camera/stop`;Fe.current=!1;const ve=()=>{if(s>0&&!Fe.current){Fe.current=!0;const Ge={},_e=Ph();_e&&(Ge.Authorization=`Bearer ${_e}`),fetch(be,{method:"POST",keepalive:!0,headers:Ge}).catch(()=>{})}},ze=()=>{ve()};window.addEventListener("beforeunload",ze);const Ce=W.current;return()=>{window.removeEventListener("beforeunload",ze),Ce&&(Ce.src=""),ve()}},[s]),_.useEffect(()=>{if(p&&!x){const ve=setTimeout(()=>{m(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(ve)}},[o,p,b,x]),_.useEffect(()=>{const be=()=>{const ve=!!document.fullscreenElement;N(ve),U(1),B({x:0,y:0}),o==="stream"&&!x&&(W.current&&(W.current.src=""),setTimeout(()=>{m(!0),y(Date.now())},200))};return document.addEventListener("fullscreenchange",be),()=>document.removeEventListener("fullscreenchange",be)},[o,x]),_.useEffect(()=>{let be;const ve=()=>{clearTimeout(be),be=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",ve),()=>{clearTimeout(be),window.removeEventListener("resize",ve)}},[]),_.useEffect(()=>()=>{ne.current&&clearTimeout(ne.current),xe.current&&clearInterval(xe.current),ue.current&&clearInterval(ue.current)},[]);const ce=_.useCallback(()=>{if(T>=dj){k(!1),h(!0);return}const be=Math.min(GXe*Math.pow(2,T),qXe);k(!0),C(Math.ceil(be/1e3)),xe.current=setInterval(()=>{C(ve=>ve<=1?(xe.current&&clearInterval(xe.current),0):ve-1)},1e3),ne.current=setTimeout(()=>{M(ve=>ve+1),k(!1),m(!0),h(!1),W.current&&(W.current.src=""),y(Date.now())},be)},[T]);_.useEffect(()=>{if(o!=="stream"||p||A||x){ue.current&&(clearInterval(ue.current),ue.current=null);return}return ue.current=setInterval(async()=>{try{const be=await ae.getCameraStatus(s);(be.stalled||!be.active&&!d)&&(console.log(`Stream issue detected: stalled=${be.stalled}, active=${be.active}, reconnecting...`),ue.current&&(clearInterval(ue.current),ue.current=null),m(!1),ce())}catch{}},WXe),()=>{ue.current&&(clearInterval(ue.current),ue.current=null)}},[o,p,d,A,x,s,ce]);const Ve=()=>{m(!1),o==="stream"&&T<dj?ce():h(!0)},V=()=>{if(m(!1),h(!1),M(0),k(!1),ne.current&&clearTimeout(ne.current),xe.current&&clearInterval(xe.current),W.current&&!localStorage.getItem("cameraWindowState")){const be=W.current,ve=be.naturalWidth,ze=be.naturalHeight;if(ve>0&&ze>0){const _e=window.outerWidth-window.innerWidth,Je=window.outerHeight-window.innerHeight,Ae=ve+16+_e,Ke=ze+45+16+Je;try{window.resizeTo(Ae,Ke)}catch{}}}},Y=()=>{if(s>0){const be={},ve=Ph();ve&&(be.Authorization=`Bearer ${ve}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:be}).catch(()=>{})}},de=be=>{o===be||x||(v(!0),m(!0),h(!1),M(0),k(!1),U(1),B({x:0,y:0}),ne.current&&clearTimeout(ne.current),xe.current&&clearInterval(xe.current),W.current&&(W.current.src=""),o==="stream"&&Y(),setTimeout(()=>{l(be),y(Date.now()),v(!1)},100))},q=()=>{x||(v(!0),m(!0),h(!1),M(0),k(!1),ne.current&&clearTimeout(ne.current),xe.current&&clearInterval(xe.current),W.current&&(W.current.src=""),o==="stream"&&Y(),setTimeout(()=>{y(Date.now()),v(!1)},100))},re=()=>{J.current&&(document.fullscreenElement?document.exitFullscreen():J.current.requestFullscreen())},X=()=>{U(be=>Math.min(be+.5,4))},le=()=>{U(be=>{const ve=Math.max(be-.5,1);return ve===1&&B({x:0,y:0}),ve})},pe=be=>{be.preventDefault(),be.deltaY<0?X():le()},ee=be=>{P>1&&(be.preventDefault(),$(!0),I({x:be.clientX-F.x,y:be.clientY-F.y}))},z=_.useCallback(()=>{if(!J.current)return{x:300,y:200};const be=J.current.getBoundingClientRect(),ve=be.width*(P-1)/2,ze=be.height*(P-1)/2;return{x:Math.max(50,ve),y:Math.max(50,ze)}},[P]),O=be=>{if(D&&P>1){const ve=be.clientX-G.x,ze=be.clientY-G.y,Ce=z();B({x:Math.max(-Ce.x,Math.min(Ce.x,ve)),y:Math.max(-Ce.y,Math.min(Ce.y,ze))})}},Z=()=>{$(!1)},me=be=>{if(be.length<2)return 0;const ve=be[0].clientX-be[1].clientX,ze=be[0].clientY-be[1].clientY;return Math.sqrt(ve*ve+ze*ze)},Te=be=>be.length<2?{x:be[0].clientX,y:be[0].clientY}:{x:(be[0].clientX+be[1].clientX)/2,y:(be[0].clientY+be[1].clientY)/2},ke=be=>{be.touches.length===2?(be.preventDefault(),Q(me(be.touches)),H(Te(be.touches))):be.touches.length===1&&P>1&&(be.preventDefault(),$(!0),I({x:be.touches[0].clientX-F.x,y:be.touches[0].clientY-F.y}))},Ee=be=>{if(be.touches.length===2&&K!==null){be.preventDefault();const ve=me(be.touches),ze=ve/K;U(Ge=>{const _e=Math.max(1,Math.min(4,Ge*ze));return _e===1&&B({x:0,y:0}),_e}),Q(ve);const Ce=Te(be.touches);if(se){const Ge=z();B(_e=>({x:Math.max(-Ge.x,Math.min(Ge.x,_e.x+(Ce.x-se.x))),y:Math.max(-Ge.y,Math.min(Ge.y,_e.y+(Ce.y-se.y)))}))}H(Ce)}else if(be.touches.length===1&&D&&P>1){be.preventDefault();const ve=be.touches[0].clientX-G.x,ze=be.touches[0].clientY-G.y,Ce=z();B({x:Math.max(-Ce.x,Math.min(Ce.x,ve)),y:Math.max(-Ce.y,Math.min(Ce.y,ze))})}},Se=be=>{be.touches.length<2&&(Q(null),H(null)),be.touches.length===0&&$(!1)},$e=()=>{U(1),B({x:0,y:0})},Qe=x?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${b}`:`/api/v1/printers/${s}/camera/snapshot?t=${b}`,Ue=p||x||A;return s?a.jsxs("div",{ref:J,className:"min-h-screen bg-black flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[a.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(Wg,{className:"w-4 h-4"}),fe?.name||`Printer ${s}`]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[a.jsx("button",{onClick:()=>de("stream"),disabled:Ue,className:`px-3 py-1 text-xs rounded transition-colors ${o==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),a.jsx("button",{onClick:()=>de("snapshot"),disabled:Ue,className:`px-3 py-1 text-xs rounded transition-colors ${o==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),a.jsx("button",{onClick:()=>oe.mutate(!De?.chamber_light),disabled:!De?.connected||oe.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${De?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30":"hover:bg-bambu-dark-tertiary"}`,title:r("printers:control")?t("camera.chamberLight"):t("printers.permission.noControl"),children:a.jsx(PO,{on:De?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>u(!0),disabled:!Ne||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${Ne&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(Ne?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:a.jsx(Gk,{className:"w-4 h-4 text-bambu-gray"})}),a.jsx("button",{onClick:q,disabled:Ue,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:a.jsx(Ir,{className:`w-4 h-4 text-bambu-gray ${Ue?"animate-spin":""}`})}),a.jsx("button",{onClick:re,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(S?"camera.exitFullscreen":"camera.fullscreen"),children:S?a.jsx(HW,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(nhe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:pe,onMouseMove:O,onMouseUp:Z,onMouseLeave:Z,onTouchStart:ke,onTouchMove:Ee,onTouchEnd:Se,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(p||x)&&!A&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(Ir,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t(o==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),A&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(bm,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:R,attempt:T+1,max:dj})}),a.jsx("button",{onClick:q,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),d&&!A&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(En,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),a.jsx("button",{onClick:q,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),a.jsx("img",{ref:W,src:Qe,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${P}) translate(${F.x/P}px, ${F.y/P}px)`,cursor:P>1?D?"grabbing":"grab":"default"},onError:Qe?Ve:void 0,onLoad:Qe?V:void 0,onMouseDown:ee,draggable:!1},b),a.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[a.jsx("button",{onClick:le,disabled:P<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:a.jsx(tO,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:$e,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(P*100),"%"]}),a.jsx("button",{onClick:X,disabled:P>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:a.jsx(eO,{className:"w-4 h-4 text-white"})})]})]})}),a.jsx(jO,{printerId:s,isOpen:c,onClose:()=>u(!1)})]}):a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function XXe(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=t.get("camera"),s=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function YXe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function QXe(t,e){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const s=new Date(r);s.setHours(0,0,0,0);const o=r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return s.getTime()===i.getTime()?o:s.getTime()===i.getTime()+864e5?`${e("streamOverlay.tomorrow")} ${o}`:r.toLocaleDateString([],{weekday:"short"})+" "+o}function ZXe(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 JXe(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 eYe(){const{printerId:t}=xk(),[e]=zR(),{t:n}=Yt(),r=nn(),i=parseInt(t||"0",10),[s,o]=_.useState(Date.now()),l=_.useMemo(()=>XXe(e),[e]),c=JXe(l.size),{data:u}=nt({queryKey:["printer",i],queryFn:()=>ae.getPrinter(i),enabled:i>0}),{data:d}=nt({queryKey:["printerStatus",i],queryFn:()=>ae.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3});_.useEffect(()=>{if(!i)return;const x=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,v=new WebSocket(x);return v.onmessage=S=>{try{const N=JSON.parse(S.data);N.type==="printer_status"&&N.printer_id===i&&r.setQueryData(["printerStatus",i],N.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 h=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const p=d.state==="RUNNING"||d.state==="PAUSE",m=d.progress||0,b=`/api/v1/printers/${i}/camera/stream?fps=${l.fps}&t=${s}`;return a.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&a.jsx("img",{src:b,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:h},s),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:a.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:a.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&a.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[a.jsx(Dr,{className:`${c.icon} text-white/70`}),a.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&a.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&&a.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:ZXe(d,n)}),l.showProgress&&p&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[a.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),a.jsxs("span",{className:"text-white font-bold",children:[Math.round(m),"%"]})]}),a.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:a.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${m}%`}})})]}),p&&(l.showLayers||l.showEta)&&a.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&&a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(is,{className:c.icon}),a.jsxs("span",{className:c.text,children:[a.jsx("span",{className:"text-white",children:d.layer_num}),a.jsx("span",{className:"mx-1",children:"/"}),a.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Nu,{className:c.icon}),a.jsx("span",{className:`${c.text} text-white`,children:YXe(d.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(er,{className:c.icon}),a.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",QXe(d.remaining_time,n)]})]})]})]}),!p&&a.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function tYe(){const{t}=Yt(),{id:e}=xk(),{mode:n}=Fm(),{data:r,isLoading:i,error:s}=nt({queryKey:["external-link",e],queryFn:()=>ae.getExternalLink(Number(e)),enabled:!!e});return i?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s||!r?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[a.jsx(En,{className:"w-12 h-12"}),a.jsx("p",{children:t("common.linkNotFound")})]}):a.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 U9=["DEBUG","INFO","WARNING","ERROR"],hj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},nYe={DEBUG:vk,INFO:yo,WARNING:En,ERROR:Ti};function rYe(){const t=nn(),[e,n]=_.useState(!0),[r,i]=_.useState(new Set),[s,o]=_.useState(""),[l,c]=_.useState("ALL"),[u,d]=_.useState(!1),[h,p]=_.useState(!1),m=_.useRef(null),{data:b,isLoading:y,refetch:x}=nt({queryKey:["application-logs",l,s],queryFn:()=>jg.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:h?2e3:!1,enabled:u});_.useEffect(()=>{u||p(!1)},[u]);const v=dt({mutationFn:()=>jg.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});_.useEffect(()=>{e&&m.current&&b?.entries&&(m.current.scrollTop=m.current.scrollHeight)},[b?.entries,e]);const S=k=>{i(R=>{const C=new Set(R);return C.has(k)?C.delete(k):C.add(k),C})},N=k=>{const R=k.split(" ");return R.length>=2?R[1]:k},T=_.useMemo(()=>b?.entries??[],[b?.entries]),M=_.useMemo(()=>[...T].reverse(),[T]),A=({level:k})=>{const R=nYe[k]||yo;return a.jsx(R,{className:`w-3.5 h-3.5 ${hj[k]||"text-gray-400"}`})};return a.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${h?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(vk,{className:"w-5 h-5"})}),a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:h?`Live streaming - ${b?.filtered_count??0} entries`:"View and filter application logs"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&a.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?a.jsx(Hu,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(hr,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h?a.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:[a.jsx(ul,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:k=>{k.stopPropagation(),p(!0),x()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[a.jsx(To,{className:"w-4 h-4"}),"Start"]}),a.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:[a.jsx(hn,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>x(),disabled:y,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:a.jsx(Ir,{className:`w-4 h-4 ${y?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:k=>n(k.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[b?.filtered_count??0,"/",b?.total_in_file??0]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Zi,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:s,onChange: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"}),s&&a.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Lt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),U9.map((k,R)=>a.jsx("button",{onClick:()=>c(k),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${R===U9.length-1?"rounded-r":""} ${l===k?`${hj[k]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:k},k))]})]})]}),a.jsx("div",{ref:m,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:T.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No log entries found"}),a.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:M.map((k,R)=>{const C=r.has(R),P=k.message.includes(`
- `);return a.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${C?"bg-bambu-dark-secondary/30":""}`,onClick:()=>P&&S(R),children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:N(k.timestamp)}),a.jsx("span",{className:"shrink-0",children:a.jsx(A,{level:k.level})}),a.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:k.logger_name,children:["[",k.logger_name,"]"]}),a.jsx("span",{className:`flex-1 ${hj[k.level]||"text-white/80"} ${!C&&P?"truncate":""}`,children:C?a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:k.message}):k.message.split(`
- `)[0]}),P&&a.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:C?a.jsx(Hu,{className:"w-3.5 h-3.5"}):a.jsx(hr,{className:"w-3.5 h-3.5"})})]})},R)})})}),a.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:h?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):a.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function iYe(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 gi({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return a.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function B9({percent:t,color:e="bg-bambu-green"}){return a.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function Wd({title:t,icon:e,children:n}){return a.jsxs(_t,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(e,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function aYe(){const{t}=Yt(),e=nn(),[n,r]=_.useState(null),[i,s]=_.useState(!1),[o,l]=_.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:h}=nt({queryKey:["systemInfo"],queryFn:ae.getSystemInfo,refetchInterval:3e4}),{data:p}=nt({queryKey:["debugLogging"],queryFn:jg.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:m}=nt({queryKey:["settings"],queryFn:ae.getSettings}),{data:b}=nt({queryKey:["library-stats"],queryFn:ae.getLibraryStats}),y=m?.time_format||"system",x=async()=>{l(!0);try{const T=await jg.setDebugLogging(!p?.enabled);e.setQueryData(["debugLogging"],T)}catch(T){console.error("Failed to toggle debug logging:",T)}finally{l(!1)}},v=async()=>{r(null),s(!0);try{await jg.downloadSupportBundle()}catch(T){r(T instanceof Error?T.message:"Failed to download support bundle")}finally{s(!1)}};if(u)return a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return a.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const S=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",N=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return a.jsxs("div",{className:"p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),a.jsxs("button",{onClick:()=>d(),disabled:h,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[a.jsx(Ir,{className:`w-4 h-4 ${h?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),a.jsx(Wd,{title:t("system.application","Application"),icon:Af,children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(gi,{icon:Af,label:t("system.version","Version"),value:`v${c.app.version}`}),a.jsx(gi,{icon:er,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),a.jsx(gi,{icon:Af,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),a.jsx(Wd,{title:t("support.title","Support & Troubleshooting"),icon:Mde,children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${p?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(vk,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[p?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),p?.enabled&&p.duration_seconds!==null&&a.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(p.duration_seconds/60),"m ",p.duration_seconds%60,"s)"]})]})]})]}),a.jsxs("button",{onClick:x,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&&a.jsx(lt,{className:"w-4 h-4 animate-spin"}),p?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:a.jsx(_i,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),a.jsxs("button",{onClick:v,disabled:i||!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&&a.jsx(lt,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!p?.enabled&&a.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:a.jsxs("p",{className:"text-sm text-bambu-gray",children:[a.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),a.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),a.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),a.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),a.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),a.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),a.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),a.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),a.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]}),a.jsxs("li",{children:["• ",t("support.collectItem7","Printer connectivity and firmware versions")]}),a.jsxs("li",{children:["• ",t("support.collectItem8","Integration status (Spoolman, MQTT, HA)")]}),a.jsxs("li",{children:["• ",t("support.collectItem9","Network interfaces (subnets only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem10","Python package versions")]}),a.jsxs("li",{children:["• ",t("support.collectItem11","Database health checks")]}),a.jsxs("li",{children:["• ",t("support.collectItem12","Docker environment details")]})]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),a.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),a.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),a.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),a.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),a.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","IP addresses in logs are replaced with [IP] and email addresses with [EMAIL].")})]}),a.jsx(rYe,{})]})}),a.jsxs(Wd,{title:t("system.database","Database"),icon:ju,children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[a.jsx(gi,{icon:wo,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),a.jsx(gi,{icon:Kg,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),a.jsx(gi,{icon:Ji,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),a.jsx(gi,{icon:lt,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(gi,{icon:Dr,label:t("system.printers","Printers"),value:c.database.printers}),a.jsx(gi,{icon:$W,label:t("system.filaments","Filaments"),value:c.database.filaments}),a.jsx(gi,{icon:rs,label:t("system.projects","Projects"),value:c.database.projects}),a.jsx(gi,{icon:sl,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[a.jsx(gi,{icon:er,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),a.jsx(gi,{icon:wo,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),a.jsxs(Wd,{title:t("system.connectedPrinters","Connected Printers"),icon:Dr,children:[a.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[a.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),a.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?a.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(T=>a.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),a.jsx("span",{className:"font-medium text-white",children:T.name})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[a.jsx("span",{children:T.model}),a.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))}):a.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),a.jsx(Wd,{title:t("system.storage","Storage"),icon:Eb,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),a.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),a.jsx(B9,{percent:c.storage.disk_percent_used,color:S}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(gi,{icon:wo,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),a.jsx(gi,{icon:ju,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),b&&a.jsx(gi,{icon:Hl,label:t("system.fileManagerStorage","File Manager"),value:iYe(b.total_size_bytes),subValue:`${b.total_files} files, ${b.total_folders} folders`})]})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.jsx(Wd,{title:t("system.memory","Memory"),icon:ihe,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),a.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),a.jsx(B9,{percent:c.memory.percent_used,color:N}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),a.jsx(Wd,{title:t("system.cpu","CPU"),icon:qw,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(gi,{icon:qw,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),a.jsx(gi,{icon:qw,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),a.jsx(Wd,{title:t("system.systemDetails","System Details"),icon:Af,children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(gi,{icon:Af,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),a.jsx(gi,{icon:qw,label:t("system.architecture","Architecture"),value:c.system.architecture}),a.jsx(gi,{icon:Af,label:t("system.python","Python"),value:c.system.python_version}),a.jsx(gi,{icon:er,label:t("system.bootTime","Boot Time"),value:Yg(c.system.boot_time,y)})]})})]})}function sYe(){const t=Pc(),{t:e}=Yt(),{login:n}=Rr(),{showToast:r}=kn(),{mode:i}=Fm(),[s,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(!1),[h,p]=_.useState(""),{data:m}=nt({queryKey:["advancedAuthStatus"],queryFn:()=>ae.getAdvancedAuthStatus()}),b=dt({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:S=>{r(S.message||e("login.loginFailed"),"error")}}),y=dt({mutationFn:S=>ae.forgotPassword({email:S}),onSuccess:S=>{r(S.message,"success"),d(!1),p("")},onError:S=>{r(S.message,"error")}}),x=S=>{if(S.preventDefault(),!s||!l){r(e("login.enterCredentials"),"error");return}b.mutate()},v=S=>{if(S.preventDefault(),!h){r("Please enter your email address","error");return}y.mutate(h)};return a.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:i==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:e("login.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:x,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:m?.advanced_auth_enabled?e("login.usernameOrEmail")||"Username or Email":e("login.username")}),a.jsx("input",{id:"username",type:"text",required:!0,value:s,onChange:S=>o(S.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:m?.advanced_auth_enabled?e("login.usernameOrEmailPlaceholder")||"Enter your username or email":e("login.usernamePlaceholder"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),a.jsx("input",{id:"password",type:"password",required:!0,value:l,onChange:S=>c(S.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"})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:b.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:b.isPending?e("login.signingIn"):e("login.signIn")})}),m?.advanced_auth_enabled&&a.jsx("div",{className:"text-center",children:a.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),u&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:a.jsxs(_t,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:[a.jsx(Cn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Z0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),a.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{d(!1),p("")},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsx(Mt,{children:m?.advanced_auth_enabled?a.jsxs("form",{onSubmit:v,className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray text-sm",children:e("login.forgotPasswordEmailMessage")||"Enter your email address and we'll send you a new password."}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"forgot-email",className:"block text-sm font-medium text-white mb-2",children:e("login.emailAddress")||"Email Address"}),a.jsx("input",{id:"forgot-email",type:"email",required:!0,value:h,onChange:S=>p(S.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.emailPlaceholder")||"your.email@example.com"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Me,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{d(!1),p("")},children:e("login.cancel")||"Cancel"}),a.jsx(Me,{type:"submit",className:"flex-1",disabled:y.isPending,children:y.isPending?e("login.sending")||"Sending...":e("login.sendResetEmail")||"Send Reset Email"})]})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[a.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),a.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[a.jsx("li",{children:e("login.resetStep1")}),a.jsx("li",{children:e("login.resetStep2")}),a.jsx("li",{children:e("login.resetStep3")}),a.jsx("li",{children:e("login.resetStep4")})]})]}),a.jsx(Me,{variant:"secondary",className:"w-full",onClick:()=>d(!1),children:e("login.gotIt")})]})})]})})]})}function oYe(){const t=Pc(),{t:e}=Yt(),{showToast:n}=kn(),{mode:r}=Fm(),{refreshAuth:i}=Rr(),[s,o]=_.useState(!1),[l,c]=_.useState(""),[u,d]=_.useState(""),[h,p]=_.useState(""),m=dt({mutationFn:()=>ae.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?u:void 0}),onSuccess:async y=>{await i(),y.auth_enabled?y.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:y=>{n(y.message,"error")}}),b=y=>{if(y.preventDefault(),s&&(l||u)){if(!l||!u){n(e("setup.toast.enterBothCredentials"),"error");return}if(u!==h){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(u.length<6){n(e("setup.toast.passwordTooShort"),"error");return}}m.mutate()};return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:e("setup.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:b,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("input",{id:"auth-enabled",type:"checkbox",checked:s,onChange:y=>o(y.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),a.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:e("setup.enableAuth")})]}),s&&a.jsxs("div",{className:"space-y-4 mt-4",children:[a.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(yo,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:e("setup.adminAccount")}),a.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-username",type:"text",value:l,onChange:y=>c(y.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"})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-password",type:"password",value:u,onChange:y=>d(y.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&&a.jsxs("div",{children:[a.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),a.jsx("input",{id:"confirm-password",type:"password",value:h,onChange:y=>p(y.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"})]})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:m.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:m.isPending?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function lYe(){const t=_.useRef(null),e=_.useRef(null),n=nn(),[r,i]=_.useState(!1),s=_.useRef(new Set),o=_.useRef(null),l=_.useRef(new Map),c=_.useRef(null),u=_.useRef([]),d=_.useRef(!1),h=_.useRef(()=>{}),p=_.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const N=u.current.shift();N?requestAnimationFrame(()=>{h.current(N),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),m=_.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(N);let M=null;T.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),M=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=A=>{try{const k=JSON.parse(A.data);k.type==="printer_status"&&k.printer_id!==void 0&&k.data?h.current(k):(u.current.push(k),p())}catch{}},T.onclose=A=>{console.log("[WebSocket] Closed",A.code,A.reason),M&&(clearInterval(M),M=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{m()},3e3)},T.onerror=A=>{console.error("[WebSocket] Error",A),T.close()},t.current=T},[p]),b=_.useCallback((S,N)=>{const T=l.current.get(S)||{};l.current.set(S,{...T,...N}),c.current||(c.current=window.setTimeout(()=>{const M=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{M.forEach((A,k)=>{n.setQueryData(["printerStatus",k],R=>{const C={...R,...A};return C.wifi_signal==null&&R?.wifi_signal!=null&&(C.wifi_signal=R.wifi_signal),C})})})},100))},[n]),y=_.useCallback(S=>{s.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const N=Array.from(s.current);s.current.clear(),o.current=null;let T=0;N.forEach(M=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[M]})})},T),T+=500})},3e3)},[n]),x=_.useCallback(S=>{switch(S.type){case"printer_status":S.printer_id!==void 0&&S.data&&b(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":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("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,y,b]);_.useEffect(()=>{h.current=x},[x]),_.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 cYe=new bce({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function uYe({children:t}){return lYe(),a.jsx(a.Fragment,{children:t})}function dYe({children:t}){const{authEnabled:e,loading:n,user:r}=Rr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?a.jsx(Gg,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function hYe({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=Rr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?i?a.jsx(a.Fragment,{children:t}):a.jsx(Gg,{to:"/",replace:!0}):a.jsx(Gg,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function fYe({children:t}){const{authEnabled:e,loading:n}=Rr();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?a.jsx(Gg,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function mYe(){return a.jsx($fe,{children:a.jsx(Qfe,{children:a.jsx(xce,{client:cYe,children:a.jsx(Kfe,{children:a.jsx(Ile,{children:a.jsxs(fle,{children:[a.jsx(Fi,{path:"/setup",element:a.jsx(fYe,{children:a.jsx(oYe,{})})}),a.jsx(Fi,{path:"/login",element:a.jsx(sYe,{})}),a.jsx(Fi,{path:"/camera/:printerId",element:a.jsx(KXe,{})}),a.jsx(Fi,{path:"/overlay/:printerId",element:a.jsx(eYe,{})}),a.jsxs(Fi,{element:a.jsx(dYe,{children:a.jsx(uYe,{children:a.jsx(tme,{})})}),children:[a.jsx(Fi,{index:!0,element:a.jsx(F8e,{})}),a.jsx(Fi,{path:"archives",element:a.jsx(L9e,{})}),a.jsx(Fi,{path:"queue",element:a.jsx(wKe,{})}),a.jsx(Fi,{path:"stats",element:a.jsx(FKe,{})}),a.jsx(Fi,{path:"profiles",element:a.jsx(_Xe,{})}),a.jsx(Fi,{path:"maintenance",element:a.jsx(EXe,{})}),a.jsx(Fi,{path:"projects",element:a.jsx(AXe,{})}),a.jsx(Fi,{path:"projects/:id",element:a.jsx(LXe,{})}),a.jsx(Fi,{path:"files",element:a.jsx(VXe,{})}),a.jsx(Fi,{path:"settings",element:a.jsx(hYe,{children:a.jsx(oXe,{})})}),a.jsx(Fi,{path:"users",element:a.jsx(Gg,{to:"/settings?tab=users",replace:!0})}),a.jsx(Fi,{path:"groups",element:a.jsx(Gg,{to:"/settings?tab=users",replace:!0})}),a.jsx(Fi,{path:"system",element:a.jsx(aYe,{})}),a.jsx(Fi,{path:"external/:id",element:a.jsx(tYe,{})})]})]})})})})})})}cse.createRoot(document.getElementById("root")).render(a.jsx(_.StrictMode,{children:a.jsx(mYe,{})}));
|