index-ug6uJJTK.js 4.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698
  1. function Cle(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 sS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ml(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var F2={exports:{}},iy={};var JU;function Ale(){if(JU)return iy;JU=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 iy.Fragment=e,iy.jsx=n,iy.jsxs=n,iy}var eB;function Tle(){return eB||(eB=1,F2.exports=Ale()),F2.exports}var a=Tle(),L2={exports:{}},jn={};var tB;function Mle(){if(tB)return jn;tB=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"),f=Symbol.iterator;function p(Z){return Z===null||typeof Z!="object"?null:(Z=f&&Z[f]||Z["@@iterator"],typeof Z=="function"?Z:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,g={};function y(Z,ue,pe){this.props=Z,this.context=ue,this.refs=g,this.updater=pe||x}y.prototype.isReactComponent={},y.prototype.setState=function(Z,ue){if(typeof Z!="object"&&typeof Z!="function"&&Z!=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,Z,ue,"setState")},y.prototype.forceUpdate=function(Z){this.updater.enqueueForceUpdate(this,Z,"forceUpdate")};function _(){}_.prototype=y.prototype;function N(Z,ue,pe){this.props=Z,this.context=ue,this.refs=g,this.updater=pe||x}var A=N.prototype=new _;A.constructor=N,v(A,y.prototype),A.isPureReactComponent=!0;var C=Array.isArray;function j(){}var k={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function M(Z,ue,pe){var be=pe.ref;return{$$typeof:t,type:Z,key:ue,ref:be!==void 0?be:null,props:pe}}function D(Z,ue){return M(Z.type,ue,Z.props)}function G(Z){return typeof Z=="object"&&Z!==null&&Z.$$typeof===t}function U(Z){var ue={"=":"=0",":":"=2"};return"$"+Z.replace(/[=:]/g,function(pe){return ue[pe]})}var W=/\/+/g;function L(Z,ue){return typeof Z=="object"&&Z!==null&&Z.key!=null?U(""+Z.key):ue.toString(36)}function ee(Z){switch(Z.status){case"fulfilled":return Z.value;case"rejected":throw Z.reason;default:switch(typeof Z.status=="string"?Z.then(j,j):(Z.status="pending",Z.then(function(ue){Z.status==="pending"&&(Z.status="fulfilled",Z.value=ue)},function(ue){Z.status==="pending"&&(Z.status="rejected",Z.reason=ue)})),Z.status){case"fulfilled":return Z.value;case"rejected":throw Z.reason}}throw Z}function ae(Z,ue,pe,be,Ee){var $=typeof Z;($==="undefined"||$==="boolean")&&(Z=null);var K=!1;if(Z===null)K=!0;else switch($){case"bigint":case"string":case"number":K=!0;break;case"object":switch(Z.$$typeof){case t:case e:K=!0;break;case d:return K=Z._init,ae(K(Z._payload),ue,pe,be,Ee)}}if(K)return Ee=Ee(Z),K=be===""?"."+L(Z,0):be,C(Ee)?(pe="",K!=null&&(pe=K.replace(W,"$&/")+"/"),ae(Ee,ue,pe,"",function(O){return O})):Ee!=null&&(G(Ee)&&(Ee=D(Ee,pe+(Ee.key==null||Z&&Z.key===Ee.key?"":(""+Ee.key).replace(W,"$&/")+"/")+K)),ue.push(Ee)),1;K=0;var T=be===""?".":be+":";if(C(Z))for(var E=0;E<Z.length;E++)be=Z[E],$=T+L(be,E),K+=ae(be,ue,pe,$,Ee);else if(E=p(Z),typeof E=="function")for(Z=E.call(Z),E=0;!(be=Z.next()).done;)be=be.value,$=T+L(be,E++),K+=ae(be,ue,pe,$,Ee);else if($==="object"){if(typeof Z.then=="function")return ae(ee(Z),ue,pe,be,Ee);throw ue=String(Z),Error("Objects are not valid as a React child (found: "+(ue==="[object Object]"?"object with keys {"+Object.keys(Z).join(", ")+"}":ue)+"). If you meant to render a collection of children, use an array instead.")}return K}function Y(Z,ue,pe){if(Z==null)return Z;var be=[],Ee=0;return ae(Z,be,"","",function($){return ue.call(pe,$,Ee++)}),be}function se(Z){if(Z._status===-1){var ue=Z._result;ue=ue(),ue.then(function(pe){(Z._status===0||Z._status===-1)&&(Z._status=1,Z._result=pe)},function(pe){(Z._status===0||Z._status===-1)&&(Z._status=2,Z._result=pe)}),Z._status===-1&&(Z._status=0,Z._result=ue)}if(Z._status===1)return Z._result.default;throw Z._result}var ce=typeof reportError=="function"?reportError:function(Z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var ue=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof Z=="object"&&Z!==null&&typeof Z.message=="string"?String(Z.message):String(Z),error:Z});if(!window.dispatchEvent(ue))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",Z);return}console.error(Z)},ye={map:Y,forEach:function(Z,ue,pe){Y(Z,function(){ue.apply(this,arguments)},pe)},count:function(Z){var ue=0;return Y(Z,function(){ue++}),ue},toArray:function(Z){return Y(Z,function(ue){return ue})||[]},only:function(Z){if(!G(Z))throw Error("React.Children.only expected to receive a single React element child.");return Z}};return jn.Activity=h,jn.Children=ye,jn.Component=y,jn.Fragment=n,jn.Profiler=i,jn.PureComponent=N,jn.StrictMode=r,jn.Suspense=c,jn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,jn.__COMPILER_RUNTIME={__proto__:null,c:function(Z){return k.H.useMemoCache(Z)}},jn.cache=function(Z){return function(){return Z.apply(null,arguments)}},jn.cacheSignal=function(){return null},jn.cloneElement=function(Z,ue,pe){if(Z==null)throw Error("The argument must be a React element, but you passed "+Z+".");var be=v({},Z.props),Ee=Z.key;if(ue!=null)for($ in ue.key!==void 0&&(Ee=""+ue.key),ue)!R.call(ue,$)||$==="key"||$==="__self"||$==="__source"||$==="ref"&&ue.ref===void 0||(be[$]=ue[$]);var $=arguments.length-2;if($===1)be.children=pe;else if(1<$){for(var K=Array($),T=0;T<$;T++)K[T]=arguments[T+2];be.children=K}return M(Z.type,Ee,be)},jn.createContext=function(Z){return Z={$$typeof:o,_currentValue:Z,_currentValue2:Z,_threadCount:0,Provider:null,Consumer:null},Z.Provider=Z,Z.Consumer={$$typeof:s,_context:Z},Z},jn.createElement=function(Z,ue,pe){var be,Ee={},$=null;if(ue!=null)for(be in ue.key!==void 0&&($=""+ue.key),ue)R.call(ue,be)&&be!=="key"&&be!=="__self"&&be!=="__source"&&(Ee[be]=ue[be]);var K=arguments.length-2;if(K===1)Ee.children=pe;else if(1<K){for(var T=Array(K),E=0;E<K;E++)T[E]=arguments[E+2];Ee.children=T}if(Z&&Z.defaultProps)for(be in K=Z.defaultProps,K)Ee[be]===void 0&&(Ee[be]=K[be]);return M(Z,$,Ee)},jn.createRef=function(){return{current:null}},jn.forwardRef=function(Z){return{$$typeof:l,render:Z}},jn.isValidElement=G,jn.lazy=function(Z){return{$$typeof:d,_payload:{_status:-1,_result:Z},_init:se}},jn.memo=function(Z,ue){return{$$typeof:u,type:Z,compare:ue===void 0?null:ue}},jn.startTransition=function(Z){var ue=k.T,pe={};k.T=pe;try{var be=Z(),Ee=k.S;Ee!==null&&Ee(pe,be),typeof be=="object"&&be!==null&&typeof be.then=="function"&&be.then(j,ce)}catch($){ce($)}finally{ue!==null&&pe.types!==null&&(ue.types=pe.types),k.T=ue}},jn.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},jn.use=function(Z){return k.H.use(Z)},jn.useActionState=function(Z,ue,pe){return k.H.useActionState(Z,ue,pe)},jn.useCallback=function(Z,ue){return k.H.useCallback(Z,ue)},jn.useContext=function(Z){return k.H.useContext(Z)},jn.useDebugValue=function(){},jn.useDeferredValue=function(Z,ue){return k.H.useDeferredValue(Z,ue)},jn.useEffect=function(Z,ue){return k.H.useEffect(Z,ue)},jn.useEffectEvent=function(Z){return k.H.useEffectEvent(Z)},jn.useId=function(){return k.H.useId()},jn.useImperativeHandle=function(Z,ue,pe){return k.H.useImperativeHandle(Z,ue,pe)},jn.useInsertionEffect=function(Z,ue){return k.H.useInsertionEffect(Z,ue)},jn.useLayoutEffect=function(Z,ue){return k.H.useLayoutEffect(Z,ue)},jn.useMemo=function(Z,ue){return k.H.useMemo(Z,ue)},jn.useOptimistic=function(Z,ue){return k.H.useOptimistic(Z,ue)},jn.useReducer=function(Z,ue,pe){return k.H.useReducer(Z,ue,pe)},jn.useRef=function(Z){return k.H.useRef(Z)},jn.useState=function(Z){return k.H.useState(Z)},jn.useSyncExternalStore=function(Z,ue,pe){return k.H.useSyncExternalStore(Z,ue,pe)},jn.useTransition=function(){return k.H.useTransition()},jn.version="19.2.4",jn}var nB;function sp(){return nB||(nB=1,L2.exports=Mle()),L2.exports}var w=sp();const Kr=Ml(w),Ple=Cle({__proto__:null,default:Kr},[w]);var O2={exports:{}},sy={},I2={exports:{}},z2={};var rB;function jle(){return rB||(rB=1,(function(t){function e(ae,Y){var se=ae.length;ae.push(Y);e:for(;0<se;){var ce=se-1>>>1,ye=ae[ce];if(0<i(ye,Y))ae[ce]=Y,ae[se]=ye,se=ce;else break e}}function n(ae){return ae.length===0?null:ae[0]}function r(ae){if(ae.length===0)return null;var Y=ae[0],se=ae.pop();if(se!==Y){ae[0]=se;e:for(var ce=0,ye=ae.length,Z=ye>>>1;ce<Z;){var ue=2*(ce+1)-1,pe=ae[ue],be=ue+1,Ee=ae[be];if(0>i(pe,se))be<ye&&0>i(Ee,pe)?(ae[ce]=Ee,ae[be]=se,ce=be):(ae[ce]=pe,ae[ue]=se,ce=ue);else if(be<ye&&0>i(Ee,se))ae[ce]=Ee,ae[be]=se,ce=be;else break e}}return Y}function i(ae,Y){var se=ae.sortIndex-Y.sortIndex;return se!==0?se:ae.id-Y.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,f=3,p=!1,x=!1,v=!1,g=!1,y=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function A(ae){for(var Y=n(u);Y!==null;){if(Y.callback===null)r(u);else if(Y.startTime<=ae)r(u),Y.sortIndex=Y.expirationTime,e(c,Y);else break;Y=n(u)}}function C(ae){if(v=!1,A(ae),!x)if(n(c)!==null)x=!0,j||(j=!0,U());else{var Y=n(u);Y!==null&&ee(C,Y.startTime-ae)}}var j=!1,k=-1,R=5,M=-1;function D(){return g?!0:!(t.unstable_now()-M<R)}function G(){if(g=!1,j){var ae=t.unstable_now();M=ae;var Y=!0;try{e:{x=!1,v&&(v=!1,_(k),k=-1),p=!0;var se=f;try{t:{for(A(ae),h=n(c);h!==null&&!(h.expirationTime>ae&&D());){var ce=h.callback;if(typeof ce=="function"){h.callback=null,f=h.priorityLevel;var ye=ce(h.expirationTime<=ae);if(ae=t.unstable_now(),typeof ye=="function"){h.callback=ye,A(ae),Y=!0;break t}h===n(c)&&r(c),A(ae)}else r(c);h=n(c)}if(h!==null)Y=!0;else{var Z=n(u);Z!==null&&ee(C,Z.startTime-ae),Y=!1}}break e}finally{h=null,f=se,p=!1}Y=void 0}}finally{Y?U():j=!1}}}var U;if(typeof N=="function")U=function(){N(G)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,L=W.port2;W.port1.onmessage=G,U=function(){L.postMessage(null)}}else U=function(){y(G,0)};function ee(ae,Y){k=y(function(){ae(t.unstable_now())},Y)}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(ae){ae.callback=null},t.unstable_forceFrameRate=function(ae){0>ae||125<ae?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<ae?Math.floor(1e3/ae):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_next=function(ae){switch(f){case 1:case 2:case 3:var Y=3;break;default:Y=f}var se=f;f=Y;try{return ae()}finally{f=se}},t.unstable_requestPaint=function(){g=!0},t.unstable_runWithPriority=function(ae,Y){switch(ae){case 1:case 2:case 3:case 4:case 5:break;default:ae=3}var se=f;f=ae;try{return Y()}finally{f=se}},t.unstable_scheduleCallback=function(ae,Y,se){var ce=t.unstable_now();switch(typeof se=="object"&&se!==null?(se=se.delay,se=typeof se=="number"&&0<se?ce+se:ce):se=ce,ae){case 1:var ye=-1;break;case 2:ye=250;break;case 5:ye=1073741823;break;case 4:ye=1e4;break;default:ye=5e3}return ye=se+ye,ae={id:d++,callback:Y,priorityLevel:ae,startTime:se,expirationTime:ye,sortIndex:-1},se>ce?(ae.sortIndex=se,e(u,ae),n(c)===null&&ae===n(u)&&(v?(_(k),k=-1):v=!0,ee(C,se-ce))):(ae.sortIndex=ye,e(c,ae),x||p||(x=!0,j||(j=!0,U()))),ae},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(ae){var Y=f;return function(){var se=f;f=Y;try{return ae.apply(this,arguments)}finally{f=se}}}})(z2)),z2}var aB;function Ele(){return aB||(aB=1,I2.exports=jle()),I2.exports}var U2={exports:{}},ss={};var iB;function Dle(){if(iB)return ss;iB=1;var t=sp();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 ss.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ss.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)},ss.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()}},ss.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))},ss.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ss.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,h=l(d,u.crossOrigin),f=typeof u.integrity=="string"?u.integrity:void 0,p=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:h,integrity:f,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:h,integrity:f,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},ss.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)},ss.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})}},ss.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)},ss.requestFormReset=function(c){r.d.r(c)},ss.unstable_batchedUpdates=function(c,u){return c(u)},ss.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},ss.useFormStatus=function(){return o.H.useHostTransitionStatus()},ss.version="19.2.4",ss}var sB;function zK(){if(sB)return U2.exports;sB=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(),U2.exports=Dle(),U2.exports}var oB;function Rle(){if(oB)return sy;oB=1;var t=Ele(),e=sp(),n=zK();function r(m){var b="https://react.dev/errors/"+m;if(1<arguments.length){b+="?args[]="+encodeURIComponent(arguments[1]);for(var S=2;S<arguments.length;S++)b+="&args[]="+encodeURIComponent(arguments[S])}return"Minified React error #"+m+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(m){return!(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)}function s(m){var b=m,S=m;if(m.alternate)for(;b.return;)b=b.return;else{m=b;do b=m,(b.flags&4098)!==0&&(S=b.return),m=b.return;while(m)}return b.tag===3?S:null}function o(m){if(m.tag===13){var b=m.memoizedState;if(b===null&&(m=m.alternate,m!==null&&(b=m.memoizedState)),b!==null)return b.dehydrated}return null}function l(m){if(m.tag===31){var b=m.memoizedState;if(b===null&&(m=m.alternate,m!==null&&(b=m.memoizedState)),b!==null)return b.dehydrated}return null}function c(m){if(s(m)!==m)throw Error(r(188))}function u(m){var b=m.alternate;if(!b){if(b=s(m),b===null)throw Error(r(188));return b!==m?null:m}for(var S=m,P=b;;){var H=S.return;if(H===null)break;var X=H.alternate;if(X===null){if(P=H.return,P!==null){S=P;continue}break}if(H.child===X.child){for(X=H.child;X;){if(X===S)return c(H),m;if(X===P)return c(H),b;X=X.sibling}throw Error(r(188))}if(S.return!==P.return)S=H,P=X;else{for(var ve=!1,Ie=H.child;Ie;){if(Ie===S){ve=!0,S=H,P=X;break}if(Ie===P){ve=!0,P=H,S=X;break}Ie=Ie.sibling}if(!ve){for(Ie=X.child;Ie;){if(Ie===S){ve=!0,S=X,P=H;break}if(Ie===P){ve=!0,P=X,S=H;break}Ie=Ie.sibling}if(!ve)throw Error(r(189))}}if(S.alternate!==P)throw Error(r(190))}if(S.tag!==3)throw Error(r(188));return S.stateNode.current===S?m:b}function d(m){var b=m.tag;if(b===5||b===26||b===27||b===6)return m;for(m=m.child;m!==null;){if(b=d(m),b!==null)return b;m=m.sibling}return null}var h=Object.assign,f=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),N=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),G=Symbol.iterator;function U(m){return m===null||typeof m!="object"?null:(m=G&&m[G]||m["@@iterator"],typeof m=="function"?m:null)}var W=Symbol.for("react.client.reference");function L(m){if(m==null)return null;if(typeof m=="function")return m.$$typeof===W?null:m.displayName||m.name||null;if(typeof m=="string")return m;switch(m){case v:return"Fragment";case y:return"Profiler";case g:return"StrictMode";case C:return"Suspense";case j:return"SuspenseList";case M:return"Activity"}if(typeof m=="object")switch(m.$$typeof){case x:return"Portal";case N:return m.displayName||"Context";case _:return(m._context.displayName||"Context")+".Consumer";case A:var b=m.render;return m=m.displayName,m||(m=b.displayName||b.name||"",m=m!==""?"ForwardRef("+m+")":"ForwardRef"),m;case k:return b=m.displayName||null,b!==null?b:L(m.type)||"Memo";case R:b=m._payload,m=m._init;try{return L(m(b))}catch{}}return null}var ee=Array.isArray,ae=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ce=[],ye=-1;function Z(m){return{current:m}}function ue(m){0>ye||(m.current=ce[ye],ce[ye]=null,ye--)}function pe(m,b){ye++,ce[ye]=m.current,m.current=b}var be=Z(null),Ee=Z(null),$=Z(null),K=Z(null);function T(m,b){switch(pe($,b),pe(Ee,m),pe(be,null),b.nodeType){case 9:case 11:m=(m=b.documentElement)&&(m=m.namespaceURI)?SU(m):0;break;default:if(m=b.tagName,b=b.namespaceURI)b=SU(b),m=_U(b,m);else switch(m){case"svg":m=1;break;case"math":m=2;break;default:m=0}}ue(be),pe(be,m)}function E(){ue(be),ue(Ee),ue($)}function O(m){m.memoizedState!==null&&pe(K,m);var b=be.current,S=_U(b,m.type);b!==S&&(pe(Ee,m),pe(be,S))}function q(m){Ee.current===m&&(ue(be),ue(Ee)),K.current===m&&(ue(K),ty._currentValue=se)}var B,re;function z(m){if(B===void 0)try{throw Error()}catch(S){var b=S.stack.trim().match(/\n( *(at )?)/);B=b&&b[1]||"",re=-1<S.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<S.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+B+m+re}var V=!1;function te(m,b){if(!m||V)return"";V=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var P={DetermineComponentFrameRoot:function(){try{if(b){var Pt=function(){throw Error()};if(Object.defineProperty(Pt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pt,[])}catch(wt){var bt=wt}Reflect.construct(m,[],Pt)}else{try{Pt.call()}catch(wt){bt=wt}m.call(Pt.prototype)}}else{try{throw Error()}catch(wt){bt=wt}(Pt=m())&&typeof Pt.catch=="function"&&Pt.catch(function(){})}}catch(wt){if(wt&&bt&&typeof wt.stack=="string")return[wt.stack,bt.stack]}return[null,null]}};P.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var H=Object.getOwnPropertyDescriptor(P.DetermineComponentFrameRoot,"name");H&&H.configurable&&Object.defineProperty(P.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var X=P.DetermineComponentFrameRoot(),ve=X[0],Ie=X[1];if(ve&&Ie){var Xe=ve.split(`
  4. `),pt=Ie.split(`
  5. `);for(H=P=0;P<Xe.length&&!Xe[P].includes("DetermineComponentFrameRoot");)P++;for(;H<pt.length&&!pt[H].includes("DetermineComponentFrameRoot");)H++;if(P===Xe.length||H===pt.length)for(P=Xe.length-1,H=pt.length-1;1<=P&&0<=H&&Xe[P]!==pt[H];)H--;for(;1<=P&&0<=H;P--,H--)if(Xe[P]!==pt[H]){if(P!==1||H!==1)do if(P--,H--,0>H||Xe[P]!==pt[H]){var kt=`
  6. `+Xe[P].replace(" at new "," at ");return m.displayName&&kt.includes("<anonymous>")&&(kt=kt.replace("<anonymous>",m.displayName)),kt}while(1<=P&&0<=H);break}}}finally{V=!1,Error.prepareStackTrace=S}return(S=m?m.displayName||m.name:"")?z(S):""}function Q(m,b){switch(m.tag){case 26:case 27:case 5:return z(m.type);case 16:return z("Lazy");case 13:return m.child!==b&&b!==null?z("Suspense Fallback"):z("Suspense");case 19:return z("SuspenseList");case 0:case 15:return te(m.type,!1);case 11:return te(m.type.render,!1);case 1:return te(m.type,!0);case 31:return z("Activity");default:return""}}function ne(m){try{var b="",S=null;do b+=Q(m,S),S=m,m=m.return;while(m);return b}catch(P){return`
  7. Error generating stack: `+P.message+`
  8. `+P.stack}}var ie=Object.prototype.hasOwnProperty,me=t.unstable_scheduleCallback,fe=t.unstable_cancelCallback,oe=t.unstable_shouldYield,I=t.unstable_requestPaint,F=t.unstable_now,J=t.unstable_getCurrentPriorityLevel,xe=t.unstable_ImmediatePriority,he=t.unstable_UserBlockingPriority,le=t.unstable_NormalPriority,Ce=t.unstable_LowPriority,Ne=t.unstable_IdlePriority,Ue=t.log,He=t.unstable_setDisableYieldValue,de=null,we=null;function ke(m){if(typeof Ue=="function"&&He(m),we&&typeof we.setStrictMode=="function")try{we.setStrictMode(de,m)}catch{}}var _e=Math.clz32?Math.clz32:Te,Ae=Math.log,Ve=Math.LN2;function Te(m){return m>>>=0,m===0?32:31-(Ae(m)/Ve|0)|0}var Ke=256,je=262144,qe=4194304;function Re(m){var b=m&42;if(b!==0)return b;switch(m&-m){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 m&261888;case 262144:case 524288:case 1048576:case 2097152:return m&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return m&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return m}}function Pe(m,b,S){var P=m.pendingLanes;if(P===0)return 0;var H=0,X=m.suspendedLanes,ve=m.pingedLanes;m=m.warmLanes;var Ie=P&134217727;return Ie!==0?(P=Ie&~X,P!==0?H=Re(P):(ve&=Ie,ve!==0?H=Re(ve):S||(S=Ie&~m,S!==0&&(H=Re(S))))):(Ie=P&~X,Ie!==0?H=Re(Ie):ve!==0?H=Re(ve):S||(S=P&~m,S!==0&&(H=Re(S)))),H===0?0:b!==0&&b!==H&&(b&X)===0&&(X=H&-H,S=b&-b,X>=S||X===32&&(S&4194048)!==0)?b:H}function Be(m,b){return(m.pendingLanes&~(m.suspendedLanes&~m.pingedLanes)&b)===0}function We(m,b){switch(m){case 1:case 2:case 4:case 8:case 64:return b+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 b+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 ct(){var m=qe;return qe<<=1,(qe&62914560)===0&&(qe=4194304),m}function St(m){for(var b=[],S=0;31>S;S++)b.push(m);return b}function Mt(m,b){m.pendingLanes|=b,b!==268435456&&(m.suspendedLanes=0,m.pingedLanes=0,m.warmLanes=0)}function yt(m,b,S,P,H,X){var ve=m.pendingLanes;m.pendingLanes=S,m.suspendedLanes=0,m.pingedLanes=0,m.warmLanes=0,m.expiredLanes&=S,m.entangledLanes&=S,m.errorRecoveryDisabledLanes&=S,m.shellSuspendCounter=0;var Ie=m.entanglements,Xe=m.expirationTimes,pt=m.hiddenUpdates;for(S=ve&~S;0<S;){var kt=31-_e(S),Pt=1<<kt;Ie[kt]=0,Xe[kt]=-1;var bt=pt[kt];if(bt!==null)for(pt[kt]=null,kt=0;kt<bt.length;kt++){var wt=bt[kt];wt!==null&&(wt.lane&=-536870913)}S&=~Pt}P!==0&&$e(m,P,0),X!==0&&H===0&&m.tag!==0&&(m.suspendedLanes|=X&~(ve&~b))}function $e(m,b,S){m.pendingLanes|=b,m.suspendedLanes&=~b;var P=31-_e(b);m.entangledLanes|=b,m.entanglements[P]=m.entanglements[P]|1073741824|S&261930}function dt(m,b){var S=m.entangledLanes|=b;for(m=m.entanglements;S;){var P=31-_e(S),H=1<<P;H&b|m[P]&b&&(m[P]|=b),S&=~H}}function gt(m,b){var S=b&-b;return S=(S&42)!==0?1:Lt(S),(S&(m.suspendedLanes|b))!==0?0:S}function Lt(m){switch(m){case 2:m=1;break;case 8:m=4;break;case 32:m=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:m=128;break;case 268435456:m=134217728;break;default:m=0}return m}function en(m){return m&=-m,2<m?8<m?(m&134217727)!==0?32:268435456:8:2}function pn(){var m=Y.p;return m!==0?m:(m=window.event,m===void 0?32:GU(m.type))}function _n(m,b){var S=Y.p;try{return Y.p=m,b()}finally{Y.p=S}}var hn=Math.random().toString(36).slice(2),gn="__reactFiber$"+hn,On="__reactProps$"+hn,Dn="__reactContainer$"+hn,zn="__reactEvents$"+hn,ze="__reactListeners$"+hn,De="__reactHandles$"+hn,Ze="__reactResources$"+hn,st="__reactMarker$"+hn;function Ye(m){delete m[gn],delete m[On],delete m[zn],delete m[ze],delete m[De]}function It(m){var b=m[gn];if(b)return b;for(var S=m.parentNode;S;){if(b=S[Dn]||S[gn]){if(S=b.alternate,b.child!==null||S!==null&&S.child!==null)for(m=PU(m);m!==null;){if(S=m[gn])return S;m=PU(m)}return b}m=S,S=m.parentNode}return null}function Me(m){if(m=m[gn]||m[Dn]){var b=m.tag;if(b===5||b===6||b===13||b===31||b===26||b===27||b===3)return m}return null}function Ge(m){var b=m.tag;if(b===5||b===26||b===27||b===6)return m.stateNode;throw Error(r(33))}function et(m){var b=m[Ze];return b||(b=m[Ze]={hoistableStyles:new Map,hoistableScripts:new Map}),b}function Qe(m){m[st]=!0}var Le=new Set,ht={};function it(m,b){tt(m,b),tt(m+"Capture",b)}function tt(m,b){for(ht[m]=b,m=0;m<b.length;m++)Le.add(b[m])}var _t=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),jt={},Dt={};function Rt(m){return ie.call(Dt,m)?!0:ie.call(jt,m)?!1:_t.test(m)?Dt[m]=!0:(jt[m]=!0,!1)}function tn(m,b,S){if(Rt(b))if(S===null)m.removeAttribute(b);else{switch(typeof S){case"undefined":case"function":case"symbol":m.removeAttribute(b);return;case"boolean":var P=b.toLowerCase().slice(0,5);if(P!=="data-"&&P!=="aria-"){m.removeAttribute(b);return}}m.setAttribute(b,""+S)}}function nn(m,b,S){if(S===null)m.removeAttribute(b);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":m.removeAttribute(b);return}m.setAttribute(b,""+S)}}function ln(m,b,S,P){if(P===null)m.removeAttribute(S);else{switch(typeof P){case"undefined":case"function":case"symbol":case"boolean":m.removeAttribute(S);return}m.setAttributeNS(b,S,""+P)}}function vn(m){switch(typeof m){case"bigint":case"boolean":case"number":case"string":case"undefined":return m;case"object":return m;default:return""}}function Rn(m){var b=m.type;return(m=m.nodeName)&&m.toLowerCase()==="input"&&(b==="checkbox"||b==="radio")}function Zt(m,b,S){var P=Object.getOwnPropertyDescriptor(m.constructor.prototype,b);if(!m.hasOwnProperty(b)&&typeof P<"u"&&typeof P.get=="function"&&typeof P.set=="function"){var H=P.get,X=P.set;return Object.defineProperty(m,b,{configurable:!0,get:function(){return H.call(this)},set:function(ve){S=""+ve,X.call(this,ve)}}),Object.defineProperty(m,b,{enumerable:P.enumerable}),{getValue:function(){return S},setValue:function(ve){S=""+ve},stopTracking:function(){m._valueTracker=null,delete m[b]}}}}function xn(m){if(!m._valueTracker){var b=Rn(m)?"checked":"value";m._valueTracker=Zt(m,b,""+m[b])}}function mn(m){if(!m)return!1;var b=m._valueTracker;if(!b)return!0;var S=b.getValue(),P="";return m&&(P=Rn(m)?m.checked?"true":"false":m.value),m=P,m!==S?(b.setValue(m),!0):!1}function Gr(m){if(m=m||(typeof document<"u"?document:void 0),typeof m>"u")return null;try{return m.activeElement||m.body}catch{return m.body}}var yn=/[\n"\\]/g;function dr(m){return m.replace(yn,function(b){return"\\"+b.charCodeAt(0).toString(16)+" "})}function as(m,b,S,P,H,X,ve,Ie){m.name="",ve!=null&&typeof ve!="function"&&typeof ve!="symbol"&&typeof ve!="boolean"?m.type=ve:m.removeAttribute("type"),b!=null?ve==="number"?(b===0&&m.value===""||m.value!=b)&&(m.value=""+vn(b)):m.value!==""+vn(b)&&(m.value=""+vn(b)):ve!=="submit"&&ve!=="reset"||m.removeAttribute("value"),b!=null?Sr(m,ve,vn(b)):S!=null?Sr(m,ve,vn(S)):P!=null&&m.removeAttribute("value"),H==null&&X!=null&&(m.defaultChecked=!!X),H!=null&&(m.checked=H&&typeof H!="function"&&typeof H!="symbol"),Ie!=null&&typeof Ie!="function"&&typeof Ie!="symbol"&&typeof Ie!="boolean"?m.name=""+vn(Ie):m.removeAttribute("name")}function wn(m,b,S,P,H,X,ve,Ie){if(X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(m.type=X),b!=null||S!=null){if(!(X!=="submit"&&X!=="reset"||b!=null)){xn(m);return}S=S!=null?""+vn(S):"",b=b!=null?""+vn(b):S,Ie||b===m.value||(m.value=b),m.defaultValue=b}P=P??H,P=typeof P!="function"&&typeof P!="symbol"&&!!P,m.checked=Ie?m.checked:!!P,m.defaultChecked=!!P,ve!=null&&typeof ve!="function"&&typeof ve!="symbol"&&typeof ve!="boolean"&&(m.name=ve),xn(m)}function Sr(m,b,S){b==="number"&&Gr(m.ownerDocument)===m||m.defaultValue===""+S||(m.defaultValue=""+S)}function ar(m,b,S,P){if(m=m.options,b){b={};for(var H=0;H<S.length;H++)b["$"+S[H]]=!0;for(S=0;S<m.length;S++)H=b.hasOwnProperty("$"+m[S].value),m[S].selected!==H&&(m[S].selected=H),H&&P&&(m[S].defaultSelected=!0)}else{for(S=""+vn(S),b=null,H=0;H<m.length;H++){if(m[H].value===S){m[H].selected=!0,P&&(m[H].defaultSelected=!0);return}b!==null||m[H].disabled||(b=m[H])}b!==null&&(b.selected=!0)}}function ya(m,b,S){if(b!=null&&(b=""+vn(b),b!==m.value&&(m.value=b),S==null)){m.defaultValue!==b&&(m.defaultValue=b);return}m.defaultValue=S!=null?""+vn(S):""}function Ba(m,b,S,P){if(b==null){if(P!=null){if(S!=null)throw Error(r(92));if(ee(P)){if(1<P.length)throw Error(r(93));P=P[0]}S=P}S==null&&(S=""),b=S}S=vn(b),m.defaultValue=S,P=m.textContent,P===S&&P!==""&&P!==null&&(m.value=P),xn(m)}function sa(m,b){if(b){var S=m.firstChild;if(S&&S===m.lastChild&&S.nodeType===3){S.nodeValue=b;return}}m.textContent=b}var vt=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 Bt(m,b,S){var P=b.indexOf("--")===0;S==null||typeof S=="boolean"||S===""?P?m.setProperty(b,""):b==="float"?m.cssFloat="":m[b]="":P?m.setProperty(b,S):typeof S!="number"||S===0||vt.has(b)?b==="float"?m.cssFloat=S:m[b]=(""+S).trim():m[b]=S+"px"}function Nn(m,b,S){if(b!=null&&typeof b!="object")throw Error(r(62));if(m=m.style,S!=null){for(var P in S)!S.hasOwnProperty(P)||b!=null&&b.hasOwnProperty(P)||(P.indexOf("--")===0?m.setProperty(P,""):P==="float"?m.cssFloat="":m[P]="");for(var H in b)P=b[H],b.hasOwnProperty(H)&&S[H]!==P&&Bt(m,H,P)}else for(var X in b)b.hasOwnProperty(X)&&Bt(m,X,b[X])}function Nt(m){if(m.indexOf("-")===-1)return!1;switch(m){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 Wn=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"]]),ea=/^[\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 ir(m){return ea.test(""+m)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":m}function mr(){}var ui=null;function an(m){return m=m.target||m.srcElement||window,m.correspondingUseElement&&(m=m.correspondingUseElement),m.nodeType===3?m.parentNode:m}var Fn=null,ki=null;function $s(m){var b=Me(m);if(b&&(m=b.stateNode)){var S=m[On]||null;e:switch(m=b.stateNode,b.type){case"input":if(as(m,S.value,S.defaultValue,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name),b=S.name,S.type==="radio"&&b!=null){for(S=m;S.parentNode;)S=S.parentNode;for(S=S.querySelectorAll('input[name="'+dr(""+b)+'"][type="radio"]'),b=0;b<S.length;b++){var P=S[b];if(P!==m&&P.form===m.form){var H=P[On]||null;if(!H)throw Error(r(90));as(P,H.value,H.defaultValue,H.defaultValue,H.checked,H.defaultChecked,H.type,H.name)}}for(b=0;b<S.length;b++)P=S[b],P.form===m.form&&mn(P)}break e;case"textarea":ya(m,S.value,S.defaultValue);break e;case"select":b=S.value,b!=null&&ar(m,!!S.multiple,b,!1)}}}var Uo=!1;function Bo(m,b,S){if(Uo)return m(b,S);Uo=!0;try{var P=m(b);return P}finally{if(Uo=!1,(Fn!==null||ki!==null)&&(Iw(),Fn&&(b=Fn,m=ki,ki=Fn=null,$s(b),m)))for(b=0;b<m.length;b++)$s(m[b])}}function zi(m,b){var S=m.stateNode;if(S===null)return null;var P=S[On]||null;if(P===null)return null;S=P[b];e:switch(b){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(P=!P.disabled)||(m=m.type,P=!(m==="button"||m==="input"||m==="select"||m==="textarea")),m=!P;break e;default:m=!1}if(m)return null;if(S&&typeof S!="function")throw Error(r(231,b,typeof S));return S}var Fr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Vs=!1;if(Fr)try{var Ca={};Object.defineProperty(Ca,"passive",{get:function(){Vs=!0}}),window.addEventListener("test",Ca,Ca),window.removeEventListener("test",Ca,Ca)}catch{Vs=!1}var ta=null,is=null,fr=null;function Ui(){if(fr)return fr;var m,b=is,S=b.length,P,H="value"in ta?ta.value:ta.textContent,X=H.length;for(m=0;m<S&&b[m]===H[m];m++);var ve=S-m;for(P=1;P<=ve&&b[S-P]===H[X-P];P++);return fr=H.slice(m,1<P?1-P:void 0)}function Dl(m){var b=m.keyCode;return"charCode"in m?(m=m.charCode,m===0&&b===13&&(m=13)):m=b,m===10&&(m=13),32<=m||m===13?m:0}function kr(){return!0}function Yt(){return!1}function va(m){function b(S,P,H,X,ve){this._reactName=S,this._targetInst=H,this.type=P,this.nativeEvent=X,this.target=ve,this.currentTarget=null;for(var Ie in m)m.hasOwnProperty(Ie)&&(S=m[Ie],this[Ie]=S?S(X):X[Ie]);return this.isDefaultPrevented=(X.defaultPrevented!=null?X.defaultPrevented:X.returnValue===!1)?kr:Yt,this.isPropagationStopped=Yt,this}return h(b.prototype,{preventDefault:function(){this.defaultPrevented=!0;var S=this.nativeEvent;S&&(S.preventDefault?S.preventDefault():typeof S.returnValue!="unknown"&&(S.returnValue=!1),this.isDefaultPrevented=kr)},stopPropagation:function(){var S=this.nativeEvent;S&&(S.stopPropagation?S.stopPropagation():typeof S.cancelBubble!="unknown"&&(S.cancelBubble=!0),this.isPropagationStopped=kr)},persist:function(){},isPersistent:kr}),b}var Qn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(m){return m.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Cr=va(Qn),Zc=h({},Qn,{view:0,detail:0}),nw=va(Zc),wx,pp,Se,Ot=h({},Zc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:UA,button:0,buttons:0,relatedTarget:function(m){return m.relatedTarget===void 0?m.fromElement===m.srcElement?m.toElement:m.fromElement:m.relatedTarget},movementX:function(m){return"movementX"in m?m.movementX:(m!==Se&&(Se&&m.type==="mousemove"?(wx=m.screenX-Se.screenX,pp=m.screenY-Se.screenY):pp=wx=0,Se=m),wx)},movementY:function(m){return"movementY"in m?m.movementY:pp}}),ha=va(Ot),na=h({},Ot,{dataTransfer:0}),Jc=va(na),gp=h({},Zc,{relatedTarget:0}),po=va(gp),ks=h({},Qn,{animationName:0,elapsedTime:0,pseudoElement:0}),zA=va(ks),kI=h({},Qn,{clipboardData:function(m){return"clipboardData"in m?m.clipboardData:window.clipboardData}}),jse=va(kI),Ese=h({},Qn,{data:0}),CI=va(Ese),Dse={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Rse={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"},Fse={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Lse(m){var b=this.nativeEvent;return b.getModifierState?b.getModifierState(m):(m=Fse[m])?!!b[m]:!1}function UA(){return Lse}var Ose=h({},Zc,{key:function(m){if(m.key){var b=Dse[m.key]||m.key;if(b!=="Unidentified")return b}return m.type==="keypress"?(m=Dl(m),m===13?"Enter":String.fromCharCode(m)):m.type==="keydown"||m.type==="keyup"?Rse[m.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:UA,charCode:function(m){return m.type==="keypress"?Dl(m):0},keyCode:function(m){return m.type==="keydown"||m.type==="keyup"?m.keyCode:0},which:function(m){return m.type==="keypress"?Dl(m):m.type==="keydown"||m.type==="keyup"?m.keyCode:0}}),Ise=va(Ose),zse=h({},Ot,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),AI=va(zse),Use=h({},Zc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:UA}),Bse=va(Use),Hse=h({},Qn,{propertyName:0,elapsedTime:0,pseudoElement:0}),$se=va(Hse),Vse=h({},Ot,{deltaX:function(m){return"deltaX"in m?m.deltaX:"wheelDeltaX"in m?-m.wheelDeltaX:0},deltaY:function(m){return"deltaY"in m?m.deltaY:"wheelDeltaY"in m?-m.wheelDeltaY:"wheelDelta"in m?-m.wheelDelta:0},deltaZ:0,deltaMode:0}),qse=va(Vse),Gse=h({},Qn,{newState:0,oldState:0}),Wse=va(Gse),Kse=[9,13,27,32],BA=Fr&&"CompositionEvent"in window,Sx=null;Fr&&"documentMode"in document&&(Sx=document.documentMode);var Yse=Fr&&"TextEvent"in window&&!Sx,TI=Fr&&(!BA||Sx&&8<Sx&&11>=Sx),MI=" ",PI=!1;function jI(m,b){switch(m){case"keyup":return Kse.indexOf(b.keyCode)!==-1;case"keydown":return b.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function EI(m){return m=m.detail,typeof m=="object"&&"data"in m?m.data:null}var bp=!1;function Xse(m,b){switch(m){case"compositionend":return EI(b);case"keypress":return b.which!==32?null:(PI=!0,MI);case"textInput":return m=b.data,m===MI&&PI?null:m;default:return null}}function Qse(m,b){if(bp)return m==="compositionend"||!BA&&jI(m,b)?(m=Ui(),fr=is=ta=null,bp=!1,m):null;switch(m){case"paste":return null;case"keypress":if(!(b.ctrlKey||b.altKey||b.metaKey)||b.ctrlKey&&b.altKey){if(b.char&&1<b.char.length)return b.char;if(b.which)return String.fromCharCode(b.which)}return null;case"compositionend":return TI&&b.locale!=="ko"?null:b.data;default:return null}}var Zse={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 DI(m){var b=m&&m.nodeName&&m.nodeName.toLowerCase();return b==="input"?!!Zse[m.type]:b==="textarea"}function RI(m,b,S,P){Fn?ki?ki.push(P):ki=[P]:Fn=P,b=qw(b,"onChange"),0<b.length&&(S=new Cr("onChange","change",null,S,P),m.push({event:S,listeners:b}))}var _x=null,Nx=null;function Jse(m){gU(m,0)}function rw(m){var b=Ge(m);if(mn(b))return m}function FI(m,b){if(m==="change")return b}var LI=!1;if(Fr){var HA;if(Fr){var $A="oninput"in document;if(!$A){var OI=document.createElement("div");OI.setAttribute("oninput","return;"),$A=typeof OI.oninput=="function"}HA=$A}else HA=!1;LI=HA&&(!document.documentMode||9<document.documentMode)}function II(){_x&&(_x.detachEvent("onpropertychange",zI),Nx=_x=null)}function zI(m){if(m.propertyName==="value"&&rw(Nx)){var b=[];RI(b,Nx,m,an(m)),Bo(Jse,b)}}function eoe(m,b,S){m==="focusin"?(II(),_x=b,Nx=S,_x.attachEvent("onpropertychange",zI)):m==="focusout"&&II()}function toe(m){if(m==="selectionchange"||m==="keyup"||m==="keydown")return rw(Nx)}function noe(m,b){if(m==="click")return rw(b)}function roe(m,b){if(m==="input"||m==="change")return rw(b)}function aoe(m,b){return m===b&&(m!==0||1/m===1/b)||m!==m&&b!==b}var go=typeof Object.is=="function"?Object.is:aoe;function kx(m,b){if(go(m,b))return!0;if(typeof m!="object"||m===null||typeof b!="object"||b===null)return!1;var S=Object.keys(m),P=Object.keys(b);if(S.length!==P.length)return!1;for(P=0;P<S.length;P++){var H=S[P];if(!ie.call(b,H)||!go(m[H],b[H]))return!1}return!0}function UI(m){for(;m&&m.firstChild;)m=m.firstChild;return m}function BI(m,b){var S=UI(m);m=0;for(var P;S;){if(S.nodeType===3){if(P=m+S.textContent.length,m<=b&&P>=b)return{node:S,offset:b-m};m=P}e:{for(;S;){if(S.nextSibling){S=S.nextSibling;break e}S=S.parentNode}S=void 0}S=UI(S)}}function HI(m,b){return m&&b?m===b?!0:m&&m.nodeType===3?!1:b&&b.nodeType===3?HI(m,b.parentNode):"contains"in m?m.contains(b):m.compareDocumentPosition?!!(m.compareDocumentPosition(b)&16):!1:!1}function $I(m){m=m!=null&&m.ownerDocument!=null&&m.ownerDocument.defaultView!=null?m.ownerDocument.defaultView:window;for(var b=Gr(m.document);b instanceof m.HTMLIFrameElement;){try{var S=typeof b.contentWindow.location.href=="string"}catch{S=!1}if(S)m=b.contentWindow;else break;b=Gr(m.document)}return b}function VA(m){var b=m&&m.nodeName&&m.nodeName.toLowerCase();return b&&(b==="input"&&(m.type==="text"||m.type==="search"||m.type==="tel"||m.type==="url"||m.type==="password")||b==="textarea"||m.contentEditable==="true")}var ioe=Fr&&"documentMode"in document&&11>=document.documentMode,xp=null,qA=null,Cx=null,GA=!1;function VI(m,b,S){var P=S.window===S?S.document:S.nodeType===9?S:S.ownerDocument;GA||xp==null||xp!==Gr(P)||(P=xp,"selectionStart"in P&&VA(P)?P={start:P.selectionStart,end:P.selectionEnd}:(P=(P.ownerDocument&&P.ownerDocument.defaultView||window).getSelection(),P={anchorNode:P.anchorNode,anchorOffset:P.anchorOffset,focusNode:P.focusNode,focusOffset:P.focusOffset}),Cx&&kx(Cx,P)||(Cx=P,P=qw(qA,"onSelect"),0<P.length&&(b=new Cr("onSelect","select",null,b,S),m.push({event:b,listeners:P}),b.target=xp)))}function gm(m,b){var S={};return S[m.toLowerCase()]=b.toLowerCase(),S["Webkit"+m]="webkit"+b,S["Moz"+m]="moz"+b,S}var yp={animationend:gm("Animation","AnimationEnd"),animationiteration:gm("Animation","AnimationIteration"),animationstart:gm("Animation","AnimationStart"),transitionrun:gm("Transition","TransitionRun"),transitionstart:gm("Transition","TransitionStart"),transitioncancel:gm("Transition","TransitionCancel"),transitionend:gm("Transition","TransitionEnd")},WA={},qI={};Fr&&(qI=document.createElement("div").style,"AnimationEvent"in window||(delete yp.animationend.animation,delete yp.animationiteration.animation,delete yp.animationstart.animation),"TransitionEvent"in window||delete yp.transitionend.transition);function bm(m){if(WA[m])return WA[m];if(!yp[m])return m;var b=yp[m],S;for(S in b)if(b.hasOwnProperty(S)&&S in qI)return WA[m]=b[S];return m}var GI=bm("animationend"),WI=bm("animationiteration"),KI=bm("animationstart"),soe=bm("transitionrun"),ooe=bm("transitionstart"),loe=bm("transitioncancel"),YI=bm("transitionend"),XI=new Map,KA="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(" ");KA.push("scrollEnd");function Rl(m,b){XI.set(m,b),it(b,[m])}var aw=typeof reportError=="function"?reportError:function(m){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var b=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof m=="object"&&m!==null&&typeof m.message=="string"?String(m.message):String(m),error:m});if(!window.dispatchEvent(b))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",m);return}console.error(m)},Ho=[],vp=0,YA=0;function iw(){for(var m=vp,b=YA=vp=0;b<m;){var S=Ho[b];Ho[b++]=null;var P=Ho[b];Ho[b++]=null;var H=Ho[b];Ho[b++]=null;var X=Ho[b];if(Ho[b++]=null,P!==null&&H!==null){var ve=P.pending;ve===null?H.next=H:(H.next=ve.next,ve.next=H),P.pending=H}X!==0&&QI(S,H,X)}}function sw(m,b,S,P){Ho[vp++]=m,Ho[vp++]=b,Ho[vp++]=S,Ho[vp++]=P,YA|=P,m.lanes|=P,m=m.alternate,m!==null&&(m.lanes|=P)}function XA(m,b,S,P){return sw(m,b,S,P),ow(m)}function xm(m,b){return sw(m,null,null,b),ow(m)}function QI(m,b,S){m.lanes|=S;var P=m.alternate;P!==null&&(P.lanes|=S);for(var H=!1,X=m.return;X!==null;)X.childLanes|=S,P=X.alternate,P!==null&&(P.childLanes|=S),X.tag===22&&(m=X.stateNode,m===null||m._visibility&1||(H=!0)),m=X,X=X.return;return m.tag===3?(X=m.stateNode,H&&b!==null&&(H=31-_e(S),m=X.hiddenUpdates,P=m[H],P===null?m[H]=[b]:P.push(b),b.lane=S|536870912),X):null}function ow(m){if(50<Kx)throw Kx=0,i2=null,Error(r(185));for(var b=m.return;b!==null;)m=b,b=m.return;return m.tag===3?m.stateNode:null}var wp={};function coe(m,b,S,P){this.tag=m,this.key=S,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=b,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=P,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bo(m,b,S,P){return new coe(m,b,S,P)}function QA(m){return m=m.prototype,!(!m||!m.isReactComponent)}function eu(m,b){var S=m.alternate;return S===null?(S=bo(m.tag,b,m.key,m.mode),S.elementType=m.elementType,S.type=m.type,S.stateNode=m.stateNode,S.alternate=m,m.alternate=S):(S.pendingProps=b,S.type=m.type,S.flags=0,S.subtreeFlags=0,S.deletions=null),S.flags=m.flags&65011712,S.childLanes=m.childLanes,S.lanes=m.lanes,S.child=m.child,S.memoizedProps=m.memoizedProps,S.memoizedState=m.memoizedState,S.updateQueue=m.updateQueue,b=m.dependencies,S.dependencies=b===null?null:{lanes:b.lanes,firstContext:b.firstContext},S.sibling=m.sibling,S.index=m.index,S.ref=m.ref,S.refCleanup=m.refCleanup,S}function ZI(m,b){m.flags&=65011714;var S=m.alternate;return S===null?(m.childLanes=0,m.lanes=b,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=S.childLanes,m.lanes=S.lanes,m.child=S.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=S.memoizedProps,m.memoizedState=S.memoizedState,m.updateQueue=S.updateQueue,m.type=S.type,b=S.dependencies,m.dependencies=b===null?null:{lanes:b.lanes,firstContext:b.firstContext}),m}function lw(m,b,S,P,H,X){var ve=0;if(P=m,typeof m=="function")QA(m)&&(ve=1);else if(typeof m=="string")ve=fle(m,S,be.current)?26:m==="html"||m==="head"||m==="body"?27:5;else e:switch(m){case M:return m=bo(31,S,b,H),m.elementType=M,m.lanes=X,m;case v:return ym(S.children,H,X,b);case g:ve=8,H|=24;break;case y:return m=bo(12,S,b,H|2),m.elementType=y,m.lanes=X,m;case C:return m=bo(13,S,b,H),m.elementType=C,m.lanes=X,m;case j:return m=bo(19,S,b,H),m.elementType=j,m.lanes=X,m;default:if(typeof m=="object"&&m!==null)switch(m.$$typeof){case N:ve=10;break e;case _:ve=9;break e;case A:ve=11;break e;case k:ve=14;break e;case R:ve=16,P=null;break e}ve=29,S=Error(r(130,m===null?"null":typeof m,"")),P=null}return b=bo(ve,S,b,H),b.elementType=m,b.type=P,b.lanes=X,b}function ym(m,b,S,P){return m=bo(7,m,P,b),m.lanes=S,m}function ZA(m,b,S){return m=bo(6,m,null,b),m.lanes=S,m}function JI(m){var b=bo(18,null,null,0);return b.stateNode=m,b}function JA(m,b,S){return b=bo(4,m.children!==null?m.children:[],m.key,b),b.lanes=S,b.stateNode={containerInfo:m.containerInfo,pendingChildren:null,implementation:m.implementation},b}var e5=new WeakMap;function $o(m,b){if(typeof m=="object"&&m!==null){var S=e5.get(m);return S!==void 0?S:(b={value:m,source:b,stack:ne(b)},e5.set(m,b),b)}return{value:m,source:b,stack:ne(b)}}var Sp=[],_p=0,cw=null,Ax=0,Vo=[],qo=0,_d=null,cc=1,uc="";function tu(m,b){Sp[_p++]=Ax,Sp[_p++]=cw,cw=m,Ax=b}function t5(m,b,S){Vo[qo++]=cc,Vo[qo++]=uc,Vo[qo++]=_d,_d=m;var P=cc;m=uc;var H=32-_e(P)-1;P&=~(1<<H),S+=1;var X=32-_e(b)+H;if(30<X){var ve=H-H%5;X=(P&(1<<ve)-1).toString(32),P>>=ve,H-=ve,cc=1<<32-_e(b)+H|S<<H|P,uc=X+m}else cc=1<<X|S<<H|P,uc=m}function eT(m){m.return!==null&&(tu(m,1),t5(m,1,0))}function tT(m){for(;m===cw;)cw=Sp[--_p],Sp[_p]=null,Ax=Sp[--_p],Sp[_p]=null;for(;m===_d;)_d=Vo[--qo],Vo[qo]=null,uc=Vo[--qo],Vo[qo]=null,cc=Vo[--qo],Vo[qo]=null}function n5(m,b){Vo[qo++]=cc,Vo[qo++]=uc,Vo[qo++]=_d,cc=b.id,uc=b.overflow,_d=m}var Bi=null,oa=null,lr=!1,Nd=null,Go=!1,nT=Error(r(519));function kd(m){var b=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Tx($o(b,m)),nT}function r5(m){var b=m.stateNode,S=m.type,P=m.memoizedProps;switch(b[gn]=m,b[On]=P,S){case"dialog":tr("cancel",b),tr("close",b);break;case"iframe":case"object":case"embed":tr("load",b);break;case"video":case"audio":for(S=0;S<Xx.length;S++)tr(Xx[S],b);break;case"source":tr("error",b);break;case"img":case"image":case"link":tr("error",b),tr("load",b);break;case"details":tr("toggle",b);break;case"input":tr("invalid",b),wn(b,P.value,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name,!0);break;case"select":tr("invalid",b);break;case"textarea":tr("invalid",b),Ba(b,P.value,P.defaultValue,P.children)}S=P.children,typeof S!="string"&&typeof S!="number"&&typeof S!="bigint"||b.textContent===""+S||P.suppressHydrationWarning===!0||vU(b.textContent,S)?(P.popover!=null&&(tr("beforetoggle",b),tr("toggle",b)),P.onScroll!=null&&tr("scroll",b),P.onScrollEnd!=null&&tr("scrollend",b),P.onClick!=null&&(b.onclick=mr),b=!0):b=!1,b||kd(m,!0)}function a5(m){for(Bi=m.return;Bi;)switch(Bi.tag){case 5:case 31:case 13:Go=!1;return;case 27:case 3:Go=!0;return;default:Bi=Bi.return}}function Np(m){if(m!==Bi)return!1;if(!lr)return a5(m),lr=!0,!1;var b=m.tag,S;if((S=b!==3&&b!==27)&&((S=b===5)&&(S=m.type,S=!(S!=="form"&&S!=="button")||v2(m.type,m.memoizedProps)),S=!S),S&&oa&&kd(m),a5(m),b===13){if(m=m.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));oa=MU(m)}else if(b===31){if(m=m.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));oa=MU(m)}else b===27?(b=oa,zd(m.type)?(m=k2,k2=null,oa=m):oa=b):oa=Bi?Ko(m.stateNode.nextSibling):null;return!0}function vm(){oa=Bi=null,lr=!1}function rT(){var m=Nd;return m!==null&&(Ks===null?Ks=m:Ks.push.apply(Ks,m),Nd=null),m}function Tx(m){Nd===null?Nd=[m]:Nd.push(m)}var aT=Z(null),wm=null,nu=null;function Cd(m,b,S){pe(aT,b._currentValue),b._currentValue=S}function ru(m){m._currentValue=aT.current,ue(aT)}function iT(m,b,S){for(;m!==null;){var P=m.alternate;if((m.childLanes&b)!==b?(m.childLanes|=b,P!==null&&(P.childLanes|=b)):P!==null&&(P.childLanes&b)!==b&&(P.childLanes|=b),m===S)break;m=m.return}}function sT(m,b,S,P){var H=m.child;for(H!==null&&(H.return=m);H!==null;){var X=H.dependencies;if(X!==null){var ve=H.child;X=X.firstContext;e:for(;X!==null;){var Ie=X;X=H;for(var Xe=0;Xe<b.length;Xe++)if(Ie.context===b[Xe]){X.lanes|=S,Ie=X.alternate,Ie!==null&&(Ie.lanes|=S),iT(X.return,S,m),P||(ve=null);break e}X=Ie.next}}else if(H.tag===18){if(ve=H.return,ve===null)throw Error(r(341));ve.lanes|=S,X=ve.alternate,X!==null&&(X.lanes|=S),iT(ve,S,m),ve=null}else ve=H.child;if(ve!==null)ve.return=H;else for(ve=H;ve!==null;){if(ve===m){ve=null;break}if(H=ve.sibling,H!==null){H.return=ve.return,ve=H;break}ve=ve.return}H=ve}}function kp(m,b,S,P){m=null;for(var H=b,X=!1;H!==null;){if(!X){if((H.flags&524288)!==0)X=!0;else if((H.flags&262144)!==0)break}if(H.tag===10){var ve=H.alternate;if(ve===null)throw Error(r(387));if(ve=ve.memoizedProps,ve!==null){var Ie=H.type;go(H.pendingProps.value,ve.value)||(m!==null?m.push(Ie):m=[Ie])}}else if(H===K.current){if(ve=H.alternate,ve===null)throw Error(r(387));ve.memoizedState.memoizedState!==H.memoizedState.memoizedState&&(m!==null?m.push(ty):m=[ty])}H=H.return}m!==null&&sT(b,m,S,P),b.flags|=262144}function uw(m){for(m=m.firstContext;m!==null;){if(!go(m.context._currentValue,m.memoizedValue))return!0;m=m.next}return!1}function Sm(m){wm=m,nu=null,m=m.dependencies,m!==null&&(m.firstContext=null)}function Hi(m){return i5(wm,m)}function dw(m,b){return wm===null&&Sm(m),i5(m,b)}function i5(m,b){var S=b._currentValue;if(b={context:b,memoizedValue:S,next:null},nu===null){if(m===null)throw Error(r(308));nu=b,m.dependencies={lanes:0,firstContext:b},m.flags|=524288}else nu=nu.next=b;return S}var uoe=typeof AbortController<"u"?AbortController:function(){var m=[],b=this.signal={aborted:!1,addEventListener:function(S,P){m.push(P)}};this.abort=function(){b.aborted=!0,m.forEach(function(S){return S()})}},doe=t.unstable_scheduleCallback,hoe=t.unstable_NormalPriority,Ya={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function oT(){return{controller:new uoe,data:new Map,refCount:0}}function Mx(m){m.refCount--,m.refCount===0&&doe(hoe,function(){m.controller.abort()})}var Px=null,lT=0,Cp=0,Ap=null;function moe(m,b){if(Px===null){var S=Px=[];lT=0,Cp=d2(),Ap={status:"pending",value:void 0,then:function(P){S.push(P)}}}return lT++,b.then(s5,s5),b}function s5(){if(--lT===0&&Px!==null){Ap!==null&&(Ap.status="fulfilled");var m=Px;Px=null,Cp=0,Ap=null;for(var b=0;b<m.length;b++)(0,m[b])()}}function foe(m,b){var S=[],P={status:"pending",value:null,reason:null,then:function(H){S.push(H)}};return m.then(function(){P.status="fulfilled",P.value=b;for(var H=0;H<S.length;H++)(0,S[H])(b)},function(H){for(P.status="rejected",P.reason=H,H=0;H<S.length;H++)(0,S[H])(void 0)}),P}var o5=ae.S;ae.S=function(m,b){Vz=F(),typeof b=="object"&&b!==null&&typeof b.then=="function"&&moe(m,b),o5!==null&&o5(m,b)};var _m=Z(null);function cT(){var m=_m.current;return m!==null?m:Wr.pooledCache}function hw(m,b){b===null?pe(_m,_m.current):pe(_m,b.pool)}function l5(){var m=cT();return m===null?null:{parent:Ya._currentValue,pool:m}}var Tp=Error(r(460)),uT=Error(r(474)),mw=Error(r(542)),fw={then:function(){}};function c5(m){return m=m.status,m==="fulfilled"||m==="rejected"}function u5(m,b,S){switch(S=m[S],S===void 0?m.push(b):S!==b&&(b.then(mr,mr),b=S),b.status){case"fulfilled":return b.value;case"rejected":throw m=b.reason,h5(m),m;default:if(typeof b.status=="string")b.then(mr,mr);else{if(m=Wr,m!==null&&100<m.shellSuspendCounter)throw Error(r(482));m=b,m.status="pending",m.then(function(P){if(b.status==="pending"){var H=b;H.status="fulfilled",H.value=P}},function(P){if(b.status==="pending"){var H=b;H.status="rejected",H.reason=P}})}switch(b.status){case"fulfilled":return b.value;case"rejected":throw m=b.reason,h5(m),m}throw km=b,Tp}}function Nm(m){try{var b=m._init;return b(m._payload)}catch(S){throw S!==null&&typeof S=="object"&&typeof S.then=="function"?(km=S,Tp):S}}var km=null;function d5(){if(km===null)throw Error(r(459));var m=km;return km=null,m}function h5(m){if(m===Tp||m===mw)throw Error(r(483))}var Mp=null,jx=0;function pw(m){var b=jx;return jx+=1,Mp===null&&(Mp=[]),u5(Mp,m,b)}function Ex(m,b){b=b.props.ref,m.ref=b!==void 0?b:null}function gw(m,b){throw b.$$typeof===f?Error(r(525)):(m=Object.prototype.toString.call(b),Error(r(31,m==="[object Object]"?"object with keys {"+Object.keys(b).join(", ")+"}":m)))}function m5(m){function b(ot,nt){if(m){var ft=ot.deletions;ft===null?(ot.deletions=[nt],ot.flags|=16):ft.push(nt)}}function S(ot,nt){if(!m)return null;for(;nt!==null;)b(ot,nt),nt=nt.sibling;return null}function P(ot){for(var nt=new Map;ot!==null;)ot.key!==null?nt.set(ot.key,ot):nt.set(ot.index,ot),ot=ot.sibling;return nt}function H(ot,nt){return ot=eu(ot,nt),ot.index=0,ot.sibling=null,ot}function X(ot,nt,ft){return ot.index=ft,m?(ft=ot.alternate,ft!==null?(ft=ft.index,ft<nt?(ot.flags|=67108866,nt):ft):(ot.flags|=67108866,nt)):(ot.flags|=1048576,nt)}function ve(ot){return m&&ot.alternate===null&&(ot.flags|=67108866),ot}function Ie(ot,nt,ft,At){return nt===null||nt.tag!==6?(nt=ZA(ft,ot.mode,At),nt.return=ot,nt):(nt=H(nt,ft),nt.return=ot,nt)}function Xe(ot,nt,ft,At){var on=ft.type;return on===v?kt(ot,nt,ft.props.children,At,ft.key):nt!==null&&(nt.elementType===on||typeof on=="object"&&on!==null&&on.$$typeof===R&&Nm(on)===nt.type)?(nt=H(nt,ft.props),Ex(nt,ft),nt.return=ot,nt):(nt=lw(ft.type,ft.key,ft.props,null,ot.mode,At),Ex(nt,ft),nt.return=ot,nt)}function pt(ot,nt,ft,At){return nt===null||nt.tag!==4||nt.stateNode.containerInfo!==ft.containerInfo||nt.stateNode.implementation!==ft.implementation?(nt=JA(ft,ot.mode,At),nt.return=ot,nt):(nt=H(nt,ft.children||[]),nt.return=ot,nt)}function kt(ot,nt,ft,At,on){return nt===null||nt.tag!==7?(nt=ym(ft,ot.mode,At,on),nt.return=ot,nt):(nt=H(nt,ft),nt.return=ot,nt)}function Pt(ot,nt,ft){if(typeof nt=="string"&&nt!==""||typeof nt=="number"||typeof nt=="bigint")return nt=ZA(""+nt,ot.mode,ft),nt.return=ot,nt;if(typeof nt=="object"&&nt!==null){switch(nt.$$typeof){case p:return ft=lw(nt.type,nt.key,nt.props,null,ot.mode,ft),Ex(ft,nt),ft.return=ot,ft;case x:return nt=JA(nt,ot.mode,ft),nt.return=ot,nt;case R:return nt=Nm(nt),Pt(ot,nt,ft)}if(ee(nt)||U(nt))return nt=ym(nt,ot.mode,ft,null),nt.return=ot,nt;if(typeof nt.then=="function")return Pt(ot,pw(nt),ft);if(nt.$$typeof===N)return Pt(ot,dw(ot,nt),ft);gw(ot,nt)}return null}function bt(ot,nt,ft,At){var on=nt!==null?nt.key:null;if(typeof ft=="string"&&ft!==""||typeof ft=="number"||typeof ft=="bigint")return on!==null?null:Ie(ot,nt,""+ft,At);if(typeof ft=="object"&&ft!==null){switch(ft.$$typeof){case p:return ft.key===on?Xe(ot,nt,ft,At):null;case x:return ft.key===on?pt(ot,nt,ft,At):null;case R:return ft=Nm(ft),bt(ot,nt,ft,At)}if(ee(ft)||U(ft))return on!==null?null:kt(ot,nt,ft,At,null);if(typeof ft.then=="function")return bt(ot,nt,pw(ft),At);if(ft.$$typeof===N)return bt(ot,nt,dw(ot,ft),At);gw(ot,ft)}return null}function wt(ot,nt,ft,At,on){if(typeof At=="string"&&At!==""||typeof At=="number"||typeof At=="bigint")return ot=ot.get(ft)||null,Ie(nt,ot,""+At,on);if(typeof At=="object"&&At!==null){switch(At.$$typeof){case p:return ot=ot.get(At.key===null?ft:At.key)||null,Xe(nt,ot,At,on);case x:return ot=ot.get(At.key===null?ft:At.key)||null,pt(nt,ot,At,on);case R:return At=Nm(At),wt(ot,nt,ft,At,on)}if(ee(At)||U(At))return ot=ot.get(ft)||null,kt(nt,ot,At,on,null);if(typeof At.then=="function")return wt(ot,nt,ft,pw(At),on);if(At.$$typeof===N)return wt(ot,nt,ft,dw(nt,At),on);gw(nt,At)}return null}function Kt(ot,nt,ft,At){for(var on=null,pr=null,Jt=nt,In=nt=0,or=null;Jt!==null&&In<ft.length;In++){Jt.index>In?(or=Jt,Jt=null):or=Jt.sibling;var gr=bt(ot,Jt,ft[In],At);if(gr===null){Jt===null&&(Jt=or);break}m&&Jt&&gr.alternate===null&&b(ot,Jt),nt=X(gr,nt,In),pr===null?on=gr:pr.sibling=gr,pr=gr,Jt=or}if(In===ft.length)return S(ot,Jt),lr&&tu(ot,In),on;if(Jt===null){for(;In<ft.length;In++)Jt=Pt(ot,ft[In],At),Jt!==null&&(nt=X(Jt,nt,In),pr===null?on=Jt:pr.sibling=Jt,pr=Jt);return lr&&tu(ot,In),on}for(Jt=P(Jt);In<ft.length;In++)or=wt(Jt,ot,In,ft[In],At),or!==null&&(m&&or.alternate!==null&&Jt.delete(or.key===null?In:or.key),nt=X(or,nt,In),pr===null?on=or:pr.sibling=or,pr=or);return m&&Jt.forEach(function(Vd){return b(ot,Vd)}),lr&&tu(ot,In),on}function bn(ot,nt,ft,At){if(ft==null)throw Error(r(151));for(var on=null,pr=null,Jt=nt,In=nt=0,or=null,gr=ft.next();Jt!==null&&!gr.done;In++,gr=ft.next()){Jt.index>In?(or=Jt,Jt=null):or=Jt.sibling;var Vd=bt(ot,Jt,gr.value,At);if(Vd===null){Jt===null&&(Jt=or);break}m&&Jt&&Vd.alternate===null&&b(ot,Jt),nt=X(Vd,nt,In),pr===null?on=Vd:pr.sibling=Vd,pr=Vd,Jt=or}if(gr.done)return S(ot,Jt),lr&&tu(ot,In),on;if(Jt===null){for(;!gr.done;In++,gr=ft.next())gr=Pt(ot,gr.value,At),gr!==null&&(nt=X(gr,nt,In),pr===null?on=gr:pr.sibling=gr,pr=gr);return lr&&tu(ot,In),on}for(Jt=P(Jt);!gr.done;In++,gr=ft.next())gr=wt(Jt,ot,In,gr.value,At),gr!==null&&(m&&gr.alternate!==null&&Jt.delete(gr.key===null?In:gr.key),nt=X(gr,nt,In),pr===null?on=gr:pr.sibling=gr,pr=gr);return m&&Jt.forEach(function(kle){return b(ot,kle)}),lr&&tu(ot,In),on}function Ir(ot,nt,ft,At){if(typeof ft=="object"&&ft!==null&&ft.type===v&&ft.key===null&&(ft=ft.props.children),typeof ft=="object"&&ft!==null){switch(ft.$$typeof){case p:e:{for(var on=ft.key;nt!==null;){if(nt.key===on){if(on=ft.type,on===v){if(nt.tag===7){S(ot,nt.sibling),At=H(nt,ft.props.children),At.return=ot,ot=At;break e}}else if(nt.elementType===on||typeof on=="object"&&on!==null&&on.$$typeof===R&&Nm(on)===nt.type){S(ot,nt.sibling),At=H(nt,ft.props),Ex(At,ft),At.return=ot,ot=At;break e}S(ot,nt);break}else b(ot,nt);nt=nt.sibling}ft.type===v?(At=ym(ft.props.children,ot.mode,At,ft.key),At.return=ot,ot=At):(At=lw(ft.type,ft.key,ft.props,null,ot.mode,At),Ex(At,ft),At.return=ot,ot=At)}return ve(ot);case x:e:{for(on=ft.key;nt!==null;){if(nt.key===on)if(nt.tag===4&&nt.stateNode.containerInfo===ft.containerInfo&&nt.stateNode.implementation===ft.implementation){S(ot,nt.sibling),At=H(nt,ft.children||[]),At.return=ot,ot=At;break e}else{S(ot,nt);break}else b(ot,nt);nt=nt.sibling}At=JA(ft,ot.mode,At),At.return=ot,ot=At}return ve(ot);case R:return ft=Nm(ft),Ir(ot,nt,ft,At)}if(ee(ft))return Kt(ot,nt,ft,At);if(U(ft)){if(on=U(ft),typeof on!="function")throw Error(r(150));return ft=on.call(ft),bn(ot,nt,ft,At)}if(typeof ft.then=="function")return Ir(ot,nt,pw(ft),At);if(ft.$$typeof===N)return Ir(ot,nt,dw(ot,ft),At);gw(ot,ft)}return typeof ft=="string"&&ft!==""||typeof ft=="number"||typeof ft=="bigint"?(ft=""+ft,nt!==null&&nt.tag===6?(S(ot,nt.sibling),At=H(nt,ft),At.return=ot,ot=At):(S(ot,nt),At=ZA(ft,ot.mode,At),At.return=ot,ot=At),ve(ot)):S(ot,nt)}return function(ot,nt,ft,At){try{jx=0;var on=Ir(ot,nt,ft,At);return Mp=null,on}catch(Jt){if(Jt===Tp||Jt===mw)throw Jt;var pr=bo(29,Jt,null,ot.mode);return pr.lanes=At,pr.return=ot,pr}}}var Cm=m5(!0),f5=m5(!1),Ad=!1;function dT(m){m.updateQueue={baseState:m.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function hT(m,b){m=m.updateQueue,b.updateQueue===m&&(b.updateQueue={baseState:m.baseState,firstBaseUpdate:m.firstBaseUpdate,lastBaseUpdate:m.lastBaseUpdate,shared:m.shared,callbacks:null})}function Td(m){return{lane:m,tag:0,payload:null,callback:null,next:null}}function Md(m,b,S){var P=m.updateQueue;if(P===null)return null;if(P=P.shared,(vr&2)!==0){var H=P.pending;return H===null?b.next=b:(b.next=H.next,H.next=b),P.pending=b,b=ow(m),QI(m,null,S),b}return sw(m,P,b,S),ow(m)}function Dx(m,b,S){if(b=b.updateQueue,b!==null&&(b=b.shared,(S&4194048)!==0)){var P=b.lanes;P&=m.pendingLanes,S|=P,b.lanes=S,dt(m,S)}}function mT(m,b){var S=m.updateQueue,P=m.alternate;if(P!==null&&(P=P.updateQueue,S===P)){var H=null,X=null;if(S=S.firstBaseUpdate,S!==null){do{var ve={lane:S.lane,tag:S.tag,payload:S.payload,callback:null,next:null};X===null?H=X=ve:X=X.next=ve,S=S.next}while(S!==null);X===null?H=X=b:X=X.next=b}else H=X=b;S={baseState:P.baseState,firstBaseUpdate:H,lastBaseUpdate:X,shared:P.shared,callbacks:P.callbacks},m.updateQueue=S;return}m=S.lastBaseUpdate,m===null?S.firstBaseUpdate=b:m.next=b,S.lastBaseUpdate=b}var fT=!1;function Rx(){if(fT){var m=Ap;if(m!==null)throw m}}function Fx(m,b,S,P){fT=!1;var H=m.updateQueue;Ad=!1;var X=H.firstBaseUpdate,ve=H.lastBaseUpdate,Ie=H.shared.pending;if(Ie!==null){H.shared.pending=null;var Xe=Ie,pt=Xe.next;Xe.next=null,ve===null?X=pt:ve.next=pt,ve=Xe;var kt=m.alternate;kt!==null&&(kt=kt.updateQueue,Ie=kt.lastBaseUpdate,Ie!==ve&&(Ie===null?kt.firstBaseUpdate=pt:Ie.next=pt,kt.lastBaseUpdate=Xe))}if(X!==null){var Pt=H.baseState;ve=0,kt=pt=Xe=null,Ie=X;do{var bt=Ie.lane&-536870913,wt=bt!==Ie.lane;if(wt?(sr&bt)===bt:(P&bt)===bt){bt!==0&&bt===Cp&&(fT=!0),kt!==null&&(kt=kt.next={lane:0,tag:Ie.tag,payload:Ie.payload,callback:null,next:null});e:{var Kt=m,bn=Ie;bt=b;var Ir=S;switch(bn.tag){case 1:if(Kt=bn.payload,typeof Kt=="function"){Pt=Kt.call(Ir,Pt,bt);break e}Pt=Kt;break e;case 3:Kt.flags=Kt.flags&-65537|128;case 0:if(Kt=bn.payload,bt=typeof Kt=="function"?Kt.call(Ir,Pt,bt):Kt,bt==null)break e;Pt=h({},Pt,bt);break e;case 2:Ad=!0}}bt=Ie.callback,bt!==null&&(m.flags|=64,wt&&(m.flags|=8192),wt=H.callbacks,wt===null?H.callbacks=[bt]:wt.push(bt))}else wt={lane:bt,tag:Ie.tag,payload:Ie.payload,callback:Ie.callback,next:null},kt===null?(pt=kt=wt,Xe=Pt):kt=kt.next=wt,ve|=bt;if(Ie=Ie.next,Ie===null){if(Ie=H.shared.pending,Ie===null)break;wt=Ie,Ie=wt.next,wt.next=null,H.lastBaseUpdate=wt,H.shared.pending=null}}while(!0);kt===null&&(Xe=Pt),H.baseState=Xe,H.firstBaseUpdate=pt,H.lastBaseUpdate=kt,X===null&&(H.shared.lanes=0),Rd|=ve,m.lanes=ve,m.memoizedState=Pt}}function p5(m,b){if(typeof m!="function")throw Error(r(191,m));m.call(b)}function g5(m,b){var S=m.callbacks;if(S!==null)for(m.callbacks=null,m=0;m<S.length;m++)p5(S[m],b)}var Pp=Z(null),bw=Z(0);function b5(m,b){m=hu,pe(bw,m),pe(Pp,b),hu=m|b.baseLanes}function pT(){pe(bw,hu),pe(Pp,Pp.current)}function gT(){hu=bw.current,ue(Pp),ue(bw)}var xo=Z(null),Wo=null;function Pd(m){var b=m.alternate;pe(Ha,Ha.current&1),pe(xo,m),Wo===null&&(b===null||Pp.current!==null||b.memoizedState!==null)&&(Wo=m)}function bT(m){pe(Ha,Ha.current),pe(xo,m),Wo===null&&(Wo=m)}function x5(m){m.tag===22?(pe(Ha,Ha.current),pe(xo,m),Wo===null&&(Wo=m)):jd()}function jd(){pe(Ha,Ha.current),pe(xo,xo.current)}function yo(m){ue(xo),Wo===m&&(Wo=null),ue(Ha)}var Ha=Z(0);function xw(m){for(var b=m;b!==null;){if(b.tag===13){var S=b.memoizedState;if(S!==null&&(S=S.dehydrated,S===null||_2(S)||N2(S)))return b}else if(b.tag===19&&(b.memoizedProps.revealOrder==="forwards"||b.memoizedProps.revealOrder==="backwards"||b.memoizedProps.revealOrder==="unstable_legacy-backwards"||b.memoizedProps.revealOrder==="together")){if((b.flags&128)!==0)return b}else if(b.child!==null){b.child.return=b,b=b.child;continue}if(b===m)break;for(;b.sibling===null;){if(b.return===null||b.return===m)return null;b=b.return}b.sibling.return=b.return,b=b.sibling}return null}var au=0,Ln=null,Lr=null,Xa=null,yw=!1,jp=!1,Am=!1,vw=0,Lx=0,Ep=null,poe=0;function Aa(){throw Error(r(321))}function xT(m,b){if(b===null)return!1;for(var S=0;S<b.length&&S<m.length;S++)if(!go(m[S],b[S]))return!1;return!0}function yT(m,b,S,P,H,X){return au=X,Ln=b,b.memoizedState=null,b.updateQueue=null,b.lanes=0,ae.H=m===null||m.memoizedState===null?tz:RT,Am=!1,X=S(P,H),Am=!1,jp&&(X=v5(b,S,P,H)),y5(m),X}function y5(m){ae.H=zx;var b=Lr!==null&&Lr.next!==null;if(au=0,Xa=Lr=Ln=null,yw=!1,Lx=0,Ep=null,b)throw Error(r(300));m===null||Qa||(m=m.dependencies,m!==null&&uw(m)&&(Qa=!0))}function v5(m,b,S,P){Ln=m;var H=0;do{if(jp&&(Ep=null),Lx=0,jp=!1,25<=H)throw Error(r(301));if(H+=1,Xa=Lr=null,m.updateQueue!=null){var X=m.updateQueue;X.lastEffect=null,X.events=null,X.stores=null,X.memoCache!=null&&(X.memoCache.index=0)}ae.H=nz,X=b(S,P)}while(jp);return X}function goe(){var m=ae.H,b=m.useState()[0];return b=typeof b.then=="function"?Ox(b):b,m=m.useState()[0],(Lr!==null?Lr.memoizedState:null)!==m&&(Ln.flags|=1024),b}function vT(){var m=vw!==0;return vw=0,m}function wT(m,b,S){b.updateQueue=m.updateQueue,b.flags&=-2053,m.lanes&=~S}function ST(m){if(yw){for(m=m.memoizedState;m!==null;){var b=m.queue;b!==null&&(b.pending=null),m=m.next}yw=!1}au=0,Xa=Lr=Ln=null,jp=!1,Lx=vw=0,Ep=null}function Cs(){var m={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xa===null?Ln.memoizedState=Xa=m:Xa=Xa.next=m,Xa}function $a(){if(Lr===null){var m=Ln.alternate;m=m!==null?m.memoizedState:null}else m=Lr.next;var b=Xa===null?Ln.memoizedState:Xa.next;if(b!==null)Xa=b,Lr=m;else{if(m===null)throw Ln.alternate===null?Error(r(467)):Error(r(310));Lr=m,m={memoizedState:Lr.memoizedState,baseState:Lr.baseState,baseQueue:Lr.baseQueue,queue:Lr.queue,next:null},Xa===null?Ln.memoizedState=Xa=m:Xa=Xa.next=m}return Xa}function ww(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ox(m){var b=Lx;return Lx+=1,Ep===null&&(Ep=[]),m=u5(Ep,m,b),b=Ln,(Xa===null?b.memoizedState:Xa.next)===null&&(b=b.alternate,ae.H=b===null||b.memoizedState===null?tz:RT),m}function Sw(m){if(m!==null&&typeof m=="object"){if(typeof m.then=="function")return Ox(m);if(m.$$typeof===N)return Hi(m)}throw Error(r(438,String(m)))}function _T(m){var b=null,S=Ln.updateQueue;if(S!==null&&(b=S.memoCache),b==null){var P=Ln.alternate;P!==null&&(P=P.updateQueue,P!==null&&(P=P.memoCache,P!=null&&(b={data:P.data.map(function(H){return H.slice()}),index:0})))}if(b==null&&(b={data:[],index:0}),S===null&&(S=ww(),Ln.updateQueue=S),S.memoCache=b,S=b.data[b.index],S===void 0)for(S=b.data[b.index]=Array(m),P=0;P<m;P++)S[P]=D;return b.index++,S}function iu(m,b){return typeof b=="function"?b(m):b}function _w(m){var b=$a();return NT(b,Lr,m)}function NT(m,b,S){var P=m.queue;if(P===null)throw Error(r(311));P.lastRenderedReducer=S;var H=m.baseQueue,X=P.pending;if(X!==null){if(H!==null){var ve=H.next;H.next=X.next,X.next=ve}b.baseQueue=H=X,P.pending=null}if(X=m.baseState,H===null)m.memoizedState=X;else{b=H.next;var Ie=ve=null,Xe=null,pt=b,kt=!1;do{var Pt=pt.lane&-536870913;if(Pt!==pt.lane?(sr&Pt)===Pt:(au&Pt)===Pt){var bt=pt.revertLane;if(bt===0)Xe!==null&&(Xe=Xe.next={lane:0,revertLane:0,gesture:null,action:pt.action,hasEagerState:pt.hasEagerState,eagerState:pt.eagerState,next:null}),Pt===Cp&&(kt=!0);else if((au&bt)===bt){pt=pt.next,bt===Cp&&(kt=!0);continue}else Pt={lane:0,revertLane:pt.revertLane,gesture:null,action:pt.action,hasEagerState:pt.hasEagerState,eagerState:pt.eagerState,next:null},Xe===null?(Ie=Xe=Pt,ve=X):Xe=Xe.next=Pt,Ln.lanes|=bt,Rd|=bt;Pt=pt.action,Am&&S(X,Pt),X=pt.hasEagerState?pt.eagerState:S(X,Pt)}else bt={lane:Pt,revertLane:pt.revertLane,gesture:pt.gesture,action:pt.action,hasEagerState:pt.hasEagerState,eagerState:pt.eagerState,next:null},Xe===null?(Ie=Xe=bt,ve=X):Xe=Xe.next=bt,Ln.lanes|=Pt,Rd|=Pt;pt=pt.next}while(pt!==null&&pt!==b);if(Xe===null?ve=X:Xe.next=Ie,!go(X,m.memoizedState)&&(Qa=!0,kt&&(S=Ap,S!==null)))throw S;m.memoizedState=X,m.baseState=ve,m.baseQueue=Xe,P.lastRenderedState=X}return H===null&&(P.lanes=0),[m.memoizedState,P.dispatch]}function kT(m){var b=$a(),S=b.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=m;var P=S.dispatch,H=S.pending,X=b.memoizedState;if(H!==null){S.pending=null;var ve=H=H.next;do X=m(X,ve.action),ve=ve.next;while(ve!==H);go(X,b.memoizedState)||(Qa=!0),b.memoizedState=X,b.baseQueue===null&&(b.baseState=X),S.lastRenderedState=X}return[X,P]}function w5(m,b,S){var P=Ln,H=$a(),X=lr;if(X){if(S===void 0)throw Error(r(407));S=S()}else S=b();var ve=!go((Lr||H).memoizedState,S);if(ve&&(H.memoizedState=S,Qa=!0),H=H.queue,TT(N5.bind(null,P,H,m),[m]),H.getSnapshot!==b||ve||Xa!==null&&Xa.memoizedState.tag&1){if(P.flags|=2048,Dp(9,{destroy:void 0},_5.bind(null,P,H,S,b),null),Wr===null)throw Error(r(349));X||(au&127)!==0||S5(P,b,S)}return S}function S5(m,b,S){m.flags|=16384,m={getSnapshot:b,value:S},b=Ln.updateQueue,b===null?(b=ww(),Ln.updateQueue=b,b.stores=[m]):(S=b.stores,S===null?b.stores=[m]:S.push(m))}function _5(m,b,S,P){b.value=S,b.getSnapshot=P,k5(b)&&C5(m)}function N5(m,b,S){return S(function(){k5(b)&&C5(m)})}function k5(m){var b=m.getSnapshot;m=m.value;try{var S=b();return!go(m,S)}catch{return!0}}function C5(m){var b=xm(m,2);b!==null&&Ys(b,m,2)}function CT(m){var b=Cs();if(typeof m=="function"){var S=m;if(m=S(),Am){ke(!0);try{S()}finally{ke(!1)}}}return b.memoizedState=b.baseState=m,b.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:iu,lastRenderedState:m},b}function A5(m,b,S,P){return m.baseState=S,NT(m,Lr,typeof P=="function"?P:iu)}function boe(m,b,S,P,H){if(Cw(m))throw Error(r(485));if(m=b.action,m!==null){var X={payload:H,action:m,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(ve){X.listeners.push(ve)}};ae.T!==null?S(!0):X.isTransition=!1,P(X),S=b.pending,S===null?(X.next=b.pending=X,T5(b,X)):(X.next=S.next,b.pending=S.next=X)}}function T5(m,b){var S=b.action,P=b.payload,H=m.state;if(b.isTransition){var X=ae.T,ve={};ae.T=ve;try{var Ie=S(H,P),Xe=ae.S;Xe!==null&&Xe(ve,Ie),M5(m,b,Ie)}catch(pt){AT(m,b,pt)}finally{X!==null&&ve.types!==null&&(X.types=ve.types),ae.T=X}}else try{X=S(H,P),M5(m,b,X)}catch(pt){AT(m,b,pt)}}function M5(m,b,S){S!==null&&typeof S=="object"&&typeof S.then=="function"?S.then(function(P){P5(m,b,P)},function(P){return AT(m,b,P)}):P5(m,b,S)}function P5(m,b,S){b.status="fulfilled",b.value=S,j5(b),m.state=S,b=m.pending,b!==null&&(S=b.next,S===b?m.pending=null:(S=S.next,b.next=S,T5(m,S)))}function AT(m,b,S){var P=m.pending;if(m.pending=null,P!==null){P=P.next;do b.status="rejected",b.reason=S,j5(b),b=b.next;while(b!==P)}m.action=null}function j5(m){m=m.listeners;for(var b=0;b<m.length;b++)(0,m[b])()}function E5(m,b){return b}function D5(m,b){if(lr){var S=Wr.formState;if(S!==null){e:{var P=Ln;if(lr){if(oa){t:{for(var H=oa,X=Go;H.nodeType!==8;){if(!X){H=null;break t}if(H=Ko(H.nextSibling),H===null){H=null;break t}}X=H.data,H=X==="F!"||X==="F"?H:null}if(H){oa=Ko(H.nextSibling),P=H.data==="F!";break e}}kd(P)}P=!1}P&&(b=S[0])}}return S=Cs(),S.memoizedState=S.baseState=b,P={pending:null,lanes:0,dispatch:null,lastRenderedReducer:E5,lastRenderedState:b},S.queue=P,S=Z5.bind(null,Ln,P),P.dispatch=S,P=CT(!1),X=DT.bind(null,Ln,!1,P.queue),P=Cs(),H={state:b,dispatch:null,action:m,pending:null},P.queue=H,S=boe.bind(null,Ln,H,X,S),H.dispatch=S,P.memoizedState=m,[b,S,!1]}function R5(m){var b=$a();return F5(b,Lr,m)}function F5(m,b,S){if(b=NT(m,b,E5)[0],m=_w(iu)[0],typeof b=="object"&&b!==null&&typeof b.then=="function")try{var P=Ox(b)}catch(ve){throw ve===Tp?mw:ve}else P=b;b=$a();var H=b.queue,X=H.dispatch;return S!==b.memoizedState&&(Ln.flags|=2048,Dp(9,{destroy:void 0},xoe.bind(null,H,S),null)),[P,X,m]}function xoe(m,b){m.action=b}function L5(m){var b=$a(),S=Lr;if(S!==null)return F5(b,S,m);$a(),b=b.memoizedState,S=$a();var P=S.queue.dispatch;return S.memoizedState=m,[b,P,!1]}function Dp(m,b,S,P){return m={tag:m,create:S,deps:P,inst:b,next:null},b=Ln.updateQueue,b===null&&(b=ww(),Ln.updateQueue=b),S=b.lastEffect,S===null?b.lastEffect=m.next=m:(P=S.next,S.next=m,m.next=P,b.lastEffect=m),m}function O5(){return $a().memoizedState}function Nw(m,b,S,P){var H=Cs();Ln.flags|=m,H.memoizedState=Dp(1|b,{destroy:void 0},S,P===void 0?null:P)}function kw(m,b,S,P){var H=$a();P=P===void 0?null:P;var X=H.memoizedState.inst;Lr!==null&&P!==null&&xT(P,Lr.memoizedState.deps)?H.memoizedState=Dp(b,X,S,P):(Ln.flags|=m,H.memoizedState=Dp(1|b,X,S,P))}function I5(m,b){Nw(8390656,8,m,b)}function TT(m,b){kw(2048,8,m,b)}function yoe(m){Ln.flags|=4;var b=Ln.updateQueue;if(b===null)b=ww(),Ln.updateQueue=b,b.events=[m];else{var S=b.events;S===null?b.events=[m]:S.push(m)}}function z5(m){var b=$a().memoizedState;return yoe({ref:b,nextImpl:m}),function(){if((vr&2)!==0)throw Error(r(440));return b.impl.apply(void 0,arguments)}}function U5(m,b){return kw(4,2,m,b)}function B5(m,b){return kw(4,4,m,b)}function H5(m,b){if(typeof b=="function"){m=m();var S=b(m);return function(){typeof S=="function"?S():b(null)}}if(b!=null)return m=m(),b.current=m,function(){b.current=null}}function $5(m,b,S){S=S!=null?S.concat([m]):null,kw(4,4,H5.bind(null,b,m),S)}function MT(){}function V5(m,b){var S=$a();b=b===void 0?null:b;var P=S.memoizedState;return b!==null&&xT(b,P[1])?P[0]:(S.memoizedState=[m,b],m)}function q5(m,b){var S=$a();b=b===void 0?null:b;var P=S.memoizedState;if(b!==null&&xT(b,P[1]))return P[0];if(P=m(),Am){ke(!0);try{m()}finally{ke(!1)}}return S.memoizedState=[P,b],P}function PT(m,b,S){return S===void 0||(au&1073741824)!==0&&(sr&261930)===0?m.memoizedState=b:(m.memoizedState=S,m=Gz(),Ln.lanes|=m,Rd|=m,S)}function G5(m,b,S,P){return go(S,b)?S:Pp.current!==null?(m=PT(m,S,P),go(m,b)||(Qa=!0),m):(au&42)===0||(au&1073741824)!==0&&(sr&261930)===0?(Qa=!0,m.memoizedState=S):(m=Gz(),Ln.lanes|=m,Rd|=m,b)}function W5(m,b,S,P,H){var X=Y.p;Y.p=X!==0&&8>X?X:8;var ve=ae.T,Ie={};ae.T=Ie,DT(m,!1,b,S);try{var Xe=H(),pt=ae.S;if(pt!==null&&pt(Ie,Xe),Xe!==null&&typeof Xe=="object"&&typeof Xe.then=="function"){var kt=foe(Xe,P);Ix(m,b,kt,So(m))}else Ix(m,b,P,So(m))}catch(Pt){Ix(m,b,{then:function(){},status:"rejected",reason:Pt},So())}finally{Y.p=X,ve!==null&&Ie.types!==null&&(ve.types=Ie.types),ae.T=ve}}function voe(){}function jT(m,b,S,P){if(m.tag!==5)throw Error(r(476));var H=K5(m).queue;W5(m,H,b,se,S===null?voe:function(){return Y5(m),S(P)})}function K5(m){var b=m.memoizedState;if(b!==null)return b;b={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:iu,lastRenderedState:se},next:null};var S={};return b.next={memoizedState:S,baseState:S,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:iu,lastRenderedState:S},next:null},m.memoizedState=b,m=m.alternate,m!==null&&(m.memoizedState=b),b}function Y5(m){var b=K5(m);b.next===null&&(b=m.alternate.memoizedState),Ix(m,b.next.queue,{},So())}function ET(){return Hi(ty)}function X5(){return $a().memoizedState}function Q5(){return $a().memoizedState}function woe(m){for(var b=m.return;b!==null;){switch(b.tag){case 24:case 3:var S=So();m=Td(S);var P=Md(b,m,S);P!==null&&(Ys(P,b,S),Dx(P,b,S)),b={cache:oT()},m.payload=b;return}b=b.return}}function Soe(m,b,S){var P=So();S={lane:P,revertLane:0,gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},Cw(m)?J5(b,S):(S=XA(m,b,S,P),S!==null&&(Ys(S,m,P),ez(S,b,P)))}function Z5(m,b,S){var P=So();Ix(m,b,S,P)}function Ix(m,b,S,P){var H={lane:P,revertLane:0,gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null};if(Cw(m))J5(b,H);else{var X=m.alternate;if(m.lanes===0&&(X===null||X.lanes===0)&&(X=b.lastRenderedReducer,X!==null))try{var ve=b.lastRenderedState,Ie=X(ve,S);if(H.hasEagerState=!0,H.eagerState=Ie,go(Ie,ve))return sw(m,b,H,0),Wr===null&&iw(),!1}catch{}if(S=XA(m,b,H,P),S!==null)return Ys(S,m,P),ez(S,b,P),!0}return!1}function DT(m,b,S,P){if(P={lane:2,revertLane:d2(),gesture:null,action:P,hasEagerState:!1,eagerState:null,next:null},Cw(m)){if(b)throw Error(r(479))}else b=XA(m,S,P,2),b!==null&&Ys(b,m,2)}function Cw(m){var b=m.alternate;return m===Ln||b!==null&&b===Ln}function J5(m,b){jp=yw=!0;var S=m.pending;S===null?b.next=b:(b.next=S.next,S.next=b),m.pending=b}function ez(m,b,S){if((S&4194048)!==0){var P=b.lanes;P&=m.pendingLanes,S|=P,b.lanes=S,dt(m,S)}}var zx={readContext:Hi,use:Sw,useCallback:Aa,useContext:Aa,useEffect:Aa,useImperativeHandle:Aa,useLayoutEffect:Aa,useInsertionEffect:Aa,useMemo:Aa,useReducer:Aa,useRef:Aa,useState:Aa,useDebugValue:Aa,useDeferredValue:Aa,useTransition:Aa,useSyncExternalStore:Aa,useId:Aa,useHostTransitionStatus:Aa,useFormState:Aa,useActionState:Aa,useOptimistic:Aa,useMemoCache:Aa,useCacheRefresh:Aa};zx.useEffectEvent=Aa;var tz={readContext:Hi,use:Sw,useCallback:function(m,b){return Cs().memoizedState=[m,b===void 0?null:b],m},useContext:Hi,useEffect:I5,useImperativeHandle:function(m,b,S){S=S!=null?S.concat([m]):null,Nw(4194308,4,H5.bind(null,b,m),S)},useLayoutEffect:function(m,b){return Nw(4194308,4,m,b)},useInsertionEffect:function(m,b){Nw(4,2,m,b)},useMemo:function(m,b){var S=Cs();b=b===void 0?null:b;var P=m();if(Am){ke(!0);try{m()}finally{ke(!1)}}return S.memoizedState=[P,b],P},useReducer:function(m,b,S){var P=Cs();if(S!==void 0){var H=S(b);if(Am){ke(!0);try{S(b)}finally{ke(!1)}}}else H=b;return P.memoizedState=P.baseState=H,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:m,lastRenderedState:H},P.queue=m,m=m.dispatch=Soe.bind(null,Ln,m),[P.memoizedState,m]},useRef:function(m){var b=Cs();return m={current:m},b.memoizedState=m},useState:function(m){m=CT(m);var b=m.queue,S=Z5.bind(null,Ln,b);return b.dispatch=S,[m.memoizedState,S]},useDebugValue:MT,useDeferredValue:function(m,b){var S=Cs();return PT(S,m,b)},useTransition:function(){var m=CT(!1);return m=W5.bind(null,Ln,m.queue,!0,!1),Cs().memoizedState=m,[!1,m]},useSyncExternalStore:function(m,b,S){var P=Ln,H=Cs();if(lr){if(S===void 0)throw Error(r(407));S=S()}else{if(S=b(),Wr===null)throw Error(r(349));(sr&127)!==0||S5(P,b,S)}H.memoizedState=S;var X={value:S,getSnapshot:b};return H.queue=X,I5(N5.bind(null,P,X,m),[m]),P.flags|=2048,Dp(9,{destroy:void 0},_5.bind(null,P,X,S,b),null),S},useId:function(){var m=Cs(),b=Wr.identifierPrefix;if(lr){var S=uc,P=cc;S=(P&~(1<<32-_e(P)-1)).toString(32)+S,b="_"+b+"R_"+S,S=vw++,0<S&&(b+="H"+S.toString(32)),b+="_"}else S=poe++,b="_"+b+"r_"+S.toString(32)+"_";return m.memoizedState=b},useHostTransitionStatus:ET,useFormState:D5,useActionState:D5,useOptimistic:function(m){var b=Cs();b.memoizedState=b.baseState=m;var S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return b.queue=S,b=DT.bind(null,Ln,!0,S),S.dispatch=b,[m,b]},useMemoCache:_T,useCacheRefresh:function(){return Cs().memoizedState=woe.bind(null,Ln)},useEffectEvent:function(m){var b=Cs(),S={impl:m};return b.memoizedState=S,function(){if((vr&2)!==0)throw Error(r(440));return S.impl.apply(void 0,arguments)}}},RT={readContext:Hi,use:Sw,useCallback:V5,useContext:Hi,useEffect:TT,useImperativeHandle:$5,useInsertionEffect:U5,useLayoutEffect:B5,useMemo:q5,useReducer:_w,useRef:O5,useState:function(){return _w(iu)},useDebugValue:MT,useDeferredValue:function(m,b){var S=$a();return G5(S,Lr.memoizedState,m,b)},useTransition:function(){var m=_w(iu)[0],b=$a().memoizedState;return[typeof m=="boolean"?m:Ox(m),b]},useSyncExternalStore:w5,useId:X5,useHostTransitionStatus:ET,useFormState:R5,useActionState:R5,useOptimistic:function(m,b){var S=$a();return A5(S,Lr,m,b)},useMemoCache:_T,useCacheRefresh:Q5};RT.useEffectEvent=z5;var nz={readContext:Hi,use:Sw,useCallback:V5,useContext:Hi,useEffect:TT,useImperativeHandle:$5,useInsertionEffect:U5,useLayoutEffect:B5,useMemo:q5,useReducer:kT,useRef:O5,useState:function(){return kT(iu)},useDebugValue:MT,useDeferredValue:function(m,b){var S=$a();return Lr===null?PT(S,m,b):G5(S,Lr.memoizedState,m,b)},useTransition:function(){var m=kT(iu)[0],b=$a().memoizedState;return[typeof m=="boolean"?m:Ox(m),b]},useSyncExternalStore:w5,useId:X5,useHostTransitionStatus:ET,useFormState:L5,useActionState:L5,useOptimistic:function(m,b){var S=$a();return Lr!==null?A5(S,Lr,m,b):(S.baseState=m,[m,S.queue.dispatch])},useMemoCache:_T,useCacheRefresh:Q5};nz.useEffectEvent=z5;function FT(m,b,S,P){b=m.memoizedState,S=S(P,b),S=S==null?b:h({},b,S),m.memoizedState=S,m.lanes===0&&(m.updateQueue.baseState=S)}var LT={enqueueSetState:function(m,b,S){m=m._reactInternals;var P=So(),H=Td(P);H.payload=b,S!=null&&(H.callback=S),b=Md(m,H,P),b!==null&&(Ys(b,m,P),Dx(b,m,P))},enqueueReplaceState:function(m,b,S){m=m._reactInternals;var P=So(),H=Td(P);H.tag=1,H.payload=b,S!=null&&(H.callback=S),b=Md(m,H,P),b!==null&&(Ys(b,m,P),Dx(b,m,P))},enqueueForceUpdate:function(m,b){m=m._reactInternals;var S=So(),P=Td(S);P.tag=2,b!=null&&(P.callback=b),b=Md(m,P,S),b!==null&&(Ys(b,m,S),Dx(b,m,S))}};function rz(m,b,S,P,H,X,ve){return m=m.stateNode,typeof m.shouldComponentUpdate=="function"?m.shouldComponentUpdate(P,X,ve):b.prototype&&b.prototype.isPureReactComponent?!kx(S,P)||!kx(H,X):!0}function az(m,b,S,P){m=b.state,typeof b.componentWillReceiveProps=="function"&&b.componentWillReceiveProps(S,P),typeof b.UNSAFE_componentWillReceiveProps=="function"&&b.UNSAFE_componentWillReceiveProps(S,P),b.state!==m&&LT.enqueueReplaceState(b,b.state,null)}function Tm(m,b){var S=b;if("ref"in b){S={};for(var P in b)P!=="ref"&&(S[P]=b[P])}if(m=m.defaultProps){S===b&&(S=h({},S));for(var H in m)S[H]===void 0&&(S[H]=m[H])}return S}function iz(m){aw(m)}function sz(m){console.error(m)}function oz(m){aw(m)}function Aw(m,b){try{var S=m.onUncaughtError;S(b.value,{componentStack:b.stack})}catch(P){setTimeout(function(){throw P})}}function lz(m,b,S){try{var P=m.onCaughtError;P(S.value,{componentStack:S.stack,errorBoundary:b.tag===1?b.stateNode:null})}catch(H){setTimeout(function(){throw H})}}function OT(m,b,S){return S=Td(S),S.tag=3,S.payload={element:null},S.callback=function(){Aw(m,b)},S}function cz(m){return m=Td(m),m.tag=3,m}function uz(m,b,S,P){var H=S.type.getDerivedStateFromError;if(typeof H=="function"){var X=P.value;m.payload=function(){return H(X)},m.callback=function(){lz(b,S,P)}}var ve=S.stateNode;ve!==null&&typeof ve.componentDidCatch=="function"&&(m.callback=function(){lz(b,S,P),typeof H!="function"&&(Fd===null?Fd=new Set([this]):Fd.add(this));var Ie=P.stack;this.componentDidCatch(P.value,{componentStack:Ie!==null?Ie:""})})}function _oe(m,b,S,P,H){if(S.flags|=32768,P!==null&&typeof P=="object"&&typeof P.then=="function"){if(b=S.alternate,b!==null&&kp(b,S,H,!0),S=xo.current,S!==null){switch(S.tag){case 31:case 13:return Wo===null?zw():S.alternate===null&&Ta===0&&(Ta=3),S.flags&=-257,S.flags|=65536,S.lanes=H,P===fw?S.flags|=16384:(b=S.updateQueue,b===null?S.updateQueue=new Set([P]):b.add(P),l2(m,P,H)),!1;case 22:return S.flags|=65536,P===fw?S.flags|=16384:(b=S.updateQueue,b===null?(b={transitions:null,markerInstances:null,retryQueue:new Set([P])},S.updateQueue=b):(S=b.retryQueue,S===null?b.retryQueue=new Set([P]):S.add(P)),l2(m,P,H)),!1}throw Error(r(435,S.tag))}return l2(m,P,H),zw(),!1}if(lr)return b=xo.current,b!==null?((b.flags&65536)===0&&(b.flags|=256),b.flags|=65536,b.lanes=H,P!==nT&&(m=Error(r(422),{cause:P}),Tx($o(m,S)))):(P!==nT&&(b=Error(r(423),{cause:P}),Tx($o(b,S))),m=m.current.alternate,m.flags|=65536,H&=-H,m.lanes|=H,P=$o(P,S),H=OT(m.stateNode,P,H),mT(m,H),Ta!==4&&(Ta=2)),!1;var X=Error(r(520),{cause:P});if(X=$o(X,S),Wx===null?Wx=[X]:Wx.push(X),Ta!==4&&(Ta=2),b===null)return!0;P=$o(P,S),S=b;do{switch(S.tag){case 3:return S.flags|=65536,m=H&-H,S.lanes|=m,m=OT(S.stateNode,P,m),mT(S,m),!1;case 1:if(b=S.type,X=S.stateNode,(S.flags&128)===0&&(typeof b.getDerivedStateFromError=="function"||X!==null&&typeof X.componentDidCatch=="function"&&(Fd===null||!Fd.has(X))))return S.flags|=65536,H&=-H,S.lanes|=H,H=cz(H),uz(H,m,S,P),mT(S,H),!1}S=S.return}while(S!==null);return!1}var IT=Error(r(461)),Qa=!1;function $i(m,b,S,P){b.child=m===null?f5(b,null,S,P):Cm(b,m.child,S,P)}function dz(m,b,S,P,H){S=S.render;var X=b.ref;if("ref"in P){var ve={};for(var Ie in P)Ie!=="ref"&&(ve[Ie]=P[Ie])}else ve=P;return Sm(b),P=yT(m,b,S,ve,X,H),Ie=vT(),m!==null&&!Qa?(wT(m,b,H),su(m,b,H)):(lr&&Ie&&eT(b),b.flags|=1,$i(m,b,P,H),b.child)}function hz(m,b,S,P,H){if(m===null){var X=S.type;return typeof X=="function"&&!QA(X)&&X.defaultProps===void 0&&S.compare===null?(b.tag=15,b.type=X,mz(m,b,X,P,H)):(m=lw(S.type,null,P,b,b.mode,H),m.ref=b.ref,m.return=b,b.child=m)}if(X=m.child,!GT(m,H)){var ve=X.memoizedProps;if(S=S.compare,S=S!==null?S:kx,S(ve,P)&&m.ref===b.ref)return su(m,b,H)}return b.flags|=1,m=eu(X,P),m.ref=b.ref,m.return=b,b.child=m}function mz(m,b,S,P,H){if(m!==null){var X=m.memoizedProps;if(kx(X,P)&&m.ref===b.ref)if(Qa=!1,b.pendingProps=P=X,GT(m,H))(m.flags&131072)!==0&&(Qa=!0);else return b.lanes=m.lanes,su(m,b,H)}return zT(m,b,S,P,H)}function fz(m,b,S,P){var H=P.children,X=m!==null?m.memoizedState:null;if(m===null&&b.stateNode===null&&(b.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),P.mode==="hidden"){if((b.flags&128)!==0){if(X=X!==null?X.baseLanes|S:S,m!==null){for(P=b.child=m.child,H=0;P!==null;)H=H|P.lanes|P.childLanes,P=P.sibling;P=H&~X}else P=0,b.child=null;return pz(m,b,X,S,P)}if((S&536870912)!==0)b.memoizedState={baseLanes:0,cachePool:null},m!==null&&hw(b,X!==null?X.cachePool:null),X!==null?b5(b,X):pT(),x5(b);else return P=b.lanes=536870912,pz(m,b,X!==null?X.baseLanes|S:S,S,P)}else X!==null?(hw(b,X.cachePool),b5(b,X),jd(),b.memoizedState=null):(m!==null&&hw(b,null),pT(),jd());return $i(m,b,H,S),b.child}function Ux(m,b){return m!==null&&m.tag===22||b.stateNode!==null||(b.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),b.sibling}function pz(m,b,S,P,H){var X=cT();return X=X===null?null:{parent:Ya._currentValue,pool:X},b.memoizedState={baseLanes:S,cachePool:X},m!==null&&hw(b,null),pT(),x5(b),m!==null&&kp(m,b,P,!0),b.childLanes=H,null}function Tw(m,b){return b=Pw({mode:b.mode,children:b.children},m.mode),b.ref=m.ref,m.child=b,b.return=m,b}function gz(m,b,S){return Cm(b,m.child,null,S),m=Tw(b,b.pendingProps),m.flags|=2,yo(b),b.memoizedState=null,m}function Noe(m,b,S){var P=b.pendingProps,H=(b.flags&128)!==0;if(b.flags&=-129,m===null){if(lr){if(P.mode==="hidden")return m=Tw(b,P),b.lanes=536870912,Ux(null,m);if(bT(b),(m=oa)?(m=TU(m,Go),m=m!==null&&m.data==="&"?m:null,m!==null&&(b.memoizedState={dehydrated:m,treeContext:_d!==null?{id:cc,overflow:uc}:null,retryLane:536870912,hydrationErrors:null},S=JI(m),S.return=b,b.child=S,Bi=b,oa=null)):m=null,m===null)throw kd(b);return b.lanes=536870912,null}return Tw(b,P)}var X=m.memoizedState;if(X!==null){var ve=X.dehydrated;if(bT(b),H)if(b.flags&256)b.flags&=-257,b=gz(m,b,S);else if(b.memoizedState!==null)b.child=m.child,b.flags|=128,b=null;else throw Error(r(558));else if(Qa||kp(m,b,S,!1),H=(S&m.childLanes)!==0,Qa||H){if(P=Wr,P!==null&&(ve=gt(P,S),ve!==0&&ve!==X.retryLane))throw X.retryLane=ve,xm(m,ve),Ys(P,m,ve),IT;zw(),b=gz(m,b,S)}else m=X.treeContext,oa=Ko(ve.nextSibling),Bi=b,lr=!0,Nd=null,Go=!1,m!==null&&n5(b,m),b=Tw(b,P),b.flags|=4096;return b}return m=eu(m.child,{mode:P.mode,children:P.children}),m.ref=b.ref,b.child=m,m.return=b,m}function Mw(m,b){var S=b.ref;if(S===null)m!==null&&m.ref!==null&&(b.flags|=4194816);else{if(typeof S!="function"&&typeof S!="object")throw Error(r(284));(m===null||m.ref!==S)&&(b.flags|=4194816)}}function zT(m,b,S,P,H){return Sm(b),S=yT(m,b,S,P,void 0,H),P=vT(),m!==null&&!Qa?(wT(m,b,H),su(m,b,H)):(lr&&P&&eT(b),b.flags|=1,$i(m,b,S,H),b.child)}function bz(m,b,S,P,H,X){return Sm(b),b.updateQueue=null,S=v5(b,P,S,H),y5(m),P=vT(),m!==null&&!Qa?(wT(m,b,X),su(m,b,X)):(lr&&P&&eT(b),b.flags|=1,$i(m,b,S,X),b.child)}function xz(m,b,S,P,H){if(Sm(b),b.stateNode===null){var X=wp,ve=S.contextType;typeof ve=="object"&&ve!==null&&(X=Hi(ve)),X=new S(P,X),b.memoizedState=X.state!==null&&X.state!==void 0?X.state:null,X.updater=LT,b.stateNode=X,X._reactInternals=b,X=b.stateNode,X.props=P,X.state=b.memoizedState,X.refs={},dT(b),ve=S.contextType,X.context=typeof ve=="object"&&ve!==null?Hi(ve):wp,X.state=b.memoizedState,ve=S.getDerivedStateFromProps,typeof ve=="function"&&(FT(b,S,ve,P),X.state=b.memoizedState),typeof S.getDerivedStateFromProps=="function"||typeof X.getSnapshotBeforeUpdate=="function"||typeof X.UNSAFE_componentWillMount!="function"&&typeof X.componentWillMount!="function"||(ve=X.state,typeof X.componentWillMount=="function"&&X.componentWillMount(),typeof X.UNSAFE_componentWillMount=="function"&&X.UNSAFE_componentWillMount(),ve!==X.state&&LT.enqueueReplaceState(X,X.state,null),Fx(b,P,X,H),Rx(),X.state=b.memoizedState),typeof X.componentDidMount=="function"&&(b.flags|=4194308),P=!0}else if(m===null){X=b.stateNode;var Ie=b.memoizedProps,Xe=Tm(S,Ie);X.props=Xe;var pt=X.context,kt=S.contextType;ve=wp,typeof kt=="object"&&kt!==null&&(ve=Hi(kt));var Pt=S.getDerivedStateFromProps;kt=typeof Pt=="function"||typeof X.getSnapshotBeforeUpdate=="function",Ie=b.pendingProps!==Ie,kt||typeof X.UNSAFE_componentWillReceiveProps!="function"&&typeof X.componentWillReceiveProps!="function"||(Ie||pt!==ve)&&az(b,X,P,ve),Ad=!1;var bt=b.memoizedState;X.state=bt,Fx(b,P,X,H),Rx(),pt=b.memoizedState,Ie||bt!==pt||Ad?(typeof Pt=="function"&&(FT(b,S,Pt,P),pt=b.memoizedState),(Xe=Ad||rz(b,S,Xe,P,bt,pt,ve))?(kt||typeof X.UNSAFE_componentWillMount!="function"&&typeof X.componentWillMount!="function"||(typeof X.componentWillMount=="function"&&X.componentWillMount(),typeof X.UNSAFE_componentWillMount=="function"&&X.UNSAFE_componentWillMount()),typeof X.componentDidMount=="function"&&(b.flags|=4194308)):(typeof X.componentDidMount=="function"&&(b.flags|=4194308),b.memoizedProps=P,b.memoizedState=pt),X.props=P,X.state=pt,X.context=ve,P=Xe):(typeof X.componentDidMount=="function"&&(b.flags|=4194308),P=!1)}else{X=b.stateNode,hT(m,b),ve=b.memoizedProps,kt=Tm(S,ve),X.props=kt,Pt=b.pendingProps,bt=X.context,pt=S.contextType,Xe=wp,typeof pt=="object"&&pt!==null&&(Xe=Hi(pt)),Ie=S.getDerivedStateFromProps,(pt=typeof Ie=="function"||typeof X.getSnapshotBeforeUpdate=="function")||typeof X.UNSAFE_componentWillReceiveProps!="function"&&typeof X.componentWillReceiveProps!="function"||(ve!==Pt||bt!==Xe)&&az(b,X,P,Xe),Ad=!1,bt=b.memoizedState,X.state=bt,Fx(b,P,X,H),Rx();var wt=b.memoizedState;ve!==Pt||bt!==wt||Ad||m!==null&&m.dependencies!==null&&uw(m.dependencies)?(typeof Ie=="function"&&(FT(b,S,Ie,P),wt=b.memoizedState),(kt=Ad||rz(b,S,kt,P,bt,wt,Xe)||m!==null&&m.dependencies!==null&&uw(m.dependencies))?(pt||typeof X.UNSAFE_componentWillUpdate!="function"&&typeof X.componentWillUpdate!="function"||(typeof X.componentWillUpdate=="function"&&X.componentWillUpdate(P,wt,Xe),typeof X.UNSAFE_componentWillUpdate=="function"&&X.UNSAFE_componentWillUpdate(P,wt,Xe)),typeof X.componentDidUpdate=="function"&&(b.flags|=4),typeof X.getSnapshotBeforeUpdate=="function"&&(b.flags|=1024)):(typeof X.componentDidUpdate!="function"||ve===m.memoizedProps&&bt===m.memoizedState||(b.flags|=4),typeof X.getSnapshotBeforeUpdate!="function"||ve===m.memoizedProps&&bt===m.memoizedState||(b.flags|=1024),b.memoizedProps=P,b.memoizedState=wt),X.props=P,X.state=wt,X.context=Xe,P=kt):(typeof X.componentDidUpdate!="function"||ve===m.memoizedProps&&bt===m.memoizedState||(b.flags|=4),typeof X.getSnapshotBeforeUpdate!="function"||ve===m.memoizedProps&&bt===m.memoizedState||(b.flags|=1024),P=!1)}return X=P,Mw(m,b),P=(b.flags&128)!==0,X||P?(X=b.stateNode,S=P&&typeof S.getDerivedStateFromError!="function"?null:X.render(),b.flags|=1,m!==null&&P?(b.child=Cm(b,m.child,null,H),b.child=Cm(b,null,S,H)):$i(m,b,S,H),b.memoizedState=X.state,m=b.child):m=su(m,b,H),m}function yz(m,b,S,P){return vm(),b.flags|=256,$i(m,b,S,P),b.child}var UT={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function BT(m){return{baseLanes:m,cachePool:l5()}}function HT(m,b,S){return m=m!==null?m.childLanes&~S:0,b&&(m|=wo),m}function vz(m,b,S){var P=b.pendingProps,H=!1,X=(b.flags&128)!==0,ve;if((ve=X)||(ve=m!==null&&m.memoizedState===null?!1:(Ha.current&2)!==0),ve&&(H=!0,b.flags&=-129),ve=(b.flags&32)!==0,b.flags&=-33,m===null){if(lr){if(H?Pd(b):jd(),(m=oa)?(m=TU(m,Go),m=m!==null&&m.data!=="&"?m:null,m!==null&&(b.memoizedState={dehydrated:m,treeContext:_d!==null?{id:cc,overflow:uc}:null,retryLane:536870912,hydrationErrors:null},S=JI(m),S.return=b,b.child=S,Bi=b,oa=null)):m=null,m===null)throw kd(b);return N2(m)?b.lanes=32:b.lanes=536870912,null}var Ie=P.children;return P=P.fallback,H?(jd(),H=b.mode,Ie=Pw({mode:"hidden",children:Ie},H),P=ym(P,H,S,null),Ie.return=b,P.return=b,Ie.sibling=P,b.child=Ie,P=b.child,P.memoizedState=BT(S),P.childLanes=HT(m,ve,S),b.memoizedState=UT,Ux(null,P)):(Pd(b),$T(b,Ie))}var Xe=m.memoizedState;if(Xe!==null&&(Ie=Xe.dehydrated,Ie!==null)){if(X)b.flags&256?(Pd(b),b.flags&=-257,b=VT(m,b,S)):b.memoizedState!==null?(jd(),b.child=m.child,b.flags|=128,b=null):(jd(),Ie=P.fallback,H=b.mode,P=Pw({mode:"visible",children:P.children},H),Ie=ym(Ie,H,S,null),Ie.flags|=2,P.return=b,Ie.return=b,P.sibling=Ie,b.child=P,Cm(b,m.child,null,S),P=b.child,P.memoizedState=BT(S),P.childLanes=HT(m,ve,S),b.memoizedState=UT,b=Ux(null,P));else if(Pd(b),N2(Ie)){if(ve=Ie.nextSibling&&Ie.nextSibling.dataset,ve)var pt=ve.dgst;ve=pt,P=Error(r(419)),P.stack="",P.digest=ve,Tx({value:P,source:null,stack:null}),b=VT(m,b,S)}else if(Qa||kp(m,b,S,!1),ve=(S&m.childLanes)!==0,Qa||ve){if(ve=Wr,ve!==null&&(P=gt(ve,S),P!==0&&P!==Xe.retryLane))throw Xe.retryLane=P,xm(m,P),Ys(ve,m,P),IT;_2(Ie)||zw(),b=VT(m,b,S)}else _2(Ie)?(b.flags|=192,b.child=m.child,b=null):(m=Xe.treeContext,oa=Ko(Ie.nextSibling),Bi=b,lr=!0,Nd=null,Go=!1,m!==null&&n5(b,m),b=$T(b,P.children),b.flags|=4096);return b}return H?(jd(),Ie=P.fallback,H=b.mode,Xe=m.child,pt=Xe.sibling,P=eu(Xe,{mode:"hidden",children:P.children}),P.subtreeFlags=Xe.subtreeFlags&65011712,pt!==null?Ie=eu(pt,Ie):(Ie=ym(Ie,H,S,null),Ie.flags|=2),Ie.return=b,P.return=b,P.sibling=Ie,b.child=P,Ux(null,P),P=b.child,Ie=m.child.memoizedState,Ie===null?Ie=BT(S):(H=Ie.cachePool,H!==null?(Xe=Ya._currentValue,H=H.parent!==Xe?{parent:Xe,pool:Xe}:H):H=l5(),Ie={baseLanes:Ie.baseLanes|S,cachePool:H}),P.memoizedState=Ie,P.childLanes=HT(m,ve,S),b.memoizedState=UT,Ux(m.child,P)):(Pd(b),S=m.child,m=S.sibling,S=eu(S,{mode:"visible",children:P.children}),S.return=b,S.sibling=null,m!==null&&(ve=b.deletions,ve===null?(b.deletions=[m],b.flags|=16):ve.push(m)),b.child=S,b.memoizedState=null,S)}function $T(m,b){return b=Pw({mode:"visible",children:b},m.mode),b.return=m,m.child=b}function Pw(m,b){return m=bo(22,m,null,b),m.lanes=0,m}function VT(m,b,S){return Cm(b,m.child,null,S),m=$T(b,b.pendingProps.children),m.flags|=2,b.memoizedState=null,m}function wz(m,b,S){m.lanes|=b;var P=m.alternate;P!==null&&(P.lanes|=b),iT(m.return,b,S)}function qT(m,b,S,P,H,X){var ve=m.memoizedState;ve===null?m.memoizedState={isBackwards:b,rendering:null,renderingStartTime:0,last:P,tail:S,tailMode:H,treeForkCount:X}:(ve.isBackwards=b,ve.rendering=null,ve.renderingStartTime=0,ve.last=P,ve.tail=S,ve.tailMode=H,ve.treeForkCount=X)}function Sz(m,b,S){var P=b.pendingProps,H=P.revealOrder,X=P.tail;P=P.children;var ve=Ha.current,Ie=(ve&2)!==0;if(Ie?(ve=ve&1|2,b.flags|=128):ve&=1,pe(Ha,ve),$i(m,b,P,S),P=lr?Ax:0,!Ie&&m!==null&&(m.flags&128)!==0)e:for(m=b.child;m!==null;){if(m.tag===13)m.memoizedState!==null&&wz(m,S,b);else if(m.tag===19)wz(m,S,b);else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===b)break e;for(;m.sibling===null;){if(m.return===null||m.return===b)break e;m=m.return}m.sibling.return=m.return,m=m.sibling}switch(H){case"forwards":for(S=b.child,H=null;S!==null;)m=S.alternate,m!==null&&xw(m)===null&&(H=S),S=S.sibling;S=H,S===null?(H=b.child,b.child=null):(H=S.sibling,S.sibling=null),qT(b,!1,H,S,X,P);break;case"backwards":case"unstable_legacy-backwards":for(S=null,H=b.child,b.child=null;H!==null;){if(m=H.alternate,m!==null&&xw(m)===null){b.child=H;break}m=H.sibling,H.sibling=S,S=H,H=m}qT(b,!0,S,null,X,P);break;case"together":qT(b,!1,null,null,void 0,P);break;default:b.memoizedState=null}return b.child}function su(m,b,S){if(m!==null&&(b.dependencies=m.dependencies),Rd|=b.lanes,(S&b.childLanes)===0)if(m!==null){if(kp(m,b,S,!1),(S&b.childLanes)===0)return null}else return null;if(m!==null&&b.child!==m.child)throw Error(r(153));if(b.child!==null){for(m=b.child,S=eu(m,m.pendingProps),b.child=S,S.return=b;m.sibling!==null;)m=m.sibling,S=S.sibling=eu(m,m.pendingProps),S.return=b;S.sibling=null}return b.child}function GT(m,b){return(m.lanes&b)!==0?!0:(m=m.dependencies,!!(m!==null&&uw(m)))}function koe(m,b,S){switch(b.tag){case 3:T(b,b.stateNode.containerInfo),Cd(b,Ya,m.memoizedState.cache),vm();break;case 27:case 5:O(b);break;case 4:T(b,b.stateNode.containerInfo);break;case 10:Cd(b,b.type,b.memoizedProps.value);break;case 31:if(b.memoizedState!==null)return b.flags|=128,bT(b),null;break;case 13:var P=b.memoizedState;if(P!==null)return P.dehydrated!==null?(Pd(b),b.flags|=128,null):(S&b.child.childLanes)!==0?vz(m,b,S):(Pd(b),m=su(m,b,S),m!==null?m.sibling:null);Pd(b);break;case 19:var H=(m.flags&128)!==0;if(P=(S&b.childLanes)!==0,P||(kp(m,b,S,!1),P=(S&b.childLanes)!==0),H){if(P)return Sz(m,b,S);b.flags|=128}if(H=b.memoizedState,H!==null&&(H.rendering=null,H.tail=null,H.lastEffect=null),pe(Ha,Ha.current),P)break;return null;case 22:return b.lanes=0,fz(m,b,S,b.pendingProps);case 24:Cd(b,Ya,m.memoizedState.cache)}return su(m,b,S)}function _z(m,b,S){if(m!==null)if(m.memoizedProps!==b.pendingProps)Qa=!0;else{if(!GT(m,S)&&(b.flags&128)===0)return Qa=!1,koe(m,b,S);Qa=(m.flags&131072)!==0}else Qa=!1,lr&&(b.flags&1048576)!==0&&t5(b,Ax,b.index);switch(b.lanes=0,b.tag){case 16:e:{var P=b.pendingProps;if(m=Nm(b.elementType),b.type=m,typeof m=="function")QA(m)?(P=Tm(m,P),b.tag=1,b=xz(null,b,m,P,S)):(b.tag=0,b=zT(null,b,m,P,S));else{if(m!=null){var H=m.$$typeof;if(H===A){b.tag=11,b=dz(null,b,m,P,S);break e}else if(H===k){b.tag=14,b=hz(null,b,m,P,S);break e}}throw b=L(m)||m,Error(r(306,b,""))}}return b;case 0:return zT(m,b,b.type,b.pendingProps,S);case 1:return P=b.type,H=Tm(P,b.pendingProps),xz(m,b,P,H,S);case 3:e:{if(T(b,b.stateNode.containerInfo),m===null)throw Error(r(387));P=b.pendingProps;var X=b.memoizedState;H=X.element,hT(m,b),Fx(b,P,null,S);var ve=b.memoizedState;if(P=ve.cache,Cd(b,Ya,P),P!==X.cache&&sT(b,[Ya],S,!0),Rx(),P=ve.element,X.isDehydrated)if(X={element:P,isDehydrated:!1,cache:ve.cache},b.updateQueue.baseState=X,b.memoizedState=X,b.flags&256){b=yz(m,b,P,S);break e}else if(P!==H){H=$o(Error(r(424)),b),Tx(H),b=yz(m,b,P,S);break e}else for(m=b.stateNode.containerInfo,m.nodeType===9?m=m.body:m=m.nodeName==="HTML"?m.ownerDocument.body:m,oa=Ko(m.firstChild),Bi=b,lr=!0,Nd=null,Go=!0,S=f5(b,null,P,S),b.child=S;S;)S.flags=S.flags&-3|4096,S=S.sibling;else{if(vm(),P===H){b=su(m,b,S);break e}$i(m,b,P,S)}b=b.child}return b;case 26:return Mw(m,b),m===null?(S=RU(b.type,null,b.pendingProps,null))?b.memoizedState=S:lr||(S=b.type,m=b.pendingProps,P=Gw($.current).createElement(S),P[gn]=b,P[On]=m,Vi(P,S,m),Qe(P),b.stateNode=P):b.memoizedState=RU(b.type,m.memoizedProps,b.pendingProps,m.memoizedState),null;case 27:return O(b),m===null&&lr&&(P=b.stateNode=jU(b.type,b.pendingProps,$.current),Bi=b,Go=!0,H=oa,zd(b.type)?(k2=H,oa=Ko(P.firstChild)):oa=H),$i(m,b,b.pendingProps.children,S),Mw(m,b),m===null&&(b.flags|=4194304),b.child;case 5:return m===null&&lr&&((H=P=oa)&&(P=tle(P,b.type,b.pendingProps,Go),P!==null?(b.stateNode=P,Bi=b,oa=Ko(P.firstChild),Go=!1,H=!0):H=!1),H||kd(b)),O(b),H=b.type,X=b.pendingProps,ve=m!==null?m.memoizedProps:null,P=X.children,v2(H,X)?P=null:ve!==null&&v2(H,ve)&&(b.flags|=32),b.memoizedState!==null&&(H=yT(m,b,goe,null,null,S),ty._currentValue=H),Mw(m,b),$i(m,b,P,S),b.child;case 6:return m===null&&lr&&((m=S=oa)&&(S=nle(S,b.pendingProps,Go),S!==null?(b.stateNode=S,Bi=b,oa=null,m=!0):m=!1),m||kd(b)),null;case 13:return vz(m,b,S);case 4:return T(b,b.stateNode.containerInfo),P=b.pendingProps,m===null?b.child=Cm(b,null,P,S):$i(m,b,P,S),b.child;case 11:return dz(m,b,b.type,b.pendingProps,S);case 7:return $i(m,b,b.pendingProps,S),b.child;case 8:return $i(m,b,b.pendingProps.children,S),b.child;case 12:return $i(m,b,b.pendingProps.children,S),b.child;case 10:return P=b.pendingProps,Cd(b,b.type,P.value),$i(m,b,P.children,S),b.child;case 9:return H=b.type._context,P=b.pendingProps.children,Sm(b),H=Hi(H),P=P(H),b.flags|=1,$i(m,b,P,S),b.child;case 14:return hz(m,b,b.type,b.pendingProps,S);case 15:return mz(m,b,b.type,b.pendingProps,S);case 19:return Sz(m,b,S);case 31:return Noe(m,b,S);case 22:return fz(m,b,S,b.pendingProps);case 24:return Sm(b),P=Hi(Ya),m===null?(H=cT(),H===null&&(H=Wr,X=oT(),H.pooledCache=X,X.refCount++,X!==null&&(H.pooledCacheLanes|=S),H=X),b.memoizedState={parent:P,cache:H},dT(b),Cd(b,Ya,H)):((m.lanes&S)!==0&&(hT(m,b),Fx(b,null,null,S),Rx()),H=m.memoizedState,X=b.memoizedState,H.parent!==P?(H={parent:P,cache:P},b.memoizedState=H,b.lanes===0&&(b.memoizedState=b.updateQueue.baseState=H),Cd(b,Ya,P)):(P=X.cache,Cd(b,Ya,P),P!==H.cache&&sT(b,[Ya],S,!0))),$i(m,b,b.pendingProps.children,S),b.child;case 29:throw b.pendingProps}throw Error(r(156,b.tag))}function ou(m){m.flags|=4}function WT(m,b,S,P,H){if((b=(m.mode&32)!==0)&&(b=!1),b){if(m.flags|=16777216,(H&335544128)===H)if(m.stateNode.complete)m.flags|=8192;else if(Xz())m.flags|=8192;else throw km=fw,uT}else m.flags&=-16777217}function Nz(m,b){if(b.type!=="stylesheet"||(b.state.loading&4)!==0)m.flags&=-16777217;else if(m.flags|=16777216,!zU(b))if(Xz())m.flags|=8192;else throw km=fw,uT}function jw(m,b){b!==null&&(m.flags|=4),m.flags&16384&&(b=m.tag!==22?ct():536870912,m.lanes|=b,Op|=b)}function Bx(m,b){if(!lr)switch(m.tailMode){case"hidden":b=m.tail;for(var S=null;b!==null;)b.alternate!==null&&(S=b),b=b.sibling;S===null?m.tail=null:S.sibling=null;break;case"collapsed":S=m.tail;for(var P=null;S!==null;)S.alternate!==null&&(P=S),S=S.sibling;P===null?b||m.tail===null?m.tail=null:m.tail.sibling=null:P.sibling=null}}function la(m){var b=m.alternate!==null&&m.alternate.child===m.child,S=0,P=0;if(b)for(var H=m.child;H!==null;)S|=H.lanes|H.childLanes,P|=H.subtreeFlags&65011712,P|=H.flags&65011712,H.return=m,H=H.sibling;else for(H=m.child;H!==null;)S|=H.lanes|H.childLanes,P|=H.subtreeFlags,P|=H.flags,H.return=m,H=H.sibling;return m.subtreeFlags|=P,m.childLanes=S,b}function Coe(m,b,S){var P=b.pendingProps;switch(tT(b),b.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return la(b),null;case 1:return la(b),null;case 3:return S=b.stateNode,P=null,m!==null&&(P=m.memoizedState.cache),b.memoizedState.cache!==P&&(b.flags|=2048),ru(Ya),E(),S.pendingContext&&(S.context=S.pendingContext,S.pendingContext=null),(m===null||m.child===null)&&(Np(b)?ou(b):m===null||m.memoizedState.isDehydrated&&(b.flags&256)===0||(b.flags|=1024,rT())),la(b),null;case 26:var H=b.type,X=b.memoizedState;return m===null?(ou(b),X!==null?(la(b),Nz(b,X)):(la(b),WT(b,H,null,P,S))):X?X!==m.memoizedState?(ou(b),la(b),Nz(b,X)):(la(b),b.flags&=-16777217):(m=m.memoizedProps,m!==P&&ou(b),la(b),WT(b,H,m,P,S)),null;case 27:if(q(b),S=$.current,H=b.type,m!==null&&b.stateNode!=null)m.memoizedProps!==P&&ou(b);else{if(!P){if(b.stateNode===null)throw Error(r(166));return la(b),null}m=be.current,Np(b)?r5(b):(m=jU(H,P,S),b.stateNode=m,ou(b))}return la(b),null;case 5:if(q(b),H=b.type,m!==null&&b.stateNode!=null)m.memoizedProps!==P&&ou(b);else{if(!P){if(b.stateNode===null)throw Error(r(166));return la(b),null}if(X=be.current,Np(b))r5(b);else{var ve=Gw($.current);switch(X){case 1:X=ve.createElementNS("http://www.w3.org/2000/svg",H);break;case 2:X=ve.createElementNS("http://www.w3.org/1998/Math/MathML",H);break;default:switch(H){case"svg":X=ve.createElementNS("http://www.w3.org/2000/svg",H);break;case"math":X=ve.createElementNS("http://www.w3.org/1998/Math/MathML",H);break;case"script":X=ve.createElement("div"),X.innerHTML="<script><\/script>",X=X.removeChild(X.firstChild);break;case"select":X=typeof P.is=="string"?ve.createElement("select",{is:P.is}):ve.createElement("select"),P.multiple?X.multiple=!0:P.size&&(X.size=P.size);break;default:X=typeof P.is=="string"?ve.createElement(H,{is:P.is}):ve.createElement(H)}}X[gn]=b,X[On]=P;e:for(ve=b.child;ve!==null;){if(ve.tag===5||ve.tag===6)X.appendChild(ve.stateNode);else if(ve.tag!==4&&ve.tag!==27&&ve.child!==null){ve.child.return=ve,ve=ve.child;continue}if(ve===b)break e;for(;ve.sibling===null;){if(ve.return===null||ve.return===b)break e;ve=ve.return}ve.sibling.return=ve.return,ve=ve.sibling}b.stateNode=X;e:switch(Vi(X,H,P),H){case"button":case"input":case"select":case"textarea":P=!!P.autoFocus;break e;case"img":P=!0;break e;default:P=!1}P&&ou(b)}}return la(b),WT(b,b.type,m===null?null:m.memoizedProps,b.pendingProps,S),null;case 6:if(m&&b.stateNode!=null)m.memoizedProps!==P&&ou(b);else{if(typeof P!="string"&&b.stateNode===null)throw Error(r(166));if(m=$.current,Np(b)){if(m=b.stateNode,S=b.memoizedProps,P=null,H=Bi,H!==null)switch(H.tag){case 27:case 5:P=H.memoizedProps}m[gn]=b,m=!!(m.nodeValue===S||P!==null&&P.suppressHydrationWarning===!0||vU(m.nodeValue,S)),m||kd(b,!0)}else m=Gw(m).createTextNode(P),m[gn]=b,b.stateNode=m}return la(b),null;case 31:if(S=b.memoizedState,m===null||m.memoizedState!==null){if(P=Np(b),S!==null){if(m===null){if(!P)throw Error(r(318));if(m=b.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(557));m[gn]=b}else vm(),(b.flags&128)===0&&(b.memoizedState=null),b.flags|=4;la(b),m=!1}else S=rT(),m!==null&&m.memoizedState!==null&&(m.memoizedState.hydrationErrors=S),m=!0;if(!m)return b.flags&256?(yo(b),b):(yo(b),null);if((b.flags&128)!==0)throw Error(r(558))}return la(b),null;case 13:if(P=b.memoizedState,m===null||m.memoizedState!==null&&m.memoizedState.dehydrated!==null){if(H=Np(b),P!==null&&P.dehydrated!==null){if(m===null){if(!H)throw Error(r(318));if(H=b.memoizedState,H=H!==null?H.dehydrated:null,!H)throw Error(r(317));H[gn]=b}else vm(),(b.flags&128)===0&&(b.memoizedState=null),b.flags|=4;la(b),H=!1}else H=rT(),m!==null&&m.memoizedState!==null&&(m.memoizedState.hydrationErrors=H),H=!0;if(!H)return b.flags&256?(yo(b),b):(yo(b),null)}return yo(b),(b.flags&128)!==0?(b.lanes=S,b):(S=P!==null,m=m!==null&&m.memoizedState!==null,S&&(P=b.child,H=null,P.alternate!==null&&P.alternate.memoizedState!==null&&P.alternate.memoizedState.cachePool!==null&&(H=P.alternate.memoizedState.cachePool.pool),X=null,P.memoizedState!==null&&P.memoizedState.cachePool!==null&&(X=P.memoizedState.cachePool.pool),X!==H&&(P.flags|=2048)),S!==m&&S&&(b.child.flags|=8192),jw(b,b.updateQueue),la(b),null);case 4:return E(),m===null&&p2(b.stateNode.containerInfo),la(b),null;case 10:return ru(b.type),la(b),null;case 19:if(ue(Ha),P=b.memoizedState,P===null)return la(b),null;if(H=(b.flags&128)!==0,X=P.rendering,X===null)if(H)Bx(P,!1);else{if(Ta!==0||m!==null&&(m.flags&128)!==0)for(m=b.child;m!==null;){if(X=xw(m),X!==null){for(b.flags|=128,Bx(P,!1),m=X.updateQueue,b.updateQueue=m,jw(b,m),b.subtreeFlags=0,m=S,S=b.child;S!==null;)ZI(S,m),S=S.sibling;return pe(Ha,Ha.current&1|2),lr&&tu(b,P.treeForkCount),b.child}m=m.sibling}P.tail!==null&&F()>Lw&&(b.flags|=128,H=!0,Bx(P,!1),b.lanes=4194304)}else{if(!H)if(m=xw(X),m!==null){if(b.flags|=128,H=!0,m=m.updateQueue,b.updateQueue=m,jw(b,m),Bx(P,!0),P.tail===null&&P.tailMode==="hidden"&&!X.alternate&&!lr)return la(b),null}else 2*F()-P.renderingStartTime>Lw&&S!==536870912&&(b.flags|=128,H=!0,Bx(P,!1),b.lanes=4194304);P.isBackwards?(X.sibling=b.child,b.child=X):(m=P.last,m!==null?m.sibling=X:b.child=X,P.last=X)}return P.tail!==null?(m=P.tail,P.rendering=m,P.tail=m.sibling,P.renderingStartTime=F(),m.sibling=null,S=Ha.current,pe(Ha,H?S&1|2:S&1),lr&&tu(b,P.treeForkCount),m):(la(b),null);case 22:case 23:return yo(b),gT(),P=b.memoizedState!==null,m!==null?m.memoizedState!==null!==P&&(b.flags|=8192):P&&(b.flags|=8192),P?(S&536870912)!==0&&(b.flags&128)===0&&(la(b),b.subtreeFlags&6&&(b.flags|=8192)):la(b),S=b.updateQueue,S!==null&&jw(b,S.retryQueue),S=null,m!==null&&m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(S=m.memoizedState.cachePool.pool),P=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(P=b.memoizedState.cachePool.pool),P!==S&&(b.flags|=2048),m!==null&&ue(_m),null;case 24:return S=null,m!==null&&(S=m.memoizedState.cache),b.memoizedState.cache!==S&&(b.flags|=2048),ru(Ya),la(b),null;case 25:return null;case 30:return null}throw Error(r(156,b.tag))}function Aoe(m,b){switch(tT(b),b.tag){case 1:return m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 3:return ru(Ya),E(),m=b.flags,(m&65536)!==0&&(m&128)===0?(b.flags=m&-65537|128,b):null;case 26:case 27:case 5:return q(b),null;case 31:if(b.memoizedState!==null){if(yo(b),b.alternate===null)throw Error(r(340));vm()}return m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 13:if(yo(b),m=b.memoizedState,m!==null&&m.dehydrated!==null){if(b.alternate===null)throw Error(r(340));vm()}return m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 19:return ue(Ha),null;case 4:return E(),null;case 10:return ru(b.type),null;case 22:case 23:return yo(b),gT(),m!==null&&ue(_m),m=b.flags,m&65536?(b.flags=m&-65537|128,b):null;case 24:return ru(Ya),null;case 25:return null;default:return null}}function kz(m,b){switch(tT(b),b.tag){case 3:ru(Ya),E();break;case 26:case 27:case 5:q(b);break;case 4:E();break;case 31:b.memoizedState!==null&&yo(b);break;case 13:yo(b);break;case 19:ue(Ha);break;case 10:ru(b.type);break;case 22:case 23:yo(b),gT(),m!==null&&ue(_m);break;case 24:ru(Ya)}}function Hx(m,b){try{var S=b.updateQueue,P=S!==null?S.lastEffect:null;if(P!==null){var H=P.next;S=H;do{if((S.tag&m)===m){P=void 0;var X=S.create,ve=S.inst;P=X(),ve.destroy=P}S=S.next}while(S!==H)}}catch(Ie){Tr(b,b.return,Ie)}}function Ed(m,b,S){try{var P=b.updateQueue,H=P!==null?P.lastEffect:null;if(H!==null){var X=H.next;P=X;do{if((P.tag&m)===m){var ve=P.inst,Ie=ve.destroy;if(Ie!==void 0){ve.destroy=void 0,H=b;var Xe=S,pt=Ie;try{pt()}catch(kt){Tr(H,Xe,kt)}}}P=P.next}while(P!==X)}}catch(kt){Tr(b,b.return,kt)}}function Cz(m){var b=m.updateQueue;if(b!==null){var S=m.stateNode;try{g5(b,S)}catch(P){Tr(m,m.return,P)}}}function Az(m,b,S){S.props=Tm(m.type,m.memoizedProps),S.state=m.memoizedState;try{S.componentWillUnmount()}catch(P){Tr(m,b,P)}}function $x(m,b){try{var S=m.ref;if(S!==null){switch(m.tag){case 26:case 27:case 5:var P=m.stateNode;break;case 30:P=m.stateNode;break;default:P=m.stateNode}typeof S=="function"?m.refCleanup=S(P):S.current=P}}catch(H){Tr(m,b,H)}}function dc(m,b){var S=m.ref,P=m.refCleanup;if(S!==null)if(typeof P=="function")try{P()}catch(H){Tr(m,b,H)}finally{m.refCleanup=null,m=m.alternate,m!=null&&(m.refCleanup=null)}else if(typeof S=="function")try{S(null)}catch(H){Tr(m,b,H)}else S.current=null}function Tz(m){var b=m.type,S=m.memoizedProps,P=m.stateNode;try{e:switch(b){case"button":case"input":case"select":case"textarea":S.autoFocus&&P.focus();break e;case"img":S.src?P.src=S.src:S.srcSet&&(P.srcset=S.srcSet)}}catch(H){Tr(m,m.return,H)}}function KT(m,b,S){try{var P=m.stateNode;Yoe(P,m.type,S,b),P[On]=b}catch(H){Tr(m,m.return,H)}}function Mz(m){return m.tag===5||m.tag===3||m.tag===26||m.tag===27&&zd(m.type)||m.tag===4}function YT(m){e:for(;;){for(;m.sibling===null;){if(m.return===null||Mz(m.return))return null;m=m.return}for(m.sibling.return=m.return,m=m.sibling;m.tag!==5&&m.tag!==6&&m.tag!==18;){if(m.tag===27&&zd(m.type)||m.flags&2||m.child===null||m.tag===4)continue e;m.child.return=m,m=m.child}if(!(m.flags&2))return m.stateNode}}function XT(m,b,S){var P=m.tag;if(P===5||P===6)m=m.stateNode,b?(S.nodeType===9?S.body:S.nodeName==="HTML"?S.ownerDocument.body:S).insertBefore(m,b):(b=S.nodeType===9?S.body:S.nodeName==="HTML"?S.ownerDocument.body:S,b.appendChild(m),S=S._reactRootContainer,S!=null||b.onclick!==null||(b.onclick=mr));else if(P!==4&&(P===27&&zd(m.type)&&(S=m.stateNode,b=null),m=m.child,m!==null))for(XT(m,b,S),m=m.sibling;m!==null;)XT(m,b,S),m=m.sibling}function Ew(m,b,S){var P=m.tag;if(P===5||P===6)m=m.stateNode,b?S.insertBefore(m,b):S.appendChild(m);else if(P!==4&&(P===27&&zd(m.type)&&(S=m.stateNode),m=m.child,m!==null))for(Ew(m,b,S),m=m.sibling;m!==null;)Ew(m,b,S),m=m.sibling}function Pz(m){var b=m.stateNode,S=m.memoizedProps;try{for(var P=m.type,H=b.attributes;H.length;)b.removeAttributeNode(H[0]);Vi(b,P,S),b[gn]=m,b[On]=S}catch(X){Tr(m,m.return,X)}}var lu=!1,Za=!1,QT=!1,jz=typeof WeakSet=="function"?WeakSet:Set,Ci=null;function Toe(m,b){if(m=m.containerInfo,x2=Jw,m=$I(m),VA(m)){if("selectionStart"in m)var S={start:m.selectionStart,end:m.selectionEnd};else e:{S=(S=m.ownerDocument)&&S.defaultView||window;var P=S.getSelection&&S.getSelection();if(P&&P.rangeCount!==0){S=P.anchorNode;var H=P.anchorOffset,X=P.focusNode;P=P.focusOffset;try{S.nodeType,X.nodeType}catch{S=null;break e}var ve=0,Ie=-1,Xe=-1,pt=0,kt=0,Pt=m,bt=null;t:for(;;){for(var wt;Pt!==S||H!==0&&Pt.nodeType!==3||(Ie=ve+H),Pt!==X||P!==0&&Pt.nodeType!==3||(Xe=ve+P),Pt.nodeType===3&&(ve+=Pt.nodeValue.length),(wt=Pt.firstChild)!==null;)bt=Pt,Pt=wt;for(;;){if(Pt===m)break t;if(bt===S&&++pt===H&&(Ie=ve),bt===X&&++kt===P&&(Xe=ve),(wt=Pt.nextSibling)!==null)break;Pt=bt,bt=Pt.parentNode}Pt=wt}S=Ie===-1||Xe===-1?null:{start:Ie,end:Xe}}else S=null}S=S||{start:0,end:0}}else S=null;for(y2={focusedElem:m,selectionRange:S},Jw=!1,Ci=b;Ci!==null;)if(b=Ci,m=b.child,(b.subtreeFlags&1028)!==0&&m!==null)m.return=b,Ci=m;else for(;Ci!==null;){switch(b=Ci,X=b.alternate,m=b.flags,b.tag){case 0:if((m&4)!==0&&(m=b.updateQueue,m=m!==null?m.events:null,m!==null))for(S=0;S<m.length;S++)H=m[S],H.ref.impl=H.nextImpl;break;case 11:case 15:break;case 1:if((m&1024)!==0&&X!==null){m=void 0,S=b,H=X.memoizedProps,X=X.memoizedState,P=S.stateNode;try{var Kt=Tm(S.type,H);m=P.getSnapshotBeforeUpdate(Kt,X),P.__reactInternalSnapshotBeforeUpdate=m}catch(bn){Tr(S,S.return,bn)}}break;case 3:if((m&1024)!==0){if(m=b.stateNode.containerInfo,S=m.nodeType,S===9)S2(m);else if(S===1)switch(m.nodeName){case"HEAD":case"HTML":case"BODY":S2(m);break;default:m.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((m&1024)!==0)throw Error(r(163))}if(m=b.sibling,m!==null){m.return=b.return,Ci=m;break}Ci=b.return}}function Ez(m,b,S){var P=S.flags;switch(S.tag){case 0:case 11:case 15:uu(m,S),P&4&&Hx(5,S);break;case 1:if(uu(m,S),P&4)if(m=S.stateNode,b===null)try{m.componentDidMount()}catch(ve){Tr(S,S.return,ve)}else{var H=Tm(S.type,b.memoizedProps);b=b.memoizedState;try{m.componentDidUpdate(H,b,m.__reactInternalSnapshotBeforeUpdate)}catch(ve){Tr(S,S.return,ve)}}P&64&&Cz(S),P&512&&$x(S,S.return);break;case 3:if(uu(m,S),P&64&&(m=S.updateQueue,m!==null)){if(b=null,S.child!==null)switch(S.child.tag){case 27:case 5:b=S.child.stateNode;break;case 1:b=S.child.stateNode}try{g5(m,b)}catch(ve){Tr(S,S.return,ve)}}break;case 27:b===null&&P&4&&Pz(S);case 26:case 5:uu(m,S),b===null&&P&4&&Tz(S),P&512&&$x(S,S.return);break;case 12:uu(m,S);break;case 31:uu(m,S),P&4&&Fz(m,S);break;case 13:uu(m,S),P&4&&Lz(m,S),P&64&&(m=S.memoizedState,m!==null&&(m=m.dehydrated,m!==null&&(S=Ooe.bind(null,S),rle(m,S))));break;case 22:if(P=S.memoizedState!==null||lu,!P){b=b!==null&&b.memoizedState!==null||Za,H=lu;var X=Za;lu=P,(Za=b)&&!X?du(m,S,(S.subtreeFlags&8772)!==0):uu(m,S),lu=H,Za=X}break;case 30:break;default:uu(m,S)}}function Dz(m){var b=m.alternate;b!==null&&(m.alternate=null,Dz(b)),m.child=null,m.deletions=null,m.sibling=null,m.tag===5&&(b=m.stateNode,b!==null&&Ye(b)),m.stateNode=null,m.return=null,m.dependencies=null,m.memoizedProps=null,m.memoizedState=null,m.pendingProps=null,m.stateNode=null,m.updateQueue=null}var ma=null,qs=!1;function cu(m,b,S){for(S=S.child;S!==null;)Rz(m,b,S),S=S.sibling}function Rz(m,b,S){if(we&&typeof we.onCommitFiberUnmount=="function")try{we.onCommitFiberUnmount(de,S)}catch{}switch(S.tag){case 26:Za||dc(S,b),cu(m,b,S),S.memoizedState?S.memoizedState.count--:S.stateNode&&(S=S.stateNode,S.parentNode.removeChild(S));break;case 27:Za||dc(S,b);var P=ma,H=qs;zd(S.type)&&(ma=S.stateNode,qs=!1),cu(m,b,S),Zx(S.stateNode),ma=P,qs=H;break;case 5:Za||dc(S,b);case 6:if(P=ma,H=qs,ma=null,cu(m,b,S),ma=P,qs=H,ma!==null)if(qs)try{(ma.nodeType===9?ma.body:ma.nodeName==="HTML"?ma.ownerDocument.body:ma).removeChild(S.stateNode)}catch(X){Tr(S,b,X)}else try{ma.removeChild(S.stateNode)}catch(X){Tr(S,b,X)}break;case 18:ma!==null&&(qs?(m=ma,CU(m.nodeType===9?m.body:m.nodeName==="HTML"?m.ownerDocument.body:m,S.stateNode),qp(m)):CU(ma,S.stateNode));break;case 4:P=ma,H=qs,ma=S.stateNode.containerInfo,qs=!0,cu(m,b,S),ma=P,qs=H;break;case 0:case 11:case 14:case 15:Ed(2,S,b),Za||Ed(4,S,b),cu(m,b,S);break;case 1:Za||(dc(S,b),P=S.stateNode,typeof P.componentWillUnmount=="function"&&Az(S,b,P)),cu(m,b,S);break;case 21:cu(m,b,S);break;case 22:Za=(P=Za)||S.memoizedState!==null,cu(m,b,S),Za=P;break;default:cu(m,b,S)}}function Fz(m,b){if(b.memoizedState===null&&(m=b.alternate,m!==null&&(m=m.memoizedState,m!==null))){m=m.dehydrated;try{qp(m)}catch(S){Tr(b,b.return,S)}}}function Lz(m,b){if(b.memoizedState===null&&(m=b.alternate,m!==null&&(m=m.memoizedState,m!==null&&(m=m.dehydrated,m!==null))))try{qp(m)}catch(S){Tr(b,b.return,S)}}function Moe(m){switch(m.tag){case 31:case 13:case 19:var b=m.stateNode;return b===null&&(b=m.stateNode=new jz),b;case 22:return m=m.stateNode,b=m._retryCache,b===null&&(b=m._retryCache=new jz),b;default:throw Error(r(435,m.tag))}}function Dw(m,b){var S=Moe(m);b.forEach(function(P){if(!S.has(P)){S.add(P);var H=Ioe.bind(null,m,P);P.then(H,H)}})}function Gs(m,b){var S=b.deletions;if(S!==null)for(var P=0;P<S.length;P++){var H=S[P],X=m,ve=b,Ie=ve;e:for(;Ie!==null;){switch(Ie.tag){case 27:if(zd(Ie.type)){ma=Ie.stateNode,qs=!1;break e}break;case 5:ma=Ie.stateNode,qs=!1;break e;case 3:case 4:ma=Ie.stateNode.containerInfo,qs=!0;break e}Ie=Ie.return}if(ma===null)throw Error(r(160));Rz(X,ve,H),ma=null,qs=!1,X=H.alternate,X!==null&&(X.return=null),H.return=null}if(b.subtreeFlags&13886)for(b=b.child;b!==null;)Oz(b,m),b=b.sibling}var Fl=null;function Oz(m,b){var S=m.alternate,P=m.flags;switch(m.tag){case 0:case 11:case 14:case 15:Gs(b,m),Ws(m),P&4&&(Ed(3,m,m.return),Hx(3,m),Ed(5,m,m.return));break;case 1:Gs(b,m),Ws(m),P&512&&(Za||S===null||dc(S,S.return)),P&64&&lu&&(m=m.updateQueue,m!==null&&(P=m.callbacks,P!==null&&(S=m.shared.hiddenCallbacks,m.shared.hiddenCallbacks=S===null?P:S.concat(P))));break;case 26:var H=Fl;if(Gs(b,m),Ws(m),P&512&&(Za||S===null||dc(S,S.return)),P&4){var X=S!==null?S.memoizedState:null;if(P=m.memoizedState,S===null)if(P===null)if(m.stateNode===null){e:{P=m.type,S=m.memoizedProps,H=H.ownerDocument||H;t:switch(P){case"title":X=H.getElementsByTagName("title")[0],(!X||X[st]||X[gn]||X.namespaceURI==="http://www.w3.org/2000/svg"||X.hasAttribute("itemprop"))&&(X=H.createElement(P),H.head.insertBefore(X,H.querySelector("head > title"))),Vi(X,P,S),X[gn]=m,Qe(X),P=X;break e;case"link":var ve=OU("link","href",H).get(P+(S.href||""));if(ve){for(var Ie=0;Ie<ve.length;Ie++)if(X=ve[Ie],X.getAttribute("href")===(S.href==null||S.href===""?null:S.href)&&X.getAttribute("rel")===(S.rel==null?null:S.rel)&&X.getAttribute("title")===(S.title==null?null:S.title)&&X.getAttribute("crossorigin")===(S.crossOrigin==null?null:S.crossOrigin)){ve.splice(Ie,1);break t}}X=H.createElement(P),Vi(X,P,S),H.head.appendChild(X);break;case"meta":if(ve=OU("meta","content",H).get(P+(S.content||""))){for(Ie=0;Ie<ve.length;Ie++)if(X=ve[Ie],X.getAttribute("content")===(S.content==null?null:""+S.content)&&X.getAttribute("name")===(S.name==null?null:S.name)&&X.getAttribute("property")===(S.property==null?null:S.property)&&X.getAttribute("http-equiv")===(S.httpEquiv==null?null:S.httpEquiv)&&X.getAttribute("charset")===(S.charSet==null?null:S.charSet)){ve.splice(Ie,1);break t}}X=H.createElement(P),Vi(X,P,S),H.head.appendChild(X);break;default:throw Error(r(468,P))}X[gn]=m,Qe(X),P=X}m.stateNode=P}else IU(H,m.type,m.stateNode);else m.stateNode=LU(H,P,m.memoizedProps);else X!==P?(X===null?S.stateNode!==null&&(S=S.stateNode,S.parentNode.removeChild(S)):X.count--,P===null?IU(H,m.type,m.stateNode):LU(H,P,m.memoizedProps)):P===null&&m.stateNode!==null&&KT(m,m.memoizedProps,S.memoizedProps)}break;case 27:Gs(b,m),Ws(m),P&512&&(Za||S===null||dc(S,S.return)),S!==null&&P&4&&KT(m,m.memoizedProps,S.memoizedProps);break;case 5:if(Gs(b,m),Ws(m),P&512&&(Za||S===null||dc(S,S.return)),m.flags&32){H=m.stateNode;try{sa(H,"")}catch(Kt){Tr(m,m.return,Kt)}}P&4&&m.stateNode!=null&&(H=m.memoizedProps,KT(m,H,S!==null?S.memoizedProps:H)),P&1024&&(QT=!0);break;case 6:if(Gs(b,m),Ws(m),P&4){if(m.stateNode===null)throw Error(r(162));P=m.memoizedProps,S=m.stateNode;try{S.nodeValue=P}catch(Kt){Tr(m,m.return,Kt)}}break;case 3:if(Yw=null,H=Fl,Fl=Ww(b.containerInfo),Gs(b,m),Fl=H,Ws(m),P&4&&S!==null&&S.memoizedState.isDehydrated)try{qp(b.containerInfo)}catch(Kt){Tr(m,m.return,Kt)}QT&&(QT=!1,Iz(m));break;case 4:P=Fl,Fl=Ww(m.stateNode.containerInfo),Gs(b,m),Ws(m),Fl=P;break;case 12:Gs(b,m),Ws(m);break;case 31:Gs(b,m),Ws(m),P&4&&(P=m.updateQueue,P!==null&&(m.updateQueue=null,Dw(m,P)));break;case 13:Gs(b,m),Ws(m),m.child.flags&8192&&m.memoizedState!==null!=(S!==null&&S.memoizedState!==null)&&(Fw=F()),P&4&&(P=m.updateQueue,P!==null&&(m.updateQueue=null,Dw(m,P)));break;case 22:H=m.memoizedState!==null;var Xe=S!==null&&S.memoizedState!==null,pt=lu,kt=Za;if(lu=pt||H,Za=kt||Xe,Gs(b,m),Za=kt,lu=pt,Ws(m),P&8192)e:for(b=m.stateNode,b._visibility=H?b._visibility&-2:b._visibility|1,H&&(S===null||Xe||lu||Za||Mm(m)),S=null,b=m;;){if(b.tag===5||b.tag===26){if(S===null){Xe=S=b;try{if(X=Xe.stateNode,H)ve=X.style,typeof ve.setProperty=="function"?ve.setProperty("display","none","important"):ve.display="none";else{Ie=Xe.stateNode;var Pt=Xe.memoizedProps.style,bt=Pt!=null&&Pt.hasOwnProperty("display")?Pt.display:null;Ie.style.display=bt==null||typeof bt=="boolean"?"":(""+bt).trim()}}catch(Kt){Tr(Xe,Xe.return,Kt)}}}else if(b.tag===6){if(S===null){Xe=b;try{Xe.stateNode.nodeValue=H?"":Xe.memoizedProps}catch(Kt){Tr(Xe,Xe.return,Kt)}}}else if(b.tag===18){if(S===null){Xe=b;try{var wt=Xe.stateNode;H?AU(wt,!0):AU(Xe.stateNode,!1)}catch(Kt){Tr(Xe,Xe.return,Kt)}}}else if((b.tag!==22&&b.tag!==23||b.memoizedState===null||b===m)&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===m)break e;for(;b.sibling===null;){if(b.return===null||b.return===m)break e;S===b&&(S=null),b=b.return}S===b&&(S=null),b.sibling.return=b.return,b=b.sibling}P&4&&(P=m.updateQueue,P!==null&&(S=P.retryQueue,S!==null&&(P.retryQueue=null,Dw(m,S))));break;case 19:Gs(b,m),Ws(m),P&4&&(P=m.updateQueue,P!==null&&(m.updateQueue=null,Dw(m,P)));break;case 30:break;case 21:break;default:Gs(b,m),Ws(m)}}function Ws(m){var b=m.flags;if(b&2){try{for(var S,P=m.return;P!==null;){if(Mz(P)){S=P;break}P=P.return}if(S==null)throw Error(r(160));switch(S.tag){case 27:var H=S.stateNode,X=YT(m);Ew(m,X,H);break;case 5:var ve=S.stateNode;S.flags&32&&(sa(ve,""),S.flags&=-33);var Ie=YT(m);Ew(m,Ie,ve);break;case 3:case 4:var Xe=S.stateNode.containerInfo,pt=YT(m);XT(m,pt,Xe);break;default:throw Error(r(161))}}catch(kt){Tr(m,m.return,kt)}m.flags&=-3}b&4096&&(m.flags&=-4097)}function Iz(m){if(m.subtreeFlags&1024)for(m=m.child;m!==null;){var b=m;Iz(b),b.tag===5&&b.flags&1024&&b.stateNode.reset(),m=m.sibling}}function uu(m,b){if(b.subtreeFlags&8772)for(b=b.child;b!==null;)Ez(m,b.alternate,b),b=b.sibling}function Mm(m){for(m=m.child;m!==null;){var b=m;switch(b.tag){case 0:case 11:case 14:case 15:Ed(4,b,b.return),Mm(b);break;case 1:dc(b,b.return);var S=b.stateNode;typeof S.componentWillUnmount=="function"&&Az(b,b.return,S),Mm(b);break;case 27:Zx(b.stateNode);case 26:case 5:dc(b,b.return),Mm(b);break;case 22:b.memoizedState===null&&Mm(b);break;case 30:Mm(b);break;default:Mm(b)}m=m.sibling}}function du(m,b,S){for(S=S&&(b.subtreeFlags&8772)!==0,b=b.child;b!==null;){var P=b.alternate,H=m,X=b,ve=X.flags;switch(X.tag){case 0:case 11:case 15:du(H,X,S),Hx(4,X);break;case 1:if(du(H,X,S),P=X,H=P.stateNode,typeof H.componentDidMount=="function")try{H.componentDidMount()}catch(pt){Tr(P,P.return,pt)}if(P=X,H=P.updateQueue,H!==null){var Ie=P.stateNode;try{var Xe=H.shared.hiddenCallbacks;if(Xe!==null)for(H.shared.hiddenCallbacks=null,H=0;H<Xe.length;H++)p5(Xe[H],Ie)}catch(pt){Tr(P,P.return,pt)}}S&&ve&64&&Cz(X),$x(X,X.return);break;case 27:Pz(X);case 26:case 5:du(H,X,S),S&&P===null&&ve&4&&Tz(X),$x(X,X.return);break;case 12:du(H,X,S);break;case 31:du(H,X,S),S&&ve&4&&Fz(H,X);break;case 13:du(H,X,S),S&&ve&4&&Lz(H,X);break;case 22:X.memoizedState===null&&du(H,X,S),$x(X,X.return);break;case 30:break;default:du(H,X,S)}b=b.sibling}}function ZT(m,b){var S=null;m!==null&&m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(S=m.memoizedState.cachePool.pool),m=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(m=b.memoizedState.cachePool.pool),m!==S&&(m!=null&&m.refCount++,S!=null&&Mx(S))}function JT(m,b){m=null,b.alternate!==null&&(m=b.alternate.memoizedState.cache),b=b.memoizedState.cache,b!==m&&(b.refCount++,m!=null&&Mx(m))}function Ll(m,b,S,P){if(b.subtreeFlags&10256)for(b=b.child;b!==null;)zz(m,b,S,P),b=b.sibling}function zz(m,b,S,P){var H=b.flags;switch(b.tag){case 0:case 11:case 15:Ll(m,b,S,P),H&2048&&Hx(9,b);break;case 1:Ll(m,b,S,P);break;case 3:Ll(m,b,S,P),H&2048&&(m=null,b.alternate!==null&&(m=b.alternate.memoizedState.cache),b=b.memoizedState.cache,b!==m&&(b.refCount++,m!=null&&Mx(m)));break;case 12:if(H&2048){Ll(m,b,S,P),m=b.stateNode;try{var X=b.memoizedProps,ve=X.id,Ie=X.onPostCommit;typeof Ie=="function"&&Ie(ve,b.alternate===null?"mount":"update",m.passiveEffectDuration,-0)}catch(Xe){Tr(b,b.return,Xe)}}else Ll(m,b,S,P);break;case 31:Ll(m,b,S,P);break;case 13:Ll(m,b,S,P);break;case 23:break;case 22:X=b.stateNode,ve=b.alternate,b.memoizedState!==null?X._visibility&2?Ll(m,b,S,P):Vx(m,b):X._visibility&2?Ll(m,b,S,P):(X._visibility|=2,Rp(m,b,S,P,(b.subtreeFlags&10256)!==0||!1)),H&2048&&ZT(ve,b);break;case 24:Ll(m,b,S,P),H&2048&&JT(b.alternate,b);break;default:Ll(m,b,S,P)}}function Rp(m,b,S,P,H){for(H=H&&((b.subtreeFlags&10256)!==0||!1),b=b.child;b!==null;){var X=m,ve=b,Ie=S,Xe=P,pt=ve.flags;switch(ve.tag){case 0:case 11:case 15:Rp(X,ve,Ie,Xe,H),Hx(8,ve);break;case 23:break;case 22:var kt=ve.stateNode;ve.memoizedState!==null?kt._visibility&2?Rp(X,ve,Ie,Xe,H):Vx(X,ve):(kt._visibility|=2,Rp(X,ve,Ie,Xe,H)),H&&pt&2048&&ZT(ve.alternate,ve);break;case 24:Rp(X,ve,Ie,Xe,H),H&&pt&2048&&JT(ve.alternate,ve);break;default:Rp(X,ve,Ie,Xe,H)}b=b.sibling}}function Vx(m,b){if(b.subtreeFlags&10256)for(b=b.child;b!==null;){var S=m,P=b,H=P.flags;switch(P.tag){case 22:Vx(S,P),H&2048&&ZT(P.alternate,P);break;case 24:Vx(S,P),H&2048&&JT(P.alternate,P);break;default:Vx(S,P)}b=b.sibling}}var qx=8192;function Fp(m,b,S){if(m.subtreeFlags&qx)for(m=m.child;m!==null;)Uz(m,b,S),m=m.sibling}function Uz(m,b,S){switch(m.tag){case 26:Fp(m,b,S),m.flags&qx&&m.memoizedState!==null&&ple(S,Fl,m.memoizedState,m.memoizedProps);break;case 5:Fp(m,b,S);break;case 3:case 4:var P=Fl;Fl=Ww(m.stateNode.containerInfo),Fp(m,b,S),Fl=P;break;case 22:m.memoizedState===null&&(P=m.alternate,P!==null&&P.memoizedState!==null?(P=qx,qx=16777216,Fp(m,b,S),qx=P):Fp(m,b,S));break;default:Fp(m,b,S)}}function Bz(m){var b=m.alternate;if(b!==null&&(m=b.child,m!==null)){b.child=null;do b=m.sibling,m.sibling=null,m=b;while(m!==null)}}function Gx(m){var b=m.deletions;if((m.flags&16)!==0){if(b!==null)for(var S=0;S<b.length;S++){var P=b[S];Ci=P,$z(P,m)}Bz(m)}if(m.subtreeFlags&10256)for(m=m.child;m!==null;)Hz(m),m=m.sibling}function Hz(m){switch(m.tag){case 0:case 11:case 15:Gx(m),m.flags&2048&&Ed(9,m,m.return);break;case 3:Gx(m);break;case 12:Gx(m);break;case 22:var b=m.stateNode;m.memoizedState!==null&&b._visibility&2&&(m.return===null||m.return.tag!==13)?(b._visibility&=-3,Rw(m)):Gx(m);break;default:Gx(m)}}function Rw(m){var b=m.deletions;if((m.flags&16)!==0){if(b!==null)for(var S=0;S<b.length;S++){var P=b[S];Ci=P,$z(P,m)}Bz(m)}for(m=m.child;m!==null;){switch(b=m,b.tag){case 0:case 11:case 15:Ed(8,b,b.return),Rw(b);break;case 22:S=b.stateNode,S._visibility&2&&(S._visibility&=-3,Rw(b));break;default:Rw(b)}m=m.sibling}}function $z(m,b){for(;Ci!==null;){var S=Ci;switch(S.tag){case 0:case 11:case 15:Ed(8,S,b);break;case 23:case 22:if(S.memoizedState!==null&&S.memoizedState.cachePool!==null){var P=S.memoizedState.cachePool.pool;P!=null&&P.refCount++}break;case 24:Mx(S.memoizedState.cache)}if(P=S.child,P!==null)P.return=S,Ci=P;else e:for(S=m;Ci!==null;){P=Ci;var H=P.sibling,X=P.return;if(Dz(P),P===S){Ci=null;break e}if(H!==null){H.return=X,Ci=H;break e}Ci=X}}}var Poe={getCacheForType:function(m){var b=Hi(Ya),S=b.data.get(m);return S===void 0&&(S=m(),b.data.set(m,S)),S},cacheSignal:function(){return Hi(Ya).controller.signal}},joe=typeof WeakMap=="function"?WeakMap:Map,vr=0,Wr=null,er=null,sr=0,Ar=0,vo=null,Dd=!1,Lp=!1,e2=!1,hu=0,Ta=0,Rd=0,Pm=0,t2=0,wo=0,Op=0,Wx=null,Ks=null,n2=!1,Fw=0,Vz=0,Lw=1/0,Ow=null,Fd=null,di=0,Ld=null,Ip=null,mu=0,r2=0,a2=null,qz=null,Kx=0,i2=null;function So(){return(vr&2)!==0&&sr!==0?sr&-sr:ae.T!==null?d2():pn()}function Gz(){if(wo===0)if((sr&536870912)===0||lr){var m=je;je<<=1,(je&3932160)===0&&(je=262144),wo=m}else wo=536870912;return m=xo.current,m!==null&&(m.flags|=32),wo}function Ys(m,b,S){(m===Wr&&(Ar===2||Ar===9)||m.cancelPendingCommit!==null)&&(zp(m,0),Od(m,sr,wo,!1)),Mt(m,S),((vr&2)===0||m!==Wr)&&(m===Wr&&((vr&2)===0&&(Pm|=S),Ta===4&&Od(m,sr,wo,!1)),hc(m))}function Wz(m,b,S){if((vr&6)!==0)throw Error(r(327));var P=!S&&(b&127)===0&&(b&m.expiredLanes)===0||Be(m,b),H=P?Roe(m,b):o2(m,b,!0),X=P;do{if(H===0){Lp&&!P&&Od(m,b,0,!1);break}else{if(S=m.current.alternate,X&&!Eoe(S)){H=o2(m,b,!1),X=!1;continue}if(H===2){if(X=b,m.errorRecoveryDisabledLanes&X)var ve=0;else ve=m.pendingLanes&-536870913,ve=ve!==0?ve:ve&536870912?536870912:0;if(ve!==0){b=ve;e:{var Ie=m;H=Wx;var Xe=Ie.current.memoizedState.isDehydrated;if(Xe&&(zp(Ie,ve).flags|=256),ve=o2(Ie,ve,!1),ve!==2){if(e2&&!Xe){Ie.errorRecoveryDisabledLanes|=X,Pm|=X,H=4;break e}X=Ks,Ks=H,X!==null&&(Ks===null?Ks=X:Ks.push.apply(Ks,X))}H=ve}if(X=!1,H!==2)continue}}if(H===1){zp(m,0),Od(m,b,0,!0);break}e:{switch(P=m,X=H,X){case 0:case 1:throw Error(r(345));case 4:if((b&4194048)!==b)break;case 6:Od(P,b,wo,!Dd);break e;case 2:Ks=null;break;case 3:case 5:break;default:throw Error(r(329))}if((b&62914560)===b&&(H=Fw+300-F(),10<H)){if(Od(P,b,wo,!Dd),Pe(P,0,!0)!==0)break e;mu=b,P.timeoutHandle=NU(Kz.bind(null,P,S,Ks,Ow,n2,b,wo,Pm,Op,Dd,X,"Throttled",-0,0),H);break e}Kz(P,S,Ks,Ow,n2,b,wo,Pm,Op,Dd,X,null,-0,0)}}break}while(!0);hc(m)}function Kz(m,b,S,P,H,X,ve,Ie,Xe,pt,kt,Pt,bt,wt){if(m.timeoutHandle=-1,Pt=b.subtreeFlags,Pt&8192||(Pt&16785408)===16785408){Pt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:mr},Uz(b,X,Pt);var Kt=(X&62914560)===X?Fw-F():(X&4194048)===X?Vz-F():0;if(Kt=gle(Pt,Kt),Kt!==null){mu=X,m.cancelPendingCommit=Kt(nU.bind(null,m,b,X,S,P,H,ve,Ie,Xe,kt,Pt,null,bt,wt)),Od(m,X,ve,!pt);return}}nU(m,b,X,S,P,H,ve,Ie,Xe)}function Eoe(m){for(var b=m;;){var S=b.tag;if((S===0||S===11||S===15)&&b.flags&16384&&(S=b.updateQueue,S!==null&&(S=S.stores,S!==null)))for(var P=0;P<S.length;P++){var H=S[P],X=H.getSnapshot;H=H.value;try{if(!go(X(),H))return!1}catch{return!1}}if(S=b.child,b.subtreeFlags&16384&&S!==null)S.return=b,b=S;else{if(b===m)break;for(;b.sibling===null;){if(b.return===null||b.return===m)return!0;b=b.return}b.sibling.return=b.return,b=b.sibling}}return!0}function Od(m,b,S,P){b&=~t2,b&=~Pm,m.suspendedLanes|=b,m.pingedLanes&=~b,P&&(m.warmLanes|=b),P=m.expirationTimes;for(var H=b;0<H;){var X=31-_e(H),ve=1<<X;P[X]=-1,H&=~ve}S!==0&&$e(m,S,b)}function Iw(){return(vr&6)===0?(Yx(0),!1):!0}function s2(){if(er!==null){if(Ar===0)var m=er.return;else m=er,nu=wm=null,ST(m),Mp=null,jx=0,m=er;for(;m!==null;)kz(m.alternate,m),m=m.return;er=null}}function zp(m,b){var S=m.timeoutHandle;S!==-1&&(m.timeoutHandle=-1,Zoe(S)),S=m.cancelPendingCommit,S!==null&&(m.cancelPendingCommit=null,S()),mu=0,s2(),Wr=m,er=S=eu(m.current,null),sr=b,Ar=0,vo=null,Dd=!1,Lp=Be(m,b),e2=!1,Op=wo=t2=Pm=Rd=Ta=0,Ks=Wx=null,n2=!1,(b&8)!==0&&(b|=b&32);var P=m.entangledLanes;if(P!==0)for(m=m.entanglements,P&=b;0<P;){var H=31-_e(P),X=1<<H;b|=m[H],P&=~X}return hu=b,iw(),S}function Yz(m,b){Ln=null,ae.H=zx,b===Tp||b===mw?(b=d5(),Ar=3):b===uT?(b=d5(),Ar=4):Ar=b===IT?8:b!==null&&typeof b=="object"&&typeof b.then=="function"?6:1,vo=b,er===null&&(Ta=1,Aw(m,$o(b,m.current)))}function Xz(){var m=xo.current;return m===null?!0:(sr&4194048)===sr?Wo===null:(sr&62914560)===sr||(sr&536870912)!==0?m===Wo:!1}function Qz(){var m=ae.H;return ae.H=zx,m===null?zx:m}function Zz(){var m=ae.A;return ae.A=Poe,m}function zw(){Ta=4,Dd||(sr&4194048)!==sr&&xo.current!==null||(Lp=!0),(Rd&134217727)===0&&(Pm&134217727)===0||Wr===null||Od(Wr,sr,wo,!1)}function o2(m,b,S){var P=vr;vr|=2;var H=Qz(),X=Zz();(Wr!==m||sr!==b)&&(Ow=null,zp(m,b)),b=!1;var ve=Ta;e:do try{if(Ar!==0&&er!==null){var Ie=er,Xe=vo;switch(Ar){case 8:s2(),ve=6;break e;case 3:case 2:case 9:case 6:xo.current===null&&(b=!0);var pt=Ar;if(Ar=0,vo=null,Up(m,Ie,Xe,pt),S&&Lp){ve=0;break e}break;default:pt=Ar,Ar=0,vo=null,Up(m,Ie,Xe,pt)}}Doe(),ve=Ta;break}catch(kt){Yz(m,kt)}while(!0);return b&&m.shellSuspendCounter++,nu=wm=null,vr=P,ae.H=H,ae.A=X,er===null&&(Wr=null,sr=0,iw()),ve}function Doe(){for(;er!==null;)Jz(er)}function Roe(m,b){var S=vr;vr|=2;var P=Qz(),H=Zz();Wr!==m||sr!==b?(Ow=null,Lw=F()+500,zp(m,b)):Lp=Be(m,b);e:do try{if(Ar!==0&&er!==null){b=er;var X=vo;t:switch(Ar){case 1:Ar=0,vo=null,Up(m,b,X,1);break;case 2:case 9:if(c5(X)){Ar=0,vo=null,eU(b);break}b=function(){Ar!==2&&Ar!==9||Wr!==m||(Ar=7),hc(m)},X.then(b,b);break e;case 3:Ar=7;break e;case 4:Ar=5;break e;case 7:c5(X)?(Ar=0,vo=null,eU(b)):(Ar=0,vo=null,Up(m,b,X,7));break;case 5:var ve=null;switch(er.tag){case 26:ve=er.memoizedState;case 5:case 27:var Ie=er;if(ve?zU(ve):Ie.stateNode.complete){Ar=0,vo=null;var Xe=Ie.sibling;if(Xe!==null)er=Xe;else{var pt=Ie.return;pt!==null?(er=pt,Uw(pt)):er=null}break t}}Ar=0,vo=null,Up(m,b,X,5);break;case 6:Ar=0,vo=null,Up(m,b,X,6);break;case 8:s2(),Ta=6;break e;default:throw Error(r(462))}}Foe();break}catch(kt){Yz(m,kt)}while(!0);return nu=wm=null,ae.H=P,ae.A=H,vr=S,er!==null?0:(Wr=null,sr=0,iw(),Ta)}function Foe(){for(;er!==null&&!oe();)Jz(er)}function Jz(m){var b=_z(m.alternate,m,hu);m.memoizedProps=m.pendingProps,b===null?Uw(m):er=b}function eU(m){var b=m,S=b.alternate;switch(b.tag){case 15:case 0:b=bz(S,b,b.pendingProps,b.type,void 0,sr);break;case 11:b=bz(S,b,b.pendingProps,b.type.render,b.ref,sr);break;case 5:ST(b);default:kz(S,b),b=er=ZI(b,hu),b=_z(S,b,hu)}m.memoizedProps=m.pendingProps,b===null?Uw(m):er=b}function Up(m,b,S,P){nu=wm=null,ST(b),Mp=null,jx=0;var H=b.return;try{if(_oe(m,H,b,S,sr)){Ta=1,Aw(m,$o(S,m.current)),er=null;return}}catch(X){if(H!==null)throw er=H,X;Ta=1,Aw(m,$o(S,m.current)),er=null;return}b.flags&32768?(lr||P===1?m=!0:Lp||(sr&536870912)!==0?m=!1:(Dd=m=!0,(P===2||P===9||P===3||P===6)&&(P=xo.current,P!==null&&P.tag===13&&(P.flags|=16384))),tU(b,m)):Uw(b)}function Uw(m){var b=m;do{if((b.flags&32768)!==0){tU(b,Dd);return}m=b.return;var S=Coe(b.alternate,b,hu);if(S!==null){er=S;return}if(b=b.sibling,b!==null){er=b;return}er=b=m}while(b!==null);Ta===0&&(Ta=5)}function tU(m,b){do{var S=Aoe(m.alternate,m);if(S!==null){S.flags&=32767,er=S;return}if(S=m.return,S!==null&&(S.flags|=32768,S.subtreeFlags=0,S.deletions=null),!b&&(m=m.sibling,m!==null)){er=m;return}er=m=S}while(m!==null);Ta=6,er=null}function nU(m,b,S,P,H,X,ve,Ie,Xe){m.cancelPendingCommit=null;do Bw();while(di!==0);if((vr&6)!==0)throw Error(r(327));if(b!==null){if(b===m.current)throw Error(r(177));if(X=b.lanes|b.childLanes,X|=YA,yt(m,S,X,ve,Ie,Xe),m===Wr&&(er=Wr=null,sr=0),Ip=b,Ld=m,mu=S,r2=X,a2=H,qz=P,(b.subtreeFlags&10256)!==0||(b.flags&10256)!==0?(m.callbackNode=null,m.callbackPriority=0,zoe(le,function(){return oU(),null})):(m.callbackNode=null,m.callbackPriority=0),P=(b.flags&13878)!==0,(b.subtreeFlags&13878)!==0||P){P=ae.T,ae.T=null,H=Y.p,Y.p=2,ve=vr,vr|=4;try{Toe(m,b,S)}finally{vr=ve,Y.p=H,ae.T=P}}di=1,rU(),aU(),iU()}}function rU(){if(di===1){di=0;var m=Ld,b=Ip,S=(b.flags&13878)!==0;if((b.subtreeFlags&13878)!==0||S){S=ae.T,ae.T=null;var P=Y.p;Y.p=2;var H=vr;vr|=4;try{Oz(b,m);var X=y2,ve=$I(m.containerInfo),Ie=X.focusedElem,Xe=X.selectionRange;if(ve!==Ie&&Ie&&Ie.ownerDocument&&HI(Ie.ownerDocument.documentElement,Ie)){if(Xe!==null&&VA(Ie)){var pt=Xe.start,kt=Xe.end;if(kt===void 0&&(kt=pt),"selectionStart"in Ie)Ie.selectionStart=pt,Ie.selectionEnd=Math.min(kt,Ie.value.length);else{var Pt=Ie.ownerDocument||document,bt=Pt&&Pt.defaultView||window;if(bt.getSelection){var wt=bt.getSelection(),Kt=Ie.textContent.length,bn=Math.min(Xe.start,Kt),Ir=Xe.end===void 0?bn:Math.min(Xe.end,Kt);!wt.extend&&bn>Ir&&(ve=Ir,Ir=bn,bn=ve);var ot=BI(Ie,bn),nt=BI(Ie,Ir);if(ot&&nt&&(wt.rangeCount!==1||wt.anchorNode!==ot.node||wt.anchorOffset!==ot.offset||wt.focusNode!==nt.node||wt.focusOffset!==nt.offset)){var ft=Pt.createRange();ft.setStart(ot.node,ot.offset),wt.removeAllRanges(),bn>Ir?(wt.addRange(ft),wt.extend(nt.node,nt.offset)):(ft.setEnd(nt.node,nt.offset),wt.addRange(ft))}}}}for(Pt=[],wt=Ie;wt=wt.parentNode;)wt.nodeType===1&&Pt.push({element:wt,left:wt.scrollLeft,top:wt.scrollTop});for(typeof Ie.focus=="function"&&Ie.focus(),Ie=0;Ie<Pt.length;Ie++){var At=Pt[Ie];At.element.scrollLeft=At.left,At.element.scrollTop=At.top}}Jw=!!x2,y2=x2=null}finally{vr=H,Y.p=P,ae.T=S}}m.current=b,di=2}}function aU(){if(di===2){di=0;var m=Ld,b=Ip,S=(b.flags&8772)!==0;if((b.subtreeFlags&8772)!==0||S){S=ae.T,ae.T=null;var P=Y.p;Y.p=2;var H=vr;vr|=4;try{Ez(m,b.alternate,b)}finally{vr=H,Y.p=P,ae.T=S}}di=3}}function iU(){if(di===4||di===3){di=0,I();var m=Ld,b=Ip,S=mu,P=qz;(b.subtreeFlags&10256)!==0||(b.flags&10256)!==0?di=5:(di=0,Ip=Ld=null,sU(m,m.pendingLanes));var H=m.pendingLanes;if(H===0&&(Fd=null),en(S),b=b.stateNode,we&&typeof we.onCommitFiberRoot=="function")try{we.onCommitFiberRoot(de,b,void 0,(b.current.flags&128)===128)}catch{}if(P!==null){b=ae.T,H=Y.p,Y.p=2,ae.T=null;try{for(var X=m.onRecoverableError,ve=0;ve<P.length;ve++){var Ie=P[ve];X(Ie.value,{componentStack:Ie.stack})}}finally{ae.T=b,Y.p=H}}(mu&3)!==0&&Bw(),hc(m),H=m.pendingLanes,(S&261930)!==0&&(H&42)!==0?m===i2?Kx++:(Kx=0,i2=m):Kx=0,Yx(0)}}function sU(m,b){(m.pooledCacheLanes&=b)===0&&(b=m.pooledCache,b!=null&&(m.pooledCache=null,Mx(b)))}function Bw(){return rU(),aU(),iU(),oU()}function oU(){if(di!==5)return!1;var m=Ld,b=r2;r2=0;var S=en(mu),P=ae.T,H=Y.p;try{Y.p=32>S?32:S,ae.T=null,S=a2,a2=null;var X=Ld,ve=mu;if(di=0,Ip=Ld=null,mu=0,(vr&6)!==0)throw Error(r(331));var Ie=vr;if(vr|=4,Hz(X.current),zz(X,X.current,ve,S),vr=Ie,Yx(0,!1),we&&typeof we.onPostCommitFiberRoot=="function")try{we.onPostCommitFiberRoot(de,X)}catch{}return!0}finally{Y.p=H,ae.T=P,sU(m,b)}}function lU(m,b,S){b=$o(S,b),b=OT(m.stateNode,b,2),m=Md(m,b,2),m!==null&&(Mt(m,2),hc(m))}function Tr(m,b,S){if(m.tag===3)lU(m,m,S);else for(;b!==null;){if(b.tag===3){lU(b,m,S);break}else if(b.tag===1){var P=b.stateNode;if(typeof b.type.getDerivedStateFromError=="function"||typeof P.componentDidCatch=="function"&&(Fd===null||!Fd.has(P))){m=$o(S,m),S=cz(2),P=Md(b,S,2),P!==null&&(uz(S,P,b,m),Mt(P,2),hc(P));break}}b=b.return}}function l2(m,b,S){var P=m.pingCache;if(P===null){P=m.pingCache=new joe;var H=new Set;P.set(b,H)}else H=P.get(b),H===void 0&&(H=new Set,P.set(b,H));H.has(S)||(e2=!0,H.add(S),m=Loe.bind(null,m,b,S),b.then(m,m))}function Loe(m,b,S){var P=m.pingCache;P!==null&&P.delete(b),m.pingedLanes|=m.suspendedLanes&S,m.warmLanes&=~S,Wr===m&&(sr&S)===S&&(Ta===4||Ta===3&&(sr&62914560)===sr&&300>F()-Fw?(vr&2)===0&&zp(m,0):t2|=S,Op===sr&&(Op=0)),hc(m)}function cU(m,b){b===0&&(b=ct()),m=xm(m,b),m!==null&&(Mt(m,b),hc(m))}function Ooe(m){var b=m.memoizedState,S=0;b!==null&&(S=b.retryLane),cU(m,S)}function Ioe(m,b){var S=0;switch(m.tag){case 31:case 13:var P=m.stateNode,H=m.memoizedState;H!==null&&(S=H.retryLane);break;case 19:P=m.stateNode;break;case 22:P=m.stateNode._retryCache;break;default:throw Error(r(314))}P!==null&&P.delete(b),cU(m,S)}function zoe(m,b){return me(m,b)}var Hw=null,Bp=null,c2=!1,$w=!1,u2=!1,Id=0;function hc(m){m!==Bp&&m.next===null&&(Bp===null?Hw=Bp=m:Bp=Bp.next=m),$w=!0,c2||(c2=!0,Boe())}function Yx(m,b){if(!u2&&$w){u2=!0;do for(var S=!1,P=Hw;P!==null;){if(m!==0){var H=P.pendingLanes;if(H===0)var X=0;else{var ve=P.suspendedLanes,Ie=P.pingedLanes;X=(1<<31-_e(42|m)+1)-1,X&=H&~(ve&~Ie),X=X&201326741?X&201326741|1:X?X|2:0}X!==0&&(S=!0,mU(P,X))}else X=sr,X=Pe(P,P===Wr?X:0,P.cancelPendingCommit!==null||P.timeoutHandle!==-1),(X&3)===0||Be(P,X)||(S=!0,mU(P,X));P=P.next}while(S);u2=!1}}function Uoe(){uU()}function uU(){$w=c2=!1;var m=0;Id!==0&&Qoe()&&(m=Id);for(var b=F(),S=null,P=Hw;P!==null;){var H=P.next,X=dU(P,b);X===0?(P.next=null,S===null?Hw=H:S.next=H,H===null&&(Bp=S)):(S=P,(m!==0||(X&3)!==0)&&($w=!0)),P=H}di!==0&&di!==5||Yx(m),Id!==0&&(Id=0)}function dU(m,b){for(var S=m.suspendedLanes,P=m.pingedLanes,H=m.expirationTimes,X=m.pendingLanes&-62914561;0<X;){var ve=31-_e(X),Ie=1<<ve,Xe=H[ve];Xe===-1?((Ie&S)===0||(Ie&P)!==0)&&(H[ve]=We(Ie,b)):Xe<=b&&(m.expiredLanes|=Ie),X&=~Ie}if(b=Wr,S=sr,S=Pe(m,m===b?S:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),P=m.callbackNode,S===0||m===b&&(Ar===2||Ar===9)||m.cancelPendingCommit!==null)return P!==null&&P!==null&&fe(P),m.callbackNode=null,m.callbackPriority=0;if((S&3)===0||Be(m,S)){if(b=S&-S,b===m.callbackPriority)return b;switch(P!==null&&fe(P),en(S)){case 2:case 8:S=he;break;case 32:S=le;break;case 268435456:S=Ne;break;default:S=le}return P=hU.bind(null,m),S=me(S,P),m.callbackPriority=b,m.callbackNode=S,b}return P!==null&&P!==null&&fe(P),m.callbackPriority=2,m.callbackNode=null,2}function hU(m,b){if(di!==0&&di!==5)return m.callbackNode=null,m.callbackPriority=0,null;var S=m.callbackNode;if(Bw()&&m.callbackNode!==S)return null;var P=sr;return P=Pe(m,m===Wr?P:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),P===0?null:(Wz(m,P,b),dU(m,F()),m.callbackNode!=null&&m.callbackNode===S?hU.bind(null,m):null)}function mU(m,b){if(Bw())return null;Wz(m,b,!0)}function Boe(){Joe(function(){(vr&6)!==0?me(xe,Uoe):uU()})}function d2(){if(Id===0){var m=Cp;m===0&&(m=Ke,Ke<<=1,(Ke&261888)===0&&(Ke=256)),Id=m}return Id}function fU(m){return m==null||typeof m=="symbol"||typeof m=="boolean"?null:typeof m=="function"?m:ir(""+m)}function pU(m,b){var S=b.ownerDocument.createElement("input");return S.name=b.name,S.value=b.value,m.id&&S.setAttribute("form",m.id),b.parentNode.insertBefore(S,b),m=new FormData(m),S.parentNode.removeChild(S),m}function Hoe(m,b,S,P,H){if(b==="submit"&&S&&S.stateNode===H){var X=fU((H[On]||null).action),ve=P.submitter;ve&&(b=(b=ve[On]||null)?fU(b.formAction):ve.getAttribute("formAction"),b!==null&&(X=b,ve=null));var Ie=new Cr("action","action",null,P,H);m.push({event:Ie,listeners:[{instance:null,listener:function(){if(P.defaultPrevented){if(Id!==0){var Xe=ve?pU(H,ve):new FormData(H);jT(S,{pending:!0,data:Xe,method:H.method,action:X},null,Xe)}}else typeof X=="function"&&(Ie.preventDefault(),Xe=ve?pU(H,ve):new FormData(H),jT(S,{pending:!0,data:Xe,method:H.method,action:X},X,Xe))},currentTarget:H}]})}}for(var h2=0;h2<KA.length;h2++){var m2=KA[h2],$oe=m2.toLowerCase(),Voe=m2[0].toUpperCase()+m2.slice(1);Rl($oe,"on"+Voe)}Rl(GI,"onAnimationEnd"),Rl(WI,"onAnimationIteration"),Rl(KI,"onAnimationStart"),Rl("dblclick","onDoubleClick"),Rl("focusin","onFocus"),Rl("focusout","onBlur"),Rl(soe,"onTransitionRun"),Rl(ooe,"onTransitionStart"),Rl(loe,"onTransitionCancel"),Rl(YI,"onTransitionEnd"),tt("onMouseEnter",["mouseout","mouseover"]),tt("onMouseLeave",["mouseout","mouseover"]),tt("onPointerEnter",["pointerout","pointerover"]),tt("onPointerLeave",["pointerout","pointerover"]),it("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),it("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),it("onBeforeInput",["compositionend","keypress","textInput","paste"]),it("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),it("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),it("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xx="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(" "),qoe=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Xx));function gU(m,b){b=(b&4)!==0;for(var S=0;S<m.length;S++){var P=m[S],H=P.event;P=P.listeners;e:{var X=void 0;if(b)for(var ve=P.length-1;0<=ve;ve--){var Ie=P[ve],Xe=Ie.instance,pt=Ie.currentTarget;if(Ie=Ie.listener,Xe!==X&&H.isPropagationStopped())break e;X=Ie,H.currentTarget=pt;try{X(H)}catch(kt){aw(kt)}H.currentTarget=null,X=Xe}else for(ve=0;ve<P.length;ve++){if(Ie=P[ve],Xe=Ie.instance,pt=Ie.currentTarget,Ie=Ie.listener,Xe!==X&&H.isPropagationStopped())break e;X=Ie,H.currentTarget=pt;try{X(H)}catch(kt){aw(kt)}H.currentTarget=null,X=Xe}}}}function tr(m,b){var S=b[zn];S===void 0&&(S=b[zn]=new Set);var P=m+"__bubble";S.has(P)||(bU(b,m,2,!1),S.add(P))}function f2(m,b,S){var P=0;b&&(P|=4),bU(S,m,P,b)}var Vw="_reactListening"+Math.random().toString(36).slice(2);function p2(m){if(!m[Vw]){m[Vw]=!0,Le.forEach(function(S){S!=="selectionchange"&&(qoe.has(S)||f2(S,!1,m),f2(S,!0,m))});var b=m.nodeType===9?m:m.ownerDocument;b===null||b[Vw]||(b[Vw]=!0,f2("selectionchange",!1,b))}}function bU(m,b,S,P){switch(GU(b)){case 2:var H=yle;break;case 8:H=vle;break;default:H=P2}S=H.bind(null,b,S,m),H=void 0,!Vs||b!=="touchstart"&&b!=="touchmove"&&b!=="wheel"||(H=!0),P?H!==void 0?m.addEventListener(b,S,{capture:!0,passive:H}):m.addEventListener(b,S,!0):H!==void 0?m.addEventListener(b,S,{passive:H}):m.addEventListener(b,S,!1)}function g2(m,b,S,P,H){var X=P;if((b&1)===0&&(b&2)===0&&P!==null)e:for(;;){if(P===null)return;var ve=P.tag;if(ve===3||ve===4){var Ie=P.stateNode.containerInfo;if(Ie===H)break;if(ve===4)for(ve=P.return;ve!==null;){var Xe=ve.tag;if((Xe===3||Xe===4)&&ve.stateNode.containerInfo===H)return;ve=ve.return}for(;Ie!==null;){if(ve=It(Ie),ve===null)return;if(Xe=ve.tag,Xe===5||Xe===6||Xe===26||Xe===27){P=X=ve;continue e}Ie=Ie.parentNode}}P=P.return}Bo(function(){var pt=X,kt=an(S),Pt=[];e:{var bt=XI.get(m);if(bt!==void 0){var wt=Cr,Kt=m;switch(m){case"keypress":if(Dl(S)===0)break e;case"keydown":case"keyup":wt=Ise;break;case"focusin":Kt="focus",wt=po;break;case"focusout":Kt="blur",wt=po;break;case"beforeblur":case"afterblur":wt=po;break;case"click":if(S.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":wt=ha;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":wt=Jc;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":wt=Bse;break;case GI:case WI:case KI:wt=zA;break;case YI:wt=$se;break;case"scroll":case"scrollend":wt=nw;break;case"wheel":wt=qse;break;case"copy":case"cut":case"paste":wt=jse;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":wt=AI;break;case"toggle":case"beforetoggle":wt=Wse}var bn=(b&4)!==0,Ir=!bn&&(m==="scroll"||m==="scrollend"),ot=bn?bt!==null?bt+"Capture":null:bt;bn=[];for(var nt=pt,ft;nt!==null;){var At=nt;if(ft=At.stateNode,At=At.tag,At!==5&&At!==26&&At!==27||ft===null||ot===null||(At=zi(nt,ot),At!=null&&bn.push(Qx(nt,At,ft))),Ir)break;nt=nt.return}0<bn.length&&(bt=new wt(bt,Kt,null,S,kt),Pt.push({event:bt,listeners:bn}))}}if((b&7)===0){e:{if(bt=m==="mouseover"||m==="pointerover",wt=m==="mouseout"||m==="pointerout",bt&&S!==ui&&(Kt=S.relatedTarget||S.fromElement)&&(It(Kt)||Kt[Dn]))break e;if((wt||bt)&&(bt=kt.window===kt?kt:(bt=kt.ownerDocument)?bt.defaultView||bt.parentWindow:window,wt?(Kt=S.relatedTarget||S.toElement,wt=pt,Kt=Kt?It(Kt):null,Kt!==null&&(Ir=s(Kt),bn=Kt.tag,Kt!==Ir||bn!==5&&bn!==27&&bn!==6)&&(Kt=null)):(wt=null,Kt=pt),wt!==Kt)){if(bn=ha,At="onMouseLeave",ot="onMouseEnter",nt="mouse",(m==="pointerout"||m==="pointerover")&&(bn=AI,At="onPointerLeave",ot="onPointerEnter",nt="pointer"),Ir=wt==null?bt:Ge(wt),ft=Kt==null?bt:Ge(Kt),bt=new bn(At,nt+"leave",wt,S,kt),bt.target=Ir,bt.relatedTarget=ft,At=null,It(kt)===pt&&(bn=new bn(ot,nt+"enter",Kt,S,kt),bn.target=ft,bn.relatedTarget=Ir,At=bn),Ir=At,wt&&Kt)t:{for(bn=Goe,ot=wt,nt=Kt,ft=0,At=ot;At;At=bn(At))ft++;At=0;for(var on=nt;on;on=bn(on))At++;for(;0<ft-At;)ot=bn(ot),ft--;for(;0<At-ft;)nt=bn(nt),At--;for(;ft--;){if(ot===nt||nt!==null&&ot===nt.alternate){bn=ot;break t}ot=bn(ot),nt=bn(nt)}bn=null}else bn=null;wt!==null&&xU(Pt,bt,wt,bn,!1),Kt!==null&&Ir!==null&&xU(Pt,Ir,Kt,bn,!0)}}e:{if(bt=pt?Ge(pt):window,wt=bt.nodeName&&bt.nodeName.toLowerCase(),wt==="select"||wt==="input"&&bt.type==="file")var pr=FI;else if(DI(bt))if(LI)pr=roe;else{pr=toe;var Jt=eoe}else wt=bt.nodeName,!wt||wt.toLowerCase()!=="input"||bt.type!=="checkbox"&&bt.type!=="radio"?pt&&Nt(pt.elementType)&&(pr=FI):pr=noe;if(pr&&(pr=pr(m,pt))){RI(Pt,pr,S,kt);break e}Jt&&Jt(m,bt,pt),m==="focusout"&&pt&&bt.type==="number"&&pt.memoizedProps.value!=null&&Sr(bt,"number",bt.value)}switch(Jt=pt?Ge(pt):window,m){case"focusin":(DI(Jt)||Jt.contentEditable==="true")&&(xp=Jt,qA=pt,Cx=null);break;case"focusout":Cx=qA=xp=null;break;case"mousedown":GA=!0;break;case"contextmenu":case"mouseup":case"dragend":GA=!1,VI(Pt,S,kt);break;case"selectionchange":if(ioe)break;case"keydown":case"keyup":VI(Pt,S,kt)}var In;if(BA)e:{switch(m){case"compositionstart":var or="onCompositionStart";break e;case"compositionend":or="onCompositionEnd";break e;case"compositionupdate":or="onCompositionUpdate";break e}or=void 0}else bp?jI(m,S)&&(or="onCompositionEnd"):m==="keydown"&&S.keyCode===229&&(or="onCompositionStart");or&&(TI&&S.locale!=="ko"&&(bp||or!=="onCompositionStart"?or==="onCompositionEnd"&&bp&&(In=Ui()):(ta=kt,is="value"in ta?ta.value:ta.textContent,bp=!0)),Jt=qw(pt,or),0<Jt.length&&(or=new CI(or,m,null,S,kt),Pt.push({event:or,listeners:Jt}),In?or.data=In:(In=EI(S),In!==null&&(or.data=In)))),(In=Yse?Xse(m,S):Qse(m,S))&&(or=qw(pt,"onBeforeInput"),0<or.length&&(Jt=new CI("onBeforeInput","beforeinput",null,S,kt),Pt.push({event:Jt,listeners:or}),Jt.data=In)),Hoe(Pt,m,pt,S,kt)}gU(Pt,b)})}function Qx(m,b,S){return{instance:m,listener:b,currentTarget:S}}function qw(m,b){for(var S=b+"Capture",P=[];m!==null;){var H=m,X=H.stateNode;if(H=H.tag,H!==5&&H!==26&&H!==27||X===null||(H=zi(m,S),H!=null&&P.unshift(Qx(m,H,X)),H=zi(m,b),H!=null&&P.push(Qx(m,H,X))),m.tag===3)return P;m=m.return}return[]}function Goe(m){if(m===null)return null;do m=m.return;while(m&&m.tag!==5&&m.tag!==27);return m||null}function xU(m,b,S,P,H){for(var X=b._reactName,ve=[];S!==null&&S!==P;){var Ie=S,Xe=Ie.alternate,pt=Ie.stateNode;if(Ie=Ie.tag,Xe!==null&&Xe===P)break;Ie!==5&&Ie!==26&&Ie!==27||pt===null||(Xe=pt,H?(pt=zi(S,X),pt!=null&&ve.unshift(Qx(S,pt,Xe))):H||(pt=zi(S,X),pt!=null&&ve.push(Qx(S,pt,Xe)))),S=S.return}ve.length!==0&&m.push({event:b,listeners:ve})}var Woe=/\r\n?/g,Koe=/\u0000|\uFFFD/g;function yU(m){return(typeof m=="string"?m:""+m).replace(Woe,`
  9. `).replace(Koe,"")}function vU(m,b){return b=yU(b),yU(m)===b}function Or(m,b,S,P,H,X){switch(S){case"children":typeof P=="string"?b==="body"||b==="textarea"&&P===""||sa(m,P):(typeof P=="number"||typeof P=="bigint")&&b!=="body"&&sa(m,""+P);break;case"className":nn(m,"class",P);break;case"tabIndex":nn(m,"tabindex",P);break;case"dir":case"role":case"viewBox":case"width":case"height":nn(m,S,P);break;case"style":Nn(m,P,X);break;case"data":if(b!=="object"){nn(m,"data",P);break}case"src":case"href":if(P===""&&(b!=="a"||S!=="href")){m.removeAttribute(S);break}if(P==null||typeof P=="function"||typeof P=="symbol"||typeof P=="boolean"){m.removeAttribute(S);break}P=ir(""+P),m.setAttribute(S,P);break;case"action":case"formAction":if(typeof P=="function"){m.setAttribute(S,"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 X=="function"&&(S==="formAction"?(b!=="input"&&Or(m,b,"name",H.name,H,null),Or(m,b,"formEncType",H.formEncType,H,null),Or(m,b,"formMethod",H.formMethod,H,null),Or(m,b,"formTarget",H.formTarget,H,null)):(Or(m,b,"encType",H.encType,H,null),Or(m,b,"method",H.method,H,null),Or(m,b,"target",H.target,H,null)));if(P==null||typeof P=="symbol"||typeof P=="boolean"){m.removeAttribute(S);break}P=ir(""+P),m.setAttribute(S,P);break;case"onClick":P!=null&&(m.onclick=mr);break;case"onScroll":P!=null&&tr("scroll",m);break;case"onScrollEnd":P!=null&&tr("scrollend",m);break;case"dangerouslySetInnerHTML":if(P!=null){if(typeof P!="object"||!("__html"in P))throw Error(r(61));if(S=P.__html,S!=null){if(H.children!=null)throw Error(r(60));m.innerHTML=S}}break;case"multiple":m.multiple=P&&typeof P!="function"&&typeof P!="symbol";break;case"muted":m.muted=P&&typeof P!="function"&&typeof P!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(P==null||typeof P=="function"||typeof P=="boolean"||typeof P=="symbol"){m.removeAttribute("xlink:href");break}S=ir(""+P),m.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",S);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":P!=null&&typeof P!="function"&&typeof P!="symbol"?m.setAttribute(S,""+P):m.removeAttribute(S);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":P&&typeof P!="function"&&typeof P!="symbol"?m.setAttribute(S,""):m.removeAttribute(S);break;case"capture":case"download":P===!0?m.setAttribute(S,""):P!==!1&&P!=null&&typeof P!="function"&&typeof P!="symbol"?m.setAttribute(S,P):m.removeAttribute(S);break;case"cols":case"rows":case"size":case"span":P!=null&&typeof P!="function"&&typeof P!="symbol"&&!isNaN(P)&&1<=P?m.setAttribute(S,P):m.removeAttribute(S);break;case"rowSpan":case"start":P==null||typeof P=="function"||typeof P=="symbol"||isNaN(P)?m.removeAttribute(S):m.setAttribute(S,P);break;case"popover":tr("beforetoggle",m),tr("toggle",m),tn(m,"popover",P);break;case"xlinkActuate":ln(m,"http://www.w3.org/1999/xlink","xlink:actuate",P);break;case"xlinkArcrole":ln(m,"http://www.w3.org/1999/xlink","xlink:arcrole",P);break;case"xlinkRole":ln(m,"http://www.w3.org/1999/xlink","xlink:role",P);break;case"xlinkShow":ln(m,"http://www.w3.org/1999/xlink","xlink:show",P);break;case"xlinkTitle":ln(m,"http://www.w3.org/1999/xlink","xlink:title",P);break;case"xlinkType":ln(m,"http://www.w3.org/1999/xlink","xlink:type",P);break;case"xmlBase":ln(m,"http://www.w3.org/XML/1998/namespace","xml:base",P);break;case"xmlLang":ln(m,"http://www.w3.org/XML/1998/namespace","xml:lang",P);break;case"xmlSpace":ln(m,"http://www.w3.org/XML/1998/namespace","xml:space",P);break;case"is":tn(m,"is",P);break;case"innerText":case"textContent":break;default:(!(2<S.length)||S[0]!=="o"&&S[0]!=="O"||S[1]!=="n"&&S[1]!=="N")&&(S=Wn.get(S)||S,tn(m,S,P))}}function b2(m,b,S,P,H,X){switch(S){case"style":Nn(m,P,X);break;case"dangerouslySetInnerHTML":if(P!=null){if(typeof P!="object"||!("__html"in P))throw Error(r(61));if(S=P.__html,S!=null){if(H.children!=null)throw Error(r(60));m.innerHTML=S}}break;case"children":typeof P=="string"?sa(m,P):(typeof P=="number"||typeof P=="bigint")&&sa(m,""+P);break;case"onScroll":P!=null&&tr("scroll",m);break;case"onScrollEnd":P!=null&&tr("scrollend",m);break;case"onClick":P!=null&&(m.onclick=mr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ht.hasOwnProperty(S))e:{if(S[0]==="o"&&S[1]==="n"&&(H=S.endsWith("Capture"),b=S.slice(2,H?S.length-7:void 0),X=m[On]||null,X=X!=null?X[S]:null,typeof X=="function"&&m.removeEventListener(b,X,H),typeof P=="function")){typeof X!="function"&&X!==null&&(S in m?m[S]=null:m.hasAttribute(S)&&m.removeAttribute(S)),m.addEventListener(b,P,H);break e}S in m?m[S]=P:P===!0?m.setAttribute(S,""):tn(m,S,P)}}}function Vi(m,b,S){switch(b){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":tr("error",m),tr("load",m);var P=!1,H=!1,X;for(X in S)if(S.hasOwnProperty(X)){var ve=S[X];if(ve!=null)switch(X){case"src":P=!0;break;case"srcSet":H=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,b));default:Or(m,b,X,ve,S,null)}}H&&Or(m,b,"srcSet",S.srcSet,S,null),P&&Or(m,b,"src",S.src,S,null);return;case"input":tr("invalid",m);var Ie=X=ve=H=null,Xe=null,pt=null;for(P in S)if(S.hasOwnProperty(P)){var kt=S[P];if(kt!=null)switch(P){case"name":H=kt;break;case"type":ve=kt;break;case"checked":Xe=kt;break;case"defaultChecked":pt=kt;break;case"value":X=kt;break;case"defaultValue":Ie=kt;break;case"children":case"dangerouslySetInnerHTML":if(kt!=null)throw Error(r(137,b));break;default:Or(m,b,P,kt,S,null)}}wn(m,X,Ie,Xe,pt,ve,H,!1);return;case"select":tr("invalid",m),P=ve=X=null;for(H in S)if(S.hasOwnProperty(H)&&(Ie=S[H],Ie!=null))switch(H){case"value":X=Ie;break;case"defaultValue":ve=Ie;break;case"multiple":P=Ie;default:Or(m,b,H,Ie,S,null)}b=X,S=ve,m.multiple=!!P,b!=null?ar(m,!!P,b,!1):S!=null&&ar(m,!!P,S,!0);return;case"textarea":tr("invalid",m),X=H=P=null;for(ve in S)if(S.hasOwnProperty(ve)&&(Ie=S[ve],Ie!=null))switch(ve){case"value":P=Ie;break;case"defaultValue":H=Ie;break;case"children":X=Ie;break;case"dangerouslySetInnerHTML":if(Ie!=null)throw Error(r(91));break;default:Or(m,b,ve,Ie,S,null)}Ba(m,P,H,X);return;case"option":for(Xe in S)S.hasOwnProperty(Xe)&&(P=S[Xe],P!=null)&&(Xe==="selected"?m.selected=P&&typeof P!="function"&&typeof P!="symbol":Or(m,b,Xe,P,S,null));return;case"dialog":tr("beforetoggle",m),tr("toggle",m),tr("cancel",m),tr("close",m);break;case"iframe":case"object":tr("load",m);break;case"video":case"audio":for(P=0;P<Xx.length;P++)tr(Xx[P],m);break;case"image":tr("error",m),tr("load",m);break;case"details":tr("toggle",m);break;case"embed":case"source":case"link":tr("error",m),tr("load",m);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(pt in S)if(S.hasOwnProperty(pt)&&(P=S[pt],P!=null))switch(pt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,b));default:Or(m,b,pt,P,S,null)}return;default:if(Nt(b)){for(kt in S)S.hasOwnProperty(kt)&&(P=S[kt],P!==void 0&&b2(m,b,kt,P,S,void 0));return}}for(Ie in S)S.hasOwnProperty(Ie)&&(P=S[Ie],P!=null&&Or(m,b,Ie,P,S,null))}function Yoe(m,b,S,P){switch(b){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var H=null,X=null,ve=null,Ie=null,Xe=null,pt=null,kt=null;for(wt in S){var Pt=S[wt];if(S.hasOwnProperty(wt)&&Pt!=null)switch(wt){case"checked":break;case"value":break;case"defaultValue":Xe=Pt;default:P.hasOwnProperty(wt)||Or(m,b,wt,null,P,Pt)}}for(var bt in P){var wt=P[bt];if(Pt=S[bt],P.hasOwnProperty(bt)&&(wt!=null||Pt!=null))switch(bt){case"type":X=wt;break;case"name":H=wt;break;case"checked":pt=wt;break;case"defaultChecked":kt=wt;break;case"value":ve=wt;break;case"defaultValue":Ie=wt;break;case"children":case"dangerouslySetInnerHTML":if(wt!=null)throw Error(r(137,b));break;default:wt!==Pt&&Or(m,b,bt,wt,P,Pt)}}as(m,ve,Ie,Xe,pt,kt,X,H);return;case"select":wt=ve=Ie=bt=null;for(X in S)if(Xe=S[X],S.hasOwnProperty(X)&&Xe!=null)switch(X){case"value":break;case"multiple":wt=Xe;default:P.hasOwnProperty(X)||Or(m,b,X,null,P,Xe)}for(H in P)if(X=P[H],Xe=S[H],P.hasOwnProperty(H)&&(X!=null||Xe!=null))switch(H){case"value":bt=X;break;case"defaultValue":Ie=X;break;case"multiple":ve=X;default:X!==Xe&&Or(m,b,H,X,P,Xe)}b=Ie,S=ve,P=wt,bt!=null?ar(m,!!S,bt,!1):!!P!=!!S&&(b!=null?ar(m,!!S,b,!0):ar(m,!!S,S?[]:"",!1));return;case"textarea":wt=bt=null;for(Ie in S)if(H=S[Ie],S.hasOwnProperty(Ie)&&H!=null&&!P.hasOwnProperty(Ie))switch(Ie){case"value":break;case"children":break;default:Or(m,b,Ie,null,P,H)}for(ve in P)if(H=P[ve],X=S[ve],P.hasOwnProperty(ve)&&(H!=null||X!=null))switch(ve){case"value":bt=H;break;case"defaultValue":wt=H;break;case"children":break;case"dangerouslySetInnerHTML":if(H!=null)throw Error(r(91));break;default:H!==X&&Or(m,b,ve,H,P,X)}ya(m,bt,wt);return;case"option":for(var Kt in S)bt=S[Kt],S.hasOwnProperty(Kt)&&bt!=null&&!P.hasOwnProperty(Kt)&&(Kt==="selected"?m.selected=!1:Or(m,b,Kt,null,P,bt));for(Xe in P)bt=P[Xe],wt=S[Xe],P.hasOwnProperty(Xe)&&bt!==wt&&(bt!=null||wt!=null)&&(Xe==="selected"?m.selected=bt&&typeof bt!="function"&&typeof bt!="symbol":Or(m,b,Xe,bt,P,wt));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 bn in S)bt=S[bn],S.hasOwnProperty(bn)&&bt!=null&&!P.hasOwnProperty(bn)&&Or(m,b,bn,null,P,bt);for(pt in P)if(bt=P[pt],wt=S[pt],P.hasOwnProperty(pt)&&bt!==wt&&(bt!=null||wt!=null))switch(pt){case"children":case"dangerouslySetInnerHTML":if(bt!=null)throw Error(r(137,b));break;default:Or(m,b,pt,bt,P,wt)}return;default:if(Nt(b)){for(var Ir in S)bt=S[Ir],S.hasOwnProperty(Ir)&&bt!==void 0&&!P.hasOwnProperty(Ir)&&b2(m,b,Ir,void 0,P,bt);for(kt in P)bt=P[kt],wt=S[kt],!P.hasOwnProperty(kt)||bt===wt||bt===void 0&&wt===void 0||b2(m,b,kt,bt,P,wt);return}}for(var ot in S)bt=S[ot],S.hasOwnProperty(ot)&&bt!=null&&!P.hasOwnProperty(ot)&&Or(m,b,ot,null,P,bt);for(Pt in P)bt=P[Pt],wt=S[Pt],!P.hasOwnProperty(Pt)||bt===wt||bt==null&&wt==null||Or(m,b,Pt,bt,P,wt)}function wU(m){switch(m){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Xoe(){if(typeof performance.getEntriesByType=="function"){for(var m=0,b=0,S=performance.getEntriesByType("resource"),P=0;P<S.length;P++){var H=S[P],X=H.transferSize,ve=H.initiatorType,Ie=H.duration;if(X&&Ie&&wU(ve)){for(ve=0,Ie=H.responseEnd,P+=1;P<S.length;P++){var Xe=S[P],pt=Xe.startTime;if(pt>Ie)break;var kt=Xe.transferSize,Pt=Xe.initiatorType;kt&&wU(Pt)&&(Xe=Xe.responseEnd,ve+=kt*(Xe<Ie?1:(Ie-pt)/(Xe-pt)))}if(--P,b+=8*(X+ve)/(H.duration/1e3),m++,10<m)break}}if(0<m)return b/m/1e6}return navigator.connection&&(m=navigator.connection.downlink,typeof m=="number")?m:5}var x2=null,y2=null;function Gw(m){return m.nodeType===9?m:m.ownerDocument}function SU(m){switch(m){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function _U(m,b){if(m===0)switch(b){case"svg":return 1;case"math":return 2;default:return 0}return m===1&&b==="foreignObject"?0:m}function v2(m,b){return m==="textarea"||m==="noscript"||typeof b.children=="string"||typeof b.children=="number"||typeof b.children=="bigint"||typeof b.dangerouslySetInnerHTML=="object"&&b.dangerouslySetInnerHTML!==null&&b.dangerouslySetInnerHTML.__html!=null}var w2=null;function Qoe(){var m=window.event;return m&&m.type==="popstate"?m===w2?!1:(w2=m,!0):(w2=null,!1)}var NU=typeof setTimeout=="function"?setTimeout:void 0,Zoe=typeof clearTimeout=="function"?clearTimeout:void 0,kU=typeof Promise=="function"?Promise:void 0,Joe=typeof queueMicrotask=="function"?queueMicrotask:typeof kU<"u"?function(m){return kU.resolve(null).then(m).catch(ele)}:NU;function ele(m){setTimeout(function(){throw m})}function zd(m){return m==="head"}function CU(m,b){var S=b,P=0;do{var H=S.nextSibling;if(m.removeChild(S),H&&H.nodeType===8)if(S=H.data,S==="/$"||S==="/&"){if(P===0){m.removeChild(H),qp(b);return}P--}else if(S==="$"||S==="$?"||S==="$~"||S==="$!"||S==="&")P++;else if(S==="html")Zx(m.ownerDocument.documentElement);else if(S==="head"){S=m.ownerDocument.head,Zx(S);for(var X=S.firstChild;X;){var ve=X.nextSibling,Ie=X.nodeName;X[st]||Ie==="SCRIPT"||Ie==="STYLE"||Ie==="LINK"&&X.rel.toLowerCase()==="stylesheet"||S.removeChild(X),X=ve}}else S==="body"&&Zx(m.ownerDocument.body);S=H}while(S);qp(b)}function AU(m,b){var S=m;m=0;do{var P=S.nextSibling;if(S.nodeType===1?b?(S._stashedDisplay=S.style.display,S.style.display="none"):(S.style.display=S._stashedDisplay||"",S.getAttribute("style")===""&&S.removeAttribute("style")):S.nodeType===3&&(b?(S._stashedText=S.nodeValue,S.nodeValue=""):S.nodeValue=S._stashedText||""),P&&P.nodeType===8)if(S=P.data,S==="/$"){if(m===0)break;m--}else S!=="$"&&S!=="$?"&&S!=="$~"&&S!=="$!"||m++;S=P}while(S)}function S2(m){var b=m.firstChild;for(b&&b.nodeType===10&&(b=b.nextSibling);b;){var S=b;switch(b=b.nextSibling,S.nodeName){case"HTML":case"HEAD":case"BODY":S2(S),Ye(S);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(S.rel.toLowerCase()==="stylesheet")continue}m.removeChild(S)}}function tle(m,b,S,P){for(;m.nodeType===1;){var H=S;if(m.nodeName.toLowerCase()!==b.toLowerCase()){if(!P&&(m.nodeName!=="INPUT"||m.type!=="hidden"))break}else if(P){if(!m[st])switch(b){case"meta":if(!m.hasAttribute("itemprop"))break;return m;case"link":if(X=m.getAttribute("rel"),X==="stylesheet"&&m.hasAttribute("data-precedence"))break;if(X!==H.rel||m.getAttribute("href")!==(H.href==null||H.href===""?null:H.href)||m.getAttribute("crossorigin")!==(H.crossOrigin==null?null:H.crossOrigin)||m.getAttribute("title")!==(H.title==null?null:H.title))break;return m;case"style":if(m.hasAttribute("data-precedence"))break;return m;case"script":if(X=m.getAttribute("src"),(X!==(H.src==null?null:H.src)||m.getAttribute("type")!==(H.type==null?null:H.type)||m.getAttribute("crossorigin")!==(H.crossOrigin==null?null:H.crossOrigin))&&X&&m.hasAttribute("async")&&!m.hasAttribute("itemprop"))break;return m;default:return m}}else if(b==="input"&&m.type==="hidden"){var X=H.name==null?null:""+H.name;if(H.type==="hidden"&&m.getAttribute("name")===X)return m}else return m;if(m=Ko(m.nextSibling),m===null)break}return null}function nle(m,b,S){if(b==="")return null;for(;m.nodeType!==3;)if((m.nodeType!==1||m.nodeName!=="INPUT"||m.type!=="hidden")&&!S||(m=Ko(m.nextSibling),m===null))return null;return m}function TU(m,b){for(;m.nodeType!==8;)if((m.nodeType!==1||m.nodeName!=="INPUT"||m.type!=="hidden")&&!b||(m=Ko(m.nextSibling),m===null))return null;return m}function _2(m){return m.data==="$?"||m.data==="$~"}function N2(m){return m.data==="$!"||m.data==="$?"&&m.ownerDocument.readyState!=="loading"}function rle(m,b){var S=m.ownerDocument;if(m.data==="$~")m._reactRetry=b;else if(m.data!=="$?"||S.readyState!=="loading")b();else{var P=function(){b(),S.removeEventListener("DOMContentLoaded",P)};S.addEventListener("DOMContentLoaded",P),m._reactRetry=P}}function Ko(m){for(;m!=null;m=m.nextSibling){var b=m.nodeType;if(b===1||b===3)break;if(b===8){if(b=m.data,b==="$"||b==="$!"||b==="$?"||b==="$~"||b==="&"||b==="F!"||b==="F")break;if(b==="/$"||b==="/&")return null}}return m}var k2=null;function MU(m){m=m.nextSibling;for(var b=0;m;){if(m.nodeType===8){var S=m.data;if(S==="/$"||S==="/&"){if(b===0)return Ko(m.nextSibling);b--}else S!=="$"&&S!=="$!"&&S!=="$?"&&S!=="$~"&&S!=="&"||b++}m=m.nextSibling}return null}function PU(m){m=m.previousSibling;for(var b=0;m;){if(m.nodeType===8){var S=m.data;if(S==="$"||S==="$!"||S==="$?"||S==="$~"||S==="&"){if(b===0)return m;b--}else S!=="/$"&&S!=="/&"||b++}m=m.previousSibling}return null}function jU(m,b,S){switch(b=Gw(S),m){case"html":if(m=b.documentElement,!m)throw Error(r(452));return m;case"head":if(m=b.head,!m)throw Error(r(453));return m;case"body":if(m=b.body,!m)throw Error(r(454));return m;default:throw Error(r(451))}}function Zx(m){for(var b=m.attributes;b.length;)m.removeAttributeNode(b[0]);Ye(m)}var Yo=new Map,EU=new Set;function Ww(m){return typeof m.getRootNode=="function"?m.getRootNode():m.nodeType===9?m:m.ownerDocument}var fu=Y.d;Y.d={f:ale,r:ile,D:sle,C:ole,L:lle,m:cle,X:dle,S:ule,M:hle};function ale(){var m=fu.f(),b=Iw();return m||b}function ile(m){var b=Me(m);b!==null&&b.tag===5&&b.type==="form"?Y5(b):fu.r(m)}var Hp=typeof document>"u"?null:document;function DU(m,b,S){var P=Hp;if(P&&typeof b=="string"&&b){var H=dr(b);H='link[rel="'+m+'"][href="'+H+'"]',typeof S=="string"&&(H+='[crossorigin="'+S+'"]'),EU.has(H)||(EU.add(H),m={rel:m,crossOrigin:S,href:b},P.querySelector(H)===null&&(b=P.createElement("link"),Vi(b,"link",m),Qe(b),P.head.appendChild(b)))}}function sle(m){fu.D(m),DU("dns-prefetch",m,null)}function ole(m,b){fu.C(m,b),DU("preconnect",m,b)}function lle(m,b,S){fu.L(m,b,S);var P=Hp;if(P&&m&&b){var H='link[rel="preload"][as="'+dr(b)+'"]';b==="image"&&S&&S.imageSrcSet?(H+='[imagesrcset="'+dr(S.imageSrcSet)+'"]',typeof S.imageSizes=="string"&&(H+='[imagesizes="'+dr(S.imageSizes)+'"]')):H+='[href="'+dr(m)+'"]';var X=H;switch(b){case"style":X=$p(m);break;case"script":X=Vp(m)}Yo.has(X)||(m=h({rel:"preload",href:b==="image"&&S&&S.imageSrcSet?void 0:m,as:b},S),Yo.set(X,m),P.querySelector(H)!==null||b==="style"&&P.querySelector(Jx(X))||b==="script"&&P.querySelector(ey(X))||(b=P.createElement("link"),Vi(b,"link",m),Qe(b),P.head.appendChild(b)))}}function cle(m,b){fu.m(m,b);var S=Hp;if(S&&m){var P=b&&typeof b.as=="string"?b.as:"script",H='link[rel="modulepreload"][as="'+dr(P)+'"][href="'+dr(m)+'"]',X=H;switch(P){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":X=Vp(m)}if(!Yo.has(X)&&(m=h({rel:"modulepreload",href:m},b),Yo.set(X,m),S.querySelector(H)===null)){switch(P){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(S.querySelector(ey(X)))return}P=S.createElement("link"),Vi(P,"link",m),Qe(P),S.head.appendChild(P)}}}function ule(m,b,S){fu.S(m,b,S);var P=Hp;if(P&&m){var H=et(P).hoistableStyles,X=$p(m);b=b||"default";var ve=H.get(X);if(!ve){var Ie={loading:0,preload:null};if(ve=P.querySelector(Jx(X)))Ie.loading=5;else{m=h({rel:"stylesheet",href:m,"data-precedence":b},S),(S=Yo.get(X))&&C2(m,S);var Xe=ve=P.createElement("link");Qe(Xe),Vi(Xe,"link",m),Xe._p=new Promise(function(pt,kt){Xe.onload=pt,Xe.onerror=kt}),Xe.addEventListener("load",function(){Ie.loading|=1}),Xe.addEventListener("error",function(){Ie.loading|=2}),Ie.loading|=4,Kw(ve,b,P)}ve={type:"stylesheet",instance:ve,count:1,state:Ie},H.set(X,ve)}}}function dle(m,b){fu.X(m,b);var S=Hp;if(S&&m){var P=et(S).hoistableScripts,H=Vp(m),X=P.get(H);X||(X=S.querySelector(ey(H)),X||(m=h({src:m,async:!0},b),(b=Yo.get(H))&&A2(m,b),X=S.createElement("script"),Qe(X),Vi(X,"link",m),S.head.appendChild(X)),X={type:"script",instance:X,count:1,state:null},P.set(H,X))}}function hle(m,b){fu.M(m,b);var S=Hp;if(S&&m){var P=et(S).hoistableScripts,H=Vp(m),X=P.get(H);X||(X=S.querySelector(ey(H)),X||(m=h({src:m,async:!0,type:"module"},b),(b=Yo.get(H))&&A2(m,b),X=S.createElement("script"),Qe(X),Vi(X,"link",m),S.head.appendChild(X)),X={type:"script",instance:X,count:1,state:null},P.set(H,X))}}function RU(m,b,S,P){var H=(H=$.current)?Ww(H):null;if(!H)throw Error(r(446));switch(m){case"meta":case"title":return null;case"style":return typeof S.precedence=="string"&&typeof S.href=="string"?(b=$p(S.href),S=et(H).hoistableStyles,P=S.get(b),P||(P={type:"style",instance:null,count:0,state:null},S.set(b,P)),P):{type:"void",instance:null,count:0,state:null};case"link":if(S.rel==="stylesheet"&&typeof S.href=="string"&&typeof S.precedence=="string"){m=$p(S.href);var X=et(H).hoistableStyles,ve=X.get(m);if(ve||(H=H.ownerDocument||H,ve={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},X.set(m,ve),(X=H.querySelector(Jx(m)))&&!X._p&&(ve.instance=X,ve.state.loading=5),Yo.has(m)||(S={rel:"preload",as:"style",href:S.href,crossOrigin:S.crossOrigin,integrity:S.integrity,media:S.media,hrefLang:S.hrefLang,referrerPolicy:S.referrerPolicy},Yo.set(m,S),X||mle(H,m,S,ve.state))),b&&P===null)throw Error(r(528,""));return ve}if(b&&P!==null)throw Error(r(529,""));return null;case"script":return b=S.async,S=S.src,typeof S=="string"&&b&&typeof b!="function"&&typeof b!="symbol"?(b=Vp(S),S=et(H).hoistableScripts,P=S.get(b),P||(P={type:"script",instance:null,count:0,state:null},S.set(b,P)),P):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,m))}}function $p(m){return'href="'+dr(m)+'"'}function Jx(m){return'link[rel="stylesheet"]['+m+"]"}function FU(m){return h({},m,{"data-precedence":m.precedence,precedence:null})}function mle(m,b,S,P){m.querySelector('link[rel="preload"][as="style"]['+b+"]")?P.loading=1:(b=m.createElement("link"),P.preload=b,b.addEventListener("load",function(){return P.loading|=1}),b.addEventListener("error",function(){return P.loading|=2}),Vi(b,"link",S),Qe(b),m.head.appendChild(b))}function Vp(m){return'[src="'+dr(m)+'"]'}function ey(m){return"script[async]"+m}function LU(m,b,S){if(b.count++,b.instance===null)switch(b.type){case"style":var P=m.querySelector('style[data-href~="'+dr(S.href)+'"]');if(P)return b.instance=P,Qe(P),P;var H=h({},S,{"data-href":S.href,"data-precedence":S.precedence,href:null,precedence:null});return P=(m.ownerDocument||m).createElement("style"),Qe(P),Vi(P,"style",H),Kw(P,S.precedence,m),b.instance=P;case"stylesheet":H=$p(S.href);var X=m.querySelector(Jx(H));if(X)return b.state.loading|=4,b.instance=X,Qe(X),X;P=FU(S),(H=Yo.get(H))&&C2(P,H),X=(m.ownerDocument||m).createElement("link"),Qe(X);var ve=X;return ve._p=new Promise(function(Ie,Xe){ve.onload=Ie,ve.onerror=Xe}),Vi(X,"link",P),b.state.loading|=4,Kw(X,S.precedence,m),b.instance=X;case"script":return X=Vp(S.src),(H=m.querySelector(ey(X)))?(b.instance=H,Qe(H),H):(P=S,(H=Yo.get(X))&&(P=h({},S),A2(P,H)),m=m.ownerDocument||m,H=m.createElement("script"),Qe(H),Vi(H,"link",P),m.head.appendChild(H),b.instance=H);case"void":return null;default:throw Error(r(443,b.type))}else b.type==="stylesheet"&&(b.state.loading&4)===0&&(P=b.instance,b.state.loading|=4,Kw(P,S.precedence,m));return b.instance}function Kw(m,b,S){for(var P=S.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),H=P.length?P[P.length-1]:null,X=H,ve=0;ve<P.length;ve++){var Ie=P[ve];if(Ie.dataset.precedence===b)X=Ie;else if(X!==H)break}X?X.parentNode.insertBefore(m,X.nextSibling):(b=S.nodeType===9?S.head:S,b.insertBefore(m,b.firstChild))}function C2(m,b){m.crossOrigin==null&&(m.crossOrigin=b.crossOrigin),m.referrerPolicy==null&&(m.referrerPolicy=b.referrerPolicy),m.title==null&&(m.title=b.title)}function A2(m,b){m.crossOrigin==null&&(m.crossOrigin=b.crossOrigin),m.referrerPolicy==null&&(m.referrerPolicy=b.referrerPolicy),m.integrity==null&&(m.integrity=b.integrity)}var Yw=null;function OU(m,b,S){if(Yw===null){var P=new Map,H=Yw=new Map;H.set(S,P)}else H=Yw,P=H.get(S),P||(P=new Map,H.set(S,P));if(P.has(m))return P;for(P.set(m,null),S=S.getElementsByTagName(m),H=0;H<S.length;H++){var X=S[H];if(!(X[st]||X[gn]||m==="link"&&X.getAttribute("rel")==="stylesheet")&&X.namespaceURI!=="http://www.w3.org/2000/svg"){var ve=X.getAttribute(b)||"";ve=m+ve;var Ie=P.get(ve);Ie?Ie.push(X):P.set(ve,[X])}}return P}function IU(m,b,S){m=m.ownerDocument||m,m.head.insertBefore(S,b==="title"?m.querySelector("head > title"):null)}function fle(m,b,S){if(S===1||b.itemProp!=null)return!1;switch(m){case"meta":case"title":return!0;case"style":if(typeof b.precedence!="string"||typeof b.href!="string"||b.href==="")break;return!0;case"link":if(typeof b.rel!="string"||typeof b.href!="string"||b.href===""||b.onLoad||b.onError)break;return b.rel==="stylesheet"?(m=b.disabled,typeof b.precedence=="string"&&m==null):!0;case"script":if(b.async&&typeof b.async!="function"&&typeof b.async!="symbol"&&!b.onLoad&&!b.onError&&b.src&&typeof b.src=="string")return!0}return!1}function zU(m){return!(m.type==="stylesheet"&&(m.state.loading&3)===0)}function ple(m,b,S,P){if(S.type==="stylesheet"&&(typeof P.media!="string"||matchMedia(P.media).matches!==!1)&&(S.state.loading&4)===0){if(S.instance===null){var H=$p(P.href),X=b.querySelector(Jx(H));if(X){b=X._p,b!==null&&typeof b=="object"&&typeof b.then=="function"&&(m.count++,m=Xw.bind(m),b.then(m,m)),S.state.loading|=4,S.instance=X,Qe(X);return}X=b.ownerDocument||b,P=FU(P),(H=Yo.get(H))&&C2(P,H),X=X.createElement("link"),Qe(X);var ve=X;ve._p=new Promise(function(Ie,Xe){ve.onload=Ie,ve.onerror=Xe}),Vi(X,"link",P),S.instance=X}m.stylesheets===null&&(m.stylesheets=new Map),m.stylesheets.set(S,b),(b=S.state.preload)&&(S.state.loading&3)===0&&(m.count++,S=Xw.bind(m),b.addEventListener("load",S),b.addEventListener("error",S))}}var T2=0;function gle(m,b){return m.stylesheets&&m.count===0&&Zw(m,m.stylesheets),0<m.count||0<m.imgCount?function(S){var P=setTimeout(function(){if(m.stylesheets&&Zw(m,m.stylesheets),m.unsuspend){var X=m.unsuspend;m.unsuspend=null,X()}},6e4+b);0<m.imgBytes&&T2===0&&(T2=62500*Xoe());var H=setTimeout(function(){if(m.waitingForImages=!1,m.count===0&&(m.stylesheets&&Zw(m,m.stylesheets),m.unsuspend)){var X=m.unsuspend;m.unsuspend=null,X()}},(m.imgBytes>T2?50:800)+b);return m.unsuspend=S,function(){m.unsuspend=null,clearTimeout(P),clearTimeout(H)}}:null}function Xw(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zw(this,this.stylesheets);else if(this.unsuspend){var m=this.unsuspend;this.unsuspend=null,m()}}}var Qw=null;function Zw(m,b){m.stylesheets=null,m.unsuspend!==null&&(m.count++,Qw=new Map,b.forEach(ble,m),Qw=null,Xw.call(m))}function ble(m,b){if(!(b.state.loading&4)){var S=Qw.get(m);if(S)var P=S.get(null);else{S=new Map,Qw.set(m,S);for(var H=m.querySelectorAll("link[data-precedence],style[data-precedence]"),X=0;X<H.length;X++){var ve=H[X];(ve.nodeName==="LINK"||ve.getAttribute("media")!=="not all")&&(S.set(ve.dataset.precedence,ve),P=ve)}P&&S.set(null,P)}H=b.instance,ve=H.getAttribute("data-precedence"),X=S.get(ve)||P,X===P&&S.set(null,H),S.set(ve,H),this.count++,P=Xw.bind(this),H.addEventListener("load",P),H.addEventListener("error",P),X?X.parentNode.insertBefore(H,X.nextSibling):(m=m.nodeType===9?m.head:m,m.insertBefore(H,m.firstChild)),b.state.loading|=4}}var ty={$$typeof:N,Provider:null,Consumer:null,_currentValue:se,_currentValue2:se,_threadCount:0};function xle(m,b,S,P,H,X,ve,Ie,Xe){this.tag=1,this.containerInfo=m,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=St(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=St(0),this.hiddenUpdates=St(null),this.identifierPrefix=P,this.onUncaughtError=H,this.onCaughtError=X,this.onRecoverableError=ve,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Xe,this.incompleteTransitions=new Map}function UU(m,b,S,P,H,X,ve,Ie,Xe,pt,kt,Pt){return m=new xle(m,b,S,ve,Xe,pt,kt,Pt,Ie),b=1,X===!0&&(b|=24),X=bo(3,null,null,b),m.current=X,X.stateNode=m,b=oT(),b.refCount++,m.pooledCache=b,b.refCount++,X.memoizedState={element:P,isDehydrated:S,cache:b},dT(X),m}function BU(m){return m?(m=wp,m):wp}function HU(m,b,S,P,H,X){H=BU(H),P.context===null?P.context=H:P.pendingContext=H,P=Td(b),P.payload={element:S},X=X===void 0?null:X,X!==null&&(P.callback=X),S=Md(m,P,b),S!==null&&(Ys(S,m,b),Dx(S,m,b))}function $U(m,b){if(m=m.memoizedState,m!==null&&m.dehydrated!==null){var S=m.retryLane;m.retryLane=S!==0&&S<b?S:b}}function M2(m,b){$U(m,b),(m=m.alternate)&&$U(m,b)}function VU(m){if(m.tag===13||m.tag===31){var b=xm(m,67108864);b!==null&&Ys(b,m,67108864),M2(m,67108864)}}function qU(m){if(m.tag===13||m.tag===31){var b=So();b=Lt(b);var S=xm(m,b);S!==null&&Ys(S,m,b),M2(m,b)}}var Jw=!0;function yle(m,b,S,P){var H=ae.T;ae.T=null;var X=Y.p;try{Y.p=2,P2(m,b,S,P)}finally{Y.p=X,ae.T=H}}function vle(m,b,S,P){var H=ae.T;ae.T=null;var X=Y.p;try{Y.p=8,P2(m,b,S,P)}finally{Y.p=X,ae.T=H}}function P2(m,b,S,P){if(Jw){var H=j2(P);if(H===null)g2(m,b,P,eS,S),WU(m,P);else if(Sle(H,m,b,S,P))P.stopPropagation();else if(WU(m,P),b&4&&-1<wle.indexOf(m)){for(;H!==null;){var X=Me(H);if(X!==null)switch(X.tag){case 3:if(X=X.stateNode,X.current.memoizedState.isDehydrated){var ve=Re(X.pendingLanes);if(ve!==0){var Ie=X;for(Ie.pendingLanes|=2,Ie.entangledLanes|=2;ve;){var Xe=1<<31-_e(ve);Ie.entanglements[1]|=Xe,ve&=~Xe}hc(X),(vr&6)===0&&(Lw=F()+500,Yx(0))}}break;case 31:case 13:Ie=xm(X,2),Ie!==null&&Ys(Ie,X,2),Iw(),M2(X,2)}if(X=j2(P),X===null&&g2(m,b,P,eS,S),X===H)break;H=X}H!==null&&P.stopPropagation()}else g2(m,b,P,null,S)}}function j2(m){return m=an(m),E2(m)}var eS=null;function E2(m){if(eS=null,m=It(m),m!==null){var b=s(m);if(b===null)m=null;else{var S=b.tag;if(S===13){if(m=o(b),m!==null)return m;m=null}else if(S===31){if(m=l(b),m!==null)return m;m=null}else if(S===3){if(b.stateNode.current.memoizedState.isDehydrated)return b.tag===3?b.stateNode.containerInfo:null;m=null}else b!==m&&(m=null)}}return eS=m,null}function GU(m){switch(m){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(J()){case xe:return 2;case he:return 8;case le:case Ce:return 32;case Ne:return 268435456;default:return 32}default:return 32}}var D2=!1,Ud=null,Bd=null,Hd=null,ny=new Map,ry=new Map,$d=[],wle="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 WU(m,b){switch(m){case"focusin":case"focusout":Ud=null;break;case"dragenter":case"dragleave":Bd=null;break;case"mouseover":case"mouseout":Hd=null;break;case"pointerover":case"pointerout":ny.delete(b.pointerId);break;case"gotpointercapture":case"lostpointercapture":ry.delete(b.pointerId)}}function ay(m,b,S,P,H,X){return m===null||m.nativeEvent!==X?(m={blockedOn:b,domEventName:S,eventSystemFlags:P,nativeEvent:X,targetContainers:[H]},b!==null&&(b=Me(b),b!==null&&VU(b)),m):(m.eventSystemFlags|=P,b=m.targetContainers,H!==null&&b.indexOf(H)===-1&&b.push(H),m)}function Sle(m,b,S,P,H){switch(b){case"focusin":return Ud=ay(Ud,m,b,S,P,H),!0;case"dragenter":return Bd=ay(Bd,m,b,S,P,H),!0;case"mouseover":return Hd=ay(Hd,m,b,S,P,H),!0;case"pointerover":var X=H.pointerId;return ny.set(X,ay(ny.get(X)||null,m,b,S,P,H)),!0;case"gotpointercapture":return X=H.pointerId,ry.set(X,ay(ry.get(X)||null,m,b,S,P,H)),!0}return!1}function KU(m){var b=It(m.target);if(b!==null){var S=s(b);if(S!==null){if(b=S.tag,b===13){if(b=o(S),b!==null){m.blockedOn=b,_n(m.priority,function(){qU(S)});return}}else if(b===31){if(b=l(S),b!==null){m.blockedOn=b,_n(m.priority,function(){qU(S)});return}}else if(b===3&&S.stateNode.current.memoizedState.isDehydrated){m.blockedOn=S.tag===3?S.stateNode.containerInfo:null;return}}}m.blockedOn=null}function tS(m){if(m.blockedOn!==null)return!1;for(var b=m.targetContainers;0<b.length;){var S=j2(m.nativeEvent);if(S===null){S=m.nativeEvent;var P=new S.constructor(S.type,S);ui=P,S.target.dispatchEvent(P),ui=null}else return b=Me(S),b!==null&&VU(b),m.blockedOn=S,!1;b.shift()}return!0}function YU(m,b,S){tS(m)&&S.delete(b)}function _le(){D2=!1,Ud!==null&&tS(Ud)&&(Ud=null),Bd!==null&&tS(Bd)&&(Bd=null),Hd!==null&&tS(Hd)&&(Hd=null),ny.forEach(YU),ry.forEach(YU)}function nS(m,b){m.blockedOn===b&&(m.blockedOn=null,D2||(D2=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,_le)))}var rS=null;function XU(m){rS!==m&&(rS=m,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){rS===m&&(rS=null);for(var b=0;b<m.length;b+=3){var S=m[b],P=m[b+1],H=m[b+2];if(typeof P!="function"){if(E2(P||S)===null)continue;break}var X=Me(S);X!==null&&(m.splice(b,3),b-=3,jT(X,{pending:!0,data:H,method:S.method,action:P},P,H))}}))}function qp(m){function b(Xe){return nS(Xe,m)}Ud!==null&&nS(Ud,m),Bd!==null&&nS(Bd,m),Hd!==null&&nS(Hd,m),ny.forEach(b),ry.forEach(b);for(var S=0;S<$d.length;S++){var P=$d[S];P.blockedOn===m&&(P.blockedOn=null)}for(;0<$d.length&&(S=$d[0],S.blockedOn===null);)KU(S),S.blockedOn===null&&$d.shift();if(S=(m.ownerDocument||m).$$reactFormReplay,S!=null)for(P=0;P<S.length;P+=3){var H=S[P],X=S[P+1],ve=H[On]||null;if(typeof X=="function")ve||XU(S);else if(ve){var Ie=null;if(X&&X.hasAttribute("formAction")){if(H=X,ve=X[On]||null)Ie=ve.formAction;else if(E2(H)!==null)continue}else Ie=ve.action;typeof Ie=="function"?S[P+1]=Ie:(S.splice(P,3),P-=3),XU(S)}}}function QU(){function m(X){X.canIntercept&&X.info==="react-transition"&&X.intercept({handler:function(){return new Promise(function(ve){return H=ve})},focusReset:"manual",scroll:"manual"})}function b(){H!==null&&(H(),H=null),P||setTimeout(S,20)}function S(){if(!P&&!navigation.transition){var X=navigation.currentEntry;X&&X.url!=null&&navigation.navigate(X.url,{state:X.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var P=!1,H=null;return navigation.addEventListener("navigate",m),navigation.addEventListener("navigatesuccess",b),navigation.addEventListener("navigateerror",b),setTimeout(S,100),function(){P=!0,navigation.removeEventListener("navigate",m),navigation.removeEventListener("navigatesuccess",b),navigation.removeEventListener("navigateerror",b),H!==null&&(H(),H=null)}}}function R2(m){this._internalRoot=m}aS.prototype.render=R2.prototype.render=function(m){var b=this._internalRoot;if(b===null)throw Error(r(409));var S=b.current,P=So();HU(S,P,m,b,null,null)},aS.prototype.unmount=R2.prototype.unmount=function(){var m=this._internalRoot;if(m!==null){this._internalRoot=null;var b=m.containerInfo;HU(m.current,2,null,m,null,null),Iw(),b[Dn]=null}};function aS(m){this._internalRoot=m}aS.prototype.unstable_scheduleHydration=function(m){if(m){var b=pn();m={blockedOn:null,target:m,priority:b};for(var S=0;S<$d.length&&b!==0&&b<$d[S].priority;S++);$d.splice(S,0,m),S===0&&KU(m)}};var ZU=e.version;if(ZU!=="19.2.4")throw Error(r(527,ZU,"19.2.4"));Y.findDOMNode=function(m){var b=m._reactInternals;if(b===void 0)throw typeof m.render=="function"?Error(r(188)):(m=Object.keys(m).join(","),Error(r(268,m)));return m=u(b),m=m!==null?d(m):null,m=m===null?null:m.stateNode,m};var Nle={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:ae,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var iS=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!iS.isDisabled&&iS.supportsFiber)try{de=iS.inject(Nle),we=iS}catch{}}return sy.createRoot=function(m,b){if(!i(m))throw Error(r(299));var S=!1,P="",H=iz,X=sz,ve=oz;return b!=null&&(b.unstable_strictMode===!0&&(S=!0),b.identifierPrefix!==void 0&&(P=b.identifierPrefix),b.onUncaughtError!==void 0&&(H=b.onUncaughtError),b.onCaughtError!==void 0&&(X=b.onCaughtError),b.onRecoverableError!==void 0&&(ve=b.onRecoverableError)),b=UU(m,1,!1,null,null,S,P,null,H,X,ve,QU),m[Dn]=b.current,p2(m),new R2(b)},sy.hydrateRoot=function(m,b,S){if(!i(m))throw Error(r(299));var P=!1,H="",X=iz,ve=sz,Ie=oz,Xe=null;return S!=null&&(S.unstable_strictMode===!0&&(P=!0),S.identifierPrefix!==void 0&&(H=S.identifierPrefix),S.onUncaughtError!==void 0&&(X=S.onUncaughtError),S.onCaughtError!==void 0&&(ve=S.onCaughtError),S.onRecoverableError!==void 0&&(Ie=S.onRecoverableError),S.formState!==void 0&&(Xe=S.formState)),b=UU(m,1,!0,b,S??null,P,H,Xe,X,ve,Ie,QU),b.context=BU(null),S=b.current,P=So(),P=Lt(P),H=Td(P),H.callback=null,Md(S,H,P),S=P,b.current.lanes=S,Mt(b,S),hc(b),m[Dn]=b.current,p2(m),new aS(b)},sy.version="19.2.4",sy}var lB;function Fle(){if(lB)return O2.exports;lB=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(),O2.exports=Rle(),O2.exports}var Lle=Fle();const kn=t=>typeof t=="string",oy=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},cB=t=>t==null?"":""+t,Ole=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Ile=/###/g,uB=t=>t&&t.indexOf("###")>-1?t.replace(Ile,"."):t,dB=t=>!t||kn(t),Xy=(t,e,n)=>{const r=kn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(dB(t))return{};const s=uB(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return dB(t)?{}:{obj:t,k:uB(r[i])}},hB=(t,e,n)=>{const{obj:r,k:i}=Xy(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=Xy(t,o,Object);for(;l.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),l=Xy(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${s}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${s}`]=n},zle=(t,e,n,r)=>{const{obj:i,k:s}=Xy(t,e,Object);i[s]=i[s]||[],i[s].push(n)},S1=(t,e)=>{const{obj:n,k:r}=Xy(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Ule=(t,e,n)=>{const r=S1(t,n);return r!==void 0?r:S1(e,n)},UK=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?kn(t[r])||t[r]instanceof String||kn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):UK(t[r],e[r],n):t[r]=e[r]);return t},Gp=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ble={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Hle=t=>kn(t)?t.replace(/[&<>"'\/]/g,e=>Ble[e]):t;class $le{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 Vle=[" ",",","?","!",";"],qle=new $le(20),Gle=(t,e,n)=>{e=e||"",n=n||"";const r=Vle.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=qle.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},JE=(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},v0=t=>t?.replace("_","-"),Wle={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 _1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Wle,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:(kn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new _1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new _1(this.logger,e)}}var Ac=new _1;let Wk=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 mB extends Wk{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):kn(r)&&s?l.push(...r.split(s)):l.push(r)));const c=S1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!kn(r)?c:JE(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),hB(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)(kn(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=S1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?UK(c,r,s):c={...c,...r},hB(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 BK={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 HK=Symbol("i18next/PATH_KEY");function Kle(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===HK?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function e3(t,e){const{[HK]:n}=t(Kle());return n.join(e?.keySeparator??".")}const fB={},B2=t=>!kn(t)&&typeof t!="boolean"&&typeof t!="number";class N1 extends Wk{constructor(e,n={}){super(),Ole(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ac.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=B2(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&&!Gle(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:kn(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:kn(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=e3(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,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return f?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 p=this.resolve(e,i);let x=p?.res;const v=p?.usedKey||l,g=p?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],_=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!kn(i.count),C=N1.hasDefaultValue(i),j=A?this.pluralResolver.getSuffix(h,i.count,i):"",k=i.ordinal&&A?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",R=A&&!i.ordinal&&i.count===0,M=R&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${j}`]||i[`defaultValue${k}`]||i.defaultValue;let D=x;N&&!x&&C&&(D=M);const G=B2(D),U=Object.prototype.toString.apply(D);if(N&&D&&G&&y.indexOf(U)<0&&!(kn(_)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const W=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,D,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return s?(p.res=W,p.usedParams=this.getUsedParamsDetails(i),p):W}if(o){const W=Array.isArray(D),L=W?[]:{},ee=W?g:v;for(const ae in D)if(Object.prototype.hasOwnProperty.call(D,ae)){const Y=`${ee}${o}${ae}`;C&&!x?L[ae]=this.translate(Y,{...i,defaultValue:B2(M)?M[ae]:void 0,joinArrays:!1,ns:c}):L[ae]=this.translate(Y,{...i,joinArrays:!1,ns:c}),L[ae]===Y&&(L[ae]=D[ae])}x=L}}else if(N&&kn(_)&&Array.isArray(x))x=x.join(_),x&&(x=this.extendTranslation(x,e,i,r));else{let W=!1,L=!1;!this.isValidLookup(x)&&C&&(W=!0,x=M),this.isValidLookup(x)||(L=!0,x=l);const ae=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&L?void 0:x,Y=C&&M!==x&&this.options.updateMissing;if(L||W||Y){if(this.logger.log(Y?"updateKey":"missingKey",h,u,l,Y?M:x),o){const Z=this.resolve(l,{...i,keySeparator:!1});Z&&Z.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 se=[];const ce=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ce&&ce[0])for(let Z=0;Z<ce.length;Z++)se.push(ce[Z]);else this.options.saveMissingTo==="all"?se=this.languageUtils.toResolveHierarchy(i.lng||this.language):se.push(i.lng||this.language);const ye=(Z,ue,pe)=>{const be=C&&pe!==x?pe:ae;this.options.missingKeyHandler?this.options.missingKeyHandler(Z,u,ue,be,Y,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(Z,u,ue,be,Y,i),this.emit("missingKey",Z,u,ue,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?se.forEach(Z=>{const ue=this.pluralResolver.getSuffixes(Z,i);R&&i[`defaultValue${this.options.pluralSeparator}zero`]&&ue.indexOf(`${this.options.pluralSeparator}zero`)<0&&ue.push(`${this.options.pluralSeparator}zero`),ue.forEach(pe=>{ye([Z],l+pe,i[`defaultValue${pe}`]||M)})}):ye(se,l,M))}x=this.extendTranslation(x,e,i,p,r),L&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(L||W)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,W?x:void 0,i))}return s?(p.res=x,p.usedParams=this.getUsedParamsDetails(i),p):x}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=kn(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&&!kn(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),f=h&&h.length;u<f&&(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=kn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=BK.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 kn(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 f=n.count!==void 0&&!kn(n.count),p=f&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(kn(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(g=>{this.isValidLookup(r)||(l=g,!fB[`${v[0]}-${g}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(fB[`${v[0]}-${g}`]=!0,this.logger.warn(`key "${i}" for languages "${v.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!!!")),v.forEach(y=>{if(this.isValidLookup(r))return;o=y;const _=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(_,d,y,g,n);else{let A;f&&(A=this.pluralResolver.getSuffix(y,n.count,n));const C=`${this.options.pluralSeparator}zero`,j=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(f&&(n.ordinal&&A.indexOf(j)===0&&_.push(d+A.replace(j,this.options.pluralSeparator)),_.push(d+A),p&&_.push(d+C)),x){const k=`${d}${this.options.contextSeparator||"_"}${n.context}`;_.push(k),f&&(n.ordinal&&A.indexOf(j)===0&&_.push(k+A.replace(j,this.options.pluralSeparator)),_.push(k+A),p&&_.push(k+C))}}let N;for(;N=_.pop();)this.isValidLookup(r)||(s=N,r=this.getResource(y,g,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&&!kn(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 pB{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ac.create("languageUtils")}getScriptPartFromCode(e){if(e=v0(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=v0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(kn(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)),kn(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 kn(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))):kn(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const gB={zero:0,one:1,two:2,few:3,many:4,other:5},bB={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Yle{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Ac.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=v0(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!"),bB;if(!e.match(/-|_/))return bB;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)=>gB[i]-gB[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 xB=(t,e,n,r=".",i=!0)=>{let s=Ule(t,e,n);return!s&&i&&kn(n)&&(s=JE(t,n,r),s===void 0&&(s=JE(e,n,r))),s},H2=t=>t.replace(/\$/g,"$$$$");class Xle{constructor(e={}){this.logger=Ac.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:f,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:v,nestingOptionsSeparator:g,maxReplaces:y,alwaysFormat:_}=e.interpolation;this.escape=n!==void 0?n:Hle,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Gp(s):o||"{{",this.suffix=l?Gp(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=f?Gp(f):p||Gp("$t("),this.nestingSuffix=x?Gp(x):v||Gp(")"),this.nestingOptionsSeparator=g||",",this.maxReplaces=y||1e3,this.alwaysFormat=_!==void 0?_:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=p=>{if(p.indexOf(this.formatSeparator)<0){const y=xB(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...i,...n,interpolationkey:p}):y}const x=p.split(this.formatSeparator),v=x.shift().trim(),g=x.join(this.formatSeparator).trim();return this.format(xB(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),g,r,{...i,...n,interpolationkey:v})};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:p=>H2(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?H2(this.escape(p)):H2(p)}].forEach(p=>{for(l=0;s=p.regex.exec(e);){const x=s[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const g=d(e,s,i);o=kn(g)?g:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!kn(o)&&!this.useRawValueToEscape&&(o=cB(o));const v=p.safeValue(o);if(e=e.replace(s[0],v),h?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=s[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const h=c.split(new RegExp(`${d}[ ]*{`));let f=`{${h[1]}`;c=h[0],f=this.interpolate(f,o);const p=f.match(/'/g),x=f.match(/"/g);((p?.length??0)%2===0&&!x||x.length%2!==0)&&(f=f.replace(/'/g,'"'));try{o=JSON.parse(f),u&&(o={...u,...o})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${f}`}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&&!kn(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&&!kn(s))return s;kn(s)||(s=cB(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 Qle=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}},yB=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(v0(r),i),e[o]=l),l(n)}},Zle=t=>(e,n,r)=>t(v0(n),r)(e);class Jle{constructor(e={}){this.logger=Ac.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?yB:Zle;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()]=yB(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}=Qle(c);if(this.formats[u]){let h=l;try{const f=i?.formatParams?.[i.interpolationkey]||{},p=f.locale||f.lng||i.locale||i.lng||r;h=this.formats[u](l,p,{...d,...i,...f})}catch(f){this.logger.warn(f)}return h}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const ece=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class tce extends Wk{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Ac.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 f=`${u}|${h}`;!r.reload&&this.store.hasResourceBundle(u,h)?this.state[f]=2:this.state[f]<0||(this.state[f]===1?o[f]===void 0&&(o[f]=!0):(this.state[f]=1,d=!1,o[f]===void 0&&(o[f]=!0),s[f]===void 0&&(s[f]=!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=>{zle(c.loaded,[s],o),ece(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();kn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),kn(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 vB=()=>({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]),kn(t[1])&&(e.defaultValue=t[1]),kn(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}),wB=t=>(kn(t.ns)&&(t.ns=[t.ns]),kn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),kn(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),oS=()=>{},nce=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Qy extends Wk{constructor(e={},n){if(super(),this.options=wB(e),this.services={},this.logger=Ac,this.modules={external:[]},nce(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&&(kn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=vB();this.options={...r,...this.options,...wB(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?Ac.init(i(this.modules.logger),this.options):Ac.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Jle;const d=new pB(this.options);this.store=new mB(this.options.resources,this.options);const h=this.services;h.logger=Ac,h.resourceStore=this.store,h.languageUtils=d,h.pluralResolver=new Yle(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 Xle(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new tce(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(p,...x)=>{this.emit(p,...x)}),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 N1(this.services,this.options),this.translator.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=oS),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=oy(),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=oS){let r=n;const i=kn(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=oy();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=oS),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"&&BK.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=oy();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=kn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(kn(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=e3(h,{...this.options,...o})),`${c.keyPrefix}${u}${h}`)):(typeof s=="function"&&(s=e3(s,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${s}`:s),this.t(d,c)};return kn(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=oy();return this.options.ns?(kn(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=oy();kn(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 pB(vB());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 Qy(e,n);return r.createInstance=Qy.createInstance,r}cloneInstance(e={},n=oS){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Qy(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 mB(l,i),s.services.resourceStore=s.store}return s.translator=new N1(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 Hs=Qy.createInstance();Hs.createInstance;Hs.dir;Hs.init;Hs.loadResources;Hs.reloadResources;Hs.use;Hs.changeLanguage;Hs.getFixedT;Hs.t;Hs.exists;Hs.setDefaultNamespace;Hs.hasLoadedNamespace;Hs.loadNamespaces;Hs.loadLanguages;const rce=(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);Df(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},SB={},$K=(t,e,n,r)=>{Df(n)&&SB[n]||(Df(n)&&(SB[n]=new Date),rce(t,e,n,r))},VK=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},t3=(t,e,n)=>{t.loadNamespaces(e,VK(t,n))},_B=(t,e,n,r)=>{if(Df(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return t3(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,VK(t,r))},ace=(t,e,n={})=>!e.languages||!e.languages.length?($K(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}}),Df=t=>typeof t=="string",ice=t=>typeof t=="object"&&t!==null,sce=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,oce={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},lce=t=>oce[t],cce=t=>t.replace(sce,lce);let n3={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:cce,transDefaultProps:void 0};const uce=(t={})=>{n3={...n3,...t}},dce=()=>n3;let qK;const hce=t=>{qK=t},mce=()=>qK,fce={type:"3rdParty",init(t){uce(t.options.react),hce(t)}},pce=w.createContext();class gce{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var $2={exports:{}},V2={};var NB;function bce(){if(NB)return V2;NB=1;var t=sp();function e(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,o=t.useDebugValue;function l(h,f){var p=f(),x=r({inst:{value:p,getSnapshot:f}}),v=x[0].inst,g=x[1];return s(function(){v.value=p,v.getSnapshot=f,c(v)&&g({inst:v})},[h,p,f]),i(function(){return c(v)&&g({inst:v}),h(function(){c(v)&&g({inst:v})})},[h]),o(p),p}function c(h){var f=h.getSnapshot;h=h.value;try{var p=f();return!n(h,p)}catch{return!0}}function u(h,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return V2.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,V2}var kB;function GK(){return kB||(kB=1,$2.exports=bce()),$2.exports}var wF=GK();const xce=(t,e)=>Df(e)?e:ice(e)&&Df(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,yce={t:xce,ready:!1},vce=()=>()=>{},Et=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(pce)||{},s=n||r||mce();s&&!s.reportNamespaces&&(s.reportNamespaces=new gce),s||$K(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...dce(),...s?.options?.react,...e}),[s,e]),{useSuspense:l,keyPrefix:c}=o,u=i||s?.options?.defaultNS,d=Df(u)?[u]:u||["translation"],h=w.useMemo(()=>d,d);s?.reportNamespaces?.addUsedNamespaces?.(h);const f=w.useRef(0),p=w.useCallback(M=>{if(!s)return vce;const{bindI18n:D,bindI18nStore:G}=o,U=()=>{f.current+=1,M()};return D&&s.on(D,U),G&&s.store.on(G,U),()=>{D&&D.split(" ").forEach(W=>s.off(W,U)),G&&G.split(" ").forEach(W=>s.store.off(W,U))}},[s,o]),x=w.useRef(),v=w.useCallback(()=>{if(!s)return yce;const M=!!(s.isInitialized||s.initializedStoreOnce)&&h.every(ee=>ace(ee,s,o)),D=e.lng||s.language,G=f.current,U=x.current;if(U&&U.ready===M&&U.lng===D&&U.keyPrefix===c&&U.revision===G)return U;const L={t:s.getFixedT(D,o.nsMode==="fallback"?h:h[0],c),ready:M,lng:D,keyPrefix:c,revision:G};return x.current=L,L},[s,h,c,o,e.lng]),[g,y]=w.useState(0),{t:_,ready:N}=wF.useSyncExternalStore(p,v,v);w.useEffect(()=>{if(s&&!N&&!l){const M=()=>y(D=>D+1);e.lng?_B(s,e.lng,h,M):t3(s,h,M)}},[s,e.lng,h,N,l,g]);const A=s||{},C=w.useRef(null),j=w.useRef(),k=M=>{const D=Object.getOwnPropertyDescriptors(M);D.__original&&delete D.__original;const G=Object.create(Object.getPrototypeOf(M),D);if(!Object.prototype.hasOwnProperty.call(G,"__original"))try{Object.defineProperty(G,"__original",{value:M,writable:!1,enumerable:!1,configurable:!1})}catch{}return G},R=w.useMemo(()=>{const M=A,D=M?.language;let G=M;M&&(C.current&&C.current.__original===M?j.current!==D?(G=k(M),C.current=G,j.current=D):G=C.current:(G=k(M),C.current=G,j.current=D));const U=[_,G,N];return U.t=_,U.i18n=G,U.ready=N,U},[_,A,N,A.resolvedLanguage,A.language,A.languages]);if(s&&l&&!N)throw new Promise(M=>{const D=()=>M();e.lng?_B(s,e.lng,h,D):t3(s,h,D)});return R},{slice:wce,forEach:Sce}=[];function _ce(t){return Sce.call(wce.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Nce(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 CB=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,kce=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(!CB.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!CB.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},AB={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=kce(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 Cce={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return AB.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&AB.create(n,t,r,i,s)}},Ace={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}},Tce={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 Wp=null;const TB=()=>{if(Wp!==null)return Wp;try{if(Wp=typeof window<"u"&&window.localStorage!==null,!Wp)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Wp=!1}return Wp};var Mce={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&TB())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&TB()&&window.localStorage.setItem(n,t)}};let Kp=null;const MB=()=>{if(Kp!==null)return Kp;try{if(Kp=typeof window<"u"&&window.sessionStorage!==null,!Kp)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Kp=!1}return Kp};var Pce={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&MB())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&MB()&&window.sessionStorage.setItem(n,t)}},jce={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}},Ece={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}},Dce={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}},Rce={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 WK=!1;try{document.cookie,WK=!0}catch{}const KK=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];WK||KK.splice(1,1);const Fce=()=>({order:KK,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class YK{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=_ce(n,this.options||{},Fce()),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(Cce),this.addDetector(Ace),this.addDetector(Mce),this.addDetector(Pce),this.addDetector(jce),this.addDetector(Ece),this.addDetector(Dce),this.addDetector(Rce),this.addDetector(Tce)}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&&!Nce(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)}))}}YK.type="languageDetector";const Lce={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",inventory:"Filament",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",export:"Export",import:"Import",clear:"Clear",selectAll:"Select All",deselectAll:"Deselect All",noChange:"— No change —",unchanged:"Unchanged",unassigned:"Unassigned",unknown:"Unknown",unknownError:"Unknown error",today:"Today",tomorrow:"Tomorrow",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:{available:"Available",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",nextAvailable:"Next available",powerOn:"Power On",offlinePrintersWithPlugs:"Offline printers with smart plugs",noPrintersConfigured:"No printers configured yet",readyToPrint:"Ready to print",external:"External",extL:"Ext-L",extR:"Ext-R",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",noCamera:"You do not have permission to view cameras"},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",confirmTitle:"Skip Object?",confirmMessage:'Are you sure you want to skip "{{name}}"? This cannot be undone.'},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."},developerModeWarning:"Developer LAN mode is not enabled on: {{names}}. Some features may not work.",howToEnable:"How to enable"},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",logView:"Print Log",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",timelapseRemoved:"Timelapse removed",failedRemoveTimelapse:"Failed to remove timelapse",timelapseUploaded:"Timelapse uploaded: {{filename}}",failedUploadTimelapse:"Failed to upload 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",uploadTimelapse:"Upload Timelapse",removeTimelapse:"Remove 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",noFileForReprint:"No 3MF file available — the file could not be downloaded from the printer when the print was recorded",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}}"?',removeTimelapse:"Remove Timelapse",removeTimelapseConfirm:'Are you sure you want to remove the timelapse video 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"},log:{date:"Date",printName:"Print Name",printer:"Printer",user:"User",status:"Status",duration:"Duration",filament:"Filament",allPrinters:"All Printers",allUsers:"All Users",allStatuses:"All Statuses",cancelled:"Cancelled",skipped:"Skipped",dateFrom:"From",dateTo:"To",noEntries:"No print log entries found",showing:"Showing {{count}} of {{total}} entries",rowsPerPage:"Rows",page:"Page",prev:"Prev",next:"Next",clearLog:"Clear Log",clearLogTitle:"Clear Print Log",clearLogConfirm:"All print log entries will be permanently deleted. Archives and queue items are not affected. This action cannot be undone. Are you sure?",clearLogButton:"Clear All",cleared:"{{count}} log entries cleared",clearFailed:"Failed to clear print log"}},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",plateNumber:"Plate {{index}}",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",totalWeight:"Total Queue Weight",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"}},backgroundDispatch:{unknownFile:"Unknown file",unknownPrinter:"Unknown printer",startingPrints:"Starting prints",progressSummary:"{{complete}}/{{total}} complete • Dispatched: {{dispatched}} • Processing: {{processing}}",expandDetails:"Expand dispatch details",collapseDetails:"Collapse dispatch details",dismissToast:"Dismiss dispatch toast",cancelDispatchJob:"Cancel dispatch job",cancel:"Cancel",cancelling:"Cancelling…",status:{dispatched:"Dispatched",processing:"Processing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"},toast:{cancellingUpload:"Cancelling upload...",cancelled:"Dispatch cancelled",cancelFailed:"Failed to cancel dispatch",completeWithFailures:"Background dispatch complete: {{completed}} succeeded, {{failed}} failed",completeSuccess:"Background dispatch complete: {{completed}} succeeded"}},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",noPrintDataInRange:"No print data in selected range",periodFilament:"Period Filament",periodCost:"Period Cost",avgPerPrint:"Avg per Print",usageOverTime:"Usage Over Time",filamentByWeight:"Weight",printDuration:"Print Duration",printerUtilization:"Printer Utilization",filamentSuccess:"Success by Material",printHabits:"Print Habits",printTimeOfDay:"Print Time of Day",colorDistribution:"Color Distribution",noColorData:"No color data available",records:"Records",longestPrint:"Longest Print",heaviestPrint:"Heaviest Print",mostExpensivePrint:"Most Expensive",busiestDay:"Busiest Day",successStreak:"Success Streak",streakPrint:"consecutive print",streakPrints:"{{count}} consecutive prints",printerStats:"Printer Stats",hours:"hours",avgPrints:"Avg. prints",noArchiveData:"No print data available",filamentByTime:"Time",avgWeight:"Avg. weight",avgTime:"Avg. time",filamentByPrints:"Prints",timeframe:{today:"Today","this-week":"This Week","this-month":"This Month","last-7":"Last 7 Days","last-30":"Last 30 Days","last-90":"Last 90 Days","this-year":"This Year","all-time":"All Time",custom:"Custom Range",from:"From",to:"To"}},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",restoreDefaults:"Restore Default Tasks",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:{lubricateCarbonRods:"Lubricate Carbon Rods",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",cleanLinearRails:"Clean Linear Rails",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",defaultsRestored:"Restored {{count}} default task(s)",printHoursUpdated:"Print hours updated",printerAssigned:"Printer assigned",printerRemoved:"Printer removed",deleteTypeConfirm:'Delete "{{name}}"?',deleteSystemTypeTitle:"Delete default maintenance task?",deleteSystemTypeMessage:'Are you sure you want to delete the default maintenance task "{{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",bedCooledThreshold:"Bed Cooled Threshold",bedCooledThresholdDescription:"Temperature below which the bed is considered cooled after a print",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"},filamentTracking:"Filament Tracking",filamentTrackingDesc:"Choose how to track your filament spools. You can use the built-in inventory or connect an external Spoolman server.",trackingModeBuiltIn:"Built-in Inventory",trackingModeBuiltInDesc:"RFID auto-matching and usage tracking included",trackingModeSpoolmanDesc:"External filament management server",builtInFeatureRfid:"Automatically detects Bambu Lab RFID spools in AMS",builtInFeatureUsage:"Tracks filament consumption per print",builtInFeatureCatalog:"Manage spools, colors, and K-factor profiles",builtInFeatureThirdParty:"Third-party spools can be assigned to inventory spools",amsSyncButton:"Sync Weights from AMS",amsSyncTitle:"Sync Spool Weights from AMS",amsSyncMessage:"This will overwrite all inventory spool weights with the current AMS remain% values from connected printers. Use this to recover from corrupted weight data. Printers must be online.",amsSyncing:"Syncing...",amsSyncSuccess:"{{synced}} spool(s) synced, {{skipped}} skipped",amsSyncError:"Failed to sync weights from AMS",spoolmanUrl:"Spoolman URL",spoolmanUrlHint:"URL of your Spoolman server (e.g., http://localhost:7912)",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected",status:"Status",connect:"Connect",disconnect:"Disconnect",howSyncWorks:"How Sync Works",syncInfoRfidOnly:"Only official Bambu Lab spools with RFID are synced",syncInfoAutoCreate:"New spools are auto-created in Spoolman on first sync",syncInfoThirdPartySkipped:"Non-Bambu Lab spools (third-party, refilled) are skipped",linkingExistingSpools:"Linking Existing Spools",linkingExistingSpoolsDesc:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".',syncMode:"Sync Mode",syncModeAuto:"Automatic",syncModeManual:"Manual Only",syncModeAutoDesc:"AMS data syncs automatically when changes are detected",syncModeManualDesc:"Only sync when manually triggered",syncAmsData:"Sync AMS Data",syncAmsDataDesc:"Manually sync printer AMS data to Spoolman",allPrinters:"All Printers",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",includeBetaUpdates:"Include beta versions",includeBetaUpdatesDesc:"Notify about beta and prerelease versions when checking for updates",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",storageUsage:"Storage Usage",storageUsageDescription:"Breakdown of data usage by category",storageUsageTotal:"Total",storageUsageErrors:"Errors",storageUsageOtherBreakdown:"Other (includes static assets, scripts, and configuration files)",storageUsageSystem:"System",storageUsageData:"Data",storageUsageUnavailable:"Storage usage information unavailable",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",catalog:{spoolCatalog:"Spool Catalog",spoolCatalogDescription:"Empty spool weights by brand/type. Used for automatic weight lookup when adding spools.",searchCatalog:"Search catalog...",addNewEntry:"Add New Entry",namePlaceholder:"Name (e.g., Bambu Lab - Plastic)",weight:"Weight",type:"Type",default:"Default",custom:"Custom",noMatch:"No entries match your search",empty:"No entries in catalog",deleteEntry:"Delete Entry",deleteConfirm:'Are you sure you want to delete "{{name}}"?',resetCatalog:"Reset Catalog",resetConfirm:"Reset catalog to defaults? This will remove all custom entries.",loadFailed:"Failed to load spool catalog",nameWeightRequired:"Name and weight are required",entryAdded:"Entry added",addFailed:"Failed to add entry",entryUpdated:"Entry updated",updateFailed:"Failed to update entry",entryDeleted:"Entry deleted",deleteFailed:"Failed to delete entry",resetSuccess:"Catalog reset to defaults",resetFailed:"Failed to reset catalog",exported:"Exported {{count}} entries",imported:"Imported {{added}} entries ({{skipped}} skipped)",importFailed:"Failed to import: invalid JSON format",exportTooltip:"Export catalog to JSON",importTooltip:"Import catalog from JSON",resetTooltip:"Reset to defaults"},colorCatalog:{title:"Color Catalog",description:"Filament colors by manufacturer/material. Used for automatic color lookup when adding spools.",searchColors:"Search colors...",allManufacturers:"All manufacturers",addNewColor:"Add New Color",manufacturer:"Manufacturer",colorName:"Color Name",hex:"Hex",materialOptional:"Material (optional)",showing:"Showing {{filtered}} of {{total}} colors",noMatch:"No colors match your search",empty:"No colors in catalog",deleteColor:"Delete Color",deleteConfirm:'Are you sure you want to delete "{{name}}"?',resetCatalog:"Reset Color Catalog",resetConfirm:"Reset catalog to defaults? This will remove all custom colors.",sync:"Sync",starting:"Starting...",syncTooltip:"Sync from FilamentColors.xyz (2000+ colors, may take a minute)",loadFailed:"Failed to load color catalog",fieldsRequired:"Manufacturer, color name, and hex color are required",colorAdded:"Color added",addFailed:"Failed to add color",colorUpdated:"Color updated",updateFailed:"Failed to update color",colorDeleted:"Color deleted",deleteFailed:"Failed to delete color",resetSuccess:"Color catalog reset to defaults",resetFailed:"Failed to reset catalog",syncUpToDate:"Already up to date ({{count}} colors checked)",syncComplete:"Added {{added}} new colors ({{skipped}} already existed)",syncError:"Sync error",syncFailed:"Failed to sync from FilamentColors.xyz",exported:"Exported {{count}} colors",imported:"Imported {{added}} colors ({{skipped}} skipped)",importFailed:"Failed to import: invalid JSON format"}},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.",clearErrors:"Clear Errors",clearSuccess:"HMS errors cleared",clearFailed:"Failed to clear HMS errors"},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"},editor:{title:"Edit Group",createTitle:"Create Group",search:"Search permissions...",selectAll:"Select All",clearAll:"Clear All",permissionsSelected:"{{count}} selected",noResults:"No permissions match your search"}},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",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."},inventory:{title:"Spool Inventory",addSpool:"Add Spool",editSpool:"Edit Spool",material:"Material",selectMaterial:"Select material...",subtype:"Subtype",brand:"Brand",searchBrand:"Search brand...",useCustomBrand:'Use "{{brand}}"',useCustomMaterial:"Use custom material: {{material}}",colorName:"Color Name",colorNamePlaceholder:"Jade White, Fire Red...",color:"Color",hexColor:"Hex Color",pickColor:"Pick custom color",labelWeight:"Label Weight",coreWeight:"Empty Spool Weight",searchSpoolWeight:"Search spool weight...",weightUsed:"Used",currentWeight:"Remaining Weight",measuredWeight:"Measured Weight",costPerKg:"Cost per kg",measuredWeightError:"Measured weight must be between {{min}}g and {{max}}g.",slicerFilament:"Slicer Filament",slicerFilamentName:"Slicer Preset Name",slicerPreset:"Slicer Preset",searchPresets:"Search filament presets...",selectedPreset:"Selected",noPresetsFound:"No presets found",tempOverrides:"Temperature Overrides",note:"Note",notePlaceholder:"Any additional notes about this spool...",archive:"Archive",restore:"Restore",noSpools:"No spools yet. Add your first spool to get started.",noManualSpools:"No manually added spools available. Add a spool to your inventory first.",kProfiles:"K-Profiles",addKProfile:"Add K-Profile",assignSpool:"Assign Spool",unassignSpool:"Unassign",assignSuccess:"Spool assigned and AMS slot configured",assignFailed:"Failed to assign spool",selectSpool:"Select a spool to assign to this slot",assigned:"Assigned",assigning:"Assigning...",searchSpools:"Search spools...",allMaterials:"All Materials",filterByBrand:"Filter by brand...",showArchived:"Show archived",quickAdd:"Quick Add (Stock)",quantity:"Quantity",stock:"Stock",configured:"Configured",spoolsCreated:"{{count}} spools created",spoolCreated:"Spool created",spoolUpdated:"Spool updated",spoolDeleted:"Spool deleted",spoolArchived:"Spool archived",spoolRestored:"Spool restored",deleteConfirm:"Are you sure you want to delete this spool? This cannot be undone.",archiveConfirm:"Are you sure you want to archive this spool?",advancedSettings:"Advanced Settings",filamentInfoTab:"Filament Info",paProfileTab:"PA Profile",filamentInfo:"Filament",additional:"Additional",loadingPresets:"Loading cloud presets...",cloudConnected:"Cloud connected",cloudNotConnected:"Cloud not connected (using defaults)",recentColors:"Recent",searchColors:"Search colors...",searchResults:"Search results",allColors:"All colors",commonColors:"Common colors",showLess:"Show less",showAll:"Show all",noColorsFound:"No colors match your search",noResults:"No matches found",selectMaterialFirst:"Please select a material first in the Filament Info tab.",noPrintersConfigured:"No printers configured. Add printers to use PA profiles.",matchingFilter:"Matching",anyBrand:"Any brand",anyVariant:"Any variant",autoSelect:"Auto-select",matches:"matches",match:"match",noMatches:"No matches",connected:"Connected",offline:"Offline",printerOffline:"Printer is offline. Connect to view calibration profiles.",noKProfilesMatch:"No K-profiles match the selected filament.",leftNozzle:"Left Nozzle",rightNozzle:"Right Nozzle",profilesSelected:"calibration profile(s) selected",totalInventory:"Total Inventory",totalConsumed:"Total Consumed",byMaterial:"By Material",inPrinter:"In Printer",lowStock:"Low Stock",sinceTracking:"Since tracking started",loadedInAms:"Loaded in AMS/Ext",remaining:"Remaining",lowStockThreshold:"<20% remaining",weightCheck:"Weight Check",lastWeighed:"Last weighed",neverWeighed:"Never weighed",search:"Search spools...",showing:"Showing",to:"to",of:"of",show:"Show",spools:"spools",spool:"spool",page:"Page",noSpoolsMatch:"No results found",noSpoolsMatchDesc:"Try adjusting your search or filters to find what you're looking for.",active:"Active",archived:"Archived",all:"All",used:"Used",new:"New",clearFilters:"Clear filters",table:"Table",cards:"Cards",net:"Net",groupSimilar:"Group",groupedSpools:"{{count}} identical spools",groupedRows:"rows",columns:"Columns",configureColumns:"Configure Columns",configureColumnsDesc:"Drag to reorder columns or use arrows. Toggle visibility with the eye icon.",visible:"visible",reset:"Reset",cancel:"Cancel",applyChanges:"Apply Changes",moveUp:"Move up",moveDown:"Move down",hideColumn:"Hide column",showColumn:"Show column",linkToSpool:"Link to Spool",tagLinked:"Tag linked to spool",tagLinkFailed:"Failed to link tag",tagAlreadyLinked:"Tag already linked to another spool",unknownTag:"Unknown RFID tag detected",usageHistory:"Usage History",noUsageHistory:"No usage recorded yet",printName:"Print Name",weightConsumed:"Weight Consumed",clearHistory:"Clear",historyCleared:"Usage history cleared",fillSourceLabel:"(Inv)"},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",used:"used",remainingUnit:"remaining"},printModal:{title:"Start Print",selectPrinter:"Select Printer",selectPlate:"Select Plate",filamentMapping:"Filament Mapping",totalCost:"Total cost:",slotRemainingShort:" - {{grams}}g left",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",leftNozzle:"L",rightNozzle:"R",leftNozzleTooltip:"Left nozzle",rightNozzleTooltip:"Right nozzle",filamentOverride:"Filament Override",filamentOverrideHint:"Optionally override filaments for model-based assignment. The scheduler will match against your selected filaments instead of the original 3MF values.",originalFilament:"Original",overrideWith:"Override with",resetToOriginal:"Reset to original"},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",step1:"On the same LAN, virtual printers appear in your slicer (Bambu Studio / OrcaSlicer) automatically via discovery. From other networks, add them manually by IP address and access code.",step2:'In Archive, Review, and Queue modes, use the "Send" button in your slicer to upload 3MF files to Bambuddy. The slicer will show "Print success" — the file is stored, not printed.',step3:"In Proxy mode, the virtual printer relays all traffic to a real printer — prints start immediately as if connected directly."},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",bindIpRequired:"Please set a bind IP first",accessCodeEmpty:"Access code cannot be empty",accessCodeLength:"Access code must be exactly 8 characters",created:"Virtual printer created",failedToCreate:"Failed to create virtual printer",deleted:"Virtual printer deleted",failedToDelete:"Failed to delete virtual printer"},list:{title:"Virtual Printers",add:"Add",addFirst:"Add Virtual Printer",empty:"No virtual printers configured. Add one to get started."},bindIp:{title:"Bind Interface",placeholder:"Select interface...",hint:"Network interface for this virtual printer to bind to. Must be unique per printer."},proxy:{accessCodeHint:"In proxy mode, use your target printer's access code in the slicer. The connection is forwarded transparently to the real printer."},addDialog:{title:"Add Virtual Printer",name:"Name",hint:"You can configure access code, target printer, and other settings after creating.",create:"Create"},deleteConfirm:{title:"Delete Virtual Printer",message:'Are you sure you want to delete "{{name}}"? This will stop all services for this printer.'}},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:{lubricateCarbonRods:"Apply lubricant to carbon rods for smooth motion",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",cleanLinearRails:"Wipe linear rails to remove dust and debris",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:{title:"Configure AMS Slot",slotConfigured:"Slot Configured!",configuringSlot:"Configuring slot:",slotLabel:"{{ams}} Slot {{slot}}",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.",noPresetsAvailable:"No presets available. Login to Bambu Cloud or import local profiles.",noMatchingPresets:"No matching presets found.",custom:"Custom",builtin:"Built-in",settingsSentToPrinter:"Settings sent to printer",filamentProfile:"Filament Profile",kProfileLabel:"K Profile (Pressure Advance)",filteringFor:"Filtering for: {{material}}",noKProfile:"No K profile (use default 0.020)",noMatchingKProfiles:"No matching K profiles found. Default K=0.020 will be used.",selectFilamentFirst:"Select a filament profile first",kFromCalibration:"K={{value}} from printer calibration",customColorLabel:"Custom Color (optional)",presetColors:"{{name}} colors:",showLessColors:"Show less colors",showMoreColors:"Show more colors",clear:"Clear",hexLabel:"Hex: #{{hex}}",resetting:"Resetting...",resetSlot:"Reset Slot",cancel:"Cancel",configuring:"Configuring...",configureSlot:"Configure Slot"},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:{},time:{unknown:"-",waiting:"Waiting",justNow:"Just now",now:"Now",minsAgo:"{{count}}m ago",inMins:"in {{count}}m",hoursAgo:"{{count}}h ago",inHours:"in {{count}}h",daysAgo:"{{count}}d ago",inDays:"in {{count}}d"},spoolbuddy:{nav:{dashboard:"Dashboard",ams:"AMS",inventory:"Inventory",writeTag:"Write",settings:"Settings"},status:{nfcReady:"NFC Ready",nfcOff:"NFC Off",offline:"Offline",online:"Online",noPrinters:"No printers",deviceOffline:"Device Offline",waitingConnection:"Waiting for device connection...",systemReady:"System Ready",status:"Status"},dashboard:{readyToScan:"Ready to scan",idleMessage:"Place a spool on the scale to identify it",nfcHint:"NFC tag will be read automatically",device:"Device",syncWeight:"Sync Weight",weightSynced:"Synced!",unknownTag:"Unknown Tag",newTag:"New Tag Detected",onScale:"on scale",linkSpool:"Link to Spool",linkTagTitle:"Link Tag to Spool",linkTag:"Link Tag",selectSpool:"Select a spool to link this tag to:",noUntagged:"No spools without tags found",tagDetected:"Tag detected",noTag:"No tag",tagId:"Tag",grossWeight:"Gross weight",spoolSize:"Spool size",close:"Close",currentSpool:"Current Spool"},modal:{spoolDetected:"Spool Detected",assignToAms:"Assign to AMS",syncWeight:"Sync Weight",weightSynced:"Synced!",syncing:"Syncing...",newTagDetected:"New Tag Detected",addToInventory:"Add to Inventory",assignToAmsTitle:"Assign to AMS",selectSlot:"Select a slot",assign:"Assign",assigning:"Assigning...",assignSuccess:"Assigned!",assignError:"Failed to assign spool. Please try again.",noPrinterSelected:"Select a printer...",noAmsDetected:"No AMS detected on this printer",slot:"Slot"},weight:{noReading:"No reading",stable:"Stable",measuring:"Measuring...",tare:"Tare",calibrate:"Calibrate"},spool:{remaining:"Remaining",material:"Material",brand:"Brand",color:"Color",coreWeight:"Core",labelWeight:"Label",scaleWeight:"Scale",netWeight:"Net",lastUsed:"Last used"},ams:{noData:"No AMS detected",connectAms:"Connect an AMS to see filament slots",noPrinter:"No printer selected",selectPrinter:"Select a printer from the top bar",printerDisconnected:"Printer disconnected",humidity:"Humidity",level:"Level",active:"Active",slot:"Slot",empty:"Empty"},inventory:{search:"Search spools...",empty:"No spools in inventory",noResults:"No matching spools",spools:"spools",addSpool:"Add Spool"},settings:{tabDevice:"Device",tabDisplay:"Display",tabScale:"Scale",tabUpdates:"Updates",nfcReader:"NFC Reader",type:"Type",connection:"Connection",notConnected:"N/A",deviceInfo:"Device Info",hostname:"Host",uptime:"Uptime",brightness:"Brightness",saved:"Saved",noBacklight:"No DSI backlight detected. Brightness control requires a DSI display.",screenBlank:"Screen Blank Timeout",screenBlankDesc:"Screen turns off after inactivity. Touch to wake.",displayNote:"Brightness is applied as a software filter.",scaleCalibration:"Scale Calibration",currentWeight:"Current weight",tareOffset:"Tare",calFactor:"Factor",knownWeight:"Known weight",calStep1:"Remove all items from the scale and press Set Zero.",calStep2:"Place known weight on scale.",setZero:"Set Zero",calibrateNow:"Calibrate",calibrated:"Calibrated",tareSet:"Tare command sent. Waiting for device...",tareFailed:"Failed to send tare command",zeroSet:"Zero point set. Place known weight on scale.",calibrationDone:"Calibration complete!",calibrationFailed:"Calibration failed",lastCalibrated:"Last calibrated",stable:"Stable",settling:"Settling...",firmware:"Firmware",scale:"Scale",noDevice:"No SpoolBuddy device found",daemonVersion:"Daemon Version",currentVersion:"Current",versionPending:"Waiting for daemon...",checking:"Checking...",checkUpdates:"Check for Updates",updateAvailable:"Update available",updateInstructions:"Update via SSH: run the SpoolBuddy install script to upgrade.",upToDate:"Up to date",includeBeta:"Include beta versions"},writeTag:{tabExisting:"Existing Spool",tabNew:"New Spool",tabReplace:"Replace Tag",searchPlaceholder:"Search by material, color, brand...",noUntaggedSpools:"No spools without tags",noTaggedSpools:"No spools with tags",selectSpool:"Select a spool, then place a blank NTAG on the reader",placeTag:"Place an NTAG on the reader",tagReady:"Tag detected — ready to write",writeTag:"Write Tag",replaceTag:"Replace Tag",writing:"Writing tag...",waiting:"Waiting for SpoolBuddy...",writeSuccess:"Tag written successfully!",writeFailed:"Write failed",queueFailed:"Failed to queue write command",tryAgain:"Try Again",cancel:"Cancel",replaceWarning:"Old tag will be unlinked. New tag will replace it.",deviceOffline:"SpoolBuddy is offline",material:"Material",colorName:"Color Name",color:"Color",brand:"Brand",weight:"Weight (g)",createSpool:"Create Spool",creating:"Creating...",spoolCreated:"Spool created! Ready to write.",createFailed:"Failed to create spool"}}},Oce={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",inventory:"Filament",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",export:"Exportieren",import:"Importieren",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",tomorrow:"Morgen",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:{available:"Verfügbar",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",nextAvailable:"Nächster verfügbar",powerOn:"Einschalten",offlinePrintersWithPlugs:"Offline-Drucker mit Smart-Plugs",noPrintersConfigured:"Noch keine Drucker konfiguriert",readyToPrint:"Druckbereit",external:"Extern",extL:"Ext-L",extR:"Ext-R",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",noCamera:"Sie haben keine Berechtigung, Kameras anzuzeigen"},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",confirmTitle:"Objekt überspringen?",confirmMessage:'Möchten Sie "{{name}}" wirklich überspringen? Dies kann nicht rückgängig gemacht werden.'},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."},developerModeWarning:"Der Entwickler-LAN-Modus ist nicht aktiviert auf: {{names}}. Einige Funktionen funktionieren möglicherweise nicht.",howToEnable:"Aktivieren"},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",logView:"Druckprotokoll",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",timelapseRemoved:"Zeitraffer entfernt",failedRemoveTimelapse:"Fehler beim Entfernen des Zeitraffers",timelapseUploaded:"Zeitraffer hochgeladen: {{filename}}",failedUploadTimelapse:"Fehler beim Hochladen 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",uploadTimelapse:"Zeitraffer hochladen",removeTimelapse:"Zeitraffer entfernen",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",noFileForReprint:"Keine 3MF-Datei verfügbar — die Datei konnte beim Aufzeichnen des Drucks nicht vom Drucker heruntergeladen werden",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?',removeTimelapse:"Zeitraffer entfernen",removeTimelapseConfirm:'Möchten Sie das Zeitraffervideo 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"},log:{date:"Datum",printName:"Druckname",printer:"Drucker",user:"Benutzer",status:"Status",duration:"Dauer",filament:"Filament",allPrinters:"Alle Drucker",allUsers:"Alle Benutzer",allStatuses:"Alle Status",cancelled:"Abgebrochen",skipped:"Übersprungen",dateFrom:"Von",dateTo:"Bis",noEntries:"Keine Druckprotokolleinträge gefunden",showing:"{{count}} von {{total}} Einträgen",rowsPerPage:"Zeilen",page:"Seite",prev:"Zurück",next:"Weiter",clearLog:"Protokoll löschen",clearLogTitle:"Druckprotokoll löschen",clearLogConfirm:"Alle Druckprotokolleinträge werden dauerhaft gelöscht. Archive und Warteschlangeneinträge sind nicht betroffen. Diese Aktion kann nicht rückgängig gemacht werden. Sind Sie sicher?",clearLogButton:"Alle löschen",cleared:"{{count}} Protokolleinträge gelöscht",clearFailed:"Druckprotokoll konnte nicht gelöscht werden"}},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",plateNumber:"Platte {{index}}",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",totalWeight:"Gesamtgewicht der Warteschlange",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"}},backgroundDispatch:{unknownFile:"Unbekannte Datei",unknownPrinter:"Unbekannter Drucker",startingPrints:"Starte Drucke",progressSummary:"{{complete}}/{{total}} abgeschlossen • Geplant: {{dispatched}} • In Bearbeitung: {{processing}}",expandDetails:"Dispatch-Details ausklappen",collapseDetails:"Dispatch-Details einklappen",dismissToast:"Dispatch-Hinweis schließen",cancelDispatchJob:"Dispatch-Job abbrechen",cancel:"Abbrechen",cancelling:"Wird abgebrochen…",status:{dispatched:"Geplant",processing:"In Bearbeitung",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"},toast:{cancellingUpload:"Upload wird abgebrochen...",cancelled:"Dispatch abgebrochen",cancelFailed:"Dispatch konnte nicht abgebrochen werden",completeWithFailures:"Background Dispatch abgeschlossen: {{completed}} erfolgreich, {{failed}} fehlgeschlagen",completeSuccess:"Background Dispatch abgeschlossen: {{completed}} erfolgreich"}},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",noPrintDataInRange:"Keine Druckdaten im ausgewählten Zeitraum",periodFilament:"Filamentverbrauch",periodCost:"Kosten",avgPerPrint:"Durchschnitt pro Druck",usageOverTime:"Verbrauch im Zeitverlauf",filamentByWeight:"Gewicht",printDuration:"Druckdauer",printerUtilization:"Druckerauslastung",filamentSuccess:"Erfolg nach Material",printHabits:"Druckgewohnheiten",printTimeOfDay:"Druck-Tageszeit",colorDistribution:"Farbverteilung",noColorData:"Keine Farbdaten verfügbar",records:"Rekorde",longestPrint:"Längster Druck",heaviestPrint:"Schwerster Druck",mostExpensivePrint:"Teuerster Druck",busiestDay:"Aktivster Tag",successStreak:"Erfolgsserie",streakPrint:"aufeinanderfolgender Druck",streakPrints:"{{count}} aufeinanderfolgende Drucke",printerStats:"Druckerstatistiken",hours:"Stunden",avgPrints:"Ø Drucke",noArchiveData:"Keine Druckdaten verfügbar",filamentByTime:"Zeitverlauf",avgWeight:"Ø Gewicht",avgTime:"Ø Zeit",filamentByPrints:"Drucke",timeframe:{today:"Heute","this-week":"Diese Woche","this-month":"Dieser Monat","last-7":"Letzte 7 Tage","last-30":"Letzte 30 Tage","last-90":"Letzte 90 Tage","this-year":"Dieses Jahr","all-time":"Gesamt",custom:"Benutzerdefiniert",from:"Von",to:"Bis"}},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",restoreDefaults:"Standardaufgaben wiederherstellen",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:{lubricateCarbonRods:"Karbonstäbe schmieren",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",cleanLinearRails:"Linearschienen 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",defaultsRestored:"{{count}} Standardaufgabe(n) wiederhergestellt",printHoursUpdated:"Druckstunden aktualisiert",printerAssigned:"Drucker zugewiesen",printerRemoved:"Drucker entfernt",deleteTypeConfirm:'"{{name}}" löschen?',deleteSystemTypeTitle:"Standard-Wartungsaufgabe löschen?",deleteSystemTypeMessage:'Möchten Sie die Standard-Wartungsaufgabe "{{name}}" wirklich 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",bedCooledThreshold:"Bett-Abkühlung Schwellenwert",bedCooledThresholdDescription:"Temperatur, unter der das Bett nach einem Druck als abgekühlt gilt",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"},filamentTracking:"Filament-Verfolgung",filamentTrackingDesc:"Wählen Sie, wie Sie Ihre Filamentspulen verfolgen möchten. Sie können das integrierte Inventar oder einen externen Spoolman-Server verwenden.",trackingModeBuiltIn:"Integriertes Inventar",trackingModeBuiltInDesc:"RFID-Erkennung und Verbrauchserfassung inklusive",trackingModeSpoolmanDesc:"Externer Filament-Management-Server",builtInFeatureRfid:"Erkennt automatisch Bambu Lab RFID-Spulen im AMS",builtInFeatureUsage:"Erfasst den Filamentverbrauch pro Druck",builtInFeatureCatalog:"Spulen, Farben und K-Faktor-Profile verwalten",builtInFeatureThirdParty:"Drittanbieter-Spulen können Inventarspulen zugewiesen werden",amsSyncButton:"Gewichte vom AMS synchronisieren",amsSyncTitle:"Spulengewichte vom AMS synchronisieren",amsSyncMessage:"Alle Inventar-Spulengewichte werden mit den aktuellen AMS-Restwerten der verbundenen Drucker überschrieben. Verwenden Sie dies zur Wiederherstellung beschädigter Gewichtsdaten. Drucker müssen online sein.",amsSyncing:"Synchronisiere...",amsSyncSuccess:"{{synced}} Spule(n) synchronisiert, {{skipped}} übersprungen",amsSyncError:"Synchronisierung der Gewichte vom AMS fehlgeschlagen",spoolmanUrl:"Spoolman URL",spoolmanUrlHint:"URL Ihres Spoolman-Servers (z.B. http://localhost:7912)",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden",status:"Status",connect:"Verbinden",disconnect:"Trennen",howSyncWorks:"So funktioniert die Synchronisierung",syncInfoRfidOnly:"Nur offizielle Bambu Lab Spulen mit RFID werden synchronisiert",syncInfoAutoCreate:"Neue Spulen werden bei der ersten Synchronisierung automatisch in Spoolman erstellt",syncInfoThirdPartySkipped:"Nicht-Bambu-Lab-Spulen (Drittanbieter, nachgefüllt) werden übersprungen",linkingExistingSpools:"Vorhandene Spulen verknüpfen",linkingExistingSpoolsDesc:'Um vorhandene Spoolman-Spulen mit Ihrem AMS zu verknüpfen, fahren Sie über einen AMS-Slot und klicken Sie auf "Mit Spoolman verknüpfen".',syncMode:"Synchronisierungsmodus",syncModeAuto:"Automatisch",syncModeManual:"Nur manuell",syncModeAutoDesc:"AMS-Daten werden automatisch synchronisiert, wenn Änderungen erkannt werden",syncModeManualDesc:"Nur bei manueller Auslösung synchronisieren",syncAmsData:"AMS-Daten synchronisieren",syncAmsDataDesc:"AMS-Daten des Druckers manuell mit Spoolman synchronisieren",allPrinters:"Alle Drucker",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",includeBetaUpdates:"Beta-Versionen einschließen",includeBetaUpdatesDesc:"Über Beta- und Vorabversionen bei der Updateprüfung benachrichtigen",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",storageUsage:"Speichernutzung",storageUsageDescription:"Aufschlüsselung der Datennutzung nach Kategorie",storageUsageTotal:"Gesamt",storageUsageErrors:"Fehler",storageUsageOtherBreakdown:"Sonstiges (enthält statische Assets, Skripte und Konfigurationsdateien)",storageUsageSystem:"System",storageUsageData:"Daten",storageUsageUnavailable:"Speichernutzungsinformationen nicht verfügbar",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",catalog:{spoolCatalog:"Spulenkatalog",spoolCatalogDescription:"Leerspulengewichte nach Marke/Typ. Wird für die automatische Gewichtssuche beim Hinzufügen von Spulen verwendet.",searchCatalog:"Katalog durchsuchen...",addNewEntry:"Neuen Eintrag hinzufügen",namePlaceholder:"Name (z.B. Bambu Lab - Plastik)",weight:"Gewicht",type:"Typ",default:"Standard",custom:"Benutzerdefiniert",noMatch:"Keine Einträge entsprechen Ihrer Suche",empty:"Keine Einträge im Katalog",deleteEntry:"Eintrag löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',resetCatalog:"Katalog zurücksetzen",resetConfirm:"Katalog auf Standardwerte zurücksetzen? Alle benutzerdefinierten Einträge werden entfernt.",loadFailed:"Spulenkatalog konnte nicht geladen werden",nameWeightRequired:"Name und Gewicht sind erforderlich",entryAdded:"Eintrag hinzugefügt",addFailed:"Eintrag konnte nicht hinzugefügt werden",entryUpdated:"Eintrag aktualisiert",updateFailed:"Eintrag konnte nicht aktualisiert werden",entryDeleted:"Eintrag gelöscht",deleteFailed:"Eintrag konnte nicht gelöscht werden",resetSuccess:"Katalog auf Standardwerte zurückgesetzt",resetFailed:"Katalog konnte nicht zurückgesetzt werden",exported:"{{count}} Einträge exportiert",imported:"{{added}} Einträge importiert ({{skipped}} übersprungen)",importFailed:"Import fehlgeschlagen: ungültiges JSON-Format",exportTooltip:"Katalog als JSON exportieren",importTooltip:"Katalog aus JSON importieren",resetTooltip:"Auf Standardwerte zurücksetzen"},colorCatalog:{title:"Farbkatalog",description:"Filamentfarben nach Hersteller/Material. Wird für die automatische Farbsuche beim Hinzufügen von Spulen verwendet.",searchColors:"Farben durchsuchen...",allManufacturers:"Alle Hersteller",addNewColor:"Neue Farbe hinzufügen",manufacturer:"Hersteller",colorName:"Farbname",hex:"Hex",materialOptional:"Material (optional)",showing:"{{filtered}} von {{total}} Farben angezeigt",noMatch:"Keine Farben entsprechen Ihrer Suche",empty:"Keine Farben im Katalog",deleteColor:"Farbe löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',resetCatalog:"Farbkatalog zurücksetzen",resetConfirm:"Katalog auf Standardwerte zurücksetzen? Alle benutzerdefinierten Farben werden entfernt.",sync:"Sync",starting:"Starten...",syncTooltip:"Von FilamentColors.xyz synchronisieren (2000+ Farben)",loadFailed:"Farbkatalog konnte nicht geladen werden",fieldsRequired:"Hersteller, Farbname und Hex-Farbe sind erforderlich",colorAdded:"Farbe hinzugefügt",addFailed:"Farbe konnte nicht hinzugefügt werden",colorUpdated:"Farbe aktualisiert",updateFailed:"Farbe konnte nicht aktualisiert werden",colorDeleted:"Farbe gelöscht",deleteFailed:"Farbe konnte nicht gelöscht werden",resetSuccess:"Farbkatalog auf Standardwerte zurückgesetzt",resetFailed:"Katalog konnte nicht zurückgesetzt werden",syncUpToDate:"Bereits aktuell ({{count}} Farben geprüft)",syncComplete:"{{added}} neue Farben hinzugefügt ({{skipped}} bereits vorhanden)",syncError:"Sync-Fehler",syncFailed:"Synchronisierung von FilamentColors.xyz fehlgeschlagen",exported:"{{count}} Farben exportiert",imported:"{{added}} Farben importiert ({{skipped}} übersprungen)",importFailed:"Import fehlgeschlagen: ungültiges JSON-Format"}},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.",clearErrors:"Fehler löschen",clearSuccess:"HMS-Fehler gelöscht",clearFailed:"HMS-Fehler konnten nicht gelöscht werden"},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"},editor:{title:"Gruppe bearbeiten",createTitle:"Gruppe erstellen",search:"Berechtigungen suchen...",selectAll:"Alle auswählen",clearAll:"Alle abwählen",permissionsSelected:"{{count}} ausgewählt",noResults:"Keine Berechtigungen entsprechen Ihrer Suche"}},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",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."},inventory:{title:"Spulen-Inventar",addSpool:"Spule hinzufügen",editSpool:"Spule bearbeiten",material:"Material",selectMaterial:"Material auswählen...",subtype:"Untertyp",brand:"Marke",searchBrand:"Marke suchen...",useCustomBrand:'"{{brand}}" verwenden',useCustomMaterial:"Benutzerdefiniertes Material verwenden: {{material}}",colorName:"Farbname",colorNamePlaceholder:"Jade White, Fire Red...",color:"Farbe",hexColor:"Hex-Farbe",pickColor:"Benutzerdefinierte Farbe wählen",labelWeight:"Nenngewicht",coreWeight:"Leergewicht der Spule",searchSpoolWeight:"Spulengewicht suchen...",weightUsed:"Verbraucht",currentWeight:"Restgewicht",measuredWeight:"Gemessenes Gewicht",costPerKg:"Kosten pro kg",measuredWeightError:"Das gemessene Gewicht muss zwischen {{min}}g und {{max}}g liegen.",slicerFilament:"Slicer-Filament",slicerFilamentName:"Slicer-Preset-Name",slicerPreset:"Slicer-Preset",searchPresets:"Filament-Presets suchen...",selectedPreset:"Ausgewählt",noPresetsFound:"Keine Presets gefunden",tempOverrides:"Temperatur-Überschreibungen",note:"Notiz",notePlaceholder:"Zusätzliche Notizen zu dieser Spule...",archive:"Archivieren",restore:"Wiederherstellen",noSpools:"Noch keine Spulen. Fügen Sie Ihre erste Spule hinzu.",noManualSpools:"Keine manuell hinzugefügten Spulen verfügbar. Fügen Sie zuerst eine Spule zum Inventar hinzu.",kProfiles:"K-Profile",addKProfile:"K-Profil hinzufügen",assignSpool:"Spule zuweisen",unassignSpool:"Zuweisung aufheben",assignSuccess:"Spule zugewiesen und AMS-Slot konfiguriert",assignFailed:"Spulenzuweisung fehlgeschlagen",selectSpool:"Wählen Sie eine Spule für diesen Slot",assigned:"Zugewiesen",assigning:"Wird zugewiesen...",searchSpools:"Spulen suchen...",allMaterials:"Alle Materialien",filterByBrand:"Nach Marke filtern...",showArchived:"Archivierte anzeigen",quickAdd:"Schnellerfassung (Lager)",quantity:"Menge",stock:"Lager",configured:"Konfiguriert",spoolsCreated:"{{count}} Spulen erstellt",spoolCreated:"Spule erstellt",spoolUpdated:"Spule aktualisiert",spoolDeleted:"Spule gelöscht",spoolArchived:"Spule archiviert",spoolRestored:"Spule wiederhergestellt",deleteConfirm:"Möchten Sie diese Spule wirklich löschen? Dies kann nicht rückgängig gemacht werden.",archiveConfirm:"Möchten Sie diese Spule wirklich archivieren?",advancedSettings:"Erweiterte Einstellungen",filamentInfoTab:"Filament-Info",paProfileTab:"PA-Profil",filamentInfo:"Filament",additional:"Zusätzlich",loadingPresets:"Cloud-Presets werden geladen...",cloudConnected:"Cloud verbunden",cloudNotConnected:"Cloud nicht verbunden (Standardwerte)",recentColors:"Zuletzt",searchColors:"Farben suchen...",searchResults:"Suchergebnisse",allColors:"Alle Farben",commonColors:"Häufige Farben",showLess:"Weniger",showAll:"Alle",noColorsFound:"Keine Farben gefunden",noResults:"Keine Ergebnisse",selectMaterialFirst:"Bitte zuerst ein Material im Filament-Info Tab auswählen.",noPrintersConfigured:"Keine Drucker konfiguriert. Fügen Sie Drucker hinzu.",matchingFilter:"Filter",anyBrand:"Jede Marke",anyVariant:"Jede Variante",autoSelect:"Auto-Auswahl",matches:"Treffer",match:"Treffer",noMatches:"Keine Treffer",connected:"Verbunden",offline:"Offline",printerOffline:"Drucker ist offline. Verbinden Sie ihn, um Kalibrierungsprofile anzuzeigen.",noKProfilesMatch:"Keine K-Profile stimmen mit dem gewählten Filament überein.",leftNozzle:"Linke Düse",rightNozzle:"Rechte Düse",profilesSelected:"Kalibrierungsprofil(e) ausgewählt",totalInventory:"Gesamtbestand",totalConsumed:"Gesamtverbrauch",byMaterial:"Nach Material",inPrinter:"Im Drucker",lowStock:"Niedriger Bestand",sinceTracking:"Seit Beginn der Erfassung",loadedInAms:"Im AMS/Ext geladen",remaining:"Verbleibend",lowStockThreshold:"<20% verbleibend",weightCheck:"Gewichtskontrolle",lastWeighed:"Zuletzt gewogen",neverWeighed:"Nie gewogen",search:"Spulen suchen...",showing:"Zeige",to:"bis",of:"von",show:"Zeige",spools:"Spulen",spool:"Spule",page:"Seite",noSpoolsMatch:"Keine Ergebnisse",noSpoolsMatchDesc:"Versuchen Sie, Ihre Suche oder Filter anzupassen.",active:"Aktiv",archived:"Archiviert",all:"Alle",used:"Verwendet",new:"Neu",clearFilters:"Filter löschen",table:"Tabelle",cards:"Karten",net:"Netto",groupSimilar:"Gruppieren",groupedSpools:"{{count}} identische Spulen",groupedRows:"Zeilen",columns:"Spalten",configureColumns:"Spalten konfigurieren",configureColumnsDesc:"Ziehen zum Neuordnen oder Pfeile verwenden. Sichtbarkeit mit dem Augensymbol umschalten.",visible:"sichtbar",reset:"Zurücksetzen",cancel:"Abbrechen",applyChanges:"Änderungen anwenden",moveUp:"Nach oben",moveDown:"Nach unten",hideColumn:"Spalte ausblenden",showColumn:"Spalte einblenden",linkToSpool:"Mit Spule verknüpfen",tagLinked:"Tag mit Spule verknüpft",tagLinkFailed:"Tag-Verknüpfung fehlgeschlagen",tagAlreadyLinked:"Tag bereits mit anderer Spule verknüpft",unknownTag:"Unbekannter RFID-Tag erkannt",usageHistory:"Verbrauchshistorie",noUsageHistory:"Noch kein Verbrauch erfasst",printName:"Druckname",weightConsumed:"Verbrauchtes Gewicht",clearHistory:"Löschen",historyCleared:"Verbrauchshistorie gelöscht",fillSourceLabel:"(Inv)"},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",used:"verwendet",remainingUnit:"verbleibend"},printModal:{title:"Druck starten",selectPrinter:"Drucker auswählen",selectPlate:"Platte auswählen",filamentMapping:"Filamentzuordnung",totalCost:"Gesamtkosten:",slotRemainingShort:" - {{grams}}g übrig",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",leftNozzle:"L",rightNozzle:"R",leftNozzleTooltip:"Linke Düse",rightNozzleTooltip:"Rechte Düse",filamentOverride:"Filament-Überschreibung",filamentOverrideHint:"Filamente für modellbasierte Zuweisung optional überschreiben. Der Planer wird gegen die ausgewählten Filamente statt der ursprünglichen 3MF-Werte abgleichen.",originalFilament:"Original",overrideWith:"Ersetzen mit",resetToOriginal:"Auf Original zurücksetzen"},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",step1:"Im selben LAN erscheinen virtuelle Drucker automatisch in deinem Slicer (Bambu Studio / OrcaSlicer). Aus anderen Netzwerken füge sie manuell per IP-Adresse und Zugangscode hinzu.",step2:'Im Archiv-, Überprüfungs- und Warteschlangen-Modus verwende die "Senden"-Funktion im Slicer, um 3MF-Dateien an Bambuddy zu senden. Der Slicer zeigt "Druck erfolgreich" — die Datei wird gespeichert, nicht gedruckt.',step3:"Im Proxy-Modus leitet der virtuelle Drucker den gesamten Datenverkehr an einen echten Drucker weiter — Drucke starten sofort wie bei einer direkten Verbindung."},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",bindIpRequired:"Bitte zuerst eine Bind-IP setzen",accessCodeEmpty:"Zugangscode darf nicht leer sein",accessCodeLength:"Zugangscode muss genau 8 Zeichen lang sein",created:"Virtueller Drucker erstellt",failedToCreate:"Virtueller Drucker konnte nicht erstellt werden",deleted:"Virtueller Drucker gelöscht",failedToDelete:"Virtueller Drucker konnte nicht gelöscht werden"},list:{title:"Virtuelle Drucker",add:"Hinzufügen",addFirst:"Virtuellen Drucker hinzufügen",empty:"Keine virtuellen Drucker konfiguriert. Fügen Sie einen hinzu, um zu beginnen."},bindIp:{title:"Bind-Interface",placeholder:"Interface auswählen...",hint:"Netzwerkinterface, an das dieser virtuelle Drucker gebunden wird. Muss pro Drucker eindeutig sein."},proxy:{accessCodeHint:"Im Proxy-Modus den Zugangscode des Zieldruckers im Slicer verwenden. Die Verbindung wird transparent zum echten Drucker weitergeleitet."},addDialog:{title:"Virtuellen Drucker hinzufügen",name:"Name",hint:"Sie können Zugangscode, Zieldrucker und andere Einstellungen nach dem Erstellen konfigurieren.",create:"Erstellen"},deleteConfirm:{title:"Virtuellen Drucker löschen",message:'Möchten Sie "{{name}}" wirklich löschen? Dies stoppt alle Dienste für diesen Drucker.'}},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:{lubricateCarbonRods:"Schmiermittel auf Karbonstäbe für sanfte Bewegung auftragen",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",cleanLinearRails:"Linearschienen abwischen, um Staub und Schmutz zu entfernen",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:{title:"AMS-Slot konfigurieren",slotConfigured:"Slot konfiguriert!",configuringSlot:"Slot wird konfiguriert:",slotLabel:"{{ams}} Slot {{slot}}",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.",noPresetsAvailable:"Keine Voreinstellungen verfügbar. Melden Sie sich bei Bambu Cloud an oder importieren Sie lokale Profile.",noMatchingPresets:"Keine passenden Voreinstellungen gefunden.",custom:"Benutzerdefiniert",builtin:"Integriert",settingsSentToPrinter:"Einstellungen an Drucker gesendet",filamentProfile:"Filamentprofil",kProfileLabel:"K-Profil (Pressure Advance)",filteringFor:"Filtern nach: {{material}}",noKProfile:"Kein K-Profil (Standard 0.020 verwenden)",noMatchingKProfiles:"Keine passenden K-Profile gefunden. Standard K=0.020 wird verwendet.",selectFilamentFirst:"Zuerst ein Filamentprofil auswählen",kFromCalibration:"K={{value}} aus Druckerkalibrierung",customColorLabel:"Benutzerdefinierte Farbe (optional)",presetColors:"{{name}} Farben:",showLessColors:"Weniger Farben anzeigen",showMoreColors:"Mehr Farben anzeigen",clear:"Löschen",hexLabel:"Hex: #{{hex}}",resetting:"Wird zurückgesetzt...",resetSlot:"Slot zurücksetzen",cancel:"Abbrechen",configuring:"Wird konfiguriert...",configureSlot:"Slot konfigurieren"},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:{},time:{unknown:"-",waiting:"Wartend",justNow:"Gerade eben",now:"Jetzt",minsAgo:"vor {{count}}m",inMins:"in {{count}}m",hoursAgo:"vor {{count}}h",inHours:"in {{count}}h",daysAgo:"vor {{count}}d",inDays:"in {{count}}d"},spoolbuddy:{nav:{dashboard:"Dashboard",ams:"AMS",inventory:"Inventar",writeTag:"Schreiben",settings:"Einstellungen"},status:{nfcReady:"NFC bereit",nfcOff:"NFC aus",offline:"Offline",online:"Online",noPrinters:"Keine Drucker",deviceOffline:"Gerät offline",waitingConnection:"Warte auf Geräteverbindung...",systemReady:"System bereit",status:"Status"},dashboard:{readyToScan:"Bereit zum Scannen",idleMessage:"Spule auf die Waage legen zum Identifizieren",nfcHint:"NFC-Tag wird automatisch gelesen",device:"Gerät",syncWeight:"Gewicht sync.",weightSynced:"Synchronisiert!",unknownTag:"Unbekannter Tag",newTag:"Neuer Tag erkannt",onScale:"auf der Waage",linkSpool:"Mit Spule verknüpfen",linkTagTitle:"Tag mit Spule verknüpfen",linkTag:"Tag verknüpfen",selectSpool:"Spule zum Verknüpfen auswählen:",noUntagged:"Keine Spulen ohne Tags gefunden",tagDetected:"Tag erkannt",noTag:"Kein Tag",tagId:"Tag",grossWeight:"Bruttogewicht",spoolSize:"Spulengröße",close:"Schließen",currentSpool:"Aktuelle Spule"},modal:{spoolDetected:"Spule erkannt",assignToAms:"AMS zuweisen",syncWeight:"Gewicht sync.",weightSynced:"Synchronisiert!",syncing:"Synchronisiere...",newTagDetected:"Neuer Tag erkannt",addToInventory:"Zum Inventar hinzufügen",assignToAmsTitle:"AMS zuweisen",selectSlot:"Slot auswählen",assign:"Zuweisen",assigning:"Zuweisen...",assignSuccess:"Zugewiesen!",assignError:"Fehler beim Zuweisen. Bitte erneut versuchen.",noPrinterSelected:"Drucker auswählen...",noAmsDetected:"Kein AMS an diesem Drucker erkannt",slot:"Slot"},weight:{noReading:"Kein Messwert",stable:"Stabil",measuring:"Messen...",tare:"Tarieren",calibrate:"Kalibrieren"},spool:{remaining:"Verbleibend",material:"Material",brand:"Marke",color:"Farbe",coreWeight:"Kern",labelWeight:"Etikett",scaleWeight:"Waage",netWeight:"Netto",lastUsed:"Zuletzt verwendet"},ams:{noData:"Kein AMS erkannt",connectAms:"AMS anschließen um Filament-Slots zu sehen",noPrinter:"Kein Drucker ausgewählt",selectPrinter:"Drucker in der oberen Leiste auswählen",printerDisconnected:"Drucker getrennt",humidity:"Feuchtigkeit",level:"Stufe",active:"Aktiv",slot:"Slot",empty:"Leer"},inventory:{search:"Spulen suchen...",empty:"Keine Spulen im Inventar",noResults:"Keine passenden Spulen",spools:"Spulen",addSpool:"Spule hinzufügen"},settings:{tabDevice:"Gerät",tabDisplay:"Anzeige",tabScale:"Waage",tabUpdates:"Updates",nfcReader:"NFC-Leser",type:"Typ",connection:"Verbindung",notConnected:"N/A",deviceInfo:"Geräteinfo",hostname:"Host",uptime:"Betriebszeit",brightness:"Helligkeit",saved:"Gespeichert",noBacklight:"Keine DSI-Hintergrundbeleuchtung erkannt. Helligkeitssteuerung erfordert ein DSI-Display.",screenBlank:"Bildschirm-Abschaltzeit",screenBlankDesc:"Bildschirm schaltet sich nach Inaktivität ab. Zum Aufwecken berühren.",displayNote:"Helligkeit wird als Software-Filter angewendet.",scaleCalibration:"Waagen-Kalibrierung",currentWeight:"Aktuelles Gewicht",tareOffset:"Tara",calFactor:"Faktor",knownWeight:"Bekanntes Gewicht",calStep1:"Alle Gegenstände von der Waage entfernen und Nullpunkt setzen.",calStep2:"Bekanntes Gewicht auf die Waage legen.",setZero:"Nullpunkt setzen",calibrateNow:"Kalibrieren",calibrated:"Kalibriert",tareSet:"Tara-Befehl gesendet. Warte auf Gerät...",tareFailed:"Tara-Befehl fehlgeschlagen",zeroSet:"Nullpunkt gesetzt. Bekanntes Gewicht auf die Waage legen.",calibrationDone:"Kalibrierung abgeschlossen!",calibrationFailed:"Kalibrierung fehlgeschlagen",lastCalibrated:"Zuletzt kalibriert",stable:"Stabil",settling:"Stabilisierung...",firmware:"Firmware",scale:"Waage",noDevice:"Kein SpoolBuddy-Gerät gefunden",daemonVersion:"Daemon-Version",currentVersion:"Aktuell",versionPending:"Warte auf Daemon...",checking:"Prüfe...",checkUpdates:"Nach Updates suchen",updateAvailable:"Update verfügbar",updateInstructions:"Update per SSH: SpoolBuddy-Installationsskript ausführen.",upToDate:"Aktuell",includeBeta:"Beta-Versionen einschließen"},writeTag:{tabExisting:"Vorhandene Spule",tabNew:"Neue Spule",tabReplace:"Tag ersetzen",searchPlaceholder:"Suche nach Material, Farbe, Marke...",noUntaggedSpools:"Keine Spulen ohne Tags",noTaggedSpools:"Keine Spulen mit Tags",selectSpool:"Spule auswählen, dann einen NTAG auf den Leser legen",placeTag:"NTAG auf den Leser legen",tagReady:"Tag erkannt — bereit zum Schreiben",writeTag:"Tag beschreiben",replaceTag:"Tag ersetzen",writing:"Tag wird beschrieben...",waiting:"Warte auf SpoolBuddy...",writeSuccess:"Tag erfolgreich beschrieben!",writeFailed:"Schreiben fehlgeschlagen",queueFailed:"Schreibbefehl konnte nicht eingereiht werden",tryAgain:"Erneut versuchen",cancel:"Abbrechen",replaceWarning:"Alter Tag wird getrennt. Neuer Tag ersetzt ihn.",deviceOffline:"SpoolBuddy ist offline",material:"Material",colorName:"Farbname",color:"Farbe",brand:"Marke",weight:"Gewicht (g)",createSpool:"Spule erstellen",creating:"Wird erstellt...",spoolCreated:"Spule erstellt! Bereit zum Schreiben.",createFailed:"Spule konnte nicht erstellt werden"}}},Ice={nav:{printers:"Imprimantes",archives:"Archives",queue:"File d'attente",stats:"Statistiques",profiles:"Profils",maintenance:"Maintenance",projects:"Projets",inventory:"Filament",files:"Gestionnaire de fichiers",settings:"Paramètres",system:"Système",collapseSidebar:"Réduire la barre latérale",expandSidebar:"Développer la barre latérale",update:"Mise à jour",updateAvailable:"Mise à jour disponible : v{{version}}",updateAvailableBanner:"La version {{version}} est disponible !",viewUpdate:"Voir la mise à jour",viewOnGithub:"Voir sur GitHub",keyboardShortcuts:"Raccourcis clavier (?)",switchToLight:"Passer au mode clair",switchToDark:"Passer au mode sombre",smartSwitches:"Interrupteurs intelligents",logout:"Déconnexion"},common:{save:"Enregistrer",saving:"Enregistrement...",cancel:"Annuler",delete:"Supprimer",edit:"Modifier",add:"Ajouter",close:"Fermer",confirm:"Confirmer",loading:"Chargement...",error:"Erreur",success:"Succès",warning:"Avertissement",enabled:"Activé",disabled:"Désactivé",yes:"Oui",no:"Non",on:"On",off:"Off",all:"Tous",none:"Aucun",search:"Rechercher",filter:"Filtrer",sort:"Trier",refresh:"Actualiser",download:"Télécharger",upload:"Téléverser",actions:"Actions",status:"Statut",name:"Nom",description:"Description",date:"Date",time:"Heure",hours:"heures",minutes:"minutes",seconds:"secondes",days:"jours",enable:"Activer",disable:"Désactiver",permissions:"Autorisations",noPrinters:"Aucune imprimante configurée",noData:"Aucune donnée disponible",linkNotFound:"Lien non trouvé",required:"Requis",optional:"Optionnel",dismiss:"Ignorer",apply:"Appliquer",reset:"Réinitialiser",export:"Exporter",import:"Importer",clear:"Effacer",selectAll:"Tout sélectionner",deselectAll:"Tout désélectionner",noChange:"— Aucun changement —",unchanged:"Inchangé",unassigned:"Non assigné",unknown:"Inconnu",unknownError:"Erreur inconnue",today:"Aujourd'hui",tomorrow:"Demain",asap:"Dès que possible",overdue:"En retard",now:"Maintenant",collapse:"Réduire",expand:"Développer",viewArchive:"Voir l'archive",viewInFileManager:"Voir dans le gestionnaire de fichiers",addedBy:"Ajouté par {{username}}",prints:"impressions",more:"+{{count}} de plus",ascending:"Croissant",descending:"Décroissant",printer:"Imprimante",remove:"Retirer",type:"Type",print:"Imprimer",rename:"Renommer",move:"Déplacer",create:"Créer",duplicate:"Dupliquer",left:"Gauche",right:"Droite"},printers:{title:"Imprimantes",addPrinter:"Ajouter une imprimante",editPrinter:"Modifier l'imprimante",deletePrinter:"Supprimer l'imprimante",printerName:"Nom de l'imprimante",serialNumber:"Numéro de série",ipAddress:"Adresse IP / Nom d'hôte",accessCode:"Code d'accès",model:"Modèle",nozzleCount:"Nombre de buses",autoArchive:"Auto-archivage",status:{available:"Disponible",idle:"Inactif",printing:"Impression en cours",paused:"En pause",offline:"Hors ligne",error:"Erreur",finished:"Terminé",unknown:"Inconnu"},temperatures:{nozzle:"Buse",bed:"Plateau",chamber:"Chambre"},progress:"{{percent}}% terminé",timeRemaining:"{{time}} restant",deleteConfirm:'Êtes-vous sûr de vouloir supprimer "{{name}}" ?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} avertissement",maintenanceWarning_plural:"{{count}} avertissements",maintenanceDue:"{{count}} échéance",maintenanceDue_plural:"{{count}} échéances",sort:{name:"Nom",status:"Statut",model:"Modèle",location:"Emplacement",ascending:"Tri croissant",descending:"Tri décroissant"},cardSize:{small:"Petites cartes",medium:"Cartes moyennes",large:"Grandes cartes",extraLarge:"Très grandes cartes"},hideOffline:"Masquer hors ligne",nextAvailable:"Prochaine disponible",powerOn:"Allumer",offlinePrintersWithPlugs:"Imprimantes hors ligne avec prises connectées",noPrintersConfigured:"Aucune imprimante configurée pour le moment",readyToPrint:"Prête à imprimer",external:"Externe",extL:"Ext-L",extR:"Ext-R",deleteArchives:"Supprimer les archives d'impression",noLabel:"Pas d'étiquette",printPreview:"Aperçu avant impression",width:"Largeur",height:"Hauteur",noObjectsFound:"Aucun objet trouvé",objectsLoadedOnPrintStart:"Les objets sont chargés au début de l'impression",willBeSkipped:"Sera sauté",name:"Nom",serialCannotBeChanged:"Le numéro de série ne peut pas être modifié",locationHelp:"Utilisé pour grouper les imprimantes et filtrer la file d'attente",wifiSignal:{veryWeak:"Très faible",weak:"Faible",fair:"Moyen",good:"Bon",excellent:"Excellent"},maintenanceUpToDate:"Maintenance à jour - Cliquez pour voir",chamberLightOn:"Allumer la lumière de la chambre",chamberLightOff:"Éteindre la lumière de la chambre",browseFiles:"Parcourir les fichiers de l'imprimante",autoOffAfterPrint:"Extinction auto après impression",autoOffExecuted:"Extinction auto exécutée - rallumez pour réinitialiser",hmsErrors:"Erreurs HMS",viewHmsErrors:"Voir {{count}} erreur(s) HMS",resume:"Reprendre",pause:"Pause",stop:"Arrêter",camera:"Caméra",skipObject:"Sauter l'objet",reconnect:"Reconnecter",mqttDebug:"Débogage MQTT",activeNozzle:"Active : buse {{nozzle}}",nozzleRack:"Rack à buses",nozzleDocked:"Rangée",nozzleMounted:"Montée",nozzleActive:"Active",nozzleIdle:"Inactive",nozzleDiameter:"Diamètre",nozzleType:"Type",nozzleStatus:"Statut",nozzleFilament:"Filament",nozzleWear:"Usure",nozzleMaxTemp:"Temp Max",nozzleSerial:"Série",nozzleHardenedSteel:"Acier Trempé",nozzleStainlessSteel:"Acier Inoxydable",nozzleTungstenCarbide:"Carbure de Tungstène",nozzleFlow:"Débit",nozzleHighFlow:"Haut débit",nozzleStandardFlow:"Standard",firmwareUpdate:"Mise à jour Firmware",firmwareInstructions:"Sur l'écran de l'imprimante, allez dans",firmwareNav:"Naviguez vers",settings:"Paramètres",firmware:"Firmware",discoverPrinters:"Découvrir les imprimantes",searching:"Recherche...",manualEntry:"Saisie manuelle",addFromCloud:"Ajouter depuis le Cloud",toast:{printerDeleted:"Imprimante supprimée",printerAdded:"Imprimante ajoutée",printerUpdated:"Imprimante mise à jour",failedToDelete:"Échec de la suppression",failedToAdd:"Échec de l'ajout",failedToUpdate:"Échec de la mise à jour",commandSent:"Commande envoyée",failedToSendCommand:"Échec de l'envoi de la commande",turnedOn:"{{name}} allumée",failedToPowerOn:"Échec de l'allumage de {{name}}",scriptTriggered:"Script déclenché",printStopped:"Impression arrêtée",printPaused:"Impression en pause",printResumed:"Impression reprise",referenceDeleted:"Référence supprimée",detectionAreaSaved:"Zone de détection enregistrée",failedToRunScript:"Échec du script",failedToStopPrint:"Échec de l'arrêt",failedToPausePrint:"Échec de la mise en pause",failedToResumePrint:"Échec de la reprise",failedToControlChamberLight:"Échec du contrôle de la lumière",failedToUpdateSetting:"Échec de mise à jour du paramètre",failedToSkipObjects:"Échec du saut d'objets",failedToRereadRfid:"Échec lecture RFID",failedToCheckPlate:"Échec vérification plateau",failedToUpdateLabel:"Échec mise à jour étiquette",failedToDeleteReference:"Échec suppression référence",failedToSaveDetectionArea:"Échec enregistrement zone",plateCheckEnabled:"Vérification plateau activée",plateCheckDisabled:"Vérification plateau désactivée",calibrationSaved:"Calibration enregistrée !",calibrationFailed:"Échec de la calibration",rfidRereadInitiated:"Lecture RFID initiée"},connection:{connected:"Connecté",offline:"Hors ligne"},queue:{inQueue:"{{count}} impression en file",inQueue_plural:"{{count}} impressions en file"},controls:"Contrôles",rfid:{reread:"Relire RFID"},permission:{noAdd:"Pas d'autorisation pour ajouter",noEdit:"Pas d'autorisation pour modifier",noDelete:"Pas d'autorisation pour supprimer",noControl:"Pas d'autorisation pour contrôler",noFiles:"Pas d'autorisation pour les fichiers",noAmsRfid:"Pas d'autorisation pour le RFID",noSmartPlugControl:"Pas d'autorisation pour les prises",noCamera:"Pas d'autorisation pour les caméras"},modal:{addTitle:"Ajouter une imprimante",editTitle:"Modifier l'imprimante",myPrinter:"Mon imprimante",selectModel:"Choisir un modèle...",locationGroup:"Emplacement / Groupe (optionnel)",locationPlaceholder:"ex: Atelier, Bureau",autoArchiveLabel:"Auto-archiver les impressions terminées",fromPrinterSettings:"Depuis les paramètres imprimante",modelOptional:"Modèle (optionnel)",saveChanges:"Enregistrer les modifications"},skipObjects:{tooltip:"Sauter des objets",onlyWhilePrinting:"Sauter (uniquement pendant l'impression)",requiresMultiple:"Sauter (nécessite 2+ objets)",title:"Sauter des objets",matchIdsInfo:"Faites correspondre les IDs avec l'écran de l'imprimante",printerShowsIds:"L'écran affiche les IDs des objets sur le plateau",skipSelected:"Sauter la sélection",skipping:"Saut en cours...",noObjectsSelected:"Aucun objet sélectionné",selectObjectsToSkip:"Sélectionnez les objets à ignorer",skipped:"sauté",objectsSkipped:"Objets sautés",activeCount:"{{count}} actifs",waitForLayer:"Attendez la couche 2 pour sauter des objets (actuelle : {{layer}})",skip:"Sauter",confirmTitle:"Sauter l'objet ?",confirmMessage:'Voulez-vous vraiment sauter "{{name}}" ? Cette action est irréversible.'},confirm:{deleteTitle:"Supprimer l'imprimante",deleteMessage:'Supprimer "{{name}}" ? Cela retirera tous les paramètres de connexion.',deleteArchivesNote:"Tout l'historique sera définitivement supprimé.",keepArchivesNote:"L'historique sera conservé mais plus associé à cette imprimante.",stopTitle:"Arrêter l'impression",stopMessage:`Arrêter l'impression sur "{{name}}" ?`,stopButton:"Arrêter",pauseTitle:"Mettre en pause",pauseMessage:`Mettre en pause l'impression sur "{{name}}" ?`,pauseButton:"Pause",resumeTitle:"Reprendre l'impression",resumeMessage:`Reprendre l'impression sur "{{name}}" ?`,resumeButton:"Reprendre",powerOnTitle:"Allumer l'imprimante",powerOnMessage:'Allumer "{{name}}" ?',powerOnButton:"Allumer",powerOffTitle:"Éteindre l'imprimante",powerOffMessage:'Éteindre "{{name}}" ?',powerOffWarning:`ATTENTION : "{{name}}" imprime ! L'éteindre maintenant peut endommager l'imprimante.`,powerOffButton:"Éteindre"},discovery:{title:"Découvrir les imprimantes",searching:"Recherche...",scanning:"Scan en cours...",scanProgress:"Scan... {{scanned}}/{{total}}",foundPrinters:"{{count}} imprimante(s) trouvée(s)",noPrintersFound:"Aucune imprimante trouvée",noPrintersFoundSubnet:"Aucune imprimante dans ce sous-réseau.",noPrintersFoundNetwork:"Aucune imprimante sur le réseau.",allConfigured:"Toutes les imprimantes trouvées sont déjà configurées.",alreadyAdded:"Déjà ajoutée",select:"Sélectionner",manualEntry:"Saisie manuelle",addFromCloud:"Ajouter depuis le Cloud",subnetToScan:"Sous-réseau à scanner",dockerNote:"Docker détecté. Entrez le sous-réseau en notation CIDR. Nécessite network_mode: host.",scanSubnet:"Scanner le sous-réseau",discoverNetwork:"Découvrir sur le réseau",scanningSubnet:"Scan du sous-réseau pour imprimantes Bambu...",scanningNetwork:"Scan du réseau...",serialRequired:"Série requis",unknown:"Inconnu",failedToStart:"Échec du démarrage de la découverte"},filaments:"Filaments",openCameraOverlay:"Ouvrir la caméra en superposition",openCameraWindow:"Ouvrir la caméra dans une fenêtre",firmwareUpdateAvailable:"Mise à jour firmware : {{current}} → {{latest}}",firmwareUpToDate:"Firmware {{version}} — À jour",firmwareUpdateButton:"Mettre à jour",plateDetection:{noPermission:"Pas d'autorisation de modification",enabledClick:"Vérification activée - Cliquez pour désactiver",disabledClick:"Vérification désactivée - Cliquez pour activer",manageCalibration:"Gérer la calibration de détection",calibrationRequired:"Calibration requise",calibrationInstructions:"Videz le plateau, puis cliquez sur Calibrer.",calibrationDescription:"Capture une image de référence du plateau vide.",calibrationTip:"Conseil : Stockez jusqu'à 5 références. Le système utilise la meilleure correspondance.",plateEmpty:"Le plateau semble vide",objectsDetected:"Objets détectés sur le plateau",confidence:"Confiance",difference:"Différence",analysisPreview:"Aperçu de l'analyse :",analysisLegend:"Cadre vert = zone, Rouge = différences",savedReferences:"Références ({{count}}/{{max}})",deleteReference:"Supprimer la référence",labelPlaceholder:"Étiquette...",clickToEdit:"{{label}} - Modifier",clickToAddLabel:"Ajouter une étiquette"},fans:{partCooling:"Ventilateur pièce",auxiliary:"Ventilateur auxiliaire",chamber:"Ventilateur chambre"},clickToViewHmsErrors:"Cliquez pour voir les erreurs HMS",estimatedCompletion:"Fin estimée",slotOptions:"Options du slot",firmwareModal:{title:"Mise à jour Firmware",titleUpToDate:"Infos Firmware",currentVersion:"Actuelle :",latestVersion:"Dernière :",releaseNotes:"Notes de version",checkingPrereqs:"Vérification des prérequis...",sdCardReady:"Carte SD prête. Cliquez pour téléverser.",uploadedSuccess:"Firmware téléversé !",applyInstructions:"Pour appliquer sur l'imprimante :",step1:"Sur l'écran, allez dans Paramètres",step2:"Allez dans Firmware",step3:'Sélectionnez "Mettre à jour depuis carte SD"',step4:"Prévoyez 10-20 minutes",done:"Terminé",starting:"Démarrage...",uploadFirmware:"Téléverser le Firmware",uploadFailed:"Échec du téléversement : {{error}}",uploadedToast:"Firmware téléversé ! Lancez la mise à jour sur l'écran."},accessCodePlaceholder:"Laissez vide pour garder l'actuel",roi:{title:"Zone de détection (ROI)",xStart:"Début X",yStart:"Début Y",width:"Largeur",height:"Hauteur",instruction:"Ajustez le cadre vert pour cibler le plateau."},developerModeWarning:"Le mode développeur LAN n'est pas activé sur : {{names}}. Certaines fonctionnalités peuvent ne pas fonctionner.",howToEnable:"Comment activer"},archives:{title:"Archives d'impression",searchPlaceholder:"Chercher dans les archives...",filterByPrinter:"Par imprimante",filterByStatus:"Par statut",sortBy:"Trier par",sortNewest:"Plus récent",sortOldest:"Plus ancien",sortName:"Nom",sortDuration:"Durée",sortLargest:"Plus volumineux",sortSmallest:"Plus léger",sortSize:"Taille",noArchives:"Aucune archive trouvée",noArchivesSearch:"Aucune archive ne correspond",noArchivesYet:"Pas encore d'archive",loadingArchives:"Chargement...",releaseToUpload:"Relâcher pour téléverser",showAll:"Tout afficher",showFavoritesOnly:"Favoris uniquement",gridView:"Grille",listView:"Liste",calendarView:"Calendrier",logView:"Journal d'impression",manageTags:"Gérer les tags",showFailedPrints:"Afficher les échecs",hideFailedPrints:"Masquer les échecs",printTime:"Temps d'impression",filamentUsed:"Filament utilisé",cost:"Coût",reprint:"Réimprimer",preview:"Aperçu",deleteArchive:"Supprimer l'archive",deleteConfirm:"Supprimer cette archive ?",favorite:"Favori",unfavorite:"Retirer des favoris",viewDetails:"Détails",status:{completed:"Réussi",failed:"Échoué",stopped:"Arrêté"},toast:{source3mfAttached:"Source 3MF attachée : {{filename}}",failedUploadSource3mf:"Échec téléversement 3MF",source3mfRemoved:"Source 3MF retirée",failedRemoveSource3mf:"Échec retrait 3MF",f3dAttached:"F3D attaché : {{filename}}",failedUploadF3d:"Échec téléversement F3D",f3dRemoved:"F3D retiré",failedRemoveF3d:"Échec retrait F3D",timelapseAttached:"Timelapse attaché : {{filename}}",timelapseAlreadyAttached:"Timelapse déjà présent",noMatchingTimelapse:"Pas de timelapse correspondant",failedScanTimelapse:"Échec scan timelapse",failedAttachTimelapse:"Échec attache timelapse",archiveDeleted:"Archive supprimée",failedDeleteArchive:"Échec suppression",addedToFavorites:"Ajouté aux favoris",removedFromFavorites:"Retiré des favoris",projectUpdated:"Projet mis à jour",failedUpdateProject:"Échec mise à jour projet",linkCopied:"Lien copié",failedCopyLink:"Échec copie lien",photoDeleted:"Photo supprimée",failedDeletePhoto:"Échec suppression photo",failedDeleteArchives:"Échec suppression archives",failedUpdateFavorites:"Échec mise à jour favoris",exportDownloaded:"Export téléchargé",exportFailed:"Échec export"},menu:{print:"Imprimer",schedule:"Planifier",openInBambuStudio:"Ouvrir dans le Slicer",slice:"Découper",externalLink:"Lien externe",viewOnMakerWorld:"Voir sur MakerWorld",preview3d:"Aperçu 3D",viewTimelapse:"Voir le Timelapse",scanForTimelapse:"Scanner pour Timelapse",downloadSource3mf:"Télécharger Source 3MF",uploadSource3mf:"Téléverser Source 3MF",replaceSource3mf:"Remplacer Source 3MF",removeSource3mf:"Retirer Source 3MF",uploadF3d:"Téléverser F3D",replaceF3d:"Remplacer F3D",downloadF3d:"Télécharger F3D",removeF3d:"Retirer F3D",download:"Télécharger",copyDownloadLink:"Copier lien de téléchargement",qrCode:"Code QR",viewPhotos:"Voir les photos",viewPhotosCount:"Voir les photos ({{count}})",projectPage:"Page du Projet",addToFavorites:"Ajouter aux favoris",removeFromFavorites:"Retirer des favoris",edit:"Modifier",goToProject:"Aller au Projet : {{name}}",addToProject:"Ajouter au Projet",removeFromProject:"Retirer du Projet",loading:"Chargement...",noProjectsAvailable:"Aucun projet disponible",select:"Sélectionner",deselect:"Désélectionner",delete:"Supprimer"},permission:{noReprint:"Pas d'autorisation de réimpression",noAddToQueue:"Pas d'autorisation pour la file",noUpdateArchives:"Pas d'autorisation de mise à jour",noUploadFiles:"Pas d'autorisation de téléversement",noDownload:"Pas d'autorisation de téléchargement",noCopyLink:"Pas d'autorisation de copie lien",noDelete:"Pas d'autorisation de suppression",noCreate:"Pas d'autorisation de création"},card:{previousPlate:"Plateau précédent",nextPlate:"Plateau suivant",plateNumber:"Plateau {{index}}",moreOptions:"Clic droit pour plus d'options",addToFavorites:"Ajouter aux favoris",removeFromFavorites:"Retirer des favoris",cancelled:"annulé",failed:"échoué",duplicate:"doublon",duplicateTitle:"Ce modèle a déjà été imprimé",openSource3mf:"Ouvrir 3MF dans Bambu Studio (clic droit pour plus)",downloadF3d:"Télécharger fichier Fusion 360",viewTimelapse:"Voir timelapse",viewPhoto:"Voir 1 photo",viewPhotos:"Voir {{count}} photos",openFolder:"Ouvrir le dossier : {{name}}",slicedFile:"Fichier découpé - prêt",sourceFile:"Fichier source uniquement - pas de mapping AMS",gcode:"GCODE",source:"SOURCE",project:"Projet : {{name}}",estimated:"Estimé : {{time}}",actual:"Réel : {{time}}",accuracy:"Précision : {{percent}}%",filament:"{{weight}}g",layer:"{{count}} couche",layers:"{{count}} couches",object:"{{count}} objet",objects:"{{count}} objets",slicedFor:"Découpé pour {{model}}",uploadedBy:"Téléversé par",noPermissionReprint:"Pas d'autorisation de réimpression",noFileForReprint:"Aucun fichier 3MF disponible — le fichier n'a pas pu être téléchargé depuis l'imprimante lors de l'enregistrement",noPermissionEdit:"Pas d'autorisation de modification",noPermissionDelete:"Pas d'autorisation de suppression",reprint:"Réimprimer",schedulePrint:"Planifier",schedule:"Planifier",openInBambuStudio:"Ouvrir dans le Slicer",openInBambuStudioToSlice:"Ouvrir dans le Slicer pour découper",slice:"Découper",externalLink:"Lien externe",makerWorld:"MakerWorld : {{designer}}",viewProject:"Voir projet",noExternalLink:"Aucun lien externe",preview3d:"Aperçu 3D",download:"Télécharger",edit:"Modifier",delete:"Supprimer"},modal:{deleteArchive:"Supprimer l'archive",deleteConfirm:'Supprimer "{{name}}" ? Cette action est irréversible.',deleteButton:"Supprimer",removeSource3mf:"Retirer Source 3MF",removeSource3mfConfirm:'Retirer le fichier 3MF de "{{name}}" ?',removeButton:"Retirer",removeF3d:"Retirer F3D",removeF3dConfirm:'Retirer le fichier Fusion 360 de "{{name}}" ?',timelapse:"{{name}} - Timelapse",selectTimelapse:"Choisir un Timelapse",selectTimelapseDesc:"Sélectionnez manuellement le timelapse :",deleteArchives:"Supprimer les archives",deleteArchivesConfirm:"Supprimer {{count}} archive(s) ?",deleteCount:"Supprimer {{count}}"},page:{title:"Archives",printsCount:"{{filtered}} sur {{total}} impressions",dropFilesHere:"Déposez les fichiers .3mf ici",releaseToUpload:"Relâcher pour téléverser",only3mfSupported:"Seuls les fichiers .3mf sont supportés",close:"Fermer",selected:"{{count}} sélectionnés",selectAll:"Tout sélectionner",tags:"Tags",project:"Projet",favorite:"Favori",delete:"Supprimer",toggledFavorites:"Favoris mis à jour pour {{count}} archive(s)",failedUpdateFavorites:"Échec mise à jour favoris",archivesDeleted:"{{count}} archive(s) supprimée(s)",failedDeleteArchives:"Échec suppression",photoDeleted:"Photo supprimée",failedDeletePhoto:"Échec suppression photo"},list:{name:"Nom",printer:"Imprimante",date:"Date",size:"Taille",actions:"Actions",hasTimelapse:"A un timelapse"},log:{date:"Date",printName:"Nom de l'impression",printer:"Imprimante",user:"Utilisateur",status:"Statut",duration:"Durée",filament:"Filament",allPrinters:"Toutes les imprimantes",allUsers:"Tous les utilisateurs",allStatuses:"Tous les statuts",cancelled:"Annulé",skipped:"Ignoré",dateFrom:"Du",dateTo:"Au",noEntries:"Aucune entrée de journal trouvée",showing:"{{count}} sur {{total}} entrées",rowsPerPage:"Lignes",page:"Page",prev:"Préc.",next:"Suiv.",clearLog:"Effacer le journal",clearLogTitle:"Effacer le journal d'impression",clearLogConfirm:"Toutes les entrées du journal d'impression seront supprimées définitivement. Les archives et les éléments de file d'attente ne sont pas affectés. Cette action est irréversible. Êtes-vous sûr ?",clearLogButton:"Tout effacer",cleared:"{{count}} entrées de journal effacées",clearFailed:"Échec de l'effacement du journal d'impression"}},queue:{title:"File d'attente",subtitle:"Gérez vos travaux d'impression",addToQueue:"Ajouter à la file",print:"Imprimer",reprint:"Réimprimer",schedulePrint:"Planifier",editQueueItem:"Modifier l'élément",printToPrinters:"Imprimer sur {{count}} imprimantes",queueToPrinters:"Ajouter à la file pour {{count}} imprimantes",sending:"Envoi...",sendingProgress:"Envoi {{current}}/{{total}}...",adding:"Ajout...",addingProgress:"Ajout {{current}}/{{total}}...",savingProgress:"Enregistrement {{current}}/{{total}}...",clearQueue:"Vider la file",clearHistory:"Effacer l'historique",emptyQueue:"La file est vide",position:"Position",scheduledTime:"Heure prévue",moveUp:"Monter",moveDown:"Descendre",startNow:"Démarrer maintenant",printingInProgress:"Impression en cours...",viewArchive:"Voir l'archive",viewInFileManager:"Voir dans le gestionnaire",itemCount:"{{count}} élément",itemCount_plural:"{{count}} éléments",dragToReorder:"Glisser pour réordonner (ASAP uniquement)",reorderHint:"La position n'affecte que les éléments ASAP.",addedBy:"Ajouté par {{name}}",nextInQueue:"Prochain en file",clearPlate:"Vider plateau & lancer suivant",clearPlateSuccess:"Plateau vidé — prêt pour l'impression suivante",plateReady:"Plateau vidé — prêt pour l'impression suivante",plateNumber:"Plateau {{index}}",sections:{currentlyPrinting:"En cours",queued:"En attente",history:"Historique"},status:{pending:"En attente",waiting:"En attente",printing:"Impression",paused:"En pause",completed:"Terminé",failed:"Échoué",skipped:"Sauté",cancelled:"Annulé"},summary:{printing:"Impressions",queued:"En attente",totalTime:"Temps total estimé",totalWeight:"Poids total estimé",history:"Historique"},filter:{allPrinters:"Toutes les imprimantes",unassigned:"Non assigné",allStatus:"Tous les statuts",allLocations:"Tous les emplacements",any:"Tout"},sort:{byPosition:"Par position",byName:"Par nom",byPrinter:"Par imprimante",bySchedule:"Par planification",byDate:"Par date",ascendingOldest:"Croissant (plus vieux)",descendingNewest:"Décroissant (plus récent)"},badges:{staged:"Préparé",requiresPrevious:"Nécessite succès précédent",autoPowerOff:"Extinction auto"},empty:{title:"Aucune impression prévue",description:"Planifiez depuis les Archives ou glissez des fichiers ici."},time:{asap:"Dès que possible",overdue:"En retard",now:"Maintenant",lessThanMinute:"Dans moins d'une minute",inMinutes:"Dans {{count}} min",inHours:"Dans {{count}} heures"},actions:{stopPrint:"Arrêter",startPrint:"Démarrer",requeue:"Remettre en file"},bulkEdit:{title:"Modifier {{count}} élément",title_plural:"Modifier {{count}} éléments",description:"Seuls les changements seront appliqués.",printer:"Imprimante",noChange:"— Aucun changement —",queueOptions:"Options de file",staged:"Préparé (manuel)",autoPowerOff:"Extinction auto après",requirePrevious:"Requiert succès précédent",printOptions:"Options d'impression",bedLevelling:"Nivellement plateau",flowCalibration:"Calibration débit",vibrationCalibration:"Vibration (Input Shaper)",layerInspection:"Inspection 1ère couche",timelapse:"Timelapse",useAms:"Utiliser AMS",applyChanges:"Appliquer",selectAll:"Tout sélectionner",deselectAll:"Tout désélectionner",selected:"{{count}} sélectionnés",editSelected:"Modifier la sélection",cancelSelected:"Annuler la sélection"},confirm:{cancelTitle:"Annuler l'impression prévue",cancelMessage:'Annuler "{{name}}" ?',stopTitle:"Arrêter l'impression",stopMessage:`Arrêter "{{name}}" sur l'imprimante ?`,removeTitle:"Retirer de l'historique",removeMessage:`Retirer "{{name}}" de l'historique ?`,clearHistoryTitle:"Effacer l'historique",clearHistoryMessage:"Retirer les {{count}} éléments ?",cancelButton:"Annuler l'impression",stopButton:"Arrêter l'impression",thisPrint:"cette impression",thisItem:"cet élément"},toast:{cancelled:"Élément annulé",cancelFailed:"Échec annulation",removed:"Élément retiré",removeFailed:"Échec retrait",stopped:"Impression arrêtée",stopFailed:"Échec arrêt",released:"Libéré dans la file",startFailed:"Échec démarrage",reorderFailed:"Échec réorganisation",historyCleared:"{{count}} éléments effacés",clearHistoryFailed:"Échec effacement",updateFailed:"Échec mise à jour",bulkCancelled:"{{count}} éléments annulés",bulkCancelFailed:"Échec annulation"},permissions:{noStopPrint:"Pas d'autorisation d'arrêt",noStartPrint:"Pas d'autorisation de démarrage",noEdit:"Pas d'autorisation de modification",noCancel:"Pas d'autorisation d'annulation",noRequeue:"Pas d'autorisation de remise en file",noRemove:"Pas d'autorisation de retrait",noClearHistory:"Pas d'autorisation historique",noEditItems:"Pas d'autorisation modification groupée",noCancelItems:"Pas d'autorisation annulation groupée"}},backgroundDispatch:{unknownFile:"Unknown file",unknownPrinter:"Unknown printer",startingPrints:"Starting prints",progressSummary:"{{complete}}/{{total}} complete • Dispatched: {{dispatched}} • Processing: {{processing}}",expandDetails:"Expand dispatch details",collapseDetails:"Collapse dispatch details",dismissToast:"Dismiss dispatch toast",cancelDispatchJob:"Cancel dispatch job",cancel:"Cancel",cancelling:"Cancelling…",status:{dispatched:"Dispatched",processing:"Processing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"},toast:{cancellingUpload:"Cancelling upload...",cancelled:"Dispatch cancelled",cancelFailed:"Failed to cancel dispatch",completeWithFailures:"Background dispatch complete: {{completed}} succeeded, {{failed}} failed",completeSuccess:"Background dispatch complete: {{completed}} succeeded"}},stats:{title:"Tableau de bord",subtitle:"Glissez les widgets pour réorganiser. Cliquez sur l'œil pour masquer.",overview:"Vue d'ensemble",totalPrints:"Total impressions",successRate:"Taux de succès",totalPrintTime:"Temps total d'impression",printTime:"Temps d'impression",totalFilament:"Total filament utilisé",filamentUsed:"Filament utilisé",filamentCost:"Coût filament",totalCost:"Coût total",energyUsed:"Énergie consommée",energyCost:"Coût énergie",averagePrintTime:"Temps moyen par impression",printsPerDay:"Impressions par jour",byPrinter:"Par imprimante",printsByPrinter:"Impressions par imprimante",byMaterial:"Par matériau",byMonth:"Par mois",last7Days:"7 derniers jours",last30Days:"30 derniers jours",last90Days:"90 derniers jours",allTime:"Tout le temps",quickStats:"Stats rapides",printActivity:"Activité d'impression",filamentTypes:"Types de filament",filamentTrends:"Tendances filament",failureAnalysis:"Analyse des échecs",timeAccuracy:"Précision du temps",successful:"Succès :",failed:"Échecs :",perfectEstimate:"100% = estimation parfaite",noTimeAccuracyData:"Pas encore de données de précision",noFilamentData:"Aucune donnée de filament",noPrinterData:"Aucune donnée d'imprimante",noPrintData:"Aucune donnée d'impression",noPrintDataLast30Days:"Aucune impression ces 30 derniers jours",failureReasons:"Raisons des échecs",topFailureReasons:"Top raisons d'échec",failedPrintsCount:"{{failed}} / {{total}} impressions ont échoué",lastWeekRate:"Semaine dernière : {{rate}}%",resetLayout:"Réinitialiser la mise en page",recalculateCosts:"Recalculer les coûts",recalculateCostsHint:"Recalcule les coûts avec les prix actuels des filaments",exportStats:"Exporter les stats",exportAsCsv:"Exporter en CSV",exportAsExcel:"Exporter en Excel",hiddenCount:"{{count}} Masqués",exportDownloaded:"Export téléchargé",exportFailed:"Échec export",layoutReset:"Mise en page réinitialisée",recalculatedCosts:"Coûts recalculés pour {{count}} archives",recalculateFailed:"Échec du calcul",loadingStats:"Chargement des statistiques...",noPermissionResetLayout:"Pas d'autorisation de réinitialisation",noPermissionRecalculate:"Pas d'autorisation de recalcul",noPrintDataInRange:"Aucune donnée dans la période sélectionnée",periodFilament:"Filament utilisé",periodCost:"Coût",avgPerPrint:"Moy. par impression",usageOverTime:"Utilisation dans le temps",filamentByWeight:"Poids",printDuration:"Durée d'impression",printerUtilization:"Utilisation imprimante",filamentSuccess:"Succès par matériau",printHabits:"Habitudes d'impression",printTimeOfDay:"Heure d'impression",colorDistribution:"Distribution des couleurs",noColorData:"Aucune donnée de couleur disponible",records:"Records",longestPrint:"Plus longue impression",heaviestPrint:"Plus lourde impression",mostExpensivePrint:"Plus chère",busiestDay:"Jour le plus actif",successStreak:"Série de succès",streakPrint:"impression consécutive",streakPrints:"{{count}} impressions consécutives",printerStats:"Stats imprimante",hours:"heures",avgPrints:"Moy. impressions",noArchiveData:"Aucune donnée d'impression disponible",filamentByTime:"Temps",avgWeight:"Moy. poids",avgTime:"Moy. temps",filamentByPrints:"Impressions",timeframe:{today:"Aujourd'hui","this-week":"Cette semaine","this-month":"Ce mois","last-7":"7 derniers jours","last-30":"30 derniers jours","last-90":"90 derniers jours","this-year":"Cette année","all-time":"Tout",custom:"Personnalisé",from:"Du",to:"Au"}},maintenance:{title:"Maintenance",overview:"Vue d'ensemble",allOk:"Toute la maintenance est à jour",dueCount:"{{count}} tâche à faire",dueCount_plural:"{{count}} tâches à faire",warningCount:"{{count}} avertissement",warningCount_plural:"{{count}} avertissements",totalPrintTime:"Temps d'impression total",nextMaintenance:"Prochaine maintenance",nothingDue:"Rien de prévu",tasks:"Tâches",lastPerformed:"Dernière réalisation",interval:"Intervalle",hoursRemaining:"{{hours}}h restantes",hoursOverdue:"{{hours}}h de retard",markDone:"Marquer comme fait",performMaintenance:"Effectuer la maintenance",history:"Historique",noHistory:"Aucun historique",editPrintHours:"Modifier les heures d'impression",currentHours:"Heures actuelles",statusTab:"Statut",settingsTab:"Paramètres",overdueCount:"{{count}} en retard",dueSoonCount:"{{count}} bientôt",dueSoon:"Bientôt",allGood:"Tout va bien",overdueBy:"Retard de {{duration}}",dueIn:"Dans {{duration}}",timeLeft:"{{duration}} restant",day:"1 jour",days:"{{count}} jours",week:"1 semaine",weeks:"{{count}} semaines",month:"1 mois",months:"{{count}} mois",year:"1 an",maintenanceTypes:"Types de maintenance",maintenanceTypesDescription:"Types système et tâches personnalisées",addCustomType:"Ajouter un type",intervalType:"Type d'intervalle",intervalValue:"Intervalle ({{type}})",icon:"Icône",documentationLink:"Lien documentation (optionnel)",assignToPrinters:"Assigner aux imprimantes",selectAtLeastOnePrinter:"Sélectionnez au moins une imprimante",addType:"Ajouter le type",custom:"Personnalisé",printHours:"Heures d'impression",calendarDays:"Jours calendaires",exampleName:"ex: Remplacement filtre HEPA",viewDocumentation:"Voir documentation",timeBasedInterval:"Intervalle temporel",intervalOverrides:"Exceptions d'intervalle",intervalOverridesDescription:"Intervalles spécifiques par imprimante",assignedToPrinters:"Assigné aux imprimantes :",noPrintersAssigned:"Aucune imprimante assignée",addPrinterShort:"Ajouter :",printersAssignedClick:"{{count}} imprimante(s) assignée(s) - gérer",removeFromPrinter:"Retirer de cette imprimante",types:{lubricateCarbonRods:"Lubrifier les tiges carbone",lubricateRails:"Lubrifier les rails linéaires",cleanNozzle:"Nettoyer la buse / hotend",checkBelts:"Vérifier la tension des courroies",cleanBuildPlate:"Nettoyer le plateau",checkExtruder:"Vérifier les engrenages de l'extrudeur",checkCooling:"Vérifier les ventilateurs",generalInspection:"Inspection générale",cleanCarbonRods:"Nettoyer les tiges carbone",cleanLinearRails:"Nettoyer les rails linéaires",checkPtfeTube:"Vérifier le tube PTFE",replaceHepaFilter:"Remplacer le filtre HEPA",replaceCarbonFilter:"Remplacer le filtre charbon",lubricateLeftNozzleRail:"Lubrifier le rail de buse gauche"},maintenanceComplete:"Maintenance marquée comme faite",typeUpdated:"Type mis à jour",typeDeleted:"Type supprimé",printHoursUpdated:"Heures mises à jour",printerAssigned:"Imprimante assignée",printerRemoved:"Imprimante retirée",deleteTypeConfirm:'Supprimer "{{name}}" ?',noPermissionUpdate:"Pas d'autorisation de mise à jour",noPermissionPerform:"Pas d'autorisation d'action",noPermissionEditTypes:"Pas d'autorisation de modification types",noPermissionDeleteTypes:"Pas d'autorisation de suppression types",noPermissionEditHours:"Pas d'autorisation de modification heures",noPermissionRemovePrinter:"Pas d'autorisation retrait imprimante",noPermissionAssignPrinter:"Pas d'autorisation assignation",noPermissionEditIntervals:"Pas d'autorisation modification intervalles",configureSettings:"Configurer types et intervalles"},settings:{title:"Paramètres",general:"Général",tabs:{general:"Général",smartPlugs:"Prises connectées",notifications:"Notifications",filament:"Filament",network:"Réseau",apiKeys:"Clés API",virtualPrinter:"Imprimante virtuelle",users:"Authentification",backup:"Sauvegarde",emailAuth:"Authentification Email"},email:{smtpSettings:"Configuration SMTP",smtpHost:"Serveur SMTP",smtpPort:"Port SMTP",security:"Sécurité",authentication:"Authentification",username:"Utilisateur",password:"Mot de passe",fromEmail:"Email expéditeur",fromName:"Nom expéditeur",testConnection:"Tester la connexion SMTP",testRecipient:"Email test destinataire",sendTest:"Envoyer email test",sending:"Envoi...",save:"Enregistrer les paramètres",saving:"Enregistrement...",advancedAuth:"Authentification avancée",advancedAuthEnabled:"L'authentification avancée est activée",advancedAuthEnabledDesc:"La gestion des utilisateurs par email est active. Les nouveaux utilisateurs recevront un mot de passe auto-généré.",advancedAuthDisabled:"Authentification avancée désactivée",advancedAuthDisabledDesc:"Activez pour les fonctionnalités liées à l'email (mot de passe oublié, etc).",enable:"Activer",disable:"Désactiver",feature1:"Génération auto et envoi de mots de passe par email",feature2:"Connexion par utilisateur ou email",feature3:"Réinitialisation mot de passe oublié disponible",feature4:"Réinitialisation admin par email",errors:{requiredFields:"Remplissez tous les champs requis",usernameRequired:"L'utilisateur est requis pour l'authentification",enterTestEmail:"Entrez une adresse email de test",smtpServerAndEmail:"Serveur et expéditeur requis pour le test",usernamePasswordRequired:"Utilisateur et mot de passe requis pour l'auth",configureSmtpFirst:"Configurez et testez le SMTP d'abord"},success:{settingsSaved:"Paramètres SMTP enregistrés"},securityOptions:{starttls:"STARTTLS (Port 587)",ssl:"SSL/TLS (Port 465)",none:"Aucun (Port 25)"},authOptions:{enabled:"Activée",disabled:"Désactivée"}},appearance:"Apparence",notifications:"Notifications",smartPlugs:"Prises connectées",spoolman:"Spoolman",updates:"Mises à jour",language:"Langue",languageDescription:"Choisissez votre langue",theme:"Thème",themeLight:"Clair",themeDark:"Sombre",themeSystem:"Système",defaultView:"Vue par défaut",defaultViewDescription:"Page affichée au démarrage",checkForUpdates:"Vérifier les mises à jour",autoUpdate:"Mise à jour auto",currentVersion:"Version actuelle",latestVersion:"Dernière version",upToDate:"Bambuddy est à jour",updateAvailable:"Mise à jour disponible",notificationLanguage:"Langue des notifications",notificationLanguageDescription:"Langue pour les notifications push",bedCooledThreshold:"Seuil de refroidissement du plateau",bedCooledThresholdDescription:"Température en dessous de laquelle le plateau est considéré comme refroidi",notificationProviders:"Fournisseurs de notifications",addProvider:"Ajouter un fournisseur",editProvider:"Modifier le fournisseur",providerType:"Type de fournisseur",testNotification:"Tester la notification",testSuccess:"Notification de test envoyée",testFailed:"Échec de l'envoi du test",quietHours:"Heures de silence",quietHoursDescription:"Ne pas déranger pendant ces heures",quietHoursStart:"Début",quietHoursEnd:"Fin",events:{title:"Événements de notification",printStart:"Impression démarrée",printComplete:"Impression terminée",printFailed:"Impression échouée",printStopped:"Impression arrêtée",printProgress:"Jalons de progression",printProgressDescription:"Notifier à 25%, 50%, 75%",printerOffline:"Imprimante hors ligne",printerError:"Erreur imprimante",filamentLow:"Filament bas",maintenanceDue:"Maintenance due",maintenanceDueDescription:"Notifier quand une tâche est due"},smartPlug:{title:"Prises connectées",add:"Ajouter une prise",edit:"Modifier la prise",name:"Nom",ipAddress:"Adresse IP",linkedPrinter:"Imprimante liée",autoOn:"Allumage auto",autoOnDescription:"Allumer au début de l'impression",autoOff:"Extinction auto",autoOffDescription:"Éteindre après l'impression",offDelay:"Délai d'extinction",offDelayMinutes:"Minutes après fin",offDelayTemp:"Quand la buse est sous",currentState:"État actuel",turnOn:"Allumer",turnOff:"Éteindre"},filamentTracking:"Suivi de Filament",filamentTrackingDesc:"Choisissez comment suivre vos bobines. Utilisez l'inventaire intégré ou connectez un serveur Spoolman.",trackingModeBuiltIn:"Inventaire Intégré",trackingModeBuiltInDesc:"Correspondance RFID et suivi de consommation inclus",trackingModeSpoolmanDesc:"Serveur de gestion externe",builtInFeatureRfid:"Détecte auto les bobines RFID Bambu Lab dans l'AMS",builtInFeatureUsage:"Suit la consommation par impression",builtInFeatureCatalog:"Gère bobines, couleurs et profils facteur K",builtInFeatureThirdParty:"Les bobines tierces peuvent être assignées aux bobines d'inventaire",amsSyncButton:"Synchroniser les poids depuis l'AMS",amsSyncTitle:"Synchroniser les poids des bobines depuis l'AMS",amsSyncMessage:"Tous les poids des bobines de l'inventaire seront écrasés par les valeurs actuelles de l'AMS des imprimantes connectées. Utilisez ceci pour récupérer des données de poids corrompues. Les imprimantes doivent être en ligne.",amsSyncing:"Synchronisation...",amsSyncSuccess:"{{synced}} bobine(s) synchronisée(s), {{skipped}} ignorée(s)",amsSyncError:"Échec de la synchronisation des poids depuis l'AMS",spoolmanUrl:"URL Spoolman",spoolmanUrlHint:"URL de votre serveur Spoolman (ex: http://localhost:7912)",spoolmanConnected:"Connecté",spoolmanDisconnected:"Déconnecté",status:"Statut",connect:"Connecter",disconnect:"Déconnecter",howSyncWorks:"Fonctionnement de la Sync",syncInfoRfidOnly:"Seules les bobines officielles RFID sont synchronisées",syncInfoAutoCreate:"Les bobines sont créées dans Spoolman à la 1ère sync",syncInfoThirdPartySkipped:"Les bobines tierces ou rechargées sont ignorées",linkingExistingSpools:"Lier des bobines existantes",linkingExistingSpoolsDesc:'Pour lier une bobine Spoolman, survolez un slot AMS et cliquez sur "Lier à Spoolman".',syncMode:"Mode de Sync",syncModeAuto:"Automatique",syncModeManual:"Manuel uniquement",syncModeAutoDesc:"Sync auto lors de changements AMS",syncModeManualDesc:"Sync uniquement sur déclenchement manuel",syncAmsData:"Synchroniser AMS",syncAmsDataDesc:"Synchroniser manuellement les données vers Spoolman",allPrinters:"Toutes les imprimantes",noDefaultPrinter:"Aucune par défaut (demander à chaque fois)",sidebarOrder:"Ordre de la barre latérale",saveThumbnails:"Enregistrer les vignettes",captureFinishPhoto:"Prendre une photo à la fin",noPrintersConfigured:"Aucune imprimante configurée",archiveMode:{always:"Toujours créer une archive",never:"Ne jamais créer d'archive",ask:"Demander à chaque fois"},checkForUpdatesLabel:"Vérifier les mises à jour",checkPrinterFirmware:"Vérifier le firmware imprimante",includeBetaUpdates:"Inclure les versions bêta",includeBetaUpdatesDesc:"Notifier des versions bêta et préliminaires lors de la vérification des mises à jour",enableRetry:"Activer la rétentative",homeAssistantDescription:"Contrôler les prises via Home Assistant",environmentManagedLabel:"(Géré par l'environnement)",autoEnabledViaEnv:"Activé via variables d'environnement",urlFromEnvReadOnly:"Valeur HA_URL (lecture seule)",tokenFromEnvReadOnly:"Valeur HA_TOKEN (lecture seule)",mqttConnectedTo:"Connecté à",prometheusDescription:"Exposer les données au format Prometheus",noSmartPlugsTitle:"Aucune prise configurée",noSmartPlugsDescription:"Ajoutez une prise Tasmota pour suivre l'énergie et automatiser.",noProvidersTitle:"Aucun fournisseur configuré",noProvidersDescription:"Ajoutez un fournisseur pour recevoir des alertes.",noTemplatesAvailable:"Aucun modèle dispo. Redémarrez pour les générer.",apiPermissionView:"Voir statut et file",apiPermissionEdit:"Gérer la file d'attente",apiKeysEmptyTitle:"Aucune clé API",apiKeysEmptyDescription:"Créez une clé pour vos intégrations.",noUsersFound:"Aucun utilisateur trouvé",noGroupsFound:"Aucun groupe trouvé",noGroupsAvailable:"Aucun groupe disponible",passwordsDoNotMatch:"Les mots de passe ne correspondent pas",systemGroupWarning:"Les noms des groupes système sont fixes",authDisabledTitle:"Authentification désactivée",authDisabledFeature1:"Requis pour accéder au système",authDisabledFeature2:"Gestion multi-utilisateurs et groupes",authDisabledFeature3:"Plus de 50 permissions granulaires",userHasCreated:"Cet utilisateur a créé :",userItemsQuestion:"Que faire de ces éléments ?",deleteUserConfirm:"Supprimer cet utilisateur ?",actionCannotBeUndone:"Cette action est irréversible.",addFirstSmartPlug:"Ajoutez votre première prise",providers:"Fournisseurs",log:"Journal",testAll:"Tout tester",testResults:"Résultats du test",testPassedCount:"{{count}} succès",testFailedCount:"{{count}} échecs",messageTemplates:"Modèles de message",messageTemplatesDescription:"Personnalisez les messages par événement.",apiKeys:"Clés API",apiKeysDescription:"Créez des clés pour webhooks et API.",createKey:"Créer une clé",apiKeyCreated:"Clé API créée avec succès",apiKeyCopyWarning:"Copiez cette clé maintenant - elle ne sera plus affichée !",useInApiBrowser:"Utiliser dans l'explorateur API",createNewApiKey:"Nouvelle clé API",keyName:"Nom de la clé",keyNamePlaceholder:"ex: Home Assistant, OctoPrint",readStatus:"Lire le statut",readStatusDescription:"Voir les imprimantes et la file",manageQueue:"Gérer la file",manageQueueDescription:"Ajouter/retirer des éléments",controlPrinter:"Contrôler l'imprimante",controlPrinterDescription:"Pause, reprise, arrêt",unnamedKey:"Clé sans nom",lastUsed:"Dernière utilisation",read:"Lecture",control:"Contrôle",createFirstKey:"Créez votre première clé",webhookEndpoints:"Points de terminaison Webhook",webhookApiKeyHint:"Utilisez la clé dans l'en-tête X-API-Key.",webhook:{getAllStatus:"Tous les statuts",getSpecificStatus:"Statut spécifique",addToQueue:"Ajouter à la file",pausePrint:"Pause",resumePrint:"Reprise",stopPrint:"Arrêt"},apiBrowser:"Explorateur API",apiBrowserDescription:"Testez les endpoints API.",apiKeyForTesting:"Clé API pour test",apiKeyPlaceholder:"Collez votre clé pour tester...",apiKeyHint:"Sera envoyée via l'en-tête X-API-Key.",deleteApiKeyTitle:"Supprimer la clé API",deleteApiKeyMessage:"Les intégrations utilisant cette clé cesseront de fonctionner.",deleteKey:"Supprimer la clé",amsDisplayThresholds:"Seuils d'affichage AMS",amsThresholdsDescription:"Seuils de couleur pour humidité et température.",humidity:"Humidité",goodGreen:"Bon (vert)",fairOrange:"Moyen (orange)",aboveFairBad:"Au-dessus = rouge (mauvais)",temperature:"Température",goodBlue:"Bon (bleu)",aboveFairHot:"Au-dessus = rouge (chaud)",historyRetention:"Rétention d'historique",keepSensorHistory:"Garder l'historique pendant",historyRetentionDescription:"Les anciennes données seront supprimées.",printModal:"Fenêtre d'impression",expandCustomMapping:"Étendre le mapping personnalisé par défaut",expandCustomMappingDescription:"Affiche le mapping AMS par imprimante étendu.",authentication:"Authentification",authEnabledDescription:"L'instance est sécurisée",authDisabledDescription:"Activez pour restreindre l'accès",authDisabledMessage:"Activez l'authentification pour gérer comptes et permissions.",enableAuthentication:"Activer l'authentification",currentUser:"Utilisateur actuel",changePassword:"Changer le mot de passe",admin:"Admin",users:"Utilisateurs",addUser:"Ajouter un utilisateur",groups:"Groupes",addGroup:"Ajouter un groupe",system:"Système",noDescription:"Pas de description",userCount:"{{count}} utilisateurs",permissionCount:"{{count}} permissions",createUser:"Créer un utilisateur",username:"Nom d'utilisateur",enterUsername:"Entrez l'utilisateur",password:"Mot de passe",enterPassword:"Mot de passe (min 6 char)",confirmPassword:"Confirmer le mot de passe",confirmPasswordPlaceholder:"Confirmez le mot de passe",viewReleaseOnGitHub:"Voir la version sur GitHub",turnAllPlugsOn:"Tout allumer",turnAllPlugsOff:"Tout éteindre",clearNotificationLogs:"Effacer les journaux",clearLogsMessage:"Efface définitivement les logs de plus de 30 jours.",clearLogs:"Effacer les logs",resetUiPreferences:"Réinitialiser l'UI",resetUiPreferencesMessage:"Réinitialise l'ordre, thème, widgets, etc. N'affecte pas vos données.",resetPreferences:"Réinitialiser",deleteGroupTitle:"Supprimer le groupe",deleteGroupMessage:"Les utilisateurs de ce groupe perdront ces permissions.",deleteGroup:"Supprimer le groupe",disableAuthenticationTitle:"Désactiver l'authentification",disableAuthenticationMessage:"Instance accessible sans connexion. Les comptes sont conservés.",disableAuthentication:"Désactiver",configureBambuddy:"Configurer Bambuddy",systemDefault:"Défaut système",archiveSettings:"Réglages Archives",newWindow:"Nouvelle fenêtre",embeddedOverlay:"Superposition intégrée",preferredSlicer:"Slicer préféré",preferredSlicerDescription:"Application pour ouvrir les fichiers",externalCameras:"Caméras externes",costTracking:"Suivi des coûts",printsOnly:"Impressions uniquement",totalConsumption:"Consommation totale",dataManagement:"Gestion des données",storageUsage:"Utilisation du stockage",storageUsageDescription:"Répartition de l'utilisation des données par catégorie",storageUsageTotal:"Total",storageUsageErrors:"Erreurs",storageUsageOtherBreakdown:"Autre (inclut ressources statiques, scripts et fichiers de configuration)",storageUsageSystem:"Système",storageUsageData:"Données",storageUsageUnavailable:"Informations d'utilisation du stockage non disponibles",clearNotificationLogsDescription:"Supprimer logs de plus de 30 jours",resetUiPreferencesDescription:"Réinitialise thèmes et affichage sans toucher aux données.",enableHomeAssistant:"Activer Home Assistant",enableMqtt:"Activer MQTT",useTls:"Utiliser TLS",enableMetricsEndpoint:"Activer l'endpoint Metrics",availableMetrics:"Metrics disponibles",editUser:"Modifier l'utilisateur",deleteUserTitle:"Supprimer l'utilisateur",groupName:"Nom du groupe",leaveEmptyForAnonymous:"Vide pour anonyme",leaveEmptyForNoAuth:"Vide si pas d'auth",enterNewPassword:"Nouveau mot de passe",confirmNewPassword:"Confirmer nouveau mdp",enterGroupName:"Entrez le nom du groupe",enterDescriptionOptional:"Description (optionnel)",enterCurrentPassword:"Mdp actuel",enterNewPasswordMin6:"Nouveau mdp (min 6 char)",toast:{keyCopied:"Clé copiée",copyFailed:"Échec copie",keyAddedToBrowser:"Clé ajoutée à l'explorateur",clearLogsFailed:"Échec effacement logs",uiPreferencesReset:"Préférences UI réinitialisées. Rafraîchissement...",authDisabled:"Authentification désactivée",authDisableFailed:"Échec désactivation",apiKeyCreated:"Clé API créée",apiKeyDeleted:"Clé API supprimée",userCreated:"Utilisateur créé",userUpdated:"Utilisateur mis à jour",userDeleted:"Utilisateur supprimé",groupCreated:"Groupe créé",groupUpdated:"Groupe mis à jour",groupDeleted:"Groupe supprimé",fillRequiredFields:"Remplissez les champs requis",passwordsDoNotMatch:"Les mots de passe ne correspondent pas",passwordTooShort:"Minimum 6 caractères",enterGroupName:"Entrez un nom de groupe",settingsSaved:"Paramètres enregistrés",cameraSettingsSaved:"Réglages caméra enregistrés",enterCameraUrl:"Entrez une URL caméra",passwordChanged:"Mot de passe modifié",connectionFailed:"Échec connexion",testFailed:"Échec test",cameraConnected:"Caméra connectée {{resolution}}"},testConnection:"Tester la connexion",catalog:{spoolCatalog:"Catalogue de Bobines",spoolCatalogDescription:"Poids des bobines vides par marque/type. Utilisé pour le calcul auto du poids restant.",searchCatalog:"Chercher dans le catalogue...",addNewEntry:"Nouvelle Entrée",namePlaceholder:"Nom (ex: Bambu Lab - Plastique)",weight:"Poids",type:"Type",default:"Défaut",custom:"Perso",noMatch:"Aucune entrée correspondante",empty:"Catalogue vide",deleteEntry:"Supprimer l'entrée",deleteConfirm:'Supprimer "{{name}}" ?',resetCatalog:"Réinitialiser le catalogue",resetConfirm:"Réinitialiser aux valeurs par défaut ? Vos entrées personnalisées seront supprimées.",loadFailed:"Échec chargement catalogue",nameWeightRequired:"Nom et poids requis",entryAdded:"Entrée ajoutée",addFailed:"Échec ajout",entryUpdated:"Entrée mise à jour",updateFailed:"Échec mise à jour",entryDeleted:"Entrée supprimée",deleteFailed:"Échec suppression",resetSuccess:"Catalogue réinitialisé",resetFailed:"Échec réinitialisation",exported:"{{count}} entrées exportées",imported:"{{added}} entrées importées ({{skipped}} ignorées)",importFailed:"Échec import : format JSON invalide",exportTooltip:"Exporter en JSON",importTooltip:"Importer depuis JSON",resetTooltip:"Réinitialiser par défaut"},colorCatalog:{title:"Catalogue de Couleurs",description:"Couleurs de filament par fabricant. Utilisé pour la recherche auto lors de l'ajout de bobines.",searchColors:"Chercher couleurs...",allManufacturers:"Tous les fabricants",addNewColor:"Nouvelle Couleur",manufacturer:"Fabricant",colorName:"Nom couleur",hex:"Hex",materialOptional:"Matériau (optionnel)",showing:"Affichage {{filtered}} sur {{total}} couleurs",noMatch:"Aucune couleur correspondante",empty:"Catalogue vide",deleteColor:"Supprimer couleur",deleteConfirm:'Supprimer "{{name}}" ?',resetCatalog:"Réinitialiser catalogue couleurs",resetConfirm:"Réinitialiser aux valeurs par défaut ?",sync:"Sync",starting:"Démarrage...",syncTooltip:"Sync depuis FilamentColors.xyz (2000+ couleurs, peut être long)",loadFailed:"Échec chargement catalogue couleurs",fieldsRequired:"Fabricant, nom et code Hex requis",colorAdded:"Couleur ajoutée",addFailed:"Échec ajout",colorUpdated:"Couleur mise à jour",updateFailed:"Échec mise à jour",colorDeleted:"Couleur supprimée",deleteFailed:"Échec suppression",resetSuccess:"Catalogue réinitialisé",resetFailed:"Échec réinitialisation",syncUpToDate:"Déjà à jour ({{count}} couleurs vérifiées)",syncComplete:"{{added}} couleurs ajoutées ({{skipped}} déjà présentes)",syncError:"Erreur de sync",syncFailed:"Échec sync FilamentColors.xyz",exported:"{{count}} couleurs exportées",imported:"{{added}} couleurs importées ({{skipped}} ignorées)",importFailed:"Échec import : format JSON invalide"}},notification:{printStarted:{title:"Impression démarrée",body:"{{printer}} : {{filename}} commence l'impression"},printCompleted:{title:"Impression terminée",body:"{{printer}} : {{filename}} a réussi"},printFailed:{title:"Impression échouée",body:"{{printer}} : {{filename}} a échoué"},printStopped:{title:"Impression arrêtée",body:"{{printer}} : {{filename}} a été arrêtée"},printProgress:{title:"Progression d'impression",body:"{{printer}} : {{filename}} est à {{percent}}%"},printerOffline:{title:"Imprimante hors ligne",body:"{{printer}} est déconnectée"},printerError:{title:"Erreur imprimante",body:"{{printer}} : {{error}}"},filamentLow:{title:"Filament bas",body:"{{printer}} : Le filament est presque vide"},maintenanceDue:{title:"Maintenance due",body:"{{printer}} : {{items}} demandent votre attention"}},errors:{generic:"Une erreur est survenue",networkError:"Erreur réseau. Vérifiez votre connexion.",notFound:"Non trouvé",unauthorized:"Non autorisé",serverError:"Erreur serveur",validationError:"Vérifiez vos saisies",printerConnectionFailed:"Échec connexion imprimante",saveFailed:"Échec enregistrement",deleteFailed:"Échec suppression",loadFailed:"Échec chargement"},hmsErrors:{title:"Erreurs - {{name}}",noErrors:"Aucune erreur",viewOnWiki:"Voir sur le Wiki Bambu Lab",clearInstructions:"Effacez les erreurs sur l'imprimante pour les retirer ici.",clearErrors:"Effacer les erreurs",clearSuccess:"Erreurs HMS effacées",clearFailed:"Échec de l'effacement des erreurs HMS"},mqttDebug:{title:"Journal de débogage MQTT",searchPlaceholder:"Chercher topic ou message...",noMessages:"Aucun message enregistré",startLoggingHint:'Cliquez sur "Démarrer" pour capturer les messages MQTT',noMessagesMatch:"Aucun message ne correspond",adjustFilterHint:"Ajustez votre recherche",incoming:"Entrant",outgoing:"Sortant",loggingStopped:"Enregistrement arrêté",loggingActive:"Enregistrement actif - rafraîchissement auto",startLogging:"Démarrer",stopLogging:"Arrêter",clearLog:"Effacer le journal",topic:"Topic",timestamp:"Horodatage",direction:"Direction",all:"Tous"},printerFiles:{title:"Gestionnaire de fichiers",storageUsed:"Utilisé :",storageFree:"Libre :",filterPlaceholder:"Filtrer les fichiers...",deleteButton:"Supprimer",deleteFiles:"Supprimer {{count}} fichiers",deleteFileConfirm:'Supprimer "{{name}}" ?',deleteFilesConfirm:"Supprimer les {{count}} fichiers sélectionnés ?",noFiles:"Aucun fichier sur l'imprimante",loadingFiles:"Chargement...",failedToLoad:"Échec chargement fichiers",toast:{filesDeleted:"{{count}} fichier(s) supprimé(s)",deleteFailed:"Échec suppression : {{error}}"}},confirm:{delete:"Voulez-vous vraiment supprimer cet élément ?",unsavedChanges:"Changements non sauvegardés. Voulez-vous quitter ?",clearQueue:"Voulez-vous vraiment vider la file d'attente ?"},login:{title:"Connexion Bambuddy",subtitle:"Connectez-vous à votre compte",username:"Utilisateur",usernamePlaceholder:"Entrez votre utilisateur",usernameOrEmail:"Utilisateur ou Email",usernameOrEmailPlaceholder:"Utilisateur ou @ Email",password:"Mot de passe",passwordPlaceholder:"Entrez votre mot de passe",signIn:"Se connecter",signingIn:"Connexion...",forgotPassword:"Mot de passe oublié ?",loginSuccess:"Connecté avec succès",loginFailed:"Échec de connexion",enterCredentials:"Entrez vos identifiants",forgotPasswordTitle:"Mot de passe oublié",forgotPasswordMessage:"Contactez votre administrateur pour réinitialiser votre accès.",forgotPasswordEmailMessage:"Entrez votre email pour recevoir un nouveau mot de passe.",emailAddress:"Adresse Email",emailPlaceholder:"votre.email@exemple.com",cancel:"Annuler",sending:"Envoi...",sendResetEmail:"Envoyer l'email",howToReset:"Comment réinitialiser :",resetStep1:"Contactez votre admin Bambuddy",resetStep2:"Demandez une réinitialisation dans la Gestion Utilisateurs",resetStep3:"Il vous donnera un mot de passe temporaire",resetStep4:"Connectez-vous et changez-le dans les Paramètres",gotIt:"Compris"},setup:{title:"Configuration Bambuddy",subtitle:"Configurez l'authentification",enableAuth:"Activer l'authentification",adminAccount:"Compte Admin",adminAccountDesc:"Si des admins existent, ils seront utilisés. Sinon, créez-en un ci-dessous.",adminUsername:"Utilisateur Admin",adminPassword:"Mot de passe Admin",optionalIfAdminExists:"(optionnel si admin existe)",adminUsernamePlaceholder:"Nom admin (optionnel)",adminPasswordPlaceholder:"Mdp admin (optionnel)",confirmPassword:"Confirmer mdp",confirmPasswordPlaceholder:"Confirmez mdp admin",settingUp:"Configuration...",completeSetup:"Terminer la configuration",toast:{authEnabledAdminCreated:"Authentification activée et admin créé",authEnabledExistingAdmins:"Authentification activée avec admins existants",setupCompleted:"Configuration terminée",enterBothCredentials:"Entrez les deux ou laissez vide pour utiliser les admins existants",passwordsDoNotMatch:"Les mots de passe ne correspondent pas",passwordTooShort:"Minimum 6 caractères"}},changePassword:{title:"Changer le mot de passe",currentPassword:"Mot de passe actuel",currentPasswordPlaceholder:"Entrez mdp actuel",newPassword:"Nouveau mot de passe",newPasswordPlaceholder:"Nouveau mdp (min 6 char)",confirmPassword:"Confirmer nouveau mdp",confirmPasswordPlaceholder:"Confirmez nouveau mdp",passwordsDoNotMatch:"Les mots de passe ne correspondent pas",passwordTooShort:"Minimum 6 caractères",changing:"Changement...",success:"Mot de passe modifié",failed:"Échec modification"},plateAlert:{title:"Impression en Pause !",message:"Objets détectés sur le plateau. L'impression a été suspendue automatiquement. Videz le plateau avant de reprendre.",understand:"J'ai compris"},camera:{title:"Vue Caméra",invalidPrinterId:"ID imprimante invalide",live:"Direct",snapshot:"Instantané",restartStream:"Redémarrer le flux",refreshSnapshot:"Rafraîchir l'image",fullscreen:"Plein écran",exitFullscreen:"Quitter plein écran",connectingToCamera:"Connexion caméra...",capturingSnapshot:"Capture...",connectionLost:"Connexion perdue",connectionFailed:"Échec connexion caméra",reconnecting:"Reconnexion dans {{countdown}}s... (essai {{attempt}}/{{max}})",reconnectNow:"Reconnexion immédiate",cameraUnavailable:"Caméra indisponible",cameraUnavailableDesc:"Vérifiez que l'imprimante est allumée.",noCamera:"Aucune caméra disponible",retry:"Réessayer",cameraStream:"Flux caméra",zoomOut:"Zoom arrière",zoomIn:"Zoom avant",resetZoom:"Réinitialiser zoom",recording:"Enregistrement",startRecording:"Démarrer l'enregistrement",stopRecording:"Arrêter l'enregistrement",chamberLight:"Basculer lumière chambre"},groups:{title:"Gestion des Groupes",subtitle:"Gérez les permissions pour le contrôle d'accès",backToSettings:"Retour aux paramètres",createGroup:"Créer un groupe",noPermission:"Accès refusé.",system:"Système",noDescription:"Pas de description",usersCount:"{{count}} utilisateurs",permissionsCount:"{{count}} permissions",edit:"Modifier",delete:"Supprimer",toast:{created:"Groupe créé",updated:"Groupe mis à jour",deleted:"Groupe supprimé",enterGroupName:"Entrez un nom de groupe"},modal:{editGroup:"Modifier le groupe",createGroup:"Créer un groupe",cancel:"Annuler",saving:"Enregistrement...",creating:"Création...",saveChanges:"Enregistrer"},form:{groupName:"Nom du groupe",groupNamePlaceholder:"Nom du groupe",systemGroupWarning:"Les groupes système sont fixes",description:"Description",descriptionPlaceholder:"Description (optionnel)",permissions:"Permissions ({{count}} sélectionnées)"},deleteModal:{title:"Supprimer le groupe",message:"Les utilisateurs de ce groupe perdront ces permissions.",confirm:"Supprimer"},editor:{title:"Modifier le groupe",createTitle:"Créer un groupe",search:"Rechercher des permissions...",selectAll:"Tout sélectionner",clearAll:"Tout désélectionner",permissionsSelected:"{{count}} sélectionnée(s)",noResults:"Aucune permission ne correspond à votre recherche"}},users:{title:"Gestion des Utilisateurs",subtitle:"Gérez les accès à Bambuddy",backToSettings:"Retour aux paramètres",createUser:"Créer un utilisateur",noPermission:"Accès refusé.",admin:"Admin",noGroups:"Aucun groupe",active:"Actif",inactive:"Inactif",edit:"Modifier",delete:"Supprimer",system:"Système",noGroupsAvailable:"Aucun groupe disponible",table:{username:"Utilisateur",groups:"Groupes",status:"Statut",actions:"Actions"},toast:{created:"Utilisateur créé",updated:"Utilisateur mis à jour",deleted:"Utilisateur supprimé",fillRequired:"Remplissez les champs requis",passwordsDoNotMatch:"Les mots de passe ne correspondent pas",passwordTooShort:"Minimum 6 caractères"},modal:{createUser:"Créer utilisateur",editUser:"Modifier utilisateur",cancel:"Annuler",creating:"Création...",saving:"Enregistrement...",saveChanges:"Enregistrer",advancedAuthSubtitle:"avec Authentification Avancée"},form:{username:"Utilisateur",usernamePlaceholder:"Nom utilisateur",email:"Email",emailPlaceholder:"utilisateur@exemple.com",password:"Mot de passe",passwordPlaceholder:"Mot de passe",confirmPassword:"Confirmer mdp",confirmPasswordPlaceholder:"Confirmez mdp",newPasswordPlaceholder:"Nouveau mdp",confirmNewPasswordPlaceholder:"Confirmez nouveau mdp",leaveBlankToKeep:"Laissez vide pour conserver l'actuel",groups:"Groupes",optional:"optionnel",autoGeneratedPassword:"Un mot de passe sera généré et envoyé par email.",passwordManagedByAdvancedAuth:'Géré par Auth Avancée. Utilisez "Réinitialiser" pour envoyer un nouveau mdp par email.',resetPassword:"Réinitialiser le mot de passe",resettingPassword:"Réinitialisation..."},deleteModal:{title:"Supprimer utilisateur",message:"Cette action est irréversible.",confirm:"Supprimer"}},streamOverlay:{title:"Superposition Flux",invalidPrinterId:"ID invalide",cameraStream:"Flux caméra",progress:"Progression",eta:"Fin estimée",printerIdle:"Imprimante inactive",printerOffline:"Imprimante hors ligne",status:{printing:"Impression",paused:"En pause",finished:"Terminée",failed:"Échouée",idle:"Inactive",unknown:"Inconnue"}},profiles:{title:"Profils",subtitle:"Gérez vos presets slicer et calibrations Pressure Advance",tabs:{cloud:"Profils Cloud",local:"Profils Locaux",kprofiles:"K-Profiles"},localProfiles:{title:"Profils Locaux",subtitle:"Gérez vos presets OrcaSlicer",import:"Importer Profils",importDesc:"Déposez les fichiers .bbscfg, .bbsflmt, .orca_filament, .zip ou .json",importing:"Importation...",search:"Chercher un preset...",noPresets:"Aucun preset local",badge:"Local",edit:"Modifier",delete:"Supprimer",cancel:"Annuler",deleteConfirmTitle:"Supprimer Preset",deleteConfirm:"Supprimer définitivement ce preset ?",source:"Source",inheritsFrom:"Hérite de",filamentType:"Type",vendor:"Vendeur",compatiblePrinters:"Imprimantes",nozzleTemp:"Temp Buse",cost:"Coût",density:"Densité",pressureAdvance:"Pressure Advance",filament:"Filament",process:"Processus",printer:"Imprimante",toast:{importSuccess:"{{count}} profil(s) importé(s)",importSkipped:"{{count}} profil(s) ignoré(s) (doublons)",importError:"{{count}} erreur(s) d'import",deleted:"Preset supprimé",updated:"Preset mis à jour"}},connectedAs:"Connecté en tant que",logout:"Déconnexion",noLogoutPermission:"Pas d'autorisation de déconnexion",failedToLoad:"Échec chargement profils",retry:"Réessayer",time:{justNow:"À l'instant",minsAgo:"Il y a {{count}}m",hoursAgo:"Il y a {{count}}h",daysAgo:"Il y a {{count}}j"},toast:{loggedOut:"Déconnecté"},login:{title:"Connexion Bambu Cloud",subtitle:"Synchronisez vos presets slicer",email:"Email",password:"Mot de passe",region:"Région",regionGlobal:"Global",regionChina:"Chine",verificationCode:"Code de vérification",totpCode:"Code Authenticator",checkEmail:"Code envoyé à {{email}}",enterTotpHint:"Entrez le code 2FA",accessToken:"Jeton d'accès (Access Token)",accessTokenHint:"Collez le jeton (depuis Bambu Studio)",back:"Retour",loginButton:"Connexion",verifyButton:"Vérifier",setTokenButton:"Définir Jeton",useToken:"Utiliser jeton d'accès",useEmail:"Connexion par email",toast:{loggedIn:"Connecté avec succès",codeSent:"Code envoyé par email",enterTotp:"Entrez le code Authenticator",tokenSet:"Jeton défini"}},presets:{myPreset:"Mon preset (modifiable)",duplicate:"Dupliquer",editable:"Modifiable",failedToLoadDetails:"Échec détails preset",deleteConfirm:"Supprimer ce preset ?",deleteWarning:'Ceci supprimera "{{name}}" de Bambu Cloud définitivement.',noDuplicatePermission:"Pas d'autorisation duplication",noEditPermission:"Pas d'autorisation modification",noDeletePermission:"Pas d'autorisation suppression",types:{filament:"Preset filament",printer:"Preset imprimante",process:"Preset processus"},toast:{deleted:"Preset supprimé",created:"Preset créé",updated:"Preset mis à jour",duplicated:"Preset dupliqué",fieldAdded:'Champ "{{key}}" ajouté',exported:"Preset exporté"},baseLabel:"Base : {{name}}",currentLabel:"Actuel : {{name}}",newPreset:"Nouveau Preset",editPreset:"Modifier Preset",duplicatePreset:"Dupliquer Preset",createNewPreset:"Créer un nouveau Preset",customizeSettings:"Personnalisez vos réglages",compareWithBase:"Comparer avec la base",compare:"Comparer",basePreset:"Preset de base",selectBasePreset:"Choisir preset de base...",presetName:"Nom du preset",myCustomPreset:"Mon preset personnalisé",inheritsFrom:"Hérite de",dropJsonToImport:"Glissez JSON pour importer",tabs:{common:"Commun",allFields:"Tous les champs"},availableFields:"Champs disponibles",searchFieldsPlaceholder:"Chercher un champ...",noMatchingFields:"Aucun champ trouvé",allFieldsAdded:"Tous les champs sont ajoutés",addCustomField:"Ajouter un champ personnalisé",yourOverrides:"Vos modifications",noOverridesYet:"Aucune modification",clickFieldsToAdd:"Cliquez à gauche pour ajouter",saveAsTemplate:"Enregistrer comme modèle",jsonTip:"Conseil : Glissez un .json pour importer les réglages"},cloudView:{searchPlaceholder:"Chercher presets...",templates:"Modèles",refresh:"Rafraîchir",newPreset:"Nouveau Preset",clearFilters:"Effacer filtres",compareMode:"Mode Comparaison",selectAnotherPreset:"Choisir un autre preset {{type}}",clickTwoPresets:"Choisissez deux presets de même type",selectFirst:"1. Sélectionner premier",selectSecond:"2. Sélectionner second",compareNow:"Comparer maintenant",lastSynced:"Synchronisé :",showingCount:"{{showing}} sur {{total}} presets",noPresetsFound:"Aucun preset trouvé",columns:{filament:"Filament",process:"Processus",printer:"Imprimante"},noFilamentPresets:"Pas de preset filament",noProcessPresets:"Pas de preset processus",noPrinterPresets:"Pas de preset imprimante",filters:{type:"Type",owner:"Propriétaire",printer:"Imprimante",nozzle:"Buse",filament:"Filament",layer:"Couche",all:"Tous",myPresets:"Mes Presets",builtIn:"Inclus",process:"Processus"},noTemplatesPermission:"Pas d'autorisation modèles",noRefreshPermission:"Pas d'autorisation rafraîchissement",noCreatePermission:"Pas d'autorisation création"},templates:{title:"Modèles rapides",noTemplates:"Aucun modèle",createFirst:"Créez-en depuis l'éditeur de preset",typeFilter:"Type :",deleteTitle:"Supprimer modèle",deleteWarning:"Action irréversible",deleteConfirm:'Supprimer "{{name}}" ?',namePlaceholder:"Nom du modèle",descriptionPlaceholder:"Description",settingsJson:"Paramètres (JSON)",fieldsCount:"{{count}} champs",shownInModals:"Visible dans fenêtres",hiddenInModals:"Masqué dans fenêtres",apply:"Appliquer",toast:{deleted:"Modèle supprimé",updated:"Modèle mis à jour",created:"Modèle créé",applied:"Modèle appliqué"}}},support:{debugLoggingActive:"Débogage actif",manageLogs:"Gérer",collectItem7:"Connectivité et versions firmware",collectItem8:"Statut intégrations (Spoolman, MQTT, HA)",collectItem9:"Interfaces réseau (sous-réseaux)",collectItem10:"Versions packages Python",collectItem11:"Santé base de données",collectItem12:"Détails environnement Docker"},fileManager:{title:"Gestionnaire de fichiers",subtitle:"Organisez vos fichiers d'impression",uploadFiles:"Téléverser fichiers",newFolder:"Nouveau dossier",folderName:"Nom du dossier",folderNamePlaceholder:"ex: Pièces Utiles",renameFile:"Renommer fichier",renameFolder:"Renommer dossier",moveFiles:"Déplacer {{count}} fichier(s)",rootNoFolder:"Racine (aucun dossier)",current:"actuel",linkFolder:"Lier le dossier",linkFolderDescription:'Lier "{{name}}" à un projet ou archive.',project:"Projet",archive:"Archive",noProjectsFound:"Aucun projet trouvé",noArchivesFound:"Aucune archive trouvée",unlink:"Délier",link:"Lier",dragDropFiles:"Glissez les fichiers ici",dropFilesHere:"Déposez ici",orClickToBrowse:"ou cliquez pour parcourir",allFileTypesSupported:"Tous types supportés. ZIP extraits.",zipFilesDetected:"ZIP détectés",zipExtractOptions:"Choix de structure pour ZIP :",preserveZipStructure:"Garder structure ZIP",createFolderFromZip:"Dossier par nom du ZIP",stlThumbnailGeneration:"Vignettes STL",zipMayContainStl:"Extraction vignettes possible pour STL.",thumbnailsCanBeGenerated:"Génération vignettes (peut être long).",generateThumbnailsForStl:"Générer vignettes STL",threemfDetected:"Fichiers 3MF détectés",threemfExtractionInfo:"Réglages extraits auto du 3MF.",willBeExtracted:"Sera extrait",filesExtracted:"{{count}} fichiers extraits",uploadComplete:"Terminé : {{succeeded}} succès",uploadFailed:"{{count}} échecs",uploading:"Téléversement...",changeLink:"Modifier lien...",linkTo:"Lier à...",linkToProjectOrArchive:"Lier à projet ou archive",addToQueue:"Ajouter à la file",schedulePrint:"Planifier",generateThumbnail:"Générer vignette",generateThumbnails:"Générer vignettes",generateThumbnailsForMissing:"Vignettes STL manquantes",gridView:"Grille",listView:"Liste",lowDiskSpaceWarning:"Espace disque faible",lowDiskSpaceDetails:"{{free}} libre sur {{total}}. Seuil : {{threshold}} Go.",files:"Fichiers",folders:"Dossiers",size:"Taille",free:"Libre",allFiles:"Tous les fichiers",wrap:"Retour ligne",enableTextWrapping:"Activer retour ligne",disableTextWrapping:"Désactiver retour ligne",dragToResizeTooltip:"Glisser pour redimensionner, double-clic reset",searchFiles:"Chercher fichiers...",allTypes:"Tous types",prints:"Impressions",ascending:"Croissant",descending:"Décroissant",resultsCount:"{{showing}} sur {{total}} fichiers",selectAll:"Tout sélectionner",deselectAll:"Tout désélectionner",selected:"{{count}} sélectionnés",adding:"Ajout...",loadingFiles:"Chargement...",folderIsEmpty:"Dossier vide",noFilesYet:"Aucun fichier",folderEmptyDescription:"Téléversez ou déplacez des fichiers ici.",noFilesDescription:"Téléversez des fichiers pour organiser.",noMatchingFiles:"Aucun fichier correspondant",noMatchingFilesDescription:"Ajustez votre recherche.",clearFilters:"Effacer filtres",printedCount:"Imprimé {{count}}x",uploadedBy:"Téléversé par",deleteFolder:"Supprimer dossier",deleteFile:"Supprimer fichier",deleteFilesCount:"Supprimer {{count}} fichiers",deleteFolderConfirm:"Supprimer le dossier et son contenu ?",deleteFileConfirm:"Supprimer ce fichier ?",deleteFilesConfirm:"Supprimer {{count}} fichiers définitivement ?",deleting:"Suppression...",noPermissionRenameFolder:"Pas d'autorisation renommage",noPermissionLinkFolder:"Pas d'autorisation lien",noPermissionDeleteFolder:"Pas d'autorisation suppression dossier",noPermissionPrint:"Pas d'autorisation impression",noPermissionAddToQueue:"Pas d'autorisation file",noPermissionDownload:"Pas d'autorisation téléchargement",noPermissionRenameFile:"Pas d'autorisation renommage fichier",noPermissionGenerateThumbnail:"Pas d'autorisation vignettes",noPermissionDeleteFile:"Pas d'autorisation suppression fichier",noPermissionCreateFolder:"Pas d'autorisation nouveau dossier",noPermissionUpload:"Pas d'autorisation téléversement",noPermissionMoveFiles:"Pas d'autorisation déplacement",noPermissionDeleteFiles:"Pas d'autorisation suppression groupée",toast:{folderCreated:"Dossier créé",folderDeleted:"Dossier supprimé",fileDeleted:"Fichier supprimé",filesDeleted:"{{count}} fichiers supprimés",filesMoved:"Fichiers déplacés",folderLinked:"Dossier lié",folderUnlinked:"Dossier délié",addedToQueue:"{{count}} fichier(s) ajouté(s)",addedToQueuePartial:"{{added}} ajoutés, {{failed}} échecs",failedToAddToQueue:"Échec ajout file : {{error}}",fileRenamed:"Fichier renommé",folderRenamed:"Dossier renommé",thumbnailsGenerated:"{{count}} vignette(s) générée(s)",thumbnailsGeneratedPartial:"{{succeeded}} succès, {{failed}} échecs",noStlMissingThumbnails:"Aucun STL sans vignette",failedToGenerateThumbnails:"Échec vignettes : {{error}}",thumbnailGenerated:"Vignette générée",failedToGenerateThumbnail:"Échec vignette : {{error}}"}},projects:{title:"Projets",subtitle:"Suivez vos projets d'impression 3D",newProject:"Nouveau Projet",editProject:"Modifier Projet",deleteProject:"Supprimer Projet",projectName:"Nom du Projet",description:"Description",noProjects:"Aucun projet",noProjectsFiltered:"Aucun projet {{status}}",noProjectsFilteredHelp:"Les projets apparaîtront ici quand leur statut changera.",createFirst:"Créez votre premier projet pour organiser vos builds.",createFirstButton:"Créer votre premier projet",create:"Créer",files:"Fichiers",prints:"Impressions",plates:"plateaux",parts:"pièces",lastModified:"Modifié le",deleteConfirm:"Supprimer ce projet ? Les archives seront déliées mais conservées.",addFiles:"Ajouter fichiers",removeFile:"Retirer fichier",viewDetails:"Détails",namePlaceholder:"ex: Build Voron 2.4",descriptionPlaceholder:"Description optionnelle...",color:"Couleur",targetPlates:"Plateaux cibles",targetPlatesPlaceholder:"ex: 25",targetPlatesHelp:"Nombre total de jobs",targetParts:"Pièces cibles",targetPartsPlaceholder:"ex: 150",targetPartsHelp:"Nombre total d'objets",tagsLabel:"Tags (séparés par virgules)",tagsPlaceholder:"ex: voron, cadeau",dueDate:"Échéance",priority:"Priorité",priorityLow:"Basse",priorityNormal:"Normale",priorityHigh:"Haute",priorityUrgent:"Urgente",statusActive:"Actif",statusCompleted:"Terminé",statusArchived:"Archivé",done:"Fait",completed:"terminé",failed:"échoué",inQueue:"en file",noPrintsYet:"Aucune impression",printJobs:"Jobs (plateaux)",partsPrinted:"Pièces imprimées",failedParts:"Pièces échouées",import:"Importer",export:"Exporter",importProject:"Importer projet",exportAll:"Exporter tous les projets",loading:"Chargement des projets...",noEditPermission:"Pas d'autorisation de modification",noDeletePermission:"Pas d'autorisation de suppression",noCreatePermission:"Pas d'autorisation de création",noImportPermission:"Pas d'autorisation d'import",noExportPermission:"Pas d'autorisation d'export",toast:{created:"Projet créé",updated:"Projet mis à jour",deleted:"Projet supprimé",imported:"Projet importé",multipleImported:"{{count}} projets importés",importFailed:"Échec d'import",exported:"Projets exportés (métadonnées)"}},projectDetail:{notFound:"Projet non trouvé",backToProjects:"Retour aux Projets",export:"Exporter",exportProject:"Exporter projet",noExportPermission:"Pas d'autorisation export",noEditPermission:"Pas d'autorisation modification",partOf:"Fait partie de :",priorityLabel:"Priorité :",noPrints:"Aucune impression dans ce projet",status:{active:"Actif",completed:"Terminé",archived:"Archivé"},priority:{low:"Basse",normal:"Normale",high:"Haute",urgent:"Urgente"},dueDate:{overdue:"En retard",today:"Aujourd'hui",daysLeft:"{{count}} jours restants"},progress:{platesProgress:"Progression Plateaux",partsProgress:"Progression Pièces",printJobs:"jobs d'impression",parts:"pièces",percentComplete:"{{percent}}% terminé",remaining:"{{count}} restant(s)"},stats:{printJobs:"Jobs d'Impression",total:"total",failed:"{{count}} échecs",partsPrinted:"{{count}} pièces imprimées",printTime:"Temps d'Impression",filamentUsed:"Filament utilisé"},cost:{title:"Suivi des coûts",filamentCost:"Coût Filament",energy:"Énergie",budget:"Budget",remaining:"Restant"},subProjects:{title:"Sous-projets ({{count}})"},notes:{title:"Notes",noEditPermission:"Pas d'autorisation modification",placeholder:"Ajouter des notes...",empty:"Aucune note. Cliquez sur modifier."},files:{title:"Fichiers",linkFolders:"Liez des dossiers depuis le gestionnaire",forQuickAccess:"pour un accès rapide.",fileCount:"{{count}} fichier(s)",empty:"Aucun dossier lié."},bom:{title:"BOM (Liste matériel)",acquired:"{{completed}}/{{total}} acquis",showAll:"Tout afficher",hideDone:"Masquer acquis",addPart:"Ajouter matériel",noAddPermission:"Pas d'autorisation ajout",partNamePlaceholder:"Nom (ex: Vis M3x8)",partName:"Nom de pièce",qty:"Qté",price:"Prix ({{currency}})",sourcingUrlPlaceholder:"Lien d'achat (optionnel)",remarksPlaceholder:"Remarques (optionnel)",deletePart:"Supprimer pièce",deleteConfirm:'Supprimer "{{name}}" ?',noUpdatePermission:"Pas d'autorisation mise à jour",noEditPermission:"Pas d'autorisation modification",noDeletePermission:"Pas d'autorisation suppression",totalCost:"Coût total :",empty:"BOM vide. Ajoutez du matériel ou de l'électronique."},timeline:{title:"Historique d'activité",empty:"Aucune activité."},template:{saveAsTemplate:"Enregistrer comme modèle",noCreatePermission:"Pas d'autorisation modèle"},queue:{title:"File d'attente",viewAll:"Tout voir",printing:"{{count}} en cours",queued:"{{count}} en file"},prints:{title:"Impressions ({{count}})"},toast:{projectUpdated:"Projet mis à jour",partAdded:"Pièce ajoutée",partRemoved:"Pièce retirée",exportFailed:"Échec export",projectExported:"Projet exporté",templateCreated:"Modèle créé"}},system:{title:"Informations Système",version:"Version",uptime:"Temps de fonctionnement",cpuUsage:"Utilisation CPU",memoryUsage:"Utilisation RAM",diskUsage:"Utilisation Disque",networkInfo:"Infos Réseau",logs:"Journaux",debugMode:"Mode Débogage",enableDebug:"Activer débogage",disableDebug:"Désactiver débogage",downloadLogs:"Télécharger logs",clearLogs:"Effacer logs",dockerInfo:"Infos Docker",containerName:"Nom conteneur",imageName:"Nom image",platform:"Plateforme",architecture:"Architecture"},library:{title:"Bibliothèque Filament",addFilament:"Ajouter Filament",editFilament:"Modifier Filament",deleteFilament:"Supprimer Filament",vendor:"Vendeur",material:"Matériau",color:"Couleur",kFactor:"Facteur K",temperature:"Température",noFilaments:"Bibliothèque vide",deleteConfirm:"Supprimer ce filament ?",importFromPrinter:"Importer de l'imprimante",exportToFile:"Exporter vers fichier"},spoolman:{title:"Intégration Spoolman",enabled:"Spoolman Activé",url:"URL Spoolman",connected:"Connecté",disconnected:"Non Connecté",testConnection:"Tester connexion",sync:"Synchroniser",syncing:"Sync...",lastSync:"Dernière Sync",linkToSpoolman:"Lier à Spoolman",openInSpoolman:"Ouvrir Spoolman",unlinkSpool:"Délier bobine",selectSpool:"Choisir bobine",noUnlinkedSpools:"Pas de bobine libre",linkSuccess:"Lien réussi",linkFailed:"Échec lien",spoolId:"ID Bobine",fillSourceLabel:"(Spoolman)",weight:"Poids",remaining:"Restant",disableWeightSync:"Désactiver Sync poids estimé AMS",disableWeightSyncDesc:"Ne pas utiliser les estimations AMS. Utile si vous préférez le suivi Spoolman.",reportPartialUsage:"Rapporter consommation partielle pour échecs",reportPartialUsageDesc:"Si l'impression échoue, rapporte le filament consommé selon les couches."},inventory:{title:"Inventaire de Bobines",addSpool:"Ajouter Bobine",editSpool:"Modifier Bobine",material:"Matériau",selectMaterial:"Choisir matériau...",subtype:"Sous-type",brand:"Marque",searchBrand:"Chercher marque...",useCustomBrand:'Utiliser "{{brand}}"',useCustomMaterial:"Utiliser un matériau personnalisé : {{material}}",colorName:"Nom de couleur",colorNamePlaceholder:"Jade White, Fire Red...",color:"Couleur",hexColor:"Code Hex",pickColor:"Choisir couleur perso",labelWeight:"Poids net",coreWeight:"Poids bobine vide",searchSpoolWeight:"Chercher poids bobine...",weightUsed:"Consommé",currentWeight:"Poids restant",measuredWeight:"Poids mesuré",costPerKg:"Coût par kg",measuredWeightError:"Le poids mesuré doit être entre {{min}}g et {{max}}g.",slicerFilament:"Filament Slicer",slicerFilamentName:"Nom du Preset Slicer",slicerPreset:"Preset Slicer",searchPresets:"Chercher presets...",selectedPreset:"Sélectionné",noPresetsFound:"Aucun preset trouvé",tempOverrides:"Exceptions Température",note:"Note",notePlaceholder:"Notes additionnelles sur cette bobine...",archive:"Archiver",restore:"Restaurer",noSpools:"Aucune bobine. Ajoutez votre première bobine pour commencer.",noManualSpools:"Aucune bobine manuelle disponible. Ajoutez-en une d'abord.",kProfiles:"K-Profiles",addKProfile:"Ajouter K-Profile",assignSpool:"Assigner Bobine",unassignSpool:"Désassigner",assignSuccess:"Bobine assignée et slot AMS configuré",assignFailed:"Échec assignation",selectSpool:"Choisir une bobine pour ce slot",assigned:"Assigné",assigning:"Assignation...",searchSpools:"Chercher bobines...",allMaterials:"Tous Matériaux",filterByBrand:"Filtrer par marque...",showArchived:"Afficher archivées",quickAdd:"Ajout rapide (Stock)",quantity:"Quantité",stock:"Stock",configured:"Configuré",spoolsCreated:"{{count}} bobines créées",spoolCreated:"Bobine créée",spoolUpdated:"Bobine mise à jour",spoolDeleted:"Bobine supprimée",spoolArchived:"Bobine archivée",spoolRestored:"Bobine restaurée",deleteConfirm:"Supprimer définitivement cette bobine ?",archiveConfirm:"Voulez-vous vraiment archiver cette bobine ?",advancedSettings:"Paramètres Avancés",filamentInfoTab:"Infos Filament",paProfileTab:"Profil PA",filamentInfo:"Filament",additional:"Additionnel",loadingPresets:"Chargement des presets cloud...",cloudConnected:"Cloud connecté",cloudNotConnected:"Cloud déconnecté (valeurs par défaut)",recentColors:"Récentes",searchColors:"Chercher couleurs...",searchResults:"Résultats",allColors:"Toutes",commonColors:"Communes",showLess:"Moins",showAll:"Toutes",noColorsFound:"Aucune couleur correspondante",noResults:"Aucun résultat",selectMaterialFirst:"Veuillez choisir un matériau dans l'onglet Infos Filament.",noPrintersConfigured:"Ajoutez une imprimante pour utiliser les profils PA.",matchingFilter:"Correspondant",anyBrand:"Toute marque",anyVariant:"Toute variante",autoSelect:"Auto-sélection",matches:"correspondances",match:"correspondance",noMatches:"Aucune correspondance",connected:"Connecté",offline:"Hors ligne",printerOffline:"Imprimante hors ligne. Connectez-vous pour voir les profils.",noKProfilesMatch:"Aucun profil K ne correspond au filament.",leftNozzle:"Buse Gauche",rightNozzle:"Buse Droite",profilesSelected:"profil(s) de calibration sélectionné(s)",totalInventory:"Total Inventaire",totalConsumed:"Total Consommé",byMaterial:"Par Matériau",inPrinter:"Dans Imprimante",lowStock:"Stock Bas",sinceTracking:"Depuis le début du suivi",loadedInAms:"Chargé dans AMS/Ext",remaining:"Restant",lowStockThreshold:"<20% restant",weightCheck:"Vérification poids",lastWeighed:"Dernière pesée",neverWeighed:"Jamais pesé",search:"Chercher bobines...",showing:"Affichage",to:"à",of:"sur",show:"Voir",spools:"bobines",spool:"bobine",page:"Page",noSpoolsMatch:"Aucun résultat trouvé",noSpoolsMatchDesc:"Ajustez votre recherche ou vos filtres.",active:"Actif",archived:"Archivé",all:"Tous",used:"Occasion",new:"Neuf",clearFilters:"Effacer filtres",table:"Tableau",cards:"Cartes",net:"Net",columns:"Colonnes",configureColumns:"Configurer Colonnes",configureColumnsDesc:"Glissez pour ordonner ou utilisez les flèches. Cliquez sur l'œil pour masquer.",visible:"visible",reset:"Reset",cancel:"Annuler",applyChanges:"Appliquer",moveUp:"Monter",moveDown:"Descendre",hideColumn:"Masquer",showColumn:"Afficher",linkToSpool:"Lier à une Bobine",tagLinked:"Tag lié à la bobine",tagLinkFailed:"Échec lien tag",tagAlreadyLinked:"Tag déjà lié à une autre bobine",unknownTag:"Tag RFID inconnu détecté",usageHistory:"Historique de Consommation",noUsageHistory:"Aucune consommation enregistrée",printName:"Nom Impression",weightConsumed:"Poids consommé",clearHistory:"Effacer",historyCleared:"Historique effacé",fillSourceLabel:"(Inv)"},timelapse:{title:"Timelapse",create:"Créer Timelapse",download:"Télécharger",delete:"Supprimer",preview:"Aperçu",frameRate:"Images/sec",quality:"Qualité",processing:"Traitement...",noTimelapses:"Aucun timelapse"},ams:{title:"AMS",slot:"Slot",empty:"Vide",emptySlot:"Slot vide",unknown:"Inconnu",humidity:"Humidité",temperature:"Température",filamentType:"Type filament",filamentColor:"Couleur",remaining:"Restant",history:"Historique AMS",noHistory:"Aucun historique",configureSlot:"Configurer Slot",externalSpool:"Bobine externe",profile:"Profil",kFactor:"Facteur K",fill:"Remplir",configure:"Configurer",used:"utilisé",remainingUnit:"restant"},printModal:{title:"Lancer l'impression",selectPrinter:"Choisir l'imprimante",selectPlate:"Choisir le plateau",filamentMapping:"Mapping Filament",totalCost:"Coût total :",slotRemainingShort:" - {{grams}}g rest.",printSettings:"Réglages d'impression",bedLeveling:"Nivellement plateau",flowCalibration:"Calibration débit",vibrationCalibration:"Vibration (Input Shaper)",layerInspection:"Inspection 1ère couche",timelapse:"Timelapse",startPrint:"Démarrer",addToQueue:"Ajouter à la file",cancel:"Annuler",noPrintersAvailable:"Aucune imprimante disponible",printerBusy:"L'imprimante est occupée",printerOffline:"L'imprimante est hors ligne",sameTypeDifferentColor:"Même type, couleur différente",filamentTypeNotLoaded:"Type de filament non chargé",openCalendar:"Ouvrir calendrier",leftNozzle:"G",rightNozzle:"D",leftNozzleTooltip:"Buse gauche",rightNozzleTooltip:"Buse droite",filamentOverride:"Remplacement de filament",filamentOverrideHint:"Remplacez optionnellement les filaments pour l'affectation par modèle. Le planificateur utilisera vos filaments sélectionnés au lieu des valeurs 3MF d'origine.",originalFilament:"Original",overrideWith:"Remplacer par",resetToOriginal:"Revenir à l'original"},backup:{title:"Sauvegarde & Restauration",createBackup:"Créer Sauvegarde",restoreBackup:"Restaurer Sauvegarde",restoreDescription:"Remplace les données par un fichier de sauvegarde",downloadBackup:"Télécharger Sauvegarde",uploadBackup:"Téléverser Sauvegarde",lastBackup:"Dernière sauvegarde",autoBackup:"Sauvegarde auto",backupNow:"Sauvegarder maintenant",restoreWarning:"Attention : Écrase TOUTES les données actuelles.",includeArchives:"Inclure Archives",includeSettings:"Inclure Paramètres",includeProfiles:"Inclure Profils",backupSuccess:"Sauvegarde réussie",restoreSuccess:"Restauration réussie",backupFailed:"Échec sauvegarde",restoreFailed:"Échec restauration",restoreNote:"L'imprimante virtuelle sera arrêtée pendant la restauration"},tags:{title:"Tags",addTag:"Ajouter Tag",editTag:"Modifier Tag",deleteTag:"Supprimer Tag",tagName:"Nom du Tag",tagColor:"Couleur du Tag",noTags:"Aucun tag",deleteConfirm:"Supprimer ce tag ?",manageTags:"Gérer les Tags"},uploadModal:{title:"Téléverser des fichiers 3MF",dragDrop:"Glissez les fichiers .3mf ici",or:"ou",browseFiles:"Parcourir",extractionInfo:"Le modèle d'imprimante est extrait des métadonnées 3MF.",uploaded:"téléversé",failed:"échoué",uploading:"En cours...",upload:"Téléverser",uploadFailed:"Échec du téléversement"},editArchive:{title:"Modifier l'archive",name:"Nom",namePlaceholder:"Nom de l'impression",printer:"Imprimante",noPrinter:"Aucune imprimante",project:"Projet",noProject:"Aucun projet",itemsPrinted:"Nombre de pièces",itemsPrintedHelp:"Nombre d'objets produits",notes:"Notes",notesPlaceholder:"Notes sur l'impression...",externalLink:"Lien externe",externalLinkPlaceholder:"https://...",externalLinkHelp:"Lien vers Printables, Thingiverse, etc.",tags:"Tags",tagsPlaceholder:"Ajouter des tags...",addMoreTags:"Plus de tags...",matchingTags:'Correspondant à "{{query}}"',existingTags:"Tags existants",clickToAdd:"(cliquer pour ajouter)",status:"Statut",failureReason:"Raison de l'échec",selectReason:"Choisir raison...",photos:"Photos du résultat",photosHelp:"Cliquez sur + pour ajouter des photos",printResult:"Résultat d'impression",saving:"Enregistrement...",failureReasons:{adhesionFailure:"Défaut d'adhésion",spaghettiDetached:"Spaghetti / Détaché",layerShift:"Décalage de couche",cloggedNozzle:"Buse bouchée",filamentRunout:"Filament fini",warping:"Warping (Déformation)",stringing:"Stringing (Cheveux d'ange)",underExtrusion:"Sous-extrusion",powerFailure:"Coupure courant",userCancelled:"Annulé par l'utilisateur",other:"Autre"},statuses:{completed:"Réussie",failed:"Échouée",aborted:"Annulée",printing:"Impression"}},kProfiles:{title:"K-Profiles",noPrintersConfigured:"Aucune imprimante configurée",addPrinterInSettings:"Ajoutez une imprimante pour gérer les K-profiles",noActivePrinters:"Aucune imprimante active",enablePrinterConnection:"Activez la connexion pour voir les K-profiles",loadingProfiles:"Chargement des K-Profiles...",printerOffline:"Imprimante hors ligne",printerOfflineDesc:"L'imprimante doit être allumée.",noMatchingProfiles:"Aucun profil correspondant",noMatchingProfilesDesc:"Ajustez votre recherche",noKProfiles:"Aucun K-Profile",noKProfilesDesc:"Aucun profil trouvé pour une buse de {{diameter}}mm",createFirstProfile:"Créer le premier profil",printer:"Imprimante",nozzle:"Buse",refresh:"Rafraîchir",addProfile:"Ajouter Profil",export:"Exporter",import:"Importer",select:"Choisir",selectAll:"Tout sélectionner",delete:"Supprimer",searchPlaceholder:"Nom ou filament...",allExtruders:"Tous les extrudeurs",leftOnly:"Gauche uniquement",rightOnly:"Droite uniquement",allFlow:"Tout débit",hfOnly:"HF uniquement",sOnly:"S uniquement",sortName:"Tri : Nom",sortKValue:"Tri : Valeur K",sortFilament:"Tri : Filament",leftExtruder:"Extrudeur gauche",rightExtruder:"Extrudeur droit",modal:{addTitle:"Ajouter K-Profile",editTitle:"Modifier K-Profile",profileName:"Nom du profil",profileNamePlaceholder:"ex: Mon profil PLA",kValue:"Valeur K",kValuePlaceholder:"0.020",kValueHelp:"Plage type : 0.01-0.06 (PLA), 0.02-0.10 (PETG)",filament:"Filament",selectFilament:"Choisir filament...",noFilamentsHelp:"Créez d'abord un profil dans Bambu Studio.",flowType:"Type de débit",highFlow:"Haut Débit (HF)",standard:"Standard",nozzleSize:"Taille buse",extruder:"Extrudeur",extruders:"Extrudeurs",left:"Gauche",right:"Droite",notes:"Notes (locales)",notesPlaceholder:"Notes sur ce profil...",notesHelp:"Enregistré dans Bambuddy, pas sur l'imprimante",syncing:"Sync avec l'imprimante...",savingExtruder:"Sauvegarde extrudeur {{current}}/{{total}}...",pleaseWait:"Patientez..."},deleteConfirm:{title:"Supprimer profil",cannotUndo:"Action irréversible",message:`Supprimer "{{name}}" de l'imprimante ?`},bulkDelete:{title:"Supprimer les profils",cannotUndo:"Action irréversible",message:"Supprimer les {{count}} profils de l'imprimante ?"},toast:{profileSaved:"Profil K enregistré",profilesSaved:"Profil K enregistré sur {{count}} extrudeur(s)",selectAtLeastOneExtruder:"Sélectionnez un extrudeur",profileDeleted:"Profil K supprimé",profilesDeleted:"{{count}} profils supprimés",exportedProfiles:"{{count}} profils exportés",importedProfiles:"{{count}} sur {{total}} profils importés",noProfilesToExport:"Rien à exporter",invalidFileFormat:"Format invalide",failedToParseImport:"Échec analyse fichier",failedToSaveBatch:"Échec enregistrement groupé",noteSaved:"Note enregistrée",failedToSaveNote:"Échec note"},permission:{noRead:"Pas d'autorisation lecture",noCreate:"Pas d'autorisation création",noUpdate:"Pas d'autorisation mise à jour",noDelete:"Pas d'autorisation suppression",noExport:"Pas d'autorisation export",noImport:"Pas d'autorisation import"}},virtualPrinter:{title:"Imprimante Virtuelle",running:"En cours",stopped:"Arrêtée",description:{default:"Active une imprimante qui apparaît dans Bambu Studio. Les fichiers envoyés sont archivés sans impression.",proxy:"Active un proxy qui relaie le trafic vers une imprimante réelle, permettant l'impression à distance."},enable:{title:"Activer l'imprimante virtuelle",visibleInSlicer:'Visible comme "Bambuddy" dans le Slicer',proxyingTo:"Proxy vers {{name}}",notActive:"Inactive"},model:{title:"Modèle d'imprimante",description:"Choisissez le modèle à émuler.",restartWarning:"Changer le modèle redémarrera le service"},accessCode:{title:"Code d'accès",isSet:"Code défini",notSet:"Code requis pour activer",placeholder:"Code 8 char",placeholderChange:"Entrez nouveau code",hint:"Exactement 8 caractères. Sert à l'auth du Slicer.",charCount:"({{count}}/8)"},targetPrinter:{title:"Imprimante cible",configured:"Cible configurée",notConfigured:"Imprimante requise pour mode Proxy",placeholder:"Choisir imprimante...",hint:"L'imprimante doit être en mode LAN.",noPrinters:"Ajoutez une imprimante réelle d'abord."},remoteInterface:{title:"Exception Interface Réseau",configured:"Override actif",optional:"Optionnel - si IP auto est fausse (VPN, Docker, multi-NIC).",placeholder:"Auto (défaut)...",hint:"Force l'IP annoncée via SSDP."},bindIp:{title:"Interface réseau",placeholder:"Sélectionner interface...",hint:"Interface réseau sur laquelle cette imprimante virtuelle écoute. Doit être unique par imprimante."},proxy:{accessCodeHint:"En mode proxy, utilisez le code d'accès de l'imprimante cible dans le slicer. La connexion est transmise de manière transparente à l'imprimante réelle."},mode:{title:"Mode",archive:"Archiver",archiveDesc:"Archive immédiatement",review:"Revue",reviewDesc:"Attendre revue avant archive",queue:"File",queueDesc:"Archiver et ajouter à la file",proxy:"Proxy",proxyDesc:"Relais vers imprimante réelle"},setupRequired:{title:"Configuration requise",description:"Nécessite des réglages système (ports, pare-feu).",readGuide:"Lire le guide de configuration"},howItWorks:{title:"Fonctionnement",step1:"Sur le même LAN, les imprimantes virtuelles apparaissent automatiquement dans votre slicer (Bambu Studio / OrcaSlicer). Depuis d'autres réseaux, ajoutez-les manuellement par adresse IP et code d'accès.",step2:`En mode Archive, Revue et File d'attente, utilisez le bouton "Envoyer" dans votre slicer pour envoyer des fichiers 3MF à Bambuddy. Le slicer affichera "Impression réussie" — le fichier est stocké, pas imprimé.`,step3:"En mode Proxy, l'imprimante virtuelle relaie tout le trafic vers une vraie imprimante — les impressions démarrent immédiatement comme en connexion directe."},status:{title:"Détails du statut",printerName:"Nom",model:"Modèle",serialNumber:"Série",mode:"Mode",pendingFiles:"Fichiers en attente",targetPrinter:"Cible",ftpPort:"Port FTP",mqttPort:"Port MQTT",ftpConnections:"Connexions FTP",mqttConnections:"Connexions MQTT"},toast:{updated:"Réglages virtuels mis à jour",failedToUpdate:"Échec mise à jour",accessCodeRequired:"Code d'accès requis",targetPrinterRequired:"Imprimante cible requise",accessCodeEmpty:"Le code ne peut pas être vide",accessCodeLength:"Le code doit faire 8 caractères"}},modelViewer:{openInSlicer:"Ouvrir dans le Slicer",tabs:{model:"Modèle 3D",gcode:"Aperçu G-code"},notAvailable:"indisponible",notSliced:"pas découpé",plates:"Plateaux",allPlates:"Tous les plateaux",plateNumber:"Plateau {{number}}",plateCount:"{{count}} plateau",plateCount_other:"{{count}} plateaux",objectCount:"{{count}} objet",objectCount_other:"{{count}} objets",filamentCount:"{{count}} filament",filamentCount_other:"{{count}} filaments",eta:"Fin {{minutes}} min",noPreview:"Aucun aperçu pour ce fichier",pagination:{pageOf:"Page {{current}} sur {{total}}",prev:"Préc",next:"Suiv"},errors:{failedToLoad:"Échec chargement fichier",noMeshes:"Aucun maillage trouvé dans le 3MF",unsupportedFormat:"Format non supporté"}},maintenanceDescriptions:{lubricateCarbonRods:"Appliquer du lubrifiant sur les tiges carbone pour un mouvement fluide",lubricateRails:"Appliquer du lubrifiant sur les rails linéaires",cleanNozzle:"Nettoyer buse et hotend anti-bouchage",checkBelts:"Tension des courroies pour la précision",cleanBuildPlate:"Nettoyage plateau pour l'adhésion",checkExtruder:"Usure des engrenages de l'extrudeur",checkCooling:"Bon fonctionnement des ventilateurs",generalInspection:"Inspection générale de la machine",cleanCarbonRods:"Nettoyer les tiges carbone (friction)",cleanLinearRails:"Essuyer les rails linéaires (poussière/débris)",checkPtfeTube:"Usure ou dommage du tube PTFE",replaceHepaFilter:"Filtre HEPA pour la qualité de l'air",replaceCarbonFilter:"Filtre charbon actif (odeurs)",lubricateLeftNozzleRail:"Lubrifier le rail de buse gauche (Série H2)"},smartPlugs:{offline:"Hors ligne",admin:"Admin",openPlugAdminPage:"Page admin de la prise",deleteSmartPlug:"Supprimer la prise",turnOnSmartPlug:"Allumer la prise",turnOffSmartPlug:"Éteindre la prise",turnOn:"Allumer",turnOff:"Éteindre",addSmartPlug:{scanningNetwork:"Scan réseau...",chooseEntity:"Choisir une entité...",connectionFailed:"Échec connexion",searchEntities:"Chercher entités...",searchPowerSensors:"Capteurs puissance...",searchEnergySensors:"Capteurs énergie...",placeholders:{plugName:"Prise Salon",mqttStateOnValue:"ON, true, 1",mqttSameAsPower:"Identique au topic puissance, ou différent"}}},richTextEditor:{bold:"Gras",italic:"Italique",underline:"Souligné",bulletList:"Liste à puces",numberedList:"Liste numérotée",alignLeft:"Aligner à gauche",alignCenter:"Centrer",alignRight:"Aligner à droite",addLink:"Ajouter lien",removeLink:"Retirer lien"},externalLinks:{noLinksConfigured:"Aucun lien externe configuré",deleteLink:"Supprimer lien",removeCustomIcon:"Retirer icône personnalisée",openInNewTab:"Ouvrir dans un nouvel onglet",placeholders:{linkName:"Mon Lien"}},keyboardShortcuts:{title:"Raccourcis Clavier",navigation:"Navigation",archivesSection:"Archives",kProfilesSection:"K-Profiles",generalSection:"Général",shortcuts:{goToPrinters:"Aller aux Imprimantes",goToArchives:"Aller aux Archives",goToQueue:"Aller à la File",goToStats:"Aller aux Stats",goToProfiles:"Aller aux Profils Cloud",goToSettings:"Aller aux Paramètres",focusSearch:"Focus recherche",openUploadModal:"Ouvrir téléversement",clearSelection:"Tout déselectionner",contextMenu:"Menu contextuel (cartes)",refreshProfiles:"Rafraîchir profils",newProfile:"Nouveau profil",exitSelectionMode:"Quitter mode sélection",showHelp:"Afficher cette aide"},footer:"Échap ou clic extérieur pour fermer"},notificationLog:{title:"Journal de Notification",events:{printStarted:"Début impression",printComplete:"Fin impression",printFailed:"Échec impression",printStopped:"Arrêt impression",progress:"Progression",printerOffline:"Hors ligne",printerError:"Erreur",lowFilament:"Filament bas",maintenanceDue:"Maintenance",test:"Test"},timeAgo:{justNow:"À l'instant",minutesAgo:"Il y a {{minutes}}m",hoursAgo:"Il y a {{hours}}h"}},restoreBackup:{title:"Restaurer Sauvegarde",restoring:"Restauration...",restoreComplete:"Restauration terminée",restoreFailed:"Échec restauration",importSettings:"Importer les réglages d'un fichier",pleaseWait:"Patientez pendant la restauration",clickToSelect:"Fichier .json ou .zip",howDuplicateHandling:"Gestion des doublons :",categories:{printers:"Imprimantes",smartPlugs:"Prises",notificationProviders:"Fournisseurs",filaments:"Filaments",archives:"Archives",pendingUploads:"Téléversements en attente",settingsTemplates:"Réglages & Modèles"},matchingInfo:{printers:"par numéro de série",smartPlugs:"par adresse IP",notificationProviders:"par nom",filaments:"par nom+type+marque",archives:"par empreinte numérique (hash)",pendingUploads:"par nom de fichier",settingsTemplates:"toujours écrasés"},replaceExisting:"Remplacer existant",keepExisting:"Garder existant",replaceDescription:"Écrase les doublons avec la sauvegarde",keepDescription:"Ne restaure que les éléments absents",caution:"Attention :",cautionText:"L'écrasement remplacera vos réglages. Les codes d'accès imprimantes sont exclus par sécurité.",itemsRestored:"Éléments restaurés",itemsSkipped:"Éléments ignorés",restored:"Restaurés",skipped:"Ignorés (déjà présents)",filesLabel:"Fichiers (3MF, vignettes, etc.)",newApiKeysGenerated:"Nouvelles clés API générées",newApiKeysWarning:"Copiées maintenant, elles ne seront plus visibles !",processingBackup:"Traitement du fichier...",noDataFound:"Aucune donnée trouvée dans le fichier.",failedToRestore:"Échec restaure. Vérifiez le format."},backupExport:{title:"Exporter Sauvegarde",selectData:"Données à inclure",selectAll:"Tout sélectionner",selectNone:"Ne rien sélectionner",categoryDescriptions:{settings:"Langue, thèmes, préférences",notifications:"ntfy, Pushover, Discord, etc.",templates:"Modèles de messages personnalisés",smartPlugs:"Configuration des prises Tasmota",externalLinks:"Liens externes de la barre latérale",printers:"Infos imprimantes (codes d'accès exclus par défaut)",plateDetection:"Images références des plateaux vides",filaments:"Types et coûts filaments",maintenance:"Plannings de maintenance personnalisés",archives:"Données impressions + fichiers (3MF, vignettes, etc.)",projects:"Projets, BOM, pièces jointes",pendingUploads:"En attente revue virtuelle",apiKeys:"Clés Webhook (nouvelles clés générées à l'import)"},requiresPrinters:"Nécessite sélection des imprimantes",zipFileWarning:"Fichier ZIP créé.",zipFileDescription:"Contient tous les médias. Peut être volumineux.",includeAccessCodes:"Inclure Codes d'accès",includeAccessCodesDescription:"Pour migrer vers une autre machine",includeAccessCodesWarning:"Codes en texte clair. Sécurisez ce fichier !",categoriesSelected:"{{selectedCount}} catégories choisies"},pendingUploads:{placeholders:{notes:"Notes sur l'impression..."},discardUpload:"Rejeter",archiveAllUploads:"Tout archiver",discardAllUploads:"Tout rejeter",archive:"Archiver",timeAgo:{justNow:"À l'instant",minutesAgo:"Il y a {{minutes}}m",hoursAgo:"Il y a {{hours}}h",daysAgo:"Il y a {{days}}j"}},apiBrowser:{placeholders:{requestBody:"Corps JSON...",searchEndpoints:"Chercher endpoints..."}},configureAmsSlot:{title:"Configurer le slot AMS",slotConfigured:"Slot configuré !",configuringSlot:"Configuration du slot :",slotLabel:"{{ams}} Slot {{slot}}",searchPresets:"Chercher presets...",colorPlaceholder:"Nom couleur ou hex (ex: brown, FF8800)",clearCustomColor:"Effacer couleur perso",noCloudPresets:"Profils Cloud absents. Connectez-vous.",noPresetsAvailable:"Aucun preset disponible. Connectez-vous à Bambu Cloud ou importez des profils locaux.",noMatchingPresets:"Aucun profil trouvé.",custom:"Perso",builtin:"Inclus",settingsSentToPrinter:"Réglages envoyés",filamentProfile:"Profil Filament",kProfileLabel:"Profil K (Pressure Advance)",filteringFor:"Filtrage pour : {{material}}",noKProfile:"Pas de profil K (utiliser défaut 0.020)",noMatchingKProfiles:"Aucun profil K trouvé. K=0.020 par défaut sera utilisé.",selectFilamentFirst:"Sélectionnez d'abord un profil filament",kFromCalibration:"K={{value}} de la calibration imprimante",customColorLabel:"Couleur personnalisée (optionnel)",presetColors:"Couleurs {{name}} :",showLessColors:"Moins de couleurs",showMoreColors:"Plus de couleurs",clear:"Effacer",hexLabel:"Hex : #{{hex}}",resetting:"Réinitialisation...",resetSlot:"Réinitialiser le slot",cancel:"Annuler",configuring:"Configuration...",configureSlot:"Configurer le slot"},githubBackup:{title:"Sauvegarde GitHub",history:"Historique",downloadBackup:"Télécharger",restoreBackup:"Restaurer",noBackupsYet:"Aucune sauvegarde"},emailSettings:{placeholders:{fromName:"BamBuddy"}},tagManagement:{searchTags:"Chercher tags...",renameTag:"Renommer tag",deleteTag:"Supprimer tag"},notificationTemplates:{placeholders:{title:"Titre notification...",body:"Message notification..."}},batchTag:{placeholders:{newTag:"Nouveau tag..."}},photoGallery:{deletePhoto:"Supprimer photo"},filamentHoverCard:{copySpoolUuid:"Copier UUID bobine"},kProfilesView:{hasNote:"A une note",copyProfile:"Copier profil"},layout:{openMenu:"Ouvrir menu",noPermissionSystemInfo:"Pas d'autorisation système"},dashboard:{dragToReorder:"Glisser pour réorganiser",hideWidget:"Masquer widget"},notificationProviderCard:{deleteNotificationProvider:"Supprimer fournisseur"},fileManagerModal:{closeFileManager:"Fermer gestionnaire",sortFiles:"Trier fichiers",goToParentFolder:"Dossier parent",threeView:"Vue 3D"},embeddedCameraViewer:{refreshStream:"Actualiser flux",close:"Fermer",zoomOut:"Zoom -",resetZoom:"Reset zoom",zoomIn:"Zoom +",dragToResize:"Glisser pour dimension"},timelapseViewer:{skipBack5s:"-5s",skipForward5s:"+5s"},notificationProviders:{descriptions:{email:"Notifications par email SMTP",telegram:"Via bot Telegram",discord:"Via webhook Discord",ntfy:"Push auto-hébergé (ntfy)",pushover:"Push fiable (Pushover)",callmebot:"WhatsApp gratuit via CallMeBot",webhook:"Requête HTTP POST personnalisée"}},logViewer:{searchPlaceholder:"Message ou nom...",noLogEntries:"Aucune entrée journal"},switchbarPopover:{noSwitchesInSwitchbar:"Aucun interrupteur"},projectPageModal:{placeholders:{title:"Titre",designer:"Designer",license:"Licence",description:"Description...",profileTitle:"Titre du profil",profileDescription:"Description du profil..."}},spoolmanSettings:{},time:{unknown:"-",waiting:"En attente",justNow:"À l'instant",now:"Maintenant",minsAgo:"il y a {{count}}m",inMins:"dans {{count}}m",hoursAgo:"il y a {{count}}h",inHours:"dans {{count}}h",daysAgo:"il y a {{count}}j",inDays:"dans {{count}}j"},spoolbuddy:{nav:{dashboard:"Tableau de bord",ams:"AMS",inventory:"Inventaire",writeTag:"Écrire",settings:"Paramètres"},status:{nfcReady:"NFC prêt",nfcOff:"NFC désactivé",offline:"Hors ligne",online:"En ligne",noPrinters:"Aucune imprimante",deviceOffline:"Appareil hors ligne",waitingConnection:"En attente de connexion...",systemReady:"Système prêt",status:"Statut"},dashboard:{readyToScan:"Prêt à scanner",idleMessage:"Placez une bobine sur la balance pour l'identifier",nfcHint:"Le tag NFC sera lu automatiquement",device:"Appareil",syncWeight:"Sync. poids",weightSynced:"Synchronisé !",unknownTag:"Tag inconnu",newTag:"Nouveau tag détecté",onScale:"sur la balance",linkSpool:"Lier à une bobine",linkTagTitle:"Lier le tag à une bobine",linkTag:"Lier le tag",selectSpool:"Sélectionnez une bobine à lier à ce tag :",noUntagged:"Aucune bobine sans tag trouvée",tagDetected:"Tag détecté",noTag:"Pas de tag",tagId:"Tag",grossWeight:"Poids brut",spoolSize:"Taille bobine",close:"Fermer"},weight:{noReading:"Pas de lecture",stable:"Stable",measuring:"Mesure...",tare:"Tarer",calibrate:"Calibrer"},spool:{remaining:"Restant",material:"Matériau",brand:"Marque",color:"Couleur",coreWeight:"Noyau",labelWeight:"Étiquette",scaleWeight:"Balance",netWeight:"Net",lastUsed:"Dernière utilisation"},ams:{noData:"Aucun AMS détecté",connectAms:"Connectez un AMS pour voir les slots",noPrinter:"Aucune imprimante sélectionnée",selectPrinter:"Sélectionnez une imprimante dans la barre supérieure",printerDisconnected:"Imprimante déconnectée",humidity:"Humidité",level:"Niveau",active:"Actif",slot:"Slot",empty:"Vide"},inventory:{search:"Rechercher des bobines...",empty:"Aucune bobine dans l'inventaire",noResults:"Aucune bobine correspondante",spools:"bobines",addSpool:"Ajouter une bobine"},settings:{tabDevice:"Appareil",tabDisplay:"Affichage",tabScale:"Balance",tabUpdates:"Mises à jour",nfcReader:"Lecteur NFC",type:"Type",connection:"Connexion",notConnected:"N/A",deviceInfo:"Info appareil",hostname:"Hôte",uptime:"Temps de fonctionnement",brightness:"Luminosité",saved:"Enregistré",noBacklight:"Aucun rétroéclairage DSI détecté. Le contrôle de luminosité nécessite un écran DSI.",screenBlank:"Délai d'extinction",screenBlankDesc:"L'écran s'éteint après inactivité. Touchez pour réveiller.",displayNote:"La luminosité est appliquée comme filtre logiciel.",scaleCalibration:"Calibration de la balance",currentWeight:"Poids actuel",tareOffset:"Tare",calFactor:"Facteur",knownWeight:"Poids connu",calStep1:"Retirez tout de la balance et appuyez sur Mettre à zéro.",calStep2:"Placez le poids connu sur la balance.",setZero:"Mettre à zéro",calibrateNow:"Calibrer",calibrated:"Calibré",tareSet:"Commande de tare envoyée. En attente de l'appareil...",tareFailed:"Échec de l'envoi de la commande de tare",zeroSet:"Point zéro défini. Placez le poids connu sur la balance.",calibrationDone:"Calibration terminée !",calibrationFailed:"Échec de la calibration",lastCalibrated:"Dernière calibration",stable:"Stable",settling:"Stabilisation...",firmware:"Firmware",scale:"Balance",noDevice:"Aucun appareil SpoolBuddy trouvé",daemonVersion:"Version du daemon",currentVersion:"Actuelle",versionPending:"En attente du daemon...",checking:"Vérification...",checkUpdates:"Vérifier les mises à jour",updateAvailable:"Mise à jour disponible",updateInstructions:"Mise à jour via SSH : exécutez le script d'installation SpoolBuddy.",upToDate:"À jour",includeBeta:"Inclure les versions bêta"},writeTag:{tabExisting:"Bobine existante",tabNew:"Nouvelle bobine",tabReplace:"Remplacer le tag",searchPlaceholder:"Rechercher par matériau, couleur, marque...",noUntaggedSpools:"Aucune bobine sans tag",noTaggedSpools:"Aucune bobine avec tag",selectSpool:"Sélectionnez une bobine, puis placez un NTAG sur le lecteur",placeTag:"Placez un NTAG sur le lecteur",tagReady:"Tag détecté — prêt à écrire",writeTag:"Écrire le tag",replaceTag:"Remplacer le tag",writing:"Écriture du tag...",waiting:"En attente de SpoolBuddy...",writeSuccess:"Tag écrit avec succès !",writeFailed:"Échec de l'écriture",queueFailed:"Impossible de mettre en file la commande d'écriture",tryAgain:"Réessayer",cancel:"Annuler",replaceWarning:"L'ancien tag sera dissocié. Le nouveau tag le remplacera.",deviceOffline:"SpoolBuddy est hors ligne",material:"Matériau",colorName:"Nom de la couleur",color:"Couleur",brand:"Marque",weight:"Poids (g)",createSpool:"Créer la bobine",creating:"Création...",spoolCreated:"Bobine créée ! Prêt à écrire.",createFailed:"Impossible de créer la bobine"}}},zce={nav:{printers:"プリンター",archives:"アーカイブ",queue:"キュー",stats:"統計",profiles:"プロファイル",maintenance:"メンテナンス",projects:"プロジェクト",inventory:"フィラメント",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:"今日",tomorrow:"明日",asap:"即時",now:"今すぐ",collapse:"折りたたむ",expand:"展開",viewArchive:"アーカイブを表示",viewInFileManager:"ファイルマネージャーで表示",addedBy:"{{username}}が追加",more:"もっと見る",printer:"プリンター",type:"種類",print:"印刷",rename:"名前変更",move:"移動",create:"作成",days:"日",enable:"有効化",linkNotFound:"リンクが見つかりません",reset:"リセット",export:"エクスポート",import:"インポート",selectAll:"すべて選択",deselectAll:"すべて選択解除",unchanged:"変更なし",overdue:"期限超過",prints:"プリント",ascending:"昇順",descending:"降順",remove:"削除",duplicate:"複製",left:"左",right:"右",done:"完了",saveChanges:"変更を保存",turnOn:"オンにする",turnOff:"オフにする",deletePhoto:"写真を削除",deletePhotoConfirm:"この写真を削除しますか?元に戻せません。",project:"プロジェクト",archive:"アーカイブ",show:"表示",hide:"非表示",back:"戻る",retry:"リトライ",model:"モデル",ok:"OK"},printers:{title:"プリンター",addPrinter:"プリンターを追加",editPrinter:"プリンターを編集",deletePrinter:"プリンターを削除",printerName:"プリンター名",serialNumber:"シリアル番号",ipAddress:"IPアドレス / ホスト名",accessCode:"アクセスコード",model:"モデル",nozzleCount:"ノズル数",autoArchive:"自動アーカイブ",status:{available:"利用可能",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:"オフラインを非表示",nextAvailable:"次に完了",powerOn:"電源オン",noPrintersConfigured:"プリンターが設定されていません",readyToPrint:"印刷可能",external:"外部",extL:"Ext-L",extR:"Ext-R",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:"スマートプラグを制御する権限がありません",noCamera:"カメラを表示する権限がありません"},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:"現在の印刷からスキップするオブジェクトを選択してください",confirmTitle:"オブジェクトをスキップしますか?",confirmMessage:"「{{name}}」をスキップしますか?この操作は元に戻せません。"},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エラーを表示",developerModeWarning:"開発者LANモードが有効になっていません: {{names}}。一部の機能が動作しない可能性があります。",howToEnable:"有効化方法"},archives:{title:"印刷アーカイブ",searchPlaceholder:"アーカイブを検索...",filterByPrinter:"プリンターで絞り込み",filterByStatus:"ステータスで絞り込み",sortBy:"並べ替え",sortNewest:"新しい順",sortOldest:"古い順",sortName:"名前順",sortDuration:"時間順",noArchives:"アーカイブが見つかりません",noArchivesYet:"アーカイブはまだありません",releaseToUpload:"ドロップしてアップロード",showAll:"すべて表示",showFavoritesOnly:"お気に入りのみ表示",gridView:"グリッド表示",listView:"リスト表示",calendarView:"カレンダー表示",logView:"印刷ログ",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:"タイムラプスの添付に失敗しました",timelapseRemoved:"タイムラプスを削除しました",failedRemoveTimelapse:"タイムラプスの削除に失敗しました",timelapseUploaded:"タイムラプスをアップロードしました: {{filename}}",failedUploadTimelapse:"タイムラプスのアップロードに失敗しました",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:"タイムラプスをスキャン",uploadTimelapse:"タイムラプスをアップロード",removeTimelapse:"タイムラプスを削除",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:"再印刷する権限がありません",noFileForReprint:"3MFファイルがありません — 印刷記録時にプリンターからファイルをダウンロードできませんでした",noPermissionDelete:"アーカイブを削除する権限がありません",openInBambuStudio:"スライサーで開く",openInBambuStudioToSlice:"スライサーでスライス",makerWorld:"MakerWorld: {{designer}}",viewProject:"プロジェクトを表示",noExternalLink:"外部リンクなし",edit:"編集",delete:"削除"},modal:{deleteArchive:"アーカイブを削除",deleteConfirm:"このアーカイブを削除しますか?",removeSource3mf:"ソース3MFを削除",removeSource3mfConfirm:'"{{name}}"からソース3MFファイルを削除してもよろしいですか?元のスライサープロジェクトファイルが削除されます。',removeF3d:"F3Dを削除",removeF3dConfirm:'"{{name}}"からFusion 360デザインファイルを削除してもよろしいですか?',removeTimelapse:"タイムラプスを削除",removeTimelapseConfirm:'"{{name}}"からタイムラプス動画を削除してもよろしいですか?',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:"操作"},log:{date:"日時",printName:"印刷名",printer:"プリンター",user:"ユーザー",status:"ステータス",duration:"所要時間",filament:"フィラメント",allPrinters:"全プリンター",allUsers:"全ユーザー",allStatuses:"全ステータス",cancelled:"キャンセル",skipped:"スキップ",dateFrom:"開始日",dateTo:"終了日",noEntries:"印刷ログが見つかりません",showing:"{{total}}件中{{count}}件を表示",rowsPerPage:"行数",page:"ページ",prev:"前へ",next:"次へ",clearLog:"ログをクリア",clearLogTitle:"印刷ログをクリア",clearLogConfirm:"すべての印刷ログエントリが完全に削除されます。アーカイブとキューアイテムには影響しません。この操作は元に戻せません。よろしいですか?",clearLogButton:"すべてクリア",cleared:"{{count}}件のログエントリを削除しました",clearFailed:"印刷ログの削除に失敗しました"},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:"プレートをクリアしました — 次の印刷の準備完了",plateNumber:"プレート {{index}}",sections:{currentlyPrinting:"印刷中",queued:"キュー中",history:"履歴"},status:{pending:"待機中",waiting:"待機中",printing:"印刷中",paused:"一時停止",completed:"完了",failed:"失敗",skipped:"スキップ",cancelled:"キャンセル済み"},summary:{printing:"印刷中",queued:"キュー中",history:"履歴",totalTime:"キュー合計時間",totalWeight:"キュー合計重量"},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:"キューアイテムをキャンセルする権限がありません"}},backgroundDispatch:{unknownFile:"不明なファイル",unknownPrinter:"不明なプリンター",startingPrints:"印刷開始中",progressSummary:"{{complete}}/{{total}} 完了 • 配信済み: {{dispatched}} • 処理中: {{processing}}",expandDetails:"配信詳細を展開",collapseDetails:"配信詳細を折りたたむ",dismissToast:"配信トーストを閉じる",cancelDispatchJob:"配信ジョブをキャンセル",cancel:"キャンセル",cancelling:"キャンセル中…",status:{dispatched:"配信済み",processing:"処理中",completed:"完了",failed:"失敗",cancelled:"キャンセル済み"},toast:{cancellingUpload:"アップロードをキャンセル中...",cancelled:"配信をキャンセルしました",cancelFailed:"配信のキャンセルに失敗しました",completeWithFailures:"バックグラウンド配信完了: {{completed}} 件成功、{{failed}} 件失敗",completeSuccess:"バックグラウンド配信完了: {{completed}} 件成功"}},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:"統計を読み込み中...",noPrintDataInRange:"選択した期間にデータがありません",periodFilament:"フィラメント使用量",periodCost:"コスト",avgPerPrint:"1印刷あたりの平均",usageOverTime:"時間推移",filamentByWeight:"重量",printDuration:"印刷時間分布",printerUtilization:"プリンター稼働率",filamentSuccess:"素材別成功率",printHabits:"印刷習慣",printTimeOfDay:"時間帯別プリント",colorDistribution:"カラー分布",noColorData:"カラーデータがありません",records:"記録",longestPrint:"最長プリント",heaviestPrint:"最重プリント",mostExpensivePrint:"最高額",busiestDay:"最多プリント日",successStreak:"連続成功",streakPrint:"連続プリント",streakPrints:"{{count}}連続プリント",printerStats:"プリンター統計",hours:"時間",avgPrints:"平均印刷数",noArchiveData:"印刷データがありません",filamentByTime:"推移",avgWeight:"平均重量",avgTime:"平均時間",filamentByPrints:"印刷数",timeframe:{today:"今日","this-week":"今週","this-month":"今月","last-7":"過去7日間","last-30":"過去30日間","last-90":"過去90日間","this-year":"今年","all-time":"全期間",custom:"カスタム",from:"開始",to:"終了"}},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:"カスタムタイプを追加",restoreDefaults:"デフォルトタスクを復元",intervalType:"インターバルタイプ",icon:"アイコン",documentationLink:"ドキュメントリンク(任意)",assignToPrinters:"プリンターに割り当て",selectAtLeastOnePrinter:"プリンターを1台以上選択してください",addType:"タイプを追加",custom:"カスタム",printHours:"印刷時間",calendarDays:"カレンダー日数",viewDocumentation:"ドキュメントを表示",timeBasedInterval:"時間ベースのインターバル",intervalOverrides:"インターバルのオーバーライド",assignedToPrinters:"割り当て済みプリンター:",noPrintersAssigned:"プリンター未割り当て",removeFromPrinter:"このプリンターから削除",types:{lubricateCarbonRods:"カーボンロッドの潤滑",lubricateRails:"リニアレールの潤滑",cleanNozzle:"ノズル/ホットエンドの清掃",checkBelts:"ベルト張力の確認",cleanBuildPlate:"ビルドプレートの清掃",checkExtruder:"エクストルーダーギアの確認",checkCooling:"冷却ファンの確認",generalInspection:"総合点検",cleanCarbonRods:"カーボンロッドの清掃",cleanLinearRails:"リニアレールの清掃",checkPtfeTube:"PTFEチューブの確認",replaceHepaFilter:"HEPAフィルター交換",replaceCarbonFilter:"カーボンフィルター交換",lubricateLeftNozzleRail:"左ノズルレールの潤滑"},typeUpdated:"メンテナンスタイプを更新しました",typeDeleted:"メンテナンスタイプを削除しました",defaultsRestored:"デフォルトタスクを{{count}}件復元しました",printerAssigned:"プリンターを割り当てました",printerRemoved:"プリンターを削除しました",deleteTypeConfirm:"「{{name}}」を削除しますか?",deleteSystemTypeTitle:"デフォルトのメンテナンスタスクを削除しますか?",deleteSystemTypeMessage:"デフォルトのメンテナンスタスク「{{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:"プッシュ通知の言語",bedCooledThreshold:"ベッド冷却しきい値",bedCooledThresholdDescription:"印刷後にベッドが冷却されたと見なす温度",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:"プリンターファームウェアの確認",includeBetaUpdates:"ベータ版を含める",includeBetaUpdatesDesc:"アップデート確認時にベータ版およびプレリリース版を通知する",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:"データ管理",storageUsage:"ストレージ使用量",storageUsageDescription:"カテゴリ別のデータ使用量の内訳",storageUsageTotal:"合計",storageUsageErrors:"エラー",storageUsageOtherBreakdown:"その他(静的アセット、スクリプト、設定ファイルを含む)",storageUsageSystem:"システム",storageUsageData:"データ",storageUsageUnavailable:"ストレージ使用量情報は利用できません",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:"説明を入力(任意)",filamentTracking:"フィラメント追跡",filamentTrackingDesc:"フィラメントスプールの追跡方法を選択してください。内蔵インベントリまたは外部Spoolmanサーバーを使用できます。",trackingModeBuiltIn:"内蔵インベントリ",trackingModeBuiltInDesc:"RFID自動検出と使用量追跡を含む",trackingModeSpoolmanDesc:"外部フィラメント管理サーバー",builtInFeatureRfid:"AMS内のBambu Lab RFIDスプールを自動検出",builtInFeatureUsage:"プリントごとのフィラメント消費量を追跡",builtInFeatureCatalog:"スプール、カラー、K値プロファイルを管理",builtInFeatureThirdParty:"サードパーティ製スプールをインベントリスプールに割り当て可能",amsSyncButton:"AMSから重量を同期",amsSyncTitle:"AMSからスプール重量を同期",amsSyncMessage:"接続されたプリンターの現在のAMS残量値で、すべてのインベントリスプール重量を上書きします。破損した重量データの復旧に使用してください。プリンターがオンラインである必要があります。",amsSyncing:"同期中...",amsSyncSuccess:"{{synced}}個のスプールを同期、{{skipped}}個をスキップ",amsSyncError:"AMSからの重量同期に失敗しました",spoolmanUrl:"Spoolman URL",spoolmanUrlHint:"Spoolmanサーバーのurl(例:http://localhost:7912)",spoolmanConnected:"接続中",spoolmanDisconnected:"未接続",status:"ステータス",connect:"接続",disconnect:"切断",howSyncWorks:"同期の仕組み",syncInfoRfidOnly:"RFIDを搭載した公式Bambu Labスプールのみ同期されます",syncInfoAutoCreate:"新しいスプールは初回同期時にSpoolmanに自動作成されます",syncInfoThirdPartySkipped:"Bambu Lab以外のスプール(サードパーティ、リフィル)はスキップされます",linkingExistingSpools:"既存スプールのリンク",linkingExistingSpoolsDesc:"既存のSpoolmanスプールをAMSにリンクするには、AMSスロットにカーソルを合わせて「Spoolmanにリンク」をクリックしてください。",syncMode:"同期モード",syncModeAuto:"自動",syncModeManual:"手動のみ",syncModeAutoDesc:"変更が検出されるとAMSデータが自動的に同期されます",syncModeManualDesc:"手動でトリガーした場合のみ同期",syncAmsData:"AMSデータを同期",syncAmsDataDesc:"プリンターのAMSデータをSpoolmanに手動同期",allPrinters:"全プリンター",catalog:{spoolCatalog:"スプールカタログ",spoolCatalogDescription:"ブランド/タイプ別の空スプール重量。スプール追加時の自動重量検索に使用されます。",searchCatalog:"カタログを検索...",addNewEntry:"新しいエントリを追加",namePlaceholder:"名前(例:Bambu Lab - プラスチック)",weight:"重量",type:"タイプ",default:"デフォルト",custom:"カスタム",noMatch:"検索に一致するエントリがありません",empty:"カタログにエントリがありません",deleteEntry:"エントリを削除",deleteConfirm:"「{{name}}」を削除してもよろしいですか?",resetCatalog:"カタログをリセット",resetConfirm:"カタログをデフォルトにリセットしますか?カスタムエントリはすべて削除されます。",loadFailed:"スプールカタログの読み込みに失敗しました",nameWeightRequired:"名前と重量は必須です",entryAdded:"エントリを追加しました",addFailed:"エントリの追加に失敗しました",entryUpdated:"エントリを更新しました",updateFailed:"エントリの更新に失敗しました",entryDeleted:"エントリを削除しました",deleteFailed:"エントリの削除に失敗しました",resetSuccess:"カタログをデフォルトにリセットしました",resetFailed:"カタログのリセットに失敗しました",exported:"{{count}}件のエントリをエクスポートしました",imported:"{{added}}件のエントリをインポートしました({{skipped}}件スキップ)",importFailed:"インポートに失敗しました:無効なJSON形式",exportTooltip:"カタログをJSONにエクスポート",importTooltip:"JSONからカタログをインポート",resetTooltip:"デフォルトにリセット"},colorCatalog:{title:"カラーカタログ",description:"メーカー/素材別のフィラメントカラー。スプール追加時の自動カラー検索に使用されます。",searchColors:"カラーを検索...",allManufacturers:"すべてのメーカー",addNewColor:"新しいカラーを追加",manufacturer:"メーカー",colorName:"カラー名",hex:"Hex",materialOptional:"素材(任意)",showing:"{{total}}件中{{filtered}}件を表示",noMatch:"検索に一致するカラーがありません",empty:"カタログにカラーがありません",deleteColor:"カラーを削除",deleteConfirm:"「{{name}}」を削除してもよろしいですか?",resetCatalog:"カラーカタログをリセット",resetConfirm:"カタログをデフォルトにリセットしますか?カスタムカラーはすべて削除されます。",sync:"同期",starting:"開始中...",syncTooltip:"FilamentColors.xyzから同期(2000+カラー)",loadFailed:"カラーカタログの読み込みに失敗しました",fieldsRequired:"メーカー、カラー名、Hexカラーは必須です",colorAdded:"カラーを追加しました",addFailed:"カラーの追加に失敗しました",colorUpdated:"カラーを更新しました",updateFailed:"カラーの更新に失敗しました",colorDeleted:"カラーを削除しました",deleteFailed:"カラーの削除に失敗しました",resetSuccess:"カラーカタログをデフォルトにリセットしました",resetFailed:"カタログのリセットに失敗しました",syncUpToDate:"最新の状態です({{count}}件のカラーを確認)",syncComplete:"{{added}}件の新しいカラーを追加しました({{skipped}}件は既に存在)",syncError:"同期エラー",syncFailed:"FilamentColors.xyzからの同期に失敗しました",exported:"{{count}}件のカラーをエクスポートしました",imported:"{{added}}件のカラーをインポートしました({{skipped}}件スキップ)",importFailed:"インポートに失敗しました:無効なJSON形式"}},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:"このグループを削除しますか?このグループのユーザーはこれらの権限を失います。"},editor:{title:"グループを編集",createTitle:"グループを作成",search:"権限を検索...",selectAll:"すべて選択",clearAll:"すべて解除",permissionsSelected:"{{count}}件選択",noResults:"検索に一致する権限がありません"},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:"進捗",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"},inventory:{title:"スプール在庫管理",addSpool:"スプールを追加",editSpool:"スプールを編集",material:"素材",selectMaterial:"素材を選択...",subtype:"サブタイプ",brand:"ブランド",searchBrand:"ブランドを検索...",useCustomBrand:"「{{brand}}」を使用",useCustomMaterial:"カスタム素材を使用: {{material}}",colorName:"色名",colorNamePlaceholder:"Jade White, Fire Red...",color:"色",hexColor:"HEXカラー",pickColor:"カスタムカラーを選択",labelWeight:"表示重量",coreWeight:"空スプール重量",searchSpoolWeight:"スプール重量を検索...",weightUsed:"使用量",currentWeight:"残量",measuredWeight:"計測重量",costPerKg:"kgあたりのコスト",measuredWeightError:"計測重量は{{min}}gから{{max}}gの間で入力してください。",slicerFilament:"スライサーフィラメント",slicerFilamentName:"スライサープリセット名",slicerPreset:"スライサープリセット",searchPresets:"フィラメントプリセットを検索...",selectedPreset:"選択済み",noPresetsFound:"プリセットが見つかりません",tempOverrides:"温度オーバーライド",note:"メモ",notePlaceholder:"このスプールに関する追加メモ...",archive:"アーカイブ",restore:"復元",noSpools:"スプールがありません。最初のスプールを追加してください。",noManualSpools:"手動で追加されたスプールがありません。先にインベントリにスプールを追加してください。",kProfiles:"Kプロファイル",addKProfile:"Kプロファイルを追加",assignSpool:"スプールを割り当て",unassignSpool:"割り当て解除",assignSuccess:"スプールを割り当て、AMSスロットを設定しました",assignFailed:"スプールの割り当てに失敗しました",selectSpool:"このスロットに割り当てるスプールを選択",assigned:"割り当て済み",assigning:"割り当て中...",searchSpools:"スプールを検索...",allMaterials:"すべての素材",filterByBrand:"ブランドで絞り込み...",showArchived:"アーカイブ済みを表示",quickAdd:"クイック追加(在庫)",quantity:"数量",stock:"在庫",configured:"設定済み",spoolsCreated:"{{count}}本のスプールを作成しました",spoolCreated:"スプールを作成しました",spoolUpdated:"スプールを更新しました",spoolDeleted:"スプールを削除しました",spoolArchived:"スプールをアーカイブしました",spoolRestored:"スプールを復元しました",deleteConfirm:"このスプールを削除しますか?この操作は元に戻せません。",archiveConfirm:"このスプールをアーカイブしますか?",advancedSettings:"詳細設定",filamentInfoTab:"フィラメント情報",paProfileTab:"PAプロファイル",filamentInfo:"フィラメント",additional:"追加情報",loadingPresets:"クラウドプリセットを読み込み中...",cloudConnected:"クラウド接続済み",cloudNotConnected:"クラウド未接続(デフォルト使用)",recentColors:"最近",searchColors:"色を検索...",searchResults:"検索結果",allColors:"すべての色",commonColors:"一般的な色",showLess:"少なく表示",showAll:"すべて表示",noColorsFound:"一致する色がありません",noResults:"結果なし",selectMaterialFirst:"フィラメント情報タブで素材を選択してください。",noPrintersConfigured:"プリンターが設定されていません。プリンターを追加してください。",matchingFilter:"フィルター",anyBrand:"すべてのブランド",anyVariant:"すべてのバリアント",autoSelect:"自動選択",matches:"件一致",match:"件一致",noMatches:"一致なし",connected:"接続済み",offline:"オフライン",printerOffline:"プリンターがオフラインです。接続してキャリブレーションプロファイルを表示してください。",noKProfilesMatch:"選択したフィラメントに一致するKプロファイルがありません。",leftNozzle:"左ノズル",rightNozzle:"右ノズル",profilesSelected:"キャリブレーションプロファイル選択済み",totalInventory:"在庫合計",totalConsumed:"総消費量",byMaterial:"素材別",inPrinter:"プリンター内",lowStock:"残量少",sinceTracking:"追跡開始以降",loadedInAms:"AMS/Extに装填中",remaining:"残り",lowStockThreshold:"残り20%未満",weightCheck:"重量チェック",lastWeighed:"最終計量",neverWeighed:"未計量",search:"スプールを検索...",showing:"表示",to:"〜",of:"/",show:"表示",spools:"スプール",spool:"スプール",page:"ページ",noSpoolsMatch:"結果なし",noSpoolsMatchDesc:"検索やフィルターを調整してみてください。",active:"アクティブ",archived:"アーカイブ済み",all:"すべて",used:"使用済み",new:"新規",clearFilters:"フィルターをクリア",table:"テーブル",cards:"カード",net:"正味",groupSimilar:"グループ化",groupedSpools:"{{count}}本の同一スプール",groupedRows:"行",columns:"列",configureColumns:"列の設定",configureColumnsDesc:"ドラッグして並べ替えるか、矢印を使用してください。目のアイコンで表示/非表示を切り替えます。",visible:"表示中",reset:"リセット",cancel:"キャンセル",applyChanges:"変更を適用",moveUp:"上へ移動",moveDown:"下へ移動",hideColumn:"列を非表示",showColumn:"列を表示",linkToSpool:"スプールにリンク",tagLinked:"タグがスプールにリンクされました",tagLinkFailed:"タグのリンクに失敗しました",tagAlreadyLinked:"タグは既に別のスプールにリンクされています",unknownTag:"不明なRFIDタグが検出されました",usageHistory:"使用履歴",noUsageHistory:"まだ使用記録がありません",printName:"プリント名",weightConsumed:"消費重量",clearHistory:"クリア",historyCleared:"使用履歴がクリアされました",fillSourceLabel:"(Inv)"},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:"設定",used:"使用済み",remainingUnit:"残り"},printModal:{flowCalibration:"フローキャリブレーション",vibrationCalibration:"振動キャリブレーション",startPrint:"印刷を開始",noPrintersAvailable:"利用可能なプリンターがありません",title:"印刷を開始",selectPrinter:"プリンターを選択",selectPlate:"プレートを選択",filamentMapping:"フィラメントマッピング",totalCost:"合計コスト:",slotRemainingShort:" - 残{{grams}}g",printSettings:"印刷設定",bedLeveling:"ベッドレベリング",layerInspection:"第一層検査",timelapse:"タイムラプス",addToQueue:"キューに追加",printerBusy:"プリンターは使用中です",printerOffline:"プリンターはオフラインです",cancel:"キャンセル",leftNozzle:"L",rightNozzle:"R",leftNozzleTooltip:"左ノズル",rightNozzleTooltip:"右ノズル",filamentOverride:"フィラメントオーバーライド",filamentOverrideHint:"モデルベースの割り当てに使用するフィラメントをオプションで上書きします。スケジューラは元の3MF値ではなく、選択したフィラメントに基づいてマッチングします。",originalFilament:"オリジナル",overrideWith:"変更先",resetToOriginal:"オリジナルに戻す"},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:{title:"仕組み",step1:"同じLAN上では、仮想プリンターはスライサー(Bambu Studio / OrcaSlicer)に自動的に表示されます。他のネットワークからは、IPアドレスとアクセスコードで手動で追加してください。",step2:"アーカイブ、レビュー、キューモードでは、スライサーの「送信」ボタンを使用して3MFファイルをBambuddyにアップロードします。スライサーは「印刷成功」と表示しますが、ファイルは保存され、印刷はされません。",step3:"プロキシモードでは、仮想プリンターはすべてのトラフィックを実際のプリンターに転送します。直接接続されているかのように印刷がすぐに開始されます。"},status:{mode:"モード",pendingFiles:"保留中のファイル",ftpPort:"FTPポート",mqttPort:"MQTTポート",ftpConnections:"FTP接続数",mqttConnections:"MQTT接続数",title:"ステータス詳細",printerName:"プリンター名",model:"モデル",serialNumber:"シリアル番号",targetPrinter:"ターゲットプリンター"},toast:{accessCodeRequired:"先にアクセスコードを設定してください",targetPrinterRequired:"先にターゲットプリンターを選択してください",bindIpRequired:"先にバインドIPを設定してください",accessCodeEmpty:"アクセスコードは空にできません",accessCodeLength:"アクセスコードは8文字である必要があります",updated:"仮想プリンター設定を更新しました",failedToUpdate:"設定の更新に失敗しました",created:"仮想プリンターを作成しました",failedToCreate:"仮想プリンターの作成に失敗しました",deleted:"仮想プリンターを削除しました",failedToDelete:"仮想プリンターの削除に失敗しました"},list:{title:"仮想プリンター",add:"追加",addFirst:"仮想プリンターを追加",empty:"仮想プリンターが設定されていません。追加して始めましょう。"},bindIp:{title:"バインドインターフェース",placeholder:"インターフェースを選択...",hint:"この仮想プリンターがバインドするネットワークインターフェース。プリンターごとに一意である必要があります。"},proxy:{accessCodeHint:"プロキシモードでは、スライサーにターゲットプリンターのアクセスコードを使用してください。接続は実際のプリンターに透過的に転送されます。"},addDialog:{title:"仮想プリンターを追加",name:"名前",hint:"アクセスコード、ターゲットプリンター、その他の設定は作成後に設定できます。",create:"作成"},deleteConfirm:{title:"仮想プリンターを削除",message:"「{{name}}」を削除してもよろしいですか?このプリンターのすべてのサービスが停止されます。"},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:{lubricateCarbonRods:"カーボンロッドに潤滑剤を塗布してスムーズな動きを確保",lubricateRails:"リニアレールの潤滑",cleanNozzle:"ノズル/ホットエンドの清掃",checkBelts:"ベルト張力の確認",cleanBuildPlate:"ビルドプレートの清掃",checkExtruder:"エクストルーダーギアの確認",checkCooling:"冷却ファンの確認",generalInspection:"総合点検",cleanCarbonRods:"カーボンロッドの清掃",cleanLinearRails:"リニアレールを拭いてほこりや汚れを除去",checkPtfeTube:"PTFEチューブの確認",replaceHepaFilter:"HEPAフィルター交換",replaceCarbonFilter:"カーボンフィルター交換",lubricateLeftNozzleRail:"左ノズルレールの潤滑"},hmsErrors:{title:"エラー - {{name}}",noErrors:"エラーなし",viewOnWiki:"Bambu Lab Wikiで表示",clearInstructions:"プリンターでエラーをクリアするとここからも消えます。",clearErrors:"エラーをクリア",clearSuccess:"HMSエラーをクリアしました",clearFailed:"HMSエラーのクリアに失敗しました"},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:{title:"AMSスロットの設定",slotConfigured:"スロットを設定しました!",configuringSlot:"スロットを設定中:",slotLabel:"{{ams}} スロット {{slot}}",searchPresets:"プリセットを検索...",colorPlaceholder:"色名またはHex(例: 茶色、FF8800)",clearCustomColor:"カスタム色をクリア",noCloudPresets:"クラウドプリセットがありません。Bambu Cloudにログインして同期してください。",noPresetsAvailable:"プリセットがありません。Bambu Cloudにログインするか、ローカルプロファイルをインポートしてください。",noMatchingPresets:"一致するプリセットが見つかりません。",custom:"カスタム",builtin:"内蔵",settingsSentToPrinter:"設定をプリンターに送信しました",filamentProfile:"フィラメントプロファイル",kProfileLabel:"Kプロファイル(Pressure Advance)",filteringFor:"フィルター中: {{material}}",noKProfile:"Kプロファイルなし(デフォルト0.020を使用)",noMatchingKProfiles:"一致するKプロファイルが見つかりません。デフォルトK=0.020が使用されます。",selectFilamentFirst:"まずフィラメントプロファイルを選択してください",kFromCalibration:"K={{value}}(プリンターキャリブレーションから)",customColorLabel:"カスタム色(オプション)",presetColors:"{{name}}の色:",showLessColors:"色を減らす",showMoreColors:"色をもっと表示",clear:"クリア",hexLabel:"Hex: #{{hex}}",resetting:"リセット中...",resetSlot:"スロットをリセット",cancel:"キャンセル",configuring:"設定中...",configureSlot:"スロットを設定"},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:{},time:{unknown:"-",waiting:"待機中",justNow:"たった今",now:"今すぐ",minsAgo:"{{count}}分前",inMins:"あと{{count}}分",hoursAgo:"{{count}}時間前",inHours:"あと{{count}}時間",daysAgo:"{{count}}日前",inDays:"あと{{count}}日"},spoolbuddy:{nav:{dashboard:"ダッシュボード",ams:"AMS",inventory:"インベントリ",writeTag:"書込み",settings:"設定"},status:{nfcReady:"NFC準備完了",nfcOff:"NFCオフ",offline:"オフライン",online:"オンライン",noPrinters:"プリンターなし",deviceOffline:"デバイスオフライン",waitingConnection:"デバイス接続を待っています...",systemReady:"システム準備完了",status:"ステータス"},dashboard:{readyToScan:"スキャン準備完了",idleMessage:"スプールを計量台に置いて識別します",nfcHint:"NFCタグは自動的に読み取られます",device:"デバイス",syncWeight:"重量同期",weightSynced:"同期完了!",unknownTag:"不明なタグ",newTag:"新しいタグを検出",onScale:"計量中",linkSpool:"スプールにリンク",linkTagTitle:"タグをスプールにリンク",linkTag:"タグをリンク",selectSpool:"このタグにリンクするスプールを選択:",noUntagged:"タグなしのスプールが見つかりません",tagDetected:"タグ検出",noTag:"タグなし",tagId:"タグ",grossWeight:"総重量",spoolSize:"スプールサイズ",close:"閉じる",currentSpool:"現在のスプール"},modal:{spoolDetected:"スプール検出",assignToAms:"AMSに割り当て",syncWeight:"重量同期",weightSynced:"同期完了!",syncing:"同期中...",newTagDetected:"新しいタグを検出",addToInventory:"インベントリに追加",assignToAmsTitle:"AMSに割り当て",selectSlot:"スロットを選択",assign:"割り当て",assigning:"割り当て中...",assignSuccess:"割り当て完了!",assignError:"スプールの割り当てに失敗しました。再試行してください。",noPrinterSelected:"プリンターを選択...",noAmsDetected:"このプリンターにAMSが検出されません",slot:"スロット"},weight:{noReading:"読み取りなし",stable:"安定",measuring:"計測中...",tare:"風袋引き",calibrate:"キャリブレーション"},spool:{remaining:"残量",material:"素材",brand:"ブランド",color:"色",coreWeight:"コア",labelWeight:"ラベル",scaleWeight:"計量",netWeight:"正味",lastUsed:"最終使用"},ams:{noData:"AMSが検出されません",connectAms:"AMSを接続してスロットを表示",noPrinter:"プリンター未選択",selectPrinter:"上部バーからプリンターを選択",printerDisconnected:"プリンター切断",humidity:"湿度",level:"レベル",active:"アクティブ",slot:"スロット",empty:"空"},inventory:{search:"スプールを検索...",empty:"インベントリにスプールがありません",noResults:"一致するスプールがありません",spools:"スプール",addSpool:"スプール追加"},settings:{tabDevice:"デバイス",tabDisplay:"ディスプレイ",tabScale:"計量",tabUpdates:"アップデート",nfcReader:"NFCリーダー",type:"タイプ",connection:"接続",notConnected:"N/A",deviceInfo:"デバイス情報",hostname:"ホスト",uptime:"稼働時間",brightness:"明るさ",saved:"保存済み",noBacklight:"DSIバックライトが検出されませんでした。明るさ制御にはDSIディスプレイが必要です。",screenBlank:"画面オフタイムアウト",screenBlankDesc:"操作がないと画面がオフになります。タッチで復帰。",displayNote:"明るさはソフトウェアフィルターとして適用されます。",scaleCalibration:"計量キャリブレーション",currentWeight:"現在の重量",tareOffset:"風袋",calFactor:"係数",knownWeight:"既知の重量",calStep1:"計量台からすべてのアイテムを取り除き、ゼロ設定を押してください。",calStep2:"既知の重量を計量台に置いてください。",setZero:"ゼロ設定",calibrateNow:"キャリブレーション",calibrated:"キャリブレーション済み",tareSet:"風袋コマンドを送信しました。デバイスを待っています...",tareFailed:"風袋コマンドの送信に失敗しました",zeroSet:"ゼロ点を設定しました。既知の重量を計量台に置いてください。",calibrationDone:"キャリブレーション完了!",calibrationFailed:"キャリブレーションに失敗しました",lastCalibrated:"最終キャリブレーション",stable:"安定",settling:"安定化中...",firmware:"ファームウェア",scale:"計量",noDevice:"SpoolBuddyデバイスが見つかりません",daemonVersion:"デーモンバージョン",currentVersion:"現在",versionPending:"デーモンを待っています...",checking:"確認中...",checkUpdates:"アップデートを確認",updateAvailable:"アップデートあり",updateInstructions:"SSH経由で更新:SpoolBuddyインストールスクリプトを実行してください。",upToDate:"最新です",includeBeta:"ベータ版を含む"},writeTag:{tabExisting:"既存のスプール",tabNew:"新規スプール",tabReplace:"タグ交換",searchPlaceholder:"素材、色、ブランドで検索...",noUntaggedSpools:"タグなしのスプールがありません",noTaggedSpools:"タグ付きのスプールがありません",selectSpool:"スプールを選択し、NTAGをリーダーに置いてください",placeTag:"NTAGをリーダーに置いてください",tagReady:"タグ検出 — 書込み準備完了",writeTag:"タグ書込み",replaceTag:"タグ交換",writing:"タグ書込み中...",waiting:"SpoolBuddyを待機中...",writeSuccess:"タグの書込みが完了しました!",writeFailed:"書込み失敗",queueFailed:"書込みコマンドのキューに失敗しました",tryAgain:"再試行",cancel:"キャンセル",replaceWarning:"古いタグのリンクが解除され、新しいタグに置き換わります。",deviceOffline:"SpoolBuddyはオフラインです",material:"素材",colorName:"色名",color:"色",brand:"ブランド",weight:"重量 (g)",createSpool:"スプール作成",creating:"作成中...",spoolCreated:"スプール作成完了!書込み準備ができました。",createFailed:"スプールの作成に失敗しました"}}},Uce={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",tomorrow:"Domani",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:{available:"Disponibile",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",nextAvailable:"Prossima disponibile",powerOn:"Accendi",offlinePrintersWithPlugs:"Stampanti offline con smart plug",noPrintersConfigured:"Nessuna stampante configurata",readyToPrint:"Pronta a stampare",external:"Esterna",extL:"Ext-L",extR:"Ext-R",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",noCamera:"Non hai il permesso di visualizzare le telecamere"},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",confirmTitle:"Saltare oggetto?",confirmMessage:'Sei sicuro di voler saltare "{{name}}"? Questa azione non può essere annullata.'},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."},developerModeWarning:"La modalità sviluppatore LAN non è attivata su: {{names}}. Alcune funzionalità potrebbero non funzionare.",howToEnable:"Come attivare"},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",logView:"Registro stampe",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",noFileForReprint:"Nessun file 3MF disponibile — il file non è stato scaricato dalla stampante durante la registrazione",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"},log:{date:"Data",printName:"Nome stampa",printer:"Stampante",user:"Utente",status:"Stato",duration:"Durata",filament:"Filamento",allPrinters:"Tutte le stampanti",allUsers:"Tutti gli utenti",allStatuses:"Tutti gli stati",cancelled:"Annullato",skipped:"Saltato",dateFrom:"Dal",dateTo:"Al",noEntries:"Nessuna voce di registro trovata",showing:"{{count}} di {{total}} voci",rowsPerPage:"Righe",page:"Pagina",prev:"Prec.",next:"Succ.",clearLog:"Cancella registro",clearLogTitle:"Cancella registro stampe",clearLogConfirm:"Tutte le voci del registro di stampa verranno eliminate permanentemente. Gli archivi e gli elementi della coda non sono interessati. Questa azione non può essere annullata. Sei sicuro?",clearLogButton:"Cancella tutto",cleared:"{{count}} voci di registro cancellate",clearFailed:"Impossibile cancellare il registro stampe"}},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}}",plateNumber:"Piatto {{index}}",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",totalWeight:"Peso totale della 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"}},backgroundDispatch:{unknownFile:"File sconosciuto",unknownPrinter:"Stampante sconosciuta",startingPrints:"Avvio stampe",progressSummary:"{{complete}}/{{total}} completati • Inviati: {{dispatched}} • In elaborazione: {{processing}}",expandDetails:"Espandi dettagli dispatch",collapseDetails:"Comprimi dettagli dispatch",dismissToast:"Chiudi notifica dispatch",cancelDispatchJob:"Annulla job dispatch",cancel:"Annulla",cancelling:"Annullamento…",status:{dispatched:"Inviato",processing:"In elaborazione",completed:"Completato",failed:"Fallito",cancelled:"Annullato"},toast:{cancellingUpload:"Annullamento upload...",cancelled:"Dispatch annullato",cancelFailed:"Impossibile annullare il dispatch",completeWithFailures:"Dispatch in background completato: {{completed}} riusciti, {{failed}} falliti",completeSuccess:"Dispatch in background completato: {{completed}} riusciti"}},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",noPrintDataInRange:"Nessun dato nel periodo selezionato",periodFilament:"Filamento utilizzato",periodCost:"Costo",avgPerPrint:"Media per stampa",usageOverTime:"Utilizzo nel tempo",filamentByWeight:"Peso",printDuration:"Durata stampa",printerUtilization:"Utilizzo stampante",filamentSuccess:"Successo per materiale",printHabits:"Abitudini di stampa",printTimeOfDay:"Ora di stampa",colorDistribution:"Distribuzione colori",noColorData:"Nessun dato colore disponibile",records:"Record",longestPrint:"Stampa più lunga",heaviestPrint:"Stampa più pesante",mostExpensivePrint:"Più costosa",busiestDay:"Giorno più attivo",successStreak:"Serie di successi",streakPrint:"stampa consecutiva",streakPrints:"{{count}} stampe consecutive",printerStats:"Statistiche stampante",hours:"ore",avgPrints:"Media stampe",noArchiveData:"Nessun dato di stampa disponibile",filamentByTime:"Tempo",avgWeight:"Media peso",avgTime:"Media tempo",filamentByPrints:"Stampe",timeframe:{today:"Oggi","this-week":"Questa settimana","this-month":"Questo mese","last-7":"Ultimi 7 giorni","last-30":"Ultimi 30 giorni","last-90":"Ultimi 90 giorni","this-year":"Quest'anno","all-time":"Tutto",custom:"Personalizzato",from:"Da",to:"A"}},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",restoreDefaults:"Ripristina attivita predefinite",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:{lubricateCarbonRods:"Lubrifica aste in carbonio",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",cleanLinearRails:"Pulisci guide lineari",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",defaultsRestored:"Ripristinate {{count}} attivita predefinite",printHoursUpdated:"Ore di stampa aggiornate",printerAssigned:"Stampante assegnata",printerRemoved:"Stampante rimossa",deleteTypeConfirm:'Eliminare "{{name}}"?',deleteSystemTypeTitle:"Eliminare attività di manutenzione predefinita?",deleteSystemTypeMessage:`Sei sicuro di voler eliminare l'attività di manutenzione predefinita "{{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",bedCooledThreshold:"Soglia raffreddamento piatto",bedCooledThresholdDescription:"Temperatura sotto la quale il piatto è considerato raffreddato dopo una stampa",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",includeBetaUpdates:"Includi versioni beta",includeBetaUpdatesDesc:"Notifica versioni beta e prerelease durante il controllo aggiornamenti",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",storageUsage:"Memoria utilizzata",storageUsageDescription:"Ripartizione della memoria per categoria",storageUsageTotal:"Totale",storageUsageErrors:"Errori",storageUsageOtherBreakdown:"Altro (include risorse statiche, script e file di configurazione)",storageUsageSystem:"Sistema",storageUsageData:"Dati",storageUsageUnavailable:"Informazioni sull'utilizzo della memoria non disponibili",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.",clearErrors:"Cancella errori",clearSuccess:"Errori HMS cancellati",clearFailed:"Impossibile cancellare gli errori HMS"},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"},editor:{title:"Modifica gruppo",createTitle:"Crea gruppo",search:"Cerca permessi...",selectAll:"Seleziona tutto",clearAll:"Deseleziona tutto",permissionsSelected:"{{count}} selezionati",noResults:"Nessun permesso corrisponde alla ricerca"}},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",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."},inventory:{title:"Inventario Bobine",addSpool:"Aggiungi Bobina",editSpool:"Modifica Bobina",material:"Materiale",selectMaterial:"Seleziona materiale...",subtype:"Sottotipo",brand:"Marchio",searchBrand:"Cerca marchio...",useCustomBrand:'Usa "{{brand}}"',useCustomMaterial:"Usa materiale personalizzato: {{material}}",colorName:"Nome Colore",colorNamePlaceholder:"Jade White, Fire Red...",color:"Colore",hexColor:"Colore Hex",pickColor:"Scegli colore personalizzato",labelWeight:"Peso da Etichetta",coreWeight:"Peso Bobina Vuota",searchSpoolWeight:"Cerca peso bobina...",weightUsed:"Utilizzato",currentWeight:"Peso Rimanente",measuredWeight:"Peso Misurato",costPerKg:"Costo per kg",measuredWeightError:"Il peso misurato deve essere compreso tra {{min}}g e {{max}}g.",slicerFilament:"Filamento Slicer",slicerFilamentName:"Nome Preset Slicer",slicerPreset:"Preset Slicer",searchPresets:"Cerca preset filamento...",selectedPreset:"Selezionato",noPresetsFound:"Nessun preset trovato",tempOverrides:"Override Temperatura",note:"Nota",notePlaceholder:"Eventuali note aggiuntive su questa bobina...",archive:"Archivia",restore:"Ripristina",noSpools:"Ancora nessuna bobina. Aggiungi la tua prima bobina per iniziare.",noManualSpools:"Nessuna bobina aggiunta manualmente disponibile. Aggiungi prima una bobina al tuo inventario.",kProfiles:"K-Profiles",addKProfile:"Aggiungi K-Profile",assignSpool:"Assegna Bobina",unassignSpool:"Scollega",assignSuccess:"Bobina assegnata e slot AMS configurato",assignFailed:"Assegnazione bobina fallita",selectSpool:"Seleziona una bobina da assegnare a questo slot",assigned:"Assegnato",assigning:"Assegnazione...",searchSpools:"Cerca bobine...",allMaterials:"Tutti i Materiali",filterByBrand:"Filtra per marchio...",showArchived:"Mostra archiviate",quickAdd:"Aggiunta rapida (Scorta)",quantity:"Quantità",stock:"Scorta",configured:"Configurata",spoolsCreated:"{{count}} bobine create",spoolCreated:"Bobina creata",spoolUpdated:"Bobina aggiornata",spoolDeleted:"Bobina eliminata",spoolArchived:"Bobina archiviata",spoolRestored:"Bobina ripristinata",deleteConfirm:"Sei sicuro di voler eliminare questa bobina? Questa azione non può essere annullata.",advancedSettings:"Impostazioni Avanzate",weightCheck:"Controllo Peso",lastWeighed:"Ultima pesatura",neverWeighed:"Mai pesato"},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:"Livello",configure:"Configura",used:"utilizzato",remainingUnit:"rimanente"},printModal:{title:"Avvia stampa",selectPrinter:"Seleziona stampante",selectPlate:"Seleziona piatto",filamentMapping:"Mappatura filamento",totalCost:"Costo totale:",slotRemainingShort:" - {{grams}}g rim.",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",leftNozzle:"L",rightNozzle:"R",leftNozzleTooltip:"Ugello sinistro",rightNozzleTooltip:"Ugello destro",filamentOverride:"Sostituzione filamento",filamentOverrideHint:"Sostituisci opzionalmente i filamenti per l'assegnazione basata sul modello. Lo scheduler abbinerà i filamenti selezionati invece dei valori 3MF originali.",originalFilament:"Originale",overrideWith:"Sostituisci con",resetToOriginal:"Ripristina originale"},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."},bindIp:{title:"Interfaccia di rete",placeholder:"Seleziona interfaccia...",hint:"Interfaccia di rete a cui questa stampante virtuale si collega. Deve essere unica per stampante."},proxy:{accessCodeHint:"In modalita proxy, usa il codice di accesso della stampante di destinazione nello slicer. La connessione viene inoltrata in modo trasparente alla stampante reale."},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",step1:"Sulla stessa LAN, le stampanti virtuali appaiono automaticamente nel tuo slicer (Bambu Studio / OrcaSlicer). Da altre reti, aggiungile manualmente tramite indirizzo IP e codice di accesso.",step2:'In modalità Archivio, Revisione e Coda, usa il pulsante "Invia" nel tuo slicer per caricare file 3MF su Bambuddy. Lo slicer mostrerà "Stampa riuscita" — il file viene salvato, non stampato.',step3:"In modalità Proxy, la stampante virtuale inoltra tutto il traffico a una stampante reale — le stampe partono immediatamente come con una connessione diretta."},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:{lubricateCarbonRods:"Applica lubrificante alle aste in carbonio per un movimento fluido",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",cleanLinearRails:"Pulisci le guide lineari per rimuovere polvere e detriti",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)"},configureAmsSlot:{title:"Configura Slot AMS",slotConfigured:"Slot configurato!",configuringSlot:"Configurazione slot:",slotLabel:"{{ams}} Slot {{slot}}",searchPresets:"Cerca preset...",colorPlaceholder:"Nome colore o hex (es. marrone, FF8800)",clearCustomColor:"Cancella colore personalizzato",noCloudPresets:"Nessun preset cloud. Accedi a Bambu Cloud per sincronizzare.",noPresetsAvailable:"Nessun preset disponibile. Accedi a Bambu Cloud o importa profili locali.",noMatchingPresets:"Nessun preset corrispondente trovato.",custom:"Personalizzato",builtin:"Integrato",settingsSentToPrinter:"Impostazioni inviate alla stampante",filamentProfile:"Profilo filamento",kProfileLabel:"Profilo K (Pressure Advance)",filteringFor:"Filtrando per: {{material}}",noKProfile:"Nessun profilo K (usa predefinito 0.020)",noMatchingKProfiles:"Nessun profilo K corrispondente. Verrà usato K=0.020 predefinito.",selectFilamentFirst:"Seleziona prima un profilo filamento",kFromCalibration:"K={{value}} dalla calibrazione stampante",customColorLabel:"Colore personalizzato (opzionale)",presetColors:"Colori {{name}}:",showLessColors:"Mostra meno colori",showMoreColors:"Mostra più colori",clear:"Cancella",hexLabel:"Hex: #{{hex}}",resetting:"Ripristino...",resetSlot:"Ripristina slot",cancel:"Annulla",configuring:"Configurazione...",configureSlot:"Configura slot"},time:{unknown:"-",waiting:"In attesa",justNow:"Proprio ora",now:"Ora",minsAgo:"{{count}}m fa",inMins:"tra {{count}}m",hoursAgo:"{{count}}h fa",inHours:"tra {{count}}h",daysAgo:"{{count}}g fa",inDays:"tra {{count}}g"},spoolbuddy:{nav:{dashboard:"Dashboard",ams:"AMS",inventory:"Inventario",writeTag:"Scrivi",settings:"Impostazioni"},status:{nfcReady:"NFC pronto",nfcOff:"NFC spento",offline:"Offline",online:"Online",noPrinters:"Nessuna stampante",deviceOffline:"Dispositivo offline",waitingConnection:"In attesa della connessione...",systemReady:"Sistema pronto",status:"Stato"},dashboard:{readyToScan:"Pronto per la scansione",idleMessage:"Posiziona una bobina sulla bilancia per identificarla",nfcHint:"Il tag NFC verrà letto automaticamente",device:"Dispositivo",syncWeight:"Sincronizza peso",weightSynced:"Sincronizzato!",unknownTag:"Tag sconosciuto",newTag:"Nuovo tag rilevato",onScale:"sulla bilancia",linkSpool:"Collega a bobina",linkTagTitle:"Collega tag a bobina",linkTag:"Collega tag",selectSpool:"Seleziona una bobina da collegare a questo tag:",noUntagged:"Nessuna bobina senza tag trovata",tagDetected:"Tag rilevato",noTag:"Nessun tag",tagId:"Tag",grossWeight:"Peso lordo",spoolSize:"Dimensione bobina",close:"Chiudi"},weight:{noReading:"Nessuna lettura",stable:"Stabile",measuring:"Misurazione...",tare:"Tara",calibrate:"Calibra"},spool:{remaining:"Rimanente",material:"Materiale",brand:"Marca",color:"Colore",coreWeight:"Nucleo",labelWeight:"Etichetta",scaleWeight:"Bilancia",netWeight:"Netto",lastUsed:"Ultimo utilizzo"},ams:{noData:"Nessun AMS rilevato",connectAms:"Collega un AMS per vedere gli slot",noPrinter:"Nessuna stampante selezionata",selectPrinter:"Seleziona una stampante dalla barra superiore",printerDisconnected:"Stampante disconnessa",humidity:"Umidità",level:"Livello",active:"Attivo",slot:"Slot",empty:"Vuoto"},inventory:{search:"Cerca bobine...",empty:"Nessuna bobina nell'inventario",noResults:"Nessuna bobina corrispondente",spools:"bobine",addSpool:"Aggiungi bobina"},settings:{tabDevice:"Dispositivo",tabDisplay:"Display",tabScale:"Bilancia",tabUpdates:"Aggiornamenti",nfcReader:"Lettore NFC",type:"Tipo",connection:"Connessione",notConnected:"N/A",deviceInfo:"Info dispositivo",hostname:"Host",uptime:"Tempo di attività",brightness:"Luminosità",saved:"Salvato",noBacklight:"Nessuna retroilluminazione DSI rilevata. Il controllo luminosità richiede un display DSI.",screenBlank:"Timeout spegnimento schermo",screenBlankDesc:"Lo schermo si spegne dopo inattività. Tocca per riattivare.",displayNote:"La luminosità viene applicata come filtro software.",scaleCalibration:"Calibrazione bilancia",currentWeight:"Peso attuale",tareOffset:"Tara",calFactor:"Fattore",knownWeight:"Peso noto",calStep1:"Rimuovere tutto dalla bilancia e premere Imposta zero.",calStep2:"Posizionare il peso noto sulla bilancia.",setZero:"Imposta zero",calibrateNow:"Calibra",calibrated:"Calibrato",tareSet:"Comando tara inviato. In attesa del dispositivo...",tareFailed:"Invio comando tara fallito",zeroSet:"Punto zero impostato. Posizionare il peso noto sulla bilancia.",calibrationDone:"Calibrazione completata!",calibrationFailed:"Calibrazione fallita",lastCalibrated:"Ultima calibrazione",stable:"Stabile",settling:"Stabilizzazione...",firmware:"Firmware",scale:"Bilancia",noDevice:"Nessun dispositivo SpoolBuddy trovato",daemonVersion:"Versione daemon",currentVersion:"Attuale",versionPending:"In attesa del daemon...",checking:"Verifica...",checkUpdates:"Verifica aggiornamenti",updateAvailable:"Aggiornamento disponibile",updateInstructions:"Aggiorna via SSH: esegui lo script di installazione SpoolBuddy.",upToDate:"Aggiornato",includeBeta:"Includi versioni beta"},writeTag:{tabExisting:"Bobina esistente",tabNew:"Nuova bobina",tabReplace:"Sostituisci tag",searchPlaceholder:"Cerca per materiale, colore, marca...",noUntaggedSpools:"Nessuna bobina senza tag",noTaggedSpools:"Nessuna bobina con tag",selectSpool:"Seleziona una bobina, poi posiziona un NTAG sul lettore",placeTag:"Posiziona un NTAG sul lettore",tagReady:"Tag rilevato — pronto per la scrittura",writeTag:"Scrivi tag",replaceTag:"Sostituisci tag",writing:"Scrittura tag...",waiting:"In attesa di SpoolBuddy...",writeSuccess:"Tag scritto con successo!",writeFailed:"Scrittura fallita",queueFailed:"Impossibile accodare il comando di scrittura",tryAgain:"Riprova",cancel:"Annulla",replaceWarning:"Il vecchio tag verrà scollegato. Il nuovo tag lo sostituirà.",deviceOffline:"SpoolBuddy è offline",material:"Materiale",colorName:"Nome colore",color:"Colore",brand:"Marca",weight:"Peso (g)",createSpool:"Crea bobina",creating:"Creazione...",spoolCreated:"Bobina creata! Pronto per la scrittura.",createFailed:"Impossibile creare la bobina"}}},Bce={nav:{printers:"Impressoras",archives:"Arquivos",queue:"Fila",stats:"Estatísticas",profiles:"Perfis",maintenance:"Manutenção",projects:"Projetos",inventory:"Inventário",files:"Gerenciador de Arquivos",settings:"Configurações",system:"Sistema",collapseSidebar:"Recolher barra lateral",expandSidebar:"Expandir barra lateral",update:"Atualizar",updateAvailable:"Atualização disponível: v{{version}}",updateAvailableBanner:"Versão {{version}} está disponível!",viewUpdate:"Ver atualização",viewOnGithub:"Ver no GitHub",keyboardShortcuts:"Atalhos de teclado (?)",switchToLight:"Mudar para modo claro",switchToDark:"Mudar para modo escuro",smartSwitches:"Interruptores inteligentes",logout:"Sair"},common:{save:"Salvar",saving:"Salvando...",cancel:"Cancelar",delete:"Excluir",edit:"Editar",add:"Adicionar",close:"Fechar",confirm:"Confirmar",loading:"Carregando...",error:"Erro",success:"Sucesso",warning:"Aviso",enabled:"Ativado",disabled:"Desativado",yes:"Sim",no:"Não",on:"Ligado",off:"Desligado",all:"Todos",none:"Nenhum",search:"Pesquisar",filter:"Filtrar",sort:"Ordenar",refresh:"Atualizar",download:"Baixar",upload:"Enviar",actions:"Ações",status:"Status",name:"Nome",description:"Descrição",date:"Data",time:"Hora",hours:"Horas",minutes:"Minutos",seconds:"Segundos",days:"Dias",enable:"Ativar",disable:"Desativar",permissions:"Permissões",noPrinters:"Nenhuma impressora configurada",noData:"Nenhum dado disponível",linkNotFound:"Link não encontrado",required:"Obrigatório",optional:"Opcional",dismiss:"Dispensar",apply:"Aplicar",reset:"Redefinir",export:"Exportar",import:"Importar",clear:"Limpar",selectAll:"Selecionar tudo",deselectAll:"Desmarcar tudo",noChange:"— Sem alterações —",unchanged:"Inalterado",unassigned:"Não atribuído",unknown:"Desconhecido",unknownError:"Erro desconhecido",today:"Hoje",tomorrow:"Amanhã",asap:"O mais rápido possível",overdue:"Atrasado",now:"Agora",collapse:"Recolher",expand:"Expandir",viewArchive:"Ver arquivo",viewInFileManager:"Ver no Gerenciador de Arquivos",addedBy:"Adicionado por {{username}}",prints:"impressões",more:"+{{count}} mais",ascending:"Crescente",descending:"Decrescente",printer:"Impressora",remove:"Remover",type:"Tipo",print:"Imprimir",rename:"Renomear",move:"Mover",create:"Criar",duplicate:"Duplicar",left:"Esquerda",right:"Direita"},printers:{title:"Impressoras",addPrinter:"Adicionar Impressora",editPrinter:"Editar Impressora",deletePrinter:"Excluir Impressora",printerName:"Nome da Impressora",serialNumber:"Número de Série",ipAddress:"Endereço IP / Nome do Host",accessCode:"Código de Acesso",model:"Modelo",nozzleCount:"Número de Bicos",autoArchive:"Arquivamento Automático",status:{available:"Disponível",idle:"Ocioso",printing:"Imprimindo",paused:"Pausado",offline:"Offline",error:"Erro",finished:"Concluído",unknown:"Desconhecido"},temperatures:{nozzle:"Bico",bed:"Cama",chamber:"Câmara"},progress:"{{percent}}% concluído",timeRemaining:"{{time}} restante",deleteConfirm:'Tem certeza de que deseja excluir "{{name}}"?',maintenanceOk:"Manutenção OK",maintenanceWarning:"{{count}} aviso",maintenanceWarning_plural:"{{count}} avisos",maintenanceDue:"{{count}} devido",maintenanceDue_plural:"{{count}} devido",sort:{name:"Nome",status:"Status",model:"Modelo",location:"Localização",ascending:"Ordem crescente",descending:"Ordem decrescente"},cardSize:{small:"Cartões pequenos",medium:"Cartões médios",large:"Cartões grandes",extraLarge:"Cartões extra grandes"},hideOffline:"Ocultar offline",nextAvailable:"Próximo disponível",powerOn:"Ligar",offlinePrintersWithPlugs:"Impressoras offline com tomadas inteligentes",noPrintersConfigured:"Nenhuma impressora configurada ainda",readyToPrint:"Pronto para imprimir",external:"Externo",extL:"Ext-L",extR:"Ext-R",deleteArchives:"Excluir arquivos de impressão",noLabel:"Sem etiqueta",printPreview:"Pré-visualização de impressão",width:"Largura",height:"Altura",noObjectsFound:"Nenhum objeto encontrado",objectsLoadedOnPrintStart:"Objetos são carregados quando uma impressão começa",willBeSkipped:"Será ignorado",name:"Nome",serialCannotBeChanged:"Número de série não pode ser alterado",locationHelp:"Usado para agrupar impressoras e filtrar trabalhos na fila",wifiSignal:{veryWeak:"Muito fraco",weak:"Fraco",fair:"Regular",good:"Bom",excellent:"Excelente"},maintenanceUpToDate:"Toda a manutenção está em dia - Clique para ver",chamberLightOn:"Ligar luz da câmara",chamberLightOff:"Desligar luz da câmara",browseFiles:"Procurar arquivos da impressora",autoOffAfterPrint:"Desligamento automático após impressão",autoOffExecuted:"Desligamento automático executado - ligue a impressora para reiniciar",hmsErrors:"Erros HMS",viewHmsErrors:"Ver {{count}} erro(s) HMS",resume:"Retomar",pause:"Pausar",stop:"Parar",camera:"âmera",skipObject:"Ignorar objeto",reconnect:"Reconectar",mqttDebug:"Depuração MQTT",activeNozzle:"Ativo: {{nozzle}} bico",nozzleRack:"Suporte de bicos",nozzleDocked:"Acoplado",nozzleMounted:"Montado",nozzleActive:"Ativo",nozzleIdle:"Ocioso",nozzleDiameter:"Diâmetro",nozzleType:"Tipo",nozzleStatus:"Status",nozzleFilament:"Filamento",nozzleWear:"Desgaste",nozzleMaxTemp:"Temp Máx",nozzleSerial:"Serial",nozzleHardenedSteel:"Aço Endurecido",nozzleStainlessSteel:"Aço Inoxidável",nozzleTungstenCarbide:"Carboneto de Tungstênio",nozzleFlow:"Fluxo",nozzleHighFlow:"Alto Fluxo",nozzleStandardFlow:"Fluxo Padrão",firmwareUpdate:"Atualização de Firmware",firmwareInstructions:"No visor da impressora, vá para",firmwareNav:"Navegar para",settings:"Configurações",firmware:"Firmware",discoverPrinters:"Descobrir Impressoras",searching:"Procurando...",manualEntry:"Entrada Manual",addFromCloud:"Adicionar da Nuvem",toast:{printerDeleted:"Impressora excluída",printerAdded:"Impressora adicionada",printerUpdated:"Impressora atualizada",failedToDelete:"Falha ao excluir impressora",failedToAdd:"Falha ao adicionar impressora",failedToUpdate:"Falha ao atualizar impressora",commandSent:"Comando enviado",failedToSendCommand:"Falha ao enviar comando",turnedOn:"{{name}} ligado",failedToPowerOn:"Falha ao ligar {{name}}",scriptTriggered:"Script acionado",printStopped:"Impressão parada",printPaused:"Impressão pausada",printResumed:"Impressão retomada",referenceDeleted:"Referência excluída",detectionAreaSaved:"Área de detecção salva",failedToRunScript:"Falha ao executar script",failedToStopPrint:"Falha ao parar impressão",failedToPausePrint:"Falha ao pausar impressão",failedToResumePrint:"Falha ao retomar impressão",failedToControlChamberLight:"Falha ao controlar a luz da câmara",failedToUpdateSetting:"Falha ao atualizar configuração",failedToSkipObjects:"Falha ao ignorar objetos",failedToRereadRfid:"Falha ao reler RFID",failedToCheckPlate:"Falha ao verificar a placa",failedToUpdateLabel:"Falha ao atualizar etiqueta",failedToDeleteReference:"Falha ao excluir referência",failedToSaveDetectionArea:"Falha ao salvar área de detecção",plateCheckEnabled:"Verificação da placa ativada",plateCheckDisabled:"Verificação da placa desativada",calibrationSaved:"Calibração salva!",calibrationFailed:"Falha na calibração",rfidRereadInitiated:"Releitura de RFID iniciada"},connection:{connected:"Conectado",offline:"Offline"},queue:{inQueue:"{{count}} impressão na fila",inQueue_plural:"{{count}} impressões na fila"},controls:"Controles",rfid:{reread:"Releitura de RFID"},permission:{noAdd:"Você não tem permissão para adicionar impressoras",noEdit:"Você não tem permissão para editar impressoras",noDelete:"Você não tem permissão para excluir impressoras",noControl:"Você não tem permissão para controlar impressoras",noFiles:"Você não tem permissão para acessar arquivos de impressora",noAmsRfid:"Você não tem permissão para reler RFID AMS",noSmartPlugControl:"Você não tem permissão para controlar tomadas inteligentes",noCamera:"Você não tem permissão para visualizar câmeras"},modal:{addTitle:"Adicionar Impressora",editTitle:"Editar Impressora",myPrinter:"Minha Impressora",selectModel:"Selecionar modelo...",locationGroup:"Localização / Grupo (opcional)",locationPlaceholder:"ex.: Oficina, Escritório, Porão",autoArchiveLabel:"Arquivar automaticamente impressões concluídas",fromPrinterSettings:"A partir das configurações da impressora",modelOptional:"Modelo (opcional)",saveChanges:"Salvar alterações"},skipObjects:{tooltip:"Ignorar objetos",onlyWhilePrinting:"Ignorar objetos (apenas durante a impressão)",requiresMultiple:"Ignorar objetos (requer 2+ objetos)",title:"Ignorar Objetos",matchIdsInfo:"Correspondência de IDs com o display da sua impressora",printerShowsIds:"A tela da impressora mostra os IDs dos objetos na placa de construção",skipSelected:"Ignorar Selecionados",skipping:"Ignorando...",noObjectsSelected:"Nenhum objeto selecionado",selectObjectsToSkip:"Selecione os objetos que deseja ignorar na impressão atual",skipped:"Ignorado",objectsSkipped:"Objetos ignorados",activeCount:"{{count}} ativo",waitForLayer:"Aguarde a camada 2+ para ignorar objetos (atualmente na camada {{layer}})",skip:"Ignorar",confirmTitle:"Ignorar Objeto?",confirmMessage:'Tem certeza de que deseja ignorar "{{name}}"? Isso não pode ser desfeito.'},confirm:{deleteTitle:"Excluir Impressora",deleteMessage:'Tem certeza de que deseja excluir "{{name}}"? Isso removerá todas as configurações de conexão.',deleteArchivesNote:"Todo o histórico de impressão desta impressora será permanentemente excluído.",keepArchivesNote:"O histórico de impressão será mantido, mas não estará mais associado a esta impressora.",stopTitle:"Parar Impressão",stopMessage:'Tem certeza de que deseja parar a impressão atual em "{{name}}"? Isso cancelará o trabalho de impressão.',stopButton:"Parar Impressão",pauseTitle:"Pausar Impressão",pauseMessage:'Tem certeza de que deseja pausar a impressão atual em "{{name}}"?',pauseButton:"Pausar Impressão",resumeTitle:"Retomar Impressão",resumeMessage:'Tem certeza de que deseja retomar a impressão em "{{name}}"?',resumeButton:"Retomar Impressão",powerOnTitle:"Ligar Impressora",powerOnMessage:'Tem certeza de que deseja ligar a impressora "{{name}}"?',powerOnButton:"Ligar",powerOffTitle:"Desligar Impressora",powerOffMessage:'Tem certeza de que deseja desligar a impressora "{{name}}"?',powerOffWarning:'AVISO: "{{name}}" está imprimindo no momento! Tem certeza de que deseja desligar a impressora? Isso interromperá a impressão e pode danificar a impressora.',powerOffButton:"Desligar"},discovery:{title:"Descobrir Impressoras",searching:"Procurando...",scanning:"Escaneando...",scanProgress:"Escaneando... {{scanned}}/{{total}}",foundPrinters:"{{count}} impressora(s) encontrada(s)",noPrintersFound:"Nenhuma impressora encontrada",noPrintersFoundSubnet:"Nenhuma impressora encontrada na sub-rede especificada.",noPrintersFoundNetwork:"Nenhuma impressora encontrada na rede.",allConfigured:"Todas as impressoras descobertas já estão configuradas.",alreadyAdded:"Já adicionada",select:"Selecionar",manualEntry:"Entrada Manual",addFromCloud:"Adicionar da Nuvem",subnetToScan:"Sub-rede para escanear",dockerNote:"Docker detectado. Insira a sub-rede da sua impressora em notação CIDR. Requer network_mode: host no docker-compose.yml.",scanSubnet:"Escanear Sub-rede para Impressoras",discoverNetwork:"Descobrir Impressoras na Rede",scanningSubnet:"Escaneando sub-rede para impressoras Bambu...",scanningNetwork:"Escaneando rede...",serialRequired:"Serial necessário",unknown:"Desconhecido",failedToStart:"Falha ao iniciar a descoberta"},filaments:"Filamentos",openCameraOverlay:"Abrir sobreposição da câmera",openCameraWindow:"Abrir câmera em nova janela",firmwareUpdateAvailable:"Atualização de firmware disponível: {{current}} → {{latest}}",firmwareUpToDate:"Firmware {{version}} — Atualizado",firmwareUpdateButton:"Atualizar",plateDetection:{noPermission:"Você não tem permissão para atualizar impressoras",enabledClick:"Verificação da placa ativada - Clique para desativar",disabledClick:"Verificação da placa desativada - Clique para ativar",manageCalibration:"Gerenciar calibração da detecção da placa",calibrationRequired:"Calibração necessária",calibrationInstructions:"Certifique-se de que a placa de construção esteja <strong>completamente vazia</strong>, em seguida clique em Calibrar.",calibrationDescription:"A calibração captura uma imagem de referência da placa vazia. Verificações futuras compararão com esta referência para detectar objetos.",calibrationTip:"<strong>Dica:</strong> Você pode armazenar até 5 calibrações para diferentes placas. O sistema usa automaticamente a melhor correspondência ao verificar.",plateEmpty:"A placa parece vazia",objectsDetected:"Objetos detectados na placa",confidence:"Confiança",difference:"Diferença",analysisPreview:"Pré-visualização da análise:",analysisLegend:"Caixa verde = área de detecção, Sobreposição vermelha = diferenças em relação à calibração",savedReferences:"Referências salvas ({{count}}/{{max}})",deleteReference:"Excluir referência",labelPlaceholder:"Etiqueta...",clickToEdit:"{{label}} - Clique para editar",clickToAddLabel:"Clique para adicionar etiqueta"},fans:{partCooling:"Ventilador de resfriamento da peça",auxiliary:"Ventilador auxiliar",chamber:"Ventilador da câmara"},clickToViewHmsErrors:"Clique para ver erros do HMS",estimatedCompletion:"Tempo estimado de conclusão",slotOptions:"Opções de slot",firmwareModal:{title:"Atualização de Firmware",titleUpToDate:"Informações do Firmware",currentVersion:"Atual:",latestVersion:"Última:",releaseNotes:"Notas de Lançamento",checkingPrereqs:"Verificando pré-requisitos...",sdCardReady:"Cartão SD pronto. Clique abaixo para enviar o firmware.",uploadedSuccess:"Firmware enviado para o cartão SD!",applyInstructions:"Para aplicar a atualização na sua impressora:",step1:"Na tela sensível ao toque da impressora, vá para <strong>Configurações</strong>",step2:"Navegue até <strong>Firmware</strong>",step3:"Selecione <strong>Atualizar a partir do cartão SD</strong>",step4:"A atualização levará de 10 a 20 minutos",done:"Concluído",starting:"Iniciando...",uploadFirmware:"Enviar Firmware",uploadFailed:"Falha ao iniciar o envio: {{error}}",uploadedToast:"Firmware enviado! Inicie a atualização na tela da impressora."},accessCodePlaceholder:"Deixe vazio para manter o atual",roi:{title:"Área de Detecção (ROI)",xStart:"Início X",yStart:"Início Y",width:"Largura",height:"Altura",instruction:"Ajuste a área de detecção para focar na placa de construção. A caixa verde na pré-visualização mostra a área atual."},developerModeWarning:"O modo desenvolvedor LAN não está ativado em: {{names}}. Alguns recursos podem não funcionar.",howToEnable:"Como ativar"},archives:{title:"Arquivos de Impressão",searchPlaceholder:"Pesquisar arquivos...",filterByPrinter:"Filtrar por impressora",filterByStatus:"Filtrar por status",sortBy:"Ordenar por",sortNewest:"Mais recentes primeiro",sortOldest:"Mais antigos primeiro",sortName:"Nome",sortDuration:"Duração",sortLargest:"Maiores primeiro",sortSmallest:"Menores primeiro",sortSize:"Tamanho",noArchives:"Nenhum arquivo encontrado",noArchivesSearch:"Nenhum arquivo corresponde à sua pesquisa",noArchivesYet:"Ainda não há arquivos",loadingArchives:"Carregando arquivos...",releaseToUpload:"Solte para enviar",showAll:"Mostrar todos",showFavoritesOnly:"Mostrar apenas favoritos",gridView:"Visualização em grade",listView:"Visualização em lista",calendarView:"Visualização em calendário",logView:"Registro de impressão",manageTags:"Gerenciar etiquetas",showFailedPrints:"Mostrar impressões falhas",hideFailedPrints:"Ocultar impressões falhas",printTime:"Tempo de impressão",filamentUsed:"Filamento usado",cost:"Custo",reprint:"Reimprimir",preview:"Pré-visualizar",deleteArchive:"Excluir arquivo",deleteConfirm:"Tem certeza de que deseja excluir este arquivo?",favorite:"Favorito",unfavorite:"Remover dos favoritos",viewDetails:"Ver detalhes",status:{completed:"Concluído",failed:"Falhou",stopped:"Parado"},toast:{source3mfAttached:"Arquivo de origem 3MF anexado: {{filename}}",failedUploadSource3mf:"Falha ao enviar arquivo de origem 3MF",source3mfRemoved:"Arquivo de origem 3MF removido",failedRemoveSource3mf:"Falha ao remover arquivo de origem 3MF",f3dAttached:"F3D anexado: {{filename}}",failedUploadF3d:"Falha ao enviar F3D",f3dRemoved:"F3D removido",failedRemoveF3d:"Falha ao remover F3D",timelapseAttached:"Timelapse anexado: {{filename}}",timelapseAlreadyAttached:"Timelapse já anexado",noMatchingTimelapse:"Nenhum timelapse correspondente encontrado",failedScanTimelapse:"Falha ao escanear timelapse",failedAttachTimelapse:"Falha ao anexar timelapse",timelapseRemoved:"Timelapse removido",failedRemoveTimelapse:"Falha ao remover timelapse",timelapseUploaded:"Timelapse enviado: {{filename}}",failedUploadTimelapse:"Falha ao enviar timelapse",archiveDeleted:"Arquivo excluído",failedDeleteArchive:"Falha ao excluir arquivo",addedToFavorites:"Adicionado aos favoritos",removedFromFavorites:"Removido dos favoritos",projectUpdated:"Projeto atualizado",failedUpdateProject:"Falha ao atualizar projeto",linkCopied:"Link copiado para a área de transferência",failedCopyLink:"Falha ao copiar link",photoDeleted:"Foto excluída",failedDeletePhoto:"Falha ao excluir foto",failedDeleteArchives:"Falha ao excluir arquivos",failedUpdateFavorites:"Falha ao atualizar favoritos",exportDownloaded:"Exportação baixada",exportFailed:"Falha na exportação"},menu:{print:"Imprimir",schedule:"Agendar",openInBambuStudio:"Abrir no Slicer",slice:"Fatiar",externalLink:"Link externo",viewOnMakerWorld:"Ver no MakerWorld",preview3d:"Pré-visualização 3D",viewTimelapse:"Ver Timelapse",scanForTimelapse:"Escanear Timelapse",uploadTimelapse:"Enviar Timelapse",removeTimelapse:"Remover Timelapse",downloadSource3mf:"Baixar Source 3MF",uploadSource3mf:"Enviar Source 3MF",replaceSource3mf:"Substituir Source 3MF",removeSource3mf:"Remover Source 3MF",uploadF3d:"Enviar F3D",replaceF3d:"Substituir F3D",downloadF3d:"Baixar F3D",removeF3d:"Remover F3D",download:"Baixar",copyDownloadLink:"Copiar link de download",qrCode:"Qr Code",viewPhotos:"Ver fotos",viewPhotosCount:"Ver fotos ({{count}})",projectPage:"Página do projeto",addToFavorites:"Adicionar aos favoritos",removeFromFavorites:"Remover dos favoritos",edit:"Editar",goToProject:"Ir para o projeto: {{name}}",addToProject:"Adicionar ao projeto",removeFromProject:"Remover do projeto",loading:"Carregando...",noProjectsAvailable:"Nenhum projeto disponível",select:"Selecionar",deselect:"Desmarcar",delete:"Excluir"},permission:{noReprint:"Você não tem permissão para reimprimir este arquivo",noAddToQueue:"Você não tem permissão para adicionar à fila",noUpdateArchives:"Você não tem permissão para atualizar arquivos",noUploadFiles:"Você não tem permissão para enviar arquivos",noDownload:"Você não tem permissão para baixar arquivos",noCopyLink:"Você não tem permissão para copiar links de download",noDelete:"Você não tem permissão para excluir este arquivo",noCreate:"Você não tem permissão para criar arquivos"},card:{previousPlate:"Placa anterior",nextPlate:"Próxima placa",plateNumber:"Placa {{index}}",moreOptions:"Clique com o botão direito para mais opções",addToFavorites:"Adicionar aos favoritos",removeFromFavorites:"Remover dos favoritos",cancelled:"cancelado",failed:"falha",duplicate:"duplicado",duplicateTitle:"Este modelo já foi impresso antes",openSource3mf:"Abrir source 3MF no Bambu Studio (clique com o botão direito para mais opções)",downloadF3d:"Baixar arquivo de design do Fusion 360",viewTimelapse:"Ver timelapse",viewPhoto:"Ver 1 foto",viewPhotos:"Ver {{count}} fotos",openFolder:"Abrir pasta: {{name}}",slicedFile:"Arquivo fatiado - pronto para imprimir",sourceFile:"Apenas arquivo fonte - nenhum mapeamento AMS disponível",gcode:"GCODE",source:"SOURCE",project:"Projeto: {{name}}",estimated:"Estimado: {{time}}",actual:"Real: {{time}}",accuracy:"Precisão: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} camada",layers:"{{count}} camadas",object:"{{count}} objeto",objects:"{{count}} objetos",slicedFor:"Fatiado para {{model}}",uploadedBy:"Enviado por",noPermissionReprint:"Você não tem permissão para reimprimir",noFileForReprint:"Nenhum arquivo 3MF disponível — o arquivo não pôde ser baixado da impressora quando a impressão foi registrada",noPermissionEdit:"Você não tem permissão para editar arquivos",noPermissionDelete:"Você não tem permissão para excluir arquivos",reprint:"Reimprimir",schedulePrint:"Agendar impressão",schedule:"Agendar",openInBambuStudio:"Abrir no Bambu Studio",openInBambuStudioToSlice:"Abrir no Bambu Studio para fatiar",slice:"Fatiar",externalLink:"Link externo",makerWorld:"MakerWorld: {{designer}}",viewProject:"Ver projeto",noExternalLink:"Nenhum link externo",preview3d:"Visualização 3D",download:"Baixar",edit:"Editar",delete:"Excluir"},modal:{deleteArchive:"Excluir Arquivo",deleteConfirm:'Tem certeza de que deseja excluir "{{name}}"? Esta ação não pode ser desfeita.',deleteButton:"Excluir",removeSource3mf:"Remover Source 3MF",removeSource3mfConfirm:'Tem certeza de que deseja remover o arquivo source 3MF de "{{name}}"? Isso excluirá o arquivo original do projeto do fatiador.',removeButton:"Remover",removeF3d:"Remover F3D",removeF3dConfirm:'Tem certeza de que deseja remover o arquivo de design do Fusion 360 de "{{name}}"?',removeTimelapse:"Remover Timelapse",removeTimelapseConfirm:'Tem certeza de que deseja remover o vídeo timelapse de "{{name}}"?',timelapse:"{{name}} - Timelapse",selectTimelapse:"Selecionar Timelapse",selectTimelapseDesc:"Nenhuma correspondência automática encontrada. Selecione o timelapse para esta impressão:",deleteArchives:"Excluir Arquivos",deleteArchivesConfirm:"Tem certeza de que deseja excluir {{count}} arquivo(s)? Esta ação não pode ser desfeita.",deleteCount:"Excluir {{count}}"},page:{title:"Arquivos",printsCount:"{{filtered}} de {{total}} impressões",dropFilesHere:"Solte arquivos .3mf aqui",releaseToUpload:"Solte para enviar",only3mfSupported:"Apenas arquivos .3mf são suportados",close:"Fechar",selected:"{{count}} selecionado(s)",selectAll:"Selecionar Todos",tags:"Tags",project:"Projeto",favorite:"Favorito",delete:"Excluir",toggledFavorites:"Favoritos alternados para {{count}} arquivo(s)",failedUpdateFavorites:"Falha ao atualizar favoritos",archivesDeleted:"{{count}} arquivo(s) excluído(s)",failedDeleteArchives:"Falha ao excluir arquivos",photoDeleted:"Foto excluída",failedDeletePhoto:"Falha ao excluir foto"},list:{name:"Nome",printer:"Impressora",date:"Data",size:"Tamanho",actions:"Ações",hasTimelapse:"Possui timelapse"},log:{date:"Data",printName:"Nome da Impressão",printer:"Impressora",user:"Usuário",status:"Status",duration:"Duração",filament:"Filamento",allPrinters:"Todas as Impressoras",allUsers:"Todos os Usuários",allStatuses:"Todos os Status",cancelled:"Cancelado",skipped:"Ignorado",dateFrom:"De",dateTo:"Até",noEntries:"Nenhuma entrada de registro de impressão encontrada",showing:"Mostrando {{count}} de {{total}} entradas",rowsPerPage:"Linhas",page:"Página",prev:"Anterior",next:"Próxima",clearLog:"Limpar Registro",clearLogTitle:"Limpar Registro de Impressão",clearLogConfirm:"Todas as entradas do registro de impressão serão permanentemente excluídas. Arquivos e itens da fila não serão afetados. Esta ação não pode ser desfeita. Tem certeza?",clearLogButton:"Limpar Tudo",cleared:"{{count}} entradas do registro de impressão limpas",clearFailed:"Falha ao limpar o registro de impressão"}},queue:{title:"Fila de Impressão",subtitle:"Agende e gerencie seus trabalhos de impressão",addToQueue:"Adicionar à Fila",print:"Imprimir",reprint:"Reimprimir",schedulePrint:"Agendar Impressão",editQueueItem:"Editar Item da Fila",printToPrinters:"Imprimir para {{count}} Impressoras",queueToPrinters:"Adicionar à Fila para {{count}} Impressoras",sending:"Enviando...",sendingProgress:"Enviando {{current}}/{{total}}...",adding:"Adicionando...",addingProgress:"Adicionando {{current}}/{{total}}...",savingProgress:"Salvando {{current}}/{{total}}...",clearQueue:"Limpar Fila",clearHistory:"Limpar Histórico",emptyQueue:"Fila vazia",position:"Posição",scheduledTime:"Hora Agendada",moveUp:"Mover para Cima",moveDown:"Mover para Baixo",startNow:"Iniciar Agora",printingInProgress:"Impressão em andamento...",viewArchive:"Ver Arquivo",viewInFileManager:"Ver no Gerenciador de Arquivos",itemCount:"{{count}} item",itemCount_plural:"{{count}} itens",dragToReorder:"Arraste para reordenar (apenas ASAP)",reorderHint:"A posição afeta apenas itens ASAP. Itens agendados são executados no horário definido.",addedBy:"Adicionado por {{name}}",nextInQueue:"Próximo na fila",clearPlate:"Limpar Placa e Iniciar Próximo",clearPlateSuccess:"Placa limpa — pronta para a próxima impressão",plateReady:"Placa limpa — pronta para a próxima impressão",plateNumber:"Placa {{index}}",sections:{currentlyPrinting:"Imprimindo Atualmente",queued:"Na Fila",history:"Histórico"},status:{pending:"Pendente",waiting:"Aguardando",printing:"Imprimindo",paused:"Pausado",completed:"Concluído",failed:"Falhou",skipped:"Ignorado",cancelled:"Cancelado"},summary:{printing:"Imprimindo",queued:"Na Fila",totalTime:"Tempo Total da Fila",totalWeight:"Peso Total da Fila",history:"Histórico"},filter:{allPrinters:"Todas as Impressoras",unassigned:"Não Atribuído",allStatus:"Todos os Status",allLocations:"Todos os Locais",any:"Qualquer"},sort:{byPosition:"Ordenar por Posição",byName:"Ordenar por Nome",byPrinter:"Ordenar por Impressora",bySchedule:"Ordenar por Agendamento",byDate:"Ordenar por Data",ascendingOldest:"Crescente (mais antigo primeiro)",descendingNewest:"Decrescente (mais recente primeiro)"},badges:{staged:"Preparado (início manual)",requiresPrevious:"Requer sucesso anterior",autoPowerOff:"Desligamento automático"},empty:{title:"Nenhuma impressão agendada",description:'Agende uma impressão a partir da página de Arquivos usando a opção "Agendar" no menu de contexto, ou arraste e solte arquivos para começar.'},time:{asap:"ASAP",overdue:"Atrasado",now:"Agora",lessThanMinute:"Em menos de um minuto",inMinutes:"Em {{count}} min",inHours:"Em {{count}} horas"},actions:{stopPrint:"Parar Impressão",startPrint:"Iniciar Impressão",requeue:"Reenfileirar"},bulkEdit:{title:"Editar {{count}} Item",title_plural:"Editar {{count}} Itens",description:"Apenas as configurações alteradas serão aplicadas aos itens selecionados.",printer:"Impressora",noChange:"— Sem alterações —",queueOptions:"Opções de Fila",staged:"Preparado (início manual)",autoPowerOff:"Desligamento automático após impressão",requirePrevious:"Requer sucesso anterior",printOptions:"Opções de Impressão",bedLevelling:"Nivelamento da Mesa",flowCalibration:"Calibração de Fluxo",vibrationCalibration:"Calibração de Vibração",layerInspection:"Inspeção da Primeira Camada",timelapse:"Timelapse",useAms:"Usar AMS",applyChanges:"Aplicar Alterações",selectAll:"Selecionar Todos",deselectAll:"Desmarcar Todos",selected:"{{count}} selecionado(s)",editSelected:"Editar Selecionados",cancelSelected:"Cancelar Selecionados"},confirm:{cancelTitle:"Cancelar Impressão Agendada",cancelMessage:'Tem certeza de que deseja cancelar "{{name}}"?',stopTitle:"Parar Impressão",stopMessage:'Tem certeza de que deseja parar a impressão atual "{{name}}"? Isso cancelará o trabalho de impressão na impressora.',removeTitle:"Remover do Histórico",removeMessage:'Tem certeza de que deseja remover "{{name}}" do histórico da fila?',clearHistoryTitle:"Limpar Histórico",clearHistoryMessage:"Tem certeza de que deseja remover todos os {{count}} itens do histórico?",cancelButton:"Cancelar Impressão",stopButton:"Parar Impressão",thisPrint:"esta impressão",thisItem:"este item"},toast:{cancelled:"Item da fila cancelado",cancelFailed:"Falha ao cancelar item",removed:"Item da fila removido",removeFailed:"Falha ao remover item",stopped:"Impressão parada",stopFailed:"Falha ao parar impressão",released:"Impressão liberada para a fila",startFailed:"Falha ao iniciar impressão",reorderFailed:"Falha ao reordenar fila",historyCleared:"Limpar {{count}} item(s) do histórico",clearHistoryFailed:"Falha ao limpar histórico",updateFailed:"Falha ao atualizar itens",bulkCancelled:"Cancelado {{count}} item(s)",bulkCancelFailed:"Falha ao cancelar itens"},permissions:{noStopPrint:"Você não tem permissão para parar impressões",noStartPrint:"Você não tem permissão para iniciar impressões",noEdit:"Você não tem permissão para editar este item da fila",noCancel:"Você não tem permissão para cancelar este item da fila",noRequeue:"Você não tem permissão para reenfileirar itens",noRemove:"Você não tem permissão para remover este item da fila",noClearHistory:"Você não tem permissão para limpar todo o histórico",noEditItems:"Você não tem permissão para editar itens da fila",noCancelItems:"Você não tem permissão para cancelar itens da fila"}},backgroundDispatch:{unknownFile:"Unknown file",unknownPrinter:"Unknown printer",startingPrints:"Starting prints",progressSummary:"{{complete}}/{{total}} complete • Dispatched: {{dispatched}} • Processing: {{processing}}",expandDetails:"Expand dispatch details",collapseDetails:"Collapse dispatch details",dismissToast:"Dismiss dispatch toast",cancelDispatchJob:"Cancel dispatch job",cancel:"Cancel",cancelling:"Cancelling…",status:{dispatched:"Dispatched",processing:"Processing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"},toast:{cancellingUpload:"Cancelling upload...",cancelled:"Dispatch cancelled",cancelFailed:"Failed to cancel dispatch",completeWithFailures:"Background dispatch complete: {{completed}} succeeded, {{failed}} failed",completeSuccess:"Background dispatch complete: {{completed}} succeeded"}},stats:{title:"Dashboard",subtitle:"Arraste os widgets para reorganizar. Clique no ícone de olho para ocultar.",overview:"Visão Geral",totalPrints:"Total de Impressões",successRate:"Taxa de Sucesso",totalPrintTime:"Tempo Total de Impressão",printTime:"Tempo de Impressão",totalFilament:"Filamento Total Utilizado",filamentUsed:"Filamento Utilizado",filamentCost:"Custo do Filamento",totalCost:"Custo Total",energyUsed:"Energia Utilizada",energyCost:"Custo da Energia",averagePrintTime:"Tempo Médio de Impressão",printsPerDay:"Impressões por Dia",byPrinter:"Por Impressora",printsByPrinter:"Impressões por Impressora",byMaterial:"Por Material",byMonth:"Por Mês",last7Days:"Últimos 7 Dias",last30Days:"Últimos 30 Dias",last90Days:"Últimos 90 Dias",allTime:"Todo o Tempo",quickStats:"Estatísticas Rápidas",printActivity:"Atividade de Impressão",filamentTypes:"Tipos de Filamento",filamentTrends:"Tendências de Filamento",failureAnalysis:"Análise de Falhas",timeAccuracy:"Precisão do Tempo",successful:"Bem-sucedido:",failed:"Falhou:",perfectEstimate:"100% = estimativa perfeita",noTimeAccuracyData:"Nenhum dado de precisão de tempo disponível",noFilamentData:"Nenhum dado de filamento disponível",noPrinterData:"Nenhum dado de impressora disponível",noPrintData:"Nenhum dado de impressão disponível",noPrintDataLast30Days:"Nenhum dado de impressão nos últimos 30 dias",failureReasons:"Razões de Falha",topFailureReasons:"Principais Razões de Falha",failedPrintsCount:"{{failed}} / {{total}} impressões falharam",lastWeekRate:"Última semana: {{rate}}%",resetLayout:"Redefinir Layout",recalculateCosts:"Recalcular Custos",recalculateCostsHint:"Recalcular todos os custos do arquivo usando os preços atuais do filamento",exportStats:"Exportar Estatísticas",exportAsCsv:"Exportar como CSV",exportAsExcel:"Exportar como Excel",hiddenCount:"{{count}} Oculto",exportDownloaded:"Exportação baixada",exportFailed:"Falha na exportação",layoutReset:"Layout redefinido",recalculatedCosts:"Custos recalculados para {{count}} arquivos",recalculateFailed:"Falha ao recalcular custos",loadingStats:"Carregando estatísticas...",noPermissionResetLayout:"Você não tem permissão para redefinir o layout",noPermissionRecalculate:"Você não tem permissão para recalcular custos",noPrintDataInRange:"Sem dados no período selecionado",periodFilament:"Filamento usado",periodCost:"Custo",avgPerPrint:"Média por impressão",usageOverTime:"Uso ao longo do tempo",filamentByWeight:"Peso",printDuration:"Duração da impressão",printerUtilization:"Utilização da impressora",filamentSuccess:"Sucesso por material",printHabits:"Hábitos de impressão",printTimeOfDay:"Horário de impressão",colorDistribution:"Distribuição de cores",noColorData:"Nenhum dado de cor disponível",records:"Recordes",longestPrint:"Impressão mais longa",heaviestPrint:"Impressão mais pesada",mostExpensivePrint:"Mais cara",busiestDay:"Dia mais movimentado",successStreak:"Sequência de sucesso",streakPrint:"impressão consecutiva",streakPrints:"{{count}} impressões consecutivas",printerStats:"Estatísticas da impressora",hours:"horas",avgPrints:"Méd. impressões",noArchiveData:"Nenhum dado de impressão disponível",filamentByTime:"Tempo",avgWeight:"Méd. peso",avgTime:"Méd. tempo",filamentByPrints:"Impressões",timeframe:{today:"Hoje","this-week":"Esta semana","this-month":"Este mês","last-7":"Últimos 7 dias","last-30":"Últimos 30 dias","last-90":"Últimos 90 dias","this-year":"Este ano","all-time":"Todo o período",custom:"Personalizado",from:"De",to:"Até"}},maintenance:{title:"Manutenção",overview:"Visão Geral",allOk:"Todas as manutenções estão em dia",dueCount:"{{count}} item pendente",dueCount_plural:"{{count}} itens pendentes",warningCount:"{{count}} aviso",warningCount_plural:"{{count}} avisos",totalPrintTime:"Tempo Total de Impressão",nextMaintenance:"Próxima Manutenção",nothingDue:"Nada pendente",tasks:"Tarefas",lastPerformed:"Última execução",interval:"Intervalo",hoursRemaining:"{{hours}}h restantes",hoursOverdue:"{{hours}}h atrasadas",markDone:"Marcar como Concluída",performMaintenance:"Realizar Manutenção",history:"Histórico",noHistory:"Nenhum histórico de manutenção",editPrintHours:"Editar Horas de Impressão",currentHours:"Horas Atuais",statusTab:"Status",settingsTab:"Configurações",overdueCount:"{{count}} atrasado",dueSoonCount:"{{count}} prestes a vencer",dueSoon:"Prestes a vencer",allGood:"Tudo certo",overdueBy:"Atrasado por {{duration}}",dueIn:"Vence em {{duration}}",timeLeft:"{{duration}} restantes",day:"1 dia",days:"{{count}} dias",week:"1 semana",weeks:"{{count}} semanas",month:"1 mês",months:"{{count}} meses",year:"1 ano",maintenanceTypes:"Tipos de Manutenção",maintenanceTypesDescription:"Tipos de sistema e suas tarefas de manutenção personalizadas",addCustomType:"Adicionar Tipo Personalizado",restoreDefaults:"Restaurar Tarefas Padrão",intervalType:"Tipo de Intervalo",intervalValue:"Intervalo ({{type}})",icon:"Icon",documentationLink:"Link da Documentação (opcional)",assignToPrinters:"Atribuir a Impressoras",selectAtLeastOnePrinter:"Selecione pelo menos uma impressora",addType:"Adicionar Tipo",custom:"Personalizado",printHours:"Horas de Impressão",calendarDays:"Dias de Calendário",exampleName:"ex., Substituir Filtro HEPA",viewDocumentation:"Ver documentação",timeBasedInterval:"Intervalo baseado em tempo",intervalOverrides:"Substituições de Intervalo",intervalOverridesDescription:"Personalize os intervalos para impressoras específicas",assignedToPrinters:"Atribuído a impressoras:",noPrintersAssigned:"Nenhuma impressora atribuída",addPrinterShort:"Adicionar:",printersAssignedClick:"{{count}} impressora(s) atribuída(s) - clique para gerenciar",removeFromPrinter:"Remover desta impressora",types:{lubricateCarbonRods:"Lubricar Barras de Carbono",lubricateRails:"Lubricar Trilhos Lineares",cleanNozzle:"Limpar Bico/Hotend",checkBelts:"Verificar Tensão das Correias",cleanBuildPlate:"Limpar Plataforma de Impressão",checkExtruder:"Verificar Engrenagens do Extrusor",checkCooling:"Verificar Ventiladores de Resfriamento",generalInspection:"Inspeção Geral",cleanCarbonRods:"Limpar Barras de Carbono",cleanLinearRails:"Limpar Trilhos Lineares",checkPtfeTube:"Verificar Tubo PTFE",replaceHepaFilter:"Substituir Filtro HEPA",replaceCarbonFilter:"Substituir Filtro de Carbono",lubricateLeftNozzleRail:"Lubrificar Trilho do Bico Esquerdo"},maintenanceComplete:"Manutenção marcada como concluída",typeUpdated:"Tipo de manutenção atualizado",typeDeleted:"Tipo de manutenção excluído",defaultsRestored:"Restauradas {{count}} tarefa(s) padrão",printHoursUpdated:"Horas de impressão atualizadas",printerAssigned:"Impressora atribuída",printerRemoved:"Impressora removida",deleteTypeConfirm:'Excluir "{{name}}"?',deleteSystemTypeTitle:"Excluir tarefa de manutenção padrão?",deleteSystemTypeMessage:'Tem certeza de que deseja excluir a tarefa de manutenção padrão "{{name}}"?',noPermissionUpdate:"Você não tem permissão para atualizar itens de manutenção",noPermissionPerform:"Você não tem permissão para realizar manutenção",noPermissionEditTypes:"Você não tem permissão para editar tipos de manutenção",noPermissionDeleteTypes:"Você não tem permissão para excluir tipos de manutenção",noPermissionEditHours:"Você não tem permissão para editar horas de impressão",noPermissionRemovePrinter:"Você não tem permissão para remover atribuições de impressora",noPermissionAssignPrinter:"Você não tem permissão para atribuir impressoras",noPermissionEditIntervals:"Você não tem permissão para editar intervalos",configureSettings:"Configure tipos de manutenção e intervalos"},settings:{title:"Configurações",general:"Geral",tabs:{general:"Geral",smartPlugs:"Tomadas Inteligentes",notifications:"Notificações",filament:"Filamento",network:"Rede",apiKeys:"Chaves API",virtualPrinter:"Impressora Virtual",users:"Autenticação",backup:"Backup",emailAuth:"Autenticação por Email"},email:{smtpSettings:"Configuração SMTP",smtpHost:"Servidor SMTP",smtpPort:"Porta SMTP",security:"Segurança",authentication:"Autenticação",username:"Nome de Usuário",password:"Senha",fromEmail:"Email de Remetente",fromName:"Nome de Remetente",testConnection:"Testar Conexão SMTP",testRecipient:"Email de Teste",sendTest:"Enviar Email de Teste",sending:"Enviando...",save:"Salvar Configurações",saving:"Salvando...",advancedAuth:"Autenticação Avançada",advancedAuthEnabled:"Autenticação Avançada está habilitada",advancedAuthEnabledDesc:"Recursos de gerenciamento de usuários baseados em email estão ativos. Novos usuários receberão senhas geradas automaticamente por email, e os usuários podem redefinir suas senhas através do recurso de esqueci minha senha.",advancedAuthDisabled:"Autenticação Avançada está desabilitada",advancedAuthDisabledDesc:"Habilite a autenticação avançada para ativar recursos baseados em email para gerenciamento de usuários.",enable:"Habilitar",disable:"Desabilitar",feature1:"Senhas são geradas automaticamente e enviadas por email para novos usuários",feature2:"Usuários podem fazer login com nome de usuário ou email",feature3:"Recurso de esqueci minha senha está disponível",feature4:"Administradores podem redefinir senhas de usuários via email",errors:{requiredFields:"Por favor, preencha todos os campos obrigatórios",usernameRequired:"Nome de usuário é obrigatório quando a autenticação está habilitada",enterTestEmail:"Por favor, insira um endereço de email de teste",smtpServerAndEmail:"Por favor, preencha o servidor SMTP e o email de remetente antes de testar",usernamePasswordRequired:"Nome de usuário e senha são obrigatórios quando a autenticação está habilitada",configureSmtpFirst:"Por favor, configure e teste as configurações SMTP primeiro"},success:{settingsSaved:"Configurações SMTP salvas com sucesso"},securityOptions:{starttls:"STARTTLS (Porta 587)",ssl:"SSL/TLS (Porta 465)",none:"Nenhuma (Porta 25)"},authOptions:{enabled:"Habilitado",disabled:"Desabilitado"}},appearance:"Aparência",notifications:"Notificações",smartPlugs:"Tomadas Inteligentes",spoolman:"Spoolman",updates:"Atualizações",language:"Idioma",languageDescription:"Selecione seu idioma preferido",theme:"Tema",themeLight:"Claro",themeDark:"Escuro",themeSystem:"Sistema",defaultView:"Visualização Padrão",defaultViewDescription:"Página a ser exibida ao abrir o aplicativo",checkForUpdates:"Verificar Atualizações",autoUpdate:"Atualização Automática",currentVersion:"Versão Atual",latestVersion:"Última Versão",upToDate:"Você está atualizado",updateAvailable:"Atualização disponível",notificationLanguage:"Idioma das Notificações",notificationLanguageDescription:"Idioma para notificações push",bedCooledThreshold:"Limite de Resfriamento da Cama",bedCooledThresholdDescription:"Temperatura abaixo da qual a cama é considerada resfriada após uma impressão",notificationProviders:"Provedores de Notificação",addProvider:"Adicionar Provedor",editProvider:"Editar Provedor",providerType:"Tipo de Provedor",testNotification:"Testar Notificação",testSuccess:"Notificação de teste enviada com sucesso",testFailed:"Falha ao enviar notificação de teste",quietHours:"Horas de Silêncio",quietHoursDescription:"Não perturbe durante essas horas",quietHoursStart:"Início",quietHoursEnd:"Fim",events:{title:"Eventos de Notificação",printStart:"Impressão Iniciada",printComplete:"Impressão Concluída",printFailed:"Falha na Impressão",printStopped:"Impressão Interrompida",printProgress:"Marcos de Progresso",printProgressDescription:"Notificar em 25%, 50%, 75%",printerOffline:"Impressora Offline",printerError:"Erro na Impressora",filamentLow:"Filamento Baixo",maintenanceDue:"Manutenção Pendente",maintenanceDueDescription:"Notificar quando a manutenção for necessária"},smartPlug:{title:"Tomadas Inteligentes",add:"Adicionar Tomada Inteligente",edit:"Editar Tomada Inteligente",name:"Nome",ipAddress:"Endereço IP",linkedPrinter:"Impressora Vinculada",autoOn:"Ligar Automaticamente",autoOnDescription:"Ligar quando a impressão começar",autoOff:"Desligar Automaticamente",autoOffDescription:"Desligar após a conclusão da impressão",offDelay:"Atraso para Desligar",offDelayMinutes:"Minutos após a impressão",offDelayTemp:"Quando o bico estiver abaixo da temperatura",currentState:"Estado Atual",turnOn:"Ligar",turnOff:"Desligar"},filamentTracking:"Rastreamento de Filamento",filamentTrackingDesc:"Escolha como rastrear seus rolos de filamento. Você pode usar o inventário interno ou conectar a um servidor Spoolman externo.",trackingModeBuiltIn:"Inventário Interno",trackingModeBuiltInDesc:"Correspondência automática de RFID e rastreamento de uso incluídos",trackingModeSpoolmanDesc:"Servidor de gerenciamento de filamento externo",builtInFeatureRfid:"Detecta automaticamente rolos RFID da Bambu Lab no AMS",builtInFeatureUsage:"Rastreia o consumo de filamento por impressão",builtInFeatureCatalog:"Gerencia rolos, cores e perfis de fator K",builtInFeatureThirdParty:"Rolos de terceiros podem ser atribuídos aos rolos do inventário",amsSyncButton:"Sincronizar Pesos do AMS",amsSyncTitle:"Sincronizar Pesos dos Rolos do AMS",amsSyncMessage:"Isso substituirá todos os pesos dos rolos do inventário pelos valores atuais de % restante do AMS das impressoras conectadas. Use isso para recuperar dados de peso corrompidos. As impressoras devem estar online.",amsSyncing:"Sincronizando...",amsSyncSuccess:"{{synced}} rolo(s) sincronizado(s), {{skipped}} ignorado(s)",amsSyncError:"Falha ao sincronizar pesos do AMS",spoolmanUrl:"Spoolman URL",spoolmanUrlHint:"URL do seu servidor Spoolman (por exemplo, http://localhost:7912)",spoolmanConnected:"Conectado",spoolmanDisconnected:"Desconectado",status:"Status",connect:"Conectar",disconnect:"Desconectar",howSyncWorks:"Como a Sincronização Funciona",syncInfoRfidOnly:"Apenas rolos oficiais da Bambu Lab com RFID são sincronizados",syncInfoAutoCreate:"Novos rolos são criados automaticamente no Spoolman na primeira sincronização",syncInfoThirdPartySkipped:"Rolos não oficiais da Bambu Lab (terceiros, reabastecidos) são ignorados",linkingExistingSpools:"Vinculando Rolos Existentes",linkingExistingSpoolsDesc:'Para vincular rolos existentes do Spoolman ao seu AMS, passe o mouse sobre um slot do AMS e clique em "Vincular ao Spoolman".',syncMode:"Modo de Sincronização",syncModeAuto:"Automático",syncModeManual:"Apenas Manual",syncModeAutoDesc:"Os dados do AMS são sincronizados automaticamente quando alterações são detectadas",syncModeManualDesc:"Somente sincronize quando acionado manualmente",syncAmsData:"Sincronizar Dados do AMS",syncAmsDataDesc:"Sincronize manualmente os dados do AMS da impressora com o Spoolman",allPrinters:"Todas as Impressoras",noDefaultPrinter:"Sem padrão (perguntar a cada vez)",sidebarOrder:"Ordem da barra lateral",saveThumbnails:"Salvar miniaturas",captureFinishPhoto:"Capturar foto de conclusão",noPrintersConfigured:"Nenhuma impressora configurada",archiveMode:{always:"Sempre criar entrada de arquivo",never:"Nunca criar entrada de arquivo",ask:"Perguntar a cada vez"},checkForUpdatesLabel:"Verificar atualizações",checkPrinterFirmware:"Verificar firmware da impressora",includeBetaUpdates:"Incluir versões beta",includeBetaUpdatesDesc:"Notificar sobre versões beta e pré-lançamento ao verificar atualizações",enableRetry:"Habilitar tentativa",homeAssistantDescription:"Controlar tomadas inteligentes via Home Assistant",environmentManagedLabel:"(Gerenciado pelo Ambiente)",autoEnabledViaEnv:"Habilitado automaticamente via variáveis de ambiente",urlFromEnvReadOnly:"Valor definido pela variável de ambiente HA_URL (somente leitura)",tokenFromEnvReadOnly:"Valor definido pela variável de ambiente HA_TOKEN (somente leitura)",mqttConnectedTo:"Conectado a",prometheusDescription:"Expor dados da impressora no formato Prometheus",noSmartPlugsTitle:"Nenhuma tomada inteligente configurada",noSmartPlugsDescription:"Adicione uma tomada inteligente baseada em Tasmota para monitorar o consumo de energia e automatizar o controle de energia.",noProvidersTitle:"Nenhum provedor configurado",noProvidersDescription:"Adicione um provedor para receber alertas.",noTemplatesAvailable:"Nenhum modelo disponível. Reinicie o backend para gerar os modelos padrão.",apiPermissionView:"Visualizar status da impressora e fila",apiPermissionEdit:"Adicionar e remover itens da fila de impressão",apiKeysEmptyTitle:"Nenhuma chave API",apiKeysEmptyDescription:"Crie uma chave API para integrar com serviços externos.",noUsersFound:"Nenhum usuário encontrado",noGroupsFound:"Nenhum grupo encontrado",noGroupsAvailable:"Nenhum grupo disponível",passwordsDoNotMatch:"As senhas não coincidem",systemGroupWarning:"Os nomes dos grupos do sistema não podem ser alterados",authDisabledTitle:"Autenticação Desativada",authDisabledFeature1:"Exigir login para acessar o sistema",authDisabledFeature2:"Criar múltiplos usuários com permissões baseadas em grupos",authDisabledFeature3:"Controlar acesso com mais de 50 permissões granulares",userHasCreated:"Este usuário criou:",userItemsQuestion:"O que você gostaria de fazer com esses itens?",deleteUserConfirm:"Tem certeza de que deseja excluir este usuário?",actionCannotBeUndone:"Esta ação não pode ser desfeita.",addFirstSmartPlug:"Adicione sua primeira tomada inteligente",providers:"Provedores",log:"Registro",testAll:"Testar tudo",testResults:"Resultados do teste",testPassedCount:"{{count}} aprovado",testFailedCount:"{{count}} falhou",messageTemplates:"Modelos de mensagem",messageTemplatesDescription:"Personalize as mensagens de notificação para cada evento.",apiKeys:"Chaves API",apiKeysDescription:"Crie chaves API para integrações externas e webhooks.",createKey:"Criar Chave",apiKeyCreated:"Chave API criada com sucesso",apiKeyCopyWarning:"Copie esta chave agora - ela não será exibida novamente!",useInApiBrowser:"Usar no Navegador API",createNewApiKey:"Criar Nova Chave API",keyName:"Nome da Chave",keyNamePlaceholder:"e.g., Home Assistant, OctoPrint",readStatus:"Status de Leitura",readStatusDescription:"Visualizar status da impressora e fila",manageQueue:"Gerenciar Fila",manageQueueDescription:"Adicionar e remover itens da fila de impressão",controlPrinter:"Controlar Impressora",controlPrinterDescription:"Pausar, retomar e parar impressões",unnamedKey:"Chave Sem Nome",lastUsed:"Último uso",read:"Ler",control:"Controlar",createFirstKey:"Crie sua primeira chave",webhookEndpoints:"Endpoints de Webhook",webhookApiKeyHint:"Use sua chave API no cabeçalho X-API-Key.",webhook:{getAllStatus:"Obter status de todas as impressoras",getSpecificStatus:"Obter status de uma impressora específica",addToQueue:"Adicionar à fila de impressão",pausePrint:"Pausar impressão",resumePrint:"Retomar impressão",stopPrint:"Parar impressão"},apiBrowser:"Navegador API",apiBrowserDescription:"Explore e teste todos os endpoints de API disponíveis.",apiKeyForTesting:"Chave API para Teste",apiKeyPlaceholder:"Cole sua chave API aqui para testar endpoints autenticados...",apiKeyHint:"Esta chave será enviada como cabeçalho X-API-Key nas solicitações.",deleteApiKeyTitle:"Excluir Chave API",deleteApiKeyMessage:"Tem certeza de que deseja excluir esta chave API? Quaisquer integrações usando esta chave deixarão de funcionar.",deleteKey:"Excluir Chave",amsDisplayThresholds:"Limiares de Exibição AMS",amsThresholdsDescription:"Configure os limiares de cores para os indicadores de umidade e temperatura do AMS.",humidity:"Umidade",goodGreen:"Bom (verde)",fairOrange:"Razoável (laranja)",aboveFairBad:"Acima do limiar razoável mostra como vermelho (ruim)",temperature:"Temperatura",goodBlue:"Bom (azul)",aboveFairHot:"Acima do limiar razoável mostra como vermelho (quente)",historyRetention:"Retenção de Histórico",keepSensorHistory:"Manter histórico do sensor por",historyRetentionDescription:"Dados antigos de umidade e temperatura serão automaticamente excluídos",printModal:"Modal de Impressão",expandCustomMapping:"Expandir mapeamento personalizado por padrão",expandCustomMappingDescription:"Ao imprimir em várias impressoras, mostrar o mapeamento AMS por impressora expandido",authentication:"Autenticação",authEnabledDescription:"Sua instância está protegida com autenticação de usuário",authDisabledDescription:"Ative para exigir login e gerenciar o acesso dos usuários",authDisabledMessage:"Ative a autenticação para criar contas de usuário, gerenciar permissões e proteger sua instância do Bambuddy.",enableAuthentication:"Ativar Autenticação",currentUser:"Usuário Atual",changePassword:"Alterar Senha",admin:"Administrador",users:"Usuários",addUser:"Adicionar Usuário",groups:"Grupos",addGroup:"Adicionar Grupo",system:"Sistema",noDescription:"Sem descrição",userCount:"{{count}} usuários",permissionCount:"{{count}} permissões",createUser:"Criar Usuário",username:"Nome de Usuário",enterUsername:"Digite o nome de usuário",password:"Senha",enterPassword:"Digite a senha (mínimo 6 caracteres)",confirmPassword:"Confirmar Senha",confirmPasswordPlaceholder:"Confirme a senha",viewReleaseOnGitHub:"Ver lançamento no GitHub",turnAllPlugsOn:"Ligar todas as tomadas",turnAllPlugsOff:"Desligar todas as tomadas",clearNotificationLogs:"Limpar Logs de Notificação",clearLogsMessage:"Isso excluirá permanentemente todos os logs de notificação com mais de 30 dias. Esta ação não pode ser desfeita.",clearLogs:"Limpar Logs",resetUiPreferences:"Redefinir Preferências de UI",resetUiPreferencesMessage:"Isso redefinirá todas as preferências de UI para os padrões: ordem da barra lateral, tema, layout do painel, modos de exibição e preferências de classificação. Suas impressoras, arquivos e configurações do servidor NÃO serão afetados. A página será recarregada após a limpeza.",resetPreferences:"Redefinir Preferências",deleteGroupTitle:"Excluir Grupo",deleteGroupMessage:"Tem certeza de que deseja excluir este grupo? Usuários neste grupo perderão essas permissões.",deleteGroup:"Excluir Grupo",disableAuthenticationTitle:"Desativar Autenticação",disableAuthenticationMessage:"Tem certeza de que deseja desativar a autenticação? Isso tornará sua instância do Bambuddy acessível sem login. Todos os usuários permanecerão no banco de dados, mas a autenticação será desativada.",disableAuthentication:"Desativar Autenticação",configureBambuddy:"Configurar Bambuddy",systemDefault:"Padrão do Sistema",archiveSettings:"Configurações de Arquivo",newWindow:"Nova Janela",embeddedOverlay:"Sobreposição Incorporada",preferredSlicer:"Fatiador Preferido",preferredSlicerDescription:"Escolha qual aplicativo de fatiamento abrirá os arquivos",externalCameras:"Câmeras Externas",costTracking:"Rastreamento de Custos",printsOnly:"Apenas Impressões",totalConsumption:"Consumo Total",dataManagement:"Gerenciamento de Dados",storageUsage:"Uso de Armazenamento",storageUsageDescription:"Detalhamento do uso de dados por categoria",storageUsageTotal:"Total",storageUsageErrors:"Erros",storageUsageOtherBreakdown:"Outros (inclui ativos estáticos, scripts e arquivos de configuração)",storageUsageSystem:"Sistema",storageUsageData:"Dados",storageUsageUnavailable:"Informações de uso de armazenamento indisponíveis",clearNotificationLogsDescription:"Excluir logs de notificação com mais de 30 dias",resetUiPreferencesDescription:"Redefinir ordem da barra lateral, tema, modos de exibição e preferências de layout. Impressoras, arquivos e configurações não são afetados.",enableHomeAssistant:"Ativar Home Assistant",enableMqtt:"Ativar MQTT",useTls:"Usar TLS",enableMetricsEndpoint:"Ativar Endpoint de Métricas",availableMetrics:"Métricas Disponíveis",editUser:"Editar Usuário",deleteUserTitle:"Excluir Usuário",groupName:"Nome do Grupo",leaveEmptyForAnonymous:"Deixe vazio para anônimo",leaveEmptyForNoAuth:"Deixe vazio para sem autenticação",enterNewPassword:"Digite a nova senha",confirmNewPassword:"Confirme a nova senha",enterGroupName:"Digite o nome do grupo",enterDescriptionOptional:"Digite a descrição (opcional)",enterCurrentPassword:"Digite a senha atual",enterNewPasswordMin6:"Digite a nova senha (mínimo 6 caracteres)",toast:{keyCopied:"Chave copiada para a área de transferência",copyFailed:"Falha ao copiar a chave",keyAddedToBrowser:"Chave adicionada ao Navegador de API",clearLogsFailed:"Falha ao limpar logs",uiPreferencesReset:"Preferências de UI redefinidas. Atualizando...",authDisabled:"Autenticação desativada com sucesso",authDisableFailed:"Falha ao desativar a autenticação",apiKeyCreated:"Chave de API criada",apiKeyDeleted:"Chave de API excluída",userCreated:"Usuário criado com sucesso",userUpdated:"Usuário atualizado com sucesso",userDeleted:"Usuário excluído com sucesso",groupCreated:"Grupo criado com sucesso",groupUpdated:"Grupo atualizado com sucesso",groupDeleted:"Grupo excluído com sucesso",fillRequiredFields:"Por favor, preencha todos os campos obrigatórios",passwordsDoNotMatch:"As senhas não coincidem",passwordTooShort:"A senha deve ter pelo menos 6 caracteres",enterGroupName:"Por favor, insira um nome de grupo",settingsSaved:"Configurações salvas",cameraSettingsSaved:"Configurações da câmera salvas",enterCameraUrl:"Por favor, insira a URL da câmera",passwordChanged:"Senha alterada com sucesso",connectionFailed:"Falha na conexão",testFailed:"Falha no teste",cameraConnected:"Câmera conectada{{resolution}}"},testConnection:"Testar Conexão",catalog:{spoolCatalog:"Catálogo de Carretéis",spoolCatalogDescription:"Pesos de carretéis vazios por marca/tipo. Usado para pesquisa automática de peso ao adicionar carretéis.",searchCatalog:"Pesquisar no catálogo...",addNewEntry:"Adicionar Nova Entrada",namePlaceholder:"Nome (ex.: Bambu Lab - Plástico)",weight:"Peso",type:"Tipo",default:"Padrão",custom:"Personalizado",noMatch:"Nenhuma entrada corresponde à sua pesquisa",empty:"Nenhuma entrada no catálogo",deleteEntry:"Excluir Entrada",deleteConfirm:'Tem certeza de que deseja excluir "{{name}}"?',resetCatalog:"Redefinir Catálogo",resetConfirm:"Redefinir catálogo para os padrões? Isso removerá todas as entradas personalizadas.",loadFailed:"Falha ao carregar o catálogo de carretéis",nameWeightRequired:"Nome e peso são obrigatórios",entryAdded:"Entrada adicionada",addFailed:"Falha ao adicionar entrada",entryUpdated:"Entrada atualizada",updateFailed:"Falha ao atualizar entrada",entryDeleted:"Entrada excluída",deleteFailed:"Falha ao excluir entrada",resetSuccess:"Catálogo redefinido para os padrões",resetFailed:"Falha ao redefinir catálogo",exported:"Exportadas {{count}} entradas",imported:"Importadas {{added}} entradas ({{skipped}} ignoradas)",importFailed:"Falha ao importar: formato JSON inválido",exportTooltip:"Exportar catálogo para JSON",importTooltip:"Importar catálogo de JSON",resetTooltip:"Redefinir para os padrões"},colorCatalog:{title:"Catálogo de Cores",description:"Cores de filamento por fabricante/material. Usado para pesquisa automática de cores ao adicionar carretéis.",searchColors:"Pesquisar cores...",allManufacturers:"Todos os fabricantes",addNewColor:"Adicionar Nova Cor",manufacturer:"Fabricante",colorName:"Nome da Cor",hex:"Hex",materialOptional:"Material (opcional)",showing:"Mostrando {{filtered}} de {{total}} cores",noMatch:"Nenhuma cor corresponde à sua pesquisa",empty:"Nenhuma cor no catálogo",deleteColor:"Excluir Cor",deleteConfirm:'Tem certeza de que deseja excluir "{{name}}"?',resetCatalog:"Redefinir Catálogo de Cores",resetConfirm:"Redefinir catálogo para os padrões? Isso removerá todas as cores personalizadas.",sync:"Sincronizar",starting:"Iniciando...",syncTooltip:"Sincronizar do FilamentColors.xyz (2000+ cores, pode levar um minuto)",loadFailed:"Falha ao carregar o catálogo de cores",fieldsRequired:"Fabricante, nome da cor e cor hex são obrigatórios",colorAdded:"Cor adicionada",addFailed:"Falha ao adicionar cor",colorUpdated:"Cor atualizada",updateFailed:"Falha ao atualizar cor",colorDeleted:"Cor excluída",deleteFailed:"Falha ao excluir cor",resetSuccess:"Catálogo de cores redefinido para os padrões",resetFailed:"Falha ao redefinir catálogo",syncUpToDate:"Já está atualizado ({{count}} cores verificadas)",syncComplete:"Adicionadas {{added}} novas cores ({{skipped}} já existiam)",syncError:"Erro de sincronização",syncFailed:"Falha ao sincronizar do FilamentColors.xyz",exported:"Exportadas {{count}} cores",imported:"Importadas {{added}} cores ({{skipped}} ignoradas)",importFailed:"Falha ao importar: formato JSON inválido"}},notification:{printStarted:{title:"Impressão Iniciada",body:"{{printer}}: {{filename}} iniciou a impressão"},printCompleted:{title:"Impressão Concluída",body:"{{printer}}: {{filename}} foi concluída com sucesso"},printFailed:{title:"Falha na Impressão",body:"{{printer}}: {{filename}} falhou"},printStopped:{title:"Impressão Interrompida",body:"{{printer}}: {{filename}} foi interrompida"},printProgress:{title:"Progresso da Impressão",body:"{{printer}}: {{filename}} está {{percent}}% concluída"},printerOffline:{title:"Impressora Offline",body:"{{printer}} está offline"},printerError:{title:"Erro na Impressora",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filamento Baixo",body:"{{printer}}: O filamento está acabando"},maintenanceDue:{title:"Manutenção Pendente",body:"{{printer}}: {{items}} precisam de atenção"}},errors:{generic:"Algo deu errado",networkError:"Erro de rede. Por favor, verifique sua conexão.",notFound:"Não encontrado",unauthorized:"Não autorizado",serverError:"Erro no servidor",validationError:"Por favor, verifique sua entrada",printerConnectionFailed:"Falha ao conectar à impressora",saveFailed:"Falha ao salvar alterações",deleteFailed:"Falha ao excluir",loadFailed:"Falha ao carregar dados"},hmsErrors:{title:"Erros - {{name}}",noErrors:"Nenhum erro",viewOnWiki:"Ver no Bambu Lab Wiki",clearInstructions:"Limpe os erros na impressora para descartá-los aqui.",clearErrors:"Limpar Erros",clearSuccess:"Erros HMS limpos",clearFailed:"Falha ao limpar erros HMS"},mqttDebug:{title:"MQTT Log de Depuração",searchPlaceholder:"Pesquisar tópico ou payload...",noMessages:"Nenhuma mensagem registrada ainda",startLoggingHint:'Clique em "Iniciar Registro" para começar a capturar mensagens MQTT',noMessagesMatch:"Nenhuma mensagem corresponde ao seu filtro",adjustFilterHint:"Tente ajustar seus critérios de pesquisa ou filtro",incoming:"Entrada",outgoing:"Saída",loggingStopped:"Registro interrompido",loggingActive:"Registro ativo - as mensagens serão atualizadas automaticamente",startLogging:"Iniciar Registro",stopLogging:"Parar Registro",clearLog:"Limpar Registro",topic:"ópico",timestamp:"Carimbo de Data/Hora",direction:"Direção",all:"Todos"},printerFiles:{title:"Gerenciador de Arquivos",storageUsed:"Usado:",storageFree:"Livre:",filterPlaceholder:"Filtrar arquivos...",deleteButton:"Excluir",deleteFiles:"Excluir {{count}} arquivos",deleteFileConfirm:'Excluir "{{name}}"? Isso não pode ser desfeito.',deleteFilesConfirm:"Excluir {{count}} arquivos selecionados? Isso não pode ser desfeito.",noFiles:"Nenhum arquivo na impressora",loadingFiles:"Carregando arquivos...",failedToLoad:"Falha ao carregar arquivos",toast:{filesDeleted:"Arquivos excluídos: {{count}}",deleteFailed:"Falha ao excluir: {{error}}"}},confirm:{delete:"Tem certeza de que deseja excluir isso?",unsavedChanges:"Você tem alterações não salvas. Tem certeza de que deseja sair?",clearQueue:"Tem certeza de que deseja limpar a fila?"},login:{title:"Bambuddy Login",subtitle:"Faça login na sua conta",username:"Nome de usuário",usernamePlaceholder:"Digite seu nome de usuário",usernameOrEmail:"Nome de usuário ou Email",usernameOrEmailPlaceholder:"Nome de usuário ou Email",password:"Senha",passwordPlaceholder:"Digite sua senha",signIn:"Entrar",signingIn:"Entrando...",forgotPassword:"Esqueceu sua senha?",loginSuccess:"Login realizado com sucesso",loginFailed:"Falha no login",enterCredentials:"Por favor, insira nome de usuário e senha",forgotPasswordTitle:"Esqueceu a Senha",forgotPasswordMessage:"Se você esqueceu sua senha, entre em contato com o administrador do sistema para redefini-la.",forgotPasswordEmailMessage:"Digite seu endereço de email e enviaremos uma nova senha.",emailAddress:"Endereço de Email",emailPlaceholder:"seu.email@exemplo.com",cancel:"Cancelar",sending:"Enviando...",sendResetEmail:"Enviar Email de Redefinição",howToReset:"Como redefinir sua senha:",resetStep1:"Entre em contato com o administrador do Bambuddy",resetStep2:"Peça para redefinir sua senha na Gestão de Usuários",resetStep3:"Eles podem definir uma nova senha temporária para você",resetStep4:"Faça login com a nova senha e altere-a nas Configurações",gotIt:"Entendi"},setup:{title:"Bambuddy Configuração",subtitle:"Configure a autenticação para sua instância do Bambuddy",enableAuth:"Ativar Autenticação",adminAccount:"Conta de Administrador",adminAccountDesc:"Se usuários administradores já existirem, a autenticação será ativada usando as contas de administrador existentes. Deixe os campos abaixo vazios para usar os administradores existentes ou insira novas credenciais para criar um novo usuário administrador.",adminUsername:"Nome de usuário do administrador",adminPassword:"Senha do administrador",optionalIfAdminExists:"(opcional se usuários administradores existirem)",adminUsernamePlaceholder:"Digite o nome de usuário do administrador (opcional)",adminPasswordPlaceholder:"Digite a senha do administrador (opcional)",confirmPassword:"Confirmar Senha",confirmPasswordPlaceholder:"Confirme a senha do administrador",settingUp:"Configurando...",completeSetup:"Concluir Configuração",toast:{authEnabledAdminCreated:"Autenticação ativada e usuário administrador criado",authEnabledExistingAdmins:"Autenticação ativada usando usuários administradores existentes",setupCompleted:"Configuração concluída",enterBothCredentials:"Por favor, insira o nome de usuário e a senha do administrador, ou deixe ambos vazios para usar os usuários administradores existentes",passwordsDoNotMatch:"As senhas não coincidem",passwordTooShort:"A senha deve ter pelo menos 6 caracteres"}},changePassword:{title:"Alterar Senha",currentPassword:"Senha Atual",currentPasswordPlaceholder:"Digite a senha atual",newPassword:"Nova Senha",newPasswordPlaceholder:"Digite a nova senha (mínimo 6 caracteres)",confirmPassword:"Confirmar Senha",confirmPasswordPlaceholder:"Confirme a nova senha",passwordsDoNotMatch:"As senhas não coincidem",passwordTooShort:"A senha deve ter pelo menos 6 caracteres",changing:"Alterando...",success:"Senha alterada com sucesso",failed:"Falha ao alterar a senha"},plateAlert:{title:"Impressão Pausada!",message:"Objetos detectados na mesa de impressão. A impressão foi automaticamente pausada. Por favor, limpe a mesa e retome a impressão.",understand:"Entendi"},camera:{title:"Visualização da Câmera",invalidPrinterId:"ID da impressora inválido",live:"Ao Vivo",snapshot:"Captura",restartStream:"Reiniciar transmissão",refreshSnapshot:"Atualizar captura",fullscreen:"Tela Cheia",exitFullscreen:"Sair da Tela Cheia",connectingToCamera:"Conectando à câmera...",capturingSnapshot:"Capturando imagem...",connectionLost:"Conexão perdida",connectionFailed:"Falha na conexão com a câmera",reconnecting:"Reconectando em {{countdown}}s... (tentativa {{attempt}}/{{max}})",reconnectNow:"Reconectar agora",cameraUnavailable:"Câmera indisponível",cameraUnavailableDesc:"Certifique-se de que a impressora está ligada e conectada.",noCamera:"Nenhuma câmera disponível",retry:"Tentar novamente",cameraStream:"Transmissão da câmera",zoomOut:"Reduzir zoom",zoomIn:"Aumentar zoom",resetZoom:"Redefinir zoom",recording:"Gravando",startRecording:"Iniciar gravação",stopRecording:"Parar gravação",chamberLight:"Alternar luz da câmara"},groups:{title:"Gerenciamento de Grupos",subtitle:"Gerenciar grupos de permissão para controle de acesso",backToSettings:"Voltar para Configurações",createGroup:"Criar Grupo",noPermission:"Você não tem permissão para acessar esta página.",system:"Sistema",noDescription:"Sem descrição",usersCount:"{{count}} usuários",permissionsCount:"{{count}} permissões",edit:"Editar",delete:"Excluir",toast:{created:"Grupo criado com sucesso",updated:"Grupo atualizado com sucesso",deleted:"Grupo excluído com sucesso",enterGroupName:"Por favor, insira um nome para o grupo"},modal:{editGroup:"Editar Grupo",createGroup:"Criar Grupo",cancel:"Cancelar",saving:"Salvando...",creating:"Criando...",saveChanges:"Salvar Alterações"},form:{groupName:"Nome do Grupo",groupNamePlaceholder:"Insira o nome do grupo",systemGroupWarning:"Os nomes dos grupos do sistema não podem ser alterados",description:"Descrição",descriptionPlaceholder:"Insira a descrição (opcional)",permissions:"Permissões ({{count}} selecionadas)"},deleteModal:{title:"Excluir Grupo",message:"Tem certeza de que deseja excluir este grupo? Os usuários deste grupo perderão essas permissões.",confirm:"Excluir Grupo"},editor:{title:"Editar Grupo",createTitle:"Criar Grupo",search:"Pesquisar permissões...",selectAll:"Selecionar Tudo",clearAll:"Limpar Tudo",permissionsSelected:"{{count}} selecionada(s)",noResults:"Nenhuma permissão corresponde à sua pesquisa"}},users:{title:"Gerenciamento de Usuários",subtitle:"Gerenciar usuários e seu acesso à sua instância do Bambuddy",backToSettings:"Voltar para Configurações",createUser:"Criar Usuário",noPermission:"Você não tem permissão para acessar esta página.",admin:"Admin",noGroups:"Sem grupos",active:"Ativo",inactive:"Inativo",edit:"Editar",delete:"Excluir",system:"Sistema",noGroupsAvailable:"Nenhum grupo disponível",table:{username:"Nome de Usuário",groups:"Grupos",status:"Status",actions:"Ações"},toast:{created:"Usuário criado com sucesso",updated:"Usuário atualizado com sucesso",deleted:"Usuário excluído com sucesso",fillRequired:"Por favor, preencha todos os campos obrigatórios",passwordsDoNotMatch:"As senhas não coincidem",passwordTooShort:"A senha deve ter pelo menos 6 caracteres"},modal:{createUser:"Criar Usuário",editUser:"Editar Usuário",cancel:"Cancelar",creating:"Criando...",saving:"Salvando...",saveChanges:"Salvar Alterações",advancedAuthSubtitle:"com Autenticação Avançada"},form:{username:"Nome de Usuário",usernamePlaceholder:"Insira o nome de usuário",email:"Email",emailPlaceholder:"user@example.com",password:"Senha",passwordPlaceholder:"Insira a senha",confirmPassword:"Confirmar Senha",confirmPasswordPlaceholder:"Confirme a senha",newPasswordPlaceholder:"Insira a nova senha",confirmNewPasswordPlaceholder:"Confirme a nova senha",leaveBlankToKeep:"deixe em branco para manter a atual",groups:"Grupos",optional:"opcional",autoGeneratedPassword:"Uma senha segura será gerada automaticamente e enviada por e-mail ao usuário.",passwordManagedByAdvancedAuth:'A senha é gerenciada pela Autenticação Avançada. Use "Redefinir Senha" para enviar uma nova senha ao usuário por e-mail.',resetPassword:"Redefinir Senha",resettingPassword:"Redefinindo Senha..."},deleteModal:{title:"Excluir Usuário",message:"Tem certeza de que deseja excluir este usuário? Esta ação não pode ser desfeita.",confirm:"Excluir Usuário"}},streamOverlay:{title:"Stream Overlay",invalidPrinterId:"ID da impressora inválido",cameraStream:"Transmissão da câmera",progress:"Progresso da impressão",eta:"ETA",printerIdle:"Impressora ociosa",printerOffline:"Impressora offline",status:{printing:"Imprimindo",paused:"Pausado",finished:"Concluído",failed:"Falhou",idle:"Ocioso",unknown:"Desconhecido"}},profiles:{title:"Perfis",subtitle:"Gerencie seus presets de fatiador e calibrações de avanço de pressão",tabs:{cloud:"Perfis na Nuvem",local:"Perfis Locais",kprofiles:"K-Perfis"},localProfiles:{title:"Perfis Locais",subtitle:"Importe e gerencie presets de fatiador do OrcaSlicer",import:"Importar Perfis",importDesc:"Solte arquivos .bbscfg, .bbsflmt, .orca_filament, .zip ou .json aqui",importing:"Importando...",search:"Pesquisar presets locais...",noPresets:"Nenhum preset local ainda",badge:"Local",edit:"Editar",delete:"Excluir",cancel:"Cancelar",deleteConfirmTitle:"Excluir Preset",deleteConfirm:"Tem certeza de que deseja excluir este preset? Esta ação não pode ser desfeita.",source:"Fonte",inheritsFrom:"Herdado de",filamentType:"Tipo",vendor:"Fornecedor",compatiblePrinters:"Impressoras Compatíveis",nozzleTemp:"Temperatura do Bico",cost:"Custo",density:"Densidade",pressureAdvance:"Avanço de Pressão",filament:"Filamento",process:"Processo",printer:"Impressora",toast:{importSuccess:"{{count}} preset(s) importada(s)",importSkipped:"{{count}} preset(s) ignorada(s) (duplicadas)",importError:"{{count}} erro(s) durante a importação",deleted:"Preset excluído",updated:"Preset atualizado"}},connectedAs:"Conectado como",logout:"Sair",noLogoutPermission:"Você não tem permissão para sair",failedToLoad:"Falha ao carregar perfis",retry:"Tentar novamente",time:{justNow:"Agora mesmo",minsAgo:"há {{count}} minutos",hoursAgo:"há {{count}} horas",daysAgo:"há {{count}} dias"},toast:{loggedOut:"Desconectado"},login:{title:"Conectar ao Bambu Cloud",subtitle:"Sincronize seus presets de fatiador entre dispositivos",email:"Email",password:"Senha",region:"Região",regionGlobal:"Global",regionChina:"China",verificationCode:"Código de Verificação",totpCode:"Código do Autenticador",checkEmail:"Verifique seu email ({{email}}) para um código de 6 dígitos",enterTotpHint:"Digite o código de 6 dígitos do seu aplicativo autenticador",accessToken:"Token de Acesso",accessTokenHint:"Cole seu token de acesso Bambu Lab (do Bambu Studio)",back:"Voltar",loginButton:"Entrar",verifyButton:"Verificar",setTokenButton:"Definir Token",useToken:"Usar token de acesso em vez disso",useEmail:"Entrar com email em vez disso",toast:{loggedIn:"Conectado com sucesso",codeSent:"Código de verificação enviado para seu email",enterTotp:"Digite o código do seu aplicativo autenticador",tokenSet:"Token definido com sucesso"}},presets:{myPreset:"Meu preset (editável)",duplicate:"Duplicar",editable:"Editável",failedToLoadDetails:"Falha ao carregar detalhes do preset",deleteConfirm:"Excluir este preset?",deleteWarning:'Isso excluirá permanentemente "{{name}}" do Bambu Cloud. Esta ação não pode ser desfeita.',noDuplicatePermission:"Você não tem permissão para duplicar presets",noEditPermission:"Você não tem permissão para editar presets",noDeletePermission:"Você não tem permissão para excluir presets",types:{filament:"Preset de filamento",printer:"Preset de impressora",process:"Preset de processo"},toast:{deleted:"Preset excluído",created:"Preset criado",updated:"Preset atualizado",duplicated:"Preset duplicado",fieldAdded:'Campo "{{key}}" adicionado',exported:"Preset exportado"},baseLabel:"Base: {{name}}",currentLabel:"Atual: {{name}}",newPreset:"Novo Preset",editPreset:"Editar Preset",duplicatePreset:"Duplicar Preset",createNewPreset:"Criar Novo Preset",customizeSettings:"Personalizar configurações para seu novo preset",compareWithBase:"Comparar com o preset base",compare:"Comparar",basePreset:"Preset Base",selectBasePreset:"Selecionar preset base...",presetName:"Nome do Preset",myCustomPreset:"Meu preset personalizado",inheritsFrom:"Herdado de",dropJsonToImport:"Solte o arquivo JSON para importar",tabs:{common:"Comum",allFields:"Todos os Campos"},availableFields:"Campos Disponíveis",searchFieldsPlaceholder:"Pesquisar campos...",noMatchingFields:"Nenhum campo correspondente",allFieldsAdded:"Todos os campos adicionados",addCustomField:"Adicionar campo personalizado",yourOverrides:"Suas Substituições",noOverridesYet:"Nenhuma substituição ainda",clickFieldsToAdd:"Clique nos campos à esquerda para adicioná-los",saveAsTemplate:"Salvar como modelo",jsonTip:"Dica: Arraste e solte um arquivo .json em qualquer lugar deste modal para importar configurações"},cloudView:{searchPlaceholder:"Pesquisar presets...",templates:"Modelos",refresh:"Atualizar",newPreset:"Novo Preset",clearFilters:"Limpar filtros",compareMode:"Modo de Comparação",selectAnotherPreset:"Selecionar outro preset {{type}}",clickTwoPresets:"Clique em dois presets do mesmo tipo para comparar",selectFirst:"1. Selecionar primeiro",selectSecond:"2. Selecionar segundo",compareNow:"Comparar Agora",lastSynced:"Última sincronização:",showingCount:"Mostrando {{showing}} de {{total}} presets",noPresetsFound:"Nenhum preset encontrado",columns:{filament:"Filamento",process:"Processo",printer:"Impressora"},noFilamentPresets:"Nenhum preset de filamento",noProcessPresets:"Nenhum preset de processo",noPrinterPresets:"Nenhum preset de impressora",filters:{type:"Tipo",owner:"Proprietário",printer:"Impressora",nozzle:"Bico",filament:"Filamento",layer:"Camada",all:"Todos",myPresets:"Meus Presets",builtIn:"Integrado",process:"Processo"},noTemplatesPermission:"Você não tem permissão para gerenciar modelos",noRefreshPermission:"Você não tem permissão para atualizar perfis",noCreatePermission:"Você não tem permissão para criar presets"},templates:{title:"Modelos Rápidos",noTemplates:"Nenhum modelo ainda",createFirst:"Crie modelos a partir do editor de presets",typeFilter:"Tipo:",deleteTitle:"Excluir Modelo",deleteWarning:"Esta ação não pode ser desfeita",deleteConfirm:'Tem certeza de que deseja excluir "{{name}}"?',namePlaceholder:"Nome do modelo",descriptionPlaceholder:"Descrição",settingsJson:"Configurações (JSON)",fieldsCount:"{{count}} campos",shownInModals:"Exibido em modais",hiddenInModals:"Oculto em modais",apply:"Aplicar",toast:{deleted:"Modelo excluído",updated:"Modelo atualizado",created:"Modelo criado",applied:"Modelo aplicado"}}},support:{debugLoggingActive:"Registro de depuração ativo",manageLogs:"Gerenciar",collectItem7:"Conectividade da impressora e versões de firmware",collectItem8:"Status de integração (Spoolman, MQTT, HA)",collectItem9:"Interfaces de rede (somente sub-redes)",collectItem10:"Versões de pacotes Python",collectItem11:"Verificações de integridade do banco de dados",collectItem12:"Detalhes do ambiente Docker"},fileManager:{title:"Gerenciador de Arquivos",subtitle:"Organize e gerencie seus arquivos de impressão",uploadFiles:"Enviar Arquivos",newFolder:"Nova Pasta",folderName:"Nome da Pasta",folderNamePlaceholder:"ex.: Peças Funcionais",renameFile:"Renomear Arquivo",renameFolder:"Renomear Pasta",moveFiles:"Mover {{count}} Arquivo(s)",rootNoFolder:"Raiz (Sem Pasta)",current:"Atual",linkFolder:"Vincular Pasta",linkFolderDescription:'Vincular "{{name}}" a um projeto ou arquivo para acesso rápido.',project:"Projeto",archive:"Arquivo",noProjectsFound:"Nenhum projeto encontrado",noArchivesFound:"Nenhum arquivo encontrado",unlink:"Desvincular",link:"Vincular",dragDropFiles:"Arraste e solte os arquivos aqui",dropFilesHere:"Solte os arquivos aqui",orClickToBrowse:"ou clique para procurar",allFileTypesSupported:"Todos os tipos de arquivos são suportados. Arquivos ZIP serão extraídos.",zipFilesDetected:"Arquivos ZIP detectados",zipExtractOptions:"Arquivos ZIP serão extraídos. Escolha como lidar com a estrutura de pastas:",preserveZipStructure:"Preservar estrutura de pastas do ZIP",createFolderFromZip:"Criar pasta a partir do nome do arquivo ZIP",stlThumbnailGeneration:"Geração de miniaturas STL",zipMayContainStl:"Arquivos ZIP podem conter arquivos STL. Miniaturas podem ser geradas durante a extração.",thumbnailsCanBeGenerated:"Miniaturas podem ser geradas para arquivos STL. Modelos grandes podem levar mais tempo para processar.",generateThumbnailsForStl:"Gerar miniaturas para arquivos STL",threemfDetected:"Arquivos 3MF detectados",threemfExtractionInfo:"Modelo da impressora, material, cor e configurações de impressão serão extraídos automaticamente dos arquivos 3MF.",willBeExtracted:"Será extraído",filesExtracted:"{{count}} arquivos extraídos",uploadComplete:"Upload concluído: {{succeeded}} bem-sucedidos",uploadFailed:"{{count}} falhou",uploading:"Enviando...",changeLink:"Alterar link...",linkTo:"Vincular a...",linkToProjectOrArchive:"Vincular a projeto ou arquivo",addToQueue:"Adicionar à fila",schedulePrint:"Agendar impressão",generateThumbnail:"Gerar miniatura",generateThumbnails:"Gerar miniaturas",generateThumbnailsForMissing:"Gerar miniaturas para arquivos STL que não possuem",gridView:"Visualização em grade",listView:"Visualização em lista",lowDiskSpaceWarning:"Aviso de pouco espaço em disco",lowDiskSpaceDetails:"Apenas {{free}} livres de {{total}} no total. O limite está definido para {{threshold}} GB nas configurações.",files:"Arquivos",folders:"Pastas",size:"Tamanho",free:"Livre",allFiles:"Todos os arquivos",wrap:"Quebrar texto",enableTextWrapping:"Ativar quebra de texto",disableTextWrapping:"Desativar quebra de texto",dragToResizeTooltip:"Arraste para redimensionar, clique duas vezes para redefinir",searchFiles:"Pesquisar arquivos...",allTypes:"Todos os tipos",prints:"Impressões",ascending:"Crescente",descending:"Decrescente",resultsCount:"{{showing}} de {{total}} arquivos",selectAll:"Selecionar tudo",deselectAll:"Desmarcar tudo",selected:"{{count}} selecionado(s)",adding:"Adicionando...",loadingFiles:"Carregando arquivos...",folderIsEmpty:"A pasta está vazia",noFilesYet:"Nenhum arquivo ainda",folderEmptyDescription:"Envie arquivos ou mova arquivos para esta pasta para começar.",noFilesDescription:"Envie arquivos para começar a organizar seus arquivos relacionados à impressão.",noMatchingFiles:"Nenhum arquivo correspondente",noMatchingFilesDescription:"Nenhum arquivo corresponde aos seus critérios de pesquisa ou filtro.",clearFilters:"Limpar filtros",printedCount:"Impresso {{count}}x",uploadedBy:"Enviado por",deleteFolder:"Excluir pasta",deleteFile:"Excluir arquivo",deleteFilesCount:"Excluir {{count}} arquivos",deleteFolderConfirm:"Tem certeza de que deseja excluir esta pasta? Todos os arquivos dentro também serão excluídos.",deleteFileConfirm:"Tem certeza de que deseja excluir este arquivo?",deleteFilesConfirm:"Tem certeza de que deseja excluir {{count}} arquivos selecionados? Esta ação não pode ser desfeita.",deleting:"Excluindo...",noPermissionRenameFolder:"Você não tem permissão para renomear pastas",noPermissionLinkFolder:"Você não tem permissão para vincular pastas",noPermissionDeleteFolder:"Você não tem permissão para excluir pastas",noPermissionPrint:"Você não tem permissão para imprimir",noPermissionAddToQueue:"Você não tem permissão para adicionar à fila",noPermissionDownload:"Você não tem permissão para baixar arquivos",noPermissionRenameFile:"Você não tem permissão para renomear este arquivo",noPermissionGenerateThumbnail:"Você não tem permissão para gerar miniaturas",noPermissionDeleteFile:"Você não tem permissão para excluir este arquivo",noPermissionCreateFolder:"Você não tem permissão para criar pastas",noPermissionUpload:"Você não tem permissão para enviar arquivos",noPermissionMoveFiles:"Você não tem permissão para mover arquivos",noPermissionDeleteFiles:"Você não tem permissão para excluir arquivos",toast:{folderCreated:"Pasta criada",folderDeleted:"Pasta excluída",fileDeleted:"Arquivo excluído",filesDeleted:"Excluídos {{count}} arquivos",filesMoved:"Arquivos movidos",folderLinked:"Pasta vinculada",folderUnlinked:"Pasta desvinculada",addedToQueue:"Adicionado {{count}} arquivo(s) à fila",addedToQueuePartial:"Adicionado {{added}} arquivo(s), {{failed}} falharam",failedToAddToQueue:"Falha ao adicionar arquivos: {{error}}",fileRenamed:"Arquivo renomeado",folderRenamed:"Pasta renomeada",thumbnailsGenerated:"Geradas {{count}} miniatura(s)",thumbnailsGeneratedPartial:"Geradas {{succeeded}} miniatura(s), {{failed}} falharam",noStlMissingThumbnails:"Nenhum arquivo STL sem miniatura",failedToGenerateThumbnails:"Falha ao gerar miniaturas: {{error}}",thumbnailGenerated:"Miniatura gerada",failedToGenerateThumbnail:"Falha ao gerar miniatura: {{error}}"}},projects:{title:"Projetos",subtitle:"Organize e acompanhe seus projetos de impressão 3D",newProject:"Novo Projeto",editProject:"Editar Projeto",deleteProject:"Excluir Projeto",projectName:"Nome do Projeto",description:"Descrição",noProjects:"Nenhum projeto ainda",noProjectsFiltered:"Nenhum projeto {{status}}",noProjectsFilteredHelp:"Você não tem nenhum projeto {{status}}. Os projetos aparecerão aqui quando seu status mudar.",createFirst:"Crie seu primeiro projeto para começar a organizar impressões relacionadas, acompanhar o progresso e gerenciar suas construções.",createFirstButton:"Crie Seu Primeiro Projeto",create:"Criar",files:"Arquivos",prints:"Impressões",plates:"Placas",parts:"Peças",lastModified:"Última Modificação",deleteConfirm:"Tem certeza de que deseja excluir este projeto? Arquivos e itens da fila serão desvinculados, mas não excluídos.",addFiles:"Adicionar Arquivos",removeFile:"Remover Arquivo",viewDetails:"Ver Detalhes",namePlaceholder:"ex., Voron 2.4 Build",descriptionPlaceholder:"Descrição opcional...",color:"Cor",targetPlates:"Placas Alvo",targetPlatesPlaceholder:"ex., 25",targetPlatesHelp:"Número de trabalhos de impressão",targetParts:"Peças Alvo",targetPartsPlaceholder:"ex., 150",targetPartsHelp:"Total de objetos necessários",tagsLabel:"Tags (separadas por vírgula)",tagsPlaceholder:"ex., voron, funcional, presente",dueDate:"Data de Vencimento",priority:"Prioridade",priorityLow:"Baixa",priorityNormal:"Normal",priorityHigh:"Alta",priorityUrgent:"Urgente",statusActive:"Ativo",statusCompleted:"Concluído",statusArchived:"Arquivado",done:"Concluído",completed:"Concluído",failed:"Falhou",inQueue:"Na fila",noPrintsYet:"Nenhuma impressão ainda",printJobs:"Trabalhos de impressão (placas)",partsPrinted:"Peças impressas",failedParts:"Peças falhadas",import:"Importar",export:"Exportar",importProject:"Importar projeto",exportAll:"Exportar todos os projetos",loading:"Carregando projetos...",noEditPermission:"Você não tem permissão para editar projetos",noDeletePermission:"Você não tem permissão para excluir projetos",noCreatePermission:"Você não tem permissão para criar projetos",noImportPermission:"Você não tem permissão para importar projetos",noExportPermission:"Você não tem permissão para exportar projetos",toast:{created:"Projeto criado",updated:"Projeto atualizado",deleted:"Projeto excluído",imported:"Projeto importado",multipleImported:"{{count}} projetos importados",importFailed:"Falha na importação",exported:"Projetos exportados (apenas metadados)"}},projectDetail:{notFound:"Projeto não encontrado",backToProjects:"Voltar para Projetos",export:"Exportar",exportProject:"Exportar projeto",noExportPermission:"Você não tem permissão para exportar projetos",noEditPermission:"Você não tem permissão para editar projetos",partOf:"Parte de:",priorityLabel:"Prioridade:",noPrints:"Nenhuma impressão neste projeto ainda",status:{active:"Ativo",completed:"Concluído",archived:"Arquivado"},priority:{low:"Baixa",normal:"Normal",high:"Alta",urgent:"Urgente"},dueDate:{overdue:"Atrasado",today:"Vence hoje",daysLeft:"{{count}} dias restantes"},progress:{platesProgress:"Progresso das Placas",partsProgress:"Progresso das Peças",printJobs:"Trabalhos de Impressão",parts:"Peças",percentComplete:"{{percent}}% concluído",remaining:"{{count}} restantes"},stats:{printJobs:"Trabalhos de Impressão",total:"total",failed:"{{count}} falhou",partsPrinted:"{{count}} peças impressas",printTime:"Tempo de Impressão",filamentUsed:"Filamento Usado"},cost:{title:"Rastreamento de Custos",filamentCost:"Custo do Filamento",energy:"Energia",budget:"Orçamento",remaining:"Restante"},subProjects:{title:"Sub-projetos ({{count}})"},notes:{title:"Notas",noEditPermission:"Você não tem permissão para editar notas",placeholder:"Adicione notas sobre este projeto...",empty:"Nenhuma nota ainda. Clique em Editar para adicionar notas."},files:{title:"Arquivos",linkFolders:"Vincular pastas do Gerenciador de Arquivos",forQuickAccess:"a este projeto para acesso rápido.",fileCount:"{{count}} arquivo(s)",empty:"Nenhuma pasta vinculada. Vá para o Gerenciador de Arquivos e vincule uma pasta a este projeto."},bom:{title:"Lista de Materiais",acquired:"{{completed}}/{{total}} adquiridos",showAll:"Mostrar todos",hideDone:"Ocultar concluídos",addPart:"Adicionar Peça",noAddPermission:"Você não tem permissão para adicionar peças",partNamePlaceholder:"Nome da peça (ex.: parafusos M3x8)",partName:"Nome da peça",qty:"Quantidade",price:"Preço ({{currency}})",sourcingUrlPlaceholder:"URL de fornecimento (opcional)",remarksPlaceholder:"Observações (opcional)",deletePart:"Excluir Peça",deleteConfirm:'Tem certeza de que deseja excluir "{{name}}"?',noUpdatePermission:"Você não tem permissão para atualizar peças",noEditPermission:"Você não tem permissão para editar peças",noDeletePermission:"Você não tem permissão para excluir peças",totalCost:"Custo total:",empty:"Nenhuma peça na lista de materiais. Adicione hardware, eletrônicos ou outros componentes para rastrear o que precisa ser adquirido."},timeline:{title:"Linha do Tempo de Atividades",empty:"Nenhuma atividade ainda."},template:{saveAsTemplate:"Salvar como Modelo",noCreatePermission:"Você não tem permissão para criar modelos"},queue:{title:"Fila",viewAll:"Ver todos",printing:"{{count}} imprimindo",queued:"{{count}} na fila"},prints:{title:"Impressões ({{count}})"},toast:{projectUpdated:"Projeto atualizado",partAdded:"Peça adicionada",partRemoved:"Peça removida",exportFailed:"Falha na exportação",projectExported:"Projeto exportado",templateCreated:"Modelo criado"}},system:{title:"Informações do Sistema",version:"Versão",uptime:"Tempo de Atividade",cpuUsage:"Uso da CPU",memoryUsage:"Uso da Memória",diskUsage:"Uso do Disco",networkInfo:"Informações de Rede",logs:"Logs",debugMode:"Modo de Depuração",enableDebug:"Ativar Registro de Depuração",disableDebug:"Desativar Registro de Depuração",downloadLogs:"Baixar Logs",clearLogs:"Limpar Logs",dockerInfo:"Informações do Docker",containerName:"Nome do Contêiner",imageName:"Nome da Imagem",platform:"Plataforma",architecture:"Arquitetura"},library:{title:"Biblioteca de Filamentos",addFilament:"Adicionar Filamento",editFilament:"Editar Filamento",deleteFilament:"Excluir Filamento",vendor:"Fornecedor",material:"Material",color:"Cor",kFactor:"Fator K",temperature:"Temperatura",noFilaments:"Nenhum filamento na biblioteca",deleteConfirm:"Tem certeza de que deseja excluir este filamento?",importFromPrinter:"Importar da Impressora",exportToFile:"Exportar para Arquivo"},spoolman:{title:"Integração com Spoolman",enabled:"Spoolman Ativado",url:"URL do Spoolman",connected:"Conectado",disconnected:"Não Conectado",testConnection:"Testar Conexão",sync:"Sincronizar",syncing:"Sincronizando...",lastSync:"Última Sincronização",linkToSpoolman:"Vincular ao Spoolman",openInSpoolman:"Abrir no Spoolman",unlinkSpool:"Desvincular Carretel",selectSpool:"Selecionar Carretel",noUnlinkedSpools:"Nenhum carretel desvinculado disponível",linkSuccess:"Carretel vinculado ao Spoolman com sucesso",linkFailed:"Falha ao vincular carretel",spoolId:"Carretel ID (Spool ID)",fillSourceLabel:"(Spoolman)",weight:"Peso",remaining:"Restante",disableWeightSync:"Desativar Sincronização de Peso Estimado do AMS",disableWeightSyncDesc:"Não atualize a capacidade restante a partir das estimativas do AMS. Use isso se preferir o rastreamento de uso do Spoolman em vez das estimativas baseadas em porcentagem do AMS. Novos carretéis ainda usarão a estimativa do AMS como seu peso inicial.",reportPartialUsage:"Relatar Uso Parcial para Impressões Falhadas",reportPartialUsageDesc:"Quando uma impressão falha ou é cancelada, relate o filamento estimado usado até aquele ponto com base no progresso das camadas."},inventory:{title:"Inventário de Carretéis",addSpool:"Adicionar Carretel",editSpool:"Editar Carretel",material:"Material",selectMaterial:"Selecionar material...",subtype:"Subtipo",brand:"Marca",searchBrand:"Pesquisar marca...",useCustomBrand:'Usar "{{brand}}"',useCustomMaterial:"Usar material personalizado: {{material}}",colorName:"Nome da Cor",colorNamePlaceholder:"Jade White, Fire Red...",color:"Cor",hexColor:"Cor Hexadecimal",pickColor:"Escolher cor personalizada",labelWeight:"Peso da Etiqueta",coreWeight:"Peso do Carretel Vazio",searchSpoolWeight:"Pesquisar peso do carretel...",weightUsed:"Usado",currentWeight:"Peso Restante",measuredWeight:"Peso Medido",costPerKg:"Custo por kg",measuredWeightError:"O peso medido deve estar entre {{min}}g e {{max}}g.",slicerFilament:"Filamento do Fatiador",slicerFilamentName:"Nome do Predefinido do Fatiador",slicerPreset:"Predefinido do Fatiador",searchPresets:"Pesquisar predefinições de filamento...",selectedPreset:"Selecionado",noPresetsFound:"Nenhuma predefinição encontrada",tempOverrides:"Substituições de Temperatura",note:"Nota",notePlaceholder:"Quaisquer notas adicionais sobre este spool...",archive:"Arquivar",restore:"Restaurar",noSpools:"Nenhum carretel ainda. Adicione seu primeiro carretel para começar.",noManualSpools:"Nenhum carretel adicionado manualmente disponível. Adicione um carretel ao seu inventário primeiro.",kProfiles:"K-Perfis",addKProfile:"Adicionar K-Perfil",assignSpool:"Atribuir Carretel",unassignSpool:"Desatribuir",assignSuccess:"Carretel atribuído e slot AMS configurado",assignFailed:"Falha ao atribuir carretel",selectSpool:"Selecione um carretel para atribuir a este slot",assigned:"Atribuído",assigning:"Atribuindo...",searchSpools:"Pesquisar carretéis...",allMaterials:"Todos os Materiais",filterByBrand:"Filtrar por marca...",showArchived:"Mostrar arquivados",quickAdd:"Adição rápida (Estoque)",quantity:"Quantidade",stock:"Estoque",configured:"Configurado",spoolsCreated:"{{count}} carretéis criados",spoolCreated:"Carretel criado",spoolUpdated:"Carretel atualizado",spoolDeleted:"Carretel excluído",spoolArchived:"Carretel arquivado",spoolRestored:"Carretel restaurado",deleteConfirm:"Tem certeza de que deseja excluir este carretel? Esta ação não pode ser desfeita.",archiveConfirm:"Tem certeza de que deseja arquivar este carretel?",advancedSettings:"Configurações Avançadas",filamentInfoTab:"Informações do Filamento",paProfileTab:"Perfil PA",filamentInfo:"Filamento",additional:"Adicional",loadingPresets:"Carregando predefinições da nuvem...",cloudConnected:"Nuvem conectada",cloudNotConnected:"Nuvem não conectada (usando padrões)",recentColors:"Recentes",searchColors:"Pesquisar cores...",searchResults:"Resultados da pesquisa",allColors:"Todas as cores",commonColors:"Cores comuns",showLess:"Mostrar menos",showAll:"Mostrar tudo",noColorsFound:"Nenhuma cor corresponde à sua pesquisa",noResults:"Nenhum resultado encontrado",selectMaterialFirst:"Por favor, selecione um material primeiro na aba Informações do Filamento.",noPrintersConfigured:"Nenhuma impressora configurada. Adicione impressoras para usar perfis PA.",matchingFilter:"Correspondente",anyBrand:"Qualquer marca",anyVariant:"Qualquer variante",autoSelect:"Seleção automática",matches:"correspondências",match:"correspondência",noMatches:"Nenhuma correspondência",connected:"Conectado",offline:"Offline",printerOffline:"A impressora está offline. Conecte-se para visualizar os perfis de calibração.",noKProfilesMatch:"Nenhum K-perfil corresponde ao filamento selecionado.",leftNozzle:"Bico Esquerdo",rightNozzle:"Bico Direito",profilesSelected:"perfil(is) de calibração selecionado(s)",totalInventory:"Inventário Total",totalConsumed:"Total Consumido",byMaterial:"Por Material",inPrinter:"Na Impressora",lowStock:"Estoque Baixo",sinceTracking:"Desde o início do rastreamento",loadedInAms:"Carregado no AMS/Ext",remaining:"Restante",lowStockThreshold:"<20% restante",weightCheck:"Verificação de Peso",lastWeighed:"Última pesagem",neverWeighed:"Nunca pesado",search:"Pesquisar carretéis...",showing:"Mostrando",to:"até",of:"de",show:"Mostrar",spools:"carretéis",spool:"carretel",page:"Página",noSpoolsMatch:"Nenhum resultado encontrado",noSpoolsMatchDesc:"Tente ajustar sua pesquisa ou filtros para encontrar o que você está procurando.",active:"Ativo",archived:"Arquivado",all:"Todos",used:"Usado",new:"Novo",clearFilters:"Limpar filtros",table:"Tabela",cards:"Cartões",net:"Líquido",columns:"Colunas",configureColumns:"Configurar Colunas",configureColumnsDesc:"Arraste para reordenar as colunas ou use as setas. Alterne a visibilidade com o ícone de olho.",visible:"Visível",reset:"Redefinir",cancel:"Cancelar",applyChanges:"Aplicar Alterações",moveUp:"Mover para cima",moveDown:"Mover para baixo",hideColumn:"Ocultar coluna",showColumn:"Mostrar coluna",linkToSpool:"Vincular ao Carretel",tagLinked:"Tag vinculada ao carretel",tagLinkFailed:"Falha ao vincular tag",tagAlreadyLinked:"Tag já vinculada a outro carretel",unknownTag:"Tag RFID desconhecida detectada",usageHistory:"Histórico de Uso",noUsageHistory:"Nenhum uso registrado ainda",printName:"Nome da Impressão",weightConsumed:"Peso Consumido",clearHistory:"Limpar",historyCleared:"Histórico de uso limpo",fillSourceLabel:"(Inv)"},timelapse:{title:"Timelapse",create:"Criar Timelapse",download:"Baixar",delete:"Excluir",preview:"Visualizar",frameRate:"Taxa de Quadros",quality:"Qualidade",processing:"Processando...",noTimelapses:"Nenhum timelapse disponível"},ams:{title:"AMS",slot:"Slot",empty:"Vazio",emptySlot:"Slot vazio",unknown:"Desconhecido",humidity:"Umidade",temperature:"Temperatura",filamentType:"Tipo de Filamento",filamentColor:"Cor",remaining:"Restante",history:"Histórico do AMS",noHistory:"Nenhum histórico disponível",configureSlot:"Configurar Slot",externalSpool:"Carretel Externo",profile:"Perfil",kFactor:"Fator K",fill:"Preencher",configure:"Configurar"},printModal:{title:"Iniciar Impressão",selectPrinter:"Selecionar Impressora",selectPlate:"Selecionar Placa",filamentMapping:"Mapeamento de Filamento",totalCost:"Custo total:",slotRemainingShort:" - {{grams}}g rest.",printSettings:"Configurações de Impressão",bedLeveling:"Nivelamento da Mesa",flowCalibration:"Calibração de Fluxo",vibrationCalibration:"Calibração de Vibração",layerInspection:"Inspeção da Primeira Camada",timelapse:"Timelapse",startPrint:"Iniciar Impressão",addToQueue:"Adicionar à Fila",cancel:"Cancelar",noPrintersAvailable:"Nenhuma impressora disponível",printerBusy:"Impressora ocupada",printerOffline:"Impressora offline",sameTypeDifferentColor:"Mesmo tipo, cor diferente",filamentTypeNotLoaded:"Tipo de filamento não carregado",openCalendar:"Abrir calendário",leftNozzle:"L",rightNozzle:"R",leftNozzleTooltip:"Bico esquerdo",rightNozzleTooltip:"Bico direito",filamentOverride:"Substituição de Filamento",filamentOverrideHint:"Substitua opcionalmente os filamentos para atribuição baseada em modelo. O agendador usará os filamentos selecionados em vez dos valores originais do 3MF.",originalFilament:"Original",overrideWith:"Substituir por",resetToOriginal:"Restaurar original"},backup:{title:"Bakup e Restauração",createBackup:"Criar Backup",restoreBackup:"Restaurar Backup",restoreDescription:"Substituir todos os dados a partir de um arquivo de backup",downloadBackup:"Baixar Backup",uploadBackup:"Enviar Backup",lastBackup:"Último Backup",autoBackup:"Auto Backup",backupNow:"Fazer Backup Agora",restoreWarning:"Aviso: Restaurar um backup substituirá todos os dados atuais.",includeArchives:"Incluir Arquivos",includeSettings:"Incluir Configurações",includeProfiles:"Incluir Perfis",backupSuccess:"Backup criado com sucesso",restoreSuccess:"Backup restaurado com sucesso",backupFailed:"Falha ao criar backup",restoreFailed:"Falha ao restaurar backup",restoreNote:"A impressora virtual será parada durante a restauração"},tags:{title:"Tags",addTag:"Adicionar Tag",editTag:"Editar Tag",deleteTag:"Excluir Tag",tagName:"Nome da Tag",tagColor:"Cor da Tag",noTags:"Nenhuma tag",deleteConfirm:"Tem certeza de que deseja excluir esta tag?",manageTags:"Gerenciar Tags"},uploadModal:{title:"Upload Arquivos 3MF",dragDrop:"Arraste e solte arquivos .3mf aqui",or:"ou",browseFiles:"Procurar Arquivos",extractionInfo:"O modelo da impressora será extraído automaticamente dos metadados do arquivo 3MF.",uploaded:"enviado",failed:"falhou",uploading:"Enviando...",upload:"Enviar",uploadFailed:"Falha no envio"},editArchive:{title:"Editar Arquivo",name:"Nome",namePlaceholder:"Nome da impressão",printer:"Impressora",noPrinter:"Nenhuma impressora",project:"Projeto",noProject:"Nenhum projeto",itemsPrinted:"Itens Impressos",itemsPrintedHelp:"Número de itens produzidos neste trabalho de impressão",notes:"Notas",notesPlaceholder:"Adicione notas sobre esta impressão...",externalLink:"Link Externo",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link para Printables, Thingiverse ou outra fonte",tags:"Tags",tagsPlaceholder:"Adicionar tags...",addMoreTags:"Adicionar mais tags...",matchingTags:'Correspondendo "{{query}}"',existingTags:"Tags existentes",clickToAdd:"(clique para adicionar)",status:"Status",failureReason:"Motivo da Falha",selectReason:"Selecione o motivo...",photos:"Fotos do Resultado da Impressão",photosHelp:"Clique em + para adicionar fotos do seu resultado impresso",printResult:"Resultado da Impressão",saving:"Salvando...",failureReasons:{adhesionFailure:"Falha de adesão",spaghettiDetached:"Spaghetti / Destacado",layerShift:"Deslocamento de camada",cloggedNozzle:"Bico entupido",filamentRunout:"Fim do filamento",warping:"Warping",stringing:"Stringing",underExtrusion:"Under-extrusion",powerFailure:"Falha de energia",userCancelled:"Cancelado pelo usuário",other:"Outro"},statuses:{completed:"Concluído",failed:"Falhou",aborted:"Cancelado",printing:"Imprimindo"}},kProfiles:{title:"K-Profiles",noPrintersConfigured:"Nenhuma impressora configurada",addPrinterInSettings:"Adicione uma impressora nas Configurações para gerenciar K-profiles",noActivePrinters:"Nenhuma impressora ativa",enablePrinterConnection:"Ative a conexão da impressora para visualizar seus K-profiles",loadingProfiles:"Carregando K-Profiles...",printerOffline:"Impressora Offline",printerOfflineDesc:"A impressora selecionada não está conectada. Ligue-a para visualizar os K-profiles.",noMatchingProfiles:"Nenhum Perfil Correspondente",noMatchingProfilesDesc:"Nenhum perfil corresponde aos seus critérios de pesquisa",noKProfiles:"Nenhum K-Profile",noKProfilesDesc:"Nenhum perfil de avanço de pressão encontrado para bico de {{diameter}}mm",createFirstProfile:"Criar Primeiro Perfil",printer:"Impressora",nozzle:"Bico",refresh:"Atualizar",addProfile:"Adicionar Perfil",export:"Exportar",import:"Importar",select:"Selecionar",selectAll:"Selecionar Todos",delete:"Excluir",searchPlaceholder:"Pesquisar por nome ou filamento...",allExtruders:"Todos os Extrusores",leftOnly:"Apenas Esquerdo",rightOnly:"Apenas Direito",allFlow:"Todo Fluxo",hfOnly:"Apenas HF",sOnly:"Apenas S",sortName:"Ordenar: Nome",sortKValue:"Ordenar: Valor K",sortFilament:"Ordenar: Filamento",leftExtruder:"Extrusor Esquerdo",rightExtruder:"Extrusor Direito",modal:{addTitle:"Adicionar K-Profile",editTitle:"Editar K-Profile",profileName:"Nome do Perfil",profileNamePlaceholder:"Meu Perfil PLA",kValue:"Valor K",kValuePlaceholder:"0.020",kValueHelp:"Faixa típica: 0.01 - 0.06 para PLA, 0.02 - 0.10 para PETG",filament:"Filamento",selectFilament:"Selecionar filamento...",noFilamentsHelp:"Nenhum filamento encontrado. Crie um K-profile no Bambu Studio primeiro.",flowType:"Tipo de Fluxo",highFlow:"Alto Fluxo",standard:"Padrão",nozzleSize:"Tamanho do Bico",extruder:"Extrusor",extruders:"Extrusores",left:"Esquerdo",right:"Direito",notes:"Notas (armazenadas localmente)",notesPlaceholder:"Adicione notas sobre este perfil...",notesHelp:"As notas são salvas no Bambuddy, não na impressora",syncing:"Sincronizando com a impressora...",savingExtruder:"Salvando no extrusor {{current}}/{{total}}...",pleaseWait:"Por favor, aguarde"},deleteConfirm:{title:"Excluir Perfil",cannotUndo:"Isso não pode ser desfeito",message:'Tem certeza de que deseja excluir "{{name}}" da impressora?'},bulkDelete:{title:"Excluir Perfis",cannotUndo:"Isso não pode ser desfeito",message:"Tem certeza de que deseja excluir {{count}} perfis selecionados da impressora?"},toast:{profileSaved:"K-profile salvo",profilesSaved:"K-profile salvo em {{count}} extrusores",selectAtLeastOneExtruder:"Por favor, selecione pelo menos um extrusor",profileDeleted:"K-profile excluído",profilesDeleted:"{{count}} perfis excluídos",exportedProfiles:"{{count}} perfis exportados",importedProfiles:"{{count}} de {{total}} perfis importados",noProfilesToExport:"Nenhum perfil para exportar",invalidFileFormat:"Formato de arquivo inválido",failedToParseImport:"Falha ao analisar o arquivo de importação",failedToSaveBatch:"Falha ao salvar K-profiles",noteSaved:"Nota salva",failedToSaveNote:"Falha ao salvar nota"},permission:{noRead:"Você não tem permissão para atualizar perfis",noCreate:"Você não tem permissão para adicionar perfis",noUpdate:"Você não tem permissão para atualizar K-profiles",noDelete:"Você não tem permissão para excluir K-profiles",noExport:"Você não tem permissão para exportar perfis",noImport:"Você não tem permissão para importar perfis"}},virtualPrinter:{title:"Impressora Virtual",running:"Em execução",stopped:"Parada",description:{default:"Ative uma impressora virtual que aparece no Bambu Studio e no OrcaSlicer. Os arquivos enviados para esta impressora serão arquivados diretamente sem impressão.",proxy:"Ative um proxy que retransmite o tráfego do slicer para uma impressora real, permitindo impressão remota em qualquer rede."},enable:{title:"Ativar Impressora Virtual",visibleInSlicer:'Visível como "Bambuddy" na descoberta do slicer',proxyingTo:"Proxy para {{name}}",notActive:"Não ativo"},model:{title:"Modelo da Impressora",description:"Selecione qual modelo de impressora emular.",restartWarning:"Alterar o modelo reiniciará a impressora virtual"},accessCode:{title:"Código de acesso",isSet:"O código de acesso está definido",notSet:"Nenhum código de acesso definido — necessário para ativar.",placeholder:"Digite um código de 8 caracteres",placeholderChange:"Digite um novo código para alterar",hint:"Deve ter exatamente 8 caracteres. Usado pelos slicers para autenticação.",charCount:"({{count}}/8)"},targetPrinter:{title:"Impressora Alvo",configured:"Proxy alvo configurado",notConfigured:"Nenhuma impressora alvo selecionada - necessário para o modo proxy",placeholder:"Selecione uma impressora...",hint:"Selecione a impressora para a qual o tráfego do slicer será enviado. A impressora deve estar no modo LAN.",noPrinters:"Nenhuma impressora configurada. Adicione uma impressora primeiro para usar o modo proxy."},remoteInterface:{title:"Substituição da Interface de Rede",configured:"Substituição da interface ativa",optional:"Opcional - use se o IP detectado automaticamente estiver errado (por exemplo, várias NICs, Docker, VPN)",placeholder:"Detecção automática (padrão)...",hint:"Substitua o endereço IP anunciado via SSDP e usado no certificado TLS. Útil quando o Bambuddy possui várias interfaces de rede."},mode:{title:"Modo",archive:"Arquivar",archiveDesc:"Arquivar arquivos imediatamente",review:"Revisar",reviewDesc:"Revisar antes de arquivar",queue:"Fila",queueDesc:"Arquivar e adicionar à fila",proxy:"Proxy",proxyDesc:"Retransmitir para impressora real"},setupRequired:{title:"Configuração Necessária",description:"O recurso de impressora virtual requer configuração adicional do sistema antes de funcionar. Isso inclui encaminhamento de portas, regras de firewall e configurações específicas da plataforma.",readGuide:"Leia o guia de configuração antes de ativar"},howItWorks:{title:"Como funciona",titleProxy:"Como funciona (Modo Proxy)",step1:"Complete o guia de configuração para sua plataforma",step2:"Ative a impressora virtual e defina um código de acesso",step3:'No Bambu Studio ou OrcaSlicer, vá para "Adicionar Impressora"',step4:'A impressora "Bambuddy" deve aparecer na lista de descoberta',step5:"Conecte-se usando o código de acesso que você definiu",step6:'Quando você "imprimir" para o Bambuddy, o arquivo 3MF será arquivado em vez disso',proxyStep1:"Selecione a impressora alvo (deve estar no modo LAN)",proxyStep2:"Para rede cruzada: selecione a interface de rede do slicer",proxyStep3:"Ative o proxy - a impressora aparece na descoberta do slicer via SSDP",proxyStep4:"Conecte-se usando o código de acesso da impressora",proxyStep5:"Imprima normalmente - o tráfego é retransmitido pelo Bambuddy",proxyStep6:"O streaming da câmera requer NAT/encaminhamento de IP (veja a documentação)"},status:{title:"Detalhes do Status",printerName:"Nome da Impressora",model:"Modelo",serialNumber:"Número de Série",mode:"Modo",pendingFiles:"Arquivos Pendentes",targetPrinter:"Impressora Alvo",ftpPort:"Porta FTP",mqttPort:"Porta MQTT",ftpConnections:"Conexões FTP",mqttConnections:"Conexões MQTT"},toast:{updated:"Configurações da impressora virtual atualizadas",failedToUpdate:"Falha ao atualizar as configurações",accessCodeRequired:"Defina um código de acesso primeiro",targetPrinterRequired:"Selecione uma impressora alvo primeiro",accessCodeEmpty:"O código de acesso não pode estar vazio",accessCodeLength:"O código de acesso deve ter exatamente 8 caracteres"}},modelViewer:{openInSlicer:"Abrir no Slicer",tabs:{model:"Modelo 3D",gcode:"Pré-visualização G-code"},notAvailable:"Não disponível",notSliced:"Não fatiado",plates:"Placas",allPlates:"Todas as Placas",plateNumber:"Placa {{number}}",plateCount:"{{count}} placa",plateCount_other:"{{count}} placas",objectCount:"{{count}} objeto",objectCount_other:"{{count}} objetos",filamentCount:"{{count}} filamento",filamentCount_other:"{{count}} filamentos",eta:"ETA {{minutes}} min",noPreview:"Pré-visualização não disponível para este arquivo",pagination:{pageOf:"Página {{current}} de {{total}}",prev:"Anterior",next:"Próximo"},errors:{failedToLoad:"Falha ao carregar o arquivo",noMeshes:"Nenhuma malha encontrada no arquivo 3MF",unsupportedFormat:"Formato de arquivo não suportado"}},maintenanceDescriptions:{lubricateCarbonRods:"Aplique lubrificante nos eixos de carbono para um movimento suave",lubricateRails:"Aplique lubrificante nos trilhos lineares para um movimento suave",cleanNozzle:"Limpe o hotend e o bico para evitar entupimentos",checkBelts:"Verifique a tensão das correias para impressões precisas",cleanBuildPlate:"Limpe a placa de construção para melhor adesão",checkExtruder:"Verifique as engrenagens do extrusor quanto ao desgaste",checkCooling:"Verifique se os ventiladores de resfriamento estão funcionando corretamente",generalInspection:"Inspeção geral da impressora",cleanCarbonRods:"Limpe os eixos de carbono para reduzir o atrito",cleanLinearRails:"Limpe os trilhos lineares para remover poeira e detritos",checkPtfeTube:"Verifique o tubo PTFE quanto ao desgaste ou danos",replaceHepaFilter:"Substitua o filtro HEPA para qualidade do ar",replaceCarbonFilter:"Substitua o filtro de carbono ativado",lubricateLeftNozzleRail:"Lubrifique o trilho do bico esquerdo (série H2)"},smartPlugs:{offline:"Offline",admin:"Admin",openPlugAdminPage:"Abrir o painel de administração da tomada inteligente",deleteSmartPlug:"Excluir Tomada Inteligente",turnOnSmartPlug:"Ligar Tomada Inteligente",turnOffSmartPlug:"Desligar Tomada Inteligente",turnOn:"Ligar",turnOff:"Desligar",addSmartPlug:{scanningNetwork:"Procurando na rede...",chooseEntity:"Escolha uma entidade...",connectionFailed:"Falha na conexão",searchEntities:"Pesquisar entidades...",searchPowerSensors:"Pesquisar sensores de energia...",searchEnergySensors:"Pesquisar sensores de energia...",placeholders:{plugName:"Tomada da Sala",mqttStateOnValue:"ON, true, 1",mqttSameAsPower:"Mesmo que o tópico de energia, ou diferente"}}},richTextEditor:{bold:"Negrito",italic:"Itálico",underline:"Sublinhado",bulletList:"Lista com marcadores",numberedList:"Lista numerada",alignLeft:"Alinhar à esquerda",alignCenter:"Centralizar",alignRight:"Alinhar à direita",addLink:"Adicionar link",removeLink:"Remover link"},externalLinks:{noLinksConfigured:"Nenhum link externo configurado",deleteLink:"Excluir link",removeCustomIcon:"Remover ícone personalizado",openInNewTab:"Abrir em nova aba",placeholders:{linkName:"Meu Link"}},keyboardShortcuts:{title:"Atalhos de Teclado",navigation:"Navegação",archivesSection:"Arquivos",kProfilesSection:"K-Profiles",generalSection:"Geral",shortcuts:{goToPrinters:"Ir para Impressoras",goToArchives:"Ir para Arquivos",goToQueue:"Ir para Fila",goToStats:"Ir para Estatísticas",goToProfiles:"Ir para Perfis na Nuvem",goToSettings:"Ir para Configurações",focusSearch:"Focar na pesquisa",openUploadModal:"Abrir modal de upload",clearSelection:"Limpar seleção / desfocar input",contextMenu:"Menu de contexto nos cartões",refreshProfiles:"Atualizar perfis",newProfile:"Novo perfil",exitSelectionMode:"Sair do modo de seleção",showHelp:"Mostrar esta ajuda"},footer:"Pressione Esc ou clique fora para fechar"},notificationLog:{title:"Registro de Notificações",events:{printStarted:"Impressão Iniciada",printComplete:"Impressão Concluída",printFailed:"Impressão Falhou",printStopped:"Impressão Interrompida",progress:"Progresso",printerOffline:"Impressora Offline",printerError:"Erro na Impressora",lowFilament:"Filamento Baixo",maintenanceDue:"Manutenção Pendente",test:"Teste"},timeAgo:{justNow:"Agora mesmo",minutesAgo:"há {{minutes}} minutos",hoursAgo:"há {{hours}} horas"}},restoreBackup:{title:"Restaurar Backup",restoring:"Restaurando...",restoreComplete:"Restauração Concluída",restoreFailed:"Falha na Restauração",importSettings:"Importar configurações de um arquivo de backup",pleaseWait:"Aguarde enquanto seus dados estão sendo restaurados",clickToSelect:"Clique para selecionar o arquivo de backup (.json ou .zip)",howDuplicateHandling:"Como funciona o tratamento de duplicatas:",categories:{printers:"Impressoras",smartPlugs:"Tomadas Inteligentes",notificationProviders:"Provedores de Notificação",filaments:"Filamentos",archives:"Arquivos",pendingUploads:"Uploads Pendentes",settingsTemplates:"Configurações e Modelos"},matchingInfo:{printers:"correspondem pelo número de série",smartPlugs:"correspondem pelo endereço IP",notificationProviders:"correspondem pelo nome",filaments:"correspondem pelo nome + tipo + marca",archives:"correspondem pelo hash do conteúdo",pendingUploads:"correspondem pelo nome do arquivo",settingsTemplates:"sempre sobrescrito"},replaceExisting:"Substituir dados existentes",keepExisting:"Manter dados existentes",replaceDescription:"Substituir itens que já existem com os dados do backup",keepDescription:"Restaurar apenas itens que não existem",caution:"Atenção:",cautionText:"Sobrescrever substituirá suas configurações atuais pelos dados do backup. Os códigos de acesso da impressora nunca são sobrescritos por segurança.",itemsRestored:"Itens Restaurados",itemsSkipped:"Itens Ignorados",restored:"Restaurado",skipped:"Ignorado (já existe)",filesLabel:"Arquivos (3MF, miniaturas, etc.)",newApiKeysGenerated:"Novas Chaves API Geradas",newApiKeysWarning:"Essas chaves são exibidas apenas uma vez. Copie-as agora!",processingBackup:"Processando arquivo de backup...",noDataFound:"Nenhum dado foi encontrado para restaurar no arquivo de backup.",failedToRestore:"Falha ao restaurar o backup. Verifique o formato do arquivo."},backupExport:{title:"Exportar Backup",selectData:"Selecione os dados a incluir",selectAll:"Selecionar Todos",selectNone:"Selecionar Nenhum",categoryDescriptions:{settings:"Idioma, tema, preferências de atualização",notifications:"ntfy, Pushover, Discord, etc.",templates:"Modelos de mensagens personalizadas",smartPlugs:"Configurações de tomadas Tasmota",externalLinks:"Links da barra lateral para serviços externos",printers:"Informações da impressora (códigos de acesso excluídos)",plateDetection:"Imagens de referência de placa vazia",filaments:"Tipos e custos de filamento",maintenance:"Cronogramas de manutenção personalizados",archives:"Todos os dados de impressão + arquivos (3MF, miniaturas, fotos)",projects:"Projetos, itens de BOM e anexos",pendingUploads:"Uploads de impressora virtual aguardando revisão",apiKeys:"Chaves API de webhook (novas chaves geradas na importação)"},requiresPrinters:"Requer que as impressoras sejam selecionadas",zipFileWarning:"Um arquivo ZIP será criado.",zipFileDescription:"Inclui todos os arquivos 3MF, miniaturas, timelapses e fotos. Isso pode levar algum tempo e resultar em um arquivo grande.",includeAccessCodes:"Incluir Códigos de Acesso",includeAccessCodesDescription:"Para transferir para outra máquina",includeAccessCodesWarning:"Os códigos de acesso serão incluídos em texto simples. Mantenha este arquivo de backup seguro!",categoriesSelected:"{{selectedCount}} categorias selecionadas"},pendingUploads:{placeholders:{notes:"Adicione notas sobre esta impressão..."},discardUpload:"Descartar Upload",archiveAllUploads:"Arquivar Todos os Uploads",discardAllUploads:"Descartar Todos os Uploads",archive:"Arquivar",timeAgo:{justNow:"Agora mesmo",minutesAgo:"há {{minutes}} minutos",hoursAgo:"há {{hours}} horas",daysAgo:"há {{days}} dias"}},apiBrowser:{placeholders:{requestBody:"Corpo da requisição JSON...",searchEndpoints:"Pesquisar endpoints..."}},configureAmsSlot:{title:"Configurar Slot AMS",slotConfigured:"Slot Configurado!",configuringSlot:"Configurando slot:",slotLabel:"{{ams}} Slot {{slot}}",searchPresets:"Pesquisar predefinições...",colorPlaceholder:"Nome da cor ou hex (ex.: marrom, FF8800)",clearCustomColor:"Limpar cor personalizada",noCloudPresets:"Nenhuma predefinição na nuvem. Faça login no Bambu Cloud para sincronizar.",noPresetsAvailable:"Nenhuma predefinição disponível. Faça login no Bambu Cloud ou importe perfis locais.",noMatchingPresets:"Nenhuma predefinição correspondente encontrada.",custom:"Personalizado",builtin:"Integrado",settingsSentToPrinter:"Configurações enviadas para a impressora",filamentProfile:"Perfil de Filamento",kProfileLabel:"Perfil K (Avanço de Pressão)",filteringFor:"Filtrando por: {{material}}",noKProfile:"Nenhum perfil K (usar padrão 0.020)",noMatchingKProfiles:"Nenhum perfil K correspondente encontrado. O K padrão=0.020 será usado.",selectFilamentFirst:"Selecione um perfil de filamento primeiro",kFromCalibration:"K={{value}} da calibração da impressora",customColorLabel:"Cor Personalizada (opcional)",presetColors:"Cores de {{name}}:",showLessColors:"Mostrar menos cores",showMoreColors:"Mostrar mais cores",clear:"Limpar",hexLabel:"Hex: #{{hex}}",resetting:"Redefinindo...",resetSlot:"Redefinir Slot",cancel:"Cancelar",configuring:"Configurando...",configureSlot:"Configurar Slot"},githubBackup:{title:"Backup do GitHub",history:"Histórico",downloadBackup:"Baixar Backup",restoreBackup:"Restaurar Backup",noBackupsYet:"Nenhum backup ainda"},emailSettings:{placeholders:{fromName:"BamBuddy"}},tagManagement:{searchTags:"Pesquisar tags...",renameTag:"Renomear tag",deleteTag:"Excluir tag"},notificationTemplates:{placeholders:{title:"Título da notificação...",body:"Corpo da notificação..."}},batchTag:{placeholders:{newTag:"Digite uma nova tag..."}},photoGallery:{deletePhoto:"Excluir foto"},filamentHoverCard:{copySpoolUuid:"Copiar UUID do carretel"},kProfilesView:{hasNote:"Possui nota",copyProfile:"Copiar perfil"},layout:{openMenu:"Abrir menu",noPermissionSystemInfo:"Você não tem permissão para visualizar informações do sistema"},dashboard:{dragToReorder:"Arrastar para reordenar",hideWidget:"Ocultar widget"},notificationProviderCard:{deleteNotificationProvider:"Excluir provedor de notificação"},fileManagerModal:{closeFileManager:"Fechar gerenciador de arquivos",sortFiles:"Ordenar arquivos",goToParentFolder:"Ir para a pasta pai",threeView:"Visualização 3D"},embeddedCameraViewer:{refreshStream:"Atualizar stream",close:"Fechar",zoomOut:"Reduzir zoom",resetZoom:"Redefinir zoom",zoomIn:"Aumentar zoom",dragToResize:"Arrastar para redimensionar"},timelapseViewer:{skipBack5s:"Voltar 5s",skipForward5s:"Avançar 5s"},notificationProviders:{descriptions:{email:"Notificações por email SMTP",telegram:"Notificações via bot do Telegram",discord:"Enviar para canal do Discord via webhook",ntfy:"Notificações push gratuitas e auto-hospedáveis",pushover:"Notificações push simples e confiáveis",callmebot:"Notificações gratuitas via WhatsApp pelo CallMeBot",webhook:"POST HTTP genérico para qualquer URL"}},logViewer:{searchPlaceholder:"Pesquisar mensagem ou nome do logger...",noLogEntries:"Nenhuma entrada de log encontrada"},switchbarPopover:{noSwitchesInSwitchbar:"Nenhum switch na barra de switches"},projectPageModal:{placeholders:{title:"Título",designer:"Designer",license:"Licença",description:"Digite a descrição...",profileTitle:"Título do perfil",profileDescription:"Descrição do perfil..."}},spoolmanSettings:{},spoolbuddy:{nav:{dashboard:"Painel",ams:"AMS",inventory:"Inventário",writeTag:"Escrever",settings:"Configurações"},status:{nfcReady:"NFC pronto",nfcOff:"NFC desligado",offline:"Offline",online:"Online",noPrinters:"Sem impressoras",deviceOffline:"Dispositivo offline",waitingConnection:"Aguardando conexão do dispositivo...",systemReady:"Sistema pronto",status:"Status"},dashboard:{readyToScan:"Pronto para escanear",idleMessage:"Coloque um carretel na balança para identificá-lo",nfcHint:"A tag NFC será lida automaticamente",device:"Dispositivo",syncWeight:"Sincronizar peso",weightSynced:"Sincronizado!",unknownTag:"Tag desconhecida",newTag:"Nova tag detectada",onScale:"na balança",linkSpool:"Vincular ao carretel",linkTagTitle:"Vincular tag ao carretel",linkTag:"Vincular tag",selectSpool:"Selecione um carretel para vincular a esta tag:",noUntagged:"Nenhum carretel sem tag encontrado",tagDetected:"Tag detectada",noTag:"Sem tag",tagId:"Tag",grossWeight:"Peso bruto",spoolSize:"Tamanho do carretel",close:"Fechar"},weight:{noReading:"Sem leitura",stable:"Estável",measuring:"Medindo...",tare:"Tarar",calibrate:"Calibrar"},spool:{remaining:"Restante",material:"Material",brand:"Marca",color:"Cor",coreWeight:"Núcleo",labelWeight:"Rótulo",scaleWeight:"Balança",netWeight:"Líquido",lastUsed:"Último uso"},ams:{noData:"Nenhum AMS detectado",connectAms:"Conecte um AMS para ver os slots",noPrinter:"Nenhuma impressora selecionada",selectPrinter:"Selecione uma impressora na barra superior",printerDisconnected:"Impressora desconectada",humidity:"Umidade",level:"Nível",active:"Ativo",slot:"Slot",empty:"Vazio"},inventory:{search:"Buscar carretéis...",empty:"Nenhum carretel no inventário",noResults:"Nenhum carretel correspondente",spools:"carretéis",addSpool:"Adicionar carretel"},settings:{tabDevice:"Dispositivo",tabDisplay:"Tela",tabScale:"Balança",tabUpdates:"Atualizações",nfcReader:"Leitor NFC",type:"Tipo",connection:"Conexão",notConnected:"N/A",deviceInfo:"Info do dispositivo",hostname:"Host",uptime:"Tempo de atividade",brightness:"Brilho",saved:"Salvo",noBacklight:"Nenhuma retroiluminação DSI detectada. O controle de brilho requer uma tela DSI.",screenBlank:"Tempo para desligar tela",screenBlankDesc:"A tela desliga após inatividade. Toque para despertar.",displayNote:"O brilho é aplicado como filtro de software.",scaleCalibration:"Calibração da balança",currentWeight:"Peso atual",tareOffset:"Tara",calFactor:"Fator",knownWeight:"Peso conhecido",calStep1:"Remova todos os itens da balança e pressione Definir zero.",calStep2:"Coloque o peso conhecido na balança.",setZero:"Definir zero",calibrateNow:"Calibrar",calibrated:"Calibrado",tareSet:"Comando de tara enviado. Aguardando dispositivo...",tareFailed:"Falha ao enviar comando de tara",zeroSet:"Ponto zero definido. Coloque o peso conhecido na balança.",calibrationDone:"Calibração concluída!",calibrationFailed:"Falha na calibração",lastCalibrated:"Última calibração",stable:"Estável",settling:"Estabilizando...",firmware:"Firmware",scale:"Balança",noDevice:"Nenhum dispositivo SpoolBuddy encontrado",daemonVersion:"Versão do daemon",currentVersion:"Atual",versionPending:"Aguardando daemon...",checking:"Verificando...",checkUpdates:"Verificar atualizações",updateAvailable:"Atualização disponível",updateInstructions:"Atualize via SSH: execute o script de instalação do SpoolBuddy.",upToDate:"Atualizado",includeBeta:"Incluir versões beta"},writeTag:{tabExisting:"Bobina existente",tabNew:"Nova bobina",tabReplace:"Substituir tag",searchPlaceholder:"Buscar por material, cor, marca...",noUntaggedSpools:"Nenhuma bobina sem tag",noTaggedSpools:"Nenhuma bobina com tag",selectSpool:"Selecione uma bobina e coloque um NTAG no leitor",placeTag:"Coloque um NTAG no leitor",tagReady:"Tag detectado — pronto para gravar",writeTag:"Gravar Tag",replaceTag:"Substituir Tag",writing:"Gravando tag...",waiting:"Aguardando SpoolBuddy...",writeSuccess:"Tag gravado com sucesso!",writeFailed:"Falha na gravação",queueFailed:"Falha ao enfileirar comando de gravação",tryAgain:"Tentar novamente",cancel:"Cancelar",replaceWarning:"O tag antigo será desvinculado. O novo tag o substituirá.",deviceOffline:"SpoolBuddy está offline",material:"Material",colorName:"Nome da cor",color:"Cor",brand:"Marca",weight:"Peso (g)",createSpool:"Criar bobina",creating:"Criando...",spoolCreated:"Bobina criada! Pronto para gravar.",createFailed:"Falha ao criar bobina"}}},Hce={en:{translation:Lce},de:{translation:Oce},fr:{translation:Ice},ja:{translation:zce},it:{translation:Uce},"pt-BR":{translation:Bce}};Hs.use(YK).use(fce).init({resources:Hce,fallbackLng:"en",supportedLngs:["en","de","fr","ja","it","pt-BR"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const PB=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"},{code:"fr",name:"French",nativeName:"Français"},{code:"ja",name:"Japanese",nativeName:"日本語"},{code:"it",name:"Italian",nativeName:"Italiano"},{code:"pt-BR",name:"Portuguese (Brazil)",nativeName:"Português (Brasil)"}];var jB="popstate";function $ce(t={}){function e(r,i){let{pathname:s,search:o,hash:l}=r.location;return r3("",{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 qce(e,n,null,t)}function ga(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function wl(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Vce(){return Math.random().toString(36).substring(2,10)}function EB(t,e){return{usr:t.state,key:t.key,idx:e}}function r3(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Kb(e):e,state:n,key:e&&e.key||r||Vce()}}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 Kb(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 qce(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 g=d(),y=g==null?null:g-u;u=g,c&&c({action:l,location:v.location,delta:y})}function f(g,y){l="PUSH";let _=r3(v.location,g,y);u=d()+1;let N=EB(_,u),A=v.createHref(_);try{o.pushState(N,"",A)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;i.location.assign(A)}s&&c&&c({action:l,location:v.location,delta:1})}function p(g,y){l="REPLACE";let _=r3(v.location,g,y);u=d();let N=EB(_,u),A=v.createHref(_);o.replaceState(N,"",A),s&&c&&c({action:l,location:v.location,delta:0})}function x(g){return Gce(g)}let v={get action(){return l},get location(){return t(i,o)},listen(g){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(jB,h),c=g,()=>{i.removeEventListener(jB,h),c=null}},createHref(g){return e(i,g)},createURL:x,encodeLocation(g){let y=x(g);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:f,replace:p,go(g){return o.go(g)}};return v}function Gce(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ga(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 XK(t,e,n="/"){return Wce(t,e,n,!1)}function Wce(t,e,n,r){let i=typeof e=="string"?Kb(e):e,s=td(i.pathname||"/",n);if(s==null)return null;let o=QK(t);Kce(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=iue(s);l=rue(o[c],u,r)}return l}function QK(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;ga(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=Gu([r,d.relativePath]),f=n.concat(d);o.children&&o.children.length>0&&(ga(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),QK(o.children,e,f,h,c)),!(o.path==null&&!o.index)&&e.push({path:h,score:tue(h,o.index),routesMeta:f})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))s(o,l);else for(let c of ZK(o.path))s(o,l,!0,c)}),e}function ZK(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=ZK(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 Kce(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:nue(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Yce=/^:[\w-]+$/,Xce=3,Qce=2,Zce=1,Jce=10,eue=-2,DB=t=>t==="*";function tue(t,e){let n=t.split("/"),r=n.length;return n.some(DB)&&(r+=eue),e&&(r+=Qce),n.filter(i=>!DB(i)).reduce((i,s)=>i+(Yce.test(s)?Xce:s===""?Zce:Jce),r)}function nue(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 rue(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=k1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),f=c.route;if(!h&&u&&n&&!r[r.length-1].route.index&&(h=k1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(i,h.params),o.push({params:i,pathname:Gu([s,h.pathname]),pathnameBase:cue(Gu([s,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(s=Gu([s,h.pathnameBase]))}return o}function k1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=aue(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},f)=>{if(d==="*"){let x=l[f]||"";o=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[f];return h&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:o,pattern:t}}function aue(t,e=!1,n=!0){wl(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 iue(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return wl(!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 td(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 sue=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function oue(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Kb(t):t,s;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?s=RB(n.substring(1),"/"):s=RB(n,e)):s=e,{pathname:s,search:uue(r),hash:due(i)}}function RB(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 q2(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 lue(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function SF(t){let e=lue(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function _F(t,e,n,r=!1){let i;typeof t=="string"?i=Kb(t):(i={...t},ga(!i.pathname||!i.pathname.includes("?"),q2("?","pathname","search",i)),ga(!i.pathname||!i.pathname.includes("#"),q2("#","pathname","hash",i)),ga(!i.search||!i.search.includes("#"),q2("#","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 f=o.split("/");for(;f[0]==="..";)f.shift(),h-=1;i.pathname=f.join("/")}l=h>=0?e[h]:"/"}let c=oue(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Gu=t=>t.join("/").replace(/\/\/+/g,"/"),cue=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),uue=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,due=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,hue=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 mue(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function fue(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var JK=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function eY(t,e){let n=t;if(typeof n!="string"||!sue.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(JK)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=td(o.pathname,e);o.origin===s.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{wl(!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 tY=["POST","PUT","PATCH","DELETE"];new Set(tY);var pue=["GET",...tY];new Set(pue);var Yb=w.createContext(null);Yb.displayName="DataRouter";var Kk=w.createContext(null);Kk.displayName="DataRouterState";var gue=w.createContext(!1),nY=w.createContext({isTransitioning:!1});nY.displayName="ViewTransition";var bue=w.createContext(new Map);bue.displayName="Fetchers";var xue=w.createContext(null);xue.displayName="Await";var zo=w.createContext(null);zo.displayName="Navigation";var pv=w.createContext(null);pv.displayName="Location";var Pl=w.createContext({outlet:null,matches:[],isDataRoute:!1});Pl.displayName="Route";var NF=w.createContext(null);NF.displayName="RouteError";var rY="REACT_ROUTER_ERROR",yue="REDIRECT",vue="ROUTE_ERROR_RESPONSE";function wue(t){if(t.startsWith(`${rY}:${yue}:{`))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 Sue(t){if(t.startsWith(`${rY}:${vue}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new hue(e.status,e.statusText,e.data)}catch{}}function _ue(t,{relative:e}={}){ga(Xb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(zo),{hash:i,pathname:s,search:o}=xv(t,{relative:e}),l=s;return n!=="/"&&(l=s==="/"?n:Gu([n,s])),r.createHref({pathname:l,search:o,hash:i})}function Xb(){return w.useContext(pv)!=null}function Wc(){return ga(Xb(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(pv).location}var aY="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function iY(t){w.useContext(zo).static||w.useLayoutEffect(t)}function jl(){let{isDataRoute:t}=w.useContext(Pl);return t?Oue():Nue()}function Nue(){ga(Xb(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(Yb),{basename:e,navigator:n}=w.useContext(zo),{matches:r}=w.useContext(Pl),{pathname:i}=Wc(),s=JSON.stringify(SF(r)),o=w.useRef(!1);return iY(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(wl(o.current,aY),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=_F(c,JSON.parse(s),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Gu([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,s,i,t])}var sY=w.createContext(null);function gv(){return w.useContext(sY)}function kue(t){let e=w.useContext(Pl).outlet;return w.useMemo(()=>e&&w.createElement(sY.Provider,{value:t},e),[e,t])}function bv(){let{matches:t}=w.useContext(Pl),e=t[t.length-1];return e?e.params:{}}function xv(t,{relative:e}={}){let{matches:n}=w.useContext(Pl),{pathname:r}=Wc(),i=JSON.stringify(SF(n));return w.useMemo(()=>_F(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Cue(t,e){return oY(t,e)}function oY(t,e,n,r,i){ga(Xb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=w.useContext(zo),{matches:o}=w.useContext(Pl),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",h=l&&l.route;{let _=h&&h.path||"";cY(u,!h||_.endsWith("*")||_.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${_}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
  10. Please change the parent <Route path="${_}"> to <Route path="${_==="/"?"*":`${_}/*`}">.`)}let f=Wc(),p;if(e){let _=typeof e=="string"?Kb(e):e;ga(d==="/"||_.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 "${_.pathname}" was given in the \`location\` prop.`),p=_}else p=f;let x=p.pathname||"/",v=x;if(d!=="/"){let _=d.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(_.length).join("/")}let g=XK(t,{pathname:v});wl(h||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),wl(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=jue(g&&g.map(_=>Object.assign({},_,{params:Object.assign({},c,_.params),pathname:Gu([d,s.encodeLocation?s.encodeLocation(_.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathname]),pathnameBase:_.pathnameBase==="/"?d:Gu([d,s.encodeLocation?s.encodeLocation(_.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathnameBase])})),o,n,r,i);return e&&y?w.createElement(pv.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},y):y}function Aue(){let t=Lue(),e=mue(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=w.createElement(w.Fragment,null,w.createElement("p",null,"💿 Hey developer 👋"),w.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",w.createElement("code",{style:s},"ErrorBoundary")," or"," ",w.createElement("code",{style:s},"errorElement")," prop on your route.")),w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},e),n?w.createElement("pre",{style:i},n):null,o)}var Tue=w.createElement(Aue,null),lY=class extends w.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=Sue(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(Pl.Provider,{value:this.props.routeContext},w.createElement(NF.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(Mue,{error:t},e):e}};lY.contextType=gue;var G2=new WeakMap;function Mue({children:t,error:e}){let{basename:n}=w.useContext(zo);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=wue(e.digest);if(r){let i=G2.get(e);if(i)throw i;let s=eY(r.location,n);if(JK&&!G2.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 G2.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return t}function Pue({routeContext:t,match:e,children:n}){let r=w.useContext(Yb);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(Pl.Provider,{value:t},n)}function jue(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);ga(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:f,errors:p}=n,x=h.route.loader&&!f.hasOwnProperty(h.route.id)&&(!p||p[h.route.id]===void 0);if(h.route.lazy||x){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:fue(n.matches),errorInfo:h})}:void 0;return s.reduceRight((d,h,f)=>{let p,x=!1,v=null,g=null;n&&(p=o&&h.route.id?o[h.route.id]:void 0,v=h.route.errorElement||Tue,l&&(c<0&&f===0?(cY("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,g=null):c===f&&(x=!0,g=h.route.hydrateFallbackElement||null)));let y=e.concat(s.slice(0,f+1)),_=()=>{let N;return p?N=v:x?N=g:h.route.Component?N=w.createElement(h.route.Component,null):h.route.element?N=h.route.element:N=d,w.createElement(Pue,{match:h,routeContext:{outlet:d,matches:y,isDataRoute:n!=null},children:N})};return n&&(h.route.ErrorBoundary||h.route.errorElement||f===0)?w.createElement(lY,{location:n.location,revalidation:n.revalidation,component:v,error:p,children:_(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:u}):_()},null)}function kF(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Eue(t){let e=w.useContext(Yb);return ga(e,kF(t)),e}function Due(t){let e=w.useContext(Kk);return ga(e,kF(t)),e}function Rue(t){let e=w.useContext(Pl);return ga(e,kF(t)),e}function CF(t){let e=Rue(t),n=e.matches[e.matches.length-1];return ga(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Fue(){return CF("useRouteId")}function Lue(){let t=w.useContext(NF),e=Due("useRouteError"),n=CF("useRouteError");return t!==void 0?t:e.errors?.[n]}function Oue(){let{router:t}=Eue("useNavigate"),e=CF("useNavigate"),n=w.useRef(!1);return iY(()=>{n.current=!0}),w.useCallback(async(i,s={})=>{wl(n.current,aY),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var FB={};function cY(t,e,n){!e&&!FB[t]&&(FB[t]=!0,wl(!1,n))}w.memo(Iue);function Iue({routes:t,future:e,state:n,onError:r}){return oY(t,void 0,n,r,e)}function gb({to:t,replace:e,state:n,relative:r}){ga(Xb(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(zo);wl(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=w.useContext(Pl),{pathname:o}=Wc(),l=jl(),c=_F(t,SF(s),o,r==="path"),u=JSON.stringify(c);return w.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function uY(t){return kue(t.context)}function Mr(t){ga(!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 zue({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1,unstable_useTransitions:o}){ga(!Xb(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=w.useMemo(()=>({basename:l,navigator:i,static:s,unstable_useTransitions:o,future:{}}),[l,i,s,o]);typeof n=="string"&&(n=Kb(n));let{pathname:u="/",search:d="",hash:h="",state:f=null,key:p="default"}=n,x=w.useMemo(()=>{let v=td(u,l);return v==null?null:{location:{pathname:v,search:d,hash:h,state:f,key:p},navigationType:r}},[l,u,d,h,f,p,r]);return wl(x!=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.`),x==null?null:w.createElement(zo.Provider,{value:c},w.createElement(pv.Provider,{children:e,value:x}))}function Uue({children:t,location:e}){return Cue(a3(t),e)}function a3(t,e=[]){let n=[];return w.Children.forEach(t,(r,i)=>{if(!w.isValidElement(r))return;let s=[...e,i];if(r.type===w.Fragment){n.push.apply(n,a3(r.props.children,s));return}ga(r.type===Mr,`[${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>`),ga(!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=a3(r.props.children,s)),n.push(o)}),n}var Y_="get",X_="application/x-www-form-urlencoded";function Yk(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Bue(t){return Yk(t)&&t.tagName.toLowerCase()==="button"}function Hue(t){return Yk(t)&&t.tagName.toLowerCase()==="form"}function $ue(t){return Yk(t)&&t.tagName.toLowerCase()==="input"}function Vue(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function que(t,e){return t.button===0&&(!e||e==="_self")&&!Vue(t)}function i3(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 Gue(t,e){let n=i3(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(s=>{n.append(i,s)})}),n}var lS=null;function Wue(){if(lS===null)try{new FormData(document.createElement("form"),0),lS=!1}catch{lS=!0}return lS}var Kue=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function W2(t){return t!=null&&!Kue.has(t)?(wl(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${X_}"`),null):t}function Yue(t,e){let n,r,i,s,o;if(Hue(t)){let l=t.getAttribute("action");r=l?td(l,e):null,n=t.getAttribute("method")||Y_,i=W2(t.getAttribute("enctype"))||X_,s=new FormData(t)}else if(Bue(t)||$ue(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?td(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||Y_,i=W2(t.getAttribute("formenctype"))||W2(l.getAttribute("enctype"))||X_,s=new FormData(l,t),!Wue()){let{name:u,type:d,value:h}=t;if(d==="image"){let f=u?`${u}.`:"";s.append(`${f}x`,"0"),s.append(`${f}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=Y_,r=null,i=X_,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 AF(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Xue(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&&td(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function Que(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 Zue(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 Jue(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let o=await Que(s,n);return o.links?o.links():[]}return[]}));return rde(r.flat(1).filter(Zue).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function LB(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 ede(t,e,{includeHydrateFallback:n}={}){return tde(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 tde(t){return[...new Set(t)]}function nde(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function rde(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(nde(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function dY(){let t=w.useContext(Yb);return AF(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function ade(){let t=w.useContext(Kk);return AF(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var TF=w.createContext(void 0);TF.displayName="FrameworkContext";function hY(){let t=w.useContext(TF);return AF(t,"You must render this element inside a <HydratedRouter> element"),t}function ide(t,e){let n=w.useContext(TF),[r,i]=w.useState(!1),[s,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:h}=e,f=w.useRef(null);w.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let v=y=>{y.forEach(_=>{o(_.isIntersecting)})},g=new IntersectionObserver(v,{threshold:.5});return f.current&&g.observe(f.current),()=>{g.disconnect()}}},[t]),w.useEffect(()=>{if(r){let v=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(v)}}},[r]);let p=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[s,f,{}]:[s,f,{onFocus:ly(l,p),onBlur:ly(c,x),onMouseEnter:ly(u,p),onMouseLeave:ly(d,x),onTouchStart:ly(h,p)}]:[!1,f,{}]}function ly(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function sde({page:t,...e}){let{router:n}=dY(),r=w.useMemo(()=>XK(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(lde,{page:t,matches:r,...e}):null}function ode(t){let{manifest:e,routeModules:n}=hY(),[r,i]=w.useState([]);return w.useEffect(()=>{let s=!1;return Jue(t,e,n).then(o=>{s||i(o)}),()=>{s=!0}},[t,e,n]),r}function lde({page:t,matches:e,...n}){let r=Wc(),{future:i,manifest:s,routeModules:o}=hY(),{basename:l}=dY(),{loaderData:c,matches:u}=ade(),d=w.useMemo(()=>LB(t,e,u,s,r,"data"),[t,e,u,s,r]),h=w.useMemo(()=>LB(t,e,u,s,r,"assets"),[t,e,u,s,r]),f=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let v=new Set,g=!1;if(e.forEach(_=>{let N=s.routes[_.route.id];!N||!N.hasLoader||(!d.some(A=>A.route.id===_.route.id)&&_.route.id in c&&o[_.route.id]?.shouldRevalidate||N.hasClientLoader?g=!0:v.add(_.route.id))}),v.size===0)return[];let y=Xue(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return g&&v.size>0&&y.searchParams.set("_routes",e.filter(_=>v.has(_.route.id)).map(_=>_.route.id).join(",")),[y.pathname+y.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,s,d,e,t,o]),p=w.useMemo(()=>ede(h,s),[h,s]),x=ode(h);return w.createElement(w.Fragment,null,f.map(v=>w.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),p.map(v=>w.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),x.map(({key:v,link:g})=>w.createElement("link",{key:v,nonce:n.nonce,...g,crossOrigin:g.crossOrigin??n.crossOrigin})))}function cde(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var ude=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ude&&(window.__reactRouterVersion="7.13.0")}catch{}function dde({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=w.useRef();i.current==null&&(i.current=$ce({window:r,v5Compat:!0}));let s=i.current,[o,l]=w.useState({action:s.action,location:s.location}),c=w.useCallback(u=>{n===!1?l(u):w.startTransition(()=>l(u))},[n]);return w.useLayoutEffect(()=>s.listen(c),[s,c]),w.createElement(zue,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:s,unstable_useTransitions:n})}var mY=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Zs=w.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:f,...p},x){let{basename:v,unstable_useTransitions:g}=w.useContext(zo),y=typeof u=="string"&&mY.test(u),_=eY(u,v);u=_.to;let N=_ue(u,{relative:i}),[A,C,j]=ide(r,p),k=fde(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:h,unstable_defaultShouldRevalidate:f,unstable_useTransitions:g});function R(D){e&&e(D),D.defaultPrevented||k(D)}let M=w.createElement("a",{...p,...j,href:_.absoluteURL||N,onClick:_.isExternal||s?e:R,ref:cde(x,C),target:c,"data-discover":!y&&n==="render"?"true":void 0});return A&&!y?w.createElement(w.Fragment,null,M,w.createElement(sde,{page:N})):M});Zs.displayName="Link";var Gg=w.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:o,viewTransition:l,children:c,...u},d){let h=xv(o,{relative:u.relative}),f=Wc(),p=w.useContext(Kk),{navigator:x,basename:v}=w.useContext(zo),g=p!=null&&yde(h)&&l===!0,y=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,_=f.pathname,N=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(_=_.toLowerCase(),N=N?N.toLowerCase():null,y=y.toLowerCase()),N&&v&&(N=td(N,v)||N);const A=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let C=_===y||!i&&_.startsWith(y)&&_.charAt(A)==="/",j=N!=null&&(N===y||!i&&N.startsWith(y)&&N.charAt(y.length)==="/"),k={isActive:C,isPending:j,isTransitioning:g},R=C?e:void 0,M;typeof r=="function"?M=r(k):M=[r,C?"active":null,j?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let D=typeof s=="function"?s(k):s;return w.createElement(Zs,{...u,"aria-current":R,className:M,ref:d,style:D,to:o,viewTransition:l},typeof c=="function"?c(k):c)});Gg.displayName="NavLink";var hde=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:o=Y_,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:f,...p},x)=>{let{unstable_useTransitions:v}=w.useContext(zo),g=bde(),y=xde(l,{relative:u}),_=o.toLowerCase()==="get"?"get":"post",N=typeof l=="string"&&mY.test(l),A=C=>{if(c&&c(C),C.defaultPrevented)return;C.preventDefault();let j=C.nativeEvent.submitter,k=j?.getAttribute("formmethod")||o,R=()=>g(j||C.currentTarget,{fetcherKey:e,method:k,navigate:n,replace:i,state:s,relative:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:f});v&&n!==!1?w.startTransition(()=>R()):R()};return w.createElement("form",{ref:x,method:_,action:y,onSubmit:r?c:A,...p,"data-discover":!N&&t==="render"?"true":void 0})});hde.displayName="Form";function mde(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function fY(t){let e=w.useContext(Yb);return ga(e,mde(t)),e}function fde(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=jl(),d=Wc(),h=xv(t,{relative:s});return w.useCallback(f=>{if(que(f,e)){f.preventDefault();let p=n!==void 0?n:w0(d)===w0(h),x=()=>u(t,{replace:p,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l});c?w.startTransition(()=>x()):x()}},[d,u,h,n,r,e,t,i,s,o,l,c])}function MF(t){wl(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=w.useRef(i3(t)),n=w.useRef(!1),r=Wc(),i=w.useMemo(()=>Gue(r.search,n.current?null:e.current),[r.search]),s=jl(),o=w.useCallback((l,c)=>{const u=i3(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,s("?"+u,c)},[s,i]);return[i,o]}var pde=0,gde=()=>`__${String(++pde)}__`;function bde(){let{router:t}=fY("useSubmit"),{basename:e}=w.useContext(zo),n=Fue(),r=t.fetch,i=t.navigate;return w.useCallback(async(s,o={})=>{let{action:l,method:c,encType:u,formData:d,body:h}=Yue(s,e);if(o.navigate===!1){let f=o.fetcherKey||gde();await r(f,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 xde(t,{relative:e}={}){let{basename:n}=w.useContext(zo),r=w.useContext(Pl);ga(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...xv(t||".",{relative:e})},o=Wc();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:Gu([n,s.pathname])),w0(s)}function yde(t,{relative:e}={}){let n=w.useContext(nY);ga(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=fY("useViewTransitionState"),i=xv(t,{relative:e});if(!n.isTransitioning)return!1;let s=td(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=td(n.nextLocation.pathname,r)||n.nextLocation.pathname;return k1(i.pathname,o)!=null||k1(i.pathname,s)!=null}var Iu=zK();const vde=Ml(Iu);var op=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(){}},wde={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Sde=class{#t=wde;#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)}},rf=new Sde;function _de(t){setTimeout(t,0)}var Rf=typeof window>"u"||"Deno"in globalThis;function ps(){}function Nde(t,e){return typeof t=="function"?t(e):t}function s3(t){return typeof t=="number"&&t>=0&&t!==1/0}function pY(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Dh(t,e){return typeof t=="function"?t(e):t}function al(t,e){return typeof t=="function"?t(e):t}function OB(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==PF(o,e.options))return!1}else if(!S0(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 IB(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(Ff(e.options.mutationKey)!==Ff(s))return!1}else if(!S0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function PF(t,e){return(e?.queryKeyHashFn||Ff)(t)}function Ff(t){return JSON.stringify(t,(e,n)=>o3(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function S0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>S0(t[n],e[n])):!1}var kde=Object.prototype.hasOwnProperty;function jF(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=zB(t)&&zB(e);if(!r&&!(o3(t)&&o3(e)))return e;const s=(r?t:Object.keys(t)).length,o=r?e:Object.keys(e),l=o.length,c=r?new Array(l):{};let u=0;for(let d=0;d<l;d++){const h=r?d:o[d],f=t[h],p=e[h];if(f===p){c[h]=f,(r?d<s:kde.call(t,h))&&u++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){c[h]=p;continue}const x=jF(f,p,n+1);c[h]=x,x===f&&u++}return s===l&&u===s?t:c}function _0(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 zB(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function o3(t){if(!UB(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!UB(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function UB(t){return Object.prototype.toString.call(t)==="[object Object]"}function Cde(t){return new Promise(e=>{rf.setTimeout(e,t)})}function l3(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?jF(t,e):e}function Ade(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Tde(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var EF=Symbol();function gY(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===EF?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function DF(t,e){return typeof t=="function"?t(...e):!!t}function Mde(t,e,n){let r=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??=e(),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),t}var Pde=class extends op{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!Rf&&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"}},RF=new Pde;function c3(){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 jde=_de;function Ede(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=jde;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 Fa=Ede(),Dde=class extends op{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!Rf&&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}},C1=new Dde;function Rde(t){return Math.min(1e3*2**t,3e4)}function bY(t){return(t??"online")==="online"?C1.isOnline():!0}var u3=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function xY(t){let e=!1,n=0,r;const i=c3(),s=()=>i.status!=="pending",o=v=>{if(!s()){const g=new u3(v);f(g),t.onCancel?.(g)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>RF.isFocused()&&(t.networkMode==="always"||C1.isOnline())&&t.canRun(),d=()=>bY(t.networkMode)&&t.canRun(),h=v=>{s()||(r?.(),i.resolve(v))},f=v=>{s()||(r?.(),i.reject(v))},p=()=>new Promise(v=>{r=g=>{(s()||u())&&v(g)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),x=()=>{if(s())return;let v;const g=n===0?t.initialPromise:void 0;try{v=g??t.fn()}catch(y){v=Promise.reject(y)}Promise.resolve(v).then(h).catch(y=>{if(s())return;const _=t.retry??(Rf?0:3),N=t.retryDelay??Rde,A=typeof N=="function"?N(n,y):N,C=_===!0||typeof _=="number"&&n<_||typeof _=="function"&&_(n,y);if(e||!C){f(y);return}n++,t.onFail?.(n,y),Cde(A).then(()=>u()?void 0:p()).then(()=>{e?f(y):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():p().then(x),i)}}var yY=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),s3(this.gcTime)&&(this.#t=rf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Rf?1/0:300*1e3))}clearGcTimeout(){this.#t&&(rf.clearTimeout(this.#t),this.#t=void 0)}},Fde=class extends yY{#t;#e;#n;#a;#r;#i;#o;constructor(t){super(),this.#o=!1,this.#i=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#a=t.client,this.#n=this.#a.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=HB(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.#i,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=HB(this.options);e.data!==void 0&&(this.setState(BB(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=l3(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(ps).catch(ps):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>al(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===EF||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Dh(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:!pY(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=gY(this.options,e),u=(()=>{const d={client:this.#a,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.#a,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=xY({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof u3&&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 u3){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,...vY(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...BB(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",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),Fa.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function vY(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:bY(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function BB(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function HB(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 FF=class extends op{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=c3(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#n=void 0;#a=void 0;#r;#i;#o;#s;#f;#d;#h;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),$B(this.#e,this.options)?this.#p():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return d3(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return d3(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 al(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#e.setOptions(this.options),e._defaulted&&!_0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&VB(this.#e,n,this.options,e)&&this.#p(),this.updateResult(),r&&(this.#e!==n||al(this.options.enabled,this.#e)!==al(e.enabled,this.#e)||Dh(this.options.staleTime,this.#e)!==Dh(e.staleTime,this.#e))&&this.#g();const i=this.#b();r&&(this.#e!==n||al(this.options.enabled,this.#e)!==al(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 Ode(this,n)&&(this.#a=n,this.#i=this.options,this.#r=this.#e.state),n}getCurrentResult(){return this.#a}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.#m.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.#p({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#p(t){this.#S();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(ps)),e}#g(){this.#v();const t=Dh(this.options.staleTime,this.#e);if(Rf||this.#a.isStale||!s3(t))return;const n=pY(this.#a.dataUpdatedAt,t)+1;this.#c=rf.setTimeout(()=>{this.#a.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,!(Rf||al(this.options.enabled,this.#e)===!1||!s3(this.#l)||this.#l===0)&&(this.#u=rf.setInterval(()=>{(this.options.refetchIntervalInBackground||RF.isFocused())&&this.#p()},this.#l))}#y(){this.#g(),this.#x(this.#b())}#v(){this.#c&&(rf.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(rf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#a,s=this.#r,o=this.#i,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},h=!1,f;if(e._optimisticResults){const R=this.hasListeners(),M=!R&&$B(t,e),D=R&&VB(t,n,e,r);(M||D)&&(d={...d,...vY(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:v}=d;f=d.data;let g=!1;if(e.placeholderData!==void 0&&f===void 0&&v==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,g=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,R!==void 0&&(v="success",f=l3(i?.data,R,e),h=!0)}if(e.select&&f!==void 0&&!g)if(i&&f===s?.data&&e.select===this.#f)f=this.#d;else try{this.#f=e.select,f=e.select(f),f=l3(i?.data,f,e),this.#d=f,this.#s=null}catch(R){this.#s=R}this.#s&&(p=this.#s,f=this.#d,x=Date.now(),v="error");const y=d.fetchStatus==="fetching",_=v==="pending",N=v==="error",A=_&&y,C=f!==void 0,k={status:v,fetchStatus:d.fetchStatus,isPending:_,isSuccess:v==="success",isError:N,isInitialLoading:A,isLoading:A,data:f,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!_,isLoadingError:N&&!C,isPaused:d.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:N&&C,isStale:LF(t,e),refetch:this.refetch,promise:this.#o,isEnabled:al(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=k.data!==void 0,M=k.status==="error"&&!R,D=W=>{M?W.reject(k.error):R&&W.resolve(k.data)},G=()=>{const W=this.#o=k.promise=c3();D(W)},U=this.#o;switch(U.status){case"pending":t.queryHash===n.queryHash&&D(U);break;case"fulfilled":(M||k.data!==U.value)&&G();break;case"rejected":(!M||k.error!==U.reason)&&G();break}}return k}updateResult(){const t=this.#a,e=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#i=this.options,this.#r.data!==void 0&&(this.#h=this.#e),_0(e,t))return;this.#a=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#m.size)return!0;const s=new Set(i??this.#m);return this.options.throwOnError&&s.add("error"),Object.keys(this.#a).some(o=>{const l=o;return this.#a[l]!==t[l]&&s.has(l)})};this.#_({listeners:n()})}#S(){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()}#_(t){Fa.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#a)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Lde(t,e){return al(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function $B(t,e){return Lde(t,e)||t.state.data!==void 0&&d3(t,e,e.refetchOnMount)}function d3(t,e,n){if(al(e.enabled,t)!==!1&&Dh(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&LF(t,e)}return!1}function VB(t,e,n,r){return(t!==e||al(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&LF(t,n)}function LF(t,e){return al(e.enabled,t)!==!1&&t.isStaleByTime(Dh(e.staleTime,t))}function Ode(t,e){return!_0(t.getCurrentResult(),e)}function qB(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=x=>{Mde(x,()=>e.signal,()=>d=!0)},f=gY(e.options,e.fetchOptions),p=async(x,v,g)=>{if(d)return Promise.reject();if(v==null&&x.pages.length)return Promise.resolve(x);const _=(()=>{const j={client:e.client,queryKey:e.queryKey,pageParam:v,direction:g?"backward":"forward",meta:e.options.meta};return h(j),j})(),N=await f(_),{maxPages:A}=e.options,C=g?Tde:Ade;return{pages:C(x.pages,N,A),pageParams:C(x.pageParams,v,A)}};if(i&&s.length){const x=i==="backward",v=x?Ide:GB,g={pages:s,pageParams:o},y=v(r,g);l=await p(g,y,x)}else{const x=t??s.length;do{const v=c===0?o[0]??r.initialPageParam:GB(r,l);if(c>0&&v==null)break;l=await p(l,v),c++}while(c<x)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function GB(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 Ide(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var zde=class extends yY{#t;#e;#n;#a;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#e=[],this.state=t.state||wY(),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.#a?.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.#a=xY({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.#a.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),this.#n.config.onMutate&&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.#a.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{await this.#n.config.onError?.(s,t,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onError?.(s,t,this.state.context,n)}catch(o){Promise.reject(o)}try{await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,s,t,this.state.context,n)}catch(o){Promise.reject(o)}throw this.#r({type:"error",error:s}),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),Fa.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function wY(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ude=class extends op{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 zde({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=cS(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=cS(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=cS(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=cS(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Fa.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=>IB(e,n))}findAll(t={}){return this.getAll().filter(e=>IB(t,e))}notify(t){Fa.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Fa.batch(()=>Promise.all(t.map(e=>e.continue().catch(ps))))}};function cS(t){return t.options.scope?.id}var Bde=class extends op{#t;#e=void 0;#n;#a;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),_0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Ff(n.mutationKey)!==Ff(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.#i(e)}getCurrentResult(){return this.#e}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#i()}mutate(e,n){return this.#a=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??wY();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}}#i(e){Fa.batch(()=>{if(this.#a&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context,i={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#a.onSuccess?.(e.data,n,r,i)}catch(s){Promise.reject(s)}try{this.#a.onSettled?.(e.data,null,n,r,i)}catch(s){Promise.reject(s)}}else if(e?.type==="error"){try{this.#a.onError?.(e.error,n,r,i)}catch(s){Promise.reject(s)}try{this.#a.onSettled?.(void 0,e.error,n,r,i)}catch(s){Promise.reject(s)}}}this.listeners.forEach(n=>{n(this.#e)})})}};function WB(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function Hde(t,e,n){const r=t.slice(0);return r[e]=n,r}var $de=class extends op{#t;#e;#n;#a;#r;#i;#o;#s;#f;#d=[];constructor(t,e,n){super(),this.#t=t,this.#a=n,this.#n=[],this.#r=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#r.forEach(t=>{t.subscribe(e=>{this.#l(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.#a=e,Fa.batch(()=>{const n=this.#r,r=this.#u(this.#n);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 f=this.#e[h];return!f||!_0(d,f)});!c&&!u||(c&&(this.#d=r,this.#r=i),this.#e=s,this.hasListeners()&&(c&&(WB(n,i).forEach(d=>{d.destroy()}),WB(i,n).forEach(d=>{d.subscribe(h=>{this.#l(d,h)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#r.map(t=>t.getCurrentQuery())}getObservers(){return this.#r}getOptimisticResult(t,e){const n=this.#u(t),r=n.map(s=>s.observer.getOptimisticResult(s.defaultedQueryOptions)),i=n.map(s=>s.defaultedQueryOptions.queryHash);return[r,s=>this.#c(s??r,e,i),()=>this.#h(r,n)]}#h(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)})})})}#c(t,e,n){if(e){const r=this.#f,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((s,o)=>s!==r[o]));return(!this.#i||this.#e!==this.#s||i||e!==this.#o)&&(this.#o=e,this.#s=this.#e,n!==void 0&&(this.#f=n),this.#i=jF(this.#i,e(t))),this.#i}return t}#u(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 FF(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#l(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=Hde(this.#e,n,e),this.#m())}#m(){if(this.hasListeners()){const t=this.#i,e=this.#h(this.#e,this.#d),n=this.#c(e,this.#a?.combine);t!==n&&Fa.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},Vde=class extends op{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??PF(r,e);let s=this.get(i);return s||(s=new Fde({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(){Fa.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=>OB(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>OB(t,n)):e}notify(t){Fa.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Fa.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Fa.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},qde=class{#t;#e;#n;#a;#r;#i;#o;#s;constructor(t={}){this.#t=t.queryCache||new Vde,this.#e=t.mutationCache||new Ude,this.#n=t.defaultOptions||{},this.#a=new Map,this.#r=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=RF.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=C1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#i--,this.#i===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(Dh(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=Nde(e,s);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Fa.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;Fa.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return Fa.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Fa.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(ps).catch(ps)}invalidateQueries(t,e={}){return Fa.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=Fa.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(ps)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(ps)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(Dh(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ps).catch(ps)}fetchInfiniteQuery(t){return t.behavior=qB(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ps).catch(ps)}ensureInfiniteQueryData(t){return t.behavior=qB(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return C1.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.#a.set(Ff(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#a.values()],n={};return e.forEach(r=>{S0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Ff(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{S0(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=PF(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===EF&&(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()}},SY=w.createContext(void 0),Qt=t=>{const e=w.useContext(SY);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Gde=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),a.jsx(SY.Provider,{value:t,children:e})),_Y=w.createContext(!1),NY=()=>w.useContext(_Y);_Y.Provider;function Wde(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Kde=w.createContext(Wde()),kY=()=>w.useContext(Kde),CY=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?DF(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},AY=t=>{w.useEffect(()=>{t.clearReset()},[t])},TY=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||DF(n,[t.error,r])),MY=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))}},PY=(t,e)=>t.isLoading&&t.isFetching&&!e,h3=(t,e)=>t?.suspense&&e.isPending,A1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Qb({queries:t,...e},n){const r=Qt(),i=NY(),s=kY(),o=w.useMemo(()=>t.map(v=>{const g=r.defaultQueryOptions(v);return g._optimisticResults=i?"isRestoring":"optimistic",g}),[t,r,i]);o.forEach(v=>{MY(v);const g=r.getQueryCache().get(v.queryHash);CY(v,s,g)}),AY(s);const[l]=w.useState(()=>new $de(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),h=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(v=>h?l.subscribe(Fa.batchCalls(v)):ps,[l,h]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((v,g)=>h3(o[g],v))?c.flatMap((v,g)=>{const y=o[g];if(y){const _=new FF(r,y);if(h3(y,v))return A1(y,_,s);PY(v,i)&&A1(y,_,s)}return[]}):[];if(p.length>0)throw Promise.all(p);const x=c.find((v,g)=>{const y=o[g];return y&&TY({result:v,errorResetBoundary:s,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(x?.error)throw x.error;return u(d())}function Yde(t,e,n){const r=NY(),i=kY(),s=Qt(),o=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=s.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",MY(o),CY(o,i,l),AY(i);const c=!s.getQueryCache().get(o.queryHash),[u]=w.useState(()=>new e(s,o)),d=u.getOptimisticResult(o),h=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(f=>{const p=h?u.subscribe(Fa.batchCalls(f)):ps;return u.updateResult(),p},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),w.useEffect(()=>{u.setOptions(o)},[o,u]),h3(o,d))throw A1(o,u,i);if(TY({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw d.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!Rf&&PY(d,r)&&(c?A1(o,u,i):l?.promise)?.catch(ps).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Je(t,e){return Yde(t,FF)}function ut(t,e){const n=Qt(),[r]=w.useState(()=>new Bde(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(Fa.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=w.useCallback((o,l)=>{r.mutate(o,l).catch(ps)},[r]);if(i.error&&DF(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const Xde=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Qde=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),KB=t=>{const e=Qde(t);return e.charAt(0).toUpperCase()+e.slice(1)},jY=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Zde=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Jde={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 ehe=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},c)=>w.createElement("svg",{ref:c,...Jde,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:jY("lucide",i),...!s&&!Zde(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(s)?s:[s]]));const at=(t,e)=>{const n=w.forwardRef(({className:r,...i},s)=>w.createElement(ehe,{ref:s,iconNode:e,className:jY(`lucide-${Xde(KB(t))}`,`lucide-${t}`,r),...i}));return n.displayName=KB(t),n};const the=[["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"}]],nhe=at("air-vent",the);const rhe=[["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"}]],Fs=at("archive",rhe);const ahe=[["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"}]],ihe=at("arrow-down-wide-narrow",ahe);const she=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],bb=at("arrow-down",she);const ohe=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],EY=at("arrow-left",ohe);const lhe=[["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"}]],m3=at("arrow-right-left",lhe);const che=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],f3=at("arrow-right",che);const uhe=[["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"}]],OF=at("arrow-up-down",uhe);const dhe=[["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"}]],hhe=at("arrow-up-narrow-wide",dhe);const mhe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Lf=at("arrow-up",mhe);const fhe=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],phe=at("beaker",fhe);const ghe=[["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"}]],eb=at("bell",ghe);const bhe=[["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"}]],xhe=at("bold",bhe);const yhe=[["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"}]],vhe=at("book",yhe);const whe=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],She=at("bookmark",whe);const _he=[["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"}]],ni=at("box",_he);const Nhe=[["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"}]],DY=at("briefcase",Nhe);const khe=[["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"}]],Xk=at("bug",khe);const Che=[["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"}]],Ahe=at("cable",Che);const The=[["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"}]],Mhe=at("calculator",The);const Phe=[["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"}]],jhe=at("calendar-days",Phe);const Ehe=[["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"}]],Xr=at("calendar",Ehe);const Dhe=[["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"}]],xb=at("camera",Dhe);const Rhe=[["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"}]],Fhe=at("chart-column",Rhe);const Lhe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Zr=at("check",Lhe);const Ohe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],En=at("chevron-down",Ohe);const Ihe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],pi=at("chevron-right",Ihe);const zhe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Jl=at("chevron-left",zhe);const Uhe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Sl=at("chevron-up",Uhe);const Bhe=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],RY=at("chevrons-left",Bhe);const Hhe=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],FY=at("chevrons-right",Hhe);const $he=[["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"}]],qa=at("circle-alert",$he);const Vhe=[["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"}]],K2=at("circle-arrow-up",Vhe);const qhe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],xr=at("circle-check-big",qhe);const Ghe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],yb=at("circle-check",Ghe);const Whe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Khe=at("circle-dot",Whe);const Yhe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Xhe=at("circle-stop",Yhe);const Qhe=[["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"}]],ii=at("circle-x",Qhe);const Zhe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],T1=at("circle",Zhe);const Jhe=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]],eme=at("clipboard-list",Jhe);const tme=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Xn=at("clock",tme);const nme=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]],rme=at("cloud-off",nme);const ame=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],Zb=at("cloud",ame);const ime=[["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"}]],sme=at("code-xml",ime);const ome=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],LY=at("code",ome);const lme=[["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"}]],cme=at("coffee",lme);const ume=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],dme=at("coins",ume);const hme=[["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"}]],mme=at("cog",hme);const fme=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],pme=at("columns-2",fme);const gme=[["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"}]],bme=at("compass",gme);const xme=[["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"}]],ec=at("copy",xme);const yme=[["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"}]],uS=at("cpu",yme);const vme=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],wme=at("cylinder",vme);const Sme=[["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"}]],Dc=at("database",Sme);const _me=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M6 12c0-1.7.7-3.2 1.8-4.2",key:"oqkarx"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M18 12c0 1.7-.7 3.2-1.8 4.2",key:"1eah9h"}]],Nme=at("disc-3",_me);const kme=[["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"}]],M1=at("dollar-sign",kme);const Cme=[["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"}]],ba=at("download",Cme);const Ame=[["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"}]],Qk=at("droplet",Ame);const Tme=[["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"}]],IF=at("droplets",Tme);const Mme=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Rh=at("ellipsis-vertical",Mme);const Pme=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],Y2=at("equal",Pme);const jme=[["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"}]],aa=at("external-link",jme);const Eme=[["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"}]],yv=at("eye-off",Eme);const Dme=[["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"}]],tc=at("eye",Dme);const Rme=[["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"}]],OY=at("fan",Rme);const Fme=[["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"}]],yf=at("file-box",Fme);const Lme=[["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"}]],P1=at("file-code",Lme);const Ome=[["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"}]],Ime=at("file-exclamation-point",Ome);const zme=[["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"}]],j1=at("file-spreadsheet",zme);const Ume=[["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"}]],Es=at("file-text",Ume);const Bme=[["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"}]],Zk=at("file",Bme);const Hme=[["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"}]],Fh=at("film",Hme);const $me=[["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"}]],Vme=at("flame",$me);const qme=[["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"}]],xs=at("folder-kanban",qme);const Gme=[["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"}]],nc=at("folder-open",Gme);const Wme=[["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"}]],Kme=at("folder-plus",Wme);const Yme=[["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"}]],Xme=at("folder-tree",Yme);const Qme=[["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"}]],IY=at("folder",Qme);const Zme=[["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"}]],Jme=at("fullscreen",Zme);const efe=[["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"}]],Jk=at("funnel",efe);const tfe=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],eC=at("gauge",tfe);const nfe=[["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"}]],rfe=at("gift",nfe);const afe=[["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"}]],tb=at("git-compare",afe);const ife=[["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"}]],p3=at("github",ife);const sfe=[["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"}]],Lh=at("globe",sfe);const ofe=[["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"}]],Oh=at("grip-vertical",ofe);const lfe=[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]],cfe=at("group",lfe);const ufe=[["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"}]],zY=at("hand",ufe);const dfe=[["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"}]],Jb=at("hard-drive",dfe);const hfe=[["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"}]],mfe=at("hash",hfe);const ffe=[["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"}]],pfe=at("headphones",ffe);const gfe=[["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"}]],bfe=at("heart",gfe);const xfe=[["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"}]],N0=at("history",xfe);const yfe=[["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"}]],vv=at("house",yfe);const vfe=[["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"}]],nd=at("image",vfe);const wfe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],to=at("info",wfe);const Sfe=[["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"}]],_fe=at("italic",Sfe);const Nfe=[["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"}]],il=at("key",Nfe);const kfe=[["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"}]],g3=at("keyboard",kfe);const Cfe=[["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"}]],Ga=at("layers",Cfe);const Afe=[["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"}]],wv=at("layout-grid",Afe);const Tfe=[["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"}]],Mfe=at("link-2-off",Tfe);const Pfe=[["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"}]],Ih=at("link-2",Pfe);const jfe=[["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"}]],ex=at("link",jfe);const Efe=[["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"}]],UY=at("list-ordered",Efe);const Dfe=[["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"}]],b3=at("list-todo",Dfe);const Rfe=[["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"}]],tC=at("list",Rfe);const Ffe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],lt=at("loader-circle",Ffe);const Lfe=[["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"}]],Q_=at("lock-open",Lfe);const Ofe=[["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"}]],Vm=at("lock",Ofe);const Ife=[["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"}]],YB=at("log-in",Ife);const zfe=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],x3=at("log-out",zfe);const Ufe=[["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"}]],k0=at("mail",Ufe);const Bfe=[["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"}]],Hfe=at("map",Bfe);const $fe=[["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"}]],nC=at("maximize-2",$fe);const Vfe=[["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"}]],qfe=at("maximize",Vfe);const Gfe=[["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"}]],Wfe=at("memory-stick",Gfe);const Kfe=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Yfe=at("menu",Kfe);const Xfe=[["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"}]],zF=at("minimize-2",Xfe);const Qfe=[["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"}]],BY=at("minimize",Qfe);const Zfe=[["path",{d:"M5 12h14",key:"1ays0h"}]],E1=at("minus",Zfe);const Jfe=[["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"}]],epe=at("monitor",Jfe);const tpe=[["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"}]],D1=at("moon",tpe);const npe=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],rpe=at("move-right",npe);const ape=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],y3=at("music",ape);const ipe=[["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"}]],si=at("package",ipe);const spe=[["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"}]],rC=at("palette",spe);const ope=[["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"}]],aC=at("pause",ope);const lpe=[["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"}]],Of=at("pen-line",lpe);const cpe=[["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"}]],af=at("pen",cpe);const upe=[["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"}]],Ka=at("pencil",upe);const dpe=[["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"}]],hpe=at("phone",dpe);const mpe=[["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"}]],lo=at("play",mpe);const fpe=[["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"}]],bl=at("plug",fpe);const ppe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],nr=at("plus",ppe);const gpe=[["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"}]],iC=at("power-off",gpe);const bpe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],gd=at("power",bpe);const xpe=[["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=at("printer",xpe);const ype=[["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"}]],HY=at("qr-code",ype);const vpe=[["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"}]],UF=at("radio",vpe);const wpe=[["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"}]],wr=at("refresh-cw",wpe);const Spe=[["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"}]],co=at("rotate-ccw",Spe);const _pe=[["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"}]],Npe=at("ruler",_pe);const kpe=[["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"}]],bs=at("save",kpe);const Cpe=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]],Ape=at("scale",Cpe);const Tpe=[["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"}]],R1=at("scan-search",Tpe);const Mpe=[["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"}]],Ppe=at("scissors",Mpe);const jpe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Er=at("search",jpe);const Epe=[["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"}]],sC=at("send",Epe);const Dpe=[["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"}]],qm=at("server",Dpe);const Rpe=[["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"}]],rd=at("settings-2",Rpe);const Fpe=[["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"}]],oC=at("settings",Fpe);const Lpe=[["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"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Ope=at("shield-alert",Lpe);const Ipe=[["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"}]],v3=at("shield",Ipe);const zpe=[["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"}]],$Y=at("shopping-cart",zpe);const Upe=[["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"}]],Bpe=at("signal",Upe);const Hpe=[["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"}]],$pe=at("skip-back",Hpe);const Vpe=[["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"}]],BF=at("skip-forward",Vpe);const qpe=[["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"}]],XB=at("sliders-vertical",qpe);const Gpe=[["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"}]],vb=at("sparkles",Gpe);const Wpe=[["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"}]],uo=at("square-check-big",Wpe);const Kpe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Ype=at("square-minus",Kpe);const Xpe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],_l=at("square",Xpe);const Qpe=[["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"}]],If=at("star",Qpe);const Zpe=[["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"}]],VY=at("sticky-note",Zpe);const Jpe=[["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"}]],QB=at("sun",Jpe);const ege=[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],tge=at("table-properties",ege);const nge=[["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"}]],ad=at("tag",nge);const rge=[["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"}]],qY=at("target",rge);const age=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],GY=at("terminal",age);const ige=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],sge=at("text-align-center",ige);const oge=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],lge=at("text-align-end",oge);const cge=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],uge=at("text-align-start",cge);const dge=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],lC=at("thermometer",dge);const hge=[["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"}]],zu=at("timer",hge);const mge=[["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"}]],Xt=at("trash-2",mge);const fge=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],HF=at("trending-down",fge);const pge=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],w3=at("trending-up",pge);const gge=[["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"}]],Mn=at("triangle-alert",gge);const bge=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],xge=at("underline",bge);const yge=[["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"}]],cC=at("unlink",yge);const vge=[["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"}]],Ia=at("upload",vge);const wge=[["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"}]],id=at("user",wge);const Sge=[["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"}]],gh=at("users",Sge);const _ge=[["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"}]],$F=at("video",_ge);const Nge=[["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"}]],kge=at("volume-2",Nge);const Cge=[["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"}]],Age=at("volume-x",Cge);const Tge=[["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"}]],Mge=at("wand-sparkles",Tge);const Pge=[["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}],["path",{d:"M6.5 8a2 2 0 0 0-1.905 1.46L2.1 18.5A2 2 0 0 0 4 21h16a2 2 0 0 0 1.925-2.54L19.4 9.5A2 2 0 0 0 17.48 8Z",key:"56o5sh"}]],WY=at("weight",Pge);const jge=[["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"}]],Xh=at("wifi-off",jge);const Ege=[["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"}]],nb=at("wifi",Ege);const Dge=[["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"}]],KY=at("wind",Dge);const Rge=[["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"}]],zf=at("wrench",Rge);const Fge=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ut=at("x",Fge);const Lge=[["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"}]],VF=at("zoom-in",Lge);const Oge=[["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"}]],Ic=at("zap",Oge);const Ige=[["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"}]],qF=at("zoom-out",Ige),rn="/api/v1";let cn=localStorage.getItem("auth_token");function Ig(t){cn=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function sd(){return cn}function Gm(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 Fe(t,e={}){const n={"Content-Type":"application/json",...e.headers};cn&&(n.Authorization=`Bearer ${cn}`);const r=await fetch(`${rn}${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))&&Ig(null),new Error(l)}const i=r.headers.get("content-length");if(!(r.status===204||i==="0"))return await r.json()}const ge={getAuthStatus:()=>Fe("/auth/status"),setupAuth:t=>Fe("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Fe("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Fe("/auth/logout",{method:"POST"}),getCurrentUser:()=>Fe("/auth/me"),disableAuth:()=>Fe("/auth/disable",{method:"POST"}),testSMTP:t=>Fe("/auth/smtp/test",{method:"POST",body:JSON.stringify(t)}),getSMTPSettings:()=>Fe("/auth/smtp"),saveSMTPSettings:t=>Fe("/auth/smtp",{method:"POST",body:JSON.stringify(t)}),enableAdvancedAuth:()=>Fe("/auth/advanced-auth/enable",{method:"POST"}),disableAdvancedAuth:()=>Fe("/auth/advanced-auth/disable",{method:"POST"}),getAdvancedAuthStatus:()=>Fe("/auth/advanced-auth/status"),forgotPassword:t=>Fe("/auth/forgot-password",{method:"POST",body:JSON.stringify(t)}),resetUserPassword:t=>Fe("/auth/reset-password",{method:"POST",body:JSON.stringify(t)}),getUsers:()=>Fe("/users/"),getUser:t=>Fe(`/users/${t}`),createUser:t=>Fe("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Fe(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:(t,e=!1)=>Fe(`/users/${t}?delete_items=${e}`,{method:"DELETE"}),getUserItemsCount:t=>Fe(`/users/${t}/items-count`),changePassword:(t,e)=>Fe("/users/me/change-password",{method:"POST",body:JSON.stringify({current_password:t,new_password:e})}),getPermissions:()=>Fe("/groups/permissions"),getGroups:()=>Fe("/groups/"),getGroup:t=>Fe(`/groups/${t}`),createGroup:t=>Fe("/groups/",{method:"POST",body:JSON.stringify(t)}),updateGroup:(t,e)=>Fe(`/groups/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteGroup:t=>Fe(`/groups/${t}`,{method:"DELETE"}),addUserToGroup:(t,e)=>Fe(`/groups/${t}/users/${e}`,{method:"POST"}),removeUserFromGroup:(t,e)=>Fe(`/groups/${t}/users/${e}`,{method:"DELETE"}),getPrinters:()=>Fe("/printers/"),getPrinter:t=>Fe(`/printers/${t}`),createPrinter:t=>Fe("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Fe(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Fe(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getDeveloperModeWarnings:()=>Fe("/printers/developer-mode-warnings"),getAvailableFilaments:(t,e)=>{const n=new URLSearchParams({model:t});return e&&n.set("location",e),Fe(`/printers/available-filaments?${n}`)},getPrinterStatus:t=>Fe(`/printers/${t}/status`),refreshPrinterStatus:t=>Fe(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Fe(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Fe(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Fe(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Fe(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Fe(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Fe(`/printers/${t}/print/resume`,{method:"POST"}),clearPlate:t=>Fe(`/printers/${t}/clear-plate`,{method:"POST"}),getCurrentPrintUser:t=>Fe(`/printers/${t}/current-print-user`),setChamberLight:(t,e)=>Fe(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Fe(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Fe(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),clearHMSErrors:t=>Fe(`/printers/${t}/hms/clear`,{method:"POST"}),refreshAmsSlot:(t,e,n)=>Fe(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Fe(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Fe(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Fe(`/printers/${t}/logging`),clearMQTTLogs:t=>Fe(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Fe(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${rn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,getPrinterFileGcodeUrl:(t,e)=>`${rn}/printers/${t}/files/gcode?path=${encodeURIComponent(e)}`,getPrinterFilePlates:(t,e)=>Fe(`/printers/${t}/files/plates?path=${encodeURIComponent(e)}`),getPrinterFilePlateThumbnail:(t,e,n)=>`${rn}/printers/${t}/files/plate-thumbnail/${e}?path=${encodeURIComponent(n)}`,downloadPrinterFile:async(t,e)=>{const n={};cn&&(n.Authorization=`Bearer ${cn}`);const r=await fetch(`${rn}/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=Gm(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"};cn&&(n.Authorization=`Bearer ${cn}`);const r=await fetch(`${rn}/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)=>Fe(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Fe(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0,i,s)=>{const o=new URLSearchParams;return t&&o.set("printer_id",String(t)),e&&o.set("project_id",String(e)),o.set("limit",String(n)),o.set("offset",String(r)),i&&o.set("date_from",i),s&&o.set("date_to",s),Fe(`/archives/?${o}`)},getArchivesSlim:(t,e)=>{const n=new URLSearchParams;t&&n.set("date_from",t),e&&n.set("date_to",e);const r=n.toString();return Fe(`/archives/slim${r?`?${r}`:""}`)},getArchive:t=>Fe(`/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)),Fe(`/archives/search?${n}`)},rebuildSearchIndex:()=>Fe("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Fe(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Fe(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Fe(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:t=>{const e=new URLSearchParams;t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo);const n=e.toString();return Fe(`/archives/stats${n?`?${n}`:""}`)},getTags:()=>Fe("/archives/tags"),renameTag:(t,e)=>Fe(`/archives/tags/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({new_name:e})}),deleteTag:t=>Fe(`/archives/tags/${encodeURIComponent(t)}`,{method:"DELETE"}),recalculateCosts:()=>Fe("/archives/recalculate-costs",{method:"POST"}),getFailureAnalysis:t=>{const e=new URLSearchParams;t?.days&&e.set("days",String(t.days)),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=e.toString();return Fe(`/archives/analysis/failures${n?`?${n}`:""}`)},compareArchives:t=>Fe(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Fe(`/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={};cn&&(n.Authorization=`Bearer ${cn}`);const r=await fetch(`${rn}/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={};cn&&(n.Authorization=`Bearer ${cn}`);const r=await fetch(`${rn}/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=>Fe(`/archives/${t}/duplicates`),backfillContentHashes:()=>Fe("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${rn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${rn}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${rn}/archives/${t}/download`,downloadArchive:async(t,e)=>{const n={};cn&&(n.Authorization=`Bearer ${cn}`);const r=await fetch(`${rn}/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=Gm(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=>`${rn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${rn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${rn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Fe(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Fe(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),deleteArchiveTimelapse:t=>Fe(`/archives/${t}/timelapse`,{method:"DELETE"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};cn&&(r.Authorization=`Bearer ${cn}`);const i=await fetch(`${rn}/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=>Fe(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Fe(`/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={};cn&&(i.Authorization=`Bearer ${cn}`);const s=await fetch(`${rn}/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)=>`${rn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};cn&&(r.Authorization=`Bearer ${cn}`);const i=await fetch(`${rn}/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)=>Fe(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${rn}/archives/${t}/source`,downloadSource3mf:async t=>{const e={};cn&&(e.Authorization=`Bearer ${cn}`);const n=await fetch(`${rn}/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=Gm(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)=>{const n=e.replace(/[/\\?#]/g,"_");return`${rn}/archives/${t}/source/${encodeURIComponent(n.endsWith(".3mf")?n:n+".3mf")}`},createSourceSlicerToken:t=>Fe(`/archives/${t}/source-slicer-token`,{method:"POST"}),getSourceSlicerDownloadUrl:(t,e,n)=>{const r=n.replace(/[/\\?#]/g,"_");return`${rn}/archives/${t}/source-dl/${e}/${encodeURIComponent(r.endsWith(".3mf")?r:r+".3mf")}`},uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};cn&&(r.Authorization=`Bearer ${cn}`);const i=await fetch(`${rn}/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=>Fe(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${rn}/archives/${t}/f3d`,downloadF3d:async t=>{const e={};cn&&(e.Authorization=`Bearer ${cn}`);const n=await fetch(`${rn}/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=Gm(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={};cn&&(r.Authorization=`Bearer ${cn}`);const i=await fetch(`${rn}/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=>Fe(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${rn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Fe(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Fe(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Fe(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${rn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>{const n=e.replace(/[/\\?#]/g,"_");return`${rn}/archives/${t}/file/${encodeURIComponent(n.endsWith(".3mf")?n:n+".3mf")}`},createArchiveSlicerToken:t=>Fe(`/archives/${t}/slicer-token`,{method:"POST"}),getArchiveSlicerDownloadUrl:(t,e,n)=>{const r=n.replace(/[/\\?#]/g,"_");return`${rn}/archives/${t}/dl/${e}/${encodeURIComponent(r.endsWith(".3mf")?r:r+".3mf")}`},getArchivePlates:t=>Fe(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Fe(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Fe(`/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?`${rn}/archives/upload?printer_id=${e}`:`${rn}/archives/upload`,i={};cn&&(i.Authorization=`Bearer ${cn}`);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?`${rn}/archives/upload-bulk?printer_id=${e}`:`${rn}/archives/upload-bulk`,i={};cn&&(i.Authorization=`Bearer ${cn}`);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()},getPrintLog:t=>{const e=new URLSearchParams;return t?.search&&e.set("search",t.search),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.username&&e.set("created_by_username",t.username),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.limit&&e.set("limit",String(t.limit)),t?.offset!==void 0&&e.set("offset",String(t.offset)),Fe(`/print-log/?${e}`)},getPrintLogThumbnail:t=>`${rn}/print-log/${t}/thumbnail`,clearPrintLog:()=>Fe("/print-log/",{method:"DELETE"}),getSettings:()=>Fe("/settings/"),updateSettings:t=>Fe("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Fe("/settings/mqtt/status"),resetSettings:()=>Fe("/settings/reset",{method:"POST"}),exportBackup:async()=>{const t=`${rn}/settings/backup`,e={};cn&&(e.Authorization=`Bearer ${cn}`);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=`${rn}/settings/restore`,r={};return cn&&(r.Authorization=`Bearer ${cn}`),(await fetch(n,{method:"POST",headers:r,body:e})).json()},checkFfmpeg:()=>Fe("/settings/check-ffmpeg"),getNetworkInterfaces:()=>Fe("/settings/network-interfaces"),getCloudStatus:()=>Fe("/cloud/status"),cloudLogin:(t,e,n="global")=>Fe("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e,n)=>Fe("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e,tfa_key:n})}),cloudSetToken:t=>Fe("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Fe("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Fe(`/cloud/settings?version=${t}`),getBuiltinFilaments:()=>Fe("/cloud/builtin-filaments"),getFilamentIdMap:()=>Fe("/cloud/filament-id-map"),getCloudSettingDetail:t=>Fe(`/cloud/settings/${t}`),createCloudSetting:t=>Fe("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Fe(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Fe(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Fe("/cloud/devices"),getCloudFields:t=>Fe(`/cloud/fields/${t}`),getAllCloudFields:()=>Fe("/cloud/fields"),getFilamentInfo:t=>Fe("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Fe("/smart-plugs/"),getSmartPlug:t=>Fe(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Fe(`/smart-plugs/by-printer/${t}`),getScriptPlugsByPrinter:t=>Fe(`/smart-plugs/by-printer/${t}/scripts`),createSmartPlug:t=>Fe("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Fe(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Fe(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Fe(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Fe(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Fe("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>Fe("/smart-plugs/discover/scan",{method:"POST"}),getTasmotaScanStatus:()=>Fe("/smart-plugs/discover/status"),stopTasmotaScan:()=>Fe("/smart-plugs/discover/stop",{method:"POST"}),getDiscoveredTasmotaDevices:()=>Fe("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Fe("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Fe(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Fe("/smart-plugs/ha/sensors"),getQueue:(t,e,n)=>{const r=new URLSearchParams;return t&&r.set("printer_id",String(t)),e&&r.set("status",e),n&&r.set("target_model",n),Fe(`/queue/?${r}`)},getQueueItem:t=>Fe(`/queue/${t}`),addToQueue:t=>Fe("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Fe(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Fe(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Fe("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Fe(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Fe(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Fe(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Fe("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Fe(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Fe(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Fe(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Fe(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Fe(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Fe(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Fe(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Fe(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Fe(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i,s="cloud")=>Fe(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}&preset_source=${encodeURIComponent(s)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Fe(`/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()),Fe(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Fe(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Fe("/filament-catalog/"),getFilament:t=>Fe(`/filament-catalog/${t}`),getFilamentsByType:t=>Fe(`/filament-catalog/by-type/${t}`),getNotificationProviders:()=>Fe("/notifications/"),getNotificationProvider:t=>Fe(`/notifications/${t}`),createNotificationProvider:t=>Fe("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Fe(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Fe(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Fe(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Fe("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Fe("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Fe("/notification-templates"),getNotificationTemplate:t=>Fe(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Fe(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Fe(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Fe("/notification-templates/variables"),previewTemplate:t=>Fe("/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)),Fe(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Fe(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Fe(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Fe("/spoolman/status"),connectSpoolman:()=>Fe("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Fe("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Fe(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Fe("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Fe("/spoolman/spools"),getSpoolmanFilaments:()=>Fe("/spoolman/filaments"),getUnlinkedSpools:()=>Fe("/spoolman/spools/unlinked"),getLinkedSpools:()=>Fe("/spoolman/spools/linked"),linkSpool:(t,e)=>Fe(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getSpoolmanSettings:()=>Fe("/settings/spoolman"),updateSpoolmanSettings:t=>Fe("/settings/spoolman",{method:"PUT",body:JSON.stringify(t)}),getSpools:(t=!1)=>Fe(`/inventory/spools?include_archived=${t}`),getSpool:t=>Fe(`/inventory/spools/${t}`),createSpool:t=>Fe("/inventory/spools",{method:"POST",body:JSON.stringify(t)}),bulkCreateSpools:(t,e)=>Fe("/inventory/spools/bulk",{method:"POST",body:JSON.stringify({spool:t,quantity:e})}),updateSpool:(t,e)=>Fe(`/inventory/spools/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSpool:t=>Fe(`/inventory/spools/${t}`,{method:"DELETE"}),archiveSpool:t=>Fe(`/inventory/spools/${t}/archive`,{method:"POST"}),restoreSpool:t=>Fe(`/inventory/spools/${t}/restore`,{method:"POST"}),getSpoolKProfiles:t=>Fe(`/inventory/spools/${t}/k-profiles`),saveSpoolKProfiles:(t,e)=>Fe(`/inventory/spools/${t}/k-profiles`,{method:"PUT",body:JSON.stringify(e)}),getAssignments:t=>Fe(`/inventory/assignments${t?`?printer_id=${t}`:""}`),assignSpool:t=>Fe("/inventory/assignments",{method:"POST",body:JSON.stringify(t)}),unassignSpool:(t,e,n)=>Fe(`/inventory/assignments/${t}/${e}/${n}`,{method:"DELETE"}),getSpoolCatalog:()=>Fe("/inventory/catalog"),addCatalogEntry:t=>Fe("/inventory/catalog",{method:"POST",body:JSON.stringify(t)}),updateCatalogEntry:(t,e)=>Fe(`/inventory/catalog/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCatalogEntry:t=>Fe(`/inventory/catalog/${t}`,{method:"DELETE"}),resetSpoolCatalog:()=>Fe("/inventory/catalog/reset",{method:"POST"}),getColorCatalog:()=>Fe("/inventory/colors"),addColorEntry:t=>Fe("/inventory/colors",{method:"POST",body:JSON.stringify(t)}),updateColorEntry:(t,e)=>Fe(`/inventory/colors/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteColorEntry:t=>Fe(`/inventory/colors/${t}`,{method:"DELETE"}),resetColorCatalog:()=>Fe("/inventory/colors/reset",{method:"POST"}),lookupColor:(t,e,n)=>Fe(`/inventory/colors/lookup?manufacturer=${encodeURIComponent(t)}&color_name=${encodeURIComponent(e)}${n?`&material=${encodeURIComponent(n)}`:""}`),searchColors:(t,e)=>Fe(`/inventory/colors/search?${t?`manufacturer=${encodeURIComponent(t)}`:""}${t&&e?"&":""}${e?`material=${encodeURIComponent(e)}`:""}`),linkTagToSpool:(t,e)=>Fe(`/inventory/spools/${t}/link-tag`,{method:"PATCH",body:JSON.stringify(e)}),getSpoolUsageHistory:(t,e=50)=>Fe(`/inventory/spools/${t}/usage?limit=${e}`),getAllUsageHistory:(t=100,e)=>Fe(`/inventory/usage?limit=${t}${e?`&printer_id=${e}`:""}`),clearSpoolUsageHistory:t=>Fe(`/inventory/spools/${t}/usage`,{method:"DELETE"}),syncWeightsFromAms:()=>Fe("/inventory/sync-ams-weights",{method:"POST"}),getFilamentPresets:()=>Fe("/cloud/filaments"),getVersion:()=>Fe("/updates/version"),checkForUpdates:()=>Fe("/updates/check"),applyUpdate:()=>Fe("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Fe("/updates/status"),getMaintenanceTypes:()=>Fe("/maintenance/types"),createMaintenanceType:t=>Fe("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Fe(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Fe(`/maintenance/types/${t}`,{method:"DELETE"}),restoreDefaultMaintenanceTypes:()=>Fe("/maintenance/types/restore-defaults",{method:"POST"}),getMaintenanceOverview:()=>Fe("/maintenance/overview"),getPrinterMaintenance:t=>Fe(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Fe(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Fe(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Fe(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Fe("/maintenance/summary"),setPrinterHours:(t,e)=>Fe(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Fe(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Fe(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${rn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${rn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Fe(`/printers/${t}/camera/test`),getCameraStatus:t=>Fe(`/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)),Fe(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Fe(`/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)),Fe(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Fe(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Fe(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${rn}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Fe(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Fe(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Fe("/external-links/"),getExternalLink:t=>Fe(`/external-links/${t}`),createExternalLink:t=>Fe("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Fe(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Fe(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Fe("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};cn&&(r.Authorization=`Bearer ${cn}`);const i=await fetch(`${rn}/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=>Fe(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${rn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Fe(`/projects/?${e}`)},getProject:t=>Fe(`/projects/${t}`),createProject:t=>Fe("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Fe(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Fe(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Fe(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Fe(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Fe(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Fe(`/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={};cn&&(r.Authorization=`Bearer ${cn}`);const i=await fetch(`${rn}/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)=>`${rn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Fe(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Fe(`/projects/${t}/bom`),createBOMItem:(t,e)=>Fe(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Fe(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Fe(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Fe("/projects/templates/"),createTemplateFromProject:t=>Fe(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Fe(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Fe(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Fe(`/projects/${t}/export?format=json`),importProject:t=>Fe("/projects/import",{method:"POST",body:JSON.stringify(t)}),importProjectFile:async t=>{const e=new FormData;e.append("file",t);const n={};cn&&(n.Authorization=`Bearer ${cn}`);const r=await fetch(`${rn}/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={};cn&&(e.Authorization=`Bearer ${cn}`);const n=await fetch(`${rn}/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=Gm(r)||`project_${t}.zip`;return{blob:await n.blob(),filename:i}},getAPIKeys:()=>Fe("/api-keys/"),createAPIKey:t=>Fe("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Fe(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Fe(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Fe(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Fe("/system/info"),getStorageUsage:t=>{const e=new URLSearchParams;t?.refresh&&e.set("refresh","true");const n=e.toString();return Fe(`/system/storage-usage${n?`?${n}`:""}`)},getLibraryFolders:()=>Fe("/library/folders"),createLibraryFolder:t=>Fe("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Fe(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Fe(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Fe(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Fe(`/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)),Fe(`/library/files?${n}`)},getLibraryFile:t=>Fe(`/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={};cn&&(s.Authorization=`Bearer ${cn}`);const o=await fetch(`${rn}/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={};cn&&(l.Authorization=`Bearer ${cn}`);const c=await fetch(`${rn}/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)=>Fe(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Fe(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${rn}/library/files/${t}/download`,createLibrarySlicerToken:t=>Fe(`/library/files/${t}/slicer-token`,{method:"POST"}),getLibrarySlicerDownloadUrl:(t,e,n)=>`${rn}/library/files/${t}/dl/${e}/${encodeURIComponent(n)}`,downloadLibraryFile:async(t,e)=>{const n={};cn&&(n.Authorization=`Bearer ${cn}`);const r=await fetch(`${rn}/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=Gm(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=>`${rn}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${rn}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${rn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Fe("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Fe("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Fe("/library/stats"),batchGenerateStlThumbnails:t=>Fe("/library/generate-stl-thumbnails",{method:"POST",body:JSON.stringify(t)}),addLibraryFilesToQueue:t=>Fe("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Fe(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),cancelBackgroundDispatchJob:t=>Fe(`/background-dispatch/${t}`,{method:"DELETE"}),getLibraryFilePlates:t=>Fe(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Fe(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>Fe("/github-backup/config"),saveGitHubBackupConfig:t=>Fe("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>Fe("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>Fe("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>Fe(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>Fe("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>Fe("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>Fe("/github-backup/status"),getGitHubBackupLogs:(t=50)=>Fe(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>Fe(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"}),getLocalPresets:()=>Fe("/local-presets/"),getLocalPresetDetail:t=>Fe(`/local-presets/${t}`),importLocalPresets:t=>fetch(`${rn}/local-presets/import`,{method:"POST",headers:cn?{Authorization:`Bearer ${cn}`}:{},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=>Fe("/local-presets/",{method:"POST",body:JSON.stringify(t)}),updateLocalPreset:(t,e)=>Fe(`/local-presets/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLocalPreset:t=>Fe(`/local-presets/${t}`,{method:"DELETE"}),refreshBaseProfileCache:()=>Fe("/local-presets/base-cache/refresh",{method:"POST"})},mc={getInfo:()=>Fe("/discovery/info"),getStatus:()=>Fe("/discovery/status"),startDiscovery:(t=10)=>Fe(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Fe("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Fe("/discovery/printers"),startSubnetScan:(t,e=1)=>Fe("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Fe("/discovery/scan/status"),stopSubnetScan:()=>Fe("/discovery/scan/stop",{method:"POST"})},zge={getSettings:()=>Fe("/settings/virtual-printer")},F1={list:()=>Fe("/virtual-printers"),get:t=>Fe(`/virtual-printers/${t}`),create:t=>Fe("/virtual-printers",{method:"POST",body:JSON.stringify(t)}),update:(t,e)=>Fe(`/virtual-printers/${t}`,{method:"PUT",body:JSON.stringify(e)}),remove:t=>Fe(`/virtual-printers/${t}`,{method:"DELETE"})},zg={list:()=>Fe("/pending-uploads/"),getCount:()=>Fe("/pending-uploads/count"),get:t=>Fe(`/pending-uploads/${t}`),archive:(t,e)=>Fe(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Fe(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Fe("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Fe("/pending-uploads/discard-all",{method:"DELETE"})},Z_={checkUpdates:()=>Fe("/firmware/updates"),checkPrinterUpdate:t=>Fe(`/firmware/updates/${t}`),prepareUpload:t=>Fe(`/firmware/updates/${t}/prepare`),startUpload:t=>Fe(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Fe(`/firmware/updates/${t}/upload/status`)},rb={getDebugLoggingState:()=>Fe("/support/debug-logging"),setDebugLogging:t=>Fe("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t={};cn&&(t.Authorization=`Bearer ${cn}`);const e=await fetch(`${rn}/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=Gm(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 Fe(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Fe("/support/logs",{method:"DELETE"})},ys={getDevices:()=>Fe("/spoolbuddy/devices"),tare:t=>Fe(`/spoolbuddy/devices/${t}/calibration/tare`,{method:"POST",body:"{}"}),getCalibration:t=>Fe(`/spoolbuddy/devices/${t}/calibration`),setCalibrationFactor:(t,e,n,r)=>Fe(`/spoolbuddy/devices/${t}/calibration/set-factor`,{method:"POST",body:JSON.stringify({known_weight_grams:e,raw_adc:n,tare_raw_adc:r})}),updateSpoolWeight:(t,e)=>Fe("/spoolbuddy/scale/update-spool-weight",{method:"POST",body:JSON.stringify({spool_id:t,weight_grams:e})}),updateDisplay:(t,e,n)=>Fe(`/spoolbuddy/devices/${t}/display`,{method:"PUT",body:JSON.stringify({brightness:e,blank_timeout:n})}),checkDaemonUpdate:(t,e)=>Fe(`/spoolbuddy/devices/${t}/update-check?include_beta=${e??!1}`),writeTag:(t,e)=>Fe("/spoolbuddy/nfc/write-tag",{method:"POST",body:JSON.stringify({device_id:t,spool_id:e})}),cancelWrite:t=>Fe(`/spoolbuddy/devices/${t}/cancel-write`,{method:"POST",body:"{}"})},YY=w.createContext(void 0);function Uge({children:t}){const[e,n]=w.useState(()=>{const k=localStorage.getItem("theme-mode"),R=localStorage.getItem("theme");return k||R||"dark"}),[r,i]=w.useState(()=>localStorage.getItem("dark-style")||"classic"),[s,o]=w.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=w.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=w.useState(()=>localStorage.getItem("light-style")||"classic"),[h,f]=w.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,x]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{ge.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&&(f(k.light_background),localStorage.setItem("light-background",k.light_background)),k.light_accent&&(x(k.light_accent),localStorage.setItem("light-accent",k.light_accent))}).catch(()=>{})},[]),w.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-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,s,l,u,h,p]);const v=()=>n(k=>k==="dark"?"light":"dark"),g=k=>n(k),y=k=>{i(k),localStorage.setItem("dark-style",k),ge.updateSettings({dark_style:k}).catch(()=>{})},_=k=>{o(k),localStorage.setItem("dark-background",k),ge.updateSettings({dark_background:k}).catch(()=>{})},N=k=>{c(k),localStorage.setItem("dark-accent",k),ge.updateSettings({dark_accent:k}).catch(()=>{})},A=k=>{d(k),localStorage.setItem("light-style",k),ge.updateSettings({light_style:k}).catch(()=>{})},C=k=>{f(k),localStorage.setItem("light-background",k),ge.updateSettings({light_background:k}).catch(()=>{})},j=k=>{x(k),localStorage.setItem("light-accent",k),ge.updateSettings({light_accent:k}).catch(()=>{})};return a.jsx(YY.Provider,{value:{mode:e,darkStyle:r,darkBackground:s,darkAccent:l,lightStyle:u,lightBackground:h,lightAccent:p,toggleMode:v,setMode:g,setDarkStyle:y,setDarkBackground:_,setDarkAccent:N,setLightStyle:A,setLightBackground:C,setLightAccent:j},children:t})}function lp(){const t=w.useContext(YY);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function Ct({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 Vn({children:t,className:e=""}){return a.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Tt({children:t,className:e=""}){return a.jsx("div",{className:`p-6 ${e}`,children:t})}function Bge(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 ZB({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 Hge({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Et(),i=Bge(n,e,r);return w.useEffect(()=>{const s=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:a.jsx(Ct,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:a.jsxs(Tt,{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(g3,{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(Ut,{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(aa,{className:"w-3 h-3 text-bambu-gray"})]}),a.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>a.jsx(ZB,{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(ZB,{children:"Esc"})," or click outside to close"]})})]})})})}function Oe({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 Sn({title:t,message:e,confirmText:n,cancelText:r,cancelVariant:i,cardClassName:s,variant:o="default",isLoading:l=!1,loadingText:c,onConfirm:u,onCancel:d}){const{t:h}=Et(),f=n??h("common.confirm"),p=r??h("common.cancel"),x=c??h("common.loading");w.useEffect(()=>{const y=_=>{_.key==="Escape"&&!l&&d()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[d,l]);const g={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"}}[o];return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:l?void 0:d,children:a.jsx(Ct,{className:`w-full max-w-md ${s??""}`,onClick:y=>y.stopPropagation(),children:a.jsxs(Tt,{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 ${g.icon}`,children:a.jsx(Mn,{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(Oe,{variant:i??"secondary",onClick:d,className:"flex-1",disabled:l,children:p}),a.jsx(Oe,{onClick:u,className:`flex-1 ${g.button}`,disabled:l,children:l?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 mr-2 animate-spin"}),x]}):f})]})]})})})}function $ge({plug:t}){const e=Qt(),[n,r]=w.useState(null),{data:i,isLoading:s}=Je({queryKey:["smart-plug-status",t.id],queryFn:()=>ge.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=ut({mutationFn:p=>ge.controlSmartPlug(t.id,p),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=t.plug_type==="mqtt"&&i?.energy?.power!==null&&i?.energy?.power!==void 0,u=(i?.reachable??!1)||c,d=o.isPending,h=t.plug_type==="mqtt",f=()=>{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(UF,{className:`w-4 h-4 ${u?"text-teal-400":"text-red-400"}`}):a.jsx(bl,{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(Ic,{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(tc,{className:"w-3 h-3 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Xh,{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(nb,{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(Ic,{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(Xh,{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(gd,{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(iC,{className:"w-4 h-4"})})]})]}),n&&a.jsx(Sn,{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:f,onCancel:()=>r(null)})]})}function JB({onClose:t}){const{data:e,isLoading:n}=Je({queryKey:["smart-plugs"],queryFn:ge.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(bl,{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(bl,{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($ge,{plug:i},i.id))})})]})}const XY=[{name:"globe",icon:Lh},{name:"link",icon:ex},{name:"external-link",icon:aa},{name:"book",icon:vhe},{name:"file-text",icon:Es},{name:"home",icon:vv},{name:"star",icon:If},{name:"heart",icon:bfe},{name:"bookmark",icon:She},{name:"shopping-cart",icon:$Y},{name:"music",icon:y3},{name:"video",icon:$F},{name:"image",icon:nd},{name:"camera",icon:xb},{name:"map",icon:Hfe},{name:"compass",icon:bme},{name:"coffee",icon:cme},{name:"gift",icon:rfe},{name:"wrench",icon:zf},{name:"zap",icon:Ic},{name:"cloud",icon:Zb},{name:"database",icon:Dc},{name:"folder",icon:IY},{name:"mail",icon:k0},{name:"phone",icon:hpe},{name:"user",icon:id},{name:"users",icon:gh},{name:"server",icon:qm},{name:"terminal",icon:GY},{name:"code",icon:LY}];function uC(t){return XY.find(n=>n.name===t)?.icon||ex}function Vge({value:t,onChange:e}){const[n,r]=w.useState(!1),i=uC(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:XY.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 e8=1144;function qge(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<e8:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${e8-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const QY=w.createContext(void 0);function Gge({children:t}){const[e,n]=w.useState(null),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(!0),u=w.useRef(!1),d=w.useRef(!0),h=async()=>{try{const j=new URLSearchParams(window.location.search),k=j.get("token");if(k){Ig(k),j.delete("token");const M=j.toString(),D=window.location.pathname+(M?`?${M}`:"")+window.location.hash;window.history.replaceState({},"",D)}const R=await ge.getAuthStatus();if(!d.current)return;if(i(R.auth_enabled),o(R.requires_setup),R.auth_enabled)if(sd())try{const D=await ge.getCurrentUser();if(!d.current)return;n(D)}catch{if(Ig(null),!d.current)return;n(null)}else n(null);else n(null)}catch{if(!d.current)return;i(!1),n(null)}finally{d.current&&c(!1)}};w.useEffect(()=>(d.current=!0,h(),()=>{d.current=!1}),[]),w.useEffect(()=>{if(!l&&s&&!r){const j=window.location.pathname;j!=="/setup"&&!j.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else s||(u.current=!1)},[l,s,r]);const f=async(j,k)=>{const R=await ge.login({username:j,password:k});Ig(R.access_token),await h()},p=()=>{Ig(null),n(null),ge.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&sd())try{const j=await ge.getCurrentUser();d.current&&n(j)}catch{Ig(null),d.current&&n(null)}},v=async()=>{await h()},g=w.useMemo(()=>new Set(e?.permissions??[]),[e?.permissions]),y=w.useMemo(()=>r?e?.is_admin??!1:!0,[r,e?.is_admin]),_=w.useCallback(j=>!r||y?!0:g.has(j),[r,y,g]),N=w.useCallback((...j)=>!r||y?!0:j.some(k=>g.has(k)),[r,y,g]),A=w.useCallback((...j)=>!r||y?!0:j.every(k=>g.has(k)),[r,y,g]),C=w.useCallback((j,k,R)=>{if(!r||y)return!0;const M=`${j}:${k}_all`,D=`${j}:${k}_own`;return g.has(M)?!0:g.has(D)?R==null?!1:R===e?.id:!1},[r,y,g,e?.id]);return a.jsx(QY.Provider,{value:{user:e,authEnabled:r,requiresSetup:s,loading:l,isAdmin:y,login:f,logout:p,refreshUser:x,refreshAuth:v,hasPermission:_,hasAnyPermission:N,hasAllPermissions:A,canModify:C},children:t})}function Rr(){const t=w.useContext(QY);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const ZY=w.createContext(void 0);function dn(){const t=w.useContext(ZY);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const t8={success:a.jsx(xr,{className:"w-5 h-5 text-green-400"}),error:a.jsx(ii,{className:"w-5 h-5 text-red-400"}),warning:a.jsx(qa,{className:"w-5 h-5 text-yellow-400"}),info:a.jsx(to,{className:"w-5 h-5 text-blue-400"}),loading:a.jsx(lt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Wge={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 Kge({children:t}){const{t:e}=Et(),[n,r]=w.useState([]),[i,s]=w.useState(!1),[o,l]=w.useState(new Set),c=w.useRef(new Map),u="background-dispatch",d=w.useRef(null),h=w.useCallback(g=>!Number.isFinite(g)||g<0?"0 B":g<1024?`${g} B`:g<1024*1024?`${(g/1024).toFixed(1)} KB`:g<1024*1024*1024?`${(g/(1024*1024)).toFixed(1)} MB`:`${(g/(1024*1024*1024)).toFixed(1)} GB`,[]);w.useEffect(()=>{const g=c.current;return()=>{g.forEach(y=>clearTimeout(y)),g.clear()}},[]);const f=w.useCallback((g,y="success")=>{const _=Math.random().toString(36).substr(2,9);r(A=>[...A,{id:_,message:g,type:y}]);const N=setTimeout(()=>{r(A=>A.filter(C=>C.id!==_)),c.current.delete(_)},3e3);c.current.set(_,N)},[]),p=w.useCallback((g,y,_="info")=>{r(N=>N.find(C=>C.id===g)?N.map(C=>C.id===g?{...C,message:y,type:_,persistent:!0}:C):[...N,{id:g,message:y,type:_,persistent:!0}])},[]),x=w.useCallback(g=>{const y=c.current.get(g);y&&(clearTimeout(y),c.current.delete(g)),r(_=>_.filter(N=>N.id!==g))},[]),v=w.useCallback(async g=>{l(y=>{const _=new Set(y);return _.add(g),_});try{const y=await ge.cancelBackgroundDispatchJob(g);f(y.status==="cancelling"?e("backgroundDispatch.toast.cancellingUpload"):e("backgroundDispatch.toast.cancelled"),"info")}catch(y){const _=y instanceof Error?y.message:e("backgroundDispatch.toast.cancelFailed");f(_,"error")}finally{l(y=>{const _=new Set(y);return _.delete(g),_})}},[f,e]);return w.useEffect(()=>{const g=(N,A,C)=>{const j=N.findIndex(R=>R.jobId===A);if(j===-1)return[...N,{jobId:A,...C}];const k=[...N];return k[j]={...k[j],...C},k},y=N=>{switch(N){case"failed":return 0;case"processing":return 1;case"dispatched":return 2;case"completed":return 3;case"cancelled":return 4}},_=N=>{const A=N.detail||{},C=A.total??0,j=A.dispatched??0,k=A.processing??0,R=A.completed??0,M=A.failed??0,D=j+k>0,G=C>0&&R+M>=C&&!D;if(D){r(W=>{const ee=W.find(be=>be.id===u)?.dispatchData?.jobs||[],ae=(A.dispatched_jobs||[]).map(be=>({jobId:be.job_id,sourceName:be.source_name||e("backgroundDispatch.unknownFile"),printerName:be.printer_name||e("backgroundDispatch.unknownPrinter"),status:"dispatched"})),se=(A.active_jobs&&A.active_jobs.length>0?A.active_jobs:A.active_job?.job_id?[A.active_job]:[]).filter(be=>typeof be.job_id=="number").map(be=>({jobId:be.job_id,sourceName:be.source_name||e("backgroundDispatch.unknownFile"),printerName:be.printer_name||e("backgroundDispatch.unknownPrinter"),status:"processing",message:be.message,uploadBytes:be.upload_bytes,uploadTotalBytes:be.upload_total_bytes,uploadProgressPct:be.upload_progress_pct})),ce=new Set([...ae,...se].map(be=>be.jobId)),ye=ee.filter(be=>!ce.has(be.jobId)&&["completed","failed","cancelled"].includes(be.status));let Z=[...ae,...se,...ye];if(A.recent_event?.job_id&&A.recent_event?.status){const be=A.recent_event.status,Ee=be==="cancelled"?"cancelled":be==="cancelling"?"processing":be,$=A.recent_event.source_name||e("backgroundDispatch.unknownFile"),K=A.recent_event.printer_name||e("backgroundDispatch.unknownPrinter");Z=g(Z,A.recent_event.job_id,{status:Ee,sourceName:$,printerName:K,message:A.recent_event.message})}se.forEach(be=>{Z=g(Z,be.jobId,{status:"processing",sourceName:be.sourceName,printerName:be.printerName,message:be.message,uploadBytes:be.uploadBytes,uploadTotalBytes:be.uploadTotalBytes,uploadProgressPct:be.uploadProgressPct})});const ue={total:C,dispatched:j,processing:k,completed:R,failed:M,jobs:[...Z].sort((be,Ee)=>{const $=y(be.status)-y(Ee.status);return $!==0?$:be.jobId-Ee.jobId})};return W.find(be=>be.id===u)?W.map(be=>be.id===u?{...be,message:e("backgroundDispatch.startingPrints"),type:"loading",persistent:!0,dispatchData:ue}:be):[...W,{id:u,message:e("backgroundDispatch.startingPrints"),type:"loading",persistent:!0,dispatchData:ue}]});return}const U=A.recent_event?.status;if(!D&&U&&["cancelled","failed","completed","idle"].includes(U)&&r(W=>W.filter(L=>L.id!==u)),G){const W=`${R}:${M}`;if(d.current===W)return;d.current=W,r(Y=>Y.filter(se=>se.id!==u));const L=M>0?e("backgroundDispatch.toast.completeWithFailures",{completed:R,failed:M}):e("backgroundDispatch.toast.completeSuccess",{completed:R}),ee=Math.random().toString(36).substr(2,9);r(Y=>[...Y,{id:ee,message:L,type:M>0?"warning":"success"}]);const ae=setTimeout(()=>{r(Y=>Y.filter(se=>se.id!==ee)),c.current.delete(ee)},4e3);c.current.set(ee,ae)}if(A.recent_event?.status==="idle"&&!D&&r(W=>W.filter(L=>L.id!==u)),D||l(new Set),A.dispatched_jobs){const W=new Set(A.dispatched_jobs.map(L=>L.job_id));l(L=>{const ee=new Set;return L.forEach(ae=>{W.has(ae)&&ee.add(ae)}),ee})}};return window.addEventListener("background-dispatch",_),()=>window.removeEventListener("background-dispatch",_)},[e]),a.jsxs(ZY.Provider,{value:{showToast:f,showPersistentToast:p,dismissToast:x},children:[t,a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:n.map(g=>a.jsx("div",{className:`rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Wge[g.type]} ${g.dispatchData?"w-[420px] p-3":"flex items-center gap-3 px-4 py-3"}`,children:g.dispatchData?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[t8[g.type],a.jsxs("div",{children:[a.jsx("p",{className:"text-white text-sm font-medium",children:e("backgroundDispatch.startingPrints")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:e("backgroundDispatch.progressSummary",{complete:g.dispatchData.completed+g.dispatchData.failed,total:g.dispatchData.total,dispatched:g.dispatchData.dispatched,processing:g.dispatchData.processing})})]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s(y=>!y),className:"text-bambu-gray hover:text-white transition-colors","aria-label":e(i?"backgroundDispatch.expandDetails":"backgroundDispatch.collapseDetails"),children:i?a.jsx(Sl,{className:"w-4 h-4"}):a.jsx(En,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>x(g.id),className:"text-bambu-gray hover:text-white transition-colors","aria-label":e("backgroundDispatch.dismissToast"),children:a.jsx(Ut,{className:"w-4 h-4"})})]})]}),!i&&a.jsx("div",{className:"mt-3 space-y-2 max-h-64 overflow-y-auto pr-1",children:g.dispatchData.jobs.map(y=>{const _={dispatched:15,processing:60,completed:100,failed:100,cancelled:100},N={dispatched:"bg-bambu-gray/60",processing:"bg-bambu-green",completed:"bg-green-500",failed:"bg-red-500",cancelled:"bg-yellow-500"};return a.jsxs("div",{className:"rounded border border-white/10 bg-black/15 p-2",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("span",{className:"text-xs text-white truncate",title:y.sourceName,children:y.sourceName}),a.jsxs("div",{className:"flex items-center gap-2",children:[(y.status==="dispatched"||y.status==="processing")&&a.jsx("button",{onClick:()=>{v(y.jobId)},disabled:o.has(y.jobId),className:"text-[11px] text-red-300 hover:text-red-200 disabled:opacity-50 disabled:cursor-not-allowed",title:e("backgroundDispatch.cancelDispatchJob"),children:o.has(y.jobId)?e("backgroundDispatch.cancelling"):e("backgroundDispatch.cancel")}),a.jsx("span",{className:"text-[11px] uppercase tracking-wide text-bambu-gray",children:e(`backgroundDispatch.status.${y.status}`)})]})]}),a.jsx("div",{className:"text-[11px] text-bambu-gray truncate",title:y.printerName,children:y.printerName}),y.message&&a.jsx("div",{className:"text-[11px] text-bambu-gray truncate",title:y.message,children:y.message}),y.status==="processing"&&typeof y.uploadBytes=="number"&&typeof y.uploadTotalBytes=="number"&&y.uploadTotalBytes>0&&a.jsxs("div",{className:"text-[11px] text-bambu-gray truncate",children:[h(y.uploadBytes)," / ",h(y.uploadTotalBytes),typeof y.uploadProgressPct=="number"?` (${y.uploadProgressPct.toFixed(1)}%)`:""]}),a.jsx("div",{className:"mt-1 h-1.5 w-full rounded bg-white/10 overflow-hidden",children:a.jsx("div",{className:`h-full ${N[y.status]} transition-all duration-300`,style:{width:`${y.status==="processing"&&typeof y.uploadProgressPct=="number"?Math.max(0,Math.min(100,y.uploadProgressPct)):_[y.status]}%`}})})]},y.jobId)})})]}):a.jsxs(a.Fragment,{children:[t8[g.type],a.jsx("span",{className:"text-white text-sm",children:g.message}),a.jsx("button",{onClick:()=>x(g.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ut,{className:"w-4 h-4"})})]})},g.id))})]})}function Yge(t="system"){switch(t){case"us":return"MM/DD/YYYY";case"eu":return"DD/MM/YYYY";case"iso":return"YYYY-MM-DD";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 Xge(t="system"){switch(t){case"12h":return"HH:MM AM/PM";case"24h":return"HH:MM";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 S3(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}`;default:return t.toLocaleDateString()}}function n8(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}`;default:return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}}function dS(t){for(const e of["/",".","-"]){const n=t.split(e);if(n.length===3)return n}return null}function Qge(t,e="system"){if(!t)return null;let n,r,i;try{switch(e){case"us":{const s=dS(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=dS(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=dS(t);if(!s)return null;i=parseInt(s[0],10),r=parseInt(s[1],10),n=parseInt(s[2],10);break}default:{const o=new Date(2e3,11,31).toLocaleDateString(),l=dS(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 Zge(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 _3(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 L1(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Jn(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function wb(t,e){const n=Jn(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function Uf(t,e="system",n){const r=Jn(t);if(!r)return"";const s=L1(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,s)}function JY(t,e="system",n){const i=L1({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}function GF(t,e="system",n){const r=new Date,i=new Date(r.getTime()+t*60*1e3),s=new Date;s.setHours(0,0,0,0);const o=new Date(i);o.setHours(0,0,0,0);const l={hour:"2-digit",minute:"2-digit"};e==="12h"?l.hour12=!0:e==="24h"&&(l.hour12=!1);const c=i.toLocaleTimeString([],l),u=Math.floor((o.getTime()-s.getTime())/864e5);return u===0?c:u===1?`${n?.("common.tomorrow")??"Tomorrow"} ${c}`:`${i.toLocaleDateString([],{weekday:"short"})} ${c}`}function js(t){if(t==null||t<0)return"--";const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function C0(t,e="system",n){if(!t)return n?.("time.unknown")??"-";const r=Jn(t);if(!r)return n?.("time.unknown")??"-";const i=new Date,s=r.getTime()-i.getTime(),o=s<0,l=Math.abs(s),c=Math.floor(l/6e4),u=Math.floor(l/36e5),d=Math.floor(l/864e5);return c<1?o?n?.("time.justNow")??"Just now":n?.("time.now")??"Now":u<1?o?n?.("time.minsAgo",{count:c})??`${c}m ago`:n?.("time.inMins",{count:c})??`in ${c}m`:d<1?o?n?.("time.hoursAgo",{count:u})??`${u}h ago`:n?.("time.inHours",{count:u})??`in ${u}h`:d<7?o?n?.("time.daysAgo",{count:d})??`${d}d ago`:n?.("time.inDays",{count:d})??`in ${d}d`:Uf(t,e)}const A0=[{id:"printers",to:"/",icon:Dr,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Fs,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Xr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Fhe,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:Zb,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:zf,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:xs,labelKey:"nav.projects"},{id:"inventory",to:"/inventory",icon:Nme,labelKey:"nav.inventory"},{id:"files",to:"/files",icon:nc,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:oC,labelKey:"nav.settings"}];function Jge(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return A0.map(e=>e.id)}return A0.map(e=>e.id)}function ebe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function X2(t){return t.startsWith("ext-")}function eX(){return localStorage.getItem("defaultView")||"/"}function tbe(t){localStorage.setItem("defaultView",t)}function nbe(){const t=jl(),e=Wc(),{mode:n,toggleMode:r}=lp(),{t:i}=Et(),s=qge(),{user:o,authEnabled:l,logout:c,hasPermission:u}=Rr(),{showToast:d}=dn(),[h,f]=w.useState(!1),[p,x]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[v,g]=w.useState(!1),[y,_]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[N,A]=w.useState(!1),[C,j]=w.useState(!1),[k,R]=w.useState(!1),[M,D]=w.useState(Jge),[G,U]=w.useState(null),[W,L]=w.useState(null),ee=w.useRef(!1),[ae,Y]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[se,ce]=w.useState(null),{data:ye}=Je({queryKey:["version"],queryFn:ge.getVersion,staleTime:1/0}),{data:Z}=Je({queryKey:["settings"],queryFn:ge.getSettings,staleTime:300*1e3}),{data:ue}=Je({queryKey:["updateCheck"],queryFn:ge.checkForUpdates,enabled:Z?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:pe}=Je({queryKey:["external-links"],queryFn:ge.getExternalLinks}),{data:be}=Je({queryKey:["smart-plugs"],queryFn:ge.getSmartPlugs,staleTime:30*1e3}),Ee=be?.some(le=>le.show_in_switchbar)??!1,{data:$}=Je({queryKey:["debugLogging"],queryFn:rb.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:K}=Je({queryKey:["developer-mode-warnings"],queryFn:ge.getDeveloperModeWarnings,staleTime:10*1e3,refetchInterval:30*1e3,refetchOnWindowFocus:!0}),{data:T}=Je({queryKey:["queue","pending"],queryFn:()=>ge.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),E=T?.length??0,{data:O}=Je({queryKey:["pending-uploads","count"],queryFn:zg.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),q=O?.count??0,B=w.useMemo(()=>{const le=new Set;return T?.forEach(Ce=>{Ce.printer_id&&le.add(Ce.printer_id)}),Array.from(le)},[T]),z=Qb({queries:B.map(le=>({queryKey:["printerStatus",le],queryFn:()=>ge.getPrinterStatus(le),staleTime:30*1e3}))}).some(le=>{const Ce=le.data;return Ce?(Ce.state==="FINISH"||Ce.state==="FAILED")&&!Ce.plate_cleared:!1}),[V,te]=w.useState(null);w.useEffect(()=>{if(!$?.enabled||!$.enabled_at){te(null);return}const le=Jn($.enabled_at)?.getTime()??Date.now(),Ce=()=>{te(Math.floor((Date.now()-le)/1e3))};Ce();const Ne=setInterval(Ce,1e3);return()=>clearInterval(Ne)},[$?.enabled,$?.enabled_at]);const Q=w.useMemo(()=>new Map(A0.map(le=>[le.id,le])),[]),ne=w.useMemo(()=>new Map((pe||[]).map(le=>[`ext-${le.id}`,le])),[pe]),ie=(()=>{const le=[],Ce=new Set,Ne={archives:"archives:read",queue:"queue:read",stats:"stats:read",profiles:"kprofiles:read",maintenance:"maintenance:read",projects:"projects:read",inventory:"inventory:read",files:"library:read",settings:"settings:read"},Ue=He=>l&&He in Ne&&!u(Ne[He]);for(const He of M)Ue(He)||(Q.has(He)||ne.has(He))&&(le.push(He),Ce.add(He));for(const He of A0)Ue(He.id)||Ce.has(He.id)||(le.push(He.id),Ce.add(He.id));for(const He of pe||[]){const de=`ext-${He.id}`;Ce.has(de)||(le.push(de),Ce.add(de))}return le})(),me=(le,Ce)=>{U(Ce),le.dataTransfer.effectAllowed="move",le.dataTransfer.setData("text/plain",Ce)},fe=(le,Ce)=>{le.preventDefault(),le.dataTransfer.dropEffect="move",L(Ce)},oe=()=>{L(null)},I=(le,Ce)=>{if(le.preventDefault(),G===null||G===Ce){U(null),L(null);return}const Ne=[...ie],Ue=Ne.indexOf(G),He=Ne.indexOf(Ce);if(Ue===-1||He===-1){U(null),L(null);return}Ne.splice(Ue,1),Ne.splice(He,0,G),D(Ne),ebe(Ne),U(null),L(null)},F=()=>{U(null),L(null)},J=ue?.update_available&&ue.latest_version&&ue.latest_version!==ae,xe=()=>{ue?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",ue.latest_version),Y(ue.latest_version))};w.useEffect(()=>{if(!ee.current&&e.pathname==="/"){const le=eX();le!=="/"&&(ee.current=!0,t(le,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(y))},[y]),w.useEffect(()=>{s&&A(!1)},[e.pathname,s]),w.useEffect(()=>{const le=Ce=>{if(!u("printers:control"))return;const Ne=Ce.detail;ce({printer_id:Ne.printer_id,printer_name:Ne.printer_name,message:Ne.message})};return window.addEventListener("plate-not-empty",le),()=>window.removeEventListener("plate-not-empty",le)},[u]);const he=w.useCallback(le=>{const Ce=le.target;if(!(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable)&&!le.metaKey&&!le.ctrlKey&&!le.altKey){const Ne=parseInt(le.key);if(Ne>=1&&Ne<=ie.length&&Ne<=9){const Ue=ie[Ne-1];if(le.preventDefault(),X2(Ue)){const He=ne.get(Ue);if(He?.open_in_new_tab)window.open(He.url,"_blank","noopener,noreferrer");else{const de=Ue.replace("ext-","");t(`/external/${de}`)}}else{const He=Q.get(Ue);He&&t(He.to)}return}switch(le.key){case"?":le.preventDefault(),j(!0);break;case"Escape":j(!1);break}}},[t,ie,Q,ne]);return w.useEffect(()=>(document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)),[he]),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:()=>A(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:a.jsx(Yfe,{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:()=>A(!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 ${y?"w-64":"w-16"}`}`,children:[a.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s||y?"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||y?"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:ie.map(le=>{if(X2(le)){const Ne=ne.get(le);if(!Ne)return null;const Ue=Ne.custom_icon?null:uC(Ne.icon);return a.jsx("li",{draggable:!0,onDragStart:He=>me(He,le),onDragOver:He=>fe(He,le),onDragLeave:oe,onDrop:He=>I(He,le),onDragEnd:F,className:`relative ${G===le?"opacity-50":""} ${W===le&&G!==le?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:Ne.open_in_new_tab?a.jsxs("a",{href:Ne.url,target:"_blank",rel:"noopener noreferrer",className:`flex items-center ${s||y?"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&&!y?Ne.name:void 0,children:[y&&!s&&a.jsx(Oh,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),Ne.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${Ne.id}/icon`,alt:"",className:"w-5 h-5 flex-shrink-0"}):Ue&&a.jsx(Ue,{className:"w-5 h-5 flex-shrink-0"}),(s||y)&&a.jsx("span",{children:Ne.name})]}):a.jsxs(Gg,{to:`/external/${Ne.id}`,className:({isActive:He})=>`flex items-center ${s||y?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${He?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!y?Ne.name:void 0,children:[y&&!s&&a.jsx(Oh,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),Ne.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${Ne.id}/icon`,alt:"",className:"w-5 h-5 flex-shrink-0"}):Ue&&a.jsx(Ue,{className:"w-5 h-5 flex-shrink-0"}),(s||y)&&a.jsx("span",{children:Ne.name})]})},le)}else{const Ne=Q.get(le);if(!Ne)return null;const{to:Ue,icon:He,labelKey:de}=Ne,we=le==="queue"&&E>0,ke=le==="archives"&&q>0,_e=we?E:ke?q:0,Ae=we||ke,Ve=le==="printers"&&z;return a.jsx("li",{draggable:!0,onDragStart:Te=>me(Te,le),onDragOver:Te=>fe(Te,le),onDragLeave:oe,onDrop:Te=>I(Te,le),onDragEnd:F,className:`relative ${G===le?"opacity-50":""} ${W===le&&G!==le?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(Gg,{to:Ue,className:({isActive:Te})=>`flex items-center ${s||y?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Te?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!y?i(de):void 0,children:[y&&!s&&a.jsx(Oh,{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(He,{className:"w-5 h-5 flex-shrink-0"}),Ve&&a.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2.5 h-2.5 bg-yellow-500 rounded-full border-2 border-bambu-dark-secondary"}),Ae&&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 ${ke?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:_e>99?"99+":_e})]}),(s||y)&&a.jsx("span",{children:i(de)})]})},le)}})})}),!s&&a.jsx("button",{onClick:()=>_(!y),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(y?"nav.collapseSidebar":"nav.expandSidebar"),children:y?a.jsx(Jl,{className:"w-5 h-5"}):a.jsx(pi,{className:"w-5 h-5"})}),a.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s||y?a.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Ee&&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(bl,{className:"w-5 h-5"})}),k&&a.jsx(JB,{onClose:()=>R(!1)})]}),u("system:read")?a.jsx(Gg,{to:"/system",className:({isActive:le})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${le?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(to,{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(to,{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(p3,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>j(!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(g3,{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(QB,{className:"w-5 h-5"}):a.jsx(D1,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:a.jsx(il,{className:"w-5 h-5"})}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx(x3,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",ye?.version||"..."]}),ue?.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:ue.latest_version}),children:[a.jsx(K2,{className:"w-4 h-4"}),a.jsx("span",{children:i("nav.update")})]})]})]}):a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[ue?.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:ue.latest_version}),children:a.jsx(K2,{className:"w-5 h-5"})}),Ee&&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(bl,{className:"w-5 h-5"})}),k&&a.jsx(JB,{onClose:()=>R(!1)})]}),u("system:read")?a.jsx(Gg,{to:"/system",className:({isActive:le})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${le?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(to,{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(to,{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(p3,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>j(!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(g3,{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(QB,{className:"w-5 h-5"}):a.jsx(D1,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:a.jsx(il,{className:"w-5 h-5"})}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx(x3,{className:"w-5 h-5"})})]})]})})]}),a.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${s?"mt-14":y?"ml-64":"ml-16"}`,children:[$?.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(Xk,{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"}),V!==null&&a.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(V/60),"m ",V%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"})})]})}),K&&K.length>0&&a.jsx("div",{className:"bg-orange-500/20 border-b border-orange-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(Ope,{className:"w-4 h-4 text-orange-500"}),a.jsx("span",{className:"text-orange-200",children:i("printers.developerModeWarning",{names:K.map(le=>le.name).join(", "),defaultValue:`Developer LAN mode is not enabled on: ${K.map(le=>le.name).join(", ")}. Some features may not work.`})}),a.jsx("a",{href:"https://wiki.bambulab.com/en/knowledge-sharing/enable-developer-mode",target:"_blank",rel:"noopener noreferrer",className:"text-orange-400 hover:text-orange-300 font-medium underline ml-2",children:i("printers.howToEnable",{defaultValue:"How to enable"})})]})}),J&&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(K2,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{children:i("nav.updateAvailableBanner",{version:ue?.latest_version,defaultValue:`Version ${ue?.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:xe,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:a.jsx(Ut,{className:"w-4 h-4"})})]}),a.jsx(uY,{})]}),C&&a.jsx(Hge,{onClose:()=>j(!1),sidebarItems:ie.map(le=>{if(X2(le)){const Ce=ne.get(le);return Ce?{type:"external",label:Ce.name}:null}else{const Ce=Q.get(le);return Ce?{type:"nav",label:Ce.labelKey,labelKey:Ce.labelKey}:null}}).filter(Boolean)}),se&&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:se.printer_name}),a.jsx("p",{className:"text-bambu-gray mb-6",children:i("plateAlert.message")}),a.jsx("button",{onClick:()=>ce(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:()=>{f(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(Ct,{className:"w-full max-w-md",onClick:le=>le.stopPropagation(),children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(il,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("changePassword.title")})]}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{f(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Ut,{className:"w-5 h-5"})})]})}),a.jsxs(Tt,{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:p.currentPassword,onChange:le=>x({...p,currentPassword:le.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder: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:p.newPassword,onChange:le=>x({...p,newPassword:le.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder: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:p.confirmPassword,onChange:le=>x({...p,confirmPassword:le.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${p.confirmPassword&&p.newPassword!==p.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("changePassword.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),p.confirmPassword&&p.newPassword!==p.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(Oe,{variant:"secondary",onClick:()=>{f(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:i("common.cancel")}),a.jsx(Oe,{onClick:async()=>{if(p.newPassword!==p.confirmPassword){d(i("changePassword.passwordsDoNotMatch"),"error");return}if(p.newPassword.length<6){d(i("changePassword.passwordTooShort"),"error");return}g(!0);try{await ge.changePassword(p.currentPassword,p.newPassword),d(i("changePassword.success"),"success"),f(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})}catch(le){const Ce=le instanceof Error?le.message:i("changePassword.failed");d(Ce,"error")}finally{g(!1)}},disabled:v||!p.currentPassword||!p.newPassword||p.newPassword!==p.confirmPassword||p.newPassword.length<6,children:v?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(il,{className:"w-4 h-4"}),i("changePassword.title")]})})]})]})]})})]})}const WF="181",ab={ROTATE:0,DOLLY:1,PAN:2},Wg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},rbe=0,r8=1,abe=2,tX=1,ibe=2,ju=3,Qh=0,ao=1,kc=2,Wu=0,ib=1,a8=2,i8=3,s8=4,sbe=5,Qm=100,obe=101,lbe=102,cbe=103,ube=104,dbe=200,hbe=201,mbe=202,fbe=203,N3=204,k3=205,pbe=206,gbe=207,bbe=208,xbe=209,ybe=210,vbe=211,wbe=212,Sbe=213,_be=214,C3=0,A3=1,T3=2,Sb=3,M3=4,P3=5,j3=6,E3=7,KF=0,Nbe=1,kbe=2,zh=0,Cbe=1,Abe=2,Tbe=3,Mbe=4,Pbe=5,jbe=6,Ebe=7,nX=300,_b=301,Nb=302,D3=303,R3=304,dC=306,F3=1e3,Uu=1001,L3=1002,Eo=1003,Dbe=1004,hS=1005,pl=1006,Q2=1007,sf=1008,zc=1009,rX=1010,aX=1011,T0=1012,YF=1013,Bf=1014,Bu=1015,tx=1016,XF=1017,QF=1018,M0=1020,iX=35902,sX=35899,oX=1021,lX=1022,Yl=1023,P0=1026,j0=1027,cX=1028,ZF=1029,JF=1030,e4=1031,t4=1033,J_=33776,e1=33777,t1=33778,n1=33779,O3=35840,I3=35841,z3=35842,U3=35843,B3=36196,H3=37492,$3=37496,V3=37808,q3=37809,G3=37810,W3=37811,K3=37812,Y3=37813,X3=37814,Q3=37815,Z3=37816,J3=37817,eD=37818,tD=37819,nD=37820,rD=37821,aD=36492,iD=36494,sD=36495,oD=36283,lD=36284,cD=36285,uD=36286,Rbe=3200,Fbe=3201,uX=0,Lbe=1,bh="",Ao="srgb",kb="srgb-linear",O1="linear",Ur="srgb",Yp=7680,o8=519,Obe=512,Ibe=513,zbe=514,dX=515,Ube=516,Bbe=517,Hbe=518,$be=519,l8=35044,c8="300 es",Tc=2e3,I1=2001;function hX(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function z1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Vbe(){const t=z1("canvas");return t.style.display="block",t}const u8={};function d8(...t){const e="THREE."+t.shift();console.log(e,...t)}function Cn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Va(...t){const e="THREE."+t.shift();console.error(e,...t)}function E0(...t){const e=t.join(" ");e in u8||(u8[e]=!0,Cn(...t))}function qbe(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 cp=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 ls=["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"],r1=Math.PI/180,dD=180/Math.PI;function Sv(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ls[t&255]+ls[t>>8&255]+ls[t>>16&255]+ls[t>>24&255]+"-"+ls[e&255]+ls[e>>8&255]+"-"+ls[e>>16&15|64]+ls[e>>24&255]+"-"+ls[n&63|128]+ls[n>>8&255]+"-"+ls[n>>16&255]+ls[n>>24&255]+ls[r&255]+ls[r>>8&255]+ls[r>>16&255]+ls[r>>24&255]).toLowerCase()}function rr(t,e,n){return Math.max(e,Math.min(n,t))}function Gbe(t,e){return(t%e+e)%e}function Z2(t,e,n){return(1-n)*t+n*e}function cy(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 Xs(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 Wbe={DEG2RAD:r1};let qn=class mX{constructor(e=0,n=0){mX.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=rr(this.x,e.x,n.x),this.y=rr(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=rr(this.x,e,n),this.y=rr(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(rr(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(rr(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}},Hf=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],f=s[o+0],p=s[o+1],x=s[o+2],v=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]=f,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(h!==v||c!==f||u!==p||d!==x){let g=c*f+u*p+d*x+h*v;g<0&&(f=-f,p=-p,x=-x,v=-v,g=-g);let y=1-l;if(g<.9995){const _=Math.acos(g),N=Math.sin(_);y=Math.sin(y*_)/N,l=Math.sin(l*_)/N,c=c*y+f*l,u=u*y+p*l,d=d*y+x*l,h=h*y+v*l}else{c=c*y+f*l,u=u*y+p*l,d=d*y+x*l,h=h*y+v*l;const _=1/Math.sqrt(c*c+u*u+d*d+h*h);c*=_,u*=_,d*=_,h*=_}}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],f=s[o+1],p=s[o+2],x=s[o+3];return e[n]=l*x+d*h+c*p-u*f,e[n+1]=c*x+d*f+u*h-l*p,e[n+2]=u*x+d*p+l*f-c*h,e[n+3]=d*x-l*h-c*f-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),h=l(s/2),f=c(r/2),p=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=f*d*h+u*p*x,this._y=u*p*h-f*d*x,this._z=u*d*x+f*p*h,this._w=u*d*h-f*p*x;break;case"YXZ":this._x=f*d*h+u*p*x,this._y=u*p*h-f*d*x,this._z=u*d*x-f*p*h,this._w=u*d*h+f*p*x;break;case"ZXY":this._x=f*d*h-u*p*x,this._y=u*p*h+f*d*x,this._z=u*d*x+f*p*h,this._w=u*d*h-f*p*x;break;case"ZYX":this._x=f*d*h-u*p*x,this._y=u*p*h+f*d*x,this._z=u*d*x-f*p*h,this._w=u*d*h+f*p*x;break;case"YZX":this._x=f*d*h+u*p*x,this._y=u*p*h+f*d*x,this._z=u*d*x-f*p*h,this._w=u*d*h-f*p*x;break;case"XZY":this._x=f*d*h-u*p*x,this._y=u*p*h-f*d*x,this._z=u*d*x+f*p*h,this._w=u*d*h+f*p*x;break;default:Cn("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],f=r+l+h;if(f>0){const p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(d-c)*p,this._y=(s-u)*p,this._z=(o-i)*p}else if(r>l&&r>h){const p=2*Math.sqrt(1+r-l-h);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+u)/p}else if(l>h){const p=2*Math.sqrt(1+l-r-h);this._w=(s-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+h-r-l);this._w=(o-i)/p,this._x=(s+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(rr(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}},xt=class fX{constructor(e=0,n=0,r=0){fX.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(h8.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(h8.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=rr(this.x,e.x,n.x),this.y=rr(this.y,e.y,n.y),this.z=rr(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=rr(this.x,e,n),this.y=rr(this.y,e,n),this.z=rr(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(rr(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 J2.copy(this).projectOnVector(e),this.sub(J2)}reflect(e){return this.sub(J2.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(rr(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 J2=new xt,h8=new Hf;let Kn=class pX{constructor(e,n,r,i,s,o,l,c,u){pX.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],f=r[2],p=r[5],x=r[8],v=i[0],g=i[3],y=i[6],_=i[1],N=i[4],A=i[7],C=i[2],j=i[5],k=i[8];return s[0]=o*v+l*_+c*C,s[3]=o*g+l*N+c*j,s[6]=o*y+l*A+c*k,s[1]=u*v+d*_+h*C,s[4]=u*g+d*N+h*j,s[7]=u*y+d*A+h*k,s[2]=f*v+p*_+x*C,s[5]=f*g+p*N+x*j,s[8]=f*y+p*A+x*k,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],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,f=l*c-d*s,p=u*s-o*c,x=n*h+r*f+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=h*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*o)*v,e[3]=f*v,e[4]=(d*n-i*c)*v,e[5]=(i*s-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(o*n-r*s)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,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(eM.makeScale(e,n)),this}rotate(e){return this.premultiply(eM.makeRotation(-e)),this}translate(e,n){return this.premultiply(eM.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 eM=new Kn,m8=new Kn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),f8=new Kn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Kbe(){const t={enabled:!0,workingColorSpace:kb,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Ur&&(i.r=Ku(i.r),i.g=Ku(i.g),i.b=Ku(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===Ur&&(i.r=sb(i.r),i.g=sb(i.g),i.b=sb(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===bh?O1: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 E0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return E0("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({[kb]:{primaries:e,whitePoint:r,transfer:O1,toXYZ:m8,fromXYZ:f8,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ao},outputColorSpaceConfig:{drawingBufferColorSpace:Ao}},[Ao]:{primaries:e,whitePoint:r,transfer:Ur,toXYZ:m8,fromXYZ:f8,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ao}}}),t}const br=Kbe();function Ku(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function sb(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Xp,Ybe=class{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{Xp===void 0&&(Xp=z1("canvas")),Xp.width=e.width,Xp.height=e.height;const i=Xp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Xp}return r.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=z1("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Ku(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(Ku(n[r]/255)*255):n[r]=Ku(n[r]);return{data:n,width:e.width,height:e.height}}else return Cn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Xbe=0,n4=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Xbe++}),this.uuid=Sv(),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(tM(i[o].image)):s.push(tM(i[o]))}else s=tM(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function tM(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Ybe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Cn("Texture: Unable to serialize Texture."),{})}let Qbe=0;const nM=new xt;let sc=class a1 extends cp{constructor(e=a1.DEFAULT_IMAGE,n=a1.DEFAULT_MAPPING,r=Uu,i=Uu,s=pl,o=sf,l=Yl,c=zc,u=a1.DEFAULT_ANISOTROPY,d=bh){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Qbe++}),this.uuid=Sv(),this.name="",this.source=new n4(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 qn(0,0),this.repeat=new qn(1,1),this.center=new qn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Kn,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(nM).x}get height(){return this.source.getSize(nM).y}get depth(){return this.source.getSize(nM).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){Cn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Cn(`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!==nX)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case F3:e.x=e.x-Math.floor(e.x);break;case Uu:e.x=e.x<0?0:1;break;case L3: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 F3:e.y=e.y-Math.floor(e.y);break;case Uu:e.y=e.y<0?0:1;break;case L3: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++}};sc.DEFAULT_IMAGE=null;sc.DEFAULT_MAPPING=nX;sc.DEFAULT_ANISOTROPY=1;let ti=class gX{constructor(e=0,n=0,r=0,i=1){gX.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],f=c[1],p=c[5],x=c[9],v=c[2],g=c[6],y=c[10];if(Math.abs(d-f)<.01&&Math.abs(h-v)<.01&&Math.abs(x-g)<.01){if(Math.abs(d+f)<.1&&Math.abs(h+v)<.1&&Math.abs(x+g)<.1&&Math.abs(u+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,A=(p+1)/2,C=(y+1)/2,j=(d+f)/4,k=(h+v)/4,R=(x+g)/4;return N>A&&N>C?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=j/r,s=k/r):A>C?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=j/i,s=R/i):C<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(C),r=k/s,i=R/s),this.set(r,i,s,n),this}let _=Math.sqrt((g-x)*(g-x)+(h-v)*(h-v)+(f-d)*(f-d));return Math.abs(_)<.001&&(_=1),this.x=(g-x)/_,this.y=(h-v)/_,this.z=(f-d)/_,this.w=Math.acos((u+p+y-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=rr(this.x,e.x,n.x),this.y=rr(this.y,e.y,n.y),this.z=rr(this.z,e.z,n.z),this.w=rr(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=rr(this.x,e,n),this.y=rr(this.y,e,n),this.z=rr(this.z,e,n),this.w=rr(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(rr(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}},Zbe=class extends cp{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:pl,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 ti(0,0,e,n),this.scissorTest=!1,this.viewport=new ti(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new sc(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:pl,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 n4(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"})}},$f=class extends Zbe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},bX=class extends sc{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=Eo,this.minFilter=Eo,this.wrapR=Uu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Jbe=class extends sc{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=Eo,this.minFilter=Eo,this.wrapR=Uu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Uh=class{constructor(e=new xt(1/0,1/0,1/0),n=new xt(-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(Ol.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ol.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=Ol.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,Ol):Ol.fromBufferAttribute(s,o),Ol.applyMatrix4(e.matrixWorld),this.expandByPoint(Ol);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),mS.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),mS.copy(r.boundingBox)),mS.applyMatrix4(e.matrixWorld),this.union(mS)}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,Ol),Ol.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(uy),fS.subVectors(this.max,uy),Qp.subVectors(e.a,uy),Zp.subVectors(e.b,uy),Jp.subVectors(e.c,uy),qd.subVectors(Zp,Qp),Gd.subVectors(Jp,Zp),jm.subVectors(Qp,Jp);let n=[0,-qd.z,qd.y,0,-Gd.z,Gd.y,0,-jm.z,jm.y,qd.z,0,-qd.x,Gd.z,0,-Gd.x,jm.z,0,-jm.x,-qd.y,qd.x,0,-Gd.y,Gd.x,0,-jm.y,jm.x,0];return!rM(n,Qp,Zp,Jp,fS)||(n=[1,0,0,0,1,0,0,0,1],!rM(n,Qp,Zp,Jp,fS))?!1:(pS.crossVectors(qd,Gd),n=[pS.x,pS.y,pS.z],rM(n,Qp,Zp,Jp,fS))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ol).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ol).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:(pu[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pu[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pu[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pu[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pu[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pu[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pu[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pu[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pu),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 pu=[new xt,new xt,new xt,new xt,new xt,new xt,new xt,new xt],Ol=new xt,mS=new Uh,Qp=new xt,Zp=new xt,Jp=new xt,qd=new xt,Gd=new xt,jm=new xt,uy=new xt,fS=new xt,pS=new xt,Em=new xt;function rM(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){Em.fromArray(t,s);const l=i.x*Math.abs(Em.x)+i.y*Math.abs(Em.y)+i.z*Math.abs(Em.z),c=e.dot(Em),u=n.dot(Em),d=r.dot(Em);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const exe=new Uh,dy=new xt,aM=new xt;let hC=class{constructor(e=new xt,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):exe.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;dy.subVectors(e,this.center);const n=dy.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(dy,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):(aM.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(dy.copy(e.center).add(aM)),this.expandByPoint(dy.copy(e.center).sub(aM))),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 gu=new xt,iM=new xt,gS=new xt,Wd=new xt,sM=new xt,bS=new xt,oM=new xt;let r4=class{constructor(e=new xt,n=new xt(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,gu)),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=gu.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(gu.copy(this.origin).addScaledVector(this.direction,n),gu.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){iM.copy(e).add(n).multiplyScalar(.5),gS.copy(n).sub(e).normalize(),Wd.copy(this.origin).sub(iM);const s=e.distanceTo(n)*.5,o=-this.direction.dot(gS),l=Wd.dot(this.direction),c=-Wd.dot(gS),u=Wd.lengthSq(),d=Math.abs(1-o*o);let h,f,p,x;if(d>0)if(h=o*c-l,f=o*l-c,x=s*d,h>=0)if(f>=-x)if(f<=x){const v=1/d;h*=v,f*=v,p=h*(h+o*f+2*l)+f*(o*h+f+2*c)+u}else f=s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+u;else f=-s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+u;else f<=-x?(h=Math.max(0,-(-o*s+l)),f=h>0?-s:Math.min(Math.max(-s,-c),s),p=-h*h+f*(f+2*c)+u):f<=x?(h=0,f=Math.min(Math.max(-s,-c),s),p=f*(f+2*c)+u):(h=Math.max(0,-(o*s+l)),f=h>0?s:Math.min(Math.max(-s,-c),s),p=-h*h+f*(f+2*c)+u);else f=o>0?-s:s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(iM).addScaledVector(gS,f),p}intersectSphere(e,n){gu.subVectors(e.center,this.origin);const r=gu.dot(this.direction),i=gu.dot(gu)-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,f=this.origin;return u>=0?(r=(e.min.x-f.x)*u,i=(e.max.x-f.x)*u):(r=(e.max.x-f.x)*u,i=(e.min.x-f.x)*u),d>=0?(s=(e.min.y-f.y)*d,o=(e.max.y-f.y)*d):(s=(e.max.y-f.y)*d,o=(e.min.y-f.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),h>=0?(l=(e.min.z-f.z)*h,c=(e.max.z-f.z)*h):(l=(e.max.z-f.z)*h,c=(e.min.z-f.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,gu)!==null}intersectTriangle(e,n,r,i,s){sM.subVectors(n,e),bS.subVectors(r,e),oM.crossVectors(sM,bS);let o=this.direction.dot(oM),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Wd.subVectors(this.origin,e);const c=l*this.direction.dot(bS.crossVectors(Wd,bS));if(c<0)return null;const u=l*this.direction.dot(sM.cross(Wd));if(u<0||c+u>o)return null;const d=-l*Wd.dot(oM);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)}},oi=class hD{constructor(e,n,r,i,s,o,l,c,u,d,h,f,p,x,v,g){hD.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,f,p,x,v,g)}set(e,n,r,i,s,o,l,c,u,d,h,f,p,x,v,g){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=s,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=h,y[14]=f,y[3]=p,y[7]=x,y[11]=v,y[15]=g,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 hD().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/eg.setFromMatrixColumn(e,0).length(),s=1/eg.setFromMatrixColumn(e,1).length(),o=1/eg.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 f=o*d,p=o*h,x=l*d,v=l*h;n[0]=c*d,n[4]=-c*h,n[8]=u,n[1]=p+x*u,n[5]=f-v*u,n[9]=-l*c,n[2]=v-f*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const f=c*d,p=c*h,x=u*d,v=u*h;n[0]=f+v*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*h,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=v+f*l,n[10]=o*c}else if(e.order==="ZXY"){const f=c*d,p=c*h,x=u*d,v=u*h;n[0]=f-v*l,n[4]=-o*h,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=v-f*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const f=o*d,p=o*h,x=l*d,v=l*h;n[0]=c*d,n[4]=x*u-p,n[8]=f*u+v,n[1]=c*h,n[5]=v*u+f,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const f=o*c,p=o*u,x=l*c,v=l*u;n[0]=c*d,n[4]=v-f*h,n[8]=x*h+p,n[1]=h,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*h+x,n[10]=f-v*h}else if(e.order==="XZY"){const f=o*c,p=o*u,x=l*c,v=l*u;n[0]=c*d,n[4]=-h,n[8]=u*d,n[1]=f*h+v,n[5]=o*d,n[9]=p*h-x,n[2]=x*h-p,n[6]=l*d,n[10]=v*h+f}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(txe,e,nxe)}lookAt(e,n,r){const i=this.elements;return _o.subVectors(e,n),_o.lengthSq()===0&&(_o.z=1),_o.normalize(),Kd.crossVectors(r,_o),Kd.lengthSq()===0&&(Math.abs(r.z)===1?_o.x+=1e-4:_o.z+=1e-4,_o.normalize(),Kd.crossVectors(r,_o)),Kd.normalize(),xS.crossVectors(_o,Kd),i[0]=Kd.x,i[4]=xS.x,i[8]=_o.x,i[1]=Kd.y,i[5]=xS.y,i[9]=_o.y,i[2]=Kd.z,i[6]=xS.z,i[10]=_o.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],f=r[9],p=r[13],x=r[2],v=r[6],g=r[10],y=r[14],_=r[3],N=r[7],A=r[11],C=r[15],j=i[0],k=i[4],R=i[8],M=i[12],D=i[1],G=i[5],U=i[9],W=i[13],L=i[2],ee=i[6],ae=i[10],Y=i[14],se=i[3],ce=i[7],ye=i[11],Z=i[15];return s[0]=o*j+l*D+c*L+u*se,s[4]=o*k+l*G+c*ee+u*ce,s[8]=o*R+l*U+c*ae+u*ye,s[12]=o*M+l*W+c*Y+u*Z,s[1]=d*j+h*D+f*L+p*se,s[5]=d*k+h*G+f*ee+p*ce,s[9]=d*R+h*U+f*ae+p*ye,s[13]=d*M+h*W+f*Y+p*Z,s[2]=x*j+v*D+g*L+y*se,s[6]=x*k+v*G+g*ee+y*ce,s[10]=x*R+v*U+g*ae+y*ye,s[14]=x*M+v*W+g*Y+y*Z,s[3]=_*j+N*D+A*L+C*se,s[7]=_*k+N*G+A*ee+C*ce,s[11]=_*R+N*U+A*ae+C*ye,s[15]=_*M+N*W+A*Y+C*Z,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],f=e[10],p=e[14],x=e[3],v=e[7],g=e[11],y=e[15];return x*(+s*c*h-i*u*h-s*l*f+r*u*f+i*l*p-r*c*p)+v*(+n*c*p-n*u*f+s*o*f-i*o*p+i*u*d-s*c*d)+g*(+n*u*h-n*l*p-s*o*h+r*o*p+s*l*d-r*u*d)+y*(-i*l*d-n*c*h+n*l*f+i*o*h-r*o*f+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],f=e[10],p=e[11],x=e[12],v=e[13],g=e[14],y=e[15],_=h*g*u-v*f*u+v*c*p-l*g*p-h*c*y+l*f*y,N=x*f*u-d*g*u-x*c*p+o*g*p+d*c*y-o*f*y,A=d*v*u-x*h*u+x*l*p-o*v*p-d*l*y+o*h*y,C=x*h*c-d*v*c-x*l*f+o*v*f+d*l*g-o*h*g,j=n*_+r*N+i*A+s*C;if(j===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/j;return e[0]=_*k,e[1]=(v*f*s-h*g*s-v*i*p+r*g*p+h*i*y-r*f*y)*k,e[2]=(l*g*s-v*c*s+v*i*u-r*g*u-l*i*y+r*c*y)*k,e[3]=(h*c*s-l*f*s-h*i*u+r*f*u+l*i*p-r*c*p)*k,e[4]=N*k,e[5]=(d*g*s-x*f*s+x*i*p-n*g*p-d*i*y+n*f*y)*k,e[6]=(x*c*s-o*g*s-x*i*u+n*g*u+o*i*y-n*c*y)*k,e[7]=(o*f*s-d*c*s+d*i*u-n*f*u-o*i*p+n*c*p)*k,e[8]=A*k,e[9]=(x*h*s-d*v*s-x*r*p+n*v*p+d*r*y-n*h*y)*k,e[10]=(o*v*s-x*l*s+x*r*u-n*v*u-o*r*y+n*l*y)*k,e[11]=(d*l*s-o*h*s-d*r*u+n*h*u+o*r*p-n*l*p)*k,e[12]=C*k,e[13]=(d*v*i-x*h*i+x*r*f-n*v*f-d*r*g+n*h*g)*k,e[14]=(x*l*i-o*v*i-x*r*c+n*v*c+o*r*g-n*l*g)*k,e[15]=(o*h*i-d*l*i+d*r*c-n*h*c-o*r*f+n*l*f)*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,f=s*u,p=s*d,x=s*h,v=o*d,g=o*h,y=l*h,_=c*u,N=c*d,A=c*h,C=r.x,j=r.y,k=r.z;return i[0]=(1-(v+y))*C,i[1]=(p+A)*C,i[2]=(x-N)*C,i[3]=0,i[4]=(p-A)*j,i[5]=(1-(f+y))*j,i[6]=(g+_)*j,i[7]=0,i[8]=(x+N)*k,i[9]=(g-_)*k,i[10]=(1-(f+v))*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=eg.set(i[0],i[1],i[2]).length();const o=eg.set(i[4],i[5],i[6]).length(),l=eg.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],Il.copy(this);const u=1/s,d=1/o,h=1/l;return Il.elements[0]*=u,Il.elements[1]*=u,Il.elements[2]*=u,Il.elements[4]*=d,Il.elements[5]*=d,Il.elements[6]*=d,Il.elements[8]*=h,Il.elements[9]*=h,Il.elements[10]*=h,n.setFromRotationMatrix(Il),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=Tc,c=!1){const u=this.elements,d=2*s/(n-e),h=2*s/(r-i),f=(n+e)/(n-e),p=(r+i)/(r-i);let x,v;if(c)x=s/(o-s),v=o*s/(o-s);else if(l===Tc)x=-(o+s)/(o-s),v=-2*o*s/(o-s);else if(l===I1)x=-o/(o-s),v=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=f,u[12]=0,u[1]=0,u[5]=h,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=Tc,c=!1){const u=this.elements,d=2/(n-e),h=2/(r-i),f=-(n+e)/(n-e),p=-(r+i)/(r-i);let x,v;if(c)x=1/(o-s),v=o/(o-s);else if(l===Tc)x=-2/(o-s),v=-(o+s)/(o-s);else if(l===I1)x=-1/(o-s),v=-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]=f,u[1]=0,u[5]=h,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const eg=new xt,Il=new oi,txe=new xt(0,0,0),nxe=new xt(1,1,1),Kd=new xt,xS=new xt,_o=new xt,p8=new oi,g8=new Hf;let Zh=class xX{constructor(e=0,n=0,r=0,i=xX.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],f=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(rr(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,u),this._z=0);break;case"YXZ":this._x=Math.asin(-rr(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(rr(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-rr(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(rr(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,p));break;case"XZY":this._z=Math.asin(-rr(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,p),this._y=0);break;default:Cn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return p8.makeRotationFromQuaternion(e),this.setFromRotationMatrix(p8,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return g8.setFromEuler(this),this.setFromQuaternion(g8,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}};Zh.DEFAULT_ORDER="XYZ";let yX=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}},rxe=0;const b8=new xt,tg=new Hf,bu=new oi,yS=new xt,hy=new xt,axe=new xt,ixe=new Hf,x8=new xt(1,0,0),y8=new xt(0,1,0),v8=new xt(0,0,1),w8={type:"added"},sxe={type:"removed"},ng={type:"childadded",child:null},lM={type:"childremoved",child:null};let Oo=class i1 extends cp{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:rxe++}),this.uuid=Sv(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i1.DEFAULT_UP.clone();const e=new xt,n=new Zh,r=new Hf,i=new xt(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 oi},normalMatrix:{value:new Kn}}),this.matrix=new oi,this.matrixWorld=new oi,this.matrixAutoUpdate=i1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yX,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 tg.setFromAxisAngle(e,n),this.quaternion.multiply(tg),this}rotateOnWorldAxis(e,n){return tg.setFromAxisAngle(e,n),this.quaternion.premultiply(tg),this}rotateX(e){return this.rotateOnAxis(x8,e)}rotateY(e){return this.rotateOnAxis(y8,e)}rotateZ(e){return this.rotateOnAxis(v8,e)}translateOnAxis(e,n){return b8.copy(e).applyQuaternion(this.quaternion),this.position.add(b8.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(x8,e)}translateY(e){return this.translateOnAxis(y8,e)}translateZ(e){return this.translateOnAxis(v8,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(bu.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?yS.copy(e):yS.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),hy.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?bu.lookAt(hy,yS,this.up):bu.lookAt(yS,hy,this.up),this.quaternion.setFromRotationMatrix(bu),i&&(bu.extractRotation(i.matrixWorld),tg.setFromRotationMatrix(bu),this.quaternion.premultiply(tg.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Va("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(w8),ng.child=e,this.dispatchEvent(ng),ng.child=null):Va("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(sxe),lM.child=e,this.dispatchEvent(lM),lM.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),bu.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),bu.multiply(e.parent.matrixWorld)),e.applyMatrix4(bu),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(w8),ng.child=e,this.dispatchEvent(ng),ng.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(hy,e,axe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hy,ixe,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),f=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),h.length>0&&(r.shapes=h),f.length>0&&(r.skeletons=f),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Oo.DEFAULT_UP=new xt(0,1,0);Oo.DEFAULT_MATRIX_AUTO_UPDATE=!0;Oo.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zl=new xt,xu=new xt,cM=new xt,yu=new xt,rg=new xt,ag=new xt,S8=new xt,uM=new xt,dM=new xt,hM=new xt,mM=new ti,fM=new ti,pM=new ti;let my=class Ug{constructor(e=new xt,n=new xt,r=new xt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),zl.subVectors(e,n),i.cross(zl);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){zl.subVectors(i,n),xu.subVectors(r,n),cM.subVectors(e,n);const o=zl.dot(zl),l=zl.dot(xu),c=zl.dot(cM),u=xu.dot(xu),d=xu.dot(cM),h=o*u-l*l;if(h===0)return s.set(0,0,0),null;const f=1/h,p=(u*c-l*d)*f,x=(o*d-l*c)*f;return s.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,yu)===null?!1:yu.x>=0&&yu.y>=0&&yu.x+yu.y<=1}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,yu)===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,yu.x),c.addScaledVector(o,yu.y),c.addScaledVector(l,yu.z),c)}static getInterpolatedAttribute(e,n,r,i,s,o){return mM.setScalar(0),fM.setScalar(0),pM.setScalar(0),mM.fromBufferAttribute(e,n),fM.fromBufferAttribute(e,r),pM.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(mM,s.x),o.addScaledVector(fM,s.y),o.addScaledVector(pM,s.z),o}static isFrontFacing(e,n,r,i){return zl.subVectors(r,n),xu.subVectors(e,n),zl.cross(xu).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 zl.subVectors(this.c,this.b),xu.subVectors(this.a,this.b),zl.cross(xu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ug.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Ug.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return Ug.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Ug.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ug.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;rg.subVectors(i,r),ag.subVectors(s,r),uM.subVectors(e,r);const c=rg.dot(uM),u=ag.dot(uM);if(c<=0&&u<=0)return n.copy(r);dM.subVectors(e,i);const d=rg.dot(dM),h=ag.dot(dM);if(d>=0&&h<=d)return n.copy(i);const f=c*h-d*u;if(f<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(rg,o);hM.subVectors(e,s);const p=rg.dot(hM),x=ag.dot(hM);if(x>=0&&p<=x)return n.copy(s);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(ag,l);const g=d*x-p*h;if(g<=0&&h-d>=0&&p-x>=0)return S8.subVectors(s,i),l=(h-d)/(h-d+(p-x)),n.copy(i).addScaledVector(S8,l);const y=1/(g+v+f);return o=v*y,l=f*y,n.copy(r).addScaledVector(rg,o).addScaledVector(ag,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const vX={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},Yd={h:0,s:0,l:0},vS={h:0,s:0,l:0};function gM(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 Yn=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=Ao){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,br.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=br.workingColorSpace){return this.r=e,this.g=n,this.b=r,br.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=br.workingColorSpace){if(e=Gbe(e,1),n=rr(n,0,1),r=rr(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=gM(o,s,e+1/3),this.g=gM(o,s,e),this.b=gM(o,s,e-1/3)}return br.colorSpaceToWorking(this,i),this}setStyle(e,n=Ao){function r(s){s!==void 0&&parseFloat(s)<1&&Cn("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:Cn("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);Cn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Ao){const r=vX[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Cn("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=Ku(e.r),this.g=Ku(e.g),this.b=Ku(e.b),this}copyLinearToSRGB(e){return this.r=sb(e.r),this.g=sb(e.g),this.b=sb(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ao){return br.workingToColorSpace(cs.copy(this),e),Math.round(rr(cs.r*255,0,255))*65536+Math.round(rr(cs.g*255,0,255))*256+Math.round(rr(cs.b*255,0,255))}getHexString(e=Ao){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=br.workingColorSpace){br.workingToColorSpace(cs.copy(this),n);const r=cs.r,i=cs.g,s=cs.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=br.workingColorSpace){return br.workingToColorSpace(cs.copy(this),n),e.r=cs.r,e.g=cs.g,e.b=cs.b,e}getStyle(e=Ao){br.workingToColorSpace(cs.copy(this),e);const n=cs.r,r=cs.g,i=cs.b;return e!==Ao?`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(Yd),this.setHSL(Yd.h+e,Yd.s+n,Yd.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(Yd),e.getHSL(vS);const r=Z2(Yd.h,vS.h,n),i=Z2(Yd.s,vS.s,n),s=Z2(Yd.l,vS.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 cs=new Yn;Yn.NAMES=vX;let oxe=0,nx=class extends cp{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:oxe++}),this.uuid=Sv(),this.name="",this.type="Material",this.blending=ib,this.side=Qh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=N3,this.blendDst=k3,this.blendEquation=Qm,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Yn(0,0,0),this.blendAlpha=0,this.depthFunc=Sb,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=o8,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yp,this.stencilZFail=Yp,this.stencilZPass=Yp,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){Cn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Cn(`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!==ib&&(r.blending=this.blending),this.side!==Qh&&(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!==N3&&(r.blendSrc=this.blendSrc),this.blendDst!==k3&&(r.blendDst=this.blendDst),this.blendEquation!==Qm&&(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!==Sb&&(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!==o8&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Yp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Yp&&(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++}},a4=class extends nx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Yn(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 Zh,this.combine=KF,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 Ja=new xt,wS=new qn;let lxe=0,Ls=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:lxe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=l8,this.updateRanges=[],this.gpuType=Bu,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)wS.fromBufferAttribute(this,n),wS.applyMatrix3(e),this.setXY(n,wS.x,wS.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Ja.fromBufferAttribute(this,n),Ja.applyMatrix3(e),this.setXYZ(n,Ja.x,Ja.y,Ja.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Ja.fromBufferAttribute(this,n),Ja.applyMatrix4(e),this.setXYZ(n,Ja.x,Ja.y,Ja.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Ja.fromBufferAttribute(this,n),Ja.applyNormalMatrix(e),this.setXYZ(n,Ja.x,Ja.y,Ja.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Ja.fromBufferAttribute(this,n),Ja.transformDirection(e),this.setXYZ(n,Ja.x,Ja.y,Ja.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=cy(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Xs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=cy(n,this.array)),n}setX(e,n){return this.normalized&&(n=Xs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=cy(n,this.array)),n}setY(e,n){return this.normalized&&(n=Xs(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=cy(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Xs(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=cy(n,this.array)),n}setW(e,n){return this.normalized&&(n=Xs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Xs(n,this.array),r=Xs(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=Xs(n,this.array),r=Xs(r,this.array),i=Xs(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=Xs(n,this.array),r=Xs(r,this.array),i=Xs(i,this.array),s=Xs(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!==l8&&(e.usage=this.usage),e}},wX=class extends Ls{constructor(e,n,r){super(new Uint16Array(e),n,r)}},SX=class extends Ls{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Do=class extends Ls{constructor(e,n,r){super(new Float32Array(e),n,r)}},cxe=0;const Xo=new oi,bM=new Oo,ig=new xt,No=new Uh,fy=new Uh,Ai=new xt;let Nl=class _X extends cp{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:cxe++}),this.uuid=Sv(),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(hX(e)?SX:wX)(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 Kn().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 Xo.makeRotationFromQuaternion(e),this.applyMatrix4(Xo),this}rotateX(e){return Xo.makeRotationX(e),this.applyMatrix4(Xo),this}rotateY(e){return Xo.makeRotationY(e),this.applyMatrix4(Xo),this}rotateZ(e){return Xo.makeRotationZ(e),this.applyMatrix4(Xo),this}translate(e,n,r){return Xo.makeTranslation(e,n,r),this.applyMatrix4(Xo),this}scale(e,n,r){return Xo.makeScale(e,n,r),this.applyMatrix4(Xo),this}lookAt(e){return bM.lookAt(e),bM.updateMatrix(),this.applyMatrix4(bM.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ig).negate(),this.translate(ig.x,ig.y,ig.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 Do(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&&Cn("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 Uh);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Va("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new xt(-1/0,-1/0,-1/0),new xt(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];No.setFromBufferAttribute(s),this.morphTargetsRelative?(Ai.addVectors(this.boundingBox.min,No.min),this.boundingBox.expandByPoint(Ai),Ai.addVectors(this.boundingBox.max,No.max),this.boundingBox.expandByPoint(Ai)):(this.boundingBox.expandByPoint(No.min),this.boundingBox.expandByPoint(No.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Va('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hC);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Va("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new xt,1/0);return}if(e){const r=this.boundingSphere.center;if(No.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];fy.setFromBufferAttribute(l),this.morphTargetsRelative?(Ai.addVectors(No.min,fy.min),No.expandByPoint(Ai),Ai.addVectors(No.max,fy.max),No.expandByPoint(Ai)):(No.expandByPoint(fy.min),No.expandByPoint(fy.max))}No.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)Ai.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ai));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++)Ai.fromBufferAttribute(l,u),c&&(ig.fromBufferAttribute(e,u),Ai.add(ig)),i=Math.max(i,r.distanceToSquared(Ai))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Va('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){Va("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 Ls(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let R=0;R<r.count;R++)l[R]=new xt,c[R]=new xt;const u=new xt,d=new xt,h=new xt,f=new qn,p=new qn,x=new qn,v=new xt,g=new xt;function y(R,M,D){u.fromBufferAttribute(r,R),d.fromBufferAttribute(r,M),h.fromBufferAttribute(r,D),f.fromBufferAttribute(s,R),p.fromBufferAttribute(s,M),x.fromBufferAttribute(s,D),d.sub(u),h.sub(u),p.sub(f),x.sub(f);const G=1/(p.x*x.y-x.x*p.y);isFinite(G)&&(v.copy(d).multiplyScalar(x.y).addScaledVector(h,-p.y).multiplyScalar(G),g.copy(h).multiplyScalar(p.x).addScaledVector(d,-x.x).multiplyScalar(G),l[R].add(v),l[M].add(v),l[D].add(v),c[R].add(g),c[M].add(g),c[D].add(g))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let R=0,M=_.length;R<M;++R){const D=_[R],G=D.start,U=D.count;for(let W=G,L=G+U;W<L;W+=3)y(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const N=new xt,A=new xt,C=new xt,j=new xt;function k(R){C.fromBufferAttribute(i,R),j.copy(C);const M=l[R];N.copy(M),N.sub(C.multiplyScalar(C.dot(M))).normalize(),A.crossVectors(j,M);const G=A.dot(c[R])<0?-1:1;o.setXYZW(R,N.x,N.y,N.z,G)}for(let R=0,M=_.length;R<M;++R){const D=_[R],G=D.start,U=D.count;for(let W=G,L=G+U;W<L;W+=3)k(e.getX(W+0)),k(e.getX(W+1)),k(e.getX(W+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Ls(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let f=0,p=r.count;f<p;f++)r.setXYZ(f,0,0,0);const i=new xt,s=new xt,o=new xt,l=new xt,c=new xt,u=new xt,d=new xt,h=new xt;if(e)for(let f=0,p=e.count;f<p;f+=3){const x=e.getX(f+0),v=e.getX(f+1),g=e.getX(f+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,v),o.fromBufferAttribute(n,g),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,g),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(g,u.x,u.y,u.z)}else for(let f=0,p=n.count;f<p;f+=3)i.fromBufferAttribute(n,f+0),s.fromBufferAttribute(n,f+1),o.fromBufferAttribute(n,f+2),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),r.setXYZ(f+0,d.x,d.y,d.z),r.setXYZ(f+1,d.x,d.y,d.z),r.setXYZ(f+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ai.fromBufferAttribute(e,n),Ai.normalize(),e.setXYZ(n,Ai.x,Ai.y,Ai.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,h=l.normalized,f=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,g=c.length;v<g;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let y=0;y<d;y++)f[x++]=u[p++]}return new Ls(f,d,h)}if(this.index===null)return Cn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new _X,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 f=u[d],p=e(f,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let h=0,f=u.length;h<f;h++){const p=u[h];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],h=s[u];for(let f=0,p=h.length;f<p;f++)d.push(h[f].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 _8=new oi,Dm=new r4,SS=new hC,N8=new xt,_S=new xt,NS=new xt,kS=new xt,xM=new xt,CS=new xt,k8=new xt,AS=new xt;let kl=class extends Oo{constructor(e=new Nl,n=new a4){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){CS.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],h=s[c];d!==0&&(xM.fromBufferAttribute(h,e),o?CS.addScaledVector(xM,d):CS.addScaledVector(xM.sub(n),d))}n.add(CS)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),SS.copy(r.boundingSphere),SS.applyMatrix4(s),Dm.copy(e.ray).recast(e.near),!(SS.containsPoint(Dm.origin)===!1&&(Dm.intersectSphere(SS,N8)===null||Dm.origin.distanceToSquared(N8)>(e.far-e.near)**2))&&(_8.copy(s).invert(),Dm.copy(e.ray).applyMatrix4(_8),!(r.boundingBox!==null&&Dm.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Dm)))}_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,f=s.groups,p=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,v=f.length;x<v;x++){const g=f[x],y=o[g.materialIndex],_=Math.max(g.start,p.start),N=Math.min(l.count,Math.min(g.start+g.count,p.start+p.count));for(let A=_,C=N;A<C;A+=3){const j=l.getX(A),k=l.getX(A+1),R=l.getX(A+2);i=TS(this,y,e,r,u,d,h,j,k,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=g.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let g=x,y=v;g<y;g+=3){const _=l.getX(g),N=l.getX(g+1),A=l.getX(g+2);i=TS(this,o,e,r,u,d,h,_,N,A),i&&(i.faceIndex=Math.floor(g/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,v=f.length;x<v;x++){const g=f[x],y=o[g.materialIndex],_=Math.max(g.start,p.start),N=Math.min(c.count,Math.min(g.start+g.count,p.start+p.count));for(let A=_,C=N;A<C;A+=3){const j=A,k=A+1,R=A+2;i=TS(this,y,e,r,u,d,h,j,k,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=g.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let g=x,y=v;g<y;g+=3){const _=g,N=g+1,A=g+2;i=TS(this,o,e,r,u,d,h,_,N,A),i&&(i.faceIndex=Math.floor(g/3),n.push(i))}}}};function uxe(t,e,n,r,i,s,o,l){let c;if(e.side===ao?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===Qh,l),c===null)return null;AS.copy(l),AS.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(AS);return u<n.near||u>n.far?null:{distance:u,point:AS.clone(),object:t}}function TS(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,_S),t.getVertexPosition(c,NS),t.getVertexPosition(u,kS);const d=uxe(t,e,n,r,_S,NS,kS,k8);if(d){const h=new xt;my.getBarycoord(k8,_S,NS,kS,h),i&&(d.uv=my.getInterpolatedAttribute(i,l,c,u,h,new qn)),s&&(d.uv1=my.getInterpolatedAttribute(s,l,c,u,h,new qn)),o&&(d.normal=my.getInterpolatedAttribute(o,l,c,u,h,new xt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new xt,materialIndex:0};my.getNormal(_S,NS,kS,f.normal),d.face=f,d.barycoord=h}return d}let i4=class NX extends Nl{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 f=0,p=0;x("z","y","x",-1,-1,r,n,e,o,s,0),x("z","y","x",1,-1,r,n,-e,o,s,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new Do(u,3)),this.setAttribute("normal",new Do(d,3)),this.setAttribute("uv",new Do(h,2));function x(v,g,y,_,N,A,C,j,k,R,M){const D=A/k,G=C/R,U=A/2,W=C/2,L=j/2,ee=k+1,ae=R+1;let Y=0,se=0;const ce=new xt;for(let ye=0;ye<ae;ye++){const Z=ye*G-W;for(let ue=0;ue<ee;ue++){const pe=ue*D-U;ce[v]=pe*_,ce[g]=Z*N,ce[y]=L,u.push(ce.x,ce.y,ce.z),ce[v]=0,ce[g]=0,ce[y]=j>0?1:-1,d.push(ce.x,ce.y,ce.z),h.push(ue/k),h.push(1-ye/R),Y+=1}}for(let ye=0;ye<R;ye++)for(let Z=0;Z<k;Z++){const ue=f+Z+ee*ye,pe=f+Z+ee*(ye+1),be=f+(Z+1)+ee*(ye+1),Ee=f+(Z+1)+ee*ye;c.push(ue,pe,Ee),c.push(pe,be,Ee),se+=6}l.addGroup(p,se,M),p+=se,f+=Y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new NX(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Cb(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?(Cn("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 Ts(t){const e={};for(let n=0;n<t.length;n++){const r=Cb(t[n]);for(const i in r)e[i]=r[i]}return e}function dxe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function kX(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:br.workingColorSpace}const hxe={clone:Cb,merge:Ts};var mxe=`void main() {
  11. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  12. }`,fxe=`void main() {
  13. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  14. }`;let od=class extends nx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=mxe,this.fragmentShader=fxe,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=Cb(e.uniforms),this.uniformsGroups=dxe(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}},CX=class extends Oo{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new oi,this.projectionMatrix=new oi,this.projectionMatrixInverse=new oi,this.coordinateSystem=Tc,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 Xd=new xt,C8=new qn,A8=new qn;let cl=class extends CX{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=dD*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(r1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return dD*2*Math.atan(Math.tan(r1*.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){Xd.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Xd.x,Xd.y).multiplyScalar(-e/Xd.z),Xd.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Xd.x,Xd.y).multiplyScalar(-e/Xd.z)}getViewSize(e,n){return this.getViewBounds(e,C8,A8),n.subVectors(A8,C8)}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(r1*.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 sg=-90,og=1;let pxe=class extends Oo{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new cl(sg,og,e,n);i.layers=this.layers,this.add(i);const s=new cl(sg,og,e,n);s.layers=this.layers,this.add(s);const o=new cl(sg,og,e,n);o.layers=this.layers,this.add(o);const l=new cl(sg,og,e,n);l.layers=this.layers,this.add(l);const c=new cl(sg,og,e,n);c.layers=this.layers,this.add(c);const u=new cl(sg,og,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===Tc)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===I1)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(),f=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,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=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(h,f,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},AX=class extends sc{constructor(e=[],n=_b,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}},gxe=class extends $f{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 AX(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
  15. varying vec3 vWorldDirection;
  16. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  17. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  18. }
  19. void main() {
  20. vWorldDirection = transformDirection( position, modelMatrix );
  21. #include <begin_vertex>
  22. #include <project_vertex>
  23. }
  24. `,fragmentShader:`
  25. uniform sampler2D tEquirect;
  26. varying vec3 vWorldDirection;
  27. #include <common>
  28. void main() {
  29. vec3 direction = normalize( vWorldDirection );
  30. vec2 sampleUV = equirectUv( direction );
  31. gl_FragColor = texture2D( tEquirect, sampleUV );
  32. }
  33. `},i=new i4(5,5,5),s=new od({name:"CubemapFromEquirect",uniforms:Cb(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ao,blending:Wu});s.uniforms.tEquirect.value=n;const o=new kl(i,s),l=n.minFilter;return n.minFilter===sf&&(n.minFilter=pl),new pxe(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)}},Kg=class extends Oo{constructor(){super(),this.isGroup=!0,this.type="Group"}};const bxe={type:"move"};let yM=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Kg,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 Kg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new xt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new xt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Kg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new xt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new xt),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 v of e.hand.values()){const g=n.getJointPose(v,r),y=this._getHandJoint(u,v);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=g.radius),y.visible=g!==null}const d=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],f=d.position.distanceTo(h.position),p=.02,x=.005;u.inputState.pinching&&f>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&f<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(bxe)))}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 Kg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},xxe=class extends Oo{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 Zh,this.environmentIntensity=1,this.environmentRotation=new Zh,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}},yxe=class extends sc{constructor(e=null,n=1,r=1,i,s,o,l,c,u=Eo,d=Eo,h,f){super(null,o,l,c,u,d,i,s,h,f),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const vM=new xt,vxe=new xt,wxe=new Kn;let lh=class{constructor(e=new xt(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=vM.subVectors(r,n).cross(vxe.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(vM),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||wxe.getNormalMatrix(e),i=this.coplanarPoint(vM).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 Rm=new hC,Sxe=new qn(.5,.5),MS=new xt;let s4=class{constructor(e=new lh,n=new lh,r=new lh,i=new lh,s=new lh,o=new lh){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=Tc,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],f=s[6],p=s[7],x=s[8],v=s[9],g=s[10],y=s[11],_=s[12],N=s[13],A=s[14],C=s[15];if(i[0].setComponents(u-o,p-d,y-x,C-_).normalize(),i[1].setComponents(u+o,p+d,y+x,C+_).normalize(),i[2].setComponents(u+l,p+h,y+v,C+N).normalize(),i[3].setComponents(u-l,p-h,y-v,C-N).normalize(),r)i[4].setComponents(c,f,g,A).normalize(),i[5].setComponents(u-c,p-f,y-g,C-A).normalize();else if(i[4].setComponents(u-c,p-f,y-g,C-A).normalize(),n===Tc)i[5].setComponents(u+c,p+f,y+g,C+A).normalize();else if(n===I1)i[5].setComponents(c,f,g,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Rm.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Rm.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Rm)}intersectsSprite(e){Rm.center.set(0,0,0);const n=Sxe.distanceTo(e.center);return Rm.radius=.7071067811865476+n,Rm.applyMatrix4(e.matrixWorld),this.intersectsSphere(Rm)}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(MS.x=i.normal.x>0?e.max.x:e.min.x,MS.y=i.normal.y>0?e.max.y:e.min.y,MS.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(MS)<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)}},TX=class extends nx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Yn(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 U1=new xt,B1=new xt,T8=new oi,py=new r4,PS=new hC,wM=new xt,M8=new xt;let _xe=class extends Oo{constructor(e=new Nl,n=new TX){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++)U1.fromBufferAttribute(n,i-1),B1.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=U1.distanceTo(B1);e.setAttribute("lineDistance",new Do(r,1))}else Cn("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(),PS.copy(r.boundingSphere),PS.applyMatrix4(i),PS.radius+=s,e.ray.intersectsSphere(PS)===!1)return;T8.copy(i).invert(),py.copy(e.ray).applyMatrix4(T8);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,f=r.attributes.position;if(d!==null){const p=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let v=p,g=x-1;v<g;v+=u){const y=d.getX(v),_=d.getX(v+1),N=jS(this,e,py,c,y,_,v);N&&n.push(N)}if(this.isLineLoop){const v=d.getX(x-1),g=d.getX(p),y=jS(this,e,py,c,v,g,x-1);y&&n.push(y)}}else{const p=Math.max(0,o.start),x=Math.min(f.count,o.start+o.count);for(let v=p,g=x-1;v<g;v+=u){const y=jS(this,e,py,c,v,v+1,v);y&&n.push(y)}if(this.isLineLoop){const v=jS(this,e,py,c,x-1,p,x-1);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}};function jS(t,e,n,r,i,s,o){const l=t.geometry.attributes.position;if(U1.fromBufferAttribute(l,i),B1.fromBufferAttribute(l,s),n.distanceSqToSegment(U1,B1,wM,M8)>r)return;wM.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(wM);if(!(u<e.near||u>e.far))return{distance:u,point:M8.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const P8=new xt,j8=new xt;let Nxe=class extends _xe{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)P8.fromBufferAttribute(n,i),j8.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+P8.distanceTo(j8);e.setAttribute("lineDistance",new Do(r,1))}else Cn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},MX=class extends sc{constructor(e,n,r=Bf,i,s,o,l=Eo,c=Eo,u,d=P0,h=1){if(d!==P0&&d!==j0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const f={width:e,height:n,depth:h};super(f,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 n4(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 PX extends sc{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let o4=class jX extends Nl{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,f=n/c,p=[],x=[],v=[],g=[];for(let y=0;y<d;y++){const _=y*f-o;for(let N=0;N<u;N++){const A=N*h-s;x.push(A,-_,0),v.push(0,0,1),g.push(N/l),g.push(1-y/c)}}for(let y=0;y<c;y++)for(let _=0;_<l;_++){const N=_+u*y,A=_+u*(y+1),C=_+1+u*(y+1),j=_+1+u*y;p.push(N,A,j),p.push(A,C,j)}this.setIndex(p),this.setAttribute("position",new Do(x,3)),this.setAttribute("normal",new Do(v,3)),this.setAttribute("uv",new Do(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new jX(e.width,e.height,e.widthSegments,e.heightSegments)}};class EX extends nx{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Yn(16777215),this.specular=new Yn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=uX,this.normalScale=new qn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zh,this.combine=KF,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 kxe=class extends nx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Rbe,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}},Cxe=class extends nx{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 E8={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 Axe{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,f=u.length;h<f;h+=2){const p=u[h],x=u[h+1];if(p.global&&(p.lastIndex=0),p.test(d))return x}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const Txe=new Axe;class l4{constructor(e){this.manager=e!==void 0?e:Txe,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}}l4.DEFAULT_MATERIAL_NAME="__DEFAULT";const vu={};class Mxe extends Error{constructor(e,n){super(e),this.response=n}}class Pxe extends l4{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=E8.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{n&&n(s),this.manager.itemEnd(e)},0),s;if(vu[e]!==void 0){vu[e].push({onLoad:n,onProgress:r,onError:i});return}vu[e]=[],vu[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&&Cn("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;const d=vu[e],h=u.body.getReader(),f=u.headers.get("X-File-Size")||u.headers.get("Content-Length"),p=f?parseInt(f):0,x=p!==0;let v=0;const g=new ReadableStream({start(y){_();function _(){h.read().then(({done:N,value:A})=>{if(N)y.close();else{v+=A.byteLength;const C=new ProgressEvent("progress",{lengthComputable:x,loaded:v,total:p});for(let j=0,k=d.length;j<k;j++){const R=d[j];R.onProgress&&R.onProgress(C)}y.enqueue(A),_()}},N=>{y.error(N)})}}});return new Response(g)}else throw new Mxe(`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),f=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(f);return u.arrayBuffer().then(x=>p.decode(x))}}}).then(u=>{E8.add(`file:${e}`,u);const d=vu[e];delete vu[e];for(let h=0,f=d.length;h<f;h++){const p=d[h];p.onLoad&&p.onLoad(u)}}).catch(u=>{const d=vu[e];if(d===void 0)throw this.manager.itemError(e),u;delete vu[e];for(let h=0,f=d.length;h<f;h++){const p=d[h];p.onError&&p.onError(u)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let DX=class extends Oo{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Yn(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 SM=new oi,D8=new xt,R8=new xt;let jxe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new qn(512,512),this.mapType=zc,this.map=null,this.mapPass=null,this.matrix=new oi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new s4,this._frameExtents=new qn(1,1),this._viewportCount=1,this._viewports=[new ti(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;D8.setFromMatrixPosition(e.matrixWorld),n.position.copy(D8),R8.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(R8),n.updateMatrixWorld(),SM.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(SM,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(SM)}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}},RX=class extends CX{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 Exe extends jxe{constructor(){super(new RX(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class F8 extends DX{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Oo.DEFAULT_UP),this.updateMatrix(),this.target=new Oo,this.shadow=new Exe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Dxe=class extends DX{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},Rxe=class extends cl{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},L8=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=rr(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(rr(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class Fxe extends Nxe{constructor(e=10,n=10,r=4473924,i=8947848){r=new Yn(r),i=new Yn(i);const s=n/2,o=e/n,l=e/2,c=[],u=[];for(let f=0,p=0,x=-l;f<=n;f++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const v=f===s?r:i;v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3}const d=new Nl;d.setAttribute("position",new Do(c,3)),d.setAttribute("color",new Do(u,3));const h=new TX({vertexColors:!0,toneMapped:!1});super(d,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Lxe extends cp{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){Cn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function O8(t,e,n,r){const i=Oxe(r);switch(n){case oX:return t*e;case cX:return t*e/i.components*i.byteLength;case ZF:return t*e/i.components*i.byteLength;case JF:return t*e*2/i.components*i.byteLength;case e4:return t*e*2/i.components*i.byteLength;case lX:return t*e*3/i.components*i.byteLength;case Yl:return t*e*4/i.components*i.byteLength;case t4:return t*e*4/i.components*i.byteLength;case J_:case e1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case t1:case n1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case I3:case U3:return Math.max(t,16)*Math.max(e,8)/4;case O3:case z3:return Math.max(t,8)*Math.max(e,8)/2;case B3:case H3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case $3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case V3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case q3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case G3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case W3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case K3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case Y3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case X3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case Q3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case Z3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case J3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case eD:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case tD:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case nD:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case rD:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case aD:case iD:case sD:return Math.ceil(t/4)*Math.ceil(e/4)*16;case oD:case lD:return Math.ceil(t/4)*Math.ceil(e/4)*8;case cD:case uD:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Oxe(t){switch(t){case zc:case rX:return{byteLength:1,components:1};case T0:case aX:case tx:return{byteLength:2,components:1};case XF:case QF:return{byteLength:2,components:4};case Bf:case YF:case Bu:return{byteLength:4,components:1};case iX:case sX:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:WF}}));typeof window<"u"&&(window.__THREE__?Cn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=WF);function FX(){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 Ixe(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,h=u.byteLength,f=t.createBuffer();t.bindBuffer(c,f),t.bufferData(c,u,d),l.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:f,type:p,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((p,x)=>p.start-x.start);let f=0;for(let p=1;p<h.length;p++){const x=h[f],v=h[p];v.start<=x.start+x.count+1?x.count=Math.max(x.count,v.start+v.count-x.start):(++f,h[f]=v)}h.length=f+1;for(let p=0,x=h.length;p<x;p++){const v=h[p];t.bufferSubData(u,v.start*d.BYTES_PER_ELEMENT,d,v.start,v.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 zxe=`#ifdef USE_ALPHAHASH
  34. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  35. #endif`,Uxe=`#ifdef USE_ALPHAHASH
  36. const float ALPHA_HASH_SCALE = 0.05;
  37. float hash2D( vec2 value ) {
  38. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  39. }
  40. float hash3D( vec3 value ) {
  41. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  42. }
  43. float getAlphaHashThreshold( vec3 position ) {
  44. float maxDeriv = max(
  45. length( dFdx( position.xyz ) ),
  46. length( dFdy( position.xyz ) )
  47. );
  48. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  49. vec2 pixScales = vec2(
  50. exp2( floor( log2( pixScale ) ) ),
  51. exp2( ceil( log2( pixScale ) ) )
  52. );
  53. vec2 alpha = vec2(
  54. hash3D( floor( pixScales.x * position.xyz ) ),
  55. hash3D( floor( pixScales.y * position.xyz ) )
  56. );
  57. float lerpFactor = fract( log2( pixScale ) );
  58. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  59. float a = min( lerpFactor, 1.0 - lerpFactor );
  60. vec3 cases = vec3(
  61. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  62. ( x - 0.5 * a ) / ( 1.0 - a ),
  63. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  64. );
  65. float threshold = ( x < ( 1.0 - a ) )
  66. ? ( ( x < a ) ? cases.x : cases.y )
  67. : cases.z;
  68. return clamp( threshold , 1.0e-6, 1.0 );
  69. }
  70. #endif`,Bxe=`#ifdef USE_ALPHAMAP
  71. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  72. #endif`,Hxe=`#ifdef USE_ALPHAMAP
  73. uniform sampler2D alphaMap;
  74. #endif`,$xe=`#ifdef USE_ALPHATEST
  75. #ifdef ALPHA_TO_COVERAGE
  76. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  77. if ( diffuseColor.a == 0.0 ) discard;
  78. #else
  79. if ( diffuseColor.a < alphaTest ) discard;
  80. #endif
  81. #endif`,Vxe=`#ifdef USE_ALPHATEST
  82. uniform float alphaTest;
  83. #endif`,qxe=`#ifdef USE_AOMAP
  84. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  85. reflectedLight.indirectDiffuse *= ambientOcclusion;
  86. #if defined( USE_CLEARCOAT )
  87. clearcoatSpecularIndirect *= ambientOcclusion;
  88. #endif
  89. #if defined( USE_SHEEN )
  90. sheenSpecularIndirect *= ambientOcclusion;
  91. #endif
  92. #if defined( USE_ENVMAP ) && defined( STANDARD )
  93. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  94. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  95. #endif
  96. #endif`,Gxe=`#ifdef USE_AOMAP
  97. uniform sampler2D aoMap;
  98. uniform float aoMapIntensity;
  99. #endif`,Wxe=`#ifdef USE_BATCHING
  100. #if ! defined( GL_ANGLE_multi_draw )
  101. #define gl_DrawID _gl_DrawID
  102. uniform int _gl_DrawID;
  103. #endif
  104. uniform highp sampler2D batchingTexture;
  105. uniform highp usampler2D batchingIdTexture;
  106. mat4 getBatchingMatrix( const in float i ) {
  107. int size = textureSize( batchingTexture, 0 ).x;
  108. int j = int( i ) * 4;
  109. int x = j % size;
  110. int y = j / size;
  111. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  112. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  113. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  114. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  115. return mat4( v1, v2, v3, v4 );
  116. }
  117. float getIndirectIndex( const in int i ) {
  118. int size = textureSize( batchingIdTexture, 0 ).x;
  119. int x = i % size;
  120. int y = i / size;
  121. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  122. }
  123. #endif
  124. #ifdef USE_BATCHING_COLOR
  125. uniform sampler2D batchingColorTexture;
  126. vec3 getBatchingColor( const in float i ) {
  127. int size = textureSize( batchingColorTexture, 0 ).x;
  128. int j = int( i );
  129. int x = j % size;
  130. int y = j / size;
  131. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  132. }
  133. #endif`,Kxe=`#ifdef USE_BATCHING
  134. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  135. #endif`,Yxe=`vec3 transformed = vec3( position );
  136. #ifdef USE_ALPHAHASH
  137. vPosition = vec3( position );
  138. #endif`,Xxe=`vec3 objectNormal = vec3( normal );
  139. #ifdef USE_TANGENT
  140. vec3 objectTangent = vec3( tangent.xyz );
  141. #endif`,Qxe=`float G_BlinnPhong_Implicit( ) {
  142. return 0.25;
  143. }
  144. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  145. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  146. }
  147. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  148. vec3 halfDir = normalize( lightDir + viewDir );
  149. float dotNH = saturate( dot( normal, halfDir ) );
  150. float dotVH = saturate( dot( viewDir, halfDir ) );
  151. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  152. float G = G_BlinnPhong_Implicit( );
  153. float D = D_BlinnPhong( shininess, dotNH );
  154. return F * ( G * D );
  155. } // validated`,Zxe=`#ifdef USE_IRIDESCENCE
  156. const mat3 XYZ_TO_REC709 = mat3(
  157. 3.2404542, -0.9692660, 0.0556434,
  158. -1.5371385, 1.8760108, -0.2040259,
  159. -0.4985314, 0.0415560, 1.0572252
  160. );
  161. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  162. vec3 sqrtF0 = sqrt( fresnel0 );
  163. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  164. }
  165. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  166. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  167. }
  168. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  169. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  170. }
  171. vec3 evalSensitivity( float OPD, vec3 shift ) {
  172. float phase = 2.0 * PI * OPD * 1.0e-9;
  173. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  174. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  175. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  176. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  177. xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
  178. xyz /= 1.0685e-7;
  179. vec3 rgb = XYZ_TO_REC709 * xyz;
  180. return rgb;
  181. }
  182. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  183. vec3 I;
  184. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  185. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  186. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  187. if ( cosTheta2Sq < 0.0 ) {
  188. return vec3( 1.0 );
  189. }
  190. float cosTheta2 = sqrt( cosTheta2Sq );
  191. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  192. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  193. float T121 = 1.0 - R12;
  194. float phi12 = 0.0;
  195. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  196. float phi21 = PI - phi12;
  197. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  198. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  199. vec3 phi23 = vec3( 0.0 );
  200. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  201. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  202. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  203. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  204. vec3 phi = vec3( phi21 ) + phi23;
  205. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  206. vec3 r123 = sqrt( R123 );
  207. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  208. vec3 C0 = R12 + Rs;
  209. I = C0;
  210. vec3 Cm = Rs - T121;
  211. for ( int m = 1; m <= 2; ++ m ) {
  212. Cm *= r123;
  213. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  214. I += Cm * Sm;
  215. }
  216. return max( I, vec3( 0.0 ) );
  217. }
  218. #endif`,Jxe=`#ifdef USE_BUMPMAP
  219. uniform sampler2D bumpMap;
  220. uniform float bumpScale;
  221. vec2 dHdxy_fwd() {
  222. vec2 dSTdx = dFdx( vBumpMapUv );
  223. vec2 dSTdy = dFdy( vBumpMapUv );
  224. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  225. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  226. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  227. return vec2( dBx, dBy );
  228. }
  229. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  230. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  231. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  232. vec3 vN = surf_norm;
  233. vec3 R1 = cross( vSigmaY, vN );
  234. vec3 R2 = cross( vN, vSigmaX );
  235. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  236. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  237. return normalize( abs( fDet ) * surf_norm - vGrad );
  238. }
  239. #endif`,eye=`#if NUM_CLIPPING_PLANES > 0
  240. vec4 plane;
  241. #ifdef ALPHA_TO_COVERAGE
  242. float distanceToPlane, distanceGradient;
  243. float clipOpacity = 1.0;
  244. #pragma unroll_loop_start
  245. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  246. plane = clippingPlanes[ i ];
  247. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  248. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  249. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  250. if ( clipOpacity == 0.0 ) discard;
  251. }
  252. #pragma unroll_loop_end
  253. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  254. float unionClipOpacity = 1.0;
  255. #pragma unroll_loop_start
  256. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  257. plane = clippingPlanes[ i ];
  258. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  259. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  260. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  261. }
  262. #pragma unroll_loop_end
  263. clipOpacity *= 1.0 - unionClipOpacity;
  264. #endif
  265. diffuseColor.a *= clipOpacity;
  266. if ( diffuseColor.a == 0.0 ) discard;
  267. #else
  268. #pragma unroll_loop_start
  269. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  270. plane = clippingPlanes[ i ];
  271. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  272. }
  273. #pragma unroll_loop_end
  274. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  275. bool clipped = true;
  276. #pragma unroll_loop_start
  277. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  278. plane = clippingPlanes[ i ];
  279. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  280. }
  281. #pragma unroll_loop_end
  282. if ( clipped ) discard;
  283. #endif
  284. #endif
  285. #endif`,tye=`#if NUM_CLIPPING_PLANES > 0
  286. varying vec3 vClipPosition;
  287. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  288. #endif`,nye=`#if NUM_CLIPPING_PLANES > 0
  289. varying vec3 vClipPosition;
  290. #endif`,rye=`#if NUM_CLIPPING_PLANES > 0
  291. vClipPosition = - mvPosition.xyz;
  292. #endif`,aye=`#if defined( USE_COLOR_ALPHA )
  293. diffuseColor *= vColor;
  294. #elif defined( USE_COLOR )
  295. diffuseColor.rgb *= vColor;
  296. #endif`,iye=`#if defined( USE_COLOR_ALPHA )
  297. varying vec4 vColor;
  298. #elif defined( USE_COLOR )
  299. varying vec3 vColor;
  300. #endif`,sye=`#if defined( USE_COLOR_ALPHA )
  301. varying vec4 vColor;
  302. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  303. varying vec3 vColor;
  304. #endif`,oye=`#if defined( USE_COLOR_ALPHA )
  305. vColor = vec4( 1.0 );
  306. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  307. vColor = vec3( 1.0 );
  308. #endif
  309. #ifdef USE_COLOR
  310. vColor *= color;
  311. #endif
  312. #ifdef USE_INSTANCING_COLOR
  313. vColor.xyz *= instanceColor.xyz;
  314. #endif
  315. #ifdef USE_BATCHING_COLOR
  316. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  317. vColor.xyz *= batchingColor.xyz;
  318. #endif`,lye=`#define PI 3.141592653589793
  319. #define PI2 6.283185307179586
  320. #define PI_HALF 1.5707963267948966
  321. #define RECIPROCAL_PI 0.3183098861837907
  322. #define RECIPROCAL_PI2 0.15915494309189535
  323. #define EPSILON 1e-6
  324. #ifndef saturate
  325. #define saturate( a ) clamp( a, 0.0, 1.0 )
  326. #endif
  327. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  328. float pow2( const in float x ) { return x*x; }
  329. vec3 pow2( const in vec3 x ) { return x*x; }
  330. float pow3( const in float x ) { return x*x*x; }
  331. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  332. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  333. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  334. highp float rand( const in vec2 uv ) {
  335. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  336. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  337. return fract( sin( sn ) * c );
  338. }
  339. #ifdef HIGH_PRECISION
  340. float precisionSafeLength( vec3 v ) { return length( v ); }
  341. #else
  342. float precisionSafeLength( vec3 v ) {
  343. float maxComponent = max3( abs( v ) );
  344. return length( v / maxComponent ) * maxComponent;
  345. }
  346. #endif
  347. struct IncidentLight {
  348. vec3 color;
  349. vec3 direction;
  350. bool visible;
  351. };
  352. struct ReflectedLight {
  353. vec3 directDiffuse;
  354. vec3 directSpecular;
  355. vec3 indirectDiffuse;
  356. vec3 indirectSpecular;
  357. };
  358. #ifdef USE_ALPHAHASH
  359. varying vec3 vPosition;
  360. #endif
  361. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  362. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  363. }
  364. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  365. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  366. }
  367. bool isPerspectiveMatrix( mat4 m ) {
  368. return m[ 2 ][ 3 ] == - 1.0;
  369. }
  370. vec2 equirectUv( in vec3 dir ) {
  371. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  372. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  373. return vec2( u, v );
  374. }
  375. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  376. return RECIPROCAL_PI * diffuseColor;
  377. }
  378. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  379. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  380. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  381. }
  382. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  383. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  384. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  385. } // validated`,cye=`#ifdef ENVMAP_TYPE_CUBE_UV
  386. #define cubeUV_minMipLevel 4.0
  387. #define cubeUV_minTileSize 16.0
  388. float getFace( vec3 direction ) {
  389. vec3 absDirection = abs( direction );
  390. float face = - 1.0;
  391. if ( absDirection.x > absDirection.z ) {
  392. if ( absDirection.x > absDirection.y )
  393. face = direction.x > 0.0 ? 0.0 : 3.0;
  394. else
  395. face = direction.y > 0.0 ? 1.0 : 4.0;
  396. } else {
  397. if ( absDirection.z > absDirection.y )
  398. face = direction.z > 0.0 ? 2.0 : 5.0;
  399. else
  400. face = direction.y > 0.0 ? 1.0 : 4.0;
  401. }
  402. return face;
  403. }
  404. vec2 getUV( vec3 direction, float face ) {
  405. vec2 uv;
  406. if ( face == 0.0 ) {
  407. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  408. } else if ( face == 1.0 ) {
  409. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  410. } else if ( face == 2.0 ) {
  411. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  412. } else if ( face == 3.0 ) {
  413. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  414. } else if ( face == 4.0 ) {
  415. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  416. } else {
  417. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  418. }
  419. return 0.5 * ( uv + 1.0 );
  420. }
  421. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  422. float face = getFace( direction );
  423. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  424. mipInt = max( mipInt, cubeUV_minMipLevel );
  425. float faceSize = exp2( mipInt );
  426. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  427. if ( face > 2.0 ) {
  428. uv.y += faceSize;
  429. face -= 3.0;
  430. }
  431. uv.x += face * faceSize;
  432. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  433. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  434. uv.x *= CUBEUV_TEXEL_WIDTH;
  435. uv.y *= CUBEUV_TEXEL_HEIGHT;
  436. #ifdef texture2DGradEXT
  437. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  438. #else
  439. return texture2D( envMap, uv ).rgb;
  440. #endif
  441. }
  442. #define cubeUV_r0 1.0
  443. #define cubeUV_m0 - 2.0
  444. #define cubeUV_r1 0.8
  445. #define cubeUV_m1 - 1.0
  446. #define cubeUV_r4 0.4
  447. #define cubeUV_m4 2.0
  448. #define cubeUV_r5 0.305
  449. #define cubeUV_m5 3.0
  450. #define cubeUV_r6 0.21
  451. #define cubeUV_m6 4.0
  452. float roughnessToMip( float roughness ) {
  453. float mip = 0.0;
  454. if ( roughness >= cubeUV_r1 ) {
  455. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  456. } else if ( roughness >= cubeUV_r4 ) {
  457. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  458. } else if ( roughness >= cubeUV_r5 ) {
  459. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  460. } else if ( roughness >= cubeUV_r6 ) {
  461. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  462. } else {
  463. mip = - 2.0 * log2( 1.16 * roughness ); }
  464. return mip;
  465. }
  466. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  467. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  468. float mipF = fract( mip );
  469. float mipInt = floor( mip );
  470. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  471. if ( mipF == 0.0 ) {
  472. return vec4( color0, 1.0 );
  473. } else {
  474. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  475. return vec4( mix( color0, color1, mipF ), 1.0 );
  476. }
  477. }
  478. #endif`,uye=`vec3 transformedNormal = objectNormal;
  479. #ifdef USE_TANGENT
  480. vec3 transformedTangent = objectTangent;
  481. #endif
  482. #ifdef USE_BATCHING
  483. mat3 bm = mat3( batchingMatrix );
  484. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  485. transformedNormal = bm * transformedNormal;
  486. #ifdef USE_TANGENT
  487. transformedTangent = bm * transformedTangent;
  488. #endif
  489. #endif
  490. #ifdef USE_INSTANCING
  491. mat3 im = mat3( instanceMatrix );
  492. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  493. transformedNormal = im * transformedNormal;
  494. #ifdef USE_TANGENT
  495. transformedTangent = im * transformedTangent;
  496. #endif
  497. #endif
  498. transformedNormal = normalMatrix * transformedNormal;
  499. #ifdef FLIP_SIDED
  500. transformedNormal = - transformedNormal;
  501. #endif
  502. #ifdef USE_TANGENT
  503. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  504. #ifdef FLIP_SIDED
  505. transformedTangent = - transformedTangent;
  506. #endif
  507. #endif`,dye=`#ifdef USE_DISPLACEMENTMAP
  508. uniform sampler2D displacementMap;
  509. uniform float displacementScale;
  510. uniform float displacementBias;
  511. #endif`,hye=`#ifdef USE_DISPLACEMENTMAP
  512. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  513. #endif`,mye=`#ifdef USE_EMISSIVEMAP
  514. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  515. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  516. emissiveColor = sRGBTransferEOTF( emissiveColor );
  517. #endif
  518. totalEmissiveRadiance *= emissiveColor.rgb;
  519. #endif`,fye=`#ifdef USE_EMISSIVEMAP
  520. uniform sampler2D emissiveMap;
  521. #endif`,pye="gl_FragColor = linearToOutputTexel( gl_FragColor );",gye=`vec4 LinearTransferOETF( in vec4 value ) {
  522. return value;
  523. }
  524. vec4 sRGBTransferEOTF( in vec4 value ) {
  525. return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
  526. }
  527. vec4 sRGBTransferOETF( in vec4 value ) {
  528. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  529. }`,bye=`#ifdef USE_ENVMAP
  530. #ifdef ENV_WORLDPOS
  531. vec3 cameraToFrag;
  532. if ( isOrthographic ) {
  533. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  534. } else {
  535. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  536. }
  537. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  538. #ifdef ENVMAP_MODE_REFLECTION
  539. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  540. #else
  541. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  542. #endif
  543. #else
  544. vec3 reflectVec = vReflect;
  545. #endif
  546. #ifdef ENVMAP_TYPE_CUBE
  547. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  548. #else
  549. vec4 envColor = vec4( 0.0 );
  550. #endif
  551. #ifdef ENVMAP_BLENDING_MULTIPLY
  552. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  553. #elif defined( ENVMAP_BLENDING_MIX )
  554. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  555. #elif defined( ENVMAP_BLENDING_ADD )
  556. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  557. #endif
  558. #endif`,xye=`#ifdef USE_ENVMAP
  559. uniform float envMapIntensity;
  560. uniform float flipEnvMap;
  561. uniform mat3 envMapRotation;
  562. #ifdef ENVMAP_TYPE_CUBE
  563. uniform samplerCube envMap;
  564. #else
  565. uniform sampler2D envMap;
  566. #endif
  567. #endif`,yye=`#ifdef USE_ENVMAP
  568. uniform float reflectivity;
  569. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  570. #define ENV_WORLDPOS
  571. #endif
  572. #ifdef ENV_WORLDPOS
  573. varying vec3 vWorldPosition;
  574. uniform float refractionRatio;
  575. #else
  576. varying vec3 vReflect;
  577. #endif
  578. #endif`,vye=`#ifdef USE_ENVMAP
  579. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  580. #define ENV_WORLDPOS
  581. #endif
  582. #ifdef ENV_WORLDPOS
  583. varying vec3 vWorldPosition;
  584. #else
  585. varying vec3 vReflect;
  586. uniform float refractionRatio;
  587. #endif
  588. #endif`,wye=`#ifdef USE_ENVMAP
  589. #ifdef ENV_WORLDPOS
  590. vWorldPosition = worldPosition.xyz;
  591. #else
  592. vec3 cameraToVertex;
  593. if ( isOrthographic ) {
  594. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  595. } else {
  596. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  597. }
  598. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  599. #ifdef ENVMAP_MODE_REFLECTION
  600. vReflect = reflect( cameraToVertex, worldNormal );
  601. #else
  602. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  603. #endif
  604. #endif
  605. #endif`,Sye=`#ifdef USE_FOG
  606. vFogDepth = - mvPosition.z;
  607. #endif`,_ye=`#ifdef USE_FOG
  608. varying float vFogDepth;
  609. #endif`,Nye=`#ifdef USE_FOG
  610. #ifdef FOG_EXP2
  611. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  612. #else
  613. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  614. #endif
  615. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  616. #endif`,kye=`#ifdef USE_FOG
  617. uniform vec3 fogColor;
  618. varying float vFogDepth;
  619. #ifdef FOG_EXP2
  620. uniform float fogDensity;
  621. #else
  622. uniform float fogNear;
  623. uniform float fogFar;
  624. #endif
  625. #endif`,Cye=`#ifdef USE_GRADIENTMAP
  626. uniform sampler2D gradientMap;
  627. #endif
  628. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  629. float dotNL = dot( normal, lightDirection );
  630. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  631. #ifdef USE_GRADIENTMAP
  632. return vec3( texture2D( gradientMap, coord ).r );
  633. #else
  634. vec2 fw = fwidth( coord ) * 0.5;
  635. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  636. #endif
  637. }`,Aye=`#ifdef USE_LIGHTMAP
  638. uniform sampler2D lightMap;
  639. uniform float lightMapIntensity;
  640. #endif`,Tye=`LambertMaterial material;
  641. material.diffuseColor = diffuseColor.rgb;
  642. material.specularStrength = specularStrength;`,Mye=`varying vec3 vViewPosition;
  643. struct LambertMaterial {
  644. vec3 diffuseColor;
  645. float specularStrength;
  646. };
  647. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  648. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  649. vec3 irradiance = dotNL * directLight.color;
  650. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  651. }
  652. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  653. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  654. }
  655. #define RE_Direct RE_Direct_Lambert
  656. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Pye=`uniform bool receiveShadow;
  657. uniform vec3 ambientLightColor;
  658. #if defined( USE_LIGHT_PROBES )
  659. uniform vec3 lightProbe[ 9 ];
  660. #endif
  661. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  662. float x = normal.x, y = normal.y, z = normal.z;
  663. vec3 result = shCoefficients[ 0 ] * 0.886227;
  664. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  665. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  666. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  667. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  668. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  669. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  670. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  671. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  672. return result;
  673. }
  674. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  675. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  676. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  677. return irradiance;
  678. }
  679. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  680. vec3 irradiance = ambientLightColor;
  681. return irradiance;
  682. }
  683. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  684. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  685. if ( cutoffDistance > 0.0 ) {
  686. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  687. }
  688. return distanceFalloff;
  689. }
  690. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  691. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  692. }
  693. #if NUM_DIR_LIGHTS > 0
  694. struct DirectionalLight {
  695. vec3 direction;
  696. vec3 color;
  697. };
  698. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  699. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  700. light.color = directionalLight.color;
  701. light.direction = directionalLight.direction;
  702. light.visible = true;
  703. }
  704. #endif
  705. #if NUM_POINT_LIGHTS > 0
  706. struct PointLight {
  707. vec3 position;
  708. vec3 color;
  709. float distance;
  710. float decay;
  711. };
  712. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  713. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  714. vec3 lVector = pointLight.position - geometryPosition;
  715. light.direction = normalize( lVector );
  716. float lightDistance = length( lVector );
  717. light.color = pointLight.color;
  718. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  719. light.visible = ( light.color != vec3( 0.0 ) );
  720. }
  721. #endif
  722. #if NUM_SPOT_LIGHTS > 0
  723. struct SpotLight {
  724. vec3 position;
  725. vec3 direction;
  726. vec3 color;
  727. float distance;
  728. float decay;
  729. float coneCos;
  730. float penumbraCos;
  731. };
  732. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  733. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  734. vec3 lVector = spotLight.position - geometryPosition;
  735. light.direction = normalize( lVector );
  736. float angleCos = dot( light.direction, spotLight.direction );
  737. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  738. if ( spotAttenuation > 0.0 ) {
  739. float lightDistance = length( lVector );
  740. light.color = spotLight.color * spotAttenuation;
  741. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  742. light.visible = ( light.color != vec3( 0.0 ) );
  743. } else {
  744. light.color = vec3( 0.0 );
  745. light.visible = false;
  746. }
  747. }
  748. #endif
  749. #if NUM_RECT_AREA_LIGHTS > 0
  750. struct RectAreaLight {
  751. vec3 color;
  752. vec3 position;
  753. vec3 halfWidth;
  754. vec3 halfHeight;
  755. };
  756. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  757. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  758. #endif
  759. #if NUM_HEMI_LIGHTS > 0
  760. struct HemisphereLight {
  761. vec3 direction;
  762. vec3 skyColor;
  763. vec3 groundColor;
  764. };
  765. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  766. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  767. float dotNL = dot( normal, hemiLight.direction );
  768. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  769. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  770. return irradiance;
  771. }
  772. #endif`,jye=`#ifdef USE_ENVMAP
  773. vec3 getIBLIrradiance( const in vec3 normal ) {
  774. #ifdef ENVMAP_TYPE_CUBE_UV
  775. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  776. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  777. return PI * envMapColor.rgb * envMapIntensity;
  778. #else
  779. return vec3( 0.0 );
  780. #endif
  781. }
  782. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  783. #ifdef ENVMAP_TYPE_CUBE_UV
  784. vec3 reflectVec = reflect( - viewDir, normal );
  785. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  786. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  787. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  788. return envMapColor.rgb * envMapIntensity;
  789. #else
  790. return vec3( 0.0 );
  791. #endif
  792. }
  793. #ifdef USE_ANISOTROPY
  794. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  795. #ifdef ENVMAP_TYPE_CUBE_UV
  796. vec3 bentNormal = cross( bitangent, viewDir );
  797. bentNormal = normalize( cross( bentNormal, bitangent ) );
  798. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  799. return getIBLRadiance( viewDir, bentNormal, roughness );
  800. #else
  801. return vec3( 0.0 );
  802. #endif
  803. }
  804. #endif
  805. #endif`,Eye=`ToonMaterial material;
  806. material.diffuseColor = diffuseColor.rgb;`,Dye=`varying vec3 vViewPosition;
  807. struct ToonMaterial {
  808. vec3 diffuseColor;
  809. };
  810. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  811. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  812. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  813. }
  814. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  815. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  816. }
  817. #define RE_Direct RE_Direct_Toon
  818. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Rye=`BlinnPhongMaterial material;
  819. material.diffuseColor = diffuseColor.rgb;
  820. material.specularColor = specular;
  821. material.specularShininess = shininess;
  822. material.specularStrength = specularStrength;`,Fye=`varying vec3 vViewPosition;
  823. struct BlinnPhongMaterial {
  824. vec3 diffuseColor;
  825. vec3 specularColor;
  826. float specularShininess;
  827. float specularStrength;
  828. };
  829. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  830. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  831. vec3 irradiance = dotNL * directLight.color;
  832. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  833. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  834. }
  835. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  836. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  837. }
  838. #define RE_Direct RE_Direct_BlinnPhong
  839. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Lye=`PhysicalMaterial material;
  840. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  841. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  842. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  843. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  844. material.roughness = min( material.roughness, 1.0 );
  845. #ifdef IOR
  846. material.ior = ior;
  847. #ifdef USE_SPECULAR
  848. float specularIntensityFactor = specularIntensity;
  849. vec3 specularColorFactor = specularColor;
  850. #ifdef USE_SPECULAR_COLORMAP
  851. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  852. #endif
  853. #ifdef USE_SPECULAR_INTENSITYMAP
  854. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  855. #endif
  856. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  857. #else
  858. float specularIntensityFactor = 1.0;
  859. vec3 specularColorFactor = vec3( 1.0 );
  860. material.specularF90 = 1.0;
  861. #endif
  862. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  863. #else
  864. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  865. material.specularF90 = 1.0;
  866. #endif
  867. #ifdef USE_CLEARCOAT
  868. material.clearcoat = clearcoat;
  869. material.clearcoatRoughness = clearcoatRoughness;
  870. material.clearcoatF0 = vec3( 0.04 );
  871. material.clearcoatF90 = 1.0;
  872. #ifdef USE_CLEARCOATMAP
  873. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  874. #endif
  875. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  876. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  877. #endif
  878. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  879. material.clearcoatRoughness += geometryRoughness;
  880. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  881. #endif
  882. #ifdef USE_DISPERSION
  883. material.dispersion = dispersion;
  884. #endif
  885. #ifdef USE_IRIDESCENCE
  886. material.iridescence = iridescence;
  887. material.iridescenceIOR = iridescenceIOR;
  888. #ifdef USE_IRIDESCENCEMAP
  889. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  890. #endif
  891. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  892. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  893. #else
  894. material.iridescenceThickness = iridescenceThicknessMaximum;
  895. #endif
  896. #endif
  897. #ifdef USE_SHEEN
  898. material.sheenColor = sheenColor;
  899. #ifdef USE_SHEEN_COLORMAP
  900. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  901. #endif
  902. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  903. #ifdef USE_SHEEN_ROUGHNESSMAP
  904. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  905. #endif
  906. #endif
  907. #ifdef USE_ANISOTROPY
  908. #ifdef USE_ANISOTROPYMAP
  909. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  910. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  911. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  912. #else
  913. vec2 anisotropyV = anisotropyVector;
  914. #endif
  915. material.anisotropy = length( anisotropyV );
  916. if( material.anisotropy == 0.0 ) {
  917. anisotropyV = vec2( 1.0, 0.0 );
  918. } else {
  919. anisotropyV /= material.anisotropy;
  920. material.anisotropy = saturate( material.anisotropy );
  921. }
  922. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  923. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  924. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  925. #endif`,Oye=`uniform sampler2D dfgLUT;
  926. struct PhysicalMaterial {
  927. vec3 diffuseColor;
  928. float roughness;
  929. vec3 specularColor;
  930. float specularF90;
  931. float dispersion;
  932. #ifdef USE_CLEARCOAT
  933. float clearcoat;
  934. float clearcoatRoughness;
  935. vec3 clearcoatF0;
  936. float clearcoatF90;
  937. #endif
  938. #ifdef USE_IRIDESCENCE
  939. float iridescence;
  940. float iridescenceIOR;
  941. float iridescenceThickness;
  942. vec3 iridescenceFresnel;
  943. vec3 iridescenceF0;
  944. #endif
  945. #ifdef USE_SHEEN
  946. vec3 sheenColor;
  947. float sheenRoughness;
  948. #endif
  949. #ifdef IOR
  950. float ior;
  951. #endif
  952. #ifdef USE_TRANSMISSION
  953. float transmission;
  954. float transmissionAlpha;
  955. float thickness;
  956. float attenuationDistance;
  957. vec3 attenuationColor;
  958. #endif
  959. #ifdef USE_ANISOTROPY
  960. float anisotropy;
  961. float alphaT;
  962. vec3 anisotropyT;
  963. vec3 anisotropyB;
  964. #endif
  965. };
  966. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  967. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  968. vec3 sheenSpecularDirect = vec3( 0.0 );
  969. vec3 sheenSpecularIndirect = vec3(0.0 );
  970. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  971. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  972. float x2 = x * x;
  973. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  974. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  975. }
  976. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  977. float a2 = pow2( alpha );
  978. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  979. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  980. return 0.5 / max( gv + gl, EPSILON );
  981. }
  982. float D_GGX( const in float alpha, const in float dotNH ) {
  983. float a2 = pow2( alpha );
  984. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  985. return RECIPROCAL_PI * a2 / pow2( denom );
  986. }
  987. #ifdef USE_ANISOTROPY
  988. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  989. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  990. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  991. float v = 0.5 / ( gv + gl );
  992. return saturate(v);
  993. }
  994. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  995. float a2 = alphaT * alphaB;
  996. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  997. highp float v2 = dot( v, v );
  998. float w2 = a2 / v2;
  999. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1000. }
  1001. #endif
  1002. #ifdef USE_CLEARCOAT
  1003. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1004. vec3 f0 = material.clearcoatF0;
  1005. float f90 = material.clearcoatF90;
  1006. float roughness = material.clearcoatRoughness;
  1007. float alpha = pow2( roughness );
  1008. vec3 halfDir = normalize( lightDir + viewDir );
  1009. float dotNL = saturate( dot( normal, lightDir ) );
  1010. float dotNV = saturate( dot( normal, viewDir ) );
  1011. float dotNH = saturate( dot( normal, halfDir ) );
  1012. float dotVH = saturate( dot( viewDir, halfDir ) );
  1013. vec3 F = F_Schlick( f0, f90, dotVH );
  1014. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1015. float D = D_GGX( alpha, dotNH );
  1016. return F * ( V * D );
  1017. }
  1018. #endif
  1019. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1020. vec3 f0 = material.specularColor;
  1021. float f90 = material.specularF90;
  1022. float roughness = material.roughness;
  1023. float alpha = pow2( roughness );
  1024. vec3 halfDir = normalize( lightDir + viewDir );
  1025. float dotNL = saturate( dot( normal, lightDir ) );
  1026. float dotNV = saturate( dot( normal, viewDir ) );
  1027. float dotNH = saturate( dot( normal, halfDir ) );
  1028. float dotVH = saturate( dot( viewDir, halfDir ) );
  1029. vec3 F = F_Schlick( f0, f90, dotVH );
  1030. #ifdef USE_IRIDESCENCE
  1031. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1032. #endif
  1033. #ifdef USE_ANISOTROPY
  1034. float dotTL = dot( material.anisotropyT, lightDir );
  1035. float dotTV = dot( material.anisotropyT, viewDir );
  1036. float dotTH = dot( material.anisotropyT, halfDir );
  1037. float dotBL = dot( material.anisotropyB, lightDir );
  1038. float dotBV = dot( material.anisotropyB, viewDir );
  1039. float dotBH = dot( material.anisotropyB, halfDir );
  1040. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1041. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1042. #else
  1043. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1044. float D = D_GGX( alpha, dotNH );
  1045. #endif
  1046. return F * ( V * D );
  1047. }
  1048. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1049. const float LUT_SIZE = 64.0;
  1050. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1051. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1052. float dotNV = saturate( dot( N, V ) );
  1053. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1054. uv = uv * LUT_SCALE + LUT_BIAS;
  1055. return uv;
  1056. }
  1057. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1058. float l = length( f );
  1059. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1060. }
  1061. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1062. float x = dot( v1, v2 );
  1063. float y = abs( x );
  1064. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1065. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1066. float v = a / b;
  1067. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1068. return cross( v1, v2 ) * theta_sintheta;
  1069. }
  1070. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1071. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1072. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1073. vec3 lightNormal = cross( v1, v2 );
  1074. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1075. vec3 T1, T2;
  1076. T1 = normalize( V - N * dot( V, N ) );
  1077. T2 = - cross( N, T1 );
  1078. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1079. vec3 coords[ 4 ];
  1080. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1081. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1082. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1083. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1084. coords[ 0 ] = normalize( coords[ 0 ] );
  1085. coords[ 1 ] = normalize( coords[ 1 ] );
  1086. coords[ 2 ] = normalize( coords[ 2 ] );
  1087. coords[ 3 ] = normalize( coords[ 3 ] );
  1088. vec3 vectorFormFactor = vec3( 0.0 );
  1089. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1090. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1091. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1092. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1093. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1094. return vec3( result );
  1095. }
  1096. #if defined( USE_SHEEN )
  1097. float D_Charlie( float roughness, float dotNH ) {
  1098. float alpha = pow2( roughness );
  1099. float invAlpha = 1.0 / alpha;
  1100. float cos2h = dotNH * dotNH;
  1101. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1102. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1103. }
  1104. float V_Neubelt( float dotNV, float dotNL ) {
  1105. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1106. }
  1107. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1108. vec3 halfDir = normalize( lightDir + viewDir );
  1109. float dotNL = saturate( dot( normal, lightDir ) );
  1110. float dotNV = saturate( dot( normal, viewDir ) );
  1111. float dotNH = saturate( dot( normal, halfDir ) );
  1112. float D = D_Charlie( sheenRoughness, dotNH );
  1113. float V = V_Neubelt( dotNV, dotNL );
  1114. return sheenColor * ( D * V );
  1115. }
  1116. #endif
  1117. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1118. float dotNV = saturate( dot( normal, viewDir ) );
  1119. float r2 = roughness * roughness;
  1120. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1121. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1122. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1123. return saturate( DG * RECIPROCAL_PI );
  1124. }
  1125. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1126. float dotNV = saturate( dot( normal, viewDir ) );
  1127. vec2 uv = vec2( roughness, dotNV );
  1128. return texture2D( dfgLUT, uv ).rg;
  1129. }
  1130. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1131. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1132. return specularColor * fab.x + specularF90 * fab.y;
  1133. }
  1134. #ifdef USE_IRIDESCENCE
  1135. void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1136. #else
  1137. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1138. #endif
  1139. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1140. #ifdef USE_IRIDESCENCE
  1141. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1142. #else
  1143. vec3 Fr = specularColor;
  1144. #endif
  1145. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1146. float Ess = fab.x + fab.y;
  1147. float Ems = 1.0 - Ess;
  1148. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1149. singleScatter += FssEss;
  1150. multiScatter += Fms * Ems;
  1151. }
  1152. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1153. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1154. float dotNL = saturate( dot( normal, lightDir ) );
  1155. float dotNV = saturate( dot( normal, viewDir ) );
  1156. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1157. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1158. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1159. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1160. float Ess_V = dfgV.x + dfgV.y;
  1161. float Ess_L = dfgL.x + dfgL.y;
  1162. float Ems_V = 1.0 - Ess_V;
  1163. float Ems_L = 1.0 - Ess_L;
  1164. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1165. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1166. float compensationFactor = Ems_V * Ems_L;
  1167. vec3 multiScatter = Fms * compensationFactor;
  1168. return singleScatter + multiScatter;
  1169. }
  1170. #if NUM_RECT_AREA_LIGHTS > 0
  1171. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1172. vec3 normal = geometryNormal;
  1173. vec3 viewDir = geometryViewDir;
  1174. vec3 position = geometryPosition;
  1175. vec3 lightPos = rectAreaLight.position;
  1176. vec3 halfWidth = rectAreaLight.halfWidth;
  1177. vec3 halfHeight = rectAreaLight.halfHeight;
  1178. vec3 lightColor = rectAreaLight.color;
  1179. float roughness = material.roughness;
  1180. vec3 rectCoords[ 4 ];
  1181. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1182. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1183. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1184. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1185. vec4 t1 = texture2D( ltc_1, uv );
  1186. vec4 t2 = texture2D( ltc_2, uv );
  1187. mat3 mInv = mat3(
  1188. vec3( t1.x, 0, t1.y ),
  1189. vec3( 0, 1, 0 ),
  1190. vec3( t1.z, 0, t1.w )
  1191. );
  1192. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1193. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1194. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1195. }
  1196. #endif
  1197. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1198. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1199. vec3 irradiance = dotNL * directLight.color;
  1200. #ifdef USE_CLEARCOAT
  1201. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1202. vec3 ccIrradiance = dotNLcc * directLight.color;
  1203. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1204. #endif
  1205. #ifdef USE_SHEEN
  1206. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1207. #endif
  1208. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1209. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1210. }
  1211. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1212. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1213. }
  1214. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  1215. #ifdef USE_CLEARCOAT
  1216. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1217. #endif
  1218. #ifdef USE_SHEEN
  1219. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1220. #endif
  1221. vec3 singleScattering = vec3( 0.0 );
  1222. vec3 multiScattering = vec3( 0.0 );
  1223. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1224. #ifdef USE_IRIDESCENCE
  1225. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1226. #else
  1227. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1228. #endif
  1229. vec3 totalScattering = singleScattering + multiScattering;
  1230. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1231. reflectedLight.indirectSpecular += radiance * singleScattering;
  1232. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1233. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1234. }
  1235. #define RE_Direct RE_Direct_Physical
  1236. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1237. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1238. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1239. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1240. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1241. }`,Iye=`
  1242. vec3 geometryPosition = - vViewPosition;
  1243. vec3 geometryNormal = normal;
  1244. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1245. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1246. #ifdef USE_CLEARCOAT
  1247. geometryClearcoatNormal = clearcoatNormal;
  1248. #endif
  1249. #ifdef USE_IRIDESCENCE
  1250. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1251. if ( material.iridescenceThickness == 0.0 ) {
  1252. material.iridescence = 0.0;
  1253. } else {
  1254. material.iridescence = saturate( material.iridescence );
  1255. }
  1256. if ( material.iridescence > 0.0 ) {
  1257. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1258. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1259. }
  1260. #endif
  1261. IncidentLight directLight;
  1262. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1263. PointLight pointLight;
  1264. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1265. PointLightShadow pointLightShadow;
  1266. #endif
  1267. #pragma unroll_loop_start
  1268. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1269. pointLight = pointLights[ i ];
  1270. getPointLightInfo( pointLight, geometryPosition, directLight );
  1271. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1272. pointLightShadow = pointLightShadows[ i ];
  1273. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1274. #endif
  1275. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1276. }
  1277. #pragma unroll_loop_end
  1278. #endif
  1279. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1280. SpotLight spotLight;
  1281. vec4 spotColor;
  1282. vec3 spotLightCoord;
  1283. bool inSpotLightMap;
  1284. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1285. SpotLightShadow spotLightShadow;
  1286. #endif
  1287. #pragma unroll_loop_start
  1288. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1289. spotLight = spotLights[ i ];
  1290. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1291. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1292. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1293. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1294. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1295. #else
  1296. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1297. #endif
  1298. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1299. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1300. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1301. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1302. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1303. #endif
  1304. #undef SPOT_LIGHT_MAP_INDEX
  1305. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1306. spotLightShadow = spotLightShadows[ i ];
  1307. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1308. #endif
  1309. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1310. }
  1311. #pragma unroll_loop_end
  1312. #endif
  1313. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1314. DirectionalLight directionalLight;
  1315. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1316. DirectionalLightShadow directionalLightShadow;
  1317. #endif
  1318. #pragma unroll_loop_start
  1319. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1320. directionalLight = directionalLights[ i ];
  1321. getDirectionalLightInfo( directionalLight, directLight );
  1322. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1323. directionalLightShadow = directionalLightShadows[ i ];
  1324. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1325. #endif
  1326. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1327. }
  1328. #pragma unroll_loop_end
  1329. #endif
  1330. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1331. RectAreaLight rectAreaLight;
  1332. #pragma unroll_loop_start
  1333. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1334. rectAreaLight = rectAreaLights[ i ];
  1335. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1336. }
  1337. #pragma unroll_loop_end
  1338. #endif
  1339. #if defined( RE_IndirectDiffuse )
  1340. vec3 iblIrradiance = vec3( 0.0 );
  1341. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1342. #if defined( USE_LIGHT_PROBES )
  1343. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1344. #endif
  1345. #if ( NUM_HEMI_LIGHTS > 0 )
  1346. #pragma unroll_loop_start
  1347. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1348. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1349. }
  1350. #pragma unroll_loop_end
  1351. #endif
  1352. #endif
  1353. #if defined( RE_IndirectSpecular )
  1354. vec3 radiance = vec3( 0.0 );
  1355. vec3 clearcoatRadiance = vec3( 0.0 );
  1356. #endif`,zye=`#if defined( RE_IndirectDiffuse )
  1357. #ifdef USE_LIGHTMAP
  1358. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1359. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1360. irradiance += lightMapIrradiance;
  1361. #endif
  1362. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1363. iblIrradiance += getIBLIrradiance( geometryNormal );
  1364. #endif
  1365. #endif
  1366. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1367. #ifdef USE_ANISOTROPY
  1368. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1369. #else
  1370. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1371. #endif
  1372. #ifdef USE_CLEARCOAT
  1373. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1374. #endif
  1375. #endif`,Uye=`#if defined( RE_IndirectDiffuse )
  1376. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1377. #endif
  1378. #if defined( RE_IndirectSpecular )
  1379. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1380. #endif`,Bye=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1381. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1382. #endif`,Hye=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1383. uniform float logDepthBufFC;
  1384. varying float vFragDepth;
  1385. varying float vIsPerspective;
  1386. #endif`,$ye=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1387. varying float vFragDepth;
  1388. varying float vIsPerspective;
  1389. #endif`,Vye=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1390. vFragDepth = 1.0 + gl_Position.w;
  1391. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1392. #endif`,qye=`#ifdef USE_MAP
  1393. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1394. #ifdef DECODE_VIDEO_TEXTURE
  1395. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1396. #endif
  1397. diffuseColor *= sampledDiffuseColor;
  1398. #endif`,Gye=`#ifdef USE_MAP
  1399. uniform sampler2D map;
  1400. #endif`,Wye=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1401. #if defined( USE_POINTS_UV )
  1402. vec2 uv = vUv;
  1403. #else
  1404. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1405. #endif
  1406. #endif
  1407. #ifdef USE_MAP
  1408. diffuseColor *= texture2D( map, uv );
  1409. #endif
  1410. #ifdef USE_ALPHAMAP
  1411. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1412. #endif`,Kye=`#if defined( USE_POINTS_UV )
  1413. varying vec2 vUv;
  1414. #else
  1415. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1416. uniform mat3 uvTransform;
  1417. #endif
  1418. #endif
  1419. #ifdef USE_MAP
  1420. uniform sampler2D map;
  1421. #endif
  1422. #ifdef USE_ALPHAMAP
  1423. uniform sampler2D alphaMap;
  1424. #endif`,Yye=`float metalnessFactor = metalness;
  1425. #ifdef USE_METALNESSMAP
  1426. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1427. metalnessFactor *= texelMetalness.b;
  1428. #endif`,Xye=`#ifdef USE_METALNESSMAP
  1429. uniform sampler2D metalnessMap;
  1430. #endif`,Qye=`#ifdef USE_INSTANCING_MORPH
  1431. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1432. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1433. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1434. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1435. }
  1436. #endif`,Zye=`#if defined( USE_MORPHCOLORS )
  1437. vColor *= morphTargetBaseInfluence;
  1438. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1439. #if defined( USE_COLOR_ALPHA )
  1440. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1441. #elif defined( USE_COLOR )
  1442. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1443. #endif
  1444. }
  1445. #endif`,Jye=`#ifdef USE_MORPHNORMALS
  1446. objectNormal *= morphTargetBaseInfluence;
  1447. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1448. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1449. }
  1450. #endif`,e0e=`#ifdef USE_MORPHTARGETS
  1451. #ifndef USE_INSTANCING_MORPH
  1452. uniform float morphTargetBaseInfluence;
  1453. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1454. #endif
  1455. uniform sampler2DArray morphTargetsTexture;
  1456. uniform ivec2 morphTargetsTextureSize;
  1457. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1458. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1459. int y = texelIndex / morphTargetsTextureSize.x;
  1460. int x = texelIndex - y * morphTargetsTextureSize.x;
  1461. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1462. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1463. }
  1464. #endif`,t0e=`#ifdef USE_MORPHTARGETS
  1465. transformed *= morphTargetBaseInfluence;
  1466. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1467. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1468. }
  1469. #endif`,n0e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1470. #ifdef FLAT_SHADED
  1471. vec3 fdx = dFdx( vViewPosition );
  1472. vec3 fdy = dFdy( vViewPosition );
  1473. vec3 normal = normalize( cross( fdx, fdy ) );
  1474. #else
  1475. vec3 normal = normalize( vNormal );
  1476. #ifdef DOUBLE_SIDED
  1477. normal *= faceDirection;
  1478. #endif
  1479. #endif
  1480. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1481. #ifdef USE_TANGENT
  1482. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1483. #else
  1484. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1485. #if defined( USE_NORMALMAP )
  1486. vNormalMapUv
  1487. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1488. vClearcoatNormalMapUv
  1489. #else
  1490. vUv
  1491. #endif
  1492. );
  1493. #endif
  1494. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1495. tbn[0] *= faceDirection;
  1496. tbn[1] *= faceDirection;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_CLEARCOAT_NORMALMAP
  1500. #ifdef USE_TANGENT
  1501. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1502. #else
  1503. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1504. #endif
  1505. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1506. tbn2[0] *= faceDirection;
  1507. tbn2[1] *= faceDirection;
  1508. #endif
  1509. #endif
  1510. vec3 nonPerturbedNormal = normal;`,r0e=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1511. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1512. #ifdef FLIP_SIDED
  1513. normal = - normal;
  1514. #endif
  1515. #ifdef DOUBLE_SIDED
  1516. normal = normal * faceDirection;
  1517. #endif
  1518. normal = normalize( normalMatrix * normal );
  1519. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1520. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1521. mapN.xy *= normalScale;
  1522. normal = normalize( tbn * mapN );
  1523. #elif defined( USE_BUMPMAP )
  1524. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1525. #endif`,a0e=`#ifndef FLAT_SHADED
  1526. varying vec3 vNormal;
  1527. #ifdef USE_TANGENT
  1528. varying vec3 vTangent;
  1529. varying vec3 vBitangent;
  1530. #endif
  1531. #endif`,i0e=`#ifndef FLAT_SHADED
  1532. varying vec3 vNormal;
  1533. #ifdef USE_TANGENT
  1534. varying vec3 vTangent;
  1535. varying vec3 vBitangent;
  1536. #endif
  1537. #endif`,s0e=`#ifndef FLAT_SHADED
  1538. vNormal = normalize( transformedNormal );
  1539. #ifdef USE_TANGENT
  1540. vTangent = normalize( transformedTangent );
  1541. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1542. #endif
  1543. #endif`,o0e=`#ifdef USE_NORMALMAP
  1544. uniform sampler2D normalMap;
  1545. uniform vec2 normalScale;
  1546. #endif
  1547. #ifdef USE_NORMALMAP_OBJECTSPACE
  1548. uniform mat3 normalMatrix;
  1549. #endif
  1550. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1551. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1552. vec3 q0 = dFdx( eye_pos.xyz );
  1553. vec3 q1 = dFdy( eye_pos.xyz );
  1554. vec2 st0 = dFdx( uv.st );
  1555. vec2 st1 = dFdy( uv.st );
  1556. vec3 N = surf_norm;
  1557. vec3 q1perp = cross( q1, N );
  1558. vec3 q0perp = cross( N, q0 );
  1559. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1560. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1561. float det = max( dot( T, T ), dot( B, B ) );
  1562. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1563. return mat3( T * scale, B * scale, N );
  1564. }
  1565. #endif`,l0e=`#ifdef USE_CLEARCOAT
  1566. vec3 clearcoatNormal = nonPerturbedNormal;
  1567. #endif`,c0e=`#ifdef USE_CLEARCOAT_NORMALMAP
  1568. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1569. clearcoatMapN.xy *= clearcoatNormalScale;
  1570. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1571. #endif`,u0e=`#ifdef USE_CLEARCOATMAP
  1572. uniform sampler2D clearcoatMap;
  1573. #endif
  1574. #ifdef USE_CLEARCOAT_NORMALMAP
  1575. uniform sampler2D clearcoatNormalMap;
  1576. uniform vec2 clearcoatNormalScale;
  1577. #endif
  1578. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1579. uniform sampler2D clearcoatRoughnessMap;
  1580. #endif`,d0e=`#ifdef USE_IRIDESCENCEMAP
  1581. uniform sampler2D iridescenceMap;
  1582. #endif
  1583. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1584. uniform sampler2D iridescenceThicknessMap;
  1585. #endif`,h0e=`#ifdef OPAQUE
  1586. diffuseColor.a = 1.0;
  1587. #endif
  1588. #ifdef USE_TRANSMISSION
  1589. diffuseColor.a *= material.transmissionAlpha;
  1590. #endif
  1591. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,m0e=`vec3 packNormalToRGB( const in vec3 normal ) {
  1592. return normalize( normal ) * 0.5 + 0.5;
  1593. }
  1594. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1595. return 2.0 * rgb.xyz - 1.0;
  1596. }
  1597. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1598. const float Inv255 = 1. / 255.;
  1599. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1600. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1601. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1602. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1603. vec4 packDepthToRGBA( const in float v ) {
  1604. if( v <= 0.0 )
  1605. return vec4( 0., 0., 0., 0. );
  1606. if( v >= 1.0 )
  1607. return vec4( 1., 1., 1., 1. );
  1608. float vuf;
  1609. float af = modf( v * PackFactors.a, vuf );
  1610. float bf = modf( vuf * ShiftRight8, vuf );
  1611. float gf = modf( vuf * ShiftRight8, vuf );
  1612. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1613. }
  1614. vec3 packDepthToRGB( const in float v ) {
  1615. if( v <= 0.0 )
  1616. return vec3( 0., 0., 0. );
  1617. if( v >= 1.0 )
  1618. return vec3( 1., 1., 1. );
  1619. float vuf;
  1620. float bf = modf( v * PackFactors.b, vuf );
  1621. float gf = modf( vuf * ShiftRight8, vuf );
  1622. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1623. }
  1624. vec2 packDepthToRG( const in float v ) {
  1625. if( v <= 0.0 )
  1626. return vec2( 0., 0. );
  1627. if( v >= 1.0 )
  1628. return vec2( 1., 1. );
  1629. float vuf;
  1630. float gf = modf( v * 256., vuf );
  1631. return vec2( vuf * Inv255, gf );
  1632. }
  1633. float unpackRGBAToDepth( const in vec4 v ) {
  1634. return dot( v, UnpackFactors4 );
  1635. }
  1636. float unpackRGBToDepth( const in vec3 v ) {
  1637. return dot( v, UnpackFactors3 );
  1638. }
  1639. float unpackRGToDepth( const in vec2 v ) {
  1640. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1641. }
  1642. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1643. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1644. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1645. }
  1646. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1647. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1648. }
  1649. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1650. return ( viewZ + near ) / ( near - far );
  1651. }
  1652. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1653. return depth * ( near - far ) - near;
  1654. }
  1655. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1656. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1657. }
  1658. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1659. return ( near * far ) / ( ( far - near ) * depth - far );
  1660. }`,f0e=`#ifdef PREMULTIPLIED_ALPHA
  1661. gl_FragColor.rgb *= gl_FragColor.a;
  1662. #endif`,p0e=`vec4 mvPosition = vec4( transformed, 1.0 );
  1663. #ifdef USE_BATCHING
  1664. mvPosition = batchingMatrix * mvPosition;
  1665. #endif
  1666. #ifdef USE_INSTANCING
  1667. mvPosition = instanceMatrix * mvPosition;
  1668. #endif
  1669. mvPosition = modelViewMatrix * mvPosition;
  1670. gl_Position = projectionMatrix * mvPosition;`,g0e=`#ifdef DITHERING
  1671. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1672. #endif`,b0e=`#ifdef DITHERING
  1673. vec3 dithering( vec3 color ) {
  1674. float grid_position = rand( gl_FragCoord.xy );
  1675. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1676. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1677. return color + dither_shift_RGB;
  1678. }
  1679. #endif`,x0e=`float roughnessFactor = roughness;
  1680. #ifdef USE_ROUGHNESSMAP
  1681. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1682. roughnessFactor *= texelRoughness.g;
  1683. #endif`,y0e=`#ifdef USE_ROUGHNESSMAP
  1684. uniform sampler2D roughnessMap;
  1685. #endif`,v0e=`#if NUM_SPOT_LIGHT_COORDS > 0
  1686. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1687. #endif
  1688. #if NUM_SPOT_LIGHT_MAPS > 0
  1689. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1690. #endif
  1691. #ifdef USE_SHADOWMAP
  1692. #if NUM_DIR_LIGHT_SHADOWS > 0
  1693. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1694. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1695. struct DirectionalLightShadow {
  1696. float shadowIntensity;
  1697. float shadowBias;
  1698. float shadowNormalBias;
  1699. float shadowRadius;
  1700. vec2 shadowMapSize;
  1701. };
  1702. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1703. #endif
  1704. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1705. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1706. struct SpotLightShadow {
  1707. float shadowIntensity;
  1708. float shadowBias;
  1709. float shadowNormalBias;
  1710. float shadowRadius;
  1711. vec2 shadowMapSize;
  1712. };
  1713. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1714. #endif
  1715. #if NUM_POINT_LIGHT_SHADOWS > 0
  1716. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1717. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1718. struct PointLightShadow {
  1719. float shadowIntensity;
  1720. float shadowBias;
  1721. float shadowNormalBias;
  1722. float shadowRadius;
  1723. vec2 shadowMapSize;
  1724. float shadowCameraNear;
  1725. float shadowCameraFar;
  1726. };
  1727. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1728. #endif
  1729. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1730. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1731. #ifdef USE_REVERSED_DEPTH_BUFFER
  1732. return step( depth, compare );
  1733. #else
  1734. return step( compare, depth );
  1735. #endif
  1736. }
  1737. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1738. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1739. }
  1740. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1741. float occlusion = 1.0;
  1742. vec2 distribution = texture2DDistribution( shadow, uv );
  1743. #ifdef USE_REVERSED_DEPTH_BUFFER
  1744. float hard_shadow = step( distribution.x, compare );
  1745. #else
  1746. float hard_shadow = step( compare, distribution.x );
  1747. #endif
  1748. if ( hard_shadow != 1.0 ) {
  1749. float distance = compare - distribution.x;
  1750. float variance = max( 0.00000, distribution.y * distribution.y );
  1751. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  1752. }
  1753. return occlusion;
  1754. }
  1755. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1756. float shadow = 1.0;
  1757. shadowCoord.xyz /= shadowCoord.w;
  1758. shadowCoord.z += shadowBias;
  1759. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1760. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1761. if ( frustumTest ) {
  1762. #if defined( SHADOWMAP_TYPE_PCF )
  1763. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1764. float dx0 = - texelSize.x * shadowRadius;
  1765. float dy0 = - texelSize.y * shadowRadius;
  1766. float dx1 = + texelSize.x * shadowRadius;
  1767. float dy1 = + texelSize.y * shadowRadius;
  1768. float dx2 = dx0 / 2.0;
  1769. float dy2 = dy0 / 2.0;
  1770. float dx3 = dx1 / 2.0;
  1771. float dy3 = dy1 / 2.0;
  1772. shadow = (
  1773. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1774. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1775. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1776. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1777. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1778. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1779. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1780. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1781. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1782. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1783. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1784. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1785. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1786. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1787. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1788. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1789. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1790. ) * ( 1.0 / 17.0 );
  1791. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1792. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1793. float dx = texelSize.x;
  1794. float dy = texelSize.y;
  1795. vec2 uv = shadowCoord.xy;
  1796. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1797. uv -= f * texelSize;
  1798. shadow = (
  1799. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1800. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1801. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1802. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1803. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1804. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1805. f.x ) +
  1806. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1807. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1808. f.x ) +
  1809. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1810. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1811. f.y ) +
  1812. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1813. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1814. f.y ) +
  1815. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1816. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1817. f.x ),
  1818. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1819. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1820. f.x ),
  1821. f.y )
  1822. ) * ( 1.0 / 9.0 );
  1823. #elif defined( SHADOWMAP_TYPE_VSM )
  1824. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1825. #else
  1826. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1827. #endif
  1828. }
  1829. return mix( 1.0, shadow, shadowIntensity );
  1830. }
  1831. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1832. vec3 absV = abs( v );
  1833. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1834. absV *= scaleToCube;
  1835. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1836. vec2 planar = v.xy;
  1837. float almostATexel = 1.5 * texelSizeY;
  1838. float almostOne = 1.0 - almostATexel;
  1839. if ( absV.z >= almostOne ) {
  1840. if ( v.z > 0.0 )
  1841. planar.x = 4.0 - v.x;
  1842. } else if ( absV.x >= almostOne ) {
  1843. float signX = sign( v.x );
  1844. planar.x = v.z * signX + 2.0 * signX;
  1845. } else if ( absV.y >= almostOne ) {
  1846. float signY = sign( v.y );
  1847. planar.x = v.x + 2.0 * signY + 2.0;
  1848. planar.y = v.z * signY - 2.0;
  1849. }
  1850. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1851. }
  1852. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1853. float shadow = 1.0;
  1854. vec3 lightToPosition = shadowCoord.xyz;
  1855. float lightToPositionLength = length( lightToPosition );
  1856. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1857. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1858. vec3 bd3D = normalize( lightToPosition );
  1859. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1860. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1861. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1862. shadow = (
  1863. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1864. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1865. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1866. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1867. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1868. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1869. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1870. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1871. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1872. ) * ( 1.0 / 9.0 );
  1873. #else
  1874. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1875. #endif
  1876. }
  1877. return mix( 1.0, shadow, shadowIntensity );
  1878. }
  1879. #endif`,w0e=`#if NUM_SPOT_LIGHT_COORDS > 0
  1880. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1881. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1882. #endif
  1883. #ifdef USE_SHADOWMAP
  1884. #if NUM_DIR_LIGHT_SHADOWS > 0
  1885. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1886. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1887. struct DirectionalLightShadow {
  1888. float shadowIntensity;
  1889. float shadowBias;
  1890. float shadowNormalBias;
  1891. float shadowRadius;
  1892. vec2 shadowMapSize;
  1893. };
  1894. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1895. #endif
  1896. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1897. struct SpotLightShadow {
  1898. float shadowIntensity;
  1899. float shadowBias;
  1900. float shadowNormalBias;
  1901. float shadowRadius;
  1902. vec2 shadowMapSize;
  1903. };
  1904. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1905. #endif
  1906. #if NUM_POINT_LIGHT_SHADOWS > 0
  1907. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1908. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1909. struct PointLightShadow {
  1910. float shadowIntensity;
  1911. float shadowBias;
  1912. float shadowNormalBias;
  1913. float shadowRadius;
  1914. vec2 shadowMapSize;
  1915. float shadowCameraNear;
  1916. float shadowCameraFar;
  1917. };
  1918. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1919. #endif
  1920. #endif`,S0e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1921. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1922. vec4 shadowWorldPosition;
  1923. #endif
  1924. #if defined( USE_SHADOWMAP )
  1925. #if NUM_DIR_LIGHT_SHADOWS > 0
  1926. #pragma unroll_loop_start
  1927. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1928. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1929. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1930. }
  1931. #pragma unroll_loop_end
  1932. #endif
  1933. #if NUM_POINT_LIGHT_SHADOWS > 0
  1934. #pragma unroll_loop_start
  1935. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1936. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1937. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1938. }
  1939. #pragma unroll_loop_end
  1940. #endif
  1941. #endif
  1942. #if NUM_SPOT_LIGHT_COORDS > 0
  1943. #pragma unroll_loop_start
  1944. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1945. shadowWorldPosition = worldPosition;
  1946. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1947. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1948. #endif
  1949. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1950. }
  1951. #pragma unroll_loop_end
  1952. #endif`,_0e=`float getShadowMask() {
  1953. float shadow = 1.0;
  1954. #ifdef USE_SHADOWMAP
  1955. #if NUM_DIR_LIGHT_SHADOWS > 0
  1956. DirectionalLightShadow directionalLight;
  1957. #pragma unroll_loop_start
  1958. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1959. directionalLight = directionalLightShadows[ i ];
  1960. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1961. }
  1962. #pragma unroll_loop_end
  1963. #endif
  1964. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1965. SpotLightShadow spotLight;
  1966. #pragma unroll_loop_start
  1967. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1968. spotLight = spotLightShadows[ i ];
  1969. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1970. }
  1971. #pragma unroll_loop_end
  1972. #endif
  1973. #if NUM_POINT_LIGHT_SHADOWS > 0
  1974. PointLightShadow pointLight;
  1975. #pragma unroll_loop_start
  1976. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1977. pointLight = pointLightShadows[ i ];
  1978. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1979. }
  1980. #pragma unroll_loop_end
  1981. #endif
  1982. #endif
  1983. return shadow;
  1984. }`,N0e=`#ifdef USE_SKINNING
  1985. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1986. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1987. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1988. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1989. #endif`,k0e=`#ifdef USE_SKINNING
  1990. uniform mat4 bindMatrix;
  1991. uniform mat4 bindMatrixInverse;
  1992. uniform highp sampler2D boneTexture;
  1993. mat4 getBoneMatrix( const in float i ) {
  1994. int size = textureSize( boneTexture, 0 ).x;
  1995. int j = int( i ) * 4;
  1996. int x = j % size;
  1997. int y = j / size;
  1998. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  1999. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2000. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2001. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2002. return mat4( v1, v2, v3, v4 );
  2003. }
  2004. #endif`,C0e=`#ifdef USE_SKINNING
  2005. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2006. vec4 skinned = vec4( 0.0 );
  2007. skinned += boneMatX * skinVertex * skinWeight.x;
  2008. skinned += boneMatY * skinVertex * skinWeight.y;
  2009. skinned += boneMatZ * skinVertex * skinWeight.z;
  2010. skinned += boneMatW * skinVertex * skinWeight.w;
  2011. transformed = ( bindMatrixInverse * skinned ).xyz;
  2012. #endif`,A0e=`#ifdef USE_SKINNING
  2013. mat4 skinMatrix = mat4( 0.0 );
  2014. skinMatrix += skinWeight.x * boneMatX;
  2015. skinMatrix += skinWeight.y * boneMatY;
  2016. skinMatrix += skinWeight.z * boneMatZ;
  2017. skinMatrix += skinWeight.w * boneMatW;
  2018. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2019. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2020. #ifdef USE_TANGENT
  2021. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2022. #endif
  2023. #endif`,T0e=`float specularStrength;
  2024. #ifdef USE_SPECULARMAP
  2025. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2026. specularStrength = texelSpecular.r;
  2027. #else
  2028. specularStrength = 1.0;
  2029. #endif`,M0e=`#ifdef USE_SPECULARMAP
  2030. uniform sampler2D specularMap;
  2031. #endif`,P0e=`#if defined( TONE_MAPPING )
  2032. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2033. #endif`,j0e=`#ifndef saturate
  2034. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2035. #endif
  2036. uniform float toneMappingExposure;
  2037. vec3 LinearToneMapping( vec3 color ) {
  2038. return saturate( toneMappingExposure * color );
  2039. }
  2040. vec3 ReinhardToneMapping( vec3 color ) {
  2041. color *= toneMappingExposure;
  2042. return saturate( color / ( vec3( 1.0 ) + color ) );
  2043. }
  2044. vec3 CineonToneMapping( vec3 color ) {
  2045. color *= toneMappingExposure;
  2046. color = max( vec3( 0.0 ), color - 0.004 );
  2047. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2048. }
  2049. vec3 RRTAndODTFit( vec3 v ) {
  2050. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2051. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2052. return a / b;
  2053. }
  2054. vec3 ACESFilmicToneMapping( vec3 color ) {
  2055. const mat3 ACESInputMat = mat3(
  2056. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2057. vec3( 0.04823, 0.01566, 0.83777 )
  2058. );
  2059. const mat3 ACESOutputMat = mat3(
  2060. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2061. vec3( -0.07367, -0.00605, 1.07602 )
  2062. );
  2063. color *= toneMappingExposure / 0.6;
  2064. color = ACESInputMat * color;
  2065. color = RRTAndODTFit( color );
  2066. color = ACESOutputMat * color;
  2067. return saturate( color );
  2068. }
  2069. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2070. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2071. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2072. vec3( - 0.0728, - 0.0083, 1.1187 )
  2073. );
  2074. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2075. vec3( 0.6274, 0.0691, 0.0164 ),
  2076. vec3( 0.3293, 0.9195, 0.0880 ),
  2077. vec3( 0.0433, 0.0113, 0.8956 )
  2078. );
  2079. vec3 agxDefaultContrastApprox( vec3 x ) {
  2080. vec3 x2 = x * x;
  2081. vec3 x4 = x2 * x2;
  2082. return + 15.5 * x4 * x2
  2083. - 40.14 * x4 * x
  2084. + 31.96 * x4
  2085. - 6.868 * x2 * x
  2086. + 0.4298 * x2
  2087. + 0.1191 * x
  2088. - 0.00232;
  2089. }
  2090. vec3 AgXToneMapping( vec3 color ) {
  2091. const mat3 AgXInsetMatrix = mat3(
  2092. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2093. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2094. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2095. );
  2096. const mat3 AgXOutsetMatrix = mat3(
  2097. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2098. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2099. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2100. );
  2101. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2102. color *= toneMappingExposure;
  2103. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2104. color = AgXInsetMatrix * color;
  2105. color = max( color, 1e-10 ); color = log2( color );
  2106. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2107. color = clamp( color, 0.0, 1.0 );
  2108. color = agxDefaultContrastApprox( color );
  2109. color = AgXOutsetMatrix * color;
  2110. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2111. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2112. color = clamp( color, 0.0, 1.0 );
  2113. return color;
  2114. }
  2115. vec3 NeutralToneMapping( vec3 color ) {
  2116. const float StartCompression = 0.8 - 0.04;
  2117. const float Desaturation = 0.15;
  2118. color *= toneMappingExposure;
  2119. float x = min( color.r, min( color.g, color.b ) );
  2120. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2121. color -= offset;
  2122. float peak = max( color.r, max( color.g, color.b ) );
  2123. if ( peak < StartCompression ) return color;
  2124. float d = 1. - StartCompression;
  2125. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2126. color *= newPeak / peak;
  2127. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2128. return mix( color, vec3( newPeak ), g );
  2129. }
  2130. vec3 CustomToneMapping( vec3 color ) { return color; }`,E0e=`#ifdef USE_TRANSMISSION
  2131. material.transmission = transmission;
  2132. material.transmissionAlpha = 1.0;
  2133. material.thickness = thickness;
  2134. material.attenuationDistance = attenuationDistance;
  2135. material.attenuationColor = attenuationColor;
  2136. #ifdef USE_TRANSMISSIONMAP
  2137. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2138. #endif
  2139. #ifdef USE_THICKNESSMAP
  2140. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2141. #endif
  2142. vec3 pos = vWorldPosition;
  2143. vec3 v = normalize( cameraPosition - pos );
  2144. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2145. vec4 transmitted = getIBLVolumeRefraction(
  2146. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2147. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2148. material.attenuationColor, material.attenuationDistance );
  2149. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2150. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2151. #endif`,D0e=`#ifdef USE_TRANSMISSION
  2152. uniform float transmission;
  2153. uniform float thickness;
  2154. uniform float attenuationDistance;
  2155. uniform vec3 attenuationColor;
  2156. #ifdef USE_TRANSMISSIONMAP
  2157. uniform sampler2D transmissionMap;
  2158. #endif
  2159. #ifdef USE_THICKNESSMAP
  2160. uniform sampler2D thicknessMap;
  2161. #endif
  2162. uniform vec2 transmissionSamplerSize;
  2163. uniform sampler2D transmissionSamplerMap;
  2164. uniform mat4 modelMatrix;
  2165. uniform mat4 projectionMatrix;
  2166. varying vec3 vWorldPosition;
  2167. float w0( float a ) {
  2168. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2169. }
  2170. float w1( float a ) {
  2171. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2172. }
  2173. float w2( float a ){
  2174. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2175. }
  2176. float w3( float a ) {
  2177. return ( 1.0 / 6.0 ) * ( a * a * a );
  2178. }
  2179. float g0( float a ) {
  2180. return w0( a ) + w1( a );
  2181. }
  2182. float g1( float a ) {
  2183. return w2( a ) + w3( a );
  2184. }
  2185. float h0( float a ) {
  2186. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2187. }
  2188. float h1( float a ) {
  2189. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2190. }
  2191. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2192. uv = uv * texelSize.zw + 0.5;
  2193. vec2 iuv = floor( uv );
  2194. vec2 fuv = fract( uv );
  2195. float g0x = g0( fuv.x );
  2196. float g1x = g1( fuv.x );
  2197. float h0x = h0( fuv.x );
  2198. float h1x = h1( fuv.x );
  2199. float h0y = h0( fuv.y );
  2200. float h1y = h1( fuv.y );
  2201. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2202. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2203. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2204. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2205. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2206. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2207. }
  2208. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2209. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2210. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2211. vec2 fLodSizeInv = 1.0 / fLodSize;
  2212. vec2 cLodSizeInv = 1.0 / cLodSize;
  2213. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2214. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2215. return mix( fSample, cSample, fract( lod ) );
  2216. }
  2217. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2218. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2219. vec3 modelScale;
  2220. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2221. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2222. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2223. return normalize( refractionVector ) * thickness * modelScale;
  2224. }
  2225. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2226. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2227. }
  2228. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2229. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2230. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2231. }
  2232. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2233. if ( isinf( attenuationDistance ) ) {
  2234. return vec3( 1.0 );
  2235. } else {
  2236. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2237. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2238. }
  2239. }
  2240. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2241. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2242. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2243. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2244. vec4 transmittedLight;
  2245. vec3 transmittance;
  2246. #ifdef USE_DISPERSION
  2247. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2248. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2249. for ( int i = 0; i < 3; i ++ ) {
  2250. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2251. vec3 refractedRayExit = position + transmissionRay;
  2252. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2253. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2254. refractionCoords += 1.0;
  2255. refractionCoords /= 2.0;
  2256. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2257. transmittedLight[ i ] = transmissionSample[ i ];
  2258. transmittedLight.a += transmissionSample.a;
  2259. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2260. }
  2261. transmittedLight.a /= 3.0;
  2262. #else
  2263. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2264. vec3 refractedRayExit = position + transmissionRay;
  2265. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2266. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2267. refractionCoords += 1.0;
  2268. refractionCoords /= 2.0;
  2269. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2270. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2271. #endif
  2272. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2273. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2274. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2275. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2276. }
  2277. #endif`,R0e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2278. varying vec2 vUv;
  2279. #endif
  2280. #ifdef USE_MAP
  2281. varying vec2 vMapUv;
  2282. #endif
  2283. #ifdef USE_ALPHAMAP
  2284. varying vec2 vAlphaMapUv;
  2285. #endif
  2286. #ifdef USE_LIGHTMAP
  2287. varying vec2 vLightMapUv;
  2288. #endif
  2289. #ifdef USE_AOMAP
  2290. varying vec2 vAoMapUv;
  2291. #endif
  2292. #ifdef USE_BUMPMAP
  2293. varying vec2 vBumpMapUv;
  2294. #endif
  2295. #ifdef USE_NORMALMAP
  2296. varying vec2 vNormalMapUv;
  2297. #endif
  2298. #ifdef USE_EMISSIVEMAP
  2299. varying vec2 vEmissiveMapUv;
  2300. #endif
  2301. #ifdef USE_METALNESSMAP
  2302. varying vec2 vMetalnessMapUv;
  2303. #endif
  2304. #ifdef USE_ROUGHNESSMAP
  2305. varying vec2 vRoughnessMapUv;
  2306. #endif
  2307. #ifdef USE_ANISOTROPYMAP
  2308. varying vec2 vAnisotropyMapUv;
  2309. #endif
  2310. #ifdef USE_CLEARCOATMAP
  2311. varying vec2 vClearcoatMapUv;
  2312. #endif
  2313. #ifdef USE_CLEARCOAT_NORMALMAP
  2314. varying vec2 vClearcoatNormalMapUv;
  2315. #endif
  2316. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2317. varying vec2 vClearcoatRoughnessMapUv;
  2318. #endif
  2319. #ifdef USE_IRIDESCENCEMAP
  2320. varying vec2 vIridescenceMapUv;
  2321. #endif
  2322. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2323. varying vec2 vIridescenceThicknessMapUv;
  2324. #endif
  2325. #ifdef USE_SHEEN_COLORMAP
  2326. varying vec2 vSheenColorMapUv;
  2327. #endif
  2328. #ifdef USE_SHEEN_ROUGHNESSMAP
  2329. varying vec2 vSheenRoughnessMapUv;
  2330. #endif
  2331. #ifdef USE_SPECULARMAP
  2332. varying vec2 vSpecularMapUv;
  2333. #endif
  2334. #ifdef USE_SPECULAR_COLORMAP
  2335. varying vec2 vSpecularColorMapUv;
  2336. #endif
  2337. #ifdef USE_SPECULAR_INTENSITYMAP
  2338. varying vec2 vSpecularIntensityMapUv;
  2339. #endif
  2340. #ifdef USE_TRANSMISSIONMAP
  2341. uniform mat3 transmissionMapTransform;
  2342. varying vec2 vTransmissionMapUv;
  2343. #endif
  2344. #ifdef USE_THICKNESSMAP
  2345. uniform mat3 thicknessMapTransform;
  2346. varying vec2 vThicknessMapUv;
  2347. #endif`,F0e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2348. varying vec2 vUv;
  2349. #endif
  2350. #ifdef USE_MAP
  2351. uniform mat3 mapTransform;
  2352. varying vec2 vMapUv;
  2353. #endif
  2354. #ifdef USE_ALPHAMAP
  2355. uniform mat3 alphaMapTransform;
  2356. varying vec2 vAlphaMapUv;
  2357. #endif
  2358. #ifdef USE_LIGHTMAP
  2359. uniform mat3 lightMapTransform;
  2360. varying vec2 vLightMapUv;
  2361. #endif
  2362. #ifdef USE_AOMAP
  2363. uniform mat3 aoMapTransform;
  2364. varying vec2 vAoMapUv;
  2365. #endif
  2366. #ifdef USE_BUMPMAP
  2367. uniform mat3 bumpMapTransform;
  2368. varying vec2 vBumpMapUv;
  2369. #endif
  2370. #ifdef USE_NORMALMAP
  2371. uniform mat3 normalMapTransform;
  2372. varying vec2 vNormalMapUv;
  2373. #endif
  2374. #ifdef USE_DISPLACEMENTMAP
  2375. uniform mat3 displacementMapTransform;
  2376. varying vec2 vDisplacementMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. uniform mat3 emissiveMapTransform;
  2380. varying vec2 vEmissiveMapUv;
  2381. #endif
  2382. #ifdef USE_METALNESSMAP
  2383. uniform mat3 metalnessMapTransform;
  2384. varying vec2 vMetalnessMapUv;
  2385. #endif
  2386. #ifdef USE_ROUGHNESSMAP
  2387. uniform mat3 roughnessMapTransform;
  2388. varying vec2 vRoughnessMapUv;
  2389. #endif
  2390. #ifdef USE_ANISOTROPYMAP
  2391. uniform mat3 anisotropyMapTransform;
  2392. varying vec2 vAnisotropyMapUv;
  2393. #endif
  2394. #ifdef USE_CLEARCOATMAP
  2395. uniform mat3 clearcoatMapTransform;
  2396. varying vec2 vClearcoatMapUv;
  2397. #endif
  2398. #ifdef USE_CLEARCOAT_NORMALMAP
  2399. uniform mat3 clearcoatNormalMapTransform;
  2400. varying vec2 vClearcoatNormalMapUv;
  2401. #endif
  2402. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2403. uniform mat3 clearcoatRoughnessMapTransform;
  2404. varying vec2 vClearcoatRoughnessMapUv;
  2405. #endif
  2406. #ifdef USE_SHEEN_COLORMAP
  2407. uniform mat3 sheenColorMapTransform;
  2408. varying vec2 vSheenColorMapUv;
  2409. #endif
  2410. #ifdef USE_SHEEN_ROUGHNESSMAP
  2411. uniform mat3 sheenRoughnessMapTransform;
  2412. varying vec2 vSheenRoughnessMapUv;
  2413. #endif
  2414. #ifdef USE_IRIDESCENCEMAP
  2415. uniform mat3 iridescenceMapTransform;
  2416. varying vec2 vIridescenceMapUv;
  2417. #endif
  2418. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2419. uniform mat3 iridescenceThicknessMapTransform;
  2420. varying vec2 vIridescenceThicknessMapUv;
  2421. #endif
  2422. #ifdef USE_SPECULARMAP
  2423. uniform mat3 specularMapTransform;
  2424. varying vec2 vSpecularMapUv;
  2425. #endif
  2426. #ifdef USE_SPECULAR_COLORMAP
  2427. uniform mat3 specularColorMapTransform;
  2428. varying vec2 vSpecularColorMapUv;
  2429. #endif
  2430. #ifdef USE_SPECULAR_INTENSITYMAP
  2431. uniform mat3 specularIntensityMapTransform;
  2432. varying vec2 vSpecularIntensityMapUv;
  2433. #endif
  2434. #ifdef USE_TRANSMISSIONMAP
  2435. uniform mat3 transmissionMapTransform;
  2436. varying vec2 vTransmissionMapUv;
  2437. #endif
  2438. #ifdef USE_THICKNESSMAP
  2439. uniform mat3 thicknessMapTransform;
  2440. varying vec2 vThicknessMapUv;
  2441. #endif`,L0e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2442. vUv = vec3( uv, 1 ).xy;
  2443. #endif
  2444. #ifdef USE_MAP
  2445. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2446. #endif
  2447. #ifdef USE_ALPHAMAP
  2448. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2449. #endif
  2450. #ifdef USE_LIGHTMAP
  2451. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2452. #endif
  2453. #ifdef USE_AOMAP
  2454. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2455. #endif
  2456. #ifdef USE_BUMPMAP
  2457. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2458. #endif
  2459. #ifdef USE_NORMALMAP
  2460. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2461. #endif
  2462. #ifdef USE_DISPLACEMENTMAP
  2463. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2464. #endif
  2465. #ifdef USE_EMISSIVEMAP
  2466. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2467. #endif
  2468. #ifdef USE_METALNESSMAP
  2469. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2470. #endif
  2471. #ifdef USE_ROUGHNESSMAP
  2472. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2473. #endif
  2474. #ifdef USE_ANISOTROPYMAP
  2475. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2476. #endif
  2477. #ifdef USE_CLEARCOATMAP
  2478. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2479. #endif
  2480. #ifdef USE_CLEARCOAT_NORMALMAP
  2481. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2482. #endif
  2483. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2484. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2485. #endif
  2486. #ifdef USE_IRIDESCENCEMAP
  2487. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2488. #endif
  2489. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2490. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2491. #endif
  2492. #ifdef USE_SHEEN_COLORMAP
  2493. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2494. #endif
  2495. #ifdef USE_SHEEN_ROUGHNESSMAP
  2496. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2497. #endif
  2498. #ifdef USE_SPECULARMAP
  2499. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2500. #endif
  2501. #ifdef USE_SPECULAR_COLORMAP
  2502. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2503. #endif
  2504. #ifdef USE_SPECULAR_INTENSITYMAP
  2505. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2506. #endif
  2507. #ifdef USE_TRANSMISSIONMAP
  2508. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2509. #endif
  2510. #ifdef USE_THICKNESSMAP
  2511. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2512. #endif`,O0e=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2513. vec4 worldPosition = vec4( transformed, 1.0 );
  2514. #ifdef USE_BATCHING
  2515. worldPosition = batchingMatrix * worldPosition;
  2516. #endif
  2517. #ifdef USE_INSTANCING
  2518. worldPosition = instanceMatrix * worldPosition;
  2519. #endif
  2520. worldPosition = modelMatrix * worldPosition;
  2521. #endif`;const I0e=`varying vec2 vUv;
  2522. uniform mat3 uvTransform;
  2523. void main() {
  2524. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2525. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2526. }`,z0e=`uniform sampler2D t2D;
  2527. uniform float backgroundIntensity;
  2528. varying vec2 vUv;
  2529. void main() {
  2530. vec4 texColor = texture2D( t2D, vUv );
  2531. #ifdef DECODE_VIDEO_TEXTURE
  2532. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  2533. #endif
  2534. texColor.rgb *= backgroundIntensity;
  2535. gl_FragColor = texColor;
  2536. #include <tonemapping_fragment>
  2537. #include <colorspace_fragment>
  2538. }`,U0e=`varying vec3 vWorldDirection;
  2539. #include <common>
  2540. void main() {
  2541. vWorldDirection = transformDirection( position, modelMatrix );
  2542. #include <begin_vertex>
  2543. #include <project_vertex>
  2544. gl_Position.z = gl_Position.w;
  2545. }`,B0e=`#ifdef ENVMAP_TYPE_CUBE
  2546. uniform samplerCube envMap;
  2547. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2548. uniform sampler2D envMap;
  2549. #endif
  2550. uniform float flipEnvMap;
  2551. uniform float backgroundBlurriness;
  2552. uniform float backgroundIntensity;
  2553. uniform mat3 backgroundRotation;
  2554. varying vec3 vWorldDirection;
  2555. #include <cube_uv_reflection_fragment>
  2556. void main() {
  2557. #ifdef ENVMAP_TYPE_CUBE
  2558. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2559. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2560. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2561. #else
  2562. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2563. #endif
  2564. texColor.rgb *= backgroundIntensity;
  2565. gl_FragColor = texColor;
  2566. #include <tonemapping_fragment>
  2567. #include <colorspace_fragment>
  2568. }`,H0e=`varying vec3 vWorldDirection;
  2569. #include <common>
  2570. void main() {
  2571. vWorldDirection = transformDirection( position, modelMatrix );
  2572. #include <begin_vertex>
  2573. #include <project_vertex>
  2574. gl_Position.z = gl_Position.w;
  2575. }`,$0e=`uniform samplerCube tCube;
  2576. uniform float tFlip;
  2577. uniform float opacity;
  2578. varying vec3 vWorldDirection;
  2579. void main() {
  2580. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2581. gl_FragColor = texColor;
  2582. gl_FragColor.a *= opacity;
  2583. #include <tonemapping_fragment>
  2584. #include <colorspace_fragment>
  2585. }`,V0e=`#include <common>
  2586. #include <batching_pars_vertex>
  2587. #include <uv_pars_vertex>
  2588. #include <displacementmap_pars_vertex>
  2589. #include <morphtarget_pars_vertex>
  2590. #include <skinning_pars_vertex>
  2591. #include <logdepthbuf_pars_vertex>
  2592. #include <clipping_planes_pars_vertex>
  2593. varying vec2 vHighPrecisionZW;
  2594. void main() {
  2595. #include <uv_vertex>
  2596. #include <batching_vertex>
  2597. #include <skinbase_vertex>
  2598. #include <morphinstance_vertex>
  2599. #ifdef USE_DISPLACEMENTMAP
  2600. #include <beginnormal_vertex>
  2601. #include <morphnormal_vertex>
  2602. #include <skinnormal_vertex>
  2603. #endif
  2604. #include <begin_vertex>
  2605. #include <morphtarget_vertex>
  2606. #include <skinning_vertex>
  2607. #include <displacementmap_vertex>
  2608. #include <project_vertex>
  2609. #include <logdepthbuf_vertex>
  2610. #include <clipping_planes_vertex>
  2611. vHighPrecisionZW = gl_Position.zw;
  2612. }`,q0e=`#if DEPTH_PACKING == 3200
  2613. uniform float opacity;
  2614. #endif
  2615. #include <common>
  2616. #include <packing>
  2617. #include <uv_pars_fragment>
  2618. #include <map_pars_fragment>
  2619. #include <alphamap_pars_fragment>
  2620. #include <alphatest_pars_fragment>
  2621. #include <alphahash_pars_fragment>
  2622. #include <logdepthbuf_pars_fragment>
  2623. #include <clipping_planes_pars_fragment>
  2624. varying vec2 vHighPrecisionZW;
  2625. void main() {
  2626. vec4 diffuseColor = vec4( 1.0 );
  2627. #include <clipping_planes_fragment>
  2628. #if DEPTH_PACKING == 3200
  2629. diffuseColor.a = opacity;
  2630. #endif
  2631. #include <map_fragment>
  2632. #include <alphamap_fragment>
  2633. #include <alphatest_fragment>
  2634. #include <alphahash_fragment>
  2635. #include <logdepthbuf_fragment>
  2636. #ifdef USE_REVERSED_DEPTH_BUFFER
  2637. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2638. #else
  2639. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2640. #endif
  2641. #if DEPTH_PACKING == 3200
  2642. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2643. #elif DEPTH_PACKING == 3201
  2644. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2645. #elif DEPTH_PACKING == 3202
  2646. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2647. #elif DEPTH_PACKING == 3203
  2648. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2649. #endif
  2650. }`,G0e=`#define DISTANCE
  2651. varying vec3 vWorldPosition;
  2652. #include <common>
  2653. #include <batching_pars_vertex>
  2654. #include <uv_pars_vertex>
  2655. #include <displacementmap_pars_vertex>
  2656. #include <morphtarget_pars_vertex>
  2657. #include <skinning_pars_vertex>
  2658. #include <clipping_planes_pars_vertex>
  2659. void main() {
  2660. #include <uv_vertex>
  2661. #include <batching_vertex>
  2662. #include <skinbase_vertex>
  2663. #include <morphinstance_vertex>
  2664. #ifdef USE_DISPLACEMENTMAP
  2665. #include <beginnormal_vertex>
  2666. #include <morphnormal_vertex>
  2667. #include <skinnormal_vertex>
  2668. #endif
  2669. #include <begin_vertex>
  2670. #include <morphtarget_vertex>
  2671. #include <skinning_vertex>
  2672. #include <displacementmap_vertex>
  2673. #include <project_vertex>
  2674. #include <worldpos_vertex>
  2675. #include <clipping_planes_vertex>
  2676. vWorldPosition = worldPosition.xyz;
  2677. }`,W0e=`#define DISTANCE
  2678. uniform vec3 referencePosition;
  2679. uniform float nearDistance;
  2680. uniform float farDistance;
  2681. varying vec3 vWorldPosition;
  2682. #include <common>
  2683. #include <packing>
  2684. #include <uv_pars_fragment>
  2685. #include <map_pars_fragment>
  2686. #include <alphamap_pars_fragment>
  2687. #include <alphatest_pars_fragment>
  2688. #include <alphahash_pars_fragment>
  2689. #include <clipping_planes_pars_fragment>
  2690. void main () {
  2691. vec4 diffuseColor = vec4( 1.0 );
  2692. #include <clipping_planes_fragment>
  2693. #include <map_fragment>
  2694. #include <alphamap_fragment>
  2695. #include <alphatest_fragment>
  2696. #include <alphahash_fragment>
  2697. float dist = length( vWorldPosition - referencePosition );
  2698. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2699. dist = saturate( dist );
  2700. gl_FragColor = packDepthToRGBA( dist );
  2701. }`,K0e=`varying vec3 vWorldDirection;
  2702. #include <common>
  2703. void main() {
  2704. vWorldDirection = transformDirection( position, modelMatrix );
  2705. #include <begin_vertex>
  2706. #include <project_vertex>
  2707. }`,Y0e=`uniform sampler2D tEquirect;
  2708. varying vec3 vWorldDirection;
  2709. #include <common>
  2710. void main() {
  2711. vec3 direction = normalize( vWorldDirection );
  2712. vec2 sampleUV = equirectUv( direction );
  2713. gl_FragColor = texture2D( tEquirect, sampleUV );
  2714. #include <tonemapping_fragment>
  2715. #include <colorspace_fragment>
  2716. }`,X0e=`uniform float scale;
  2717. attribute float lineDistance;
  2718. varying float vLineDistance;
  2719. #include <common>
  2720. #include <uv_pars_vertex>
  2721. #include <color_pars_vertex>
  2722. #include <fog_pars_vertex>
  2723. #include <morphtarget_pars_vertex>
  2724. #include <logdepthbuf_pars_vertex>
  2725. #include <clipping_planes_pars_vertex>
  2726. void main() {
  2727. vLineDistance = scale * lineDistance;
  2728. #include <uv_vertex>
  2729. #include <color_vertex>
  2730. #include <morphinstance_vertex>
  2731. #include <morphcolor_vertex>
  2732. #include <begin_vertex>
  2733. #include <morphtarget_vertex>
  2734. #include <project_vertex>
  2735. #include <logdepthbuf_vertex>
  2736. #include <clipping_planes_vertex>
  2737. #include <fog_vertex>
  2738. }`,Q0e=`uniform vec3 diffuse;
  2739. uniform float opacity;
  2740. uniform float dashSize;
  2741. uniform float totalSize;
  2742. varying float vLineDistance;
  2743. #include <common>
  2744. #include <color_pars_fragment>
  2745. #include <uv_pars_fragment>
  2746. #include <map_pars_fragment>
  2747. #include <fog_pars_fragment>
  2748. #include <logdepthbuf_pars_fragment>
  2749. #include <clipping_planes_pars_fragment>
  2750. void main() {
  2751. vec4 diffuseColor = vec4( diffuse, opacity );
  2752. #include <clipping_planes_fragment>
  2753. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2754. discard;
  2755. }
  2756. vec3 outgoingLight = vec3( 0.0 );
  2757. #include <logdepthbuf_fragment>
  2758. #include <map_fragment>
  2759. #include <color_fragment>
  2760. outgoingLight = diffuseColor.rgb;
  2761. #include <opaque_fragment>
  2762. #include <tonemapping_fragment>
  2763. #include <colorspace_fragment>
  2764. #include <fog_fragment>
  2765. #include <premultiplied_alpha_fragment>
  2766. }`,Z0e=`#include <common>
  2767. #include <batching_pars_vertex>
  2768. #include <uv_pars_vertex>
  2769. #include <envmap_pars_vertex>
  2770. #include <color_pars_vertex>
  2771. #include <fog_pars_vertex>
  2772. #include <morphtarget_pars_vertex>
  2773. #include <skinning_pars_vertex>
  2774. #include <logdepthbuf_pars_vertex>
  2775. #include <clipping_planes_pars_vertex>
  2776. void main() {
  2777. #include <uv_vertex>
  2778. #include <color_vertex>
  2779. #include <morphinstance_vertex>
  2780. #include <morphcolor_vertex>
  2781. #include <batching_vertex>
  2782. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2783. #include <beginnormal_vertex>
  2784. #include <morphnormal_vertex>
  2785. #include <skinbase_vertex>
  2786. #include <skinnormal_vertex>
  2787. #include <defaultnormal_vertex>
  2788. #endif
  2789. #include <begin_vertex>
  2790. #include <morphtarget_vertex>
  2791. #include <skinning_vertex>
  2792. #include <project_vertex>
  2793. #include <logdepthbuf_vertex>
  2794. #include <clipping_planes_vertex>
  2795. #include <worldpos_vertex>
  2796. #include <envmap_vertex>
  2797. #include <fog_vertex>
  2798. }`,J0e=`uniform vec3 diffuse;
  2799. uniform float opacity;
  2800. #ifndef FLAT_SHADED
  2801. varying vec3 vNormal;
  2802. #endif
  2803. #include <common>
  2804. #include <dithering_pars_fragment>
  2805. #include <color_pars_fragment>
  2806. #include <uv_pars_fragment>
  2807. #include <map_pars_fragment>
  2808. #include <alphamap_pars_fragment>
  2809. #include <alphatest_pars_fragment>
  2810. #include <alphahash_pars_fragment>
  2811. #include <aomap_pars_fragment>
  2812. #include <lightmap_pars_fragment>
  2813. #include <envmap_common_pars_fragment>
  2814. #include <envmap_pars_fragment>
  2815. #include <fog_pars_fragment>
  2816. #include <specularmap_pars_fragment>
  2817. #include <logdepthbuf_pars_fragment>
  2818. #include <clipping_planes_pars_fragment>
  2819. void main() {
  2820. vec4 diffuseColor = vec4( diffuse, opacity );
  2821. #include <clipping_planes_fragment>
  2822. #include <logdepthbuf_fragment>
  2823. #include <map_fragment>
  2824. #include <color_fragment>
  2825. #include <alphamap_fragment>
  2826. #include <alphatest_fragment>
  2827. #include <alphahash_fragment>
  2828. #include <specularmap_fragment>
  2829. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2830. #ifdef USE_LIGHTMAP
  2831. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2832. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2833. #else
  2834. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2835. #endif
  2836. #include <aomap_fragment>
  2837. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2838. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2839. #include <envmap_fragment>
  2840. #include <opaque_fragment>
  2841. #include <tonemapping_fragment>
  2842. #include <colorspace_fragment>
  2843. #include <fog_fragment>
  2844. #include <premultiplied_alpha_fragment>
  2845. #include <dithering_fragment>
  2846. }`,eve=`#define LAMBERT
  2847. varying vec3 vViewPosition;
  2848. #include <common>
  2849. #include <batching_pars_vertex>
  2850. #include <uv_pars_vertex>
  2851. #include <displacementmap_pars_vertex>
  2852. #include <envmap_pars_vertex>
  2853. #include <color_pars_vertex>
  2854. #include <fog_pars_vertex>
  2855. #include <normal_pars_vertex>
  2856. #include <morphtarget_pars_vertex>
  2857. #include <skinning_pars_vertex>
  2858. #include <shadowmap_pars_vertex>
  2859. #include <logdepthbuf_pars_vertex>
  2860. #include <clipping_planes_pars_vertex>
  2861. void main() {
  2862. #include <uv_vertex>
  2863. #include <color_vertex>
  2864. #include <morphinstance_vertex>
  2865. #include <morphcolor_vertex>
  2866. #include <batching_vertex>
  2867. #include <beginnormal_vertex>
  2868. #include <morphnormal_vertex>
  2869. #include <skinbase_vertex>
  2870. #include <skinnormal_vertex>
  2871. #include <defaultnormal_vertex>
  2872. #include <normal_vertex>
  2873. #include <begin_vertex>
  2874. #include <morphtarget_vertex>
  2875. #include <skinning_vertex>
  2876. #include <displacementmap_vertex>
  2877. #include <project_vertex>
  2878. #include <logdepthbuf_vertex>
  2879. #include <clipping_planes_vertex>
  2880. vViewPosition = - mvPosition.xyz;
  2881. #include <worldpos_vertex>
  2882. #include <envmap_vertex>
  2883. #include <shadowmap_vertex>
  2884. #include <fog_vertex>
  2885. }`,tve=`#define LAMBERT
  2886. uniform vec3 diffuse;
  2887. uniform vec3 emissive;
  2888. uniform float opacity;
  2889. #include <common>
  2890. #include <packing>
  2891. #include <dithering_pars_fragment>
  2892. #include <color_pars_fragment>
  2893. #include <uv_pars_fragment>
  2894. #include <map_pars_fragment>
  2895. #include <alphamap_pars_fragment>
  2896. #include <alphatest_pars_fragment>
  2897. #include <alphahash_pars_fragment>
  2898. #include <aomap_pars_fragment>
  2899. #include <lightmap_pars_fragment>
  2900. #include <emissivemap_pars_fragment>
  2901. #include <envmap_common_pars_fragment>
  2902. #include <envmap_pars_fragment>
  2903. #include <fog_pars_fragment>
  2904. #include <bsdfs>
  2905. #include <lights_pars_begin>
  2906. #include <normal_pars_fragment>
  2907. #include <lights_lambert_pars_fragment>
  2908. #include <shadowmap_pars_fragment>
  2909. #include <bumpmap_pars_fragment>
  2910. #include <normalmap_pars_fragment>
  2911. #include <specularmap_pars_fragment>
  2912. #include <logdepthbuf_pars_fragment>
  2913. #include <clipping_planes_pars_fragment>
  2914. void main() {
  2915. vec4 diffuseColor = vec4( diffuse, opacity );
  2916. #include <clipping_planes_fragment>
  2917. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2918. vec3 totalEmissiveRadiance = emissive;
  2919. #include <logdepthbuf_fragment>
  2920. #include <map_fragment>
  2921. #include <color_fragment>
  2922. #include <alphamap_fragment>
  2923. #include <alphatest_fragment>
  2924. #include <alphahash_fragment>
  2925. #include <specularmap_fragment>
  2926. #include <normal_fragment_begin>
  2927. #include <normal_fragment_maps>
  2928. #include <emissivemap_fragment>
  2929. #include <lights_lambert_fragment>
  2930. #include <lights_fragment_begin>
  2931. #include <lights_fragment_maps>
  2932. #include <lights_fragment_end>
  2933. #include <aomap_fragment>
  2934. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2935. #include <envmap_fragment>
  2936. #include <opaque_fragment>
  2937. #include <tonemapping_fragment>
  2938. #include <colorspace_fragment>
  2939. #include <fog_fragment>
  2940. #include <premultiplied_alpha_fragment>
  2941. #include <dithering_fragment>
  2942. }`,nve=`#define MATCAP
  2943. varying vec3 vViewPosition;
  2944. #include <common>
  2945. #include <batching_pars_vertex>
  2946. #include <uv_pars_vertex>
  2947. #include <color_pars_vertex>
  2948. #include <displacementmap_pars_vertex>
  2949. #include <fog_pars_vertex>
  2950. #include <normal_pars_vertex>
  2951. #include <morphtarget_pars_vertex>
  2952. #include <skinning_pars_vertex>
  2953. #include <logdepthbuf_pars_vertex>
  2954. #include <clipping_planes_pars_vertex>
  2955. void main() {
  2956. #include <uv_vertex>
  2957. #include <color_vertex>
  2958. #include <morphinstance_vertex>
  2959. #include <morphcolor_vertex>
  2960. #include <batching_vertex>
  2961. #include <beginnormal_vertex>
  2962. #include <morphnormal_vertex>
  2963. #include <skinbase_vertex>
  2964. #include <skinnormal_vertex>
  2965. #include <defaultnormal_vertex>
  2966. #include <normal_vertex>
  2967. #include <begin_vertex>
  2968. #include <morphtarget_vertex>
  2969. #include <skinning_vertex>
  2970. #include <displacementmap_vertex>
  2971. #include <project_vertex>
  2972. #include <logdepthbuf_vertex>
  2973. #include <clipping_planes_vertex>
  2974. #include <fog_vertex>
  2975. vViewPosition = - mvPosition.xyz;
  2976. }`,rve=`#define MATCAP
  2977. uniform vec3 diffuse;
  2978. uniform float opacity;
  2979. uniform sampler2D matcap;
  2980. varying vec3 vViewPosition;
  2981. #include <common>
  2982. #include <dithering_pars_fragment>
  2983. #include <color_pars_fragment>
  2984. #include <uv_pars_fragment>
  2985. #include <map_pars_fragment>
  2986. #include <alphamap_pars_fragment>
  2987. #include <alphatest_pars_fragment>
  2988. #include <alphahash_pars_fragment>
  2989. #include <fog_pars_fragment>
  2990. #include <normal_pars_fragment>
  2991. #include <bumpmap_pars_fragment>
  2992. #include <normalmap_pars_fragment>
  2993. #include <logdepthbuf_pars_fragment>
  2994. #include <clipping_planes_pars_fragment>
  2995. void main() {
  2996. vec4 diffuseColor = vec4( diffuse, opacity );
  2997. #include <clipping_planes_fragment>
  2998. #include <logdepthbuf_fragment>
  2999. #include <map_fragment>
  3000. #include <color_fragment>
  3001. #include <alphamap_fragment>
  3002. #include <alphatest_fragment>
  3003. #include <alphahash_fragment>
  3004. #include <normal_fragment_begin>
  3005. #include <normal_fragment_maps>
  3006. vec3 viewDir = normalize( vViewPosition );
  3007. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3008. vec3 y = cross( viewDir, x );
  3009. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3010. #ifdef USE_MATCAP
  3011. vec4 matcapColor = texture2D( matcap, uv );
  3012. #else
  3013. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3014. #endif
  3015. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3016. #include <opaque_fragment>
  3017. #include <tonemapping_fragment>
  3018. #include <colorspace_fragment>
  3019. #include <fog_fragment>
  3020. #include <premultiplied_alpha_fragment>
  3021. #include <dithering_fragment>
  3022. }`,ave=`#define NORMAL
  3023. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3024. varying vec3 vViewPosition;
  3025. #endif
  3026. #include <common>
  3027. #include <batching_pars_vertex>
  3028. #include <uv_pars_vertex>
  3029. #include <displacementmap_pars_vertex>
  3030. #include <normal_pars_vertex>
  3031. #include <morphtarget_pars_vertex>
  3032. #include <skinning_pars_vertex>
  3033. #include <logdepthbuf_pars_vertex>
  3034. #include <clipping_planes_pars_vertex>
  3035. void main() {
  3036. #include <uv_vertex>
  3037. #include <batching_vertex>
  3038. #include <beginnormal_vertex>
  3039. #include <morphinstance_vertex>
  3040. #include <morphnormal_vertex>
  3041. #include <skinbase_vertex>
  3042. #include <skinnormal_vertex>
  3043. #include <defaultnormal_vertex>
  3044. #include <normal_vertex>
  3045. #include <begin_vertex>
  3046. #include <morphtarget_vertex>
  3047. #include <skinning_vertex>
  3048. #include <displacementmap_vertex>
  3049. #include <project_vertex>
  3050. #include <logdepthbuf_vertex>
  3051. #include <clipping_planes_vertex>
  3052. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3053. vViewPosition = - mvPosition.xyz;
  3054. #endif
  3055. }`,ive=`#define NORMAL
  3056. uniform float opacity;
  3057. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3058. varying vec3 vViewPosition;
  3059. #endif
  3060. #include <packing>
  3061. #include <uv_pars_fragment>
  3062. #include <normal_pars_fragment>
  3063. #include <bumpmap_pars_fragment>
  3064. #include <normalmap_pars_fragment>
  3065. #include <logdepthbuf_pars_fragment>
  3066. #include <clipping_planes_pars_fragment>
  3067. void main() {
  3068. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3069. #include <clipping_planes_fragment>
  3070. #include <logdepthbuf_fragment>
  3071. #include <normal_fragment_begin>
  3072. #include <normal_fragment_maps>
  3073. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3074. #ifdef OPAQUE
  3075. gl_FragColor.a = 1.0;
  3076. #endif
  3077. }`,sve=`#define PHONG
  3078. varying vec3 vViewPosition;
  3079. #include <common>
  3080. #include <batching_pars_vertex>
  3081. #include <uv_pars_vertex>
  3082. #include <displacementmap_pars_vertex>
  3083. #include <envmap_pars_vertex>
  3084. #include <color_pars_vertex>
  3085. #include <fog_pars_vertex>
  3086. #include <normal_pars_vertex>
  3087. #include <morphtarget_pars_vertex>
  3088. #include <skinning_pars_vertex>
  3089. #include <shadowmap_pars_vertex>
  3090. #include <logdepthbuf_pars_vertex>
  3091. #include <clipping_planes_pars_vertex>
  3092. void main() {
  3093. #include <uv_vertex>
  3094. #include <color_vertex>
  3095. #include <morphcolor_vertex>
  3096. #include <batching_vertex>
  3097. #include <beginnormal_vertex>
  3098. #include <morphinstance_vertex>
  3099. #include <morphnormal_vertex>
  3100. #include <skinbase_vertex>
  3101. #include <skinnormal_vertex>
  3102. #include <defaultnormal_vertex>
  3103. #include <normal_vertex>
  3104. #include <begin_vertex>
  3105. #include <morphtarget_vertex>
  3106. #include <skinning_vertex>
  3107. #include <displacementmap_vertex>
  3108. #include <project_vertex>
  3109. #include <logdepthbuf_vertex>
  3110. #include <clipping_planes_vertex>
  3111. vViewPosition = - mvPosition.xyz;
  3112. #include <worldpos_vertex>
  3113. #include <envmap_vertex>
  3114. #include <shadowmap_vertex>
  3115. #include <fog_vertex>
  3116. }`,ove=`#define PHONG
  3117. uniform vec3 diffuse;
  3118. uniform vec3 emissive;
  3119. uniform vec3 specular;
  3120. uniform float shininess;
  3121. uniform float opacity;
  3122. #include <common>
  3123. #include <packing>
  3124. #include <dithering_pars_fragment>
  3125. #include <color_pars_fragment>
  3126. #include <uv_pars_fragment>
  3127. #include <map_pars_fragment>
  3128. #include <alphamap_pars_fragment>
  3129. #include <alphatest_pars_fragment>
  3130. #include <alphahash_pars_fragment>
  3131. #include <aomap_pars_fragment>
  3132. #include <lightmap_pars_fragment>
  3133. #include <emissivemap_pars_fragment>
  3134. #include <envmap_common_pars_fragment>
  3135. #include <envmap_pars_fragment>
  3136. #include <fog_pars_fragment>
  3137. #include <bsdfs>
  3138. #include <lights_pars_begin>
  3139. #include <normal_pars_fragment>
  3140. #include <lights_phong_pars_fragment>
  3141. #include <shadowmap_pars_fragment>
  3142. #include <bumpmap_pars_fragment>
  3143. #include <normalmap_pars_fragment>
  3144. #include <specularmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( diffuse, opacity );
  3149. #include <clipping_planes_fragment>
  3150. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3151. vec3 totalEmissiveRadiance = emissive;
  3152. #include <logdepthbuf_fragment>
  3153. #include <map_fragment>
  3154. #include <color_fragment>
  3155. #include <alphamap_fragment>
  3156. #include <alphatest_fragment>
  3157. #include <alphahash_fragment>
  3158. #include <specularmap_fragment>
  3159. #include <normal_fragment_begin>
  3160. #include <normal_fragment_maps>
  3161. #include <emissivemap_fragment>
  3162. #include <lights_phong_fragment>
  3163. #include <lights_fragment_begin>
  3164. #include <lights_fragment_maps>
  3165. #include <lights_fragment_end>
  3166. #include <aomap_fragment>
  3167. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3168. #include <envmap_fragment>
  3169. #include <opaque_fragment>
  3170. #include <tonemapping_fragment>
  3171. #include <colorspace_fragment>
  3172. #include <fog_fragment>
  3173. #include <premultiplied_alpha_fragment>
  3174. #include <dithering_fragment>
  3175. }`,lve=`#define STANDARD
  3176. varying vec3 vViewPosition;
  3177. #ifdef USE_TRANSMISSION
  3178. varying vec3 vWorldPosition;
  3179. #endif
  3180. #include <common>
  3181. #include <batching_pars_vertex>
  3182. #include <uv_pars_vertex>
  3183. #include <displacementmap_pars_vertex>
  3184. #include <color_pars_vertex>
  3185. #include <fog_pars_vertex>
  3186. #include <normal_pars_vertex>
  3187. #include <morphtarget_pars_vertex>
  3188. #include <skinning_pars_vertex>
  3189. #include <shadowmap_pars_vertex>
  3190. #include <logdepthbuf_pars_vertex>
  3191. #include <clipping_planes_pars_vertex>
  3192. void main() {
  3193. #include <uv_vertex>
  3194. #include <color_vertex>
  3195. #include <morphinstance_vertex>
  3196. #include <morphcolor_vertex>
  3197. #include <batching_vertex>
  3198. #include <beginnormal_vertex>
  3199. #include <morphnormal_vertex>
  3200. #include <skinbase_vertex>
  3201. #include <skinnormal_vertex>
  3202. #include <defaultnormal_vertex>
  3203. #include <normal_vertex>
  3204. #include <begin_vertex>
  3205. #include <morphtarget_vertex>
  3206. #include <skinning_vertex>
  3207. #include <displacementmap_vertex>
  3208. #include <project_vertex>
  3209. #include <logdepthbuf_vertex>
  3210. #include <clipping_planes_vertex>
  3211. vViewPosition = - mvPosition.xyz;
  3212. #include <worldpos_vertex>
  3213. #include <shadowmap_vertex>
  3214. #include <fog_vertex>
  3215. #ifdef USE_TRANSMISSION
  3216. vWorldPosition = worldPosition.xyz;
  3217. #endif
  3218. }`,cve=`#define STANDARD
  3219. #ifdef PHYSICAL
  3220. #define IOR
  3221. #define USE_SPECULAR
  3222. #endif
  3223. uniform vec3 diffuse;
  3224. uniform vec3 emissive;
  3225. uniform float roughness;
  3226. uniform float metalness;
  3227. uniform float opacity;
  3228. #ifdef IOR
  3229. uniform float ior;
  3230. #endif
  3231. #ifdef USE_SPECULAR
  3232. uniform float specularIntensity;
  3233. uniform vec3 specularColor;
  3234. #ifdef USE_SPECULAR_COLORMAP
  3235. uniform sampler2D specularColorMap;
  3236. #endif
  3237. #ifdef USE_SPECULAR_INTENSITYMAP
  3238. uniform sampler2D specularIntensityMap;
  3239. #endif
  3240. #endif
  3241. #ifdef USE_CLEARCOAT
  3242. uniform float clearcoat;
  3243. uniform float clearcoatRoughness;
  3244. #endif
  3245. #ifdef USE_DISPERSION
  3246. uniform float dispersion;
  3247. #endif
  3248. #ifdef USE_IRIDESCENCE
  3249. uniform float iridescence;
  3250. uniform float iridescenceIOR;
  3251. uniform float iridescenceThicknessMinimum;
  3252. uniform float iridescenceThicknessMaximum;
  3253. #endif
  3254. #ifdef USE_SHEEN
  3255. uniform vec3 sheenColor;
  3256. uniform float sheenRoughness;
  3257. #ifdef USE_SHEEN_COLORMAP
  3258. uniform sampler2D sheenColorMap;
  3259. #endif
  3260. #ifdef USE_SHEEN_ROUGHNESSMAP
  3261. uniform sampler2D sheenRoughnessMap;
  3262. #endif
  3263. #endif
  3264. #ifdef USE_ANISOTROPY
  3265. uniform vec2 anisotropyVector;
  3266. #ifdef USE_ANISOTROPYMAP
  3267. uniform sampler2D anisotropyMap;
  3268. #endif
  3269. #endif
  3270. varying vec3 vViewPosition;
  3271. #include <common>
  3272. #include <packing>
  3273. #include <dithering_pars_fragment>
  3274. #include <color_pars_fragment>
  3275. #include <uv_pars_fragment>
  3276. #include <map_pars_fragment>
  3277. #include <alphamap_pars_fragment>
  3278. #include <alphatest_pars_fragment>
  3279. #include <alphahash_pars_fragment>
  3280. #include <aomap_pars_fragment>
  3281. #include <lightmap_pars_fragment>
  3282. #include <emissivemap_pars_fragment>
  3283. #include <iridescence_fragment>
  3284. #include <cube_uv_reflection_fragment>
  3285. #include <envmap_common_pars_fragment>
  3286. #include <envmap_physical_pars_fragment>
  3287. #include <fog_pars_fragment>
  3288. #include <lights_pars_begin>
  3289. #include <normal_pars_fragment>
  3290. #include <lights_physical_pars_fragment>
  3291. #include <transmission_pars_fragment>
  3292. #include <shadowmap_pars_fragment>
  3293. #include <bumpmap_pars_fragment>
  3294. #include <normalmap_pars_fragment>
  3295. #include <clearcoat_pars_fragment>
  3296. #include <iridescence_pars_fragment>
  3297. #include <roughnessmap_pars_fragment>
  3298. #include <metalnessmap_pars_fragment>
  3299. #include <logdepthbuf_pars_fragment>
  3300. #include <clipping_planes_pars_fragment>
  3301. void main() {
  3302. vec4 diffuseColor = vec4( diffuse, opacity );
  3303. #include <clipping_planes_fragment>
  3304. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3305. vec3 totalEmissiveRadiance = emissive;
  3306. #include <logdepthbuf_fragment>
  3307. #include <map_fragment>
  3308. #include <color_fragment>
  3309. #include <alphamap_fragment>
  3310. #include <alphatest_fragment>
  3311. #include <alphahash_fragment>
  3312. #include <roughnessmap_fragment>
  3313. #include <metalnessmap_fragment>
  3314. #include <normal_fragment_begin>
  3315. #include <normal_fragment_maps>
  3316. #include <clearcoat_normal_fragment_begin>
  3317. #include <clearcoat_normal_fragment_maps>
  3318. #include <emissivemap_fragment>
  3319. #include <lights_physical_fragment>
  3320. #include <lights_fragment_begin>
  3321. #include <lights_fragment_maps>
  3322. #include <lights_fragment_end>
  3323. #include <aomap_fragment>
  3324. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3325. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3326. #include <transmission_fragment>
  3327. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3328. #ifdef USE_SHEEN
  3329. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3330. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3331. #endif
  3332. #ifdef USE_CLEARCOAT
  3333. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3334. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3335. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3336. #endif
  3337. #include <opaque_fragment>
  3338. #include <tonemapping_fragment>
  3339. #include <colorspace_fragment>
  3340. #include <fog_fragment>
  3341. #include <premultiplied_alpha_fragment>
  3342. #include <dithering_fragment>
  3343. }`,uve=`#define TOON
  3344. varying vec3 vViewPosition;
  3345. #include <common>
  3346. #include <batching_pars_vertex>
  3347. #include <uv_pars_vertex>
  3348. #include <displacementmap_pars_vertex>
  3349. #include <color_pars_vertex>
  3350. #include <fog_pars_vertex>
  3351. #include <normal_pars_vertex>
  3352. #include <morphtarget_pars_vertex>
  3353. #include <skinning_pars_vertex>
  3354. #include <shadowmap_pars_vertex>
  3355. #include <logdepthbuf_pars_vertex>
  3356. #include <clipping_planes_pars_vertex>
  3357. void main() {
  3358. #include <uv_vertex>
  3359. #include <color_vertex>
  3360. #include <morphinstance_vertex>
  3361. #include <morphcolor_vertex>
  3362. #include <batching_vertex>
  3363. #include <beginnormal_vertex>
  3364. #include <morphnormal_vertex>
  3365. #include <skinbase_vertex>
  3366. #include <skinnormal_vertex>
  3367. #include <defaultnormal_vertex>
  3368. #include <normal_vertex>
  3369. #include <begin_vertex>
  3370. #include <morphtarget_vertex>
  3371. #include <skinning_vertex>
  3372. #include <displacementmap_vertex>
  3373. #include <project_vertex>
  3374. #include <logdepthbuf_vertex>
  3375. #include <clipping_planes_vertex>
  3376. vViewPosition = - mvPosition.xyz;
  3377. #include <worldpos_vertex>
  3378. #include <shadowmap_vertex>
  3379. #include <fog_vertex>
  3380. }`,dve=`#define TOON
  3381. uniform vec3 diffuse;
  3382. uniform vec3 emissive;
  3383. uniform float opacity;
  3384. #include <common>
  3385. #include <packing>
  3386. #include <dithering_pars_fragment>
  3387. #include <color_pars_fragment>
  3388. #include <uv_pars_fragment>
  3389. #include <map_pars_fragment>
  3390. #include <alphamap_pars_fragment>
  3391. #include <alphatest_pars_fragment>
  3392. #include <alphahash_pars_fragment>
  3393. #include <aomap_pars_fragment>
  3394. #include <lightmap_pars_fragment>
  3395. #include <emissivemap_pars_fragment>
  3396. #include <gradientmap_pars_fragment>
  3397. #include <fog_pars_fragment>
  3398. #include <bsdfs>
  3399. #include <lights_pars_begin>
  3400. #include <normal_pars_fragment>
  3401. #include <lights_toon_pars_fragment>
  3402. #include <shadowmap_pars_fragment>
  3403. #include <bumpmap_pars_fragment>
  3404. #include <normalmap_pars_fragment>
  3405. #include <logdepthbuf_pars_fragment>
  3406. #include <clipping_planes_pars_fragment>
  3407. void main() {
  3408. vec4 diffuseColor = vec4( diffuse, opacity );
  3409. #include <clipping_planes_fragment>
  3410. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3411. vec3 totalEmissiveRadiance = emissive;
  3412. #include <logdepthbuf_fragment>
  3413. #include <map_fragment>
  3414. #include <color_fragment>
  3415. #include <alphamap_fragment>
  3416. #include <alphatest_fragment>
  3417. #include <alphahash_fragment>
  3418. #include <normal_fragment_begin>
  3419. #include <normal_fragment_maps>
  3420. #include <emissivemap_fragment>
  3421. #include <lights_toon_fragment>
  3422. #include <lights_fragment_begin>
  3423. #include <lights_fragment_maps>
  3424. #include <lights_fragment_end>
  3425. #include <aomap_fragment>
  3426. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3427. #include <opaque_fragment>
  3428. #include <tonemapping_fragment>
  3429. #include <colorspace_fragment>
  3430. #include <fog_fragment>
  3431. #include <premultiplied_alpha_fragment>
  3432. #include <dithering_fragment>
  3433. }`,hve=`uniform float size;
  3434. uniform float scale;
  3435. #include <common>
  3436. #include <color_pars_vertex>
  3437. #include <fog_pars_vertex>
  3438. #include <morphtarget_pars_vertex>
  3439. #include <logdepthbuf_pars_vertex>
  3440. #include <clipping_planes_pars_vertex>
  3441. #ifdef USE_POINTS_UV
  3442. varying vec2 vUv;
  3443. uniform mat3 uvTransform;
  3444. #endif
  3445. void main() {
  3446. #ifdef USE_POINTS_UV
  3447. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3448. #endif
  3449. #include <color_vertex>
  3450. #include <morphinstance_vertex>
  3451. #include <morphcolor_vertex>
  3452. #include <begin_vertex>
  3453. #include <morphtarget_vertex>
  3454. #include <project_vertex>
  3455. gl_PointSize = size;
  3456. #ifdef USE_SIZEATTENUATION
  3457. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3458. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3459. #endif
  3460. #include <logdepthbuf_vertex>
  3461. #include <clipping_planes_vertex>
  3462. #include <worldpos_vertex>
  3463. #include <fog_vertex>
  3464. }`,mve=`uniform vec3 diffuse;
  3465. uniform float opacity;
  3466. #include <common>
  3467. #include <color_pars_fragment>
  3468. #include <map_particle_pars_fragment>
  3469. #include <alphatest_pars_fragment>
  3470. #include <alphahash_pars_fragment>
  3471. #include <fog_pars_fragment>
  3472. #include <logdepthbuf_pars_fragment>
  3473. #include <clipping_planes_pars_fragment>
  3474. void main() {
  3475. vec4 diffuseColor = vec4( diffuse, opacity );
  3476. #include <clipping_planes_fragment>
  3477. vec3 outgoingLight = vec3( 0.0 );
  3478. #include <logdepthbuf_fragment>
  3479. #include <map_particle_fragment>
  3480. #include <color_fragment>
  3481. #include <alphatest_fragment>
  3482. #include <alphahash_fragment>
  3483. outgoingLight = diffuseColor.rgb;
  3484. #include <opaque_fragment>
  3485. #include <tonemapping_fragment>
  3486. #include <colorspace_fragment>
  3487. #include <fog_fragment>
  3488. #include <premultiplied_alpha_fragment>
  3489. }`,fve=`#include <common>
  3490. #include <batching_pars_vertex>
  3491. #include <fog_pars_vertex>
  3492. #include <morphtarget_pars_vertex>
  3493. #include <skinning_pars_vertex>
  3494. #include <logdepthbuf_pars_vertex>
  3495. #include <shadowmap_pars_vertex>
  3496. void main() {
  3497. #include <batching_vertex>
  3498. #include <beginnormal_vertex>
  3499. #include <morphinstance_vertex>
  3500. #include <morphnormal_vertex>
  3501. #include <skinbase_vertex>
  3502. #include <skinnormal_vertex>
  3503. #include <defaultnormal_vertex>
  3504. #include <begin_vertex>
  3505. #include <morphtarget_vertex>
  3506. #include <skinning_vertex>
  3507. #include <project_vertex>
  3508. #include <logdepthbuf_vertex>
  3509. #include <worldpos_vertex>
  3510. #include <shadowmap_vertex>
  3511. #include <fog_vertex>
  3512. }`,pve=`uniform vec3 color;
  3513. uniform float opacity;
  3514. #include <common>
  3515. #include <packing>
  3516. #include <fog_pars_fragment>
  3517. #include <bsdfs>
  3518. #include <lights_pars_begin>
  3519. #include <logdepthbuf_pars_fragment>
  3520. #include <shadowmap_pars_fragment>
  3521. #include <shadowmask_pars_fragment>
  3522. void main() {
  3523. #include <logdepthbuf_fragment>
  3524. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3525. #include <tonemapping_fragment>
  3526. #include <colorspace_fragment>
  3527. #include <fog_fragment>
  3528. }`,gve=`uniform float rotation;
  3529. uniform vec2 center;
  3530. #include <common>
  3531. #include <uv_pars_vertex>
  3532. #include <fog_pars_vertex>
  3533. #include <logdepthbuf_pars_vertex>
  3534. #include <clipping_planes_pars_vertex>
  3535. void main() {
  3536. #include <uv_vertex>
  3537. vec4 mvPosition = modelViewMatrix[ 3 ];
  3538. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3539. #ifndef USE_SIZEATTENUATION
  3540. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3541. if ( isPerspective ) scale *= - mvPosition.z;
  3542. #endif
  3543. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3544. vec2 rotatedPosition;
  3545. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3546. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3547. mvPosition.xy += rotatedPosition;
  3548. gl_Position = projectionMatrix * mvPosition;
  3549. #include <logdepthbuf_vertex>
  3550. #include <clipping_planes_vertex>
  3551. #include <fog_vertex>
  3552. }`,bve=`uniform vec3 diffuse;
  3553. uniform float opacity;
  3554. #include <common>
  3555. #include <uv_pars_fragment>
  3556. #include <map_pars_fragment>
  3557. #include <alphamap_pars_fragment>
  3558. #include <alphatest_pars_fragment>
  3559. #include <alphahash_pars_fragment>
  3560. #include <fog_pars_fragment>
  3561. #include <logdepthbuf_pars_fragment>
  3562. #include <clipping_planes_pars_fragment>
  3563. void main() {
  3564. vec4 diffuseColor = vec4( diffuse, opacity );
  3565. #include <clipping_planes_fragment>
  3566. vec3 outgoingLight = vec3( 0.0 );
  3567. #include <logdepthbuf_fragment>
  3568. #include <map_fragment>
  3569. #include <alphamap_fragment>
  3570. #include <alphatest_fragment>
  3571. #include <alphahash_fragment>
  3572. outgoingLight = diffuseColor.rgb;
  3573. #include <opaque_fragment>
  3574. #include <tonemapping_fragment>
  3575. #include <colorspace_fragment>
  3576. #include <fog_fragment>
  3577. }`,Bn={alphahash_fragment:zxe,alphahash_pars_fragment:Uxe,alphamap_fragment:Bxe,alphamap_pars_fragment:Hxe,alphatest_fragment:$xe,alphatest_pars_fragment:Vxe,aomap_fragment:qxe,aomap_pars_fragment:Gxe,batching_pars_vertex:Wxe,batching_vertex:Kxe,begin_vertex:Yxe,beginnormal_vertex:Xxe,bsdfs:Qxe,iridescence_fragment:Zxe,bumpmap_pars_fragment:Jxe,clipping_planes_fragment:eye,clipping_planes_pars_fragment:tye,clipping_planes_pars_vertex:nye,clipping_planes_vertex:rye,color_fragment:aye,color_pars_fragment:iye,color_pars_vertex:sye,color_vertex:oye,common:lye,cube_uv_reflection_fragment:cye,defaultnormal_vertex:uye,displacementmap_pars_vertex:dye,displacementmap_vertex:hye,emissivemap_fragment:mye,emissivemap_pars_fragment:fye,colorspace_fragment:pye,colorspace_pars_fragment:gye,envmap_fragment:bye,envmap_common_pars_fragment:xye,envmap_pars_fragment:yye,envmap_pars_vertex:vye,envmap_physical_pars_fragment:jye,envmap_vertex:wye,fog_vertex:Sye,fog_pars_vertex:_ye,fog_fragment:Nye,fog_pars_fragment:kye,gradientmap_pars_fragment:Cye,lightmap_pars_fragment:Aye,lights_lambert_fragment:Tye,lights_lambert_pars_fragment:Mye,lights_pars_begin:Pye,lights_toon_fragment:Eye,lights_toon_pars_fragment:Dye,lights_phong_fragment:Rye,lights_phong_pars_fragment:Fye,lights_physical_fragment:Lye,lights_physical_pars_fragment:Oye,lights_fragment_begin:Iye,lights_fragment_maps:zye,lights_fragment_end:Uye,logdepthbuf_fragment:Bye,logdepthbuf_pars_fragment:Hye,logdepthbuf_pars_vertex:$ye,logdepthbuf_vertex:Vye,map_fragment:qye,map_pars_fragment:Gye,map_particle_fragment:Wye,map_particle_pars_fragment:Kye,metalnessmap_fragment:Yye,metalnessmap_pars_fragment:Xye,morphinstance_vertex:Qye,morphcolor_vertex:Zye,morphnormal_vertex:Jye,morphtarget_pars_vertex:e0e,morphtarget_vertex:t0e,normal_fragment_begin:n0e,normal_fragment_maps:r0e,normal_pars_fragment:a0e,normal_pars_vertex:i0e,normal_vertex:s0e,normalmap_pars_fragment:o0e,clearcoat_normal_fragment_begin:l0e,clearcoat_normal_fragment_maps:c0e,clearcoat_pars_fragment:u0e,iridescence_pars_fragment:d0e,opaque_fragment:h0e,packing:m0e,premultiplied_alpha_fragment:f0e,project_vertex:p0e,dithering_fragment:g0e,dithering_pars_fragment:b0e,roughnessmap_fragment:x0e,roughnessmap_pars_fragment:y0e,shadowmap_pars_fragment:v0e,shadowmap_pars_vertex:w0e,shadowmap_vertex:S0e,shadowmask_pars_fragment:_0e,skinbase_vertex:N0e,skinning_pars_vertex:k0e,skinning_vertex:C0e,skinnormal_vertex:A0e,specularmap_fragment:T0e,specularmap_pars_fragment:M0e,tonemapping_fragment:P0e,tonemapping_pars_fragment:j0e,transmission_fragment:E0e,transmission_pars_fragment:D0e,uv_pars_fragment:R0e,uv_pars_vertex:F0e,uv_vertex:L0e,worldpos_vertex:O0e,background_vert:I0e,background_frag:z0e,backgroundCube_vert:U0e,backgroundCube_frag:B0e,cube_vert:H0e,cube_frag:$0e,depth_vert:V0e,depth_frag:q0e,distanceRGBA_vert:G0e,distanceRGBA_frag:W0e,equirect_vert:K0e,equirect_frag:Y0e,linedashed_vert:X0e,linedashed_frag:Q0e,meshbasic_vert:Z0e,meshbasic_frag:J0e,meshlambert_vert:eve,meshlambert_frag:tve,meshmatcap_vert:nve,meshmatcap_frag:rve,meshnormal_vert:ave,meshnormal_frag:ive,meshphong_vert:sve,meshphong_frag:ove,meshphysical_vert:lve,meshphysical_frag:cve,meshtoon_vert:uve,meshtoon_frag:dve,points_vert:hve,points_frag:mve,shadow_vert:fve,shadow_frag:pve,sprite_vert:gve,sprite_frag:bve},$t={common:{diffuse:{value:new Yn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Kn},alphaMap:{value:null},alphaMapTransform:{value:new Kn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Kn}},envmap:{envMap:{value:null},envMapRotation:{value:new Kn},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 Kn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Kn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Kn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Kn},normalScale:{value:new qn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Kn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Kn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Kn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Kn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Yn(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 Yn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Kn},alphaTest:{value:0},uvTransform:{value:new Kn}},sprite:{diffuse:{value:new Yn(16777215)},opacity:{value:1},center:{value:new qn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Kn},alphaMap:{value:null},alphaMapTransform:{value:new Kn},alphaTest:{value:0}}},_c={basic:{uniforms:Ts([$t.common,$t.specularmap,$t.envmap,$t.aomap,$t.lightmap,$t.fog]),vertexShader:Bn.meshbasic_vert,fragmentShader:Bn.meshbasic_frag},lambert:{uniforms:Ts([$t.common,$t.specularmap,$t.envmap,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.fog,$t.lights,{emissive:{value:new Yn(0)}}]),vertexShader:Bn.meshlambert_vert,fragmentShader:Bn.meshlambert_frag},phong:{uniforms:Ts([$t.common,$t.specularmap,$t.envmap,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.fog,$t.lights,{emissive:{value:new Yn(0)},specular:{value:new Yn(1118481)},shininess:{value:30}}]),vertexShader:Bn.meshphong_vert,fragmentShader:Bn.meshphong_frag},standard:{uniforms:Ts([$t.common,$t.envmap,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.roughnessmap,$t.metalnessmap,$t.fog,$t.lights,{emissive:{value:new Yn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Bn.meshphysical_vert,fragmentShader:Bn.meshphysical_frag},toon:{uniforms:Ts([$t.common,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.gradientmap,$t.fog,$t.lights,{emissive:{value:new Yn(0)}}]),vertexShader:Bn.meshtoon_vert,fragmentShader:Bn.meshtoon_frag},matcap:{uniforms:Ts([$t.common,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.fog,{matcap:{value:null}}]),vertexShader:Bn.meshmatcap_vert,fragmentShader:Bn.meshmatcap_frag},points:{uniforms:Ts([$t.points,$t.fog]),vertexShader:Bn.points_vert,fragmentShader:Bn.points_frag},dashed:{uniforms:Ts([$t.common,$t.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Bn.linedashed_vert,fragmentShader:Bn.linedashed_frag},depth:{uniforms:Ts([$t.common,$t.displacementmap]),vertexShader:Bn.depth_vert,fragmentShader:Bn.depth_frag},normal:{uniforms:Ts([$t.common,$t.bumpmap,$t.normalmap,$t.displacementmap,{opacity:{value:1}}]),vertexShader:Bn.meshnormal_vert,fragmentShader:Bn.meshnormal_frag},sprite:{uniforms:Ts([$t.sprite,$t.fog]),vertexShader:Bn.sprite_vert,fragmentShader:Bn.sprite_frag},background:{uniforms:{uvTransform:{value:new Kn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Bn.background_vert,fragmentShader:Bn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Kn}},vertexShader:Bn.backgroundCube_vert,fragmentShader:Bn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Bn.cube_vert,fragmentShader:Bn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Bn.equirect_vert,fragmentShader:Bn.equirect_frag},distanceRGBA:{uniforms:Ts([$t.common,$t.displacementmap,{referencePosition:{value:new xt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Bn.distanceRGBA_vert,fragmentShader:Bn.distanceRGBA_frag},shadow:{uniforms:Ts([$t.lights,$t.fog,{color:{value:new Yn(0)},opacity:{value:1}}]),vertexShader:Bn.shadow_vert,fragmentShader:Bn.shadow_frag}};_c.physical={uniforms:Ts([_c.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Kn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Kn},clearcoatNormalScale:{value:new qn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Kn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Kn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Kn},sheen:{value:0},sheenColor:{value:new Yn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Kn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Kn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Kn},transmissionSamplerSize:{value:new qn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Kn},attenuationDistance:{value:0},attenuationColor:{value:new Yn(0)},specularColor:{value:new Yn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Kn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Kn},anisotropyVector:{value:new qn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Kn}}]),vertexShader:Bn.meshphysical_vert,fragmentShader:Bn.meshphysical_frag};const ES={r:0,b:0,g:0},Fm=new Zh,xve=new oi;function yve(t,e,n,r,i,s,o){const l=new Yn(0);let c=s===!0?0:1,u,d,h=null,f=0,p=null;function x(N){let A=N.isScene===!0?N.background:null;return A&&A.isTexture&&(A=(N.backgroundBlurriness>0?n:e).get(A)),A}function v(N){let A=!1;const C=x(N);C===null?y(l,c):C&&C.isColor&&(y(C,1),A=!0);const j=t.xr.getEnvironmentBlendMode();j==="additive"?r.buffers.color.setClear(0,0,0,1,o):j==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function g(N,A){const C=x(A);C&&(C.isCubeTexture||C.mapping===dC)?(d===void 0&&(d=new kl(new i4(1,1,1),new od({name:"BackgroundCubeMaterial",uniforms:Cb(_c.backgroundCube.uniforms),vertexShader:_c.backgroundCube.vertexShader,fragmentShader:_c.backgroundCube.fragmentShader,side:ao,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(j,k,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Fm.copy(A.backgroundRotation),Fm.x*=-1,Fm.y*=-1,Fm.z*=-1,C.isCubeTexture&&C.isRenderTargetTexture===!1&&(Fm.y*=-1,Fm.z*=-1),d.material.uniforms.envMap.value=C,d.material.uniforms.flipEnvMap.value=C.isCubeTexture&&C.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(xve.makeRotationFromEuler(Fm)),d.material.toneMapped=br.getTransfer(C.colorSpace)!==Ur,(h!==C||f!==C.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,h=C,f=C.version,p=t.toneMapping),d.layers.enableAll(),N.unshift(d,d.geometry,d.material,0,0,null)):C&&C.isTexture&&(u===void 0&&(u=new kl(new o4(2,2),new od({name:"BackgroundMaterial",uniforms:Cb(_c.background.uniforms),vertexShader:_c.background.vertexShader,fragmentShader:_c.background.fragmentShader,side:Qh,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=C,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=br.getTransfer(C.colorSpace)!==Ur,C.matrixAutoUpdate===!0&&C.updateMatrix(),u.material.uniforms.uvTransform.value.copy(C.matrix),(h!==C||f!==C.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,h=C,f=C.version,p=t.toneMapping),u.layers.enableAll(),N.unshift(u,u.geometry,u.material,0,0,null))}function y(N,A){N.getRGB(ES,kX(t)),r.buffers.color.setClear(ES.r,ES.g,ES.b,A,o)}function _(){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,A=1){l.set(N),c=A,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(N){c=N,y(l,c)},render:v,addToRenderList:g,dispose:_}}function vve(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=f(null);let s=i,o=!1;function l(D,G,U,W,L){let ee=!1;const ae=h(W,U,G);s!==ae&&(s=ae,u(s.object)),ee=p(D,W,U,L),ee&&x(D,W,U,L),L!==null&&e.update(L,t.ELEMENT_ARRAY_BUFFER),(ee||o)&&(o=!1,A(D,G,U,W),L!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(L).buffer))}function c(){return t.createVertexArray()}function u(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function h(D,G,U){const W=U.wireframe===!0;let L=r[D.id];L===void 0&&(L={},r[D.id]=L);let ee=L[G.id];ee===void 0&&(ee={},L[G.id]=ee);let ae=ee[W];return ae===void 0&&(ae=f(c()),ee[W]=ae),ae}function f(D){const G=[],U=[],W=[];for(let L=0;L<n;L++)G[L]=0,U[L]=0,W[L]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:G,enabledAttributes:U,attributeDivisors:W,object:D,attributes:{},index:null}}function p(D,G,U,W){const L=s.attributes,ee=G.attributes;let ae=0;const Y=U.getAttributes();for(const se in Y)if(Y[se].location>=0){const ye=L[se];let Z=ee[se];if(Z===void 0&&(se==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),se==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor)),ye===void 0||ye.attribute!==Z||Z&&ye.data!==Z.data)return!0;ae++}return s.attributesNum!==ae||s.index!==W}function x(D,G,U,W){const L={},ee=G.attributes;let ae=0;const Y=U.getAttributes();for(const se in Y)if(Y[se].location>=0){let ye=ee[se];ye===void 0&&(se==="instanceMatrix"&&D.instanceMatrix&&(ye=D.instanceMatrix),se==="instanceColor"&&D.instanceColor&&(ye=D.instanceColor));const Z={};Z.attribute=ye,ye&&ye.data&&(Z.data=ye.data),L[se]=Z,ae++}s.attributes=L,s.attributesNum=ae,s.index=W}function v(){const D=s.newAttributes;for(let G=0,U=D.length;G<U;G++)D[G]=0}function g(D){y(D,0)}function y(D,G){const U=s.newAttributes,W=s.enabledAttributes,L=s.attributeDivisors;U[D]=1,W[D]===0&&(t.enableVertexAttribArray(D),W[D]=1),L[D]!==G&&(t.vertexAttribDivisor(D,G),L[D]=G)}function _(){const D=s.newAttributes,G=s.enabledAttributes;for(let U=0,W=G.length;U<W;U++)G[U]!==D[U]&&(t.disableVertexAttribArray(U),G[U]=0)}function N(D,G,U,W,L,ee,ae){ae===!0?t.vertexAttribIPointer(D,G,U,L,ee):t.vertexAttribPointer(D,G,U,W,L,ee)}function A(D,G,U,W){v();const L=W.attributes,ee=U.getAttributes(),ae=G.defaultAttributeValues;for(const Y in ee){const se=ee[Y];if(se.location>=0){let ce=L[Y];if(ce===void 0&&(Y==="instanceMatrix"&&D.instanceMatrix&&(ce=D.instanceMatrix),Y==="instanceColor"&&D.instanceColor&&(ce=D.instanceColor)),ce!==void 0){const ye=ce.normalized,Z=ce.itemSize,ue=e.get(ce);if(ue===void 0)continue;const pe=ue.buffer,be=ue.type,Ee=ue.bytesPerElement,$=be===t.INT||be===t.UNSIGNED_INT||ce.gpuType===YF;if(ce.isInterleavedBufferAttribute){const K=ce.data,T=K.stride,E=ce.offset;if(K.isInstancedInterleavedBuffer){for(let O=0;O<se.locationSize;O++)y(se.location+O,K.meshPerAttribute);D.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=K.meshPerAttribute*K.count)}else for(let O=0;O<se.locationSize;O++)g(se.location+O);t.bindBuffer(t.ARRAY_BUFFER,pe);for(let O=0;O<se.locationSize;O++)N(se.location+O,Z/se.locationSize,be,ye,T*Ee,(E+Z/se.locationSize*O)*Ee,$)}else{if(ce.isInstancedBufferAttribute){for(let K=0;K<se.locationSize;K++)y(se.location+K,ce.meshPerAttribute);D.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ce.meshPerAttribute*ce.count)}else for(let K=0;K<se.locationSize;K++)g(se.location+K);t.bindBuffer(t.ARRAY_BUFFER,pe);for(let K=0;K<se.locationSize;K++)N(se.location+K,Z/se.locationSize,be,ye,Z*Ee,Z/se.locationSize*K*Ee,$)}}else if(ae!==void 0){const ye=ae[Y];if(ye!==void 0)switch(ye.length){case 2:t.vertexAttrib2fv(se.location,ye);break;case 3:t.vertexAttrib3fv(se.location,ye);break;case 4:t.vertexAttrib4fv(se.location,ye);break;default:t.vertexAttrib1fv(se.location,ye)}}}}_()}function C(){R();for(const D in r){const G=r[D];for(const U in G){const W=G[U];for(const L in W)d(W[L].object),delete W[L];delete G[U]}delete r[D]}}function j(D){if(r[D.id]===void 0)return;const G=r[D.id];for(const U in G){const W=G[U];for(const L in W)d(W[L].object),delete W[L];delete G[U]}delete r[D.id]}function k(D){for(const G in r){const U=r[G];if(U[D.id]===void 0)continue;const W=U[D.id];for(const L in W)d(W[L].object),delete W[L];delete U[D.id]}}function R(){M(),o=!0,s!==i&&(s=i,u(s.object))}function M(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:R,resetDefaultState:M,dispose:C,releaseStatesOfGeometry:j,releaseStatesOfProgram:k,initAttributes:v,enableAttribute:g,disableUnusedAttributes:_}}function wve(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 p=0;for(let x=0;x<h;x++)p+=d[x];n.update(p,r,1)}function c(u,d,h,f){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<u.length;x++)o(u[x],d[x],f[x]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,f,0,h);let x=0;for(let v=0;v<h;v++)x+=d[v]*f[v];n.update(x,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function Sve(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!==Yl&&r.convert(k)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(k){const R=k===tx&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(k!==zc&&r.convert(k)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&k!==Bu&&!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&&(Cn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const h=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),g=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),_=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),N=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),C=x>0,j=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:h,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:x,maxTextureSize:v,maxCubemapSize:g,maxAttributes:y,maxVertexUniforms:_,maxVaryings:N,maxFragmentUniforms:A,vertexTextures:C,maxSamples:j}}function _ve(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new lh,l=new Kn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){const p=h.length!==0||f||r!==0||i;return i=f,r=h.length,p},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){n=d(h,f,0)},this.setState=function(h,f,p){const x=h.clippingPlanes,v=h.clipIntersection,g=h.clipShadows,y=t.get(h);if(!i||x===null||x.length===0||s&&!g)s?d(null):u();else{const _=s?0:r,N=_*4;let A=y.clippingState||null;c.value=A,A=d(x,f,N,p);for(let C=0;C!==N;++C)A[C]=n[C];y.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(h,f,p,x){const v=h!==null?h.length:0;let g=null;if(v!==0){if(g=c.value,x!==!0||g===null){const y=p+v*4,_=f.matrixWorldInverse;l.getNormalMatrix(_),(g===null||g.length<y)&&(g=new Float32Array(y));for(let N=0,A=p;N!==v;++N,A+=4)o.copy(h[N]).applyMatrix4(_,l),o.normal.toArray(g,A),g[A+3]=o.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,g}}function Nve(t){let e=new WeakMap;function n(o,l){return l===D3?o.mapping=_b:l===R3&&(o.mapping=Nb),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===D3||l===R3)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 gxe(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 Nh=4,I8=[.125,.215,.35,.446,.526,.582],Zm=20,kve=256,gy=new RX,z8=new Yn;let _M=null,NM=0,kM=0,CM=!1;const Cve=new xt;let U8=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=Cve}=s;_M=this._renderer.getRenderTarget(),NM=this._renderer.getActiveCubeFace(),kM=this._renderer.getActiveMipmapLevel(),CM=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=$8(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=H8(),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(_M,NM,kM),this._renderer.xr.enabled=CM,e.scissorTest=!1,lg(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===_b||e.mapping===Nb?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),_M=this._renderer.getRenderTarget(),NM=this._renderer.getActiveCubeFace(),kM=this._renderer.getActiveMipmapLevel(),CM=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:pl,minFilter:pl,generateMipmaps:!1,type:tx,format:Yl,colorSpace:kb,depthBuffer:!1},i=B8(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=B8(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Ave(s)),this._blurMaterial=Mve(s,e,n),this._ggxMaterial=Tve(s,e,n)}return i}_compileMaterial(e){const n=new kl(new Nl,e);this._renderer.compile(n,gy)}_sceneToCubeUV(e,n,r,i,s){const c=new cl(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,f=h.autoClear,p=h.toneMapping;h.getClearColor(z8),h.toneMapping=zh,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new kl(new i4,new a4({name:"PMREM.Background",side:ao,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,g=v.material;let y=!1;const _=e.background;_?_.isColor&&(g.color.copy(_),e.background=null,y=!0):(g.color.copy(z8),y=!0);for(let N=0;N<6;N++){const A=N%3;A===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)):A===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 C=this._cubeSize;lg(i,A*C,N>2?C:0,C,C),h.setRenderTarget(i),y&&h.render(v,c),h.render(e,c)}h.toneMapping=p,h.autoClear=f,e.background=_}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===_b||e.mapping===Nb;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=$8()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=H8());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;lg(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,gy)}_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),f=.05+u*.95,p=h*f,{_lodMax:x}=this,v=this._sizeLods[r],g=3*v*(r>x-Nh?r-x+Nh:0),y=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,lg(s,g,y,3*v,2*v),i.setRenderTarget(s),i.render(l,gy),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=x-r,lg(e,g,y,3*v,2*v),i.setRenderTarget(e),i.render(l,gy)}_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"&&Va("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[i];h.material=u;const f=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Zm-1),v=s/x,g=isFinite(s)?1+Math.floor(d*v):Zm;g>Zm&&Cn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Zm}`);const y=[];let _=0;for(let k=0;k<Zm;++k){const R=k/v,M=Math.exp(-R*R/2);y.push(M),k===0?_+=M:k<g&&(_+=2*M)}for(let k=0;k<y.length;k++)y[k]=y[k]/_;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=y,f.latitudinal.value=o==="latitudinal",l&&(f.poleAxis.value=l);const{_lodMax:N}=this;f.dTheta.value=x,f.mipInt.value=N-r;const A=this._sizeLods[i],C=3*A*(i>N-Nh?i-N+Nh:0),j=4*(this._cubeSize-A);lg(n,C,j,3*A,2*A),c.setRenderTarget(n),c.render(h,gy)}};function Ave(t){const e=[],n=[],r=[];let i=t;const s=t-Nh+1+I8.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Nh?c=I8[o-t+Nh-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,h=1+u,f=[d,d,h,d,h,h,d,d,h,h,d,h],p=6,x=6,v=3,g=2,y=1,_=new Float32Array(v*x*p),N=new Float32Array(g*x*p),A=new Float32Array(y*x*p);for(let j=0;j<p;j++){const k=j%3*2/3-1,R=j>2?0:-1,M=[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];_.set(M,v*x*j),N.set(f,g*x*j);const D=[j,j,j,j,j,j];A.set(D,y*x*j)}const C=new Nl;C.setAttribute("position",new Ls(_,v)),C.setAttribute("uv",new Ls(N,g)),C.setAttribute("faceIndex",new Ls(A,y)),r.push(new kl(C,null)),i>Nh&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function B8(t,e,n){const r=new $f(t,e,n);return r.texture.mapping=dC,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function lg(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function Tve(t,e,n){return new od({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:kve,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:mC(),fragmentShader:`
  3578. precision highp float;
  3579. precision highp int;
  3580. varying vec3 vOutputDirection;
  3581. uniform sampler2D envMap;
  3582. uniform float roughness;
  3583. uniform float mipInt;
  3584. #define ENVMAP_TYPE_CUBE_UV
  3585. #include <cube_uv_reflection_fragment>
  3586. #define PI 3.14159265359
  3587. // Van der Corput radical inverse
  3588. float radicalInverse_VdC(uint bits) {
  3589. bits = (bits << 16u) | (bits >> 16u);
  3590. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3591. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3592. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3593. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3594. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3595. }
  3596. // Hammersley sequence
  3597. vec2 hammersley(uint i, uint N) {
  3598. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3599. }
  3600. // GGX VNDF importance sampling (Eric Heitz 2018)
  3601. // "Sampling the GGX Distribution of Visible Normals"
  3602. // https://jcgt.org/published/0007/04/01/
  3603. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3604. float alpha = roughness * roughness;
  3605. // Section 3.2: Transform view direction to hemisphere configuration
  3606. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3607. // Section 4.1: Orthonormal basis
  3608. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3609. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3610. vec3 T2 = cross(Vh, T1);
  3611. // Section 4.2: Parameterization of projected area
  3612. float r = sqrt(Xi.x);
  3613. float phi = 2.0 * PI * Xi.y;
  3614. float t1 = r * cos(phi);
  3615. float t2 = r * sin(phi);
  3616. float s = 0.5 * (1.0 + Vh.z);
  3617. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3618. // Section 4.3: Reprojection onto hemisphere
  3619. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3620. // Section 3.4: Transform back to ellipsoid configuration
  3621. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3622. }
  3623. void main() {
  3624. vec3 N = normalize(vOutputDirection);
  3625. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3626. vec3 prefilteredColor = vec3(0.0);
  3627. float totalWeight = 0.0;
  3628. // For very low roughness, just sample the environment directly
  3629. if (roughness < 0.001) {
  3630. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3631. return;
  3632. }
  3633. // Tangent space basis for VNDF sampling
  3634. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3635. vec3 tangent = normalize(cross(up, N));
  3636. vec3 bitangent = cross(N, tangent);
  3637. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3638. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3639. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3640. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3641. // Transform H back to world space
  3642. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3643. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3644. float NdotL = max(dot(N, L), 0.0);
  3645. if(NdotL > 0.0) {
  3646. // Sample environment at fixed mip level
  3647. // VNDF importance sampling handles the distribution filtering
  3648. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3649. // Weight by NdotL for the split-sum approximation
  3650. // VNDF PDF naturally accounts for the visible microfacet distribution
  3651. prefilteredColor += sampleColor * NdotL;
  3652. totalWeight += NdotL;
  3653. }
  3654. }
  3655. if (totalWeight > 0.0) {
  3656. prefilteredColor = prefilteredColor / totalWeight;
  3657. }
  3658. gl_FragColor = vec4(prefilteredColor, 1.0);
  3659. }
  3660. `,blending:Wu,depthTest:!1,depthWrite:!1})}function Mve(t,e,n){const r=new Float32Array(Zm),i=new xt(0,1,0);return new od({name:"SphericalGaussianBlur",defines:{n:Zm,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:mC(),fragmentShader:`
  3661. precision mediump float;
  3662. precision mediump int;
  3663. varying vec3 vOutputDirection;
  3664. uniform sampler2D envMap;
  3665. uniform int samples;
  3666. uniform float weights[ n ];
  3667. uniform bool latitudinal;
  3668. uniform float dTheta;
  3669. uniform float mipInt;
  3670. uniform vec3 poleAxis;
  3671. #define ENVMAP_TYPE_CUBE_UV
  3672. #include <cube_uv_reflection_fragment>
  3673. vec3 getSample( float theta, vec3 axis ) {
  3674. float cosTheta = cos( theta );
  3675. // Rodrigues' axis-angle rotation
  3676. vec3 sampleDirection = vOutputDirection * cosTheta
  3677. + cross( axis, vOutputDirection ) * sin( theta )
  3678. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3679. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3680. }
  3681. void main() {
  3682. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3683. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3684. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3685. }
  3686. axis = normalize( axis );
  3687. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3688. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3689. for ( int i = 1; i < n; i++ ) {
  3690. if ( i >= samples ) {
  3691. break;
  3692. }
  3693. float theta = dTheta * float( i );
  3694. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3695. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3696. }
  3697. }
  3698. `,blending:Wu,depthTest:!1,depthWrite:!1})}function H8(){return new od({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:mC(),fragmentShader:`
  3699. precision mediump float;
  3700. precision mediump int;
  3701. varying vec3 vOutputDirection;
  3702. uniform sampler2D envMap;
  3703. #include <common>
  3704. void main() {
  3705. vec3 outputDirection = normalize( vOutputDirection );
  3706. vec2 uv = equirectUv( outputDirection );
  3707. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3708. }
  3709. `,blending:Wu,depthTest:!1,depthWrite:!1})}function $8(){return new od({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:mC(),fragmentShader:`
  3710. precision mediump float;
  3711. precision mediump int;
  3712. uniform float flipEnvMap;
  3713. varying vec3 vOutputDirection;
  3714. uniform samplerCube envMap;
  3715. void main() {
  3716. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3717. }
  3718. `,blending:Wu,depthTest:!1,depthWrite:!1})}function mC(){return`
  3719. precision mediump float;
  3720. precision mediump int;
  3721. attribute float faceIndex;
  3722. varying vec3 vOutputDirection;
  3723. // RH coordinate system; PMREM face-indexing convention
  3724. vec3 getDirection( vec2 uv, float face ) {
  3725. uv = 2.0 * uv - 1.0;
  3726. vec3 direction = vec3( uv, 1.0 );
  3727. if ( face == 0.0 ) {
  3728. direction = direction.zyx; // ( 1, v, u ) pos x
  3729. } else if ( face == 1.0 ) {
  3730. direction = direction.xzy;
  3731. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3732. } else if ( face == 2.0 ) {
  3733. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3734. } else if ( face == 3.0 ) {
  3735. direction = direction.zyx;
  3736. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3737. } else if ( face == 4.0 ) {
  3738. direction = direction.xzy;
  3739. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3740. } else if ( face == 5.0 ) {
  3741. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3742. }
  3743. return direction;
  3744. }
  3745. void main() {
  3746. vOutputDirection = getDirection( uv, faceIndex );
  3747. gl_Position = vec4( position, 1.0 );
  3748. }
  3749. `}function Pve(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===D3||c===R3,d=c===_b||c===Nb;if(u||d){let h=e.get(l);const f=h!==void 0?h.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==f)return n===null&&(n=new U8(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 p=l.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new U8(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 jve(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&&E0("WebGLRenderer: "+r+" extension not supported."),i}}}function Eve(t,e,n,r){const i={},s=new WeakMap;function o(h){const f=h.target;f.index!==null&&e.remove(f.index);for(const x in f.attributes)e.remove(f.attributes[x]);f.removeEventListener("dispose",o),delete i[f.id];const p=s.get(f);p&&(e.remove(p),s.delete(f)),r.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,n.memory.geometries--}function l(h,f){return i[f.id]===!0||(f.addEventListener("dispose",o),i[f.id]=!0,n.memory.geometries++),f}function c(h){const f=h.attributes;for(const p in f)e.update(f[p],t.ARRAY_BUFFER)}function u(h){const f=[],p=h.index,x=h.attributes.position;let v=0;if(p!==null){const _=p.array;v=p.version;for(let N=0,A=_.length;N<A;N+=3){const C=_[N+0],j=_[N+1],k=_[N+2];f.push(C,j,j,k,k,C)}}else if(x!==void 0){const _=x.array;v=x.version;for(let N=0,A=_.length/3-1;N<A;N+=3){const C=N+0,j=N+1,k=N+2;f.push(C,j,j,k,k,C)}}else return;const g=new(hX(f)?SX:wX)(f,1);g.version=v;const y=s.get(h);y&&e.remove(y),s.set(h,g)}function d(h){const f=s.get(h);if(f){const p=h.index;p!==null&&f.version<p.version&&u(h)}else u(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:d}}function Dve(t,e,n){let r;function i(f){r=f}let s,o;function l(f){s=f.type,o=f.bytesPerElement}function c(f,p){t.drawElements(r,p,s,f*o),n.update(p,r,1)}function u(f,p,x){x!==0&&(t.drawElementsInstanced(r,p,s,f*o,x),n.update(p,r,x))}function d(f,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,s,f,0,x);let g=0;for(let y=0;y<x;y++)g+=p[y];n.update(g,r,1)}function h(f,p,x,v){if(x===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let y=0;y<f.length;y++)u(f[y]/o,p[y],v[y]);else{g.multiDrawElementsInstancedWEBGL(r,p,0,s,f,0,v,0,x);let y=0;for(let _=0;_<x;_++)y+=p[_]*v[_];n.update(y,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=h}function Rve(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:Va("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 Fve(t,e,n){const r=new WeakMap,i=new ti;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 f=r.get(l);if(f===void 0||f.count!==h){let D=function(){R.dispose(),r.delete(l),l.removeEventListener("dispose",D)};var p=D;f!==void 0&&f.texture.dispose();const x=l.morphAttributes.position!==void 0,v=l.morphAttributes.normal!==void 0,g=l.morphAttributes.color!==void 0,y=l.morphAttributes.position||[],_=l.morphAttributes.normal||[],N=l.morphAttributes.color||[];let A=0;x===!0&&(A=1),v===!0&&(A=2),g===!0&&(A=3);let C=l.attributes.position.count*A,j=1;C>e.maxTextureSize&&(j=Math.ceil(C/e.maxTextureSize),C=e.maxTextureSize);const k=new Float32Array(C*j*4*h),R=new bX(k,C,j,h);R.type=Bu,R.needsUpdate=!0;const M=A*4;for(let G=0;G<h;G++){const U=y[G],W=_[G],L=N[G],ee=C*j*4*G;for(let ae=0;ae<U.count;ae++){const Y=ae*M;x===!0&&(i.fromBufferAttribute(U,ae),k[ee+Y+0]=i.x,k[ee+Y+1]=i.y,k[ee+Y+2]=i.z,k[ee+Y+3]=0),v===!0&&(i.fromBufferAttribute(W,ae),k[ee+Y+4]=i.x,k[ee+Y+5]=i.y,k[ee+Y+6]=i.z,k[ee+Y+7]=0),g===!0&&(i.fromBufferAttribute(L,ae),k[ee+Y+8]=i.x,k[ee+Y+9]=i.y,k[ee+Y+10]=i.z,k[ee+Y+11]=L.itemSize===4?i.w:1)}}f={count:h,texture:R,size:new qn(C,j)},r.set(l,f),l.addEventListener("dispose",D)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let x=0;for(let g=0;g<u.length;g++)x+=u[g];const v=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",v),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",f.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",f.size)}return{update:s}}function Lve(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 f=c.skeleton;i.get(f)!==u&&(f.update(),i.set(f,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 LX=new sc,V8=new MX(1,1),OX=new bX,IX=new Jbe,zX=new AX,q8=[],G8=[],W8=new Float32Array(16),K8=new Float32Array(9),Y8=new Float32Array(4);function rx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=q8[i];if(s===void 0&&(s=new Float32Array(i),q8[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 gi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function bi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function fC(t,e){let n=G8[e];n===void 0&&(n=new Int32Array(e),G8[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Ove(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Ive(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(gi(n,e))return;t.uniform2fv(this.addr,e),bi(n,e)}}function zve(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(gi(n,e))return;t.uniform3fv(this.addr,e),bi(n,e)}}function Uve(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(gi(n,e))return;t.uniform4fv(this.addr,e),bi(n,e)}}function Bve(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),bi(n,e)}else{if(gi(n,r))return;Y8.set(r),t.uniformMatrix2fv(this.addr,!1,Y8),bi(n,r)}}function Hve(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),bi(n,e)}else{if(gi(n,r))return;K8.set(r),t.uniformMatrix3fv(this.addr,!1,K8),bi(n,r)}}function $ve(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),bi(n,e)}else{if(gi(n,r))return;W8.set(r),t.uniformMatrix4fv(this.addr,!1,W8),bi(n,r)}}function Vve(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function qve(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(gi(n,e))return;t.uniform2iv(this.addr,e),bi(n,e)}}function Gve(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(gi(n,e))return;t.uniform3iv(this.addr,e),bi(n,e)}}function Wve(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(gi(n,e))return;t.uniform4iv(this.addr,e),bi(n,e)}}function Kve(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Yve(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(gi(n,e))return;t.uniform2uiv(this.addr,e),bi(n,e)}}function Xve(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(gi(n,e))return;t.uniform3uiv(this.addr,e),bi(n,e)}}function Qve(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(gi(n,e))return;t.uniform4uiv(this.addr,e),bi(n,e)}}function Zve(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?(V8.compareFunction=dX,s=V8):s=LX,n.setTexture2D(e||s,i)}function Jve(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||IX,i)}function ewe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||zX,i)}function twe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||OX,i)}function nwe(t){switch(t){case 5126:return Ove;case 35664:return Ive;case 35665:return zve;case 35666:return Uve;case 35674:return Bve;case 35675:return Hve;case 35676:return $ve;case 5124:case 35670:return Vve;case 35667:case 35671:return qve;case 35668:case 35672:return Gve;case 35669:case 35673:return Wve;case 5125:return Kve;case 36294:return Yve;case 36295:return Xve;case 36296:return Qve;case 35678:case 36198:case 36298:case 36306:case 35682:return Zve;case 35679:case 36299:case 36307:return Jve;case 35680:case 36300:case 36308:case 36293:return ewe;case 36289:case 36303:case 36311:case 36292:return twe}}function rwe(t,e){t.uniform1fv(this.addr,e)}function awe(t,e){const n=rx(e,this.size,2);t.uniform2fv(this.addr,n)}function iwe(t,e){const n=rx(e,this.size,3);t.uniform3fv(this.addr,n)}function swe(t,e){const n=rx(e,this.size,4);t.uniform4fv(this.addr,n)}function owe(t,e){const n=rx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function lwe(t,e){const n=rx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function cwe(t,e){const n=rx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function uwe(t,e){t.uniform1iv(this.addr,e)}function dwe(t,e){t.uniform2iv(this.addr,e)}function hwe(t,e){t.uniform3iv(this.addr,e)}function mwe(t,e){t.uniform4iv(this.addr,e)}function fwe(t,e){t.uniform1uiv(this.addr,e)}function pwe(t,e){t.uniform2uiv(this.addr,e)}function gwe(t,e){t.uniform3uiv(this.addr,e)}function bwe(t,e){t.uniform4uiv(this.addr,e)}function xwe(t,e,n){const r=this.cache,i=e.length,s=fC(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),bi(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||LX,s[o])}function ywe(t,e,n){const r=this.cache,i=e.length,s=fC(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),bi(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||IX,s[o])}function vwe(t,e,n){const r=this.cache,i=e.length,s=fC(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),bi(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||zX,s[o])}function wwe(t,e,n){const r=this.cache,i=e.length,s=fC(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),bi(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||OX,s[o])}function Swe(t){switch(t){case 5126:return rwe;case 35664:return awe;case 35665:return iwe;case 35666:return swe;case 35674:return owe;case 35675:return lwe;case 35676:return cwe;case 5124:case 35670:return uwe;case 35667:case 35671:return dwe;case 35668:case 35672:return hwe;case 35669:case 35673:return mwe;case 5125:return fwe;case 36294:return pwe;case 36295:return gwe;case 36296:return bwe;case 35678:case 36198:case 36298:case 36306:case 35682:return xwe;case 35679:case 36299:case 36307:return ywe;case 35680:case 36300:case 36308:case 36293:return vwe;case 36289:case 36303:case 36311:case 36292:return wwe}}let _we=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=nwe(n.type)}},Nwe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Swe(n.type)}},kwe=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 AM=/(\w+)(\])?(\[|\.)?/g;function X8(t,e){t.seq.push(e),t.map[e.id]=e}function Cwe(t,e,n){const r=t.name,i=r.length;for(AM.lastIndex=0;;){const s=AM.exec(r),o=AM.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){X8(n,u===void 0?new _we(l,t,e):new Nwe(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new kwe(l),X8(n,h)),n=h}}}let s1=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);Cwe(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 Q8(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const Awe=37297;let Twe=0;function Mwe(t,e){const n=t.split(`
  3750. `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  3751. `)}const Z8=new Kn;function Pwe(t){br._getMatrix(Z8,br.workingColorSpace,t);const e=`mat3( ${Z8.elements.map(n=>n.toFixed(4))} )`;switch(br.getTransfer(t)){case O1:return[e,"LinearTransferOETF"];case Ur:return[e,"sRGBTransferOETF"];default:return Cn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function J8(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
  3752. `+s+`
  3753. `+Mwe(t.getShaderSource(e),l)}else return s}function jwe(t,e){const n=Pwe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3754. `)}function Ewe(t,e){let n;switch(e){case Cbe:n="Linear";break;case Abe:n="Reinhard";break;case Tbe:n="Cineon";break;case Mbe:n="ACESFilmic";break;case jbe:n="AgX";break;case Ebe:n="Neutral";break;case Pbe:n="Custom";break;default:Cn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const DS=new xt;function Dwe(){br.getLuminanceCoefficients(DS);const t=DS.x.toFixed(4),e=DS.y.toFixed(4),n=DS.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3755. `)}function Rwe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ly).join(`
  3756. `)}function Fwe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3757. `)}function Lwe(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 Ly(t){return t!==""}function e6(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 t6(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Owe=/^[ \t]*#include +<([\w\d./]+)>/gm;function mD(t){return t.replace(Owe,zwe)}const Iwe=new Map;function zwe(t,e){let n=Bn[e];if(n===void 0){const r=Iwe.get(e);if(r!==void 0)n=Bn[r],Cn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return mD(n)}const Uwe=/#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 n6(t){return t.replace(Uwe,Bwe)}function Bwe(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 r6(t){let e=`precision ${t.precision} float;
  3758. precision ${t.precision} int;
  3759. precision ${t.precision} sampler2D;
  3760. precision ${t.precision} samplerCube;
  3761. precision ${t.precision} sampler3D;
  3762. precision ${t.precision} sampler2DArray;
  3763. precision ${t.precision} sampler2DShadow;
  3764. precision ${t.precision} samplerCubeShadow;
  3765. precision ${t.precision} sampler2DArrayShadow;
  3766. precision ${t.precision} isampler2D;
  3767. precision ${t.precision} isampler3D;
  3768. precision ${t.precision} isamplerCube;
  3769. precision ${t.precision} isampler2DArray;
  3770. precision ${t.precision} usampler2D;
  3771. precision ${t.precision} usampler3D;
  3772. precision ${t.precision} usamplerCube;
  3773. precision ${t.precision} usampler2DArray;
  3774. `;return t.precision==="highp"?e+=`
  3775. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3776. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3777. #define LOW_PRECISION`),e}function Hwe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===tX?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===ibe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ju&&(e="SHADOWMAP_TYPE_VSM"),e}function $we(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case _b:case Nb:e="ENVMAP_TYPE_CUBE";break;case dC:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Vwe(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===Nb&&(e="ENVMAP_MODE_REFRACTION"),e}function qwe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case KF:e="ENVMAP_BLENDING_MULTIPLY";break;case Nbe:e="ENVMAP_BLENDING_MIX";break;case kbe:e="ENVMAP_BLENDING_ADD";break}return e}function Gwe(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 Wwe(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=Hwe(n),u=$we(n),d=Vwe(n),h=qwe(n),f=Gwe(n),p=Rwe(n),x=Fwe(s),v=i.createProgram();let g,y,_=n.glslVersion?"#version "+n.glslVersion+`
  3778. `:"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Ly).join(`
  3779. `),g.length>0&&(g+=`
  3780. `),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Ly).join(`
  3781. `),y.length>0&&(y+=`
  3782. `)):(g=[r6(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3783. `].filter(Ly).join(`
  3784. `),y=[r6(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.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!==zh?"#define TONE_MAPPING":"",n.toneMapping!==zh?Bn.tonemapping_pars_fragment:"",n.toneMapping!==zh?Ewe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Bn.colorspace_pars_fragment,jwe("linearToOutputTexel",n.outputColorSpace),Dwe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3785. `].filter(Ly).join(`
  3786. `)),o=mD(o),o=e6(o,n),o=t6(o,n),l=mD(l),l=e6(l,n),l=t6(l,n),o=n6(o),l=n6(l),n.isRawShaderMaterial!==!0&&(_=`#version 300 es
  3787. `,g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3788. `)+`
  3789. `+g,y=["#define varying in",n.glslVersion===c8?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===c8?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  3790. `)+`
  3791. `+y);const N=_+g+o,A=_+y+l,C=Q8(i,i.VERTEX_SHADER,N),j=Q8(i,i.FRAGMENT_SHADER,A);i.attachShader(v,C),i.attachShader(v,j),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function k(G){if(t.debug.checkShaderErrors){const U=i.getProgramInfoLog(v)||"",W=i.getShaderInfoLog(C)||"",L=i.getShaderInfoLog(j)||"",ee=U.trim(),ae=W.trim(),Y=L.trim();let se=!0,ce=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(se=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,C,j);else{const ye=J8(i,C,"vertex"),Z=J8(i,j,"fragment");Va("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  3792. Material Name: `+G.name+`
  3793. Material Type: `+G.type+`
  3794. Program Info Log: `+ee+`
  3795. `+ye+`
  3796. `+Z)}else ee!==""?Cn("WebGLProgram: Program Info Log:",ee):(ae===""||Y==="")&&(ce=!1);ce&&(G.diagnostics={runnable:se,programLog:ee,vertexShader:{log:ae,prefix:g},fragmentShader:{log:Y,prefix:y}})}i.deleteShader(C),i.deleteShader(j),R=new s1(i,v),M=Lwe(i,v)}let R;this.getUniforms=function(){return R===void 0&&k(this),R};let M;this.getAttributes=function(){return M===void 0&&k(this),M};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(v,Awe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Twe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=C,this.fragmentShader=j,this}let Kwe=0,Ywe=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 Xwe(e),n.set(e,r)),r}},Xwe=class{constructor(e){this.id=Kwe++,this.code=e,this.usedTimes=0}};function Qwe(t,e,n,r,i,s,o){const l=new yX,c=new Ywe,u=new Set,d=[],h=i.logarithmicDepthBuffer,f=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(M){return u.add(M),M===0?"uv":`uv${M}`}function g(M,D,G,U,W){const L=U.fog,ee=W.geometry,ae=M.isMeshStandardMaterial?U.environment:null,Y=(M.isMeshStandardMaterial?n:e).get(M.envMap||ae),se=Y&&Y.mapping===dC?Y.image.height:null,ce=x[M.type];M.precision!==null&&(p=i.getMaxPrecision(M.precision),p!==M.precision&&Cn("WebGLProgram.getParameters:",M.precision,"not supported, using",p,"instead."));const ye=ee.morphAttributes.position||ee.morphAttributes.normal||ee.morphAttributes.color,Z=ye!==void 0?ye.length:0;let ue=0;ee.morphAttributes.position!==void 0&&(ue=1),ee.morphAttributes.normal!==void 0&&(ue=2),ee.morphAttributes.color!==void 0&&(ue=3);let pe,be,Ee,$;if(ce){const St=_c[ce];pe=St.vertexShader,be=St.fragmentShader}else pe=M.vertexShader,be=M.fragmentShader,c.update(M),Ee=c.getVertexShaderID(M),$=c.getFragmentShaderID(M);const K=t.getRenderTarget(),T=t.state.buffers.depth.getReversed(),E=W.isInstancedMesh===!0,O=W.isBatchedMesh===!0,q=!!M.map,B=!!M.matcap,re=!!Y,z=!!M.aoMap,V=!!M.lightMap,te=!!M.bumpMap,Q=!!M.normalMap,ne=!!M.displacementMap,ie=!!M.emissiveMap,me=!!M.metalnessMap,fe=!!M.roughnessMap,oe=M.anisotropy>0,I=M.clearcoat>0,F=M.dispersion>0,J=M.iridescence>0,xe=M.sheen>0,he=M.transmission>0,le=oe&&!!M.anisotropyMap,Ce=I&&!!M.clearcoatMap,Ne=I&&!!M.clearcoatNormalMap,Ue=I&&!!M.clearcoatRoughnessMap,He=J&&!!M.iridescenceMap,de=J&&!!M.iridescenceThicknessMap,we=xe&&!!M.sheenColorMap,ke=xe&&!!M.sheenRoughnessMap,_e=!!M.specularMap,Ae=!!M.specularColorMap,Ve=!!M.specularIntensityMap,Te=he&&!!M.transmissionMap,Ke=he&&!!M.thicknessMap,je=!!M.gradientMap,qe=!!M.alphaMap,Re=M.alphaTest>0,Pe=!!M.alphaHash,Be=!!M.extensions;let We=zh;M.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(We=t.toneMapping);const ct={shaderID:ce,shaderType:M.type,shaderName:M.name,vertexShader:pe,fragmentShader:be,defines:M.defines,customVertexShaderID:Ee,customFragmentShaderID:$,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:p,batching:O,batchingColor:O&&W._colorsTexture!==null,instancing:E,instancingColor:E&&W.instanceColor!==null,instancingMorph:E&&W.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:K===null?t.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:kb,alphaToCoverage:!!M.alphaToCoverage,map:q,matcap:B,envMap:re,envMapMode:re&&Y.mapping,envMapCubeUVHeight:se,aoMap:z,lightMap:V,bumpMap:te,normalMap:Q,displacementMap:f&&ne,emissiveMap:ie,normalMapObjectSpace:Q&&M.normalMapType===Lbe,normalMapTangentSpace:Q&&M.normalMapType===uX,metalnessMap:me,roughnessMap:fe,anisotropy:oe,anisotropyMap:le,clearcoat:I,clearcoatMap:Ce,clearcoatNormalMap:Ne,clearcoatRoughnessMap:Ue,dispersion:F,iridescence:J,iridescenceMap:He,iridescenceThicknessMap:de,sheen:xe,sheenColorMap:we,sheenRoughnessMap:ke,specularMap:_e,specularColorMap:Ae,specularIntensityMap:Ve,transmission:he,transmissionMap:Te,thicknessMap:Ke,gradientMap:je,opaque:M.transparent===!1&&M.blending===ib&&M.alphaToCoverage===!1,alphaMap:qe,alphaTest:Re,alphaHash:Pe,combine:M.combine,mapUv:q&&v(M.map.channel),aoMapUv:z&&v(M.aoMap.channel),lightMapUv:V&&v(M.lightMap.channel),bumpMapUv:te&&v(M.bumpMap.channel),normalMapUv:Q&&v(M.normalMap.channel),displacementMapUv:ne&&v(M.displacementMap.channel),emissiveMapUv:ie&&v(M.emissiveMap.channel),metalnessMapUv:me&&v(M.metalnessMap.channel),roughnessMapUv:fe&&v(M.roughnessMap.channel),anisotropyMapUv:le&&v(M.anisotropyMap.channel),clearcoatMapUv:Ce&&v(M.clearcoatMap.channel),clearcoatNormalMapUv:Ne&&v(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ue&&v(M.clearcoatRoughnessMap.channel),iridescenceMapUv:He&&v(M.iridescenceMap.channel),iridescenceThicknessMapUv:de&&v(M.iridescenceThicknessMap.channel),sheenColorMapUv:we&&v(M.sheenColorMap.channel),sheenRoughnessMapUv:ke&&v(M.sheenRoughnessMap.channel),specularMapUv:_e&&v(M.specularMap.channel),specularColorMapUv:Ae&&v(M.specularColorMap.channel),specularIntensityMapUv:Ve&&v(M.specularIntensityMap.channel),transmissionMapUv:Te&&v(M.transmissionMap.channel),thicknessMapUv:Ke&&v(M.thicknessMap.channel),alphaMapUv:qe&&v(M.alphaMap.channel),vertexTangents:!!ee.attributes.tangent&&(Q||oe),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!ee.attributes.color&&ee.attributes.color.itemSize===4,pointsUvs:W.isPoints===!0&&!!ee.attributes.uv&&(q||qe),fog:!!L,useFog:M.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:M.flatShading===!0&&M.wireframe===!1,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:T,skinning:W.isSkinnedMesh===!0,morphTargets:ee.morphAttributes.position!==void 0,morphNormals:ee.morphAttributes.normal!==void 0,morphColors:ee.morphAttributes.color!==void 0,morphTargetsCount:Z,morphTextureStride:ue,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:t.shadowMap.enabled&&G.length>0,shadowMapType:t.shadowMap.type,toneMapping:We,decodeVideoTexture:q&&M.map.isVideoTexture===!0&&br.getTransfer(M.map.colorSpace)===Ur,decodeVideoTextureEmissive:ie&&M.emissiveMap.isVideoTexture===!0&&br.getTransfer(M.emissiveMap.colorSpace)===Ur,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===kc,flipSided:M.side===ao,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:Be&&M.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Be&&M.extensions.multiDraw===!0||O)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return ct.vertexUv1s=u.has(1),ct.vertexUv2s=u.has(2),ct.vertexUv3s=u.has(3),u.clear(),ct}function y(M){const D=[];if(M.shaderID?D.push(M.shaderID):(D.push(M.customVertexShaderID),D.push(M.customFragmentShaderID)),M.defines!==void 0)for(const G in M.defines)D.push(G),D.push(M.defines[G]);return M.isRawShaderMaterial===!1&&(_(D,M),N(D,M),D.push(t.outputColorSpace)),D.push(M.customProgramCacheKey),D.join()}function _(M,D){M.push(D.precision),M.push(D.outputColorSpace),M.push(D.envMapMode),M.push(D.envMapCubeUVHeight),M.push(D.mapUv),M.push(D.alphaMapUv),M.push(D.lightMapUv),M.push(D.aoMapUv),M.push(D.bumpMapUv),M.push(D.normalMapUv),M.push(D.displacementMapUv),M.push(D.emissiveMapUv),M.push(D.metalnessMapUv),M.push(D.roughnessMapUv),M.push(D.anisotropyMapUv),M.push(D.clearcoatMapUv),M.push(D.clearcoatNormalMapUv),M.push(D.clearcoatRoughnessMapUv),M.push(D.iridescenceMapUv),M.push(D.iridescenceThicknessMapUv),M.push(D.sheenColorMapUv),M.push(D.sheenRoughnessMapUv),M.push(D.specularMapUv),M.push(D.specularColorMapUv),M.push(D.specularIntensityMapUv),M.push(D.transmissionMapUv),M.push(D.thicknessMapUv),M.push(D.combine),M.push(D.fogExp2),M.push(D.sizeAttenuation),M.push(D.morphTargetsCount),M.push(D.morphAttributeCount),M.push(D.numDirLights),M.push(D.numPointLights),M.push(D.numSpotLights),M.push(D.numSpotLightMaps),M.push(D.numHemiLights),M.push(D.numRectAreaLights),M.push(D.numDirLightShadows),M.push(D.numPointLightShadows),M.push(D.numSpotLightShadows),M.push(D.numSpotLightShadowsWithMaps),M.push(D.numLightProbes),M.push(D.shadowMapType),M.push(D.toneMapping),M.push(D.numClippingPlanes),M.push(D.numClipIntersection),M.push(D.depthPacking)}function N(M,D){l.disableAll(),D.supportsVertexTextures&&l.enable(0),D.instancing&&l.enable(1),D.instancingColor&&l.enable(2),D.instancingMorph&&l.enable(3),D.matcap&&l.enable(4),D.envMap&&l.enable(5),D.normalMapObjectSpace&&l.enable(6),D.normalMapTangentSpace&&l.enable(7),D.clearcoat&&l.enable(8),D.iridescence&&l.enable(9),D.alphaTest&&l.enable(10),D.vertexColors&&l.enable(11),D.vertexAlphas&&l.enable(12),D.vertexUv1s&&l.enable(13),D.vertexUv2s&&l.enable(14),D.vertexUv3s&&l.enable(15),D.vertexTangents&&l.enable(16),D.anisotropy&&l.enable(17),D.alphaHash&&l.enable(18),D.batching&&l.enable(19),D.dispersion&&l.enable(20),D.batchingColor&&l.enable(21),D.gradientMap&&l.enable(22),M.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.reversedDepthBuffer&&l.enable(4),D.skinning&&l.enable(5),D.morphTargets&&l.enable(6),D.morphNormals&&l.enable(7),D.morphColors&&l.enable(8),D.premultipliedAlpha&&l.enable(9),D.shadowMapEnabled&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),D.decodeVideoTextureEmissive&&l.enable(20),D.alphaToCoverage&&l.enable(21),M.push(l.mask)}function A(M){const D=x[M.type];let G;if(D){const U=_c[D];G=hxe.clone(U.uniforms)}else G=M.uniforms;return G}function C(M,D){let G;for(let U=0,W=d.length;U<W;U++){const L=d[U];if(L.cacheKey===D){G=L,++G.usedTimes;break}}return G===void 0&&(G=new Wwe(t,D,M,s),d.push(G)),G}function j(M){if(--M.usedTimes===0){const D=d.indexOf(M);d[D]=d[d.length-1],d.pop(),M.destroy()}}function k(M){c.remove(M)}function R(){c.dispose()}return{getParameters:g,getProgramCacheKey:y,getUniforms:A,acquireProgram:C,releaseProgram:j,releaseShaderCache:k,programs:d,dispose:R}}function Zwe(){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 Jwe(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 a6(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,f,p,x,v,g){let y=t[e];return y===void 0?(y={id:h.id,object:h,geometry:f,material:p,groupOrder:x,renderOrder:h.renderOrder,z:v,group:g},t[e]=y):(y.id=h.id,y.object=h,y.geometry=f,y.material=p,y.groupOrder=x,y.renderOrder=h.renderOrder,y.z=v,y.group=g),e++,y}function l(h,f,p,x,v,g){const y=o(h,f,p,x,v,g);p.transmission>0?r.push(y):p.transparent===!0?i.push(y):n.push(y)}function c(h,f,p,x,v,g){const y=o(h,f,p,x,v,g);p.transmission>0?r.unshift(y):p.transparent===!0?i.unshift(y):n.unshift(y)}function u(h,f){n.length>1&&n.sort(h||Jwe),r.length>1&&r.sort(f||a6),i.length>1&&i.sort(f||a6)}function d(){for(let h=e,f=t.length;h<f;h++){const p=t[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function eSe(){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 tSe(){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 xt,color:new Yn};break;case"SpotLight":n={position:new xt,direction:new xt,color:new Yn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new xt,color:new Yn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new xt,skyColor:new Yn,groundColor:new Yn};break;case"RectAreaLight":n={color:new Yn,position:new xt,halfWidth:new xt,halfHeight:new xt};break}return t[e.id]=n,n}}}function nSe(){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 qn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new qn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let rSe=0;function aSe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function iSe(t){const e=new tSe,n=nSe(),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 xt);const i=new xt,s=new oi,o=new oi;function l(u){let d=0,h=0,f=0;for(let M=0;M<9;M++)r.probe[M].set(0,0,0);let p=0,x=0,v=0,g=0,y=0,_=0,N=0,A=0,C=0,j=0,k=0;u.sort(aSe);for(let M=0,D=u.length;M<D;M++){const G=u[M],U=G.color,W=G.intensity,L=G.distance,ee=G.shadow&&G.shadow.map?G.shadow.map.texture:null;if(G.isAmbientLight)d+=U.r*W,h+=U.g*W,f+=U.b*W;else if(G.isLightProbe){for(let ae=0;ae<9;ae++)r.probe[ae].addScaledVector(G.sh.coefficients[ae],W);k++}else if(G.isDirectionalLight){const ae=e.get(G);if(ae.color.copy(G.color).multiplyScalar(G.intensity),G.castShadow){const Y=G.shadow,se=n.get(G);se.shadowIntensity=Y.intensity,se.shadowBias=Y.bias,se.shadowNormalBias=Y.normalBias,se.shadowRadius=Y.radius,se.shadowMapSize=Y.mapSize,r.directionalShadow[p]=se,r.directionalShadowMap[p]=ee,r.directionalShadowMatrix[p]=G.shadow.matrix,_++}r.directional[p]=ae,p++}else if(G.isSpotLight){const ae=e.get(G);ae.position.setFromMatrixPosition(G.matrixWorld),ae.color.copy(U).multiplyScalar(W),ae.distance=L,ae.coneCos=Math.cos(G.angle),ae.penumbraCos=Math.cos(G.angle*(1-G.penumbra)),ae.decay=G.decay,r.spot[v]=ae;const Y=G.shadow;if(G.map&&(r.spotLightMap[C]=G.map,C++,Y.updateMatrices(G),G.castShadow&&j++),r.spotLightMatrix[v]=Y.matrix,G.castShadow){const se=n.get(G);se.shadowIntensity=Y.intensity,se.shadowBias=Y.bias,se.shadowNormalBias=Y.normalBias,se.shadowRadius=Y.radius,se.shadowMapSize=Y.mapSize,r.spotShadow[v]=se,r.spotShadowMap[v]=ee,A++}v++}else if(G.isRectAreaLight){const ae=e.get(G);ae.color.copy(U).multiplyScalar(W),ae.halfWidth.set(G.width*.5,0,0),ae.halfHeight.set(0,G.height*.5,0),r.rectArea[g]=ae,g++}else if(G.isPointLight){const ae=e.get(G);if(ae.color.copy(G.color).multiplyScalar(G.intensity),ae.distance=G.distance,ae.decay=G.decay,G.castShadow){const Y=G.shadow,se=n.get(G);se.shadowIntensity=Y.intensity,se.shadowBias=Y.bias,se.shadowNormalBias=Y.normalBias,se.shadowRadius=Y.radius,se.shadowMapSize=Y.mapSize,se.shadowCameraNear=Y.camera.near,se.shadowCameraFar=Y.camera.far,r.pointShadow[x]=se,r.pointShadowMap[x]=ee,r.pointShadowMatrix[x]=G.shadow.matrix,N++}r.point[x]=ae,x++}else if(G.isHemisphereLight){const ae=e.get(G);ae.skyColor.copy(G.color).multiplyScalar(W),ae.groundColor.copy(G.groundColor).multiplyScalar(W),r.hemi[y]=ae,y++}}g>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=$t.LTC_FLOAT_1,r.rectAreaLTC2=$t.LTC_FLOAT_2):(r.rectAreaLTC1=$t.LTC_HALF_1,r.rectAreaLTC2=$t.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=h,r.ambient[2]=f;const R=r.hash;(R.directionalLength!==p||R.pointLength!==x||R.spotLength!==v||R.rectAreaLength!==g||R.hemiLength!==y||R.numDirectionalShadows!==_||R.numPointShadows!==N||R.numSpotShadows!==A||R.numSpotMaps!==C||R.numLightProbes!==k)&&(r.directional.length=p,r.spot.length=v,r.rectArea.length=g,r.point.length=x,r.hemi.length=y,r.directionalShadow.length=_,r.directionalShadowMap.length=_,r.pointShadow.length=N,r.pointShadowMap.length=N,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=_,r.pointShadowMatrix.length=N,r.spotLightMatrix.length=A+C-j,r.spotLightMap.length=C,r.numSpotLightShadowsWithMaps=j,r.numLightProbes=k,R.directionalLength=p,R.pointLength=x,R.spotLength=v,R.rectAreaLength=g,R.hemiLength=y,R.numDirectionalShadows=_,R.numPointShadows=N,R.numSpotShadows=A,R.numSpotMaps=C,R.numLightProbes=k,r.version=rSe++)}function c(u,d){let h=0,f=0,p=0,x=0,v=0;const g=d.matrixWorldInverse;for(let y=0,_=u.length;y<_;y++){const N=u[y];if(N.isDirectionalLight){const A=r.directional[h];A.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(g),h++}else if(N.isSpotLight){const A=r.spot[p];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(g),A.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(g),p++}else if(N.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(g),o.identity(),s.copy(N.matrixWorld),s.premultiply(g),o.extractRotation(s),A.halfWidth.set(N.width*.5,0,0),A.halfHeight.set(0,N.height*.5,0),A.halfWidth.applyMatrix4(o),A.halfHeight.applyMatrix4(o),x++}else if(N.isPointLight){const A=r.point[f];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(g),f++}else if(N.isHemisphereLight){const A=r.hemi[v];A.direction.setFromMatrixPosition(N.matrixWorld),A.direction.transformDirection(g),v++}}}return{setup:l,setupView:c,state:r}}function s6(t){const e=new iSe(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 sSe(t){let e=new WeakMap;function n(i,s=0){const o=e.get(i);let l;return o===void 0?(l=new s6(t),e.set(i,[l])):s>=o.length?(l=new s6(t),o.push(l)):l=o[s],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const oSe=`void main() {
  3797. gl_Position = vec4( position, 1.0 );
  3798. }`,lSe=`uniform sampler2D shadow_pass;
  3799. uniform vec2 resolution;
  3800. uniform float radius;
  3801. #include <packing>
  3802. void main() {
  3803. const float samples = float( VSM_SAMPLES );
  3804. float mean = 0.0;
  3805. float squared_mean = 0.0;
  3806. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3807. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3808. for ( float i = 0.0; i < samples; i ++ ) {
  3809. float uvOffset = uvStart + i * uvStride;
  3810. #ifdef HORIZONTAL_PASS
  3811. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3812. mean += distribution.x;
  3813. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3814. #else
  3815. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3816. mean += depth;
  3817. squared_mean += depth * depth;
  3818. #endif
  3819. }
  3820. mean = mean / samples;
  3821. squared_mean = squared_mean / samples;
  3822. float std_dev = sqrt( squared_mean - mean * mean );
  3823. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3824. }`;function cSe(t,e,n){let r=new s4;const i=new qn,s=new qn,o=new ti,l=new kxe({depthPacking:Fbe}),c=new Cxe,u={},d=n.maxTextureSize,h={[Qh]:ao,[ao]:Qh,[kc]:kc},f=new od({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new qn},radius:{value:4}},vertexShader:oSe,fragmentShader:lSe}),p=f.clone();p.defines.HORIZONTAL_PASS=1;const x=new Nl;x.setAttribute("position",new Ls(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new kl(x,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=tX;let y=this.type;this.render=function(j,k,R){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||j.length===0)return;const M=t.getRenderTarget(),D=t.getActiveCubeFace(),G=t.getActiveMipmapLevel(),U=t.state;U.setBlending(Wu),U.buffers.depth.getReversed()===!0?U.buffers.color.setClear(0,0,0,0):U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const W=y!==ju&&this.type===ju,L=y===ju&&this.type!==ju;for(let ee=0,ae=j.length;ee<ae;ee++){const Y=j[ee],se=Y.shadow;if(se===void 0){Cn("WebGLShadowMap:",Y,"has no shadow.");continue}if(se.autoUpdate===!1&&se.needsUpdate===!1)continue;i.copy(se.mapSize);const ce=se.getFrameExtents();if(i.multiply(ce),s.copy(se.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/ce.x),i.x=s.x*ce.x,se.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/ce.y),i.y=s.y*ce.y,se.mapSize.y=s.y)),se.map===null||W===!0||L===!0){const Z=this.type!==ju?{minFilter:Eo,magFilter:Eo}:{};se.map!==null&&se.map.dispose(),se.map=new $f(i.x,i.y,Z),se.map.texture.name=Y.name+".shadowMap",se.camera.updateProjectionMatrix()}t.setRenderTarget(se.map),t.clear();const ye=se.getViewportCount();for(let Z=0;Z<ye;Z++){const ue=se.getViewport(Z);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),U.viewport(o),se.updateMatrices(Y,Z),r=se.getFrustum(),A(k,R,se.camera,Y,this.type)}se.isPointLightShadow!==!0&&this.type===ju&&_(se,R),se.needsUpdate=!1}y=this.type,g.needsUpdate=!1,t.setRenderTarget(M,D,G)};function _(j,k){const R=e.update(v);f.defines.VSM_SAMPLES!==j.blurSamples&&(f.defines.VSM_SAMPLES=j.blurSamples,p.defines.VSM_SAMPLES=j.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),j.mapPass===null&&(j.mapPass=new $f(i.x,i.y)),f.uniforms.shadow_pass.value=j.map.texture,f.uniforms.resolution.value=j.mapSize,f.uniforms.radius.value=j.radius,t.setRenderTarget(j.mapPass),t.clear(),t.renderBufferDirect(k,null,R,f,v,null),p.uniforms.shadow_pass.value=j.mapPass.texture,p.uniforms.resolution.value=j.mapSize,p.uniforms.radius.value=j.radius,t.setRenderTarget(j.map),t.clear(),t.renderBufferDirect(k,null,R,p,v,null)}function N(j,k,R,M){let D=null;const G=R.isPointLight===!0?j.customDistanceMaterial:j.customDepthMaterial;if(G!==void 0)D=G;else if(D=R.isPointLight===!0?c:l,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0||k.alphaToCoverage===!0){const U=D.uuid,W=k.uuid;let L=u[U];L===void 0&&(L={},u[U]=L);let ee=L[W];ee===void 0&&(ee=D.clone(),L[W]=ee,k.addEventListener("dispose",C)),D=ee}if(D.visible=k.visible,D.wireframe=k.wireframe,M===ju?D.side=k.shadowSide!==null?k.shadowSide:k.side:D.side=k.shadowSide!==null?k.shadowSide:h[k.side],D.alphaMap=k.alphaMap,D.alphaTest=k.alphaToCoverage===!0?.5:k.alphaTest,D.map=k.map,D.clipShadows=k.clipShadows,D.clippingPlanes=k.clippingPlanes,D.clipIntersection=k.clipIntersection,D.displacementMap=k.displacementMap,D.displacementScale=k.displacementScale,D.displacementBias=k.displacementBias,D.wireframeLinewidth=k.wireframeLinewidth,D.linewidth=k.linewidth,R.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const U=t.properties.get(D);U.light=R}return D}function A(j,k,R,M,D){if(j.visible===!1)return;if(j.layers.test(k.layers)&&(j.isMesh||j.isLine||j.isPoints)&&(j.castShadow||j.receiveShadow&&D===ju)&&(!j.frustumCulled||r.intersectsObject(j))){j.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,j.matrixWorld);const W=e.update(j),L=j.material;if(Array.isArray(L)){const ee=W.groups;for(let ae=0,Y=ee.length;ae<Y;ae++){const se=ee[ae],ce=L[se.materialIndex];if(ce&&ce.visible){const ye=N(j,ce,M,D);j.onBeforeShadow(t,j,k,R,W,ye,se),t.renderBufferDirect(R,null,W,ye,j,se),j.onAfterShadow(t,j,k,R,W,ye,se)}}}else if(L.visible){const ee=N(j,L,M,D);j.onBeforeShadow(t,j,k,R,W,ee,null),t.renderBufferDirect(R,null,W,ee,j,null),j.onAfterShadow(t,j,k,R,W,ee,null)}}const U=j.children;for(let W=0,L=U.length;W<L;W++)A(U[W],k,R,M,D)}function C(j){j.target.removeEventListener("dispose",C);for(const R in u){const M=u[R],D=j.target.uuid;D in M&&(M[D].dispose(),delete M[D])}}}const uSe={[C3]:A3,[T3]:j3,[M3]:E3,[Sb]:P3,[A3]:C3,[j3]:T3,[E3]:M3,[P3]:Sb};function dSe(t,e){function n(){let Te=!1;const Ke=new ti;let je=null;const qe=new ti(0,0,0,0);return{setMask:function(Re){je!==Re&&!Te&&(t.colorMask(Re,Re,Re,Re),je=Re)},setLocked:function(Re){Te=Re},setClear:function(Re,Pe,Be,We,ct){ct===!0&&(Re*=We,Pe*=We,Be*=We),Ke.set(Re,Pe,Be,We),qe.equals(Ke)===!1&&(t.clearColor(Re,Pe,Be,We),qe.copy(Ke))},reset:function(){Te=!1,je=null,qe.set(-1,0,0,0)}}}function r(){let Te=!1,Ke=!1,je=null,qe=null,Re=null;return{setReversed:function(Pe){if(Ke!==Pe){const Be=e.get("EXT_clip_control");Pe?Be.clipControlEXT(Be.LOWER_LEFT_EXT,Be.ZERO_TO_ONE_EXT):Be.clipControlEXT(Be.LOWER_LEFT_EXT,Be.NEGATIVE_ONE_TO_ONE_EXT),Ke=Pe;const We=Re;Re=null,this.setClear(We)}},getReversed:function(){return Ke},setTest:function(Pe){Pe?K(t.DEPTH_TEST):T(t.DEPTH_TEST)},setMask:function(Pe){je!==Pe&&!Te&&(t.depthMask(Pe),je=Pe)},setFunc:function(Pe){if(Ke&&(Pe=uSe[Pe]),qe!==Pe){switch(Pe){case C3:t.depthFunc(t.NEVER);break;case A3:t.depthFunc(t.ALWAYS);break;case T3:t.depthFunc(t.LESS);break;case Sb:t.depthFunc(t.LEQUAL);break;case M3:t.depthFunc(t.EQUAL);break;case P3:t.depthFunc(t.GEQUAL);break;case j3:t.depthFunc(t.GREATER);break;case E3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}qe=Pe}},setLocked:function(Pe){Te=Pe},setClear:function(Pe){Re!==Pe&&(Ke&&(Pe=1-Pe),t.clearDepth(Pe),Re=Pe)},reset:function(){Te=!1,je=null,qe=null,Re=null,Ke=!1}}}function i(){let Te=!1,Ke=null,je=null,qe=null,Re=null,Pe=null,Be=null,We=null,ct=null;return{setTest:function(St){Te||(St?K(t.STENCIL_TEST):T(t.STENCIL_TEST))},setMask:function(St){Ke!==St&&!Te&&(t.stencilMask(St),Ke=St)},setFunc:function(St,Mt,yt){(je!==St||qe!==Mt||Re!==yt)&&(t.stencilFunc(St,Mt,yt),je=St,qe=Mt,Re=yt)},setOp:function(St,Mt,yt){(Pe!==St||Be!==Mt||We!==yt)&&(t.stencilOp(St,Mt,yt),Pe=St,Be=Mt,We=yt)},setLocked:function(St){Te=St},setClear:function(St){ct!==St&&(t.clearStencil(St),ct=St)},reset:function(){Te=!1,Ke=null,je=null,qe=null,Re=null,Pe=null,Be=null,We=null,ct=null}}}const s=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},h={},f=new WeakMap,p=[],x=null,v=!1,g=null,y=null,_=null,N=null,A=null,C=null,j=null,k=new Yn(0,0,0),R=0,M=!1,D=null,G=null,U=null,W=null,L=null;const ee=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ae=!1,Y=0;const se=t.getParameter(t.VERSION);se.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(se)[1]),ae=Y>=1):se.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),ae=Y>=2);let ce=null,ye={};const Z=t.getParameter(t.SCISSOR_BOX),ue=t.getParameter(t.VIEWPORT),pe=new ti().fromArray(Z),be=new ti().fromArray(ue);function Ee(Te,Ke,je,qe){const Re=new Uint8Array(4),Pe=t.createTexture();t.bindTexture(Te,Pe),t.texParameteri(Te,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Te,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Be=0;Be<je;Be++)Te===t.TEXTURE_3D||Te===t.TEXTURE_2D_ARRAY?t.texImage3D(Ke,0,t.RGBA,1,1,qe,0,t.RGBA,t.UNSIGNED_BYTE,Re):t.texImage2D(Ke+Be,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Re);return Pe}const $={};$[t.TEXTURE_2D]=Ee(t.TEXTURE_2D,t.TEXTURE_2D,1),$[t.TEXTURE_CUBE_MAP]=Ee(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),$[t.TEXTURE_2D_ARRAY]=Ee(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),$[t.TEXTURE_3D]=Ee(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),l.setClear(0),K(t.DEPTH_TEST),o.setFunc(Sb),te(!1),Q(r8),K(t.CULL_FACE),z(Wu);function K(Te){d[Te]!==!0&&(t.enable(Te),d[Te]=!0)}function T(Te){d[Te]!==!1&&(t.disable(Te),d[Te]=!1)}function E(Te,Ke){return h[Te]!==Ke?(t.bindFramebuffer(Te,Ke),h[Te]=Ke,Te===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=Ke),Te===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=Ke),!0):!1}function O(Te,Ke){let je=p,qe=!1;if(Te){je=f.get(Ke),je===void 0&&(je=[],f.set(Ke,je));const Re=Te.textures;if(je.length!==Re.length||je[0]!==t.COLOR_ATTACHMENT0){for(let Pe=0,Be=Re.length;Pe<Be;Pe++)je[Pe]=t.COLOR_ATTACHMENT0+Pe;je.length=Re.length,qe=!0}}else je[0]!==t.BACK&&(je[0]=t.BACK,qe=!0);qe&&t.drawBuffers(je)}function q(Te){return x!==Te?(t.useProgram(Te),x=Te,!0):!1}const B={[Qm]:t.FUNC_ADD,[obe]:t.FUNC_SUBTRACT,[lbe]:t.FUNC_REVERSE_SUBTRACT};B[cbe]=t.MIN,B[ube]=t.MAX;const re={[dbe]:t.ZERO,[hbe]:t.ONE,[mbe]:t.SRC_COLOR,[N3]:t.SRC_ALPHA,[ybe]:t.SRC_ALPHA_SATURATE,[bbe]:t.DST_COLOR,[pbe]:t.DST_ALPHA,[fbe]:t.ONE_MINUS_SRC_COLOR,[k3]:t.ONE_MINUS_SRC_ALPHA,[xbe]:t.ONE_MINUS_DST_COLOR,[gbe]:t.ONE_MINUS_DST_ALPHA,[vbe]:t.CONSTANT_COLOR,[wbe]:t.ONE_MINUS_CONSTANT_COLOR,[Sbe]:t.CONSTANT_ALPHA,[_be]:t.ONE_MINUS_CONSTANT_ALPHA};function z(Te,Ke,je,qe,Re,Pe,Be,We,ct,St){if(Te===Wu){v===!0&&(T(t.BLEND),v=!1);return}if(v===!1&&(K(t.BLEND),v=!0),Te!==sbe){if(Te!==g||St!==M){if((y!==Qm||A!==Qm)&&(t.blendEquation(t.FUNC_ADD),y=Qm,A=Qm),St)switch(Te){case ib:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case a8:t.blendFunc(t.ONE,t.ONE);break;case i8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case s8:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Va("WebGLState: Invalid blending: ",Te);break}else switch(Te){case ib:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case a8:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case i8:Va("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case s8:Va("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Va("WebGLState: Invalid blending: ",Te);break}_=null,N=null,C=null,j=null,k.set(0,0,0),R=0,g=Te,M=St}return}Re=Re||Ke,Pe=Pe||je,Be=Be||qe,(Ke!==y||Re!==A)&&(t.blendEquationSeparate(B[Ke],B[Re]),y=Ke,A=Re),(je!==_||qe!==N||Pe!==C||Be!==j)&&(t.blendFuncSeparate(re[je],re[qe],re[Pe],re[Be]),_=je,N=qe,C=Pe,j=Be),(We.equals(k)===!1||ct!==R)&&(t.blendColor(We.r,We.g,We.b,ct),k.copy(We),R=ct),g=Te,M=!1}function V(Te,Ke){Te.side===kc?T(t.CULL_FACE):K(t.CULL_FACE);let je=Te.side===ao;Ke&&(je=!je),te(je),Te.blending===ib&&Te.transparent===!1?z(Wu):z(Te.blending,Te.blendEquation,Te.blendSrc,Te.blendDst,Te.blendEquationAlpha,Te.blendSrcAlpha,Te.blendDstAlpha,Te.blendColor,Te.blendAlpha,Te.premultipliedAlpha),o.setFunc(Te.depthFunc),o.setTest(Te.depthTest),o.setMask(Te.depthWrite),s.setMask(Te.colorWrite);const qe=Te.stencilWrite;l.setTest(qe),qe&&(l.setMask(Te.stencilWriteMask),l.setFunc(Te.stencilFunc,Te.stencilRef,Te.stencilFuncMask),l.setOp(Te.stencilFail,Te.stencilZFail,Te.stencilZPass)),ie(Te.polygonOffset,Te.polygonOffsetFactor,Te.polygonOffsetUnits),Te.alphaToCoverage===!0?K(t.SAMPLE_ALPHA_TO_COVERAGE):T(t.SAMPLE_ALPHA_TO_COVERAGE)}function te(Te){D!==Te&&(Te?t.frontFace(t.CW):t.frontFace(t.CCW),D=Te)}function Q(Te){Te!==rbe?(K(t.CULL_FACE),Te!==G&&(Te===r8?t.cullFace(t.BACK):Te===abe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):T(t.CULL_FACE),G=Te}function ne(Te){Te!==U&&(ae&&t.lineWidth(Te),U=Te)}function ie(Te,Ke,je){Te?(K(t.POLYGON_OFFSET_FILL),(W!==Ke||L!==je)&&(t.polygonOffset(Ke,je),W=Ke,L=je)):T(t.POLYGON_OFFSET_FILL)}function me(Te){Te?K(t.SCISSOR_TEST):T(t.SCISSOR_TEST)}function fe(Te){Te===void 0&&(Te=t.TEXTURE0+ee-1),ce!==Te&&(t.activeTexture(Te),ce=Te)}function oe(Te,Ke,je){je===void 0&&(ce===null?je=t.TEXTURE0+ee-1:je=ce);let qe=ye[je];qe===void 0&&(qe={type:void 0,texture:void 0},ye[je]=qe),(qe.type!==Te||qe.texture!==Ke)&&(ce!==je&&(t.activeTexture(je),ce=je),t.bindTexture(Te,Ke||$[Te]),qe.type=Te,qe.texture=Ke)}function I(){const Te=ye[ce];Te!==void 0&&Te.type!==void 0&&(t.bindTexture(Te.type,null),Te.type=void 0,Te.texture=void 0)}function F(){try{t.compressedTexImage2D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function J(){try{t.compressedTexImage3D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function xe(){try{t.texSubImage2D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function he(){try{t.texSubImage3D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function le(){try{t.compressedTexSubImage2D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function Ce(){try{t.compressedTexSubImage3D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function Ne(){try{t.texStorage2D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function Ue(){try{t.texStorage3D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function He(){try{t.texImage2D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function de(){try{t.texImage3D(...arguments)}catch(Te){Te("WebGLState:",Te)}}function we(Te){pe.equals(Te)===!1&&(t.scissor(Te.x,Te.y,Te.z,Te.w),pe.copy(Te))}function ke(Te){be.equals(Te)===!1&&(t.viewport(Te.x,Te.y,Te.z,Te.w),be.copy(Te))}function _e(Te,Ke){let je=u.get(Ke);je===void 0&&(je=new WeakMap,u.set(Ke,je));let qe=je.get(Te);qe===void 0&&(qe=t.getUniformBlockIndex(Ke,Te.name),je.set(Te,qe))}function Ae(Te,Ke){const qe=u.get(Ke).get(Te);c.get(Ke)!==qe&&(t.uniformBlockBinding(Ke,qe,Te.__bindingPointIndex),c.set(Ke,qe))}function Ve(){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={},ce=null,ye={},h={},f=new WeakMap,p=[],x=null,v=!1,g=null,y=null,_=null,N=null,A=null,C=null,j=null,k=new Yn(0,0,0),R=0,M=!1,D=null,G=null,U=null,W=null,L=null,pe.set(0,0,t.canvas.width,t.canvas.height),be.set(0,0,t.canvas.width,t.canvas.height),s.reset(),o.reset(),l.reset()}return{buffers:{color:s,depth:o,stencil:l},enable:K,disable:T,bindFramebuffer:E,drawBuffers:O,useProgram:q,setBlending:z,setMaterial:V,setFlipSided:te,setCullFace:Q,setLineWidth:ne,setPolygonOffset:ie,setScissorTest:me,activeTexture:fe,bindTexture:oe,unbindTexture:I,compressedTexImage2D:F,compressedTexImage3D:J,texImage2D:He,texImage3D:de,updateUBOMapping:_e,uniformBlockBinding:Ae,texStorage2D:Ne,texStorage3D:Ue,texSubImage2D:xe,texSubImage3D:he,compressedTexSubImage2D:le,compressedTexSubImage3D:Ce,scissor:we,viewport:ke,reset:Ve}}function hSe(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 qn,d=new WeakMap;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(I,F){return p?new OffscreenCanvas(I,F):z1("canvas")}function v(I,F,J){let xe=1;const he=oe(I);if((he.width>J||he.height>J)&&(xe=J/Math.max(he.width,he.height)),xe<1)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap||typeof VideoFrame<"u"&&I instanceof VideoFrame){const le=Math.floor(xe*he.width),Ce=Math.floor(xe*he.height);h===void 0&&(h=x(le,Ce));const Ne=F?x(le,Ce):h;return Ne.width=le,Ne.height=Ce,Ne.getContext("2d").drawImage(I,0,0,le,Ce),Cn("WebGLRenderer: Texture has been resized from ("+he.width+"x"+he.height+") to ("+le+"x"+Ce+")."),Ne}else return"data"in I&&Cn("WebGLRenderer: Image in DataTexture is too big ("+he.width+"x"+he.height+")."),I;return I}function g(I){return I.generateMipmaps}function y(I){t.generateMipmap(I)}function _(I){return I.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:I.isWebGL3DRenderTarget?t.TEXTURE_3D:I.isWebGLArrayRenderTarget||I.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function N(I,F,J,xe,he=!1){if(I!==null){if(t[I]!==void 0)return t[I];Cn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let le=F;if(F===t.RED&&(J===t.FLOAT&&(le=t.R32F),J===t.HALF_FLOAT&&(le=t.R16F),J===t.UNSIGNED_BYTE&&(le=t.R8)),F===t.RED_INTEGER&&(J===t.UNSIGNED_BYTE&&(le=t.R8UI),J===t.UNSIGNED_SHORT&&(le=t.R16UI),J===t.UNSIGNED_INT&&(le=t.R32UI),J===t.BYTE&&(le=t.R8I),J===t.SHORT&&(le=t.R16I),J===t.INT&&(le=t.R32I)),F===t.RG&&(J===t.FLOAT&&(le=t.RG32F),J===t.HALF_FLOAT&&(le=t.RG16F),J===t.UNSIGNED_BYTE&&(le=t.RG8)),F===t.RG_INTEGER&&(J===t.UNSIGNED_BYTE&&(le=t.RG8UI),J===t.UNSIGNED_SHORT&&(le=t.RG16UI),J===t.UNSIGNED_INT&&(le=t.RG32UI),J===t.BYTE&&(le=t.RG8I),J===t.SHORT&&(le=t.RG16I),J===t.INT&&(le=t.RG32I)),F===t.RGB_INTEGER&&(J===t.UNSIGNED_BYTE&&(le=t.RGB8UI),J===t.UNSIGNED_SHORT&&(le=t.RGB16UI),J===t.UNSIGNED_INT&&(le=t.RGB32UI),J===t.BYTE&&(le=t.RGB8I),J===t.SHORT&&(le=t.RGB16I),J===t.INT&&(le=t.RGB32I)),F===t.RGBA_INTEGER&&(J===t.UNSIGNED_BYTE&&(le=t.RGBA8UI),J===t.UNSIGNED_SHORT&&(le=t.RGBA16UI),J===t.UNSIGNED_INT&&(le=t.RGBA32UI),J===t.BYTE&&(le=t.RGBA8I),J===t.SHORT&&(le=t.RGBA16I),J===t.INT&&(le=t.RGBA32I)),F===t.RGB&&(J===t.UNSIGNED_INT_5_9_9_9_REV&&(le=t.RGB9_E5),J===t.UNSIGNED_INT_10F_11F_11F_REV&&(le=t.R11F_G11F_B10F)),F===t.RGBA){const Ce=he?O1:br.getTransfer(xe);J===t.FLOAT&&(le=t.RGBA32F),J===t.HALF_FLOAT&&(le=t.RGBA16F),J===t.UNSIGNED_BYTE&&(le=Ce===Ur?t.SRGB8_ALPHA8:t.RGBA8),J===t.UNSIGNED_SHORT_4_4_4_4&&(le=t.RGBA4),J===t.UNSIGNED_SHORT_5_5_5_1&&(le=t.RGB5_A1)}return(le===t.R16F||le===t.R32F||le===t.RG16F||le===t.RG32F||le===t.RGBA16F||le===t.RGBA32F)&&e.get("EXT_color_buffer_float"),le}function A(I,F){let J;return I?F===null||F===Bf||F===M0?J=t.DEPTH24_STENCIL8:F===Bu?J=t.DEPTH32F_STENCIL8:F===T0&&(J=t.DEPTH24_STENCIL8,Cn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):F===null||F===Bf||F===M0?J=t.DEPTH_COMPONENT24:F===Bu?J=t.DEPTH_COMPONENT32F:F===T0&&(J=t.DEPTH_COMPONENT16),J}function C(I,F){return g(I)===!0||I.isFramebufferTexture&&I.minFilter!==Eo&&I.minFilter!==pl?Math.log2(Math.max(F.width,F.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?F.mipmaps.length:1}function j(I){const F=I.target;F.removeEventListener("dispose",j),R(F),F.isVideoTexture&&d.delete(F)}function k(I){const F=I.target;F.removeEventListener("dispose",k),D(F)}function R(I){const F=r.get(I);if(F.__webglInit===void 0)return;const J=I.source,xe=f.get(J);if(xe){const he=xe[F.__cacheKey];he.usedTimes--,he.usedTimes===0&&M(I),Object.keys(xe).length===0&&f.delete(J)}r.remove(I)}function M(I){const F=r.get(I);t.deleteTexture(F.__webglTexture);const J=I.source,xe=f.get(J);delete xe[F.__cacheKey],o.memory.textures--}function D(I){const F=r.get(I);if(I.depthTexture&&(I.depthTexture.dispose(),r.remove(I.depthTexture)),I.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++){if(Array.isArray(F.__webglFramebuffer[xe]))for(let he=0;he<F.__webglFramebuffer[xe].length;he++)t.deleteFramebuffer(F.__webglFramebuffer[xe][he]);else t.deleteFramebuffer(F.__webglFramebuffer[xe]);F.__webglDepthbuffer&&t.deleteRenderbuffer(F.__webglDepthbuffer[xe])}else{if(Array.isArray(F.__webglFramebuffer))for(let xe=0;xe<F.__webglFramebuffer.length;xe++)t.deleteFramebuffer(F.__webglFramebuffer[xe]);else t.deleteFramebuffer(F.__webglFramebuffer);if(F.__webglDepthbuffer&&t.deleteRenderbuffer(F.__webglDepthbuffer),F.__webglMultisampledFramebuffer&&t.deleteFramebuffer(F.__webglMultisampledFramebuffer),F.__webglColorRenderbuffer)for(let xe=0;xe<F.__webglColorRenderbuffer.length;xe++)F.__webglColorRenderbuffer[xe]&&t.deleteRenderbuffer(F.__webglColorRenderbuffer[xe]);F.__webglDepthRenderbuffer&&t.deleteRenderbuffer(F.__webglDepthRenderbuffer)}const J=I.textures;for(let xe=0,he=J.length;xe<he;xe++){const le=r.get(J[xe]);le.__webglTexture&&(t.deleteTexture(le.__webglTexture),o.memory.textures--),r.remove(J[xe])}r.remove(I)}let G=0;function U(){G=0}function W(){const I=G;return I>=i.maxTextures&&Cn("WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+i.maxTextures),G+=1,I}function L(I){const F=[];return F.push(I.wrapS),F.push(I.wrapT),F.push(I.wrapR||0),F.push(I.magFilter),F.push(I.minFilter),F.push(I.anisotropy),F.push(I.internalFormat),F.push(I.format),F.push(I.type),F.push(I.generateMipmaps),F.push(I.premultiplyAlpha),F.push(I.flipY),F.push(I.unpackAlignment),F.push(I.colorSpace),F.join()}function ee(I,F){const J=r.get(I);if(I.isVideoTexture&&me(I),I.isRenderTargetTexture===!1&&I.isExternalTexture!==!0&&I.version>0&&J.__version!==I.version){const xe=I.image;if(xe===null)Cn("WebGLRenderer: Texture marked for update but no image data found.");else if(xe.complete===!1)Cn("WebGLRenderer: Texture marked for update but image is incomplete");else{$(J,I,F);return}}else I.isExternalTexture&&(J.__webglTexture=I.sourceTexture?I.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,J.__webglTexture,t.TEXTURE0+F)}function ae(I,F){const J=r.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&J.__version!==I.version){$(J,I,F);return}else I.isExternalTexture&&(J.__webglTexture=I.sourceTexture?I.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,J.__webglTexture,t.TEXTURE0+F)}function Y(I,F){const J=r.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&J.__version!==I.version){$(J,I,F);return}n.bindTexture(t.TEXTURE_3D,J.__webglTexture,t.TEXTURE0+F)}function se(I,F){const J=r.get(I);if(I.version>0&&J.__version!==I.version){K(J,I,F);return}n.bindTexture(t.TEXTURE_CUBE_MAP,J.__webglTexture,t.TEXTURE0+F)}const ce={[F3]:t.REPEAT,[Uu]:t.CLAMP_TO_EDGE,[L3]:t.MIRRORED_REPEAT},ye={[Eo]:t.NEAREST,[Dbe]:t.NEAREST_MIPMAP_NEAREST,[hS]:t.NEAREST_MIPMAP_LINEAR,[pl]:t.LINEAR,[Q2]:t.LINEAR_MIPMAP_NEAREST,[sf]:t.LINEAR_MIPMAP_LINEAR},Z={[Obe]:t.NEVER,[$be]:t.ALWAYS,[Ibe]:t.LESS,[dX]:t.LEQUAL,[zbe]:t.EQUAL,[Hbe]:t.GEQUAL,[Ube]:t.GREATER,[Bbe]:t.NOTEQUAL};function ue(I,F){if(F.type===Bu&&e.has("OES_texture_float_linear")===!1&&(F.magFilter===pl||F.magFilter===Q2||F.magFilter===hS||F.magFilter===sf||F.minFilter===pl||F.minFilter===Q2||F.minFilter===hS||F.minFilter===sf)&&Cn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(I,t.TEXTURE_WRAP_S,ce[F.wrapS]),t.texParameteri(I,t.TEXTURE_WRAP_T,ce[F.wrapT]),(I===t.TEXTURE_3D||I===t.TEXTURE_2D_ARRAY)&&t.texParameteri(I,t.TEXTURE_WRAP_R,ce[F.wrapR]),t.texParameteri(I,t.TEXTURE_MAG_FILTER,ye[F.magFilter]),t.texParameteri(I,t.TEXTURE_MIN_FILTER,ye[F.minFilter]),F.compareFunction&&(t.texParameteri(I,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(I,t.TEXTURE_COMPARE_FUNC,Z[F.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(F.magFilter===Eo||F.minFilter!==hS&&F.minFilter!==sf||F.type===Bu&&e.has("OES_texture_float_linear")===!1)return;if(F.anisotropy>1||r.get(F).__currentAnisotropy){const J=e.get("EXT_texture_filter_anisotropic");t.texParameterf(I,J.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(F.anisotropy,i.getMaxAnisotropy())),r.get(F).__currentAnisotropy=F.anisotropy}}}function pe(I,F){let J=!1;I.__webglInit===void 0&&(I.__webglInit=!0,F.addEventListener("dispose",j));const xe=F.source;let he=f.get(xe);he===void 0&&(he={},f.set(xe,he));const le=L(F);if(le!==I.__cacheKey){he[le]===void 0&&(he[le]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,J=!0),he[le].usedTimes++;const Ce=he[I.__cacheKey];Ce!==void 0&&(he[I.__cacheKey].usedTimes--,Ce.usedTimes===0&&M(F)),I.__cacheKey=le,I.__webglTexture=he[le].texture}return J}function be(I,F,J){return Math.floor(Math.floor(I/J)/F)}function Ee(I,F,J,xe){const le=I.updateRanges;if(le.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,F.width,F.height,J,xe,F.data);else{le.sort((de,we)=>de.start-we.start);let Ce=0;for(let de=1;de<le.length;de++){const we=le[Ce],ke=le[de],_e=we.start+we.count,Ae=be(ke.start,F.width,4),Ve=be(we.start,F.width,4);ke.start<=_e+1&&Ae===Ve&&be(ke.start+ke.count-1,F.width,4)===Ae?we.count=Math.max(we.count,ke.start+ke.count-we.start):(++Ce,le[Ce]=ke)}le.length=Ce+1;const Ne=t.getParameter(t.UNPACK_ROW_LENGTH),Ue=t.getParameter(t.UNPACK_SKIP_PIXELS),He=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,F.width);for(let de=0,we=le.length;de<we;de++){const ke=le[de],_e=Math.floor(ke.start/4),Ae=Math.ceil(ke.count/4),Ve=_e%F.width,Te=Math.floor(_e/F.width),Ke=Ae,je=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ve),t.pixelStorei(t.UNPACK_SKIP_ROWS,Te),n.texSubImage2D(t.TEXTURE_2D,0,Ve,Te,Ke,je,J,xe,F.data)}I.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ne),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ue),t.pixelStorei(t.UNPACK_SKIP_ROWS,He)}}function $(I,F,J){let xe=t.TEXTURE_2D;(F.isDataArrayTexture||F.isCompressedArrayTexture)&&(xe=t.TEXTURE_2D_ARRAY),F.isData3DTexture&&(xe=t.TEXTURE_3D);const he=pe(I,F),le=F.source;n.bindTexture(xe,I.__webglTexture,t.TEXTURE0+J);const Ce=r.get(le);if(le.version!==Ce.__version||he===!0){n.activeTexture(t.TEXTURE0+J);const Ne=br.getPrimaries(br.workingColorSpace),Ue=F.colorSpace===bh?null:br.getPrimaries(F.colorSpace),He=F.colorSpace===bh||Ne===Ue?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,F.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,F.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);let de=v(F.image,!1,i.maxTextureSize);de=fe(F,de);const we=s.convert(F.format,F.colorSpace),ke=s.convert(F.type);let _e=N(F.internalFormat,we,ke,F.colorSpace,F.isVideoTexture);ue(xe,F);let Ae;const Ve=F.mipmaps,Te=F.isVideoTexture!==!0,Ke=Ce.__version===void 0||he===!0,je=le.dataReady,qe=C(F,de);if(F.isDepthTexture)_e=A(F.format===j0,F.type),Ke&&(Te?n.texStorage2D(t.TEXTURE_2D,1,_e,de.width,de.height):n.texImage2D(t.TEXTURE_2D,0,_e,de.width,de.height,0,we,ke,null));else if(F.isDataTexture)if(Ve.length>0){Te&&Ke&&n.texStorage2D(t.TEXTURE_2D,qe,_e,Ve[0].width,Ve[0].height);for(let Re=0,Pe=Ve.length;Re<Pe;Re++)Ae=Ve[Re],Te?je&&n.texSubImage2D(t.TEXTURE_2D,Re,0,0,Ae.width,Ae.height,we,ke,Ae.data):n.texImage2D(t.TEXTURE_2D,Re,_e,Ae.width,Ae.height,0,we,ke,Ae.data);F.generateMipmaps=!1}else Te?(Ke&&n.texStorage2D(t.TEXTURE_2D,qe,_e,de.width,de.height),je&&Ee(F,de,we,ke)):n.texImage2D(t.TEXTURE_2D,0,_e,de.width,de.height,0,we,ke,de.data);else if(F.isCompressedTexture)if(F.isCompressedArrayTexture){Te&&Ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,qe,_e,Ve[0].width,Ve[0].height,de.depth);for(let Re=0,Pe=Ve.length;Re<Pe;Re++)if(Ae=Ve[Re],F.format!==Yl)if(we!==null)if(Te){if(je)if(F.layerUpdates.size>0){const Be=O8(Ae.width,Ae.height,F.format,F.type);for(const We of F.layerUpdates){const ct=Ae.data.subarray(We*Be/Ae.data.BYTES_PER_ELEMENT,(We+1)*Be/Ae.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,We,Ae.width,Ae.height,1,we,ct)}F.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,0,Ae.width,Ae.height,de.depth,we,Ae.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Re,_e,Ae.width,Ae.height,de.depth,0,Ae.data,0,0);else Cn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Te?je&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,0,Ae.width,Ae.height,de.depth,we,ke,Ae.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Re,_e,Ae.width,Ae.height,de.depth,0,we,ke,Ae.data)}else{Te&&Ke&&n.texStorage2D(t.TEXTURE_2D,qe,_e,Ve[0].width,Ve[0].height);for(let Re=0,Pe=Ve.length;Re<Pe;Re++)Ae=Ve[Re],F.format!==Yl?we!==null?Te?je&&n.compressedTexSubImage2D(t.TEXTURE_2D,Re,0,0,Ae.width,Ae.height,we,Ae.data):n.compressedTexImage2D(t.TEXTURE_2D,Re,_e,Ae.width,Ae.height,0,Ae.data):Cn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Te?je&&n.texSubImage2D(t.TEXTURE_2D,Re,0,0,Ae.width,Ae.height,we,ke,Ae.data):n.texImage2D(t.TEXTURE_2D,Re,_e,Ae.width,Ae.height,0,we,ke,Ae.data)}else if(F.isDataArrayTexture)if(Te){if(Ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,qe,_e,de.width,de.height,de.depth),je)if(F.layerUpdates.size>0){const Re=O8(de.width,de.height,F.format,F.type);for(const Pe of F.layerUpdates){const Be=de.data.subarray(Pe*Re/de.data.BYTES_PER_ELEMENT,(Pe+1)*Re/de.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Pe,de.width,de.height,1,we,ke,Be)}F.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,de.width,de.height,de.depth,we,ke,de.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,_e,de.width,de.height,de.depth,0,we,ke,de.data);else if(F.isData3DTexture)Te?(Ke&&n.texStorage3D(t.TEXTURE_3D,qe,_e,de.width,de.height,de.depth),je&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,de.width,de.height,de.depth,we,ke,de.data)):n.texImage3D(t.TEXTURE_3D,0,_e,de.width,de.height,de.depth,0,we,ke,de.data);else if(F.isFramebufferTexture){if(Ke)if(Te)n.texStorage2D(t.TEXTURE_2D,qe,_e,de.width,de.height);else{let Re=de.width,Pe=de.height;for(let Be=0;Be<qe;Be++)n.texImage2D(t.TEXTURE_2D,Be,_e,Re,Pe,0,we,ke,null),Re>>=1,Pe>>=1}}else if(Ve.length>0){if(Te&&Ke){const Re=oe(Ve[0]);n.texStorage2D(t.TEXTURE_2D,qe,_e,Re.width,Re.height)}for(let Re=0,Pe=Ve.length;Re<Pe;Re++)Ae=Ve[Re],Te?je&&n.texSubImage2D(t.TEXTURE_2D,Re,0,0,we,ke,Ae):n.texImage2D(t.TEXTURE_2D,Re,_e,we,ke,Ae);F.generateMipmaps=!1}else if(Te){if(Ke){const Re=oe(de);n.texStorage2D(t.TEXTURE_2D,qe,_e,Re.width,Re.height)}je&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,we,ke,de)}else n.texImage2D(t.TEXTURE_2D,0,_e,we,ke,de);g(F)&&y(xe),Ce.__version=le.version,F.onUpdate&&F.onUpdate(F)}I.__version=F.version}function K(I,F,J){if(F.image.length!==6)return;const xe=pe(I,F),he=F.source;n.bindTexture(t.TEXTURE_CUBE_MAP,I.__webglTexture,t.TEXTURE0+J);const le=r.get(he);if(he.version!==le.__version||xe===!0){n.activeTexture(t.TEXTURE0+J);const Ce=br.getPrimaries(br.workingColorSpace),Ne=F.colorSpace===bh?null:br.getPrimaries(F.colorSpace),Ue=F.colorSpace===bh||Ce===Ne?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,F.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,F.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ue);const He=F.isCompressedTexture||F.image[0].isCompressedTexture,de=F.image[0]&&F.image[0].isDataTexture,we=[];for(let Pe=0;Pe<6;Pe++)!He&&!de?we[Pe]=v(F.image[Pe],!0,i.maxCubemapSize):we[Pe]=de?F.image[Pe].image:F.image[Pe],we[Pe]=fe(F,we[Pe]);const ke=we[0],_e=s.convert(F.format,F.colorSpace),Ae=s.convert(F.type),Ve=N(F.internalFormat,_e,Ae,F.colorSpace),Te=F.isVideoTexture!==!0,Ke=le.__version===void 0||xe===!0,je=he.dataReady;let qe=C(F,ke);ue(t.TEXTURE_CUBE_MAP,F);let Re;if(He){Te&&Ke&&n.texStorage2D(t.TEXTURE_CUBE_MAP,qe,Ve,ke.width,ke.height);for(let Pe=0;Pe<6;Pe++){Re=we[Pe].mipmaps;for(let Be=0;Be<Re.length;Be++){const We=Re[Be];F.format!==Yl?_e!==null?Te?je&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be,0,0,We.width,We.height,_e,We.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be,Ve,We.width,We.height,0,We.data):Cn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Te?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be,0,0,We.width,We.height,_e,Ae,We.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be,Ve,We.width,We.height,0,_e,Ae,We.data)}}}else{if(Re=F.mipmaps,Te&&Ke){Re.length>0&&qe++;const Pe=oe(we[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,qe,Ve,Pe.width,Pe.height)}for(let Pe=0;Pe<6;Pe++)if(de){Te?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0,0,0,we[Pe].width,we[Pe].height,_e,Ae,we[Pe].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0,Ve,we[Pe].width,we[Pe].height,0,_e,Ae,we[Pe].data);for(let Be=0;Be<Re.length;Be++){const ct=Re[Be].image[Pe].image;Te?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be+1,0,0,ct.width,ct.height,_e,Ae,ct.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be+1,Ve,ct.width,ct.height,0,_e,Ae,ct.data)}}else{Te?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0,0,0,_e,Ae,we[Pe]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0,Ve,_e,Ae,we[Pe]);for(let Be=0;Be<Re.length;Be++){const We=Re[Be];Te?je&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be+1,0,0,_e,Ae,We.image[Pe]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be+1,Ve,_e,Ae,We.image[Pe])}}}g(F)&&y(t.TEXTURE_CUBE_MAP),le.__version=he.version,F.onUpdate&&F.onUpdate(F)}I.__version=F.version}function T(I,F,J,xe,he,le){const Ce=s.convert(J.format,J.colorSpace),Ne=s.convert(J.type),Ue=N(J.internalFormat,Ce,Ne,J.colorSpace),He=r.get(F),de=r.get(J);if(de.__renderTarget=F,!He.__hasExternalTextures){const we=Math.max(1,F.width>>le),ke=Math.max(1,F.height>>le);he===t.TEXTURE_3D||he===t.TEXTURE_2D_ARRAY?n.texImage3D(he,le,Ue,we,ke,F.depth,0,Ce,Ne,null):n.texImage2D(he,le,Ue,we,ke,0,Ce,Ne,null)}n.bindFramebuffer(t.FRAMEBUFFER,I),ie(F)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,xe,he,de.__webglTexture,0,ne(F)):(he===t.TEXTURE_2D||he>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&he<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,xe,he,de.__webglTexture,le),n.bindFramebuffer(t.FRAMEBUFFER,null)}function E(I,F,J){if(t.bindRenderbuffer(t.RENDERBUFFER,I),F.depthBuffer){const xe=F.depthTexture,he=xe&&xe.isDepthTexture?xe.type:null,le=A(F.stencilBuffer,he),Ce=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ne=ne(F);ie(F)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ne,le,F.width,F.height):J?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ne,le,F.width,F.height):t.renderbufferStorage(t.RENDERBUFFER,le,F.width,F.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ce,t.RENDERBUFFER,I)}else{const xe=F.textures;for(let he=0;he<xe.length;he++){const le=xe[he],Ce=s.convert(le.format,le.colorSpace),Ne=s.convert(le.type),Ue=N(le.internalFormat,Ce,Ne,le.colorSpace),He=ne(F);J&&ie(F)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,He,Ue,F.width,F.height):ie(F)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,He,Ue,F.width,F.height):t.renderbufferStorage(t.RENDERBUFFER,Ue,F.width,F.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function O(I,F){if(F&&F.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,I),!(F.depthTexture&&F.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const xe=r.get(F.depthTexture);xe.__renderTarget=F,(!xe.__webglTexture||F.depthTexture.image.width!==F.width||F.depthTexture.image.height!==F.height)&&(F.depthTexture.image.width=F.width,F.depthTexture.image.height=F.height,F.depthTexture.needsUpdate=!0),ee(F.depthTexture,0);const he=xe.__webglTexture,le=ne(F);if(F.depthTexture.format===P0)ie(F)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,he,0,le):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,he,0);else if(F.depthTexture.format===j0)ie(F)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,he,0,le):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,he,0);else throw new Error("Unknown depthTexture format")}function q(I){const F=r.get(I),J=I.isWebGLCubeRenderTarget===!0;if(F.__boundDepthTexture!==I.depthTexture){const xe=I.depthTexture;if(F.__depthDisposeCallback&&F.__depthDisposeCallback(),xe){const he=()=>{delete F.__boundDepthTexture,delete F.__depthDisposeCallback,xe.removeEventListener("dispose",he)};xe.addEventListener("dispose",he),F.__depthDisposeCallback=he}F.__boundDepthTexture=xe}if(I.depthTexture&&!F.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");const xe=I.texture.mipmaps;xe&&xe.length>0?O(F.__webglFramebuffer[0],I):O(F.__webglFramebuffer,I)}else if(J){F.__webglDepthbuffer=[];for(let xe=0;xe<6;xe++)if(n.bindFramebuffer(t.FRAMEBUFFER,F.__webglFramebuffer[xe]),F.__webglDepthbuffer[xe]===void 0)F.__webglDepthbuffer[xe]=t.createRenderbuffer(),E(F.__webglDepthbuffer[xe],I,!1);else{const he=I.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,le=F.__webglDepthbuffer[xe];t.bindRenderbuffer(t.RENDERBUFFER,le),t.framebufferRenderbuffer(t.FRAMEBUFFER,he,t.RENDERBUFFER,le)}}else{const xe=I.texture.mipmaps;if(xe&&xe.length>0?n.bindFramebuffer(t.FRAMEBUFFER,F.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,F.__webglFramebuffer),F.__webglDepthbuffer===void 0)F.__webglDepthbuffer=t.createRenderbuffer(),E(F.__webglDepthbuffer,I,!1);else{const he=I.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,le=F.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,le),t.framebufferRenderbuffer(t.FRAMEBUFFER,he,t.RENDERBUFFER,le)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function B(I,F,J){const xe=r.get(I);F!==void 0&&T(xe.__webglFramebuffer,I,I.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),J!==void 0&&q(I)}function re(I){const F=I.texture,J=r.get(I),xe=r.get(F);I.addEventListener("dispose",k);const he=I.textures,le=I.isWebGLCubeRenderTarget===!0,Ce=he.length>1;if(Ce||(xe.__webglTexture===void 0&&(xe.__webglTexture=t.createTexture()),xe.__version=F.version,o.memory.textures++),le){J.__webglFramebuffer=[];for(let Ne=0;Ne<6;Ne++)if(F.mipmaps&&F.mipmaps.length>0){J.__webglFramebuffer[Ne]=[];for(let Ue=0;Ue<F.mipmaps.length;Ue++)J.__webglFramebuffer[Ne][Ue]=t.createFramebuffer()}else J.__webglFramebuffer[Ne]=t.createFramebuffer()}else{if(F.mipmaps&&F.mipmaps.length>0){J.__webglFramebuffer=[];for(let Ne=0;Ne<F.mipmaps.length;Ne++)J.__webglFramebuffer[Ne]=t.createFramebuffer()}else J.__webglFramebuffer=t.createFramebuffer();if(Ce)for(let Ne=0,Ue=he.length;Ne<Ue;Ne++){const He=r.get(he[Ne]);He.__webglTexture===void 0&&(He.__webglTexture=t.createTexture(),o.memory.textures++)}if(I.samples>0&&ie(I)===!1){J.__webglMultisampledFramebuffer=t.createFramebuffer(),J.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,J.__webglMultisampledFramebuffer);for(let Ne=0;Ne<he.length;Ne++){const Ue=he[Ne];J.__webglColorRenderbuffer[Ne]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,J.__webglColorRenderbuffer[Ne]);const He=s.convert(Ue.format,Ue.colorSpace),de=s.convert(Ue.type),we=N(Ue.internalFormat,He,de,Ue.colorSpace,I.isXRRenderTarget===!0),ke=ne(I);t.renderbufferStorageMultisample(t.RENDERBUFFER,ke,we,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ne,t.RENDERBUFFER,J.__webglColorRenderbuffer[Ne])}t.bindRenderbuffer(t.RENDERBUFFER,null),I.depthBuffer&&(J.__webglDepthRenderbuffer=t.createRenderbuffer(),E(J.__webglDepthRenderbuffer,I,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(le){n.bindTexture(t.TEXTURE_CUBE_MAP,xe.__webglTexture),ue(t.TEXTURE_CUBE_MAP,F);for(let Ne=0;Ne<6;Ne++)if(F.mipmaps&&F.mipmaps.length>0)for(let Ue=0;Ue<F.mipmaps.length;Ue++)T(J.__webglFramebuffer[Ne][Ue],I,F,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Ue);else T(J.__webglFramebuffer[Ne],I,F,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0);g(F)&&y(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Ce){for(let Ne=0,Ue=he.length;Ne<Ue;Ne++){const He=he[Ne],de=r.get(He);let we=t.TEXTURE_2D;(I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(we=I.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(we,de.__webglTexture),ue(we,He),T(J.__webglFramebuffer,I,He,t.COLOR_ATTACHMENT0+Ne,we,0),g(He)&&y(we)}n.unbindTexture()}else{let Ne=t.TEXTURE_2D;if((I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(Ne=I.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ne,xe.__webglTexture),ue(Ne,F),F.mipmaps&&F.mipmaps.length>0)for(let Ue=0;Ue<F.mipmaps.length;Ue++)T(J.__webglFramebuffer[Ue],I,F,t.COLOR_ATTACHMENT0,Ne,Ue);else T(J.__webglFramebuffer,I,F,t.COLOR_ATTACHMENT0,Ne,0);g(F)&&y(Ne),n.unbindTexture()}I.depthBuffer&&q(I)}function z(I){const F=I.textures;for(let J=0,xe=F.length;J<xe;J++){const he=F[J];if(g(he)){const le=_(I),Ce=r.get(he).__webglTexture;n.bindTexture(le,Ce),y(le),n.unbindTexture()}}}const V=[],te=[];function Q(I){if(I.samples>0){if(ie(I)===!1){const F=I.textures,J=I.width,xe=I.height;let he=t.COLOR_BUFFER_BIT;const le=I.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ce=r.get(I),Ne=F.length>1;if(Ne)for(let He=0;He<F.length;He++)n.bindFramebuffer(t.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ce.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer);const Ue=I.texture.mipmaps;Ue&&Ue.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ce.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ce.__webglFramebuffer);for(let He=0;He<F.length;He++){if(I.resolveDepthBuffer&&(I.depthBuffer&&(he|=t.DEPTH_BUFFER_BIT),I.stencilBuffer&&I.resolveStencilBuffer&&(he|=t.STENCIL_BUFFER_BIT)),Ne){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ce.__webglColorRenderbuffer[He]);const de=r.get(F[He]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,de,0)}t.blitFramebuffer(0,0,J,xe,0,0,J,xe,he,t.NEAREST),c===!0&&(V.length=0,te.length=0,V.push(t.COLOR_ATTACHMENT0+He),I.depthBuffer&&I.resolveDepthBuffer===!1&&(V.push(le),te.push(le),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,te)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,V))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ne)for(let He=0;He<F.length;He++){n.bindFramebuffer(t.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.RENDERBUFFER,Ce.__webglColorRenderbuffer[He]);const de=r.get(F[He]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ce.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.TEXTURE_2D,de,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ce.__webglMultisampledFramebuffer)}else if(I.depthBuffer&&I.resolveDepthBuffer===!1&&c){const F=I.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[F])}}}function ne(I){return Math.min(i.maxSamples,I.samples)}function ie(I){const F=r.get(I);return I.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&F.__useRenderToTexture!==!1}function me(I){const F=o.render.frame;d.get(I)!==F&&(d.set(I,F),I.update())}function fe(I,F){const J=I.colorSpace,xe=I.format,he=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||J!==kb&&J!==bh&&(br.getTransfer(J)===Ur?(xe!==Yl||he!==zc)&&Cn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Va("WebGLTextures: Unsupported texture color space:",J)),F}function oe(I){return typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement?(u.width=I.naturalWidth||I.width,u.height=I.naturalHeight||I.height):typeof VideoFrame<"u"&&I instanceof VideoFrame?(u.width=I.displayWidth,u.height=I.displayHeight):(u.width=I.width,u.height=I.height),u}this.allocateTextureUnit=W,this.resetTextureUnits=U,this.setTexture2D=ee,this.setTexture2DArray=ae,this.setTexture3D=Y,this.setTextureCube=se,this.rebindTextures=B,this.setupRenderTarget=re,this.updateRenderTargetMipmap=z,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=q,this.setupFrameBufferTexture=T,this.useMultisampledRTT=ie}function mSe(t,e){function n(r,i=bh){let s;const o=br.getTransfer(i);if(r===zc)return t.UNSIGNED_BYTE;if(r===XF)return t.UNSIGNED_SHORT_4_4_4_4;if(r===QF)return t.UNSIGNED_SHORT_5_5_5_1;if(r===iX)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===sX)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===rX)return t.BYTE;if(r===aX)return t.SHORT;if(r===T0)return t.UNSIGNED_SHORT;if(r===YF)return t.INT;if(r===Bf)return t.UNSIGNED_INT;if(r===Bu)return t.FLOAT;if(r===tx)return t.HALF_FLOAT;if(r===oX)return t.ALPHA;if(r===lX)return t.RGB;if(r===Yl)return t.RGBA;if(r===P0)return t.DEPTH_COMPONENT;if(r===j0)return t.DEPTH_STENCIL;if(r===cX)return t.RED;if(r===ZF)return t.RED_INTEGER;if(r===JF)return t.RG;if(r===e4)return t.RG_INTEGER;if(r===t4)return t.RGBA_INTEGER;if(r===J_||r===e1||r===t1||r===n1)if(o===Ur)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===J_)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===e1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===t1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===n1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===J_)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===e1)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===t1)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===n1)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===O3||r===I3||r===z3||r===U3)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===O3)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===I3)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===z3)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===U3)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===B3||r===H3||r===$3)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===B3||r===H3)return o===Ur?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===$3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===V3||r===q3||r===G3||r===W3||r===K3||r===Y3||r===X3||r===Q3||r===Z3||r===J3||r===eD||r===tD||r===nD||r===rD)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===V3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===q3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===G3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===W3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===K3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===Y3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===X3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Q3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Z3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===J3)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===eD)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===tD)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===nD)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===rD)return o===Ur?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===aD||r===iD||r===sD)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===aD)return o===Ur?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===iD)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===sD)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===oD||r===lD||r===cD||r===uD)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===oD)return s.COMPRESSED_RED_RGTC1_EXT;if(r===lD)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===cD)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===uD)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===M0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const fSe=`
  3825. void main() {
  3826. gl_Position = vec4( position, 1.0 );
  3827. }`,pSe=`
  3828. uniform sampler2DArray depthColor;
  3829. uniform float depthWidth;
  3830. uniform float depthHeight;
  3831. void main() {
  3832. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3833. if ( coord.x >= 1.0 ) {
  3834. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3835. } else {
  3836. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3837. }
  3838. }`;class gSe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new PX(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 od({vertexShader:fSe,fragmentShader:pSe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new kl(new o4(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let bSe=class extends cp{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,f=null,p=null,x=null;const v=typeof XRWebGLBinding<"u",g=new gSe,y={},_=n.getContextAttributes();let N=null,A=null;const C=[],j=[],k=new qn;let R=null;const M=new cl;M.viewport=new ti;const D=new cl;D.viewport=new ti;const G=[M,D],U=new Rxe;let W=null,L=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let K=C[$];return K===void 0&&(K=new yM,C[$]=K),K.getTargetRaySpace()},this.getControllerGrip=function($){let K=C[$];return K===void 0&&(K=new yM,C[$]=K),K.getGripSpace()},this.getHand=function($){let K=C[$];return K===void 0&&(K=new yM,C[$]=K),K.getHandSpace()};function ee($){const K=j.indexOf($.inputSource);if(K===-1)return;const T=C[K];T!==void 0&&(T.update($.inputSource,$.frame,u||o),T.dispatchEvent({type:$.type,data:$.inputSource}))}function ae(){i.removeEventListener("select",ee),i.removeEventListener("selectstart",ee),i.removeEventListener("selectend",ee),i.removeEventListener("squeeze",ee),i.removeEventListener("squeezestart",ee),i.removeEventListener("squeezeend",ee),i.removeEventListener("end",ae),i.removeEventListener("inputsourceschange",Y);for(let $=0;$<C.length;$++){const K=j[$];K!==null&&(j[$]=null,C[$].disconnect(K))}W=null,L=null,g.reset();for(const $ in y)delete y[$];e.setRenderTarget(N),p=null,f=null,h=null,i=null,A=null,Ee.stop(),r.isPresenting=!1,e.setPixelRatio(R),e.setSize(k.width,k.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){s=$,r.isPresenting===!0&&Cn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){l=$,r.isPresenting===!0&&Cn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function($){u=$},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return h===null&&v&&(h=new XRWebGLBinding(i,n)),h},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function($){if(i=$,i!==null){if(N=e.getRenderTarget(),i.addEventListener("select",ee),i.addEventListener("selectstart",ee),i.addEventListener("selectend",ee),i.addEventListener("squeeze",ee),i.addEventListener("squeezestart",ee),i.addEventListener("squeezeend",ee),i.addEventListener("end",ae),i.addEventListener("inputsourceschange",Y),_.xrCompatible!==!0&&await n.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(k),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let T=null,E=null,O=null;_.depth&&(O=_.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,T=_.stencil?j0:P0,E=_.stencil?M0:Bf);const q={colorFormat:n.RGBA8,depthFormat:O,scaleFactor:s};h=this.getBinding(),f=h.createProjectionLayer(q),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),A=new $f(f.textureWidth,f.textureHeight,{format:Yl,type:zc,depthTexture:new MX(f.textureWidth,f.textureHeight,E,void 0,void 0,void 0,void 0,void 0,void 0,T),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{const T={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,n,T),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),A=new $f(p.framebufferWidth,p.framebufferHeight,{format:Yl,type:zc,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),Ee.setContext(i),Ee.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function Y($){for(let K=0;K<$.removed.length;K++){const T=$.removed[K],E=j.indexOf(T);E>=0&&(j[E]=null,C[E].disconnect(T))}for(let K=0;K<$.added.length;K++){const T=$.added[K];let E=j.indexOf(T);if(E===-1){for(let q=0;q<C.length;q++)if(q>=j.length){j.push(T),E=q;break}else if(j[q]===null){j[q]=T,E=q;break}if(E===-1)break}const O=C[E];O&&O.connect(T)}}const se=new xt,ce=new xt;function ye($,K,T){se.setFromMatrixPosition(K.matrixWorld),ce.setFromMatrixPosition(T.matrixWorld);const E=se.distanceTo(ce),O=K.projectionMatrix.elements,q=T.projectionMatrix.elements,B=O[14]/(O[10]-1),re=O[14]/(O[10]+1),z=(O[9]+1)/O[5],V=(O[9]-1)/O[5],te=(O[8]-1)/O[0],Q=(q[8]+1)/q[0],ne=B*te,ie=B*Q,me=E/(-te+Q),fe=me*-te;if(K.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(fe),$.translateZ(me),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),O[10]===-1)$.projectionMatrix.copy(K.projectionMatrix),$.projectionMatrixInverse.copy(K.projectionMatrixInverse);else{const oe=B+me,I=re+me,F=ne-fe,J=ie+(E-fe),xe=z*re/I*oe,he=V*re/I*oe;$.projectionMatrix.makePerspective(F,J,xe,he,oe,I),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function Z($,K){K===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(K.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(i===null)return;let K=$.near,T=$.far;g.texture!==null&&(g.depthNear>0&&(K=g.depthNear),g.depthFar>0&&(T=g.depthFar)),U.near=D.near=M.near=K,U.far=D.far=M.far=T,(W!==U.near||L!==U.far)&&(i.updateRenderState({depthNear:U.near,depthFar:U.far}),W=U.near,L=U.far),U.layers.mask=$.layers.mask|6,M.layers.mask=U.layers.mask&3,D.layers.mask=U.layers.mask&5;const E=$.parent,O=U.cameras;Z(U,E);for(let q=0;q<O.length;q++)Z(O[q],E);O.length===2?ye(U,M,D):U.projectionMatrix.copy(M.projectionMatrix),ue($,U,E)};function ue($,K,T){T===null?$.matrix.copy(K.matrixWorld):($.matrix.copy(T.matrixWorld),$.matrix.invert(),$.matrix.multiply(K.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(K.projectionMatrix),$.projectionMatrixInverse.copy(K.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=dD*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return U},this.getFoveation=function(){if(!(f===null&&p===null))return c},this.setFoveation=function($){c=$,f!==null&&(f.fixedFoveation=$),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=$)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(U)},this.getCameraTexture=function($){return y[$]};let pe=null;function be($,K){if(d=K.getViewerPose(u||o),x=K,d!==null){const T=d.views;p!==null&&(e.setRenderTargetFramebuffer(A,p.framebuffer),e.setRenderTarget(A));let E=!1;T.length!==U.cameras.length&&(U.cameras.length=0,E=!0);for(let re=0;re<T.length;re++){const z=T[re];let V=null;if(p!==null)V=p.getViewport(z);else{const Q=h.getViewSubImage(f,z);V=Q.viewport,re===0&&(e.setRenderTargetTextures(A,Q.colorTexture,Q.depthStencilTexture),e.setRenderTarget(A))}let te=G[re];te===void 0&&(te=new cl,te.layers.enable(re),te.viewport=new ti,G[re]=te),te.matrix.fromArray(z.transform.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale),te.projectionMatrix.fromArray(z.projectionMatrix),te.projectionMatrixInverse.copy(te.projectionMatrix).invert(),te.viewport.set(V.x,V.y,V.width,V.height),re===0&&(U.matrix.copy(te.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale)),E===!0&&U.cameras.push(te)}const O=i.enabledFeatures;if(O&&O.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){h=r.getBinding();const re=h.getDepthInformation(T[0]);re&&re.isValid&&re.texture&&g.init(re,i.renderState)}if(O&&O.includes("camera-access")&&v){e.state.unbindTexture(),h=r.getBinding();for(let re=0;re<T.length;re++){const z=T[re].camera;if(z){let V=y[z];V||(V=new PX,y[z]=V);const te=h.getCameraImage(z);V.sourceTexture=te}}}}for(let T=0;T<C.length;T++){const E=j[T],O=C[T];E!==null&&O!==void 0&&O.update(E,K,u||o)}pe&&pe($,K),K.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:K}),x=null}const Ee=new FX;Ee.setAnimationLoop(be),this.setAnimationLoop=function($){pe=$},this.dispose=function(){}}};const Lm=new Zh,xSe=new oi;function ySe(t,e){function n(g,y){g.matrixAutoUpdate===!0&&g.updateMatrix(),y.value.copy(g.matrix)}function r(g,y){y.color.getRGB(g.fogColor.value,kX(t)),y.isFog?(g.fogNear.value=y.near,g.fogFar.value=y.far):y.isFogExp2&&(g.fogDensity.value=y.density)}function i(g,y,_,N,A){y.isMeshBasicMaterial||y.isMeshLambertMaterial?s(g,y):y.isMeshToonMaterial?(s(g,y),h(g,y)):y.isMeshPhongMaterial?(s(g,y),d(g,y)):y.isMeshStandardMaterial?(s(g,y),f(g,y),y.isMeshPhysicalMaterial&&p(g,y,A)):y.isMeshMatcapMaterial?(s(g,y),x(g,y)):y.isMeshDepthMaterial?s(g,y):y.isMeshDistanceMaterial?(s(g,y),v(g,y)):y.isMeshNormalMaterial?s(g,y):y.isLineBasicMaterial?(o(g,y),y.isLineDashedMaterial&&l(g,y)):y.isPointsMaterial?c(g,y,_,N):y.isSpriteMaterial?u(g,y):y.isShadowMaterial?(g.color.value.copy(y.color),g.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function s(g,y){g.opacity.value=y.opacity,y.color&&g.diffuse.value.copy(y.color),y.emissive&&g.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(g.map.value=y.map,n(y.map,g.mapTransform)),y.alphaMap&&(g.alphaMap.value=y.alphaMap,n(y.alphaMap,g.alphaMapTransform)),y.bumpMap&&(g.bumpMap.value=y.bumpMap,n(y.bumpMap,g.bumpMapTransform),g.bumpScale.value=y.bumpScale,y.side===ao&&(g.bumpScale.value*=-1)),y.normalMap&&(g.normalMap.value=y.normalMap,n(y.normalMap,g.normalMapTransform),g.normalScale.value.copy(y.normalScale),y.side===ao&&g.normalScale.value.negate()),y.displacementMap&&(g.displacementMap.value=y.displacementMap,n(y.displacementMap,g.displacementMapTransform),g.displacementScale.value=y.displacementScale,g.displacementBias.value=y.displacementBias),y.emissiveMap&&(g.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,g.emissiveMapTransform)),y.specularMap&&(g.specularMap.value=y.specularMap,n(y.specularMap,g.specularMapTransform)),y.alphaTest>0&&(g.alphaTest.value=y.alphaTest);const _=e.get(y),N=_.envMap,A=_.envMapRotation;N&&(g.envMap.value=N,Lm.copy(A),Lm.x*=-1,Lm.y*=-1,Lm.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(Lm.y*=-1,Lm.z*=-1),g.envMapRotation.value.setFromMatrix4(xSe.makeRotationFromEuler(Lm)),g.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=y.reflectivity,g.ior.value=y.ior,g.refractionRatio.value=y.refractionRatio),y.lightMap&&(g.lightMap.value=y.lightMap,g.lightMapIntensity.value=y.lightMapIntensity,n(y.lightMap,g.lightMapTransform)),y.aoMap&&(g.aoMap.value=y.aoMap,g.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,g.aoMapTransform))}function o(g,y){g.diffuse.value.copy(y.color),g.opacity.value=y.opacity,y.map&&(g.map.value=y.map,n(y.map,g.mapTransform))}function l(g,y){g.dashSize.value=y.dashSize,g.totalSize.value=y.dashSize+y.gapSize,g.scale.value=y.scale}function c(g,y,_,N){g.diffuse.value.copy(y.color),g.opacity.value=y.opacity,g.size.value=y.size*_,g.scale.value=N*.5,y.map&&(g.map.value=y.map,n(y.map,g.uvTransform)),y.alphaMap&&(g.alphaMap.value=y.alphaMap,n(y.alphaMap,g.alphaMapTransform)),y.alphaTest>0&&(g.alphaTest.value=y.alphaTest)}function u(g,y){g.diffuse.value.copy(y.color),g.opacity.value=y.opacity,g.rotation.value=y.rotation,y.map&&(g.map.value=y.map,n(y.map,g.mapTransform)),y.alphaMap&&(g.alphaMap.value=y.alphaMap,n(y.alphaMap,g.alphaMapTransform)),y.alphaTest>0&&(g.alphaTest.value=y.alphaTest)}function d(g,y){g.specular.value.copy(y.specular),g.shininess.value=Math.max(y.shininess,1e-4)}function h(g,y){y.gradientMap&&(g.gradientMap.value=y.gradientMap)}function f(g,y){g.metalness.value=y.metalness,y.metalnessMap&&(g.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,g.metalnessMapTransform)),g.roughness.value=y.roughness,y.roughnessMap&&(g.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,g.roughnessMapTransform)),y.envMap&&(g.envMapIntensity.value=y.envMapIntensity)}function p(g,y,_){g.ior.value=y.ior,y.sheen>0&&(g.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),g.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(g.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,g.sheenColorMapTransform)),y.sheenRoughnessMap&&(g.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,g.sheenRoughnessMapTransform))),y.clearcoat>0&&(g.clearcoat.value=y.clearcoat,g.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(g.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,g.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(g.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===ao&&g.clearcoatNormalScale.value.negate())),y.dispersion>0&&(g.dispersion.value=y.dispersion),y.iridescence>0&&(g.iridescence.value=y.iridescence,g.iridescenceIOR.value=y.iridescenceIOR,g.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(g.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,g.iridescenceMapTransform)),y.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),y.transmission>0&&(g.transmission.value=y.transmission,g.transmissionSamplerMap.value=_.texture,g.transmissionSamplerSize.value.set(_.width,_.height),y.transmissionMap&&(g.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,g.transmissionMapTransform)),g.thickness.value=y.thickness,y.thicknessMap&&(g.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=y.attenuationDistance,g.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(g.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(g.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=y.specularIntensity,g.specularColor.value.copy(y.specularColor),y.specularColorMap&&(g.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,g.specularColorMapTransform)),y.specularIntensityMap&&(g.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,g.specularIntensityMapTransform))}function x(g,y){y.matcap&&(g.matcap.value=y.matcap)}function v(g,y){const _=e.get(y).light;g.referencePosition.value.setFromMatrixPosition(_.matrixWorld),g.nearDistance.value=_.shadow.camera.near,g.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function vSe(t,e,n,r){let i={},s={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(_,N){const A=N.program;r.uniformBlockBinding(_,A)}function u(_,N){let A=i[_.id];A===void 0&&(x(_),A=d(_),i[_.id]=A,_.addEventListener("dispose",g));const C=N.program;r.updateUBOMapping(_,C);const j=e.render.frame;s[_.id]!==j&&(f(_),s[_.id]=j)}function d(_){const N=h();_.__bindingPointIndex=N;const A=t.createBuffer(),C=_.__size,j=_.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,C,j),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,A),A}function h(){for(let _=0;_<l;_++)if(o.indexOf(_)===-1)return o.push(_),_;return Va("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(_){const N=i[_.id],A=_.uniforms,C=_.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let j=0,k=A.length;j<k;j++){const R=Array.isArray(A[j])?A[j]:[A[j]];for(let M=0,D=R.length;M<D;M++){const G=R[M];if(p(G,j,M,C)===!0){const U=G.__offset,W=Array.isArray(G.value)?G.value:[G.value];let L=0;for(let ee=0;ee<W.length;ee++){const ae=W[ee],Y=v(ae);typeof ae=="number"||typeof ae=="boolean"?(G.__data[0]=ae,t.bufferSubData(t.UNIFORM_BUFFER,U+L,G.__data)):ae.isMatrix3?(G.__data[0]=ae.elements[0],G.__data[1]=ae.elements[1],G.__data[2]=ae.elements[2],G.__data[3]=0,G.__data[4]=ae.elements[3],G.__data[5]=ae.elements[4],G.__data[6]=ae.elements[5],G.__data[7]=0,G.__data[8]=ae.elements[6],G.__data[9]=ae.elements[7],G.__data[10]=ae.elements[8],G.__data[11]=0):(ae.toArray(G.__data,L),L+=Y.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,U,G.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(_,N,A,C){const j=_.value,k=N+"_"+A;if(C[k]===void 0)return typeof j=="number"||typeof j=="boolean"?C[k]=j:C[k]=j.clone(),!0;{const R=C[k];if(typeof j=="number"||typeof j=="boolean"){if(R!==j)return C[k]=j,!0}else if(R.equals(j)===!1)return R.copy(j),!0}return!1}function x(_){const N=_.uniforms;let A=0;const C=16;for(let k=0,R=N.length;k<R;k++){const M=Array.isArray(N[k])?N[k]:[N[k]];for(let D=0,G=M.length;D<G;D++){const U=M[D],W=Array.isArray(U.value)?U.value:[U.value];for(let L=0,ee=W.length;L<ee;L++){const ae=W[L],Y=v(ae),se=A%C,ce=se%Y.boundary,ye=se+ce;A+=ce,ye!==0&&C-ye<Y.storage&&(A+=C-ye),U.__data=new Float32Array(Y.storage/Float32Array.BYTES_PER_ELEMENT),U.__offset=A,A+=Y.storage}}}const j=A%C;return j>0&&(A+=C-j),_.__size=A,_.__cache={},this}function v(_){const N={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(N.boundary=4,N.storage=4):_.isVector2?(N.boundary=8,N.storage=8):_.isVector3||_.isColor?(N.boundary=16,N.storage=12):_.isVector4?(N.boundary=16,N.storage=16):_.isMatrix3?(N.boundary=48,N.storage=48):_.isMatrix4?(N.boundary=64,N.storage=64):_.isTexture?Cn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Cn("WebGLRenderer: Unsupported uniform value type.",_),N}function g(_){const N=_.target;N.removeEventListener("dispose",g);const A=o.indexOf(N.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete s[N.id]}function y(){for(const _ in i)t.deleteBuffer(i[_]);o=[],i={},s={}}return{bind:c,update:u,dispose:y}}const wSe=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 wu=null;function SSe(){return wu===null&&(wu=new yxe(wSe,32,32,JF,tx),wu.minFilter=pl,wu.magFilter=pl,wu.wrapS=Uu,wu.wrapT=Uu,wu.generateMipmaps=!1,wu.needsUpdate=!0),wu}let _Se=class{constructor(e={}){const{canvas:n=Vbe(),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:f=!1}=e;this.isWebGLRenderer=!0;let p;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=r.getContextAttributes().alpha}else p=o;const x=new Set([t4,e4,ZF]),v=new Set([zc,Bf,T0,M0,XF,QF]),g=new Uint32Array(4),y=new Int32Array(4);let _=null,N=null;const A=[],C=[];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=zh,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const j=this;let k=!1;this._outputColorSpace=Ao;let R=0,M=0,D=null,G=-1,U=null;const W=new ti,L=new ti;let ee=null;const ae=new Yn(0);let Y=0,se=n.width,ce=n.height,ye=1,Z=null,ue=null;const pe=new ti(0,0,se,ce),be=new ti(0,0,se,ce);let Ee=!1;const $=new s4;let K=!1,T=!1;const E=new oi,O=new xt,q=new ti,B={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let re=!1;function z(){return D===null?ye:1}let V=r;function te(Me,Ge){return n.getContext(Me,Ge)}try{const Me={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${WF}`),n.addEventListener("webglcontextlost",Re,!1),n.addEventListener("webglcontextrestored",Pe,!1),n.addEventListener("webglcontextcreationerror",Be,!1),V===null){const Ge="webgl2";if(V=te(Ge,Me),V===null)throw te(Ge)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(Me){throw Me("WebGLRenderer: "+Me.message),Me}let Q,ne,ie,me,fe,oe,I,F,J,xe,he,le,Ce,Ne,Ue,He,de,we,ke,_e,Ae,Ve,Te,Ke;function je(){Q=new jve(V),Q.init(),Ve=new mSe(V,Q),ne=new Sve(V,Q,e,Ve),ie=new dSe(V,Q),ne.reversedDepthBuffer&&f&&ie.buffers.depth.setReversed(!0),me=new Rve(V),fe=new Zwe,oe=new hSe(V,Q,ie,fe,ne,Ve,me),I=new Nve(j),F=new Pve(j),J=new Ixe(V),Te=new vve(V,J),xe=new Eve(V,J,me,Te),he=new Lve(V,xe,J,me),ke=new Fve(V,ne,oe),He=new _ve(fe),le=new Qwe(j,I,F,Q,ne,Te,He),Ce=new ySe(j,fe),Ne=new eSe,Ue=new sSe(Q),we=new yve(j,I,F,ie,he,p,c),de=new cSe(j,he,ne),Ke=new vSe(V,me,ne,ie),_e=new wve(V,Q,me),Ae=new Dve(V,Q,me),me.programs=le.programs,j.capabilities=ne,j.extensions=Q,j.properties=fe,j.renderLists=Ne,j.shadowMap=de,j.state=ie,j.info=me}je();const qe=new bSe(j,V);this.xr=qe,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const Me=Q.get("WEBGL_lose_context");Me&&Me.loseContext()},this.forceContextRestore=function(){const Me=Q.get("WEBGL_lose_context");Me&&Me.restoreContext()},this.getPixelRatio=function(){return ye},this.setPixelRatio=function(Me){Me!==void 0&&(ye=Me,this.setSize(se,ce,!1))},this.getSize=function(Me){return Me.set(se,ce)},this.setSize=function(Me,Ge,et=!0){if(qe.isPresenting){Cn("WebGLRenderer: Can't change size while VR device is presenting.");return}se=Me,ce=Ge,n.width=Math.floor(Me*ye),n.height=Math.floor(Ge*ye),et===!0&&(n.style.width=Me+"px",n.style.height=Ge+"px"),this.setViewport(0,0,Me,Ge)},this.getDrawingBufferSize=function(Me){return Me.set(se*ye,ce*ye).floor()},this.setDrawingBufferSize=function(Me,Ge,et){se=Me,ce=Ge,ye=et,n.width=Math.floor(Me*et),n.height=Math.floor(Ge*et),this.setViewport(0,0,Me,Ge)},this.getCurrentViewport=function(Me){return Me.copy(W)},this.getViewport=function(Me){return Me.copy(pe)},this.setViewport=function(Me,Ge,et,Qe){Me.isVector4?pe.set(Me.x,Me.y,Me.z,Me.w):pe.set(Me,Ge,et,Qe),ie.viewport(W.copy(pe).multiplyScalar(ye).round())},this.getScissor=function(Me){return Me.copy(be)},this.setScissor=function(Me,Ge,et,Qe){Me.isVector4?be.set(Me.x,Me.y,Me.z,Me.w):be.set(Me,Ge,et,Qe),ie.scissor(L.copy(be).multiplyScalar(ye).round())},this.getScissorTest=function(){return Ee},this.setScissorTest=function(Me){ie.setScissorTest(Ee=Me)},this.setOpaqueSort=function(Me){Z=Me},this.setTransparentSort=function(Me){ue=Me},this.getClearColor=function(Me){return Me.copy(we.getClearColor())},this.setClearColor=function(){we.setClearColor(...arguments)},this.getClearAlpha=function(){return we.getClearAlpha()},this.setClearAlpha=function(){we.setClearAlpha(...arguments)},this.clear=function(Me=!0,Ge=!0,et=!0){let Qe=0;if(Me){let Le=!1;if(D!==null){const ht=D.texture.format;Le=x.has(ht)}if(Le){const ht=D.texture.type,it=v.has(ht),tt=we.getClearColor(),_t=we.getClearAlpha(),jt=tt.r,Dt=tt.g,Rt=tt.b;it?(g[0]=jt,g[1]=Dt,g[2]=Rt,g[3]=_t,V.clearBufferuiv(V.COLOR,0,g)):(y[0]=jt,y[1]=Dt,y[2]=Rt,y[3]=_t,V.clearBufferiv(V.COLOR,0,y))}else Qe|=V.COLOR_BUFFER_BIT}Ge&&(Qe|=V.DEPTH_BUFFER_BIT),et&&(Qe|=V.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V.clear(Qe)},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",Re,!1),n.removeEventListener("webglcontextrestored",Pe,!1),n.removeEventListener("webglcontextcreationerror",Be,!1),we.dispose(),Ne.dispose(),Ue.dispose(),fe.dispose(),I.dispose(),F.dispose(),he.dispose(),Te.dispose(),Ke.dispose(),le.dispose(),qe.dispose(),qe.removeEventListener("sessionstart",dt),qe.removeEventListener("sessionend",gt),Lt.stop()};function Re(Me){Me.preventDefault(),d8("WebGLRenderer: Context Lost."),k=!0}function Pe(){d8("WebGLRenderer: Context Restored."),k=!1;const Me=me.autoReset,Ge=de.enabled,et=de.autoUpdate,Qe=de.needsUpdate,Le=de.type;je(),me.autoReset=Me,de.enabled=Ge,de.autoUpdate=et,de.needsUpdate=Qe,de.type=Le}function Be(Me){Va("WebGLRenderer: A WebGL context could not be created. Reason: ",Me.statusMessage)}function We(Me){const Ge=Me.target;Ge.removeEventListener("dispose",We),ct(Ge)}function ct(Me){St(Me),fe.remove(Me)}function St(Me){const Ge=fe.get(Me).programs;Ge!==void 0&&(Ge.forEach(function(et){le.releaseProgram(et)}),Me.isShaderMaterial&&le.releaseShaderCache(Me))}this.renderBufferDirect=function(Me,Ge,et,Qe,Le,ht){Ge===null&&(Ge=B);const it=Le.isMesh&&Le.matrixWorld.determinant()<0,tt=ze(Me,Ge,et,Qe,Le);ie.setMaterial(Qe,it);let _t=et.index,jt=1;if(Qe.wireframe===!0){if(_t=xe.getWireframeAttribute(et),_t===void 0)return;jt=2}const Dt=et.drawRange,Rt=et.attributes.position;let tn=Dt.start*jt,nn=(Dt.start+Dt.count)*jt;ht!==null&&(tn=Math.max(tn,ht.start*jt),nn=Math.min(nn,(ht.start+ht.count)*jt)),_t!==null?(tn=Math.max(tn,0),nn=Math.min(nn,_t.count)):Rt!=null&&(tn=Math.max(tn,0),nn=Math.min(nn,Rt.count));const ln=nn-tn;if(ln<0||ln===1/0)return;Te.setup(Le,Qe,tt,et,_t);let vn,Rn=_e;if(_t!==null&&(vn=J.get(_t),Rn=Ae,Rn.setIndex(vn)),Le.isMesh)Qe.wireframe===!0?(ie.setLineWidth(Qe.wireframeLinewidth*z()),Rn.setMode(V.LINES)):Rn.setMode(V.TRIANGLES);else if(Le.isLine){let Zt=Qe.linewidth;Zt===void 0&&(Zt=1),ie.setLineWidth(Zt*z()),Le.isLineSegments?Rn.setMode(V.LINES):Le.isLineLoop?Rn.setMode(V.LINE_LOOP):Rn.setMode(V.LINE_STRIP)}else Le.isPoints?Rn.setMode(V.POINTS):Le.isSprite&&Rn.setMode(V.TRIANGLES);if(Le.isBatchedMesh)if(Le._multiDrawInstances!==null)E0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Rn.renderMultiDrawInstances(Le._multiDrawStarts,Le._multiDrawCounts,Le._multiDrawCount,Le._multiDrawInstances);else if(Q.get("WEBGL_multi_draw"))Rn.renderMultiDraw(Le._multiDrawStarts,Le._multiDrawCounts,Le._multiDrawCount);else{const Zt=Le._multiDrawStarts,xn=Le._multiDrawCounts,mn=Le._multiDrawCount,Gr=_t?J.get(_t).bytesPerElement:1,yn=fe.get(Qe).currentProgram.getUniforms();for(let dr=0;dr<mn;dr++)yn.setValue(V,"_gl_DrawID",dr),Rn.render(Zt[dr]/Gr,xn[dr])}else if(Le.isInstancedMesh)Rn.renderInstances(tn,ln,Le.count);else if(et.isInstancedBufferGeometry){const Zt=et._maxInstanceCount!==void 0?et._maxInstanceCount:1/0,xn=Math.min(et.instanceCount,Zt);Rn.renderInstances(tn,ln,xn)}else Rn.render(tn,ln)};function Mt(Me,Ge,et){Me.transparent===!0&&Me.side===kc&&Me.forceSinglePass===!1?(Me.side=ao,Me.needsUpdate=!0,On(Me,Ge,et),Me.side=Qh,Me.needsUpdate=!0,On(Me,Ge,et),Me.side=kc):On(Me,Ge,et)}this.compile=function(Me,Ge,et=null){et===null&&(et=Me),N=Ue.get(et),N.init(Ge),C.push(N),et.traverseVisible(function(Le){Le.isLight&&Le.layers.test(Ge.layers)&&(N.pushLight(Le),Le.castShadow&&N.pushShadow(Le))}),Me!==et&&Me.traverseVisible(function(Le){Le.isLight&&Le.layers.test(Ge.layers)&&(N.pushLight(Le),Le.castShadow&&N.pushShadow(Le))}),N.setupLights();const Qe=new Set;return Me.traverse(function(Le){if(!(Le.isMesh||Le.isPoints||Le.isLine||Le.isSprite))return;const ht=Le.material;if(ht)if(Array.isArray(ht))for(let it=0;it<ht.length;it++){const tt=ht[it];Mt(tt,et,Le),Qe.add(tt)}else Mt(ht,et,Le),Qe.add(ht)}),N=C.pop(),Qe},this.compileAsync=function(Me,Ge,et=null){const Qe=this.compile(Me,Ge,et);return new Promise(Le=>{function ht(){if(Qe.forEach(function(it){fe.get(it).currentProgram.isReady()&&Qe.delete(it)}),Qe.size===0){Le(Me);return}setTimeout(ht,10)}Q.get("KHR_parallel_shader_compile")!==null?ht():setTimeout(ht,10)})};let yt=null;function $e(Me){yt&&yt(Me)}function dt(){Lt.stop()}function gt(){Lt.start()}const Lt=new FX;Lt.setAnimationLoop($e),typeof self<"u"&&Lt.setContext(self),this.setAnimationLoop=function(Me){yt=Me,qe.setAnimationLoop(Me),Me===null?Lt.stop():Lt.start()},qe.addEventListener("sessionstart",dt),qe.addEventListener("sessionend",gt),this.render=function(Me,Ge){if(Ge!==void 0&&Ge.isCamera!==!0){Va("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(k===!0)return;if(Me.matrixWorldAutoUpdate===!0&&Me.updateMatrixWorld(),Ge.parent===null&&Ge.matrixWorldAutoUpdate===!0&&Ge.updateMatrixWorld(),qe.enabled===!0&&qe.isPresenting===!0&&(qe.cameraAutoUpdate===!0&&qe.updateCamera(Ge),Ge=qe.getCamera()),Me.isScene===!0&&Me.onBeforeRender(j,Me,Ge,D),N=Ue.get(Me,C.length),N.init(Ge),C.push(N),E.multiplyMatrices(Ge.projectionMatrix,Ge.matrixWorldInverse),$.setFromProjectionMatrix(E,Tc,Ge.reversedDepth),T=this.localClippingEnabled,K=He.init(this.clippingPlanes,T),_=Ne.get(Me,A.length),_.init(),A.push(_),qe.enabled===!0&&qe.isPresenting===!0){const ht=j.xr.getDepthSensingMesh();ht!==null&&en(ht,Ge,-1/0,j.sortObjects)}en(Me,Ge,0,j.sortObjects),_.finish(),j.sortObjects===!0&&_.sort(Z,ue),re=qe.enabled===!1||qe.isPresenting===!1||qe.hasDepthSensing()===!1,re&&we.addToRenderList(_,Me),this.info.render.frame++,K===!0&&He.beginShadows();const et=N.state.shadowsArray;de.render(et,Me,Ge),K===!0&&He.endShadows(),this.info.autoReset===!0&&this.info.reset();const Qe=_.opaque,Le=_.transmissive;if(N.setupLights(),Ge.isArrayCamera){const ht=Ge.cameras;if(Le.length>0)for(let it=0,tt=ht.length;it<tt;it++){const _t=ht[it];_n(Qe,Le,Me,_t)}re&&we.render(Me);for(let it=0,tt=ht.length;it<tt;it++){const _t=ht[it];pn(_,Me,_t,_t.viewport)}}else Le.length>0&&_n(Qe,Le,Me,Ge),re&&we.render(Me),pn(_,Me,Ge);D!==null&&M===0&&(oe.updateMultisampleRenderTarget(D),oe.updateRenderTargetMipmap(D)),Me.isScene===!0&&Me.onAfterRender(j,Me,Ge),Te.resetDefaultState(),G=-1,U=null,C.pop(),C.length>0?(N=C[C.length-1],K===!0&&He.setGlobalState(j.clippingPlanes,N.state.camera)):N=null,A.pop(),A.length>0?_=A[A.length-1]:_=null};function en(Me,Ge,et,Qe){if(Me.visible===!1)return;if(Me.layers.test(Ge.layers)){if(Me.isGroup)et=Me.renderOrder;else if(Me.isLOD)Me.autoUpdate===!0&&Me.update(Ge);else if(Me.isLight)N.pushLight(Me),Me.castShadow&&N.pushShadow(Me);else if(Me.isSprite){if(!Me.frustumCulled||$.intersectsSprite(Me)){Qe&&q.setFromMatrixPosition(Me.matrixWorld).applyMatrix4(E);const it=he.update(Me),tt=Me.material;tt.visible&&_.push(Me,it,tt,et,q.z,null)}}else if((Me.isMesh||Me.isLine||Me.isPoints)&&(!Me.frustumCulled||$.intersectsObject(Me))){const it=he.update(Me),tt=Me.material;if(Qe&&(Me.boundingSphere!==void 0?(Me.boundingSphere===null&&Me.computeBoundingSphere(),q.copy(Me.boundingSphere.center)):(it.boundingSphere===null&&it.computeBoundingSphere(),q.copy(it.boundingSphere.center)),q.applyMatrix4(Me.matrixWorld).applyMatrix4(E)),Array.isArray(tt)){const _t=it.groups;for(let jt=0,Dt=_t.length;jt<Dt;jt++){const Rt=_t[jt],tn=tt[Rt.materialIndex];tn&&tn.visible&&_.push(Me,it,tn,et,q.z,Rt)}}else tt.visible&&_.push(Me,it,tt,et,q.z,null)}}const ht=Me.children;for(let it=0,tt=ht.length;it<tt;it++)en(ht[it],Ge,et,Qe)}function pn(Me,Ge,et,Qe){const{opaque:Le,transmissive:ht,transparent:it}=Me;N.setupLightsView(et),K===!0&&He.setGlobalState(j.clippingPlanes,et),Qe&&ie.viewport(W.copy(Qe)),Le.length>0&&hn(Le,Ge,et),ht.length>0&&hn(ht,Ge,et),it.length>0&&hn(it,Ge,et),ie.buffers.depth.setTest(!0),ie.buffers.depth.setMask(!0),ie.buffers.color.setMask(!0),ie.setPolygonOffset(!1)}function _n(Me,Ge,et,Qe){if((et.isScene===!0?et.overrideMaterial:null)!==null)return;N.state.transmissionRenderTarget[Qe.id]===void 0&&(N.state.transmissionRenderTarget[Qe.id]=new $f(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")||Q.has("EXT_color_buffer_float")?tx:zc,minFilter:sf,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:br.workingColorSpace}));const ht=N.state.transmissionRenderTarget[Qe.id],it=Qe.viewport||W;ht.setSize(it.z*j.transmissionResolutionScale,it.w*j.transmissionResolutionScale);const tt=j.getRenderTarget(),_t=j.getActiveCubeFace(),jt=j.getActiveMipmapLevel();j.setRenderTarget(ht),j.getClearColor(ae),Y=j.getClearAlpha(),Y<1&&j.setClearColor(16777215,.5),j.clear(),re&&we.render(et);const Dt=j.toneMapping;j.toneMapping=zh;const Rt=Qe.viewport;if(Qe.viewport!==void 0&&(Qe.viewport=void 0),N.setupLightsView(Qe),K===!0&&He.setGlobalState(j.clippingPlanes,Qe),hn(Me,et,Qe),oe.updateMultisampleRenderTarget(ht),oe.updateRenderTargetMipmap(ht),Q.has("WEBGL_multisampled_render_to_texture")===!1){let tn=!1;for(let nn=0,ln=Ge.length;nn<ln;nn++){const vn=Ge[nn],{object:Rn,geometry:Zt,material:xn,group:mn}=vn;if(xn.side===kc&&Rn.layers.test(Qe.layers)){const Gr=xn.side;xn.side=ao,xn.needsUpdate=!0,gn(Rn,et,Qe,Zt,xn,mn),xn.side=Gr,xn.needsUpdate=!0,tn=!0}}tn===!0&&(oe.updateMultisampleRenderTarget(ht),oe.updateRenderTargetMipmap(ht))}j.setRenderTarget(tt,_t,jt),j.setClearColor(ae,Y),Rt!==void 0&&(Qe.viewport=Rt),j.toneMapping=Dt}function hn(Me,Ge,et){const Qe=Ge.isScene===!0?Ge.overrideMaterial:null;for(let Le=0,ht=Me.length;Le<ht;Le++){const it=Me[Le],{object:tt,geometry:_t,group:jt}=it;let Dt=it.material;Dt.allowOverride===!0&&Qe!==null&&(Dt=Qe),tt.layers.test(et.layers)&&gn(tt,Ge,et,_t,Dt,jt)}}function gn(Me,Ge,et,Qe,Le,ht){Me.onBeforeRender(j,Ge,et,Qe,Le,ht),Me.modelViewMatrix.multiplyMatrices(et.matrixWorldInverse,Me.matrixWorld),Me.normalMatrix.getNormalMatrix(Me.modelViewMatrix),Le.onBeforeRender(j,Ge,et,Qe,Me,ht),Le.transparent===!0&&Le.side===kc&&Le.forceSinglePass===!1?(Le.side=ao,Le.needsUpdate=!0,j.renderBufferDirect(et,Ge,Qe,Le,Me,ht),Le.side=Qh,Le.needsUpdate=!0,j.renderBufferDirect(et,Ge,Qe,Le,Me,ht),Le.side=kc):j.renderBufferDirect(et,Ge,Qe,Le,Me,ht),Me.onAfterRender(j,Ge,et,Qe,Le,ht)}function On(Me,Ge,et){Ge.isScene!==!0&&(Ge=B);const Qe=fe.get(Me),Le=N.state.lights,ht=N.state.shadowsArray,it=Le.state.version,tt=le.getParameters(Me,Le.state,ht,Ge,et),_t=le.getProgramCacheKey(tt);let jt=Qe.programs;Qe.environment=Me.isMeshStandardMaterial?Ge.environment:null,Qe.fog=Ge.fog,Qe.envMap=(Me.isMeshStandardMaterial?F:I).get(Me.envMap||Qe.environment),Qe.envMapRotation=Qe.environment!==null&&Me.envMap===null?Ge.environmentRotation:Me.envMapRotation,jt===void 0&&(Me.addEventListener("dispose",We),jt=new Map,Qe.programs=jt);let Dt=jt.get(_t);if(Dt!==void 0){if(Qe.currentProgram===Dt&&Qe.lightsStateVersion===it)return zn(Me,tt),Dt}else tt.uniforms=le.getUniforms(Me),Me.onBeforeCompile(tt,j),Dt=le.acquireProgram(tt,_t),jt.set(_t,Dt),Qe.uniforms=tt.uniforms;const Rt=Qe.uniforms;return(!Me.isShaderMaterial&&!Me.isRawShaderMaterial||Me.clipping===!0)&&(Rt.clippingPlanes=He.uniform),zn(Me,tt),Qe.needsLights=Ze(Me),Qe.lightsStateVersion=it,Qe.needsLights&&(Rt.ambientLightColor.value=Le.state.ambient,Rt.lightProbe.value=Le.state.probe,Rt.directionalLights.value=Le.state.directional,Rt.directionalLightShadows.value=Le.state.directionalShadow,Rt.spotLights.value=Le.state.spot,Rt.spotLightShadows.value=Le.state.spotShadow,Rt.rectAreaLights.value=Le.state.rectArea,Rt.ltc_1.value=Le.state.rectAreaLTC1,Rt.ltc_2.value=Le.state.rectAreaLTC2,Rt.pointLights.value=Le.state.point,Rt.pointLightShadows.value=Le.state.pointShadow,Rt.hemisphereLights.value=Le.state.hemi,Rt.directionalShadowMap.value=Le.state.directionalShadowMap,Rt.directionalShadowMatrix.value=Le.state.directionalShadowMatrix,Rt.spotShadowMap.value=Le.state.spotShadowMap,Rt.spotLightMatrix.value=Le.state.spotLightMatrix,Rt.spotLightMap.value=Le.state.spotLightMap,Rt.pointShadowMap.value=Le.state.pointShadowMap,Rt.pointShadowMatrix.value=Le.state.pointShadowMatrix),Qe.currentProgram=Dt,Qe.uniformsList=null,Dt}function Dn(Me){if(Me.uniformsList===null){const Ge=Me.currentProgram.getUniforms();Me.uniformsList=s1.seqWithValue(Ge.seq,Me.uniforms)}return Me.uniformsList}function zn(Me,Ge){const et=fe.get(Me);et.outputColorSpace=Ge.outputColorSpace,et.batching=Ge.batching,et.batchingColor=Ge.batchingColor,et.instancing=Ge.instancing,et.instancingColor=Ge.instancingColor,et.instancingMorph=Ge.instancingMorph,et.skinning=Ge.skinning,et.morphTargets=Ge.morphTargets,et.morphNormals=Ge.morphNormals,et.morphColors=Ge.morphColors,et.morphTargetsCount=Ge.morphTargetsCount,et.numClippingPlanes=Ge.numClippingPlanes,et.numIntersection=Ge.numClipIntersection,et.vertexAlphas=Ge.vertexAlphas,et.vertexTangents=Ge.vertexTangents,et.toneMapping=Ge.toneMapping}function ze(Me,Ge,et,Qe,Le){Ge.isScene!==!0&&(Ge=B),oe.resetTextureUnits();const ht=Ge.fog,it=Qe.isMeshStandardMaterial?Ge.environment:null,tt=D===null?j.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:kb,_t=(Qe.isMeshStandardMaterial?F:I).get(Qe.envMap||it),jt=Qe.vertexColors===!0&&!!et.attributes.color&&et.attributes.color.itemSize===4,Dt=!!et.attributes.tangent&&(!!Qe.normalMap||Qe.anisotropy>0),Rt=!!et.morphAttributes.position,tn=!!et.morphAttributes.normal,nn=!!et.morphAttributes.color;let ln=zh;Qe.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(ln=j.toneMapping);const vn=et.morphAttributes.position||et.morphAttributes.normal||et.morphAttributes.color,Rn=vn!==void 0?vn.length:0,Zt=fe.get(Qe),xn=N.state.lights;if(K===!0&&(T===!0||Me!==U)){const ya=Me===U&&Qe.id===G;He.setState(Qe,Me,ya)}let mn=!1;Qe.version===Zt.__version?(Zt.needsLights&&Zt.lightsStateVersion!==xn.state.version||Zt.outputColorSpace!==tt||Le.isBatchedMesh&&Zt.batching===!1||!Le.isBatchedMesh&&Zt.batching===!0||Le.isBatchedMesh&&Zt.batchingColor===!0&&Le.colorTexture===null||Le.isBatchedMesh&&Zt.batchingColor===!1&&Le.colorTexture!==null||Le.isInstancedMesh&&Zt.instancing===!1||!Le.isInstancedMesh&&Zt.instancing===!0||Le.isSkinnedMesh&&Zt.skinning===!1||!Le.isSkinnedMesh&&Zt.skinning===!0||Le.isInstancedMesh&&Zt.instancingColor===!0&&Le.instanceColor===null||Le.isInstancedMesh&&Zt.instancingColor===!1&&Le.instanceColor!==null||Le.isInstancedMesh&&Zt.instancingMorph===!0&&Le.morphTexture===null||Le.isInstancedMesh&&Zt.instancingMorph===!1&&Le.morphTexture!==null||Zt.envMap!==_t||Qe.fog===!0&&Zt.fog!==ht||Zt.numClippingPlanes!==void 0&&(Zt.numClippingPlanes!==He.numPlanes||Zt.numIntersection!==He.numIntersection)||Zt.vertexAlphas!==jt||Zt.vertexTangents!==Dt||Zt.morphTargets!==Rt||Zt.morphNormals!==tn||Zt.morphColors!==nn||Zt.toneMapping!==ln||Zt.morphTargetsCount!==Rn)&&(mn=!0):(mn=!0,Zt.__version=Qe.version);let Gr=Zt.currentProgram;mn===!0&&(Gr=On(Qe,Ge,Le));let yn=!1,dr=!1,as=!1;const wn=Gr.getUniforms(),Sr=Zt.uniforms;if(ie.useProgram(Gr.program)&&(yn=!0,dr=!0,as=!0),Qe.id!==G&&(G=Qe.id,dr=!0),yn||U!==Me){ie.buffers.depth.getReversed()&&Me.reversedDepth!==!0&&(Me._reversedDepth=!0,Me.updateProjectionMatrix()),wn.setValue(V,"projectionMatrix",Me.projectionMatrix),wn.setValue(V,"viewMatrix",Me.matrixWorldInverse);const Ba=wn.map.cameraPosition;Ba!==void 0&&Ba.setValue(V,O.setFromMatrixPosition(Me.matrixWorld)),ne.logarithmicDepthBuffer&&wn.setValue(V,"logDepthBufFC",2/(Math.log(Me.far+1)/Math.LN2)),(Qe.isMeshPhongMaterial||Qe.isMeshToonMaterial||Qe.isMeshLambertMaterial||Qe.isMeshBasicMaterial||Qe.isMeshStandardMaterial||Qe.isShaderMaterial)&&wn.setValue(V,"isOrthographic",Me.isOrthographicCamera===!0),U!==Me&&(U=Me,dr=!0,as=!0)}if(Le.isSkinnedMesh){wn.setOptional(V,Le,"bindMatrix"),wn.setOptional(V,Le,"bindMatrixInverse");const ya=Le.skeleton;ya&&(ya.boneTexture===null&&ya.computeBoneTexture(),wn.setValue(V,"boneTexture",ya.boneTexture,oe))}Le.isBatchedMesh&&(wn.setOptional(V,Le,"batchingTexture"),wn.setValue(V,"batchingTexture",Le._matricesTexture,oe),wn.setOptional(V,Le,"batchingIdTexture"),wn.setValue(V,"batchingIdTexture",Le._indirectTexture,oe),wn.setOptional(V,Le,"batchingColorTexture"),Le._colorsTexture!==null&&wn.setValue(V,"batchingColorTexture",Le._colorsTexture,oe));const ar=et.morphAttributes;if((ar.position!==void 0||ar.normal!==void 0||ar.color!==void 0)&&ke.update(Le,et,Gr),(dr||Zt.receiveShadow!==Le.receiveShadow)&&(Zt.receiveShadow=Le.receiveShadow,wn.setValue(V,"receiveShadow",Le.receiveShadow)),Qe.isMeshGouraudMaterial&&Qe.envMap!==null&&(Sr.envMap.value=_t,Sr.flipEnvMap.value=_t.isCubeTexture&&_t.isRenderTargetTexture===!1?-1:1),Qe.isMeshStandardMaterial&&Qe.envMap===null&&Ge.environment!==null&&(Sr.envMapIntensity.value=Ge.environmentIntensity),Sr.dfgLUT!==void 0&&(Sr.dfgLUT.value=SSe()),dr&&(wn.setValue(V,"toneMappingExposure",j.toneMappingExposure),Zt.needsLights&&De(Sr,as),ht&&Qe.fog===!0&&Ce.refreshFogUniforms(Sr,ht),Ce.refreshMaterialUniforms(Sr,Qe,ye,ce,N.state.transmissionRenderTarget[Me.id]),s1.upload(V,Dn(Zt),Sr,oe)),Qe.isShaderMaterial&&Qe.uniformsNeedUpdate===!0&&(s1.upload(V,Dn(Zt),Sr,oe),Qe.uniformsNeedUpdate=!1),Qe.isSpriteMaterial&&wn.setValue(V,"center",Le.center),wn.setValue(V,"modelViewMatrix",Le.modelViewMatrix),wn.setValue(V,"normalMatrix",Le.normalMatrix),wn.setValue(V,"modelMatrix",Le.matrixWorld),Qe.isShaderMaterial||Qe.isRawShaderMaterial){const ya=Qe.uniformsGroups;for(let Ba=0,sa=ya.length;Ba<sa;Ba++){const vt=ya[Ba];Ke.update(vt,Gr),Ke.bind(vt,Gr)}}return Gr}function De(Me,Ge){Me.ambientLightColor.needsUpdate=Ge,Me.lightProbe.needsUpdate=Ge,Me.directionalLights.needsUpdate=Ge,Me.directionalLightShadows.needsUpdate=Ge,Me.pointLights.needsUpdate=Ge,Me.pointLightShadows.needsUpdate=Ge,Me.spotLights.needsUpdate=Ge,Me.spotLightShadows.needsUpdate=Ge,Me.rectAreaLights.needsUpdate=Ge,Me.hemisphereLights.needsUpdate=Ge}function Ze(Me){return Me.isMeshLambertMaterial||Me.isMeshToonMaterial||Me.isMeshPhongMaterial||Me.isMeshStandardMaterial||Me.isShadowMaterial||Me.isShaderMaterial&&Me.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(Me,Ge,et){const Qe=fe.get(Me);Qe.__autoAllocateDepthBuffer=Me.resolveDepthBuffer===!1,Qe.__autoAllocateDepthBuffer===!1&&(Qe.__useRenderToTexture=!1),fe.get(Me.texture).__webglTexture=Ge,fe.get(Me.depthTexture).__webglTexture=Qe.__autoAllocateDepthBuffer?void 0:et,Qe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(Me,Ge){const et=fe.get(Me);et.__webglFramebuffer=Ge,et.__useDefaultFramebuffer=Ge===void 0};const st=V.createFramebuffer();this.setRenderTarget=function(Me,Ge=0,et=0){D=Me,R=Ge,M=et;let Qe=!0,Le=null,ht=!1,it=!1;if(Me){const _t=fe.get(Me);if(_t.__useDefaultFramebuffer!==void 0)ie.bindFramebuffer(V.FRAMEBUFFER,null),Qe=!1;else if(_t.__webglFramebuffer===void 0)oe.setupRenderTarget(Me);else if(_t.__hasExternalTextures)oe.rebindTextures(Me,fe.get(Me.texture).__webglTexture,fe.get(Me.depthTexture).__webglTexture);else if(Me.depthBuffer){const Rt=Me.depthTexture;if(_t.__boundDepthTexture!==Rt){if(Rt!==null&&fe.has(Rt)&&(Me.width!==Rt.image.width||Me.height!==Rt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");oe.setupDepthRenderbuffer(Me)}}const jt=Me.texture;(jt.isData3DTexture||jt.isDataArrayTexture||jt.isCompressedArrayTexture)&&(it=!0);const Dt=fe.get(Me).__webglFramebuffer;Me.isWebGLCubeRenderTarget?(Array.isArray(Dt[Ge])?Le=Dt[Ge][et]:Le=Dt[Ge],ht=!0):Me.samples>0&&oe.useMultisampledRTT(Me)===!1?Le=fe.get(Me).__webglMultisampledFramebuffer:Array.isArray(Dt)?Le=Dt[et]:Le=Dt,W.copy(Me.viewport),L.copy(Me.scissor),ee=Me.scissorTest}else W.copy(pe).multiplyScalar(ye).floor(),L.copy(be).multiplyScalar(ye).floor(),ee=Ee;if(et!==0&&(Le=st),ie.bindFramebuffer(V.FRAMEBUFFER,Le)&&Qe&&ie.drawBuffers(Me,Le),ie.viewport(W),ie.scissor(L),ie.setScissorTest(ee),ht){const _t=fe.get(Me.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,_t.__webglTexture,et)}else if(it){const _t=Ge;for(let jt=0;jt<Me.textures.length;jt++){const Dt=fe.get(Me.textures[jt]);V.framebufferTextureLayer(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0+jt,Dt.__webglTexture,et,_t)}}else if(Me!==null&&et!==0){const _t=fe.get(Me.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_2D,_t.__webglTexture,et)}G=-1},this.readRenderTargetPixels=function(Me,Ge,et,Qe,Le,ht,it,tt=0){if(!(Me&&Me.isWebGLRenderTarget)){Va("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _t=fe.get(Me).__webglFramebuffer;if(Me.isWebGLCubeRenderTarget&&it!==void 0&&(_t=_t[it]),_t){ie.bindFramebuffer(V.FRAMEBUFFER,_t);try{const jt=Me.textures[tt],Dt=jt.format,Rt=jt.type;if(!ne.textureFormatReadable(Dt)){Va("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ne.textureTypeReadable(Rt)){Va("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ge>=0&&Ge<=Me.width-Qe&&et>=0&&et<=Me.height-Le&&(Me.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+tt),V.readPixels(Ge,et,Qe,Le,Ve.convert(Dt),Ve.convert(Rt),ht))}finally{const jt=D!==null?fe.get(D).__webglFramebuffer:null;ie.bindFramebuffer(V.FRAMEBUFFER,jt)}}},this.readRenderTargetPixelsAsync=async function(Me,Ge,et,Qe,Le,ht,it,tt=0){if(!(Me&&Me.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let _t=fe.get(Me).__webglFramebuffer;if(Me.isWebGLCubeRenderTarget&&it!==void 0&&(_t=_t[it]),_t)if(Ge>=0&&Ge<=Me.width-Qe&&et>=0&&et<=Me.height-Le){ie.bindFramebuffer(V.FRAMEBUFFER,_t);const jt=Me.textures[tt],Dt=jt.format,Rt=jt.type;if(!ne.textureFormatReadable(Dt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ne.textureTypeReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const tn=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,tn),V.bufferData(V.PIXEL_PACK_BUFFER,ht.byteLength,V.STREAM_READ),Me.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+tt),V.readPixels(Ge,et,Qe,Le,Ve.convert(Dt),Ve.convert(Rt),0);const nn=D!==null?fe.get(D).__webglFramebuffer:null;ie.bindFramebuffer(V.FRAMEBUFFER,nn);const ln=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await qbe(V,ln,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,tn),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,ht),V.deleteBuffer(tn),V.deleteSync(ln),ht}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(Me,Ge=null,et=0){const Qe=Math.pow(2,-et),Le=Math.floor(Me.image.width*Qe),ht=Math.floor(Me.image.height*Qe),it=Ge!==null?Ge.x:0,tt=Ge!==null?Ge.y:0;oe.setTexture2D(Me,0),V.copyTexSubImage2D(V.TEXTURE_2D,et,0,0,it,tt,Le,ht),ie.unbindTexture()};const Ye=V.createFramebuffer(),It=V.createFramebuffer();this.copyTextureToTexture=function(Me,Ge,et=null,Qe=null,Le=0,ht=null){ht===null&&(Le!==0?(E0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ht=Le,Le=0):ht=0);let it,tt,_t,jt,Dt,Rt,tn,nn,ln;const vn=Me.isCompressedTexture?Me.mipmaps[ht]:Me.image;if(et!==null)it=et.max.x-et.min.x,tt=et.max.y-et.min.y,_t=et.isBox3?et.max.z-et.min.z:1,jt=et.min.x,Dt=et.min.y,Rt=et.isBox3?et.min.z:0;else{const ar=Math.pow(2,-Le);it=Math.floor(vn.width*ar),tt=Math.floor(vn.height*ar),Me.isDataArrayTexture?_t=vn.depth:Me.isData3DTexture?_t=Math.floor(vn.depth*ar):_t=1,jt=0,Dt=0,Rt=0}Qe!==null?(tn=Qe.x,nn=Qe.y,ln=Qe.z):(tn=0,nn=0,ln=0);const Rn=Ve.convert(Ge.format),Zt=Ve.convert(Ge.type);let xn;Ge.isData3DTexture?(oe.setTexture3D(Ge,0),xn=V.TEXTURE_3D):Ge.isDataArrayTexture||Ge.isCompressedArrayTexture?(oe.setTexture2DArray(Ge,0),xn=V.TEXTURE_2D_ARRAY):(oe.setTexture2D(Ge,0),xn=V.TEXTURE_2D),V.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,Ge.flipY),V.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ge.premultiplyAlpha),V.pixelStorei(V.UNPACK_ALIGNMENT,Ge.unpackAlignment);const mn=V.getParameter(V.UNPACK_ROW_LENGTH),Gr=V.getParameter(V.UNPACK_IMAGE_HEIGHT),yn=V.getParameter(V.UNPACK_SKIP_PIXELS),dr=V.getParameter(V.UNPACK_SKIP_ROWS),as=V.getParameter(V.UNPACK_SKIP_IMAGES);V.pixelStorei(V.UNPACK_ROW_LENGTH,vn.width),V.pixelStorei(V.UNPACK_IMAGE_HEIGHT,vn.height),V.pixelStorei(V.UNPACK_SKIP_PIXELS,jt),V.pixelStorei(V.UNPACK_SKIP_ROWS,Dt),V.pixelStorei(V.UNPACK_SKIP_IMAGES,Rt);const wn=Me.isDataArrayTexture||Me.isData3DTexture,Sr=Ge.isDataArrayTexture||Ge.isData3DTexture;if(Me.isDepthTexture){const ar=fe.get(Me),ya=fe.get(Ge),Ba=fe.get(ar.__renderTarget),sa=fe.get(ya.__renderTarget);ie.bindFramebuffer(V.READ_FRAMEBUFFER,Ba.__webglFramebuffer),ie.bindFramebuffer(V.DRAW_FRAMEBUFFER,sa.__webglFramebuffer);for(let vt=0;vt<_t;vt++)wn&&(V.framebufferTextureLayer(V.READ_FRAMEBUFFER,V.COLOR_ATTACHMENT0,fe.get(Me).__webglTexture,Le,Rt+vt),V.framebufferTextureLayer(V.DRAW_FRAMEBUFFER,V.COLOR_ATTACHMENT0,fe.get(Ge).__webglTexture,ht,ln+vt)),V.blitFramebuffer(jt,Dt,it,tt,tn,nn,it,tt,V.DEPTH_BUFFER_BIT,V.NEAREST);ie.bindFramebuffer(V.READ_FRAMEBUFFER,null),ie.bindFramebuffer(V.DRAW_FRAMEBUFFER,null)}else if(Le!==0||Me.isRenderTargetTexture||fe.has(Me)){const ar=fe.get(Me),ya=fe.get(Ge);ie.bindFramebuffer(V.READ_FRAMEBUFFER,Ye),ie.bindFramebuffer(V.DRAW_FRAMEBUFFER,It);for(let Ba=0;Ba<_t;Ba++)wn?V.framebufferTextureLayer(V.READ_FRAMEBUFFER,V.COLOR_ATTACHMENT0,ar.__webglTexture,Le,Rt+Ba):V.framebufferTexture2D(V.READ_FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_2D,ar.__webglTexture,Le),Sr?V.framebufferTextureLayer(V.DRAW_FRAMEBUFFER,V.COLOR_ATTACHMENT0,ya.__webglTexture,ht,ln+Ba):V.framebufferTexture2D(V.DRAW_FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_2D,ya.__webglTexture,ht),Le!==0?V.blitFramebuffer(jt,Dt,it,tt,tn,nn,it,tt,V.COLOR_BUFFER_BIT,V.NEAREST):Sr?V.copyTexSubImage3D(xn,ht,tn,nn,ln+Ba,jt,Dt,it,tt):V.copyTexSubImage2D(xn,ht,tn,nn,jt,Dt,it,tt);ie.bindFramebuffer(V.READ_FRAMEBUFFER,null),ie.bindFramebuffer(V.DRAW_FRAMEBUFFER,null)}else Sr?Me.isDataTexture||Me.isData3DTexture?V.texSubImage3D(xn,ht,tn,nn,ln,it,tt,_t,Rn,Zt,vn.data):Ge.isCompressedArrayTexture?V.compressedTexSubImage3D(xn,ht,tn,nn,ln,it,tt,_t,Rn,vn.data):V.texSubImage3D(xn,ht,tn,nn,ln,it,tt,_t,Rn,Zt,vn):Me.isDataTexture?V.texSubImage2D(V.TEXTURE_2D,ht,tn,nn,it,tt,Rn,Zt,vn.data):Me.isCompressedTexture?V.compressedTexSubImage2D(V.TEXTURE_2D,ht,tn,nn,vn.width,vn.height,Rn,vn.data):V.texSubImage2D(V.TEXTURE_2D,ht,tn,nn,it,tt,Rn,Zt,vn);V.pixelStorei(V.UNPACK_ROW_LENGTH,mn),V.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Gr),V.pixelStorei(V.UNPACK_SKIP_PIXELS,yn),V.pixelStorei(V.UNPACK_SKIP_ROWS,dr),V.pixelStorei(V.UNPACK_SKIP_IMAGES,as),ht===0&&Ge.generateMipmaps&&V.generateMipmap(xn),ie.unbindTexture()},this.initRenderTarget=function(Me){fe.get(Me).__webglFramebuffer===void 0&&oe.setupRenderTarget(Me)},this.initTexture=function(Me){Me.isCubeTexture?oe.setTextureCube(Me,0):Me.isData3DTexture?oe.setTexture3D(Me,0):Me.isDataArrayTexture||Me.isCompressedArrayTexture?oe.setTexture2DArray(Me,0):oe.setTexture2D(Me,0),ie.unbindTexture()},this.resetState=function(){R=0,M=0,D=null,ie.reset(),Te.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Tc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=br._getDrawingBufferColorSpace(e),n.unpackColorSpace=br._getUnpackColorSpace()}};const o6={type:"change"},c4={type:"start"},UX={type:"end"},RS=new r4,l6=new lh,NSe=Math.cos(70*Wbe.DEG2RAD),hi=new xt,Qs=2*Math.PI,$r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},TM=1e-6;class kSe extends Lxe{constructor(e,n=null){super(e,n),this.state=$r.NONE,this.target=new xt,this.cursor=new xt,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:ab.ROTATE,MIDDLE:ab.DOLLY,RIGHT:ab.PAN},this.touches={ONE:Wg.ROTATE,TWO:Wg.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new xt,this._lastQuaternion=new Hf,this._lastTargetPosition=new xt,this._quat=new Hf().setFromUnitVectors(e.up,new xt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new L8,this._sphericalDelta=new L8,this._scale=1,this._panOffset=new xt,this._rotateStart=new qn,this._rotateEnd=new qn,this._rotateDelta=new qn,this._panStart=new qn,this._panEnd=new qn,this._panDelta=new qn,this._dollyStart=new qn,this._dollyEnd=new qn,this._dollyDelta=new qn,this._dollyDirection=new xt,this._mouse=new qn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ASe.bind(this),this._onPointerDown=CSe.bind(this),this._onPointerUp=TSe.bind(this),this._onContextMenu=FSe.bind(this),this._onMouseWheel=jSe.bind(this),this._onKeyDown=ESe.bind(this),this._onTouchStart=DSe.bind(this),this._onTouchMove=RSe.bind(this),this._onMouseDown=MSe.bind(this),this._onMouseMove=PSe.bind(this),this._interceptControlDown=LSe.bind(this),this._interceptControlUp=OSe.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(o6),this.update(),this.state=$r.NONE}update(e=null){const n=this.object.position;hi.copy(n).sub(this.target),hi.applyQuaternion(this._quat),this._spherical.setFromVector3(hi),this.autoRotate&&this.state===$r.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+=Qs:r>Math.PI&&(r-=Qs),i<-Math.PI?i+=Qs:i>Math.PI&&(i-=Qs),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(hi.setFromSpherical(this._spherical),hi.applyQuaternion(this._quatInverse),n.copy(this.target).add(hi),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const l=hi.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const l=new xt(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 xt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=hi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(RS.origin.copy(this.object.position),RS.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(RS.direction))<NSe?this.object.lookAt(this.target):(l6.setFromNormalAndCoplanarPoint(this.object.up,this.target),RS.intersectPlane(l6,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)>TM||8*(1-this._lastQuaternion.dot(this.object.quaternion))>TM||this._lastTargetPosition.distanceToSquared(this.target)>TM?(this.dispatchEvent(o6),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Qs/60*this.autoRotateSpeed*e:Qs/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){hi.setFromMatrixColumn(n,0),hi.multiplyScalar(-e),this._panOffset.add(hi)}_panUp(e,n){this.screenSpacePanning===!0?hi.setFromMatrixColumn(n,1):(hi.setFromMatrixColumn(n,0),hi.crossVectors(this.object.up,hi)),hi.multiplyScalar(e),this._panOffset.add(hi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;hi.copy(i).sub(this.target);let s=hi.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*n*s/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,s=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Qs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Qs*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(Qs*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(-Qs*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(Qs*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(-Qs*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(Qs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Qs*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 qn,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 CSe(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 ASe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function TSe(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(UX),this.state=$r.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 MSe(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 ab.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=$r.DOLLY;break;case ab.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=$r.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=$r.ROTATE}break;case ab.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=$r.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=$r.PAN}break;default:this.state=$r.NONE}this.state!==$r.NONE&&this.dispatchEvent(c4)}function PSe(t){switch(this.state){case $r.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case $r.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case $r.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function jSe(t){this.enabled===!1||this.enableZoom===!1||this.state!==$r.NONE||(t.preventDefault(),this.dispatchEvent(c4),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(UX))}function ESe(t){this.enabled!==!1&&this._handleKeyDown(t)}function DSe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Wg.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=$r.TOUCH_ROTATE;break;case Wg.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=$r.TOUCH_PAN;break;default:this.state=$r.NONE}break;case 2:switch(this.touches.TWO){case Wg.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=$r.TOUCH_DOLLY_PAN;break;case Wg.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=$r.TOUCH_DOLLY_ROTATE;break;default:this.state=$r.NONE}break;default:this.state=$r.NONE}this.state!==$r.NONE&&this.dispatchEvent(c4)}function RSe(t){switch(this._trackPointer(t),this.state){case $r.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case $r.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case $r.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case $r.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=$r.NONE}}function FSe(t){this.enabled!==!1&&t.preventDefault()}function LSe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function OSe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ISe(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 Nl;let u=0;for(let d=0;d<t.length;++d){const h=t[d];let f=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 p in h.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(h.attributes[p]),f++}if(f!==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 p in h.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(h.morphAttributes[p])}if(e){let p;if(n)p=h.index.count;else if(h.attributes.position!==void 0)p=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,p,d),u+=p}}if(n){let d=0;const h=[];for(let f=0;f<t.length;++f){const p=t[f].index;for(let x=0;x<p.count;++x)h.push(p.getX(x)+d);d+=t[f].attributes.position.count}c.setIndex(h)}for(const d in s){const h=c6(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 f=0;f<h;++f){const p=[];for(let v=0;v<o[d].length;++v)p.push(o[d][v][f]);const x=c6(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function c6(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 Ls(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 f=0,p=d.count;f<p;f++)for(let x=0;x<n;x++){const v=d.getComponent(f,x);l.setComponent(f+h,x,v)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}class zSe extends l4{constructor(e){super(e)}load(e,n,r,i){const s=this,o=new Pxe(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,f=d.getUint32(80,!0);if(80+32/8+f*h===d.byteLength)return!0;const x=[115,111,108,105,100];for(let v=0;v<5;v++)if(r(x,d,v))return!1;return!0}function r(u,d,h){for(let f=0,p=u.length;f<p;f++)if(u[f]!==d.getUint8(h+f))return!1;return!0}function i(u){const d=new DataView(u),h=d.getUint32(80,!0);let f,p,x,v=!1,g,y,_,N,A;for(let G=0;G<70;G++)d.getUint32(G,!1)==1129270351&&d.getUint8(G+4)==82&&d.getUint8(G+5)==61&&(v=!0,g=new Float32Array(h*3*3),y=d.getUint8(G+6)/255,_=d.getUint8(G+7)/255,N=d.getUint8(G+8)/255,A=d.getUint8(G+9)/255);const C=84,j=50,k=new Nl,R=new Float32Array(h*3*3),M=new Float32Array(h*3*3),D=new Yn;for(let G=0;G<h;G++){const U=C+G*j,W=d.getFloat32(U,!0),L=d.getFloat32(U+4,!0),ee=d.getFloat32(U+8,!0);if(v){const ae=d.getUint16(U+48,!0);(ae&32768)===0?(f=(ae&31)/31,p=(ae>>5&31)/31,x=(ae>>10&31)/31):(f=y,p=_,x=N)}for(let ae=1;ae<=3;ae++){const Y=U+ae*12,se=G*3*3+(ae-1)*3;R[se]=d.getFloat32(Y,!0),R[se+1]=d.getFloat32(Y+4,!0),R[se+2]=d.getFloat32(Y+8,!0),M[se]=W,M[se+1]=L,M[se+2]=ee,v&&(D.setRGB(f,p,x,Ao),g[se]=D.r,g[se+1]=D.g,g[se+2]=D.b)}}return k.setAttribute("position",new Ls(R,3)),k.setAttribute("normal",new Ls(M,3)),v&&(k.setAttribute("color",new Ls(g,3)),k.hasColors=!0,k.alpha=A),k}function s(u){const d=new Nl,h=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g,p=/solid\s(.+)/;let x=0;const v=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,g=new RegExp("vertex"+v+v+v,"g"),y=new RegExp("normal"+v+v+v,"g"),_=[],N=[],A=[],C=new xt;let j,k=0,R=0,M=0;for(;(j=h.exec(u))!==null;){R=M;const D=j[0],G=(j=p.exec(D))!==null?j[1]:"";for(A.push(G);(j=f.exec(D))!==null;){let L=0,ee=0;const ae=j[0];for(;(j=y.exec(ae))!==null;)C.x=parseFloat(j[1]),C.y=parseFloat(j[2]),C.z=parseFloat(j[3]),ee++;for(;(j=g.exec(ae))!==null;)_.push(parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3])),N.push(C.x,C.y,C.z),L++,M++;ee!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+x),L!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+x),x++}const U=R,W=M-R;d.userData.groupNames=A,d.addGroup(U,W,k),k++}return d.setAttribute("position",new Do(_,3)),d.setAttribute("normal",new Do(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 FS(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 MM={exports:{}};var u6;function USe(){return u6||(u6=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 FS=="function"&&FS;if(!d&&h)return h(u,!0);if(l)return l(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(x){var v=r[u][1][x];return o(v||x)},p,p.exports,n,r,i,s)}return i[u].exports}for(var l=typeof FS=="function"&&FS,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,f,p,x,v,g=[],y=0,_=c.length,N=_,A=s.getTypeOf(c)!=="string";y<c.length;)N=_-y,h=A?(u=c[y++],d=y<_?c[y++]:0,y<_?c[y++]:0):(u=c.charCodeAt(y++),d=y<_?c.charCodeAt(y++):0,y<_?c.charCodeAt(y++):0),f=u>>2,p=(3&u)<<4|d>>4,x=1<N?(15&d)<<2|h>>6:64,v=2<N?63&h:64,g.push(l.charAt(f)+l.charAt(p)+l.charAt(x)+l.charAt(v));return g.join("")},i.decode=function(c){var u,d,h,f,p,x,v=0,g=0,y="data:";if(c.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var _,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(_=o.uint8array?new Uint8Array(0|N):new Array(0|N);v<c.length;)u=l.indexOf(c.charAt(v++))<<2|(f=l.indexOf(c.charAt(v++)))>>4,d=(15&f)<<4|(p=l.indexOf(c.charAt(v++)))>>2,h=(3&p)<<6|(x=l.indexOf(c.charAt(v++))),_[g++]=u,p!==64&&(_[g++]=d),x!==64&&(_[g++]=h);return _}},{"./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,f,p,x){this.compressedSize=d,this.uncompressedSize=h,this.crc32=f,this.compression=p,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),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,f){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(h.compressWorker(f)).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,f){var p=o,x=f+h;u^=-1;for(var v=f;v<x;v++)u=u>>>8^p[255&(u^d[v])];return-1^u})(0|c,l,l.length,0):(function(u,d,h,f){var p=o,x=f+h;u^=-1;for(var v=f;v<x;v++)u=u>>>8^p[255&(u^d.charCodeAt(v))];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,f){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=f,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(f){h.push({data:f,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(p,x){var v,g="";for(v=0;v<x;v++)g+=String.fromCharCode(255&p),p>>>=8;return g}function o(p,x,v,g,y,_){var N,A,C=p.file,j=p.compression,k=_!==u.utf8encode,R=l.transformTo("string",_(C.name)),M=l.transformTo("string",u.utf8encode(C.name)),D=C.comment,G=l.transformTo("string",_(D)),U=l.transformTo("string",u.utf8encode(D)),W=M.length!==C.name.length,L=U.length!==D.length,ee="",ae="",Y="",se=C.dir,ce=C.date,ye={crc32:0,compressedSize:0,uncompressedSize:0};x&&!v||(ye.crc32=p.crc32,ye.compressedSize=p.compressedSize,ye.uncompressedSize=p.uncompressedSize);var Z=0;x&&(Z|=8),k||!W&&!L||(Z|=2048);var ue=0,pe=0;se&&(ue|=16),y==="UNIX"?(pe=798,ue|=(function(Ee,$){var K=Ee;return Ee||(K=$?16893:33204),(65535&K)<<16})(C.unixPermissions,se)):(pe=20,ue|=(function(Ee){return 63&(Ee||0)})(C.dosPermissions)),N=ce.getUTCHours(),N<<=6,N|=ce.getUTCMinutes(),N<<=5,N|=ce.getUTCSeconds()/2,A=ce.getUTCFullYear()-1980,A<<=4,A|=ce.getUTCMonth()+1,A<<=5,A|=ce.getUTCDate(),W&&(ae=s(1,1)+s(d(R),4)+M,ee+="up"+s(ae.length,2)+ae),L&&(Y=s(1,1)+s(d(G),4)+U,ee+="uc"+s(Y.length,2)+Y);var be="";return be+=`
  3839. \0`,be+=s(Z,2),be+=j.magic,be+=s(N,2),be+=s(A,2),be+=s(ye.crc32,4),be+=s(ye.compressedSize,4),be+=s(ye.uncompressedSize,4),be+=s(R.length,2),be+=s(ee.length,2),{fileRecord:h.LOCAL_FILE_HEADER+be+R+ee,dirRecord:h.CENTRAL_FILE_HEADER+s(pe,2)+be+s(G.length,2)+"\0\0\0\0"+s(ue,4)+s(g,4)+R+ee+G}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),h=n("../signature");function f(p,x,v,g){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=v,this.encodeFileName=g,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(f,c),f.prototype.push=function(p){var x=p.meta.percent||0,v=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:v?(x+100*(v-g-1))/v:100}}))},f.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var v=o(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,v=o(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),x)this.push({data:(function(g){return h.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var v=this.bytesWritten-p,g=(function(y,_,N,A,C){var j=l.transformTo("string",C(A));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(_,4)+s(N,4)+s(j.length,2)+j})(this.dirRecords.length,v,p,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(p){this._sources.push(p);var x=this;return p.on("data",function(v){x.processChunk(v)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(v){x.error(v)}),this},f.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))},f.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var v=0;v<x.length;v++)try{x[v].error(p)}catch{}return!0},f.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=f},{"../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(f,p){h++;var x=(function(_,N){var A=_||N,C=s[A];if(!C)throw new Error(A+" is not a valid compression method !");return C})(p.options.compression,c.compression),v=p.options.compressionOptions||c.compressionOptions||{},g=p.dir,y=p.date;p._compressWorker(x,v).withStreamInfo("file",{name:f,dir:g,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(f){d.error(f)}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(f){return new o.Promise(function(p,x){var v=f.decompressed.getContentWorker().pipe(new u);v.on("error",function(g){x(g)}).on("end",function(){v.streamInfo.crc32!==f.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(f,p){var x=this;return p=s.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(f)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",f,!0,p.optimizedBinaryString,p.base64).then(function(v){var g=new c(p);return g.load(v),g}).then(function(v){var g=[o.Promise.resolve(v)],y=v.files;if(p.checkCRC32)for(var _=0;_<y.length;_++)g.push(h(y[_]));return o.Promise.all(g)}).then(function(v){for(var g=v.shift(),y=g.files,_=0;_<y.length;_++){var N=y[_],A=N.fileNameStr,C=s.resolve(N.fileNameStr);x.file(C,N.decompressed,{binary:!0,optimizedBinaryString:!0,date:N.date,dir:N.dir,comment:N.fileCommentStr.length?N.fileCommentStr:null,unixPermissions:N.unixPermissions,dosPermissions:N.dosPermissions,createFolders:p.createFolders}),N.dir||(x.file(C).unsafeOriginalName=A)}return g.zipComment.length&&(x.comment=g.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var s=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(l,o),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var s=n("readable-stream").Readable;function o(l,c,u){s.call(this,c),this._helper=l;var d=this;l.on("data",function(h,f){d.push(h)||d._helper.pause(),u&&u(f)}).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(C,j,k){var R,M=l.getTypeOf(j),D=l.extend(k||{},d);D.date=D.date||new Date,D.compression!==null&&(D.compression=D.compression.toUpperCase()),typeof D.unixPermissions=="string"&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(C=y(C)),D.createFolders&&(R=g(C))&&_.call(this,R,!0);var G=M==="string"&&D.binary===!1&&D.base64===!1;k&&k.binary!==void 0||(D.binary=!G),(j instanceof h&&j.uncompressedSize===0||D.dir||!j||j.length===0)&&(D.base64=!1,D.binary=!0,j="",D.compression="STORE",M="string");var U=null;U=j instanceof h||j instanceof c?j:x.isNode&&x.isStream(j)?new v(C,j):l.prepareContent(C,j,D.binary,D.optimizedBinaryString,D.base64);var W=new f(C,U,D);this.files[C]=W}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),h=n("./compressedObject"),f=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),g=function(C){C.slice(-1)==="/"&&(C=C.substring(0,C.length-1));var j=C.lastIndexOf("/");return 0<j?C.substring(0,j):""},y=function(C){return C.slice(-1)!=="/"&&(C+="/"),C},_=function(C,j){return j=j!==void 0?j:d.createFolders,C=y(C),this.files[C]||s.call(this,C,null,{dir:!0,createFolders:j}),this.files[C]};function N(C){return Object.prototype.toString.call(C)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(C){var j,k,R;for(j in this.files)R=this.files[j],(k=j.slice(this.root.length,j.length))&&j.slice(0,this.root.length)===this.root&&C(k,R)},filter:function(C){var j=[];return this.forEach(function(k,R){C(k,R)&&j.push(R)}),j},file:function(C,j,k){if(arguments.length!==1)return C=this.root+C,s.call(this,C,j,k),this;if(N(C)){var R=C;return this.filter(function(D,G){return!G.dir&&R.test(D)})}var M=this.files[this.root+C];return M&&!M.dir?M:null},folder:function(C){if(!C)return this;if(N(C))return this.filter(function(M,D){return D.dir&&C.test(M)});var j=this.root+C,k=_.call(this,j),R=this.clone();return R.root=k.name,R},remove:function(C){C=this.root+C;var j=this.files[C];if(j||(C.slice(-1)!=="/"&&(C+="/"),j=this.files[C]),j&&!j.dir)delete this.files[C];else for(var k=this.filter(function(M,D){return D.name.slice(0,C.length)===C}),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(C){var j,k={};try{if((k=l.extend(C||{},{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||"";j=p.generateWorker(this,k,R)}catch(M){(j=new c("error")).error(M)}return new u(j,k.type||"string",k.mimeType)},generateAsync:function(C,j){return this.generateInternalStream(C).accumulate(j)},generateNodeStream:function(C,j){return(C=C||{}).type||(C.type="nodebuffer"),this.generateInternalStream(C).toNodejsStream(j)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var s=n("./DataReader");function 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),f=this.length-4;0<=f;--f)if(this.data[f]===c&&this.data[f+1]===u&&this.data[f+2]===d&&this.data[f+3]===h)return f-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),f=this.readData(4);return c===f[0]&&u===f[1]&&d===f[2]&&h===f[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 f=s.getTypeOf(h);return s.checkSupport(f),f!=="string"||o.uint8array?f==="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 f(x,v){return new d.Promise(function(g,y){var _=[],N=x._internalType,A=x._outputType,C=x._mimeType;x.on("data",function(j,k){_.push(j),v&&v(k)}).on("error",function(j){_=[],y(j)}).on("end",function(){try{var j=(function(k,R,M){switch(k){case"blob":return s.newBlob(s.transformTo("arraybuffer",R),M);case"base64":return c.encode(R);default:return s.transformTo(k,R)}})(A,(function(k,R){var M,D=0,G=null,U=0;for(M=0;M<R.length;M++)U+=R[M].length;switch(k){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(G=new Uint8Array(U),M=0;M<R.length;M++)G.set(R[M],D),D+=R[M].length;return G;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+k+"'")}})(N,_),C);g(j)}catch(k){y(k)}_=[]}).resume()})}function p(x,v,g){var y=v;switch(v){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=v,this._mimeType=g,s.checkSupport(y),this._worker=x.pipe(new o(y)),x.lock()}catch(_){this._worker=new l("error"),this._worker.error(_)}}p.prototype={accumulate:function(x){return f(this,x)},on:function(x,v){var g=this;return x==="data"?this._worker.on(x,function(y){v.call(g,y.data,y.meta)}):this._worker.on(x,function(){s.delay(v,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var s=n("./utils"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function h(){c.call(this,"utf-8 decode"),this.leftOver=null}function f(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return o.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(x){var v,g,y,_,N,A=x.length,C=0;for(_=0;_<A;_++)(64512&(g=x.charCodeAt(_)))==55296&&_+1<A&&(64512&(y=x.charCodeAt(_+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),_++),C+=g<128?1:g<2048?2:g<65536?3:4;for(v=o.uint8array?new Uint8Array(C):new Array(C),_=N=0;N<C;_++)(64512&(g=x.charCodeAt(_)))==55296&&_+1<A&&(64512&(y=x.charCodeAt(_+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),_++),g<128?v[N++]=g:(g<2048?v[N++]=192|g>>>6:(g<65536?v[N++]=224|g>>>12:(v[N++]=240|g>>>18,v[N++]=128|g>>>12&63),v[N++]=128|g>>>6&63),v[N++]=128|63&g);return v})(p)},i.utf8decode=function(p){return o.nodebuffer?s.transformTo("nodebuffer",p).toString("utf-8"):(function(x){var v,g,y,_,N=x.length,A=new Array(2*N);for(v=g=0;v<N;)if((y=x[v++])<128)A[g++]=y;else if(4<(_=u[y]))A[g++]=65533,v+=_-1;else{for(y&=_===2?31:_===3?15:7;1<_&&v<N;)y=y<<6|63&x[v++],_--;1<_?A[g++]=65533:y<65536?A[g++]=y:(y-=65536,A[g++]=55296|y>>10&1023,A[g++]=56320|1023&y)}return A.length!==g&&(A.subarray?A=A.subarray(0,g):A.length=g),s.applyFromCharCode(A)})(p=s.transformTo(o.uint8array?"uint8array":"array",p))},s.inherits(h,c),h.prototype.processChunk=function(p){var x=s.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var v=x;(x=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),x.set(v,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var g=(function(_,N){var A;for((N=N||_.length)>_.length&&(N=_.length),A=N-1;0<=A&&(192&_[A])==128;)A--;return A<0||A===0?N:A+u[_[A]]>N?A:N})(x),y=x;g!==x.length&&(o.uint8array?(y=x.subarray(0,g),this.leftOver=x.subarray(g,x.length)):(y=x.slice(0,g),this.leftOver=x.slice(g,x.length))),this.push({data:i.utf8decode(y),meta:p.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(f,c),f.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=f},{"./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(v){return v}function d(v,g){for(var y=0;y<v.length;++y)g[y]=255&v.charCodeAt(y);return g}n("setimmediate"),i.newBlob=function(v,g){i.checkSupport("blob");try{return new Blob([v],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(v),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(v,g,y){var _=[],N=0,A=v.length;if(A<=y)return String.fromCharCode.apply(null,v);for(;N<A;)g==="array"||g==="nodebuffer"?_.push(String.fromCharCode.apply(null,v.slice(N,Math.min(N+y,A)))):_.push(String.fromCharCode.apply(null,v.subarray(N,Math.min(N+y,A)))),N+=y;return _.join("")},stringifyByChar:function(v){for(var g="",y=0;y<v.length;y++)g+=String.fromCharCode(v[y]);return g},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 f(v){var g=65536,y=i.getTypeOf(v),_=!0;if(y==="uint8array"?_=h.applyCanBeUsed.uint8array:y==="nodebuffer"&&(_=h.applyCanBeUsed.nodebuffer),_)for(;1<g;)try{return h.stringifyByChunk(v,y,g)}catch{g=Math.floor(g/2)}return h.stringifyByChar(v)}function p(v,g){for(var y=0;y<v.length;y++)g[y]=v[y];return g}i.applyFromCharCode=f;var x={};x.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return x.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,l.allocBuffer(v.length))}},x.array={string:f,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(v)}},x.arraybuffer={string:function(v){return f(new Uint8Array(v))},array:function(v){return p(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(new Uint8Array(v))}},x.uint8array={string:f,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return l.newBufferFrom(v)}},x.nodebuffer={string:f,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return x.nodebuffer.uint8array(v).buffer},uint8array:function(v){return p(v,new Uint8Array(v.length))},nodebuffer:u},i.transformTo=function(v,g){if(g=g||"",!v)return g;i.checkSupport(v);var y=i.getTypeOf(g);return x[y][v](g)},i.resolve=function(v){for(var g=v.split("/"),y=[],_=0;_<g.length;_++){var N=g[_];N==="."||N===""&&_!==0&&_!==g.length-1||(N===".."?y.pop():y.push(N))}return y.join("/")},i.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":s.nodebuffer&&l.isBuffer(v)?"nodebuffer":s.uint8array&&v instanceof Uint8Array?"uint8array":s.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(v){if(!s[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(v){var g,y,_="";for(y=0;y<(v||"").length;y++)_+="\\x"+((g=v.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return _},i.delay=function(v,g,y){setImmediate(function(){v.apply(y||null,g||[])})},i.inherits=function(v,g){function y(){}y.prototype=g.prototype,v.prototype=new y},i.extend=function(){var v,g,y={};for(v=0;v<arguments.length;v++)for(g in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],g)&&y[g]===void 0&&(y[g]=arguments[v][g]);return y},i.prepareContent=function(v,g,y,_,N){return c.Promise.resolve(g).then(function(A){return s.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new c.Promise(function(C,j){var k=new FileReader;k.onload=function(R){C(R.target.result)},k.onerror=function(R){j(R.target.error)},k.readAsArrayBuffer(A)}):A}).then(function(A){var C=i.getTypeOf(A);return C?(C==="arraybuffer"?A=i.transformTo("uint8array",A):C==="string"&&(N?A=o.decode(A):y&&_!==!0&&(A=(function(j){return d(j,s.uint8array?new Uint8Array(j.length):new Array(j.length))})(A))),A):c.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var 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 f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(f)+", expected "+o.pretty(h)+")")}},isSignature:function(h,f){var p=this.reader.index;this.reader.setIndex(h);var x=this.reader.readString(4)===f;return this.reader.setIndex(p),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),f=u.uint8array?"uint8array":"array",p=o.transformTo(f,h);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h,f,p,x=this.zip64EndOfCentralSize-44;0<x;)h=this.reader.readInt(2),f=this.reader.readInt(4),p=this.reader.readData(f),this.zip64ExtensibleData[h]={id:h,length:f,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,f;for(h=0;h<this.files.length;h++)f=this.files[h],this.reader.setIndex(f.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.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 f=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 p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=f-p;if(0<x)this.isSignature(f,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" 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 f(p,x){this.options=p,this.loadOptions=x}f.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,v;if(p.skip(22),this.fileNameLength=p.readInt(2),v=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(g){for(var y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===g)return d[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,v,g,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)x=p.readInt(2),v=p.readInt(2),g=p.readData(v),this.extraFields[x]={id:x,length:v,value:g};p.setIndex(y)},handleUTF8:function(){var p=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var v=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=s(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=s(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function s(x,v,g){this.name=x,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=v,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(x){var v=null,g="string";try{if(!x)throw new Error("No output type specified.");var y=(g=x.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),v=this._decompressWorker();var _=!this._dataBinary;_&&!y&&(v=v.pipe(new c.Utf8EncodeWorker)),!_&&y&&(v=v.pipe(new c.Utf8DecodeWorker))}catch(N){(v=new d("error")).error(N)}return new o(v,g,"")},async:function(x,v){return this.internalStream(x).accumulate(v)},nodeStream:function(x,v){return this.internalStream(x||"nodebuffer").toNodejsStream(v)},_compressWorker:function(x,v){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(g,x,v)},_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"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<h.length;p++)s.prototype[h[p]]=f;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(s){var o,l,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var u=0,d=new c(x),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 v=s.document.createElement("script");v.onreadystatechange=function(){x(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},s.document.documentElement.appendChild(v)}:function(){setTimeout(x,0)};else{var f=new s.MessageChannel;f.port1.onmessage=x,o=function(){f.port2.postMessage(0)}}var p=[];function x(){var v,g;l=!0;for(var y=p.length;y;){for(g=p,p=[],v=-1;++v<y;)g[v]();y=p.length}l=!1}r.exports=function(v){p.push(v)!==1||l||o()}}).call(this,typeof sS<"u"?sS: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(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==o&&v(this,y)}function f(y,_,N){this.promise=y,typeof _=="function"&&(this.onFulfilled=_,this.callFulfilled=this.otherCallFulfilled),typeof N=="function"&&(this.onRejected=N,this.callRejected=this.otherCallRejected)}function p(y,_,N){s(function(){var A;try{A=_(N)}catch(C){return l.reject(y,C)}A===y?l.reject(y,new TypeError("Cannot resolve promise with itself")):l.resolve(y,A)})}function x(y){var _=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof _=="function")return function(){_.apply(y,arguments)}}function v(y,_){var N=!1;function A(k){N||(N=!0,l.reject(y,k))}function C(k){N||(N=!0,l.resolve(y,k))}var j=g(function(){_(C,A)});j.status==="error"&&A(j.value)}function g(y,_){var N={};try{N.value=y(_),N.status="success"}catch(A){N.status="error",N.value=A}return N}(r.exports=h).prototype.finally=function(y){if(typeof y!="function")return this;var _=this.constructor;return this.then(function(N){return _.resolve(y()).then(function(){return N})},function(N){return _.resolve(y()).then(function(){throw N})})},h.prototype.catch=function(y){return this.then(null,y)},h.prototype.then=function(y,_){if(typeof y!="function"&&this.state===u||typeof _!="function"&&this.state===c)return this;var N=new this.constructor(o);return this.state!==d?p(N,this.state===u?y:_,this.outcome):this.queue.push(new f(N,y,_)),N},f.prototype.callFulfilled=function(y){l.resolve(this.promise,y)},f.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},f.prototype.callRejected=function(y){l.reject(this.promise,y)},f.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},l.resolve=function(y,_){var N=g(x,_);if(N.status==="error")return l.reject(y,N.value);var A=N.value;if(A)v(y,A);else{y.state=u,y.outcome=_;for(var C=-1,j=y.queue.length;++C<j;)y.queue[C].callFulfilled(_)}return y},l.reject=function(y,_){y.state=c,y.outcome=_;for(var N=-1,A=y.queue.length;++N<A;)y.queue[N].callRejected(_);return y},h.resolve=function(y){return y instanceof this?y:l.resolve(new this(o),y)},h.reject=function(y){var _=new this(o);return l.reject(_,y)},h.all=function(y){var _=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=y.length,A=!1;if(!N)return this.resolve([]);for(var C=new Array(N),j=0,k=-1,R=new this(o);++k<N;)M(y[k],k);return R;function M(D,G){_.resolve(D).then(function(U){C[G]=U,++j!==N||A||(A=!0,l.resolve(R,C))},function(U){A||(A=!0,l.reject(R,U))})}},h.race=function(y){var _=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=y.length,A=!1;if(!N)return this.resolve([]);for(var C=-1,j=new this(o);++C<N;)k=y[C],_.resolve(k).then(function(R){A||(A=!0,l.resolve(j,R))},function(R){A||(A=!0,l.reject(j,R))});var k;return j}},{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,f=-1,p=0,x=8;function v(y){if(!(this instanceof v))return new v(y);this.options=o.assign({level:f,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var _=this.options;_.raw&&0<_.windowBits?_.windowBits=-_.windowBits:_.gzip&&0<_.windowBits&&_.windowBits<16&&(_.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,_.level,_.method,_.windowBits,_.memLevel,_.strategy);if(N!==h)throw new Error(c[N]);if(_.header&&s.deflateSetHeader(this.strm,_.header),_.dictionary){var A;if(A=typeof _.dictionary=="string"?l.string2buf(_.dictionary):d.call(_.dictionary)==="[object ArrayBuffer]"?new Uint8Array(_.dictionary):_.dictionary,(N=s.deflateSetDictionary(this.strm,A))!==h)throw new Error(c[N]);this._dict_set=!0}}function g(y,_){var N=new v(_);if(N.push(y,!0),N.err)throw N.msg||c[N.err];return N.result}v.prototype.push=function(y,_){var N,A,C=this.strm,j=this.options.chunkSize;if(this.ended)return!1;A=_===~~_?_:_===!0?4:0,typeof y=="string"?C.input=l.string2buf(y):d.call(y)==="[object ArrayBuffer]"?C.input=new Uint8Array(y):C.input=y,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new o.Buf8(j),C.next_out=0,C.avail_out=j),(N=s.deflate(C,A))!==1&&N!==h)return this.onEnd(N),!(this.ended=!0);C.avail_out!==0&&(C.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(C.output,C.next_out))):this.onData(o.shrinkBuf(C.output,C.next_out)))}while((0<C.avail_in||C.avail_out===0)&&N!==1);return A===4?(N=s.deflateEnd(this.strm),this.onEnd(N),this.ended=!0,N===h):A!==2||(this.onEnd(h),!(C.avail_out=0))},v.prototype.onData=function(y){this.chunks.push(y)},v.prototype.onEnd=function(y){y===h&&(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.Deflate=v,i.deflate=g,i.deflateRaw=function(y,_){return(_=_||{}).raw=!0,g(y,_)},i.gzip=function(y,_){return(_=_||{}).gzip=!0,g(y,_)}},{"./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"),f=Object.prototype.toString;function p(v){if(!(this instanceof p))return new p(v);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},v||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||v&&v.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var y=s.inflateInit2(this.strm,g.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function x(v,g){var y=new p(g);if(y.push(v,!0),y.err)throw y.msg||u[y.err];return y.result}p.prototype.push=function(v,g){var y,_,N,A,C,j,k=this.strm,R=this.options.chunkSize,M=this.options.dictionary,D=!1;if(this.ended)return!1;_=g===~~g?g:g===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof v=="string"?k.input=l.binstring2buf(v):f.call(v)==="[object ArrayBuffer]"?k.input=new Uint8Array(v):k.input=v,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),(y=s.inflate(k,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&M&&(j=typeof M=="string"?l.string2buf(M):f.call(M)==="[object ArrayBuffer]"?new Uint8Array(M):M,y=s.inflateSetDictionary(this.strm,j)),y===c.Z_BUF_ERROR&&D===!0&&(y=c.Z_OK,D=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);k.next_out&&(k.avail_out!==0&&y!==c.Z_STREAM_END&&(k.avail_in!==0||_!==c.Z_FINISH&&_!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(N=l.utf8border(k.output,k.next_out),A=k.next_out-N,C=l.buf2string(k.output,N),k.next_out=A,k.avail_out=R-A,A&&o.arraySet(k.output,k.output,N,A,0),this.onData(C)):this.onData(o.shrinkBuf(k.output,k.next_out)))),k.avail_in===0&&k.avail_out===0&&(D=!0)}while((0<k.avail_in||k.avail_out===0)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(_=c.Z_FINISH),_===c.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c.Z_OK):_!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(k.avail_out=0))},p.prototype.onData=function(v){this.chunks.push(v)},p.prototype.onEnd=function(v){v===c.Z_OK&&(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.Inflate=p,i.inflate=x,i.inflateRaw=function(v,g){return(g=g||{}).raw=!0,x(v,g)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var 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,f){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+h),f);else for(var p=0;p<h;p++)c[f+p]=u[d+p]},flattenChunks:function(c){var u,d,h,f,p,x;for(u=h=0,d=c.length;u<d;u++)h+=c[u].length;for(x=new Uint8Array(h),u=f=0,d=c.length;u<d;u++)p=c[u],x.set(p,f),f+=p.length;return x}},l={arraySet:function(c,u,d,h,f){for(var p=0;p<h;p++)c[f+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(s)},{}],42:[function(n,r,i){var s=n("./common"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new s.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(h,f){if(f<65537&&(h.subarray&&l||!h.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(h,f));for(var p="",x=0;x<f;x++)p+=String.fromCharCode(h[x]);return p}c[254]=c[254]=1,i.string2buf=function(h){var f,p,x,v,g,y=h.length,_=0;for(v=0;v<y;v++)(64512&(p=h.charCodeAt(v)))==55296&&v+1<y&&(64512&(x=h.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),_+=p<128?1:p<2048?2:p<65536?3:4;for(f=new s.Buf8(_),v=g=0;g<_;v++)(64512&(p=h.charCodeAt(v)))==55296&&v+1<y&&(64512&(x=h.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),p<128?f[g++]=p:(p<2048?f[g++]=192|p>>>6:(p<65536?f[g++]=224|p>>>12:(f[g++]=240|p>>>18,f[g++]=128|p>>>12&63),f[g++]=128|p>>>6&63),f[g++]=128|63&p);return f},i.buf2binstring=function(h){return d(h,h.length)},i.binstring2buf=function(h){for(var f=new s.Buf8(h.length),p=0,x=f.length;p<x;p++)f[p]=h.charCodeAt(p);return f},i.buf2string=function(h,f){var p,x,v,g,y=f||h.length,_=new Array(2*y);for(p=x=0;p<y;)if((v=h[p++])<128)_[x++]=v;else if(4<(g=c[v]))_[x++]=65533,p+=g-1;else{for(v&=g===2?31:g===3?15:7;1<g&&p<y;)v=v<<6|63&h[p++],g--;1<g?_[x++]=65533:v<65536?_[x++]=v:(v-=65536,_[x++]=55296|v>>10&1023,_[x++]=56320|1023&v)}return d(_,x)},i.utf8border=function(h,f){var p;for((f=f||h.length)>h.length&&(f=h.length),p=f-1;0<=p&&(192&h[p])==128;)p--;return p<0||p===0?f:p+c[h[p]]>f?p:f}},{"./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 f=u;f<h;f++)o=o>>>8^d[255&(o^l[f])];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,f=4,p=0,x=-2,v=-1,g=4,y=2,_=8,N=9,A=286,C=30,j=19,k=2*A+1,R=15,M=3,D=258,G=D+M+1,U=42,W=113,L=1,ee=2,ae=3,Y=4;function se(z,V){return z.msg=d[V],V}function ce(z){return(z<<1)-(4<z?9:0)}function ye(z){for(var V=z.length;0<=--V;)z[V]=0}function Z(z){var V=z.state,te=V.pending;te>z.avail_out&&(te=z.avail_out),te!==0&&(o.arraySet(z.output,V.pending_buf,V.pending_out,te,z.next_out),z.next_out+=te,V.pending_out+=te,z.total_out+=te,z.avail_out-=te,V.pending-=te,V.pending===0&&(V.pending_out=0))}function ue(z,V){l._tr_flush_block(z,0<=z.block_start?z.block_start:-1,z.strstart-z.block_start,V),z.block_start=z.strstart,Z(z.strm)}function pe(z,V){z.pending_buf[z.pending++]=V}function be(z,V){z.pending_buf[z.pending++]=V>>>8&255,z.pending_buf[z.pending++]=255&V}function Ee(z,V){var te,Q,ne=z.max_chain_length,ie=z.strstart,me=z.prev_length,fe=z.nice_match,oe=z.strstart>z.w_size-G?z.strstart-(z.w_size-G):0,I=z.window,F=z.w_mask,J=z.prev,xe=z.strstart+D,he=I[ie+me-1],le=I[ie+me];z.prev_length>=z.good_match&&(ne>>=2),fe>z.lookahead&&(fe=z.lookahead);do if(I[(te=V)+me]===le&&I[te+me-1]===he&&I[te]===I[ie]&&I[++te]===I[ie+1]){ie+=2,te++;do;while(I[++ie]===I[++te]&&I[++ie]===I[++te]&&I[++ie]===I[++te]&&I[++ie]===I[++te]&&I[++ie]===I[++te]&&I[++ie]===I[++te]&&I[++ie]===I[++te]&&I[++ie]===I[++te]&&ie<xe);if(Q=D-(xe-ie),ie=xe-D,me<Q){if(z.match_start=V,fe<=(me=Q))break;he=I[ie+me-1],le=I[ie+me]}}while((V=J[V&F])>oe&&--ne!=0);return me<=z.lookahead?me:z.lookahead}function $(z){var V,te,Q,ne,ie,me,fe,oe,I,F,J=z.w_size;do{if(ne=z.window_size-z.lookahead-z.strstart,z.strstart>=J+(J-G)){for(o.arraySet(z.window,z.window,J,J,0),z.match_start-=J,z.strstart-=J,z.block_start-=J,V=te=z.hash_size;Q=z.head[--V],z.head[V]=J<=Q?Q-J:0,--te;);for(V=te=J;Q=z.prev[--V],z.prev[V]=J<=Q?Q-J:0,--te;);ne+=J}if(z.strm.avail_in===0)break;if(me=z.strm,fe=z.window,oe=z.strstart+z.lookahead,I=ne,F=void 0,F=me.avail_in,I<F&&(F=I),te=F===0?0:(me.avail_in-=F,o.arraySet(fe,me.input,me.next_in,F,oe),me.state.wrap===1?me.adler=c(me.adler,fe,F,oe):me.state.wrap===2&&(me.adler=u(me.adler,fe,F,oe)),me.next_in+=F,me.total_in+=F,F),z.lookahead+=te,z.lookahead+z.insert>=M)for(ie=z.strstart-z.insert,z.ins_h=z.window[ie],z.ins_h=(z.ins_h<<z.hash_shift^z.window[ie+1])&z.hash_mask;z.insert&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[ie+M-1])&z.hash_mask,z.prev[ie&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=ie,ie++,z.insert--,!(z.lookahead+z.insert<M)););}while(z.lookahead<G&&z.strm.avail_in!==0)}function K(z,V){for(var te,Q;;){if(z.lookahead<G){if($(z),z.lookahead<G&&V===h)return L;if(z.lookahead===0)break}if(te=0,z.lookahead>=M&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+M-1])&z.hash_mask,te=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),te!==0&&z.strstart-te<=z.w_size-G&&(z.match_length=Ee(z,te)),z.match_length>=M)if(Q=l._tr_tally(z,z.strstart-z.match_start,z.match_length-M),z.lookahead-=z.match_length,z.match_length<=z.max_lazy_match&&z.lookahead>=M){for(z.match_length--;z.strstart++,z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+M-1])&z.hash_mask,te=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart,--z.match_length!=0;);z.strstart++}else z.strstart+=z.match_length,z.match_length=0,z.ins_h=z.window[z.strstart],z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+1])&z.hash_mask;else Q=l._tr_tally(z,0,z.window[z.strstart]),z.lookahead--,z.strstart++;if(Q&&(ue(z,!1),z.strm.avail_out===0))return L}return z.insert=z.strstart<M-1?z.strstart:M-1,V===f?(ue(z,!0),z.strm.avail_out===0?ae:Y):z.last_lit&&(ue(z,!1),z.strm.avail_out===0)?L:ee}function T(z,V){for(var te,Q,ne;;){if(z.lookahead<G){if($(z),z.lookahead<G&&V===h)return L;if(z.lookahead===0)break}if(te=0,z.lookahead>=M&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+M-1])&z.hash_mask,te=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),z.prev_length=z.match_length,z.prev_match=z.match_start,z.match_length=M-1,te!==0&&z.prev_length<z.max_lazy_match&&z.strstart-te<=z.w_size-G&&(z.match_length=Ee(z,te),z.match_length<=5&&(z.strategy===1||z.match_length===M&&4096<z.strstart-z.match_start)&&(z.match_length=M-1)),z.prev_length>=M&&z.match_length<=z.prev_length){for(ne=z.strstart+z.lookahead-M,Q=l._tr_tally(z,z.strstart-1-z.prev_match,z.prev_length-M),z.lookahead-=z.prev_length-1,z.prev_length-=2;++z.strstart<=ne&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+M-1])&z.hash_mask,te=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),--z.prev_length!=0;);if(z.match_available=0,z.match_length=M-1,z.strstart++,Q&&(ue(z,!1),z.strm.avail_out===0))return L}else if(z.match_available){if((Q=l._tr_tally(z,0,z.window[z.strstart-1]))&&ue(z,!1),z.strstart++,z.lookahead--,z.strm.avail_out===0)return L}else z.match_available=1,z.strstart++,z.lookahead--}return z.match_available&&(Q=l._tr_tally(z,0,z.window[z.strstart-1]),z.match_available=0),z.insert=z.strstart<M-1?z.strstart:M-1,V===f?(ue(z,!0),z.strm.avail_out===0?ae:Y):z.last_lit&&(ue(z,!1),z.strm.avail_out===0)?L:ee}function E(z,V,te,Q,ne){this.good_length=z,this.max_lazy=V,this.nice_length=te,this.max_chain=Q,this.func=ne}function O(){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=_,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*C+1)),this.bl_tree=new o.Buf16(2*(2*j+1)),ye(this.dyn_ltree),ye(this.dyn_dtree),ye(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*A+1),ye(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*A+1),ye(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 q(z){var V;return z&&z.state?(z.total_in=z.total_out=0,z.data_type=y,(V=z.state).pending=0,V.pending_out=0,V.wrap<0&&(V.wrap=-V.wrap),V.status=V.wrap?U:W,z.adler=V.wrap===2?0:1,V.last_flush=h,l._tr_init(V),p):se(z,x)}function B(z){var V=q(z);return V===p&&(function(te){te.window_size=2*te.w_size,ye(te.head),te.max_lazy_match=s[te.level].max_lazy,te.good_match=s[te.level].good_length,te.nice_match=s[te.level].nice_length,te.max_chain_length=s[te.level].max_chain,te.strstart=0,te.block_start=0,te.lookahead=0,te.insert=0,te.match_length=te.prev_length=M-1,te.match_available=0,te.ins_h=0})(z.state),V}function re(z,V,te,Q,ne,ie){if(!z)return x;var me=1;if(V===v&&(V=6),Q<0?(me=0,Q=-Q):15<Q&&(me=2,Q-=16),ne<1||N<ne||te!==_||Q<8||15<Q||V<0||9<V||ie<0||g<ie)return se(z,x);Q===8&&(Q=9);var fe=new O;return(z.state=fe).strm=z,fe.wrap=me,fe.gzhead=null,fe.w_bits=Q,fe.w_size=1<<fe.w_bits,fe.w_mask=fe.w_size-1,fe.hash_bits=ne+7,fe.hash_size=1<<fe.hash_bits,fe.hash_mask=fe.hash_size-1,fe.hash_shift=~~((fe.hash_bits+M-1)/M),fe.window=new o.Buf8(2*fe.w_size),fe.head=new o.Buf16(fe.hash_size),fe.prev=new o.Buf16(fe.w_size),fe.lit_bufsize=1<<ne+6,fe.pending_buf_size=4*fe.lit_bufsize,fe.pending_buf=new o.Buf8(fe.pending_buf_size),fe.d_buf=1*fe.lit_bufsize,fe.l_buf=3*fe.lit_bufsize,fe.level=V,fe.strategy=ie,fe.method=te,B(z)}s=[new E(0,0,0,0,function(z,V){var te=65535;for(te>z.pending_buf_size-5&&(te=z.pending_buf_size-5);;){if(z.lookahead<=1){if($(z),z.lookahead===0&&V===h)return L;if(z.lookahead===0)break}z.strstart+=z.lookahead,z.lookahead=0;var Q=z.block_start+te;if((z.strstart===0||z.strstart>=Q)&&(z.lookahead=z.strstart-Q,z.strstart=Q,ue(z,!1),z.strm.avail_out===0)||z.strstart-z.block_start>=z.w_size-G&&(ue(z,!1),z.strm.avail_out===0))return L}return z.insert=0,V===f?(ue(z,!0),z.strm.avail_out===0?ae:Y):(z.strstart>z.block_start&&(ue(z,!1),z.strm.avail_out),L)}),new E(4,4,8,4,K),new E(4,5,16,8,K),new E(4,6,32,32,K),new E(4,4,16,16,T),new E(8,16,32,32,T),new E(8,16,128,128,T),new E(8,32,128,256,T),new E(32,128,258,1024,T),new E(32,258,258,4096,T)],i.deflateInit=function(z,V){return re(z,V,_,15,8,0)},i.deflateInit2=re,i.deflateReset=B,i.deflateResetKeep=q,i.deflateSetHeader=function(z,V){return z&&z.state?z.state.wrap!==2?x:(z.state.gzhead=V,p):x},i.deflate=function(z,V){var te,Q,ne,ie;if(!z||!z.state||5<V||V<0)return z?se(z,x):x;if(Q=z.state,!z.output||!z.input&&z.avail_in!==0||Q.status===666&&V!==f)return se(z,z.avail_out===0?-5:x);if(Q.strm=z,te=Q.last_flush,Q.last_flush=V,Q.status===U)if(Q.wrap===2)z.adler=0,pe(Q,31),pe(Q,139),pe(Q,8),Q.gzhead?(pe(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)),pe(Q,255&Q.gzhead.time),pe(Q,Q.gzhead.time>>8&255),pe(Q,Q.gzhead.time>>16&255),pe(Q,Q.gzhead.time>>24&255),pe(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),pe(Q,255&Q.gzhead.os),Q.gzhead.extra&&Q.gzhead.extra.length&&(pe(Q,255&Q.gzhead.extra.length),pe(Q,Q.gzhead.extra.length>>8&255)),Q.gzhead.hcrc&&(z.adler=u(z.adler,Q.pending_buf,Q.pending,0)),Q.gzindex=0,Q.status=69):(pe(Q,0),pe(Q,0),pe(Q,0),pe(Q,0),pe(Q,0),pe(Q,Q.level===9?2:2<=Q.strategy||Q.level<2?4:0),pe(Q,3),Q.status=W);else{var me=_+(Q.w_bits-8<<4)<<8;me|=(2<=Q.strategy||Q.level<2?0:Q.level<6?1:Q.level===6?2:3)<<6,Q.strstart!==0&&(me|=32),me+=31-me%31,Q.status=W,be(Q,me),Q.strstart!==0&&(be(Q,z.adler>>>16),be(Q,65535&z.adler)),z.adler=1}if(Q.status===69)if(Q.gzhead.extra){for(ne=Q.pending;Q.gzindex<(65535&Q.gzhead.extra.length)&&(Q.pending!==Q.pending_buf_size||(Q.gzhead.hcrc&&Q.pending>ne&&(z.adler=u(z.adler,Q.pending_buf,Q.pending-ne,ne)),Z(z),ne=Q.pending,Q.pending!==Q.pending_buf_size));)pe(Q,255&Q.gzhead.extra[Q.gzindex]),Q.gzindex++;Q.gzhead.hcrc&&Q.pending>ne&&(z.adler=u(z.adler,Q.pending_buf,Q.pending-ne,ne)),Q.gzindex===Q.gzhead.extra.length&&(Q.gzindex=0,Q.status=73)}else Q.status=73;if(Q.status===73)if(Q.gzhead.name){ne=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>ne&&(z.adler=u(z.adler,Q.pending_buf,Q.pending-ne,ne)),Z(z),ne=Q.pending,Q.pending===Q.pending_buf_size)){ie=1;break}ie=Q.gzindex<Q.gzhead.name.length?255&Q.gzhead.name.charCodeAt(Q.gzindex++):0,pe(Q,ie)}while(ie!==0);Q.gzhead.hcrc&&Q.pending>ne&&(z.adler=u(z.adler,Q.pending_buf,Q.pending-ne,ne)),ie===0&&(Q.gzindex=0,Q.status=91)}else Q.status=91;if(Q.status===91)if(Q.gzhead.comment){ne=Q.pending;do{if(Q.pending===Q.pending_buf_size&&(Q.gzhead.hcrc&&Q.pending>ne&&(z.adler=u(z.adler,Q.pending_buf,Q.pending-ne,ne)),Z(z),ne=Q.pending,Q.pending===Q.pending_buf_size)){ie=1;break}ie=Q.gzindex<Q.gzhead.comment.length?255&Q.gzhead.comment.charCodeAt(Q.gzindex++):0,pe(Q,ie)}while(ie!==0);Q.gzhead.hcrc&&Q.pending>ne&&(z.adler=u(z.adler,Q.pending_buf,Q.pending-ne,ne)),ie===0&&(Q.status=103)}else Q.status=103;if(Q.status===103&&(Q.gzhead.hcrc?(Q.pending+2>Q.pending_buf_size&&Z(z),Q.pending+2<=Q.pending_buf_size&&(pe(Q,255&z.adler),pe(Q,z.adler>>8&255),z.adler=0,Q.status=W)):Q.status=W),Q.pending!==0){if(Z(z),z.avail_out===0)return Q.last_flush=-1,p}else if(z.avail_in===0&&ce(V)<=ce(te)&&V!==f)return se(z,-5);if(Q.status===666&&z.avail_in!==0)return se(z,-5);if(z.avail_in!==0||Q.lookahead!==0||V!==h&&Q.status!==666){var fe=Q.strategy===2?(function(oe,I){for(var F;;){if(oe.lookahead===0&&($(oe),oe.lookahead===0)){if(I===h)return L;break}if(oe.match_length=0,F=l._tr_tally(oe,0,oe.window[oe.strstart]),oe.lookahead--,oe.strstart++,F&&(ue(oe,!1),oe.strm.avail_out===0))return L}return oe.insert=0,I===f?(ue(oe,!0),oe.strm.avail_out===0?ae:Y):oe.last_lit&&(ue(oe,!1),oe.strm.avail_out===0)?L:ee})(Q,V):Q.strategy===3?(function(oe,I){for(var F,J,xe,he,le=oe.window;;){if(oe.lookahead<=D){if($(oe),oe.lookahead<=D&&I===h)return L;if(oe.lookahead===0)break}if(oe.match_length=0,oe.lookahead>=M&&0<oe.strstart&&(J=le[xe=oe.strstart-1])===le[++xe]&&J===le[++xe]&&J===le[++xe]){he=oe.strstart+D;do;while(J===le[++xe]&&J===le[++xe]&&J===le[++xe]&&J===le[++xe]&&J===le[++xe]&&J===le[++xe]&&J===le[++xe]&&J===le[++xe]&&xe<he);oe.match_length=D-(he-xe),oe.match_length>oe.lookahead&&(oe.match_length=oe.lookahead)}if(oe.match_length>=M?(F=l._tr_tally(oe,1,oe.match_length-M),oe.lookahead-=oe.match_length,oe.strstart+=oe.match_length,oe.match_length=0):(F=l._tr_tally(oe,0,oe.window[oe.strstart]),oe.lookahead--,oe.strstart++),F&&(ue(oe,!1),oe.strm.avail_out===0))return L}return oe.insert=0,I===f?(ue(oe,!0),oe.strm.avail_out===0?ae:Y):oe.last_lit&&(ue(oe,!1),oe.strm.avail_out===0)?L:ee})(Q,V):s[Q.level].func(Q,V);if(fe!==ae&&fe!==Y||(Q.status=666),fe===L||fe===ae)return z.avail_out===0&&(Q.last_flush=-1),p;if(fe===ee&&(V===1?l._tr_align(Q):V!==5&&(l._tr_stored_block(Q,0,0,!1),V===3&&(ye(Q.head),Q.lookahead===0&&(Q.strstart=0,Q.block_start=0,Q.insert=0))),Z(z),z.avail_out===0))return Q.last_flush=-1,p}return V!==f?p:Q.wrap<=0?1:(Q.wrap===2?(pe(Q,255&z.adler),pe(Q,z.adler>>8&255),pe(Q,z.adler>>16&255),pe(Q,z.adler>>24&255),pe(Q,255&z.total_in),pe(Q,z.total_in>>8&255),pe(Q,z.total_in>>16&255),pe(Q,z.total_in>>24&255)):(be(Q,z.adler>>>16),be(Q,65535&z.adler)),Z(z),0<Q.wrap&&(Q.wrap=-Q.wrap),Q.pending!==0?p:1)},i.deflateEnd=function(z){var V;return z&&z.state?(V=z.state.status)!==U&&V!==69&&V!==73&&V!==91&&V!==103&&V!==W&&V!==666?se(z,x):(z.state=null,V===W?se(z,-3):p):x},i.deflateSetDictionary=function(z,V){var te,Q,ne,ie,me,fe,oe,I,F=V.length;if(!z||!z.state||(ie=(te=z.state).wrap)===2||ie===1&&te.status!==U||te.lookahead)return x;for(ie===1&&(z.adler=c(z.adler,V,F,0)),te.wrap=0,F>=te.w_size&&(ie===0&&(ye(te.head),te.strstart=0,te.block_start=0,te.insert=0),I=new o.Buf8(te.w_size),o.arraySet(I,V,F-te.w_size,te.w_size,0),V=I,F=te.w_size),me=z.avail_in,fe=z.next_in,oe=z.input,z.avail_in=F,z.next_in=0,z.input=V,$(te);te.lookahead>=M;){for(Q=te.strstart,ne=te.lookahead-(M-1);te.ins_h=(te.ins_h<<te.hash_shift^te.window[Q+M-1])&te.hash_mask,te.prev[Q&te.w_mask]=te.head[te.ins_h],te.head[te.ins_h]=Q,Q++,--ne;);te.strstart=Q,te.lookahead=M-1,$(te)}return te.strstart+=te.lookahead,te.block_start=te.strstart,te.insert=te.lookahead,te.lookahead=0,te.match_length=te.prev_length=M-1,te.match_available=0,z.next_in=fe,z.input=oe,z.avail_in=me,te.wrap=ie,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(s,o){var l,c,u,d,h,f,p,x,v,g,y,_,N,A,C,j,k,R,M,D,G,U,W,L,ee;l=s.state,c=s.next_in,L=s.input,u=c+(s.avail_in-5),d=s.next_out,ee=s.output,h=d-(o-s.avail_out),f=d+(s.avail_out-257),p=l.dmax,x=l.wsize,v=l.whave,g=l.wnext,y=l.window,_=l.hold,N=l.bits,A=l.lencode,C=l.distcode,j=(1<<l.lenbits)-1,k=(1<<l.distbits)-1;e:do{N<15&&(_+=L[c++]<<N,N+=8,_+=L[c++]<<N,N+=8),R=A[_&j];t:for(;;){if(_>>>=M=R>>>24,N-=M,(M=R>>>16&255)===0)ee[d++]=65535&R;else{if(!(16&M)){if((64&M)==0){R=A[(65535&R)+(_&(1<<M)-1)];continue t}if(32&M){l.mode=12;break e}s.msg="invalid literal/length code",l.mode=30;break e}D=65535&R,(M&=15)&&(N<M&&(_+=L[c++]<<N,N+=8),D+=_&(1<<M)-1,_>>>=M,N-=M),N<15&&(_+=L[c++]<<N,N+=8,_+=L[c++]<<N,N+=8),R=C[_&k];n:for(;;){if(_>>>=M=R>>>24,N-=M,!(16&(M=R>>>16&255))){if((64&M)==0){R=C[(65535&R)+(_&(1<<M)-1)];continue n}s.msg="invalid distance code",l.mode=30;break e}if(G=65535&R,N<(M&=15)&&(_+=L[c++]<<N,(N+=8)<M&&(_+=L[c++]<<N,N+=8)),p<(G+=_&(1<<M)-1)){s.msg="invalid distance too far back",l.mode=30;break e}if(_>>>=M,N-=M,(M=d-h)<G){if(v<(M=G-M)&&l.sane){s.msg="invalid distance too far back",l.mode=30;break e}if(W=y,(U=0)===g){if(U+=x-M,M<D){for(D-=M;ee[d++]=y[U++],--M;);U=d-G,W=ee}}else if(g<M){if(U+=x+g-M,(M-=g)<D){for(D-=M;ee[d++]=y[U++],--M;);if(U=0,g<D){for(D-=M=g;ee[d++]=y[U++],--M;);U=d-G,W=ee}}}else if(U+=g-M,M<D){for(D-=M;ee[d++]=y[U++],--M;);U=d-G,W=ee}for(;2<D;)ee[d++]=W[U++],ee[d++]=W[U++],ee[d++]=W[U++],D-=3;D&&(ee[d++]=W[U++],1<D&&(ee[d++]=W[U++]))}else{for(U=d-G;ee[d++]=ee[U++],ee[d++]=ee[U++],ee[d++]=ee[U++],2<(D-=3););D&&(ee[d++]=ee[U++],1<D&&(ee[d++]=ee[U++]))}break}}break}}while(c<u&&d<f);c-=D=N>>3,_&=(1<<(N-=D<<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<f?f-d+257:257-(d-f),l.hold=_,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,f=0,p=-2,x=1,v=852,g=592;function y(U){return(U>>>24&255)+(U>>>8&65280)+((65280&U)<<8)+((255&U)<<24)}function _(){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(U){var W;return U&&U.state?(W=U.state,U.total_in=U.total_out=W.total=0,U.msg="",W.wrap&&(U.adler=1&W.wrap),W.mode=x,W.last=0,W.havedict=0,W.dmax=32768,W.head=null,W.hold=0,W.bits=0,W.lencode=W.lendyn=new s.Buf32(v),W.distcode=W.distdyn=new s.Buf32(g),W.sane=1,W.back=-1,f):p}function A(U){var W;return U&&U.state?((W=U.state).wsize=0,W.whave=0,W.wnext=0,N(U)):p}function C(U,W){var L,ee;return U&&U.state?(ee=U.state,W<0?(L=0,W=-W):(L=1+(W>>4),W<48&&(W&=15)),W&&(W<8||15<W)?p:(ee.window!==null&&ee.wbits!==W&&(ee.window=null),ee.wrap=L,ee.wbits=W,A(U))):p}function j(U,W){var L,ee;return U?(ee=new _,(U.state=ee).window=null,(L=C(U,W))!==f&&(U.state=null),L):p}var k,R,M=!0;function D(U){if(M){var W;for(k=new s.Buf32(512),R=new s.Buf32(32),W=0;W<144;)U.lens[W++]=8;for(;W<256;)U.lens[W++]=9;for(;W<280;)U.lens[W++]=7;for(;W<288;)U.lens[W++]=8;for(u(d,U.lens,0,288,k,0,U.work,{bits:9}),W=0;W<32;)U.lens[W++]=5;u(h,U.lens,0,32,R,0,U.work,{bits:5}),M=!1}U.lencode=k,U.lenbits=9,U.distcode=R,U.distbits=5}function G(U,W,L,ee){var ae,Y=U.state;return Y.window===null&&(Y.wsize=1<<Y.wbits,Y.wnext=0,Y.whave=0,Y.window=new s.Buf8(Y.wsize)),ee>=Y.wsize?(s.arraySet(Y.window,W,L-Y.wsize,Y.wsize,0),Y.wnext=0,Y.whave=Y.wsize):(ee<(ae=Y.wsize-Y.wnext)&&(ae=ee),s.arraySet(Y.window,W,L-ee,ae,Y.wnext),(ee-=ae)?(s.arraySet(Y.window,W,L-ee,ee,0),Y.wnext=ee,Y.whave=Y.wsize):(Y.wnext+=ae,Y.wnext===Y.wsize&&(Y.wnext=0),Y.whave<Y.wsize&&(Y.whave+=ae))),0}i.inflateReset=A,i.inflateReset2=C,i.inflateResetKeep=N,i.inflateInit=function(U){return j(U,15)},i.inflateInit2=j,i.inflate=function(U,W){var L,ee,ae,Y,se,ce,ye,Z,ue,pe,be,Ee,$,K,T,E,O,q,B,re,z,V,te,Q,ne=0,ie=new s.Buf8(4),me=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!U||!U.state||!U.output||!U.input&&U.avail_in!==0)return p;(L=U.state).mode===12&&(L.mode=13),se=U.next_out,ae=U.output,ye=U.avail_out,Y=U.next_in,ee=U.input,ce=U.avail_in,Z=L.hold,ue=L.bits,pe=ce,be=ye,V=f;e:for(;;)switch(L.mode){case x:if(L.wrap===0){L.mode=13;break}for(;ue<16;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if(2&L.wrap&&Z===35615){ie[L.check=0]=255&Z,ie[1]=Z>>>8&255,L.check=l(L.check,ie,2,0),ue=Z=0,L.mode=2;break}if(L.flags=0,L.head&&(L.head.done=!1),!(1&L.wrap)||(((255&Z)<<8)+(Z>>8))%31){U.msg="incorrect header check",L.mode=30;break}if((15&Z)!=8){U.msg="unknown compression method",L.mode=30;break}if(ue-=4,z=8+(15&(Z>>>=4)),L.wbits===0)L.wbits=z;else if(z>L.wbits){U.msg="invalid window size",L.mode=30;break}L.dmax=1<<z,U.adler=L.check=1,L.mode=512&Z?10:12,ue=Z=0;break;case 2:for(;ue<16;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if(L.flags=Z,(255&L.flags)!=8){U.msg="unknown compression method",L.mode=30;break}if(57344&L.flags){U.msg="unknown header flags set",L.mode=30;break}L.head&&(L.head.text=Z>>8&1),512&L.flags&&(ie[0]=255&Z,ie[1]=Z>>>8&255,L.check=l(L.check,ie,2,0)),ue=Z=0,L.mode=3;case 3:for(;ue<32;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}L.head&&(L.head.time=Z),512&L.flags&&(ie[0]=255&Z,ie[1]=Z>>>8&255,ie[2]=Z>>>16&255,ie[3]=Z>>>24&255,L.check=l(L.check,ie,4,0)),ue=Z=0,L.mode=4;case 4:for(;ue<16;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}L.head&&(L.head.xflags=255&Z,L.head.os=Z>>8),512&L.flags&&(ie[0]=255&Z,ie[1]=Z>>>8&255,L.check=l(L.check,ie,2,0)),ue=Z=0,L.mode=5;case 5:if(1024&L.flags){for(;ue<16;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}L.length=Z,L.head&&(L.head.extra_len=Z),512&L.flags&&(ie[0]=255&Z,ie[1]=Z>>>8&255,L.check=l(L.check,ie,2,0)),ue=Z=0}else L.head&&(L.head.extra=null);L.mode=6;case 6:if(1024&L.flags&&(ce<(Ee=L.length)&&(Ee=ce),Ee&&(L.head&&(z=L.head.extra_len-L.length,L.head.extra||(L.head.extra=new Array(L.head.extra_len)),s.arraySet(L.head.extra,ee,Y,Ee,z)),512&L.flags&&(L.check=l(L.check,ee,Ee,Y)),ce-=Ee,Y+=Ee,L.length-=Ee),L.length))break e;L.length=0,L.mode=7;case 7:if(2048&L.flags){if(ce===0)break e;for(Ee=0;z=ee[Y+Ee++],L.head&&z&&L.length<65536&&(L.head.name+=String.fromCharCode(z)),z&&Ee<ce;);if(512&L.flags&&(L.check=l(L.check,ee,Ee,Y)),ce-=Ee,Y+=Ee,z)break e}else L.head&&(L.head.name=null);L.length=0,L.mode=8;case 8:if(4096&L.flags){if(ce===0)break e;for(Ee=0;z=ee[Y+Ee++],L.head&&z&&L.length<65536&&(L.head.comment+=String.fromCharCode(z)),z&&Ee<ce;);if(512&L.flags&&(L.check=l(L.check,ee,Ee,Y)),ce-=Ee,Y+=Ee,z)break e}else L.head&&(L.head.comment=null);L.mode=9;case 9:if(512&L.flags){for(;ue<16;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if(Z!==(65535&L.check)){U.msg="header crc mismatch",L.mode=30;break}ue=Z=0}L.head&&(L.head.hcrc=L.flags>>9&1,L.head.done=!0),U.adler=L.check=0,L.mode=12;break;case 10:for(;ue<32;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}U.adler=L.check=y(Z),ue=Z=0,L.mode=11;case 11:if(L.havedict===0)return U.next_out=se,U.avail_out=ye,U.next_in=Y,U.avail_in=ce,L.hold=Z,L.bits=ue,2;U.adler=L.check=1,L.mode=12;case 12:if(W===5||W===6)break e;case 13:if(L.last){Z>>>=7&ue,ue-=7&ue,L.mode=27;break}for(;ue<3;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}switch(L.last=1&Z,ue-=1,3&(Z>>>=1)){case 0:L.mode=14;break;case 1:if(D(L),L.mode=20,W!==6)break;Z>>>=2,ue-=2;break e;case 2:L.mode=17;break;case 3:U.msg="invalid block type",L.mode=30}Z>>>=2,ue-=2;break;case 14:for(Z>>>=7&ue,ue-=7&ue;ue<32;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if((65535&Z)!=(Z>>>16^65535)){U.msg="invalid stored block lengths",L.mode=30;break}if(L.length=65535&Z,ue=Z=0,L.mode=15,W===6)break e;case 15:L.mode=16;case 16:if(Ee=L.length){if(ce<Ee&&(Ee=ce),ye<Ee&&(Ee=ye),Ee===0)break e;s.arraySet(ae,ee,Y,Ee,se),ce-=Ee,Y+=Ee,ye-=Ee,se+=Ee,L.length-=Ee;break}L.mode=12;break;case 17:for(;ue<14;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if(L.nlen=257+(31&Z),Z>>>=5,ue-=5,L.ndist=1+(31&Z),Z>>>=5,ue-=5,L.ncode=4+(15&Z),Z>>>=4,ue-=4,286<L.nlen||30<L.ndist){U.msg="too many length or distance symbols",L.mode=30;break}L.have=0,L.mode=18;case 18:for(;L.have<L.ncode;){for(;ue<3;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}L.lens[me[L.have++]]=7&Z,Z>>>=3,ue-=3}for(;L.have<19;)L.lens[me[L.have++]]=0;if(L.lencode=L.lendyn,L.lenbits=7,te={bits:L.lenbits},V=u(0,L.lens,0,19,L.lencode,0,L.work,te),L.lenbits=te.bits,V){U.msg="invalid code lengths set",L.mode=30;break}L.have=0,L.mode=19;case 19:for(;L.have<L.nlen+L.ndist;){for(;E=(ne=L.lencode[Z&(1<<L.lenbits)-1])>>>16&255,O=65535&ne,!((T=ne>>>24)<=ue);){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if(O<16)Z>>>=T,ue-=T,L.lens[L.have++]=O;else{if(O===16){for(Q=T+2;ue<Q;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if(Z>>>=T,ue-=T,L.have===0){U.msg="invalid bit length repeat",L.mode=30;break}z=L.lens[L.have-1],Ee=3+(3&Z),Z>>>=2,ue-=2}else if(O===17){for(Q=T+3;ue<Q;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}ue-=T,z=0,Ee=3+(7&(Z>>>=T)),Z>>>=3,ue-=3}else{for(Q=T+7;ue<Q;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}ue-=T,z=0,Ee=11+(127&(Z>>>=T)),Z>>>=7,ue-=7}if(L.have+Ee>L.nlen+L.ndist){U.msg="invalid bit length repeat",L.mode=30;break}for(;Ee--;)L.lens[L.have++]=z}}if(L.mode===30)break;if(L.lens[256]===0){U.msg="invalid code -- missing end-of-block",L.mode=30;break}if(L.lenbits=9,te={bits:L.lenbits},V=u(d,L.lens,0,L.nlen,L.lencode,0,L.work,te),L.lenbits=te.bits,V){U.msg="invalid literal/lengths set",L.mode=30;break}if(L.distbits=6,L.distcode=L.distdyn,te={bits:L.distbits},V=u(h,L.lens,L.nlen,L.ndist,L.distcode,0,L.work,te),L.distbits=te.bits,V){U.msg="invalid distances set",L.mode=30;break}if(L.mode=20,W===6)break e;case 20:L.mode=21;case 21:if(6<=ce&&258<=ye){U.next_out=se,U.avail_out=ye,U.next_in=Y,U.avail_in=ce,L.hold=Z,L.bits=ue,c(U,be),se=U.next_out,ae=U.output,ye=U.avail_out,Y=U.next_in,ee=U.input,ce=U.avail_in,Z=L.hold,ue=L.bits,L.mode===12&&(L.back=-1);break}for(L.back=0;E=(ne=L.lencode[Z&(1<<L.lenbits)-1])>>>16&255,O=65535&ne,!((T=ne>>>24)<=ue);){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if(E&&(240&E)==0){for(q=T,B=E,re=O;E=(ne=L.lencode[re+((Z&(1<<q+B)-1)>>q)])>>>16&255,O=65535&ne,!(q+(T=ne>>>24)<=ue);){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}Z>>>=q,ue-=q,L.back+=q}if(Z>>>=T,ue-=T,L.back+=T,L.length=O,E===0){L.mode=26;break}if(32&E){L.back=-1,L.mode=12;break}if(64&E){U.msg="invalid literal/length code",L.mode=30;break}L.extra=15&E,L.mode=22;case 22:if(L.extra){for(Q=L.extra;ue<Q;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}L.length+=Z&(1<<L.extra)-1,Z>>>=L.extra,ue-=L.extra,L.back+=L.extra}L.was=L.length,L.mode=23;case 23:for(;E=(ne=L.distcode[Z&(1<<L.distbits)-1])>>>16&255,O=65535&ne,!((T=ne>>>24)<=ue);){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if((240&E)==0){for(q=T,B=E,re=O;E=(ne=L.distcode[re+((Z&(1<<q+B)-1)>>q)])>>>16&255,O=65535&ne,!(q+(T=ne>>>24)<=ue);){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}Z>>>=q,ue-=q,L.back+=q}if(Z>>>=T,ue-=T,L.back+=T,64&E){U.msg="invalid distance code",L.mode=30;break}L.offset=O,L.extra=15&E,L.mode=24;case 24:if(L.extra){for(Q=L.extra;ue<Q;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}L.offset+=Z&(1<<L.extra)-1,Z>>>=L.extra,ue-=L.extra,L.back+=L.extra}if(L.offset>L.dmax){U.msg="invalid distance too far back",L.mode=30;break}L.mode=25;case 25:if(ye===0)break e;if(Ee=be-ye,L.offset>Ee){if((Ee=L.offset-Ee)>L.whave&&L.sane){U.msg="invalid distance too far back",L.mode=30;break}$=Ee>L.wnext?(Ee-=L.wnext,L.wsize-Ee):L.wnext-Ee,Ee>L.length&&(Ee=L.length),K=L.window}else K=ae,$=se-L.offset,Ee=L.length;for(ye<Ee&&(Ee=ye),ye-=Ee,L.length-=Ee;ae[se++]=K[$++],--Ee;);L.length===0&&(L.mode=21);break;case 26:if(ye===0)break e;ae[se++]=L.length,ye--,L.mode=21;break;case 27:if(L.wrap){for(;ue<32;){if(ce===0)break e;ce--,Z|=ee[Y++]<<ue,ue+=8}if(be-=ye,U.total_out+=be,L.total+=be,be&&(U.adler=L.check=L.flags?l(L.check,ae,be,se-be):o(L.check,ae,be,se-be)),be=ye,(L.flags?Z:y(Z))!==L.check){U.msg="incorrect data check",L.mode=30;break}ue=Z=0}L.mode=28;case 28:if(L.wrap&&L.flags){for(;ue<32;){if(ce===0)break e;ce--,Z+=ee[Y++]<<ue,ue+=8}if(Z!==(4294967295&L.total)){U.msg="incorrect length check",L.mode=30;break}ue=Z=0}L.mode=29;case 29:V=1;break e;case 30:V=-3;break e;case 31:return-4;default:return p}return U.next_out=se,U.avail_out=ye,U.next_in=Y,U.avail_in=ce,L.hold=Z,L.bits=ue,(L.wsize||be!==U.avail_out&&L.mode<30&&(L.mode<27||W!==4))&&G(U,U.output,U.next_out,be-U.avail_out)?(L.mode=31,-4):(pe-=U.avail_in,be-=U.avail_out,U.total_in+=pe,U.total_out+=be,L.total+=be,L.wrap&&be&&(U.adler=L.check=L.flags?l(L.check,ae,be,U.next_out-be):o(L.check,ae,be,U.next_out-be)),U.data_type=L.bits+(L.last?64:0)+(L.mode===12?128:0)+(L.mode===20||L.mode===15?256:0),(pe==0&&be===0||W===4)&&V===f&&(V=-5),V)},i.inflateEnd=function(U){if(!U||!U.state)return p;var W=U.state;return W.window&&(W.window=null),U.state=null,f},i.inflateGetHeader=function(U,W){var L;return U&&U.state?(2&(L=U.state).wrap)==0?p:((L.head=W).done=!1,f):p},i.inflateSetDictionary=function(U,W){var L,ee=W.length;return U&&U.state?(L=U.state).wrap!==0&&L.mode!==11?p:L.mode===11&&o(1,W,ee,0)!==L.check?-3:G(U,W,ee,ee)?(L.mode=31,-4):(L.havedict=1,f):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var s=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,h,f,p,x,v,g,y){var _,N,A,C,j,k,R,M,D,G=y.bits,U=0,W=0,L=0,ee=0,ae=0,Y=0,se=0,ce=0,ye=0,Z=0,ue=null,pe=0,be=new s.Buf16(16),Ee=new s.Buf16(16),$=null,K=0;for(U=0;U<=15;U++)be[U]=0;for(W=0;W<p;W++)be[h[f+W]]++;for(ae=G,ee=15;1<=ee&&be[ee]===0;ee--);if(ee<ae&&(ae=ee),ee===0)return x[v++]=20971520,x[v++]=20971520,y.bits=1,0;for(L=1;L<ee&&be[L]===0;L++);for(ae<L&&(ae=L),U=ce=1;U<=15;U++)if(ce<<=1,(ce-=be[U])<0)return-1;if(0<ce&&(d===0||ee!==1))return-1;for(Ee[1]=0,U=1;U<15;U++)Ee[U+1]=Ee[U]+be[U];for(W=0;W<p;W++)h[f+W]!==0&&(g[Ee[h[f+W]]++]=W);if(k=d===0?(ue=$=g,19):d===1?(ue=o,pe-=257,$=l,K-=257,256):(ue=c,$=u,-1),U=L,j=v,se=W=Z=0,A=-1,C=(ye=1<<(Y=ae))-1,d===1&&852<ye||d===2&&592<ye)return 1;for(;;){for(R=U-se,D=g[W]<k?(M=0,g[W]):g[W]>k?(M=$[K+g[W]],ue[pe+g[W]]):(M=96,0),_=1<<U-se,L=N=1<<Y;x[j+(Z>>se)+(N-=_)]=R<<24|M<<16|D|0,N!==0;);for(_=1<<U-1;Z&_;)_>>=1;if(_!==0?(Z&=_-1,Z+=_):Z=0,W++,--be[U]==0){if(U===ee)break;U=h[f+g[W]]}if(ae<U&&(Z&C)!==A){for(se===0&&(se=ae),j+=L,ce=1<<(Y=U-se);Y+se<ee&&!((ce-=be[Y+se])<=0);)Y++,ce<<=1;if(ye+=1<<Y,d===1&&852<ye||d===2&&592<ye)return 1;x[A=Z&C]=ae<<24|Y<<16|j-v|0}}return Z!==0&&(x[j+Z]=U-se<<24|64<<16|0),y.bits=ae,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(ne){for(var ie=ne.length;0<=--ie;)ne[ie]=0}var u=0,d=29,h=256,f=h+1+d,p=30,x=19,v=2*f+1,g=15,y=16,_=7,N=256,A=16,C=17,j=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],M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],G=new Array(2*(f+2));c(G);var U=new Array(2*p);c(U);var W=new Array(512);c(W);var L=new Array(256);c(L);var ee=new Array(d);c(ee);var ae,Y,se,ce=new Array(p);function ye(ne,ie,me,fe,oe){this.static_tree=ne,this.extra_bits=ie,this.extra_base=me,this.elems=fe,this.max_length=oe,this.has_stree=ne&&ne.length}function Z(ne,ie){this.dyn_tree=ne,this.max_code=0,this.stat_desc=ie}function ue(ne){return ne<256?W[ne]:W[256+(ne>>>7)]}function pe(ne,ie){ne.pending_buf[ne.pending++]=255&ie,ne.pending_buf[ne.pending++]=ie>>>8&255}function be(ne,ie,me){ne.bi_valid>y-me?(ne.bi_buf|=ie<<ne.bi_valid&65535,pe(ne,ne.bi_buf),ne.bi_buf=ie>>y-ne.bi_valid,ne.bi_valid+=me-y):(ne.bi_buf|=ie<<ne.bi_valid&65535,ne.bi_valid+=me)}function Ee(ne,ie,me){be(ne,me[2*ie],me[2*ie+1])}function $(ne,ie){for(var me=0;me|=1&ne,ne>>>=1,me<<=1,0<--ie;);return me>>>1}function K(ne,ie,me){var fe,oe,I=new Array(g+1),F=0;for(fe=1;fe<=g;fe++)I[fe]=F=F+me[fe-1]<<1;for(oe=0;oe<=ie;oe++){var J=ne[2*oe+1];J!==0&&(ne[2*oe]=$(I[J]++,J))}}function T(ne){var ie;for(ie=0;ie<f;ie++)ne.dyn_ltree[2*ie]=0;for(ie=0;ie<p;ie++)ne.dyn_dtree[2*ie]=0;for(ie=0;ie<x;ie++)ne.bl_tree[2*ie]=0;ne.dyn_ltree[2*N]=1,ne.opt_len=ne.static_len=0,ne.last_lit=ne.matches=0}function E(ne){8<ne.bi_valid?pe(ne,ne.bi_buf):0<ne.bi_valid&&(ne.pending_buf[ne.pending++]=ne.bi_buf),ne.bi_buf=0,ne.bi_valid=0}function O(ne,ie,me,fe){var oe=2*ie,I=2*me;return ne[oe]<ne[I]||ne[oe]===ne[I]&&fe[ie]<=fe[me]}function q(ne,ie,me){for(var fe=ne.heap[me],oe=me<<1;oe<=ne.heap_len&&(oe<ne.heap_len&&O(ie,ne.heap[oe+1],ne.heap[oe],ne.depth)&&oe++,!O(ie,fe,ne.heap[oe],ne.depth));)ne.heap[me]=ne.heap[oe],me=oe,oe<<=1;ne.heap[me]=fe}function B(ne,ie,me){var fe,oe,I,F,J=0;if(ne.last_lit!==0)for(;fe=ne.pending_buf[ne.d_buf+2*J]<<8|ne.pending_buf[ne.d_buf+2*J+1],oe=ne.pending_buf[ne.l_buf+J],J++,fe===0?Ee(ne,oe,ie):(Ee(ne,(I=L[oe])+h+1,ie),(F=k[I])!==0&&be(ne,oe-=ee[I],F),Ee(ne,I=ue(--fe),me),(F=R[I])!==0&&be(ne,fe-=ce[I],F)),J<ne.last_lit;);Ee(ne,N,ie)}function re(ne,ie){var me,fe,oe,I=ie.dyn_tree,F=ie.stat_desc.static_tree,J=ie.stat_desc.has_stree,xe=ie.stat_desc.elems,he=-1;for(ne.heap_len=0,ne.heap_max=v,me=0;me<xe;me++)I[2*me]!==0?(ne.heap[++ne.heap_len]=he=me,ne.depth[me]=0):I[2*me+1]=0;for(;ne.heap_len<2;)I[2*(oe=ne.heap[++ne.heap_len]=he<2?++he:0)]=1,ne.depth[oe]=0,ne.opt_len--,J&&(ne.static_len-=F[2*oe+1]);for(ie.max_code=he,me=ne.heap_len>>1;1<=me;me--)q(ne,I,me);for(oe=xe;me=ne.heap[1],ne.heap[1]=ne.heap[ne.heap_len--],q(ne,I,1),fe=ne.heap[1],ne.heap[--ne.heap_max]=me,ne.heap[--ne.heap_max]=fe,I[2*oe]=I[2*me]+I[2*fe],ne.depth[oe]=(ne.depth[me]>=ne.depth[fe]?ne.depth[me]:ne.depth[fe])+1,I[2*me+1]=I[2*fe+1]=oe,ne.heap[1]=oe++,q(ne,I,1),2<=ne.heap_len;);ne.heap[--ne.heap_max]=ne.heap[1],(function(le,Ce){var Ne,Ue,He,de,we,ke,_e=Ce.dyn_tree,Ae=Ce.max_code,Ve=Ce.stat_desc.static_tree,Te=Ce.stat_desc.has_stree,Ke=Ce.stat_desc.extra_bits,je=Ce.stat_desc.extra_base,qe=Ce.stat_desc.max_length,Re=0;for(de=0;de<=g;de++)le.bl_count[de]=0;for(_e[2*le.heap[le.heap_max]+1]=0,Ne=le.heap_max+1;Ne<v;Ne++)qe<(de=_e[2*_e[2*(Ue=le.heap[Ne])+1]+1]+1)&&(de=qe,Re++),_e[2*Ue+1]=de,Ae<Ue||(le.bl_count[de]++,we=0,je<=Ue&&(we=Ke[Ue-je]),ke=_e[2*Ue],le.opt_len+=ke*(de+we),Te&&(le.static_len+=ke*(Ve[2*Ue+1]+we)));if(Re!==0){do{for(de=qe-1;le.bl_count[de]===0;)de--;le.bl_count[de]--,le.bl_count[de+1]+=2,le.bl_count[qe]--,Re-=2}while(0<Re);for(de=qe;de!==0;de--)for(Ue=le.bl_count[de];Ue!==0;)Ae<(He=le.heap[--Ne])||(_e[2*He+1]!==de&&(le.opt_len+=(de-_e[2*He+1])*_e[2*He],_e[2*He+1]=de),Ue--)}})(ne,ie),K(I,he,ne.bl_count)}function z(ne,ie,me){var fe,oe,I=-1,F=ie[1],J=0,xe=7,he=4;for(F===0&&(xe=138,he=3),ie[2*(me+1)+1]=65535,fe=0;fe<=me;fe++)oe=F,F=ie[2*(fe+1)+1],++J<xe&&oe===F||(J<he?ne.bl_tree[2*oe]+=J:oe!==0?(oe!==I&&ne.bl_tree[2*oe]++,ne.bl_tree[2*A]++):J<=10?ne.bl_tree[2*C]++:ne.bl_tree[2*j]++,I=oe,he=(J=0)===F?(xe=138,3):oe===F?(xe=6,3):(xe=7,4))}function V(ne,ie,me){var fe,oe,I=-1,F=ie[1],J=0,xe=7,he=4;for(F===0&&(xe=138,he=3),fe=0;fe<=me;fe++)if(oe=F,F=ie[2*(fe+1)+1],!(++J<xe&&oe===F)){if(J<he)for(;Ee(ne,oe,ne.bl_tree),--J!=0;);else oe!==0?(oe!==I&&(Ee(ne,oe,ne.bl_tree),J--),Ee(ne,A,ne.bl_tree),be(ne,J-3,2)):J<=10?(Ee(ne,C,ne.bl_tree),be(ne,J-3,3)):(Ee(ne,j,ne.bl_tree),be(ne,J-11,7));I=oe,he=(J=0)===F?(xe=138,3):oe===F?(xe=6,3):(xe=7,4)}}c(ce);var te=!1;function Q(ne,ie,me,fe){be(ne,(u<<1)+(fe?1:0),3),(function(oe,I,F,J){E(oe),pe(oe,F),pe(oe,~F),s.arraySet(oe.pending_buf,oe.window,I,F,oe.pending),oe.pending+=F})(ne,ie,me)}i._tr_init=function(ne){te||((function(){var ie,me,fe,oe,I,F=new Array(g+1);for(oe=fe=0;oe<d-1;oe++)for(ee[oe]=fe,ie=0;ie<1<<k[oe];ie++)L[fe++]=oe;for(L[fe-1]=oe,oe=I=0;oe<16;oe++)for(ce[oe]=I,ie=0;ie<1<<R[oe];ie++)W[I++]=oe;for(I>>=7;oe<p;oe++)for(ce[oe]=I<<7,ie=0;ie<1<<R[oe]-7;ie++)W[256+I++]=oe;for(me=0;me<=g;me++)F[me]=0;for(ie=0;ie<=143;)G[2*ie+1]=8,ie++,F[8]++;for(;ie<=255;)G[2*ie+1]=9,ie++,F[9]++;for(;ie<=279;)G[2*ie+1]=7,ie++,F[7]++;for(;ie<=287;)G[2*ie+1]=8,ie++,F[8]++;for(K(G,f+1,F),ie=0;ie<p;ie++)U[2*ie+1]=5,U[2*ie]=$(ie,5);ae=new ye(G,k,h+1,f,g),Y=new ye(U,R,0,p,g),se=new ye(new Array(0),M,0,x,_)})(),te=!0),ne.l_desc=new Z(ne.dyn_ltree,ae),ne.d_desc=new Z(ne.dyn_dtree,Y),ne.bl_desc=new Z(ne.bl_tree,se),ne.bi_buf=0,ne.bi_valid=0,T(ne)},i._tr_stored_block=Q,i._tr_flush_block=function(ne,ie,me,fe){var oe,I,F=0;0<ne.level?(ne.strm.data_type===2&&(ne.strm.data_type=(function(J){var xe,he=4093624447;for(xe=0;xe<=31;xe++,he>>>=1)if(1&he&&J.dyn_ltree[2*xe]!==0)return o;if(J.dyn_ltree[18]!==0||J.dyn_ltree[20]!==0||J.dyn_ltree[26]!==0)return l;for(xe=32;xe<h;xe++)if(J.dyn_ltree[2*xe]!==0)return l;return o})(ne)),re(ne,ne.l_desc),re(ne,ne.d_desc),F=(function(J){var xe;for(z(J,J.dyn_ltree,J.l_desc.max_code),z(J,J.dyn_dtree,J.d_desc.max_code),re(J,J.bl_desc),xe=x-1;3<=xe&&J.bl_tree[2*D[xe]+1]===0;xe--);return J.opt_len+=3*(xe+1)+5+5+4,xe})(ne),oe=ne.opt_len+3+7>>>3,(I=ne.static_len+3+7>>>3)<=oe&&(oe=I)):oe=I=me+5,me+4<=oe&&ie!==-1?Q(ne,ie,me,fe):ne.strategy===4||I===oe?(be(ne,2+(fe?1:0),3),B(ne,G,U)):(be(ne,4+(fe?1:0),3),(function(J,xe,he,le){var Ce;for(be(J,xe-257,5),be(J,he-1,5),be(J,le-4,4),Ce=0;Ce<le;Ce++)be(J,J.bl_tree[2*D[Ce]+1],3);V(J,J.dyn_ltree,xe-1),V(J,J.dyn_dtree,he-1)})(ne,ne.l_desc.max_code+1,ne.d_desc.max_code+1,F+1),B(ne,ne.dyn_ltree,ne.dyn_dtree)),T(ne),fe&&E(ne)},i._tr_tally=function(ne,ie,me){return ne.pending_buf[ne.d_buf+2*ne.last_lit]=ie>>>8&255,ne.pending_buf[ne.d_buf+2*ne.last_lit+1]=255&ie,ne.pending_buf[ne.l_buf+ne.last_lit]=255&me,ne.last_lit++,ie===0?ne.dyn_ltree[2*me]++:(ne.matches++,ie--,ne.dyn_ltree[2*(L[me]+h+1)]++,ne.dyn_dtree[2*ue(ie)]++),ne.last_lit===ne.lit_bufsize-1},i._tr_align=function(ne){be(ne,2,3),Ee(ne,N,G),(function(ie){ie.bi_valid===16?(pe(ie,ie.bi_buf),ie.bi_buf=0,ie.bi_valid=0):8<=ie.bi_valid&&(ie.pending_buf[ie.pending++]=255&ie.bi_buf,ie.bi_buf>>=8,ie.bi_valid-=8)})(ne)}},{"../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,f=1,p={},x=!1,v=o.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(o);g=g&&g.setTimeout?g:o,c={}.toString.call(o.process)==="[object process]"?function(A){process.nextTick(function(){_(A)})}:(function(){if(o.postMessage&&!o.importScripts){var A=!0,C=o.onmessage;return o.onmessage=function(){A=!1},o.postMessage("","*"),o.onmessage=C,A}})()?(h="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",N,!1):o.attachEvent("onmessage",N),function(A){o.postMessage(h+A,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){_(A.data)},function(A){d.port2.postMessage(A)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(A){var C=v.createElement("script");C.onreadystatechange=function(){_(A),C.onreadystatechange=null,u.removeChild(C),C=null},u.appendChild(C)}):function(A){setTimeout(_,0,A)},g.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var C=new Array(arguments.length-1),j=0;j<C.length;j++)C[j]=arguments[j+1];var k={callback:A,args:C};return p[f]=k,c(f),f++},g.clearImmediate=y}function y(A){delete p[A]}function _(A){if(x)setTimeout(_,0,A);else{var C=p[A];if(C){x=!0;try{(function(j){var k=j.callback,R=j.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)}})(C)}finally{y(A),x=!1}}}}function N(A){A.source===o&&typeof A.data=="string"&&A.data.indexOf(h)===0&&_(+A.data.slice(h.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof sS<"u"?sS:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(MM)),MM.exports}var BSe=USe();const HSe=Ml(BSe);function $Se(t){const e=new oi;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 d6=$Se;async function h6(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 m6(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 VSe(t){let e;try{e=await HSe.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 A=N.startsWith("/")?N.slice(1):N,C=e.files[A];if(!C)return null;const j=await C.async("string");return o.parseFromString(j,"application/xml")}const c=new Map,u=new Map,d=new Map,h=new Map,f=e.files["Metadata/model_settings.config"];if(f)try{const N=await f.async("string"),A=o.parseFromString(N,"application/xml"),C=A.getElementsByTagName("object");for(let k=0;k<C.length;k++){const R=C[k],M=R.getAttribute("id");if(!M)continue;const D=Array.from(R.children).filter(L=>L.tagName==="metadata"&&L.getAttribute("key")==="extruder");if(D.length>0){const L=D[0].getAttribute("value");L&&c.set(M,Math.max(0,parseInt(L,10)-1))}const U=Array.from(R.children).find(L=>L.tagName==="metadata"&&L.getAttribute("key")==="name")?.getAttribute("value");U&&d.set(M,U);const W=R.getElementsByTagName("part");for(let L=0;L<W.length;L++){const ee=W[L],ae=ee.getAttribute("id");if(!ae)continue;const Y=Array.from(ee.children).filter(se=>se.tagName==="metadata"&&se.getAttribute("key")==="extruder");if(Y.length>0){const se=Y[0].getAttribute("value");se&&u.set(`${M}:${ae}`,Math.max(0,parseInt(se,10)-1))}}}const j=A.getElementsByTagName("plate");for(let k=0;k<j.length;k++){const R=j[k];let M=null;const D=R.getElementsByTagName("metadata");let G=0,U=0;for(let L=0;L<D.length;L++){const ee=D[L],ae=ee.getAttribute("key");if(ae==="plater_id"||ae==="plate_id"){const Y=ee.getAttribute("value");if(Y){const se=Number.parseInt(Y,10);Number.isFinite(se)&&(M=se)}}else if(ae==="pos_x"){const Y=ee.getAttribute("value"),se=Y?Number.parseFloat(Y):Number.NaN;Number.isFinite(se)&&(G=se)}else if(ae==="pos_y"){const Y=ee.getAttribute("value"),se=Y?Number.parseFloat(Y):Number.NaN;Number.isFinite(se)&&(U=se)}}if(M==null)continue;(G!==0||U!==0)&&s.set(M,{offsetX:G,offsetY:U});const W=R.getElementsByTagName("model_instance");for(let L=0;L<W.length;L++){const ae=W[L].getElementsByTagName("metadata");for(let Y=0;Y<ae.length;Y++){const se=ae[Y];if(se.getAttribute("key")==="object_id"){const ce=se.getAttribute("value");ce&&h.set(ce,M)}}}}}catch{}const p=new Map,x=Object.keys(e.files).filter(N=>N.startsWith("Metadata/plate_")&&N.endsWith(".json"));for(const N of x){const A=N.match(/^Metadata\/plate_(\d+)\.json$/);if(!A)continue;const C=Number.parseInt(A[1],10);if(Number.isFinite(C))try{const j=await e.files[N].async("string"),k=JSON.parse(j),R=k.bbox_objects??[];for(const M of R)M?.name&&p.set(M.name,C);if(Array.isArray(k.bbox_all)&&k.bbox_all.length>=4){const[M,D,G,U]=k.bbox_all;[M,D,G,U].every(W=>Number.isFinite(W))&&i.set(C,{minX:M,minY:D,maxX:G,maxY:U})}}catch{}}const v=Object.keys(e.files).find(N=>N==="3D/3dmodel.model"||N.endsWith("/3dmodel.model"));if(!v){const N=Object.keys(e.files).find(A=>A.endsWith(".model"));if(N){const A=await l(N);if(A){const C=await h6(A,0);C.length>0&&n.set("1",{id:"1",meshes:C,defaultExtruder:0})}}return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s}}const g=await l(v);if(!g)return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s};const y=g.getElementsByTagName("object");for(let N=0;N<y.length;N++){const A=y[N],C=A.getAttribute("id");if(!C)continue;const j=m6(A)??h.get(C)??null;let k=c.get(C)??-1;if(k<0){const G=A.getAttribute("p:extruder")||A.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";k=Math.max(0,parseInt(G,10)-1)}const R=[],M=A.getElementsByTagName("mesh");for(let G=0;G<M.length;G++){const U=M[G],W=[],L=[],ee=U.getElementsByTagName("vertex");for(let Y=0;Y<ee.length;Y++){const se=ee[Y];W.push(parseFloat(se.getAttribute("x")||"0"),parseFloat(se.getAttribute("y")||"0"),parseFloat(se.getAttribute("z")||"0"))}const ae=U.getElementsByTagName("triangle");for(let Y=0;Y<ae.length;Y++){const se=ae[Y];L.push(parseInt(se.getAttribute("v1")||"0"),parseInt(se.getAttribute("v2")||"0"),parseInt(se.getAttribute("v3")||"0"))}W.length>0&&L.length>0&&R.push({vertices:W,triangles:L,extruder:k})}const D=A.getElementsByTagName("component");for(let G=0;G<D.length;G++){const U=D[G],W=U.getAttribute("p:path")||U.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),L=U.getAttribute("objectid");if(W){const ee=await l(W);if(ee){const ae=L?`${C}:${L}`:null,Y=ae?u.get(ae)??k:k,se=await h6(ee,Y),ce=U.getAttribute("transform"),ye=d6(ce);for(const Z of se)if(ce){const ue=[];for(let pe=0;pe<Z.vertices.length;pe+=3){const be=new xt(Z.vertices[pe],Z.vertices[pe+1],Z.vertices[pe+2]);be.applyMatrix4(ye),ue.push(be.x,be.y,be.z)}R.push({vertices:ue,triangles:Z.triangles,extruder:Z.extruder})}else R.push(Z)}}}R.length>0&&n.set(C,{id:C,meshes:R,defaultExtruder:k,plateId:j})}const _=g.getElementsByTagName("build");if(_.length>0){const N=_[0].getElementsByTagName("item");for(let A=0;A<N.length;A++){const C=N[A],j=C.getAttribute("objectid");if(!j)continue;const k=d6(C.getAttribute("transform")),R=m6(C),M=n.get(j)?.plateId??null,D=d.get(j),G=D?p.get(D)??null:null;r.push({objectId:j,transform:k,plateId:R??M??G??null})}}return{objects:n,buildItems:r,plateBounds:i,plateOffsets:s}}function f6(t){const e=new Nl,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 Ls(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function qSe(t){t.traverse(e=>{if(e instanceof kl)if(e.geometry.dispose(),Array.isArray(e.material))for(const n of e.material)n.dispose();else e.material.dispose()})}function GSe(t,e,n){const{objects:r,buildItems:i}=t,s=new Kg,o=h=>{const p=n?.[h]||"#00ae42",x=new Yn(p);return new EX({color:x,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 f=r.get(h.objectId);if(f)for(const p of f.meshes){const x=h.extruder??p.extruder,v=[];for(let y=0;y<p.vertices.length;y+=3){const _=new xt(p.vertices[y],p.vertices[y+1],p.vertices[y+2]);_.applyMatrix4(h.transform),v.push(_.x,_.y,_.z)}const g=f6({vertices:v,triangles:p.triangles});l.has(x)||l.set(x,[]),l.get(x).push(g)}}else for(const h of r.values())for(const f of h.meshes){const p=f.extruder,x=f6(f);l.has(p)||l.set(p,[]),l.get(p).push(x)}for(const[h,f]of l){if(f.length===0)continue;const p=f.length===1?f[0]:ISe(f,!1);if(p){const x=o(h),v=new kl(p,x);s.add(v)}if(f.length>1)for(const x of f)x.dispose()}return s}function BX({url:t,fileType:e,buildVolume:n={x:256,y:256,z:256},filamentColors:r,selectedPlateId:i=null,className:s=""}){const{t:o}=Et(),l=w.useRef(null),c=w.useRef(null),u=w.useRef(null),d=w.useRef(null),h=w.useRef(null),f=w.useRef(null),p=w.useRef(null),x=w.useRef(null),[v,g]=w.useState(!0),[y,_]=w.useState(null),[N,A]=w.useState(null),[C,j]=w.useState(null);w.useEffect(()=>{if(!l.current)return;const M=l.current,D=M.clientWidth,G=M.clientHeight,U=new xxe;U.background=new Yn(1710618),u.current=U;const W=new cl(45,D/G,.1,1e4);W.position.set(150,150,150),d.current=W;const L=new _Se({antialias:!0});L.setSize(D,G),L.setPixelRatio(window.devicePixelRatio),M.appendChild(L.domElement),c.current=L;const ee=new kSe(W,L.domElement);ee.enableDamping=!0,ee.dampingFactor=.05,h.current=ee;const ae=new Dxe(16777215,.6);U.add(ae);const Y=new F8(16777215,.8);Y.position.set(100,100,100),U.add(Y);const se=new F8(16777215,.4);se.position.set(-100,50,-100),U.add(se);const ce=Math.max(n.x,n.y),ye=Math.ceil(ce/16),Z=new Fxe(ce,ye,4473924,3355443);U.add(Z),x.current=Z;const ue=new o4(n.x,n.y),pe=new a4({color:44610,transparent:!0,opacity:.15,side:kc}),be=new kl(ue,pe);be.rotation.x=-Math.PI/2,be.position.y=-.5,U.add(be),p.current=be;let Ee;const $=()=>{Ee=requestAnimationFrame($),ee.update(),L.render(U,W)};$(),g(!0),_(null),A(null),j(null);const K=(e||t.split("?")[0].split(".").pop()||"").toLowerCase(),T={},E=sd();E&&(T.Authorization=`Bearer ${E}`),K==="stl"?fetch(t,{headers:T}).then(B=>{if(!B.ok)throw new Error(o("modelViewer.errors.failedToLoad"));return B.arrayBuffer()}).then(B=>{const z=new zSe().parse(B);z.computeVertexNormals(),z.rotateX(-Math.PI/2),j(z)}).catch(B=>{_(B.message),g(!1)}):K==="3mf"?fetch(t,{headers:T}).then(B=>{if(!B.ok)throw new Error(o("modelViewer.errors.failedToLoad"));return B.arrayBuffer()}).then(VSe).then(B=>{if(B.objects.size===0)throw new Error(o("modelViewer.errors.noMeshes"));A(B)}).catch(B=>{_(B.message),g(!1)}):(_(o("modelViewer.errors.unsupportedFormat")),g(!1));const O=()=>{if(!M)return;const B=M.clientWidth,re=M.clientHeight;B===0||re===0||(W.aspect=B/re,W.updateProjectionMatrix(),L.setSize(B,re))};window.addEventListener("resize",O);const q=new ResizeObserver(()=>{O()});return q.observe(M),()=>{window.removeEventListener("resize",O),q.disconnect(),cancelAnimationFrame(Ee),ee.dispose(),L.dispose(),M.removeChild(L.domElement),f.current=null,p.current=null,x.current=null}},[t,n,e,o]),w.useEffect(()=>{if(!u.current||!d.current||!h.current||!N&&!C)return;f.current&&(u.current.remove(f.current),qSe(f.current));const M=!!C,D=M?(()=>{const K=r?.[0]||"#00ae42",T=new EX({color:new Yn(K),shininess:30}),E=new kl(C,T),O=new Kg;return O.add(E),O})():GSe(N,i??null,r);f.current=D,u.current.add(D);const G=new Uh().setFromObject(D),U=G.getCenter(new xt);D.position.y=-G.min.y;const W=!M&&i!=null&&N.buildItems.length>0?N.plateBounds.get(i):void 0,L=!M&&i!=null?N.plateOffsets.get(i):void 0,ee=M||N.buildItems.length===0||i!=null&&!W&&!L,ae=ee?-U.x:0,Y=ee?-U.z:0;let se=0,ce=0;if(!M&&i!=null&&N.buildItems.length>0&&W){const K=new Uh().setFromObject(D);se=K.min.x-W.minX,ce=K.min.z-W.minY}const ye=n.x/2,Z=n.y/2;!M&&i!=null&&N.buildItems.length>0&&W?(D.position.x=ae-se,D.position.z=Y-ce):!M&&i!=null&&L?(D.position.x=ae+(ye-L.offsetX),D.position.z=Y+(Z-L.offsetY)):ee?(D.position.x=ae+ye,D.position.z=Y+Z):(D.position.x=ae,D.position.z=Y),p.current&&(p.current.position.x=ye,p.current.position.z=Z),x.current&&(x.current.position.x=ye,x.current.position.z=Z);const ue=new Uh().setFromObject(D),pe=ue.getCenter(new xt),be=ue.getSize(new xt),$=Math.max(be.x,be.y,be.z)*1.8;d.current.position.set(pe.x+$*.7,pe.y+$*.5,pe.z+$*.7),h.current.target.copy(pe),h.current.update(),g(!1)},[N,C,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=M=>{d.current&&d.current.position.multiplyScalar(M)};return a.jsxs("div",{className:`relative ${s}`,children:[a.jsx("div",{ref:l,className:"w-full h-full min-h-[400px]"}),v&&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"})}),y&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx("p",{className:"text-red-400",children:y})}),!v&&!y&&a.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>R(.8),children:a.jsx(VF,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>R(1.25),children:a.jsx(qF,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:k,children:a.jsx(co,{className:"w-4 h-4"})})]})]})}const pC="159",cg={ROTATE:0,DOLLY:1,PAN:2},ug={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},WSe=0,p6=1,KSe=2,HX=1,YSe=2,Eu=3,Jh=0,io=1,Lu=2,Bh=0,ob=1,g6=2,b6=3,x6=4,XSe=5,Jm=100,QSe=101,ZSe=102,y6=103,v6=104,JSe=200,e_e=201,t_e=202,n_e=203,fD=204,pD=205,r_e=206,a_e=207,i_e=208,s_e=209,o_e=210,l_e=211,c_e=212,u_e=213,d_e=214,h_e=0,m_e=1,f_e=2,H1=3,p_e=4,g_e=5,b_e=6,x_e=7,u4=0,y_e=1,v_e=2,Hh=0,w_e=1,S_e=2,__e=3,N_e=4,k_e=5,$X=300,Ab=301,Tb=302,gD=303,bD=304,gC=306,xD=1e3,Vl=1001,yD=1002,Qi=1003,w6=1004,PM=1005,ul=1006,C_e=1007,D0=1008,$h=1009,A_e=1010,T_e=1011,d4=1012,VX=1013,kh=1014,Hu=1015,R0=1016,qX=1017,GX=1018,vf=1020,M_e=1021,dl=1023,P_e=1024,j_e=1025,wf=1026,Mb=1027,E_e=1028,WX=1029,D_e=1030,KX=1031,YX=1033,jM=33776,EM=33777,DM=33778,RM=33779,S6=35840,_6=35841,N6=35842,k6=35843,XX=36196,C6=37492,A6=37496,T6=37808,M6=37809,P6=37810,j6=37811,E6=37812,D6=37813,R6=37814,F6=37815,L6=37816,O6=37817,I6=37818,z6=37819,U6=37820,B6=37821,FM=36492,H6=36494,$6=36495,R_e=36283,V6=36284,q6=36285,G6=36286,QX=3e3,Sf=3001,F_e=3200,L_e=3201,ZX=0,O_e=1,hl="",Zi="srgb",ld="srgb-linear",h4="display-p3",bC="display-p3-linear",$1="linear",ca="srgb",V1="rec709",q1="p3",dg=7680,W6=519,I_e=512,z_e=513,U_e=514,JX=515,B_e=516,H_e=517,$_e=518,V_e=519,vD=35044,K6="300 es",wD=1035,Mc=2e3,F0=2001;class up{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 us=["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 Y6=1234567;const Zy=Math.PI/180,L0=180/Math.PI;function Yu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(us[t&255]+us[t>>8&255]+us[t>>16&255]+us[t>>24&255]+"-"+us[e&255]+us[e>>8&255]+"-"+us[e>>16&15|64]+us[e>>24&255]+"-"+us[n&63|128]+us[n>>8&255]+"-"+us[n>>16&255]+us[n>>24&255]+us[r&255]+us[r>>8&255]+us[r>>16&255]+us[r>>24&255]).toLowerCase()}function Ji(t,e,n){return Math.max(e,Math.min(n,t))}function m4(t,e){return(t%e+e)%e}function q_e(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function G_e(t,e,n){return t!==e?(n-t)/(e-t):0}function Jy(t,e,n){return(1-n)*t+n*e}function W_e(t,e,n,r){return Jy(t,e,1-Math.exp(-n*r))}function K_e(t,e=1){return e-Math.abs(m4(t,e*2)-e)}function Y_e(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function X_e(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function Q_e(t,e){return t+Math.floor(Math.random()*(e-t+1))}function Z_e(t,e){return t+Math.random()*(e-t)}function J_e(t){return t*(.5-Math.random())}function e1e(t){t!==void 0&&(Y6=t);let e=Y6+=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 t1e(t){return t*Zy}function n1e(t){return t*L0}function SD(t){return(t&t-1)===0&&t!==0}function r1e(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function G1(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function a1e(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),f=o((e-r)/2),p=s((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*h,c*f,l*u);break;case"YZY":t.set(c*f,l*d,c*h,l*u);break;case"ZXZ":t.set(c*h,c*f,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function 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 Br(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 eQ={DEG2RAD:Zy,RAD2DEG:L0,generateUUID:Yu,clamp:Ji,euclideanModulo:m4,mapLinear:q_e,inverseLerp:G_e,lerp:Jy,damp:W_e,pingpong:K_e,smoothstep:Y_e,smootherstep:X_e,randInt:Q_e,randFloat:Z_e,randFloatSpread:J_e,seededRandom:e1e,degToRad:t1e,radToDeg:n1e,isPowerOfTwo:SD,ceilPowerOfTwo:r1e,floorPowerOfTwo:G1,setQuaternionFromProperEuler:a1e,normalize:Br,denormalize:Cc};class Tn{constructor(e=0,n=0){Tn.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Ji(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),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 Zn{constructor(e,n,r,i,s,o,l,c,u){Zn.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],f=r[2],p=r[5],x=r[8],v=i[0],g=i[3],y=i[6],_=i[1],N=i[4],A=i[7],C=i[2],j=i[5],k=i[8];return s[0]=o*v+l*_+c*C,s[3]=o*g+l*N+c*j,s[6]=o*y+l*A+c*k,s[1]=u*v+d*_+h*C,s[4]=u*g+d*N+h*j,s[7]=u*y+d*A+h*k,s[2]=f*v+p*_+x*C,s[5]=f*g+p*N+x*j,s[8]=f*y+p*A+x*k,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],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,f=l*c-d*s,p=u*s-o*c,x=n*h+r*f+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=h*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*o)*v,e[3]=f*v,e[4]=(d*n-i*c)*v,e[5]=(i*s-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(o*n-r*s)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,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(LM.makeScale(e,n)),this}rotate(e){return this.premultiply(LM.makeRotation(-e)),this}translate(e,n){return this.premultiply(LM.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 LM=new Zn;function tQ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function W1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function i1e(){const t=W1("canvas");return t.style.display="block",t}const X6={};function e0(t){t in X6||(X6[t]=!0,console.warn(t))}const Q6=new Zn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Z6=new Zn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),LS={[ld]:{transfer:$1,primaries:V1,toReference:t=>t,fromReference:t=>t},[Zi]:{transfer:ca,primaries:V1,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[bC]:{transfer:$1,primaries:q1,toReference:t=>t.applyMatrix3(Z6),fromReference:t=>t.applyMatrix3(Q6)},[h4]:{transfer:ca,primaries:q1,toReference:t=>t.convertSRGBToLinear().applyMatrix3(Z6),fromReference:t=>t.applyMatrix3(Q6).convertLinearToSRGB()}},s1e=new Set([ld,bC]),Hr={enabled:!0,_workingColorSpace:ld,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(!s1e.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=LS[e].toReference,i=LS[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 LS[t].primaries},getTransfer:function(t){return t===hl?$1:LS[t].transfer}};function lb(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function OM(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let hg;class nQ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{hg===void 0&&(hg=W1("canvas")),hg.width=e.width,hg.height=e.height;const r=hg.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=hg}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=W1("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]=lb(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(lb(n[r]/255)*255):n[r]=lb(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 o1e=0;class rQ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:o1e++}),this.uuid=Yu(),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(IM(i[o].image)):s.push(IM(i[o]))}else s=IM(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function IM(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?nQ.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 l1e=0;class so extends up{constructor(e=so.DEFAULT_IMAGE,n=so.DEFAULT_MAPPING,r=Vl,i=Vl,s=ul,o=D0,l=dl,c=$h,u=so.DEFAULT_ANISOTROPY,d=hl){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:l1e++}),this.uuid=Yu(),this.name="",this.source=new rQ(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 Tn(0,0),this.repeat=new Tn(1,1),this.center=new Tn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Zn,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===Sf?Zi:hl),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!==$X)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case xD:e.x=e.x-Math.floor(e.x);break;case Vl:e.x=e.x<0?0:1;break;case yD:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case xD:e.y=e.y-Math.floor(e.y);break;case Vl:e.y=e.y<0?0:1;break;case yD: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===Zi?Sf:QX}set encoding(e){e0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Sf?Zi:hl}}so.DEFAULT_IMAGE=null;so.DEFAULT_MAPPING=$X;so.DEFAULT_ANISOTROPY=1;class Vr{constructor(e=0,n=0,r=0,i=1){Vr.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],f=c[1],p=c[5],x=c[9],v=c[2],g=c[6],y=c[10];if(Math.abs(d-f)<.01&&Math.abs(h-v)<.01&&Math.abs(x-g)<.01){if(Math.abs(d+f)<.1&&Math.abs(h+v)<.1&&Math.abs(x+g)<.1&&Math.abs(u+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,A=(p+1)/2,C=(y+1)/2,j=(d+f)/4,k=(h+v)/4,R=(x+g)/4;return N>A&&N>C?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=j/r,s=k/r):A>C?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=j/i,s=R/i):C<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(C),r=k/s,i=R/s),this.set(r,i,s,n),this}let _=Math.sqrt((g-x)*(g-x)+(h-v)*(h-v)+(f-d)*(f-d));return Math.abs(_)<.001&&(_=1),this.x=(g-x)/_,this.y=(h-v)/_,this.z=(f-d)/_,this.w=Math.acos((u+p+y-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 c1e extends up{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Vr(0,0,e,n),this.scissorTest=!1,this.viewport=new Vr(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===Sf?Zi:hl),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ul,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new so(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 rQ(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 Vf extends c1e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class aQ extends so{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=Qi,this.minFilter=Qi,this.wrapR=Vl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class u1e extends so{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=Qi,this.minFilter=Qi,this.wrapR=Vl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class qf{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 f=s[o+0],p=s[o+1],x=s[o+2],v=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]=f,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(h!==v||c!==f||u!==p||d!==x){let g=1-l;const y=c*f+u*p+d*x+h*v,_=y>=0?1:-1,N=1-y*y;if(N>Number.EPSILON){const C=Math.sqrt(N),j=Math.atan2(C,y*_);g=Math.sin(g*j)/C,l=Math.sin(l*j)/C}const A=l*_;if(c=c*g+f*A,u=u*g+p*A,d=d*g+x*A,h=h*g+v*A,g===1-l){const C=1/Math.sqrt(c*c+u*u+d*d+h*h);c*=C,u*=C,d*=C,h*=C}}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],f=s[o+1],p=s[o+2],x=s[o+3];return e[n]=l*x+d*h+c*p-u*f,e[n+1]=c*x+d*f+u*h-l*p,e[n+2]=u*x+d*p+l*f-c*h,e[n+3]=d*x-l*h-c*f-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),h=l(s/2),f=c(r/2),p=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=f*d*h+u*p*x,this._y=u*p*h-f*d*x,this._z=u*d*x+f*p*h,this._w=u*d*h-f*p*x;break;case"YXZ":this._x=f*d*h+u*p*x,this._y=u*p*h-f*d*x,this._z=u*d*x-f*p*h,this._w=u*d*h+f*p*x;break;case"ZXY":this._x=f*d*h-u*p*x,this._y=u*p*h+f*d*x,this._z=u*d*x+f*p*h,this._w=u*d*h-f*p*x;break;case"ZYX":this._x=f*d*h-u*p*x,this._y=u*p*h+f*d*x,this._z=u*d*x-f*p*h,this._w=u*d*h+f*p*x;break;case"YZX":this._x=f*d*h+u*p*x,this._y=u*p*h+f*d*x,this._z=u*d*x-f*p*h,this._w=u*d*h-f*p*x;break;case"XZY":this._x=f*d*h-u*p*x,this._y=u*p*h-f*d*x,this._z=u*d*x+f*p*h,this._w=u*d*h+f*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],h=n[10],f=r+l+h;if(f>0){const p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(d-c)*p,this._y=(s-u)*p,this._z=(o-i)*p}else if(r>l&&r>h){const p=2*Math.sqrt(1+r-l-h);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+u)/p}else if(l>h){const p=2*Math.sqrt(1+l-r-h);this._w=(s-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+h-r-l);this._w=(o-i)/p,this._x=(s+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ji(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-s*c,this._y=i*d+o*c+s*l-r*u,this._z=s*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-s*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const c=1-l*l;if(c<=Number.EPSILON){const p=1-n;return this._w=p*o+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*s+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),h=Math.sin((1-n)*d)/u,f=Math.sin(n*d)/u;return this._w=o*h+this._w*f,this._x=r*h+this._x*f,this._y=i*h+this._y*f,this._z=s*h+this._z*f,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 rt{constructor(e=0,n=0,r=0){rt.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(J6.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(J6.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 zM.copy(this).projectOnVector(e),this.sub(zM)}reflect(e){return this.sub(zM.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Ji(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(n),this.y=r*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const zM=new rt,J6=new qf;class xl{constructor(e=new rt(1/0,1/0,1/0),n=new rt(-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(Ul.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ul.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=Ul.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,Ul):Ul.fromBufferAttribute(s,o),Ul.applyMatrix4(e.matrixWorld),this.expandByPoint(Ul);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),OS.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),OS.copy(r.boundingBox)),OS.applyMatrix4(e.matrixWorld),this.union(OS)}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,Ul),Ul.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(by),IS.subVectors(this.max,by),mg.subVectors(e.a,by),fg.subVectors(e.b,by),pg.subVectors(e.c,by),Qd.subVectors(fg,mg),Zd.subVectors(pg,fg),Om.subVectors(mg,pg);let n=[0,-Qd.z,Qd.y,0,-Zd.z,Zd.y,0,-Om.z,Om.y,Qd.z,0,-Qd.x,Zd.z,0,-Zd.x,Om.z,0,-Om.x,-Qd.y,Qd.x,0,-Zd.y,Zd.x,0,-Om.y,Om.x,0];return!UM(n,mg,fg,pg,IS)||(n=[1,0,0,0,1,0,0,0,1],!UM(n,mg,fg,pg,IS))?!1:(zS.crossVectors(Qd,Zd),n=[zS.x,zS.y,zS.z],UM(n,mg,fg,pg,IS))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ul).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ul).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:(Su[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Su[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Su[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Su[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Su[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Su[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Su[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Su[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Su),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 Su=[new rt,new rt,new rt,new rt,new rt,new rt,new rt,new rt],Ul=new rt,OS=new xl,mg=new rt,fg=new rt,pg=new rt,Qd=new rt,Zd=new rt,Om=new rt,by=new rt,IS=new rt,zS=new rt,Im=new rt;function UM(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){Im.fromArray(t,s);const l=i.x*Math.abs(Im.x)+i.y*Math.abs(Im.y)+i.z*Math.abs(Im.z),c=e.dot(Im),u=n.dot(Im),d=r.dot(Im);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const d1e=new xl,xy=new rt,BM=new rt;class Rc{constructor(e=new rt,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):d1e.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;xy.subVectors(e,this.center);const n=xy.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(xy,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):(BM.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xy.copy(e.center).add(BM)),this.expandByPoint(xy.copy(e.center).sub(BM))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const _u=new rt,HM=new rt,US=new rt,Jd=new rt,$M=new rt,BS=new rt,VM=new rt;class f4{constructor(e=new rt,n=new rt(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,_u)),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=_u.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(_u.copy(this.origin).addScaledVector(this.direction,n),_u.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){HM.copy(e).add(n).multiplyScalar(.5),US.copy(n).sub(e).normalize(),Jd.copy(this.origin).sub(HM);const s=e.distanceTo(n)*.5,o=-this.direction.dot(US),l=Jd.dot(this.direction),c=-Jd.dot(US),u=Jd.lengthSq(),d=Math.abs(1-o*o);let h,f,p,x;if(d>0)if(h=o*c-l,f=o*l-c,x=s*d,h>=0)if(f>=-x)if(f<=x){const v=1/d;h*=v,f*=v,p=h*(h+o*f+2*l)+f*(o*h+f+2*c)+u}else f=s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+u;else f=-s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+u;else f<=-x?(h=Math.max(0,-(-o*s+l)),f=h>0?-s:Math.min(Math.max(-s,-c),s),p=-h*h+f*(f+2*c)+u):f<=x?(h=0,f=Math.min(Math.max(-s,-c),s),p=f*(f+2*c)+u):(h=Math.max(0,-(o*s+l)),f=h>0?s:Math.min(Math.max(-s,-c),s),p=-h*h+f*(f+2*c)+u);else f=o>0?-s:s,h=Math.max(0,-(o*f+l)),p=-h*h+f*(f+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(HM).addScaledVector(US,f),p}intersectSphere(e,n){_u.subVectors(e.center,this.origin);const r=_u.dot(this.direction),i=_u.dot(_u)-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,f=this.origin;return u>=0?(r=(e.min.x-f.x)*u,i=(e.max.x-f.x)*u):(r=(e.max.x-f.x)*u,i=(e.min.x-f.x)*u),d>=0?(s=(e.min.y-f.y)*d,o=(e.max.y-f.y)*d):(s=(e.max.y-f.y)*d,o=(e.min.y-f.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),h>=0?(l=(e.min.z-f.z)*h,c=(e.max.z-f.z)*h):(l=(e.max.z-f.z)*h,c=(e.min.z-f.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,_u)!==null}intersectTriangle(e,n,r,i,s){$M.subVectors(n,e),BS.subVectors(r,e),VM.crossVectors($M,BS);let o=this.direction.dot(VM),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Jd.subVectors(this.origin,e);const c=l*this.direction.dot(BS.crossVectors(Jd,BS));if(c<0)return null;const u=l*this.direction.dot($M.cross(Jd));if(u<0||c+u>o)return null;const d=-l*Jd.dot(VM);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 ia{constructor(e,n,r,i,s,o,l,c,u,d,h,f,p,x,v,g){ia.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,f,p,x,v,g)}set(e,n,r,i,s,o,l,c,u,d,h,f,p,x,v,g){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=s,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=h,y[14]=f,y[3]=p,y[7]=x,y[11]=v,y[15]=g,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 ia().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/gg.setFromMatrixColumn(e,0).length(),s=1/gg.setFromMatrixColumn(e,1).length(),o=1/gg.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 f=o*d,p=o*h,x=l*d,v=l*h;n[0]=c*d,n[4]=-c*h,n[8]=u,n[1]=p+x*u,n[5]=f-v*u,n[9]=-l*c,n[2]=v-f*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const f=c*d,p=c*h,x=u*d,v=u*h;n[0]=f+v*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*h,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=v+f*l,n[10]=o*c}else if(e.order==="ZXY"){const f=c*d,p=c*h,x=u*d,v=u*h;n[0]=f-v*l,n[4]=-o*h,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=v-f*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const f=o*d,p=o*h,x=l*d,v=l*h;n[0]=c*d,n[4]=x*u-p,n[8]=f*u+v,n[1]=c*h,n[5]=v*u+f,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const f=o*c,p=o*u,x=l*c,v=l*u;n[0]=c*d,n[4]=v-f*h,n[8]=x*h+p,n[1]=h,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*h+x,n[10]=f-v*h}else if(e.order==="XZY"){const f=o*c,p=o*u,x=l*c,v=l*u;n[0]=c*d,n[4]=-h,n[8]=u*d,n[1]=f*h+v,n[5]=o*d,n[9]=p*h-x,n[2]=x*h-p,n[6]=l*d,n[10]=v*h+f}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(h1e,e,m1e)}lookAt(e,n,r){const i=this.elements;return ko.subVectors(e,n),ko.lengthSq()===0&&(ko.z=1),ko.normalize(),eh.crossVectors(r,ko),eh.lengthSq()===0&&(Math.abs(r.z)===1?ko.x+=1e-4:ko.z+=1e-4,ko.normalize(),eh.crossVectors(r,ko)),eh.normalize(),HS.crossVectors(ko,eh),i[0]=eh.x,i[4]=HS.x,i[8]=ko.x,i[1]=eh.y,i[5]=HS.y,i[9]=ko.y,i[2]=eh.z,i[6]=HS.z,i[10]=ko.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],f=r[9],p=r[13],x=r[2],v=r[6],g=r[10],y=r[14],_=r[3],N=r[7],A=r[11],C=r[15],j=i[0],k=i[4],R=i[8],M=i[12],D=i[1],G=i[5],U=i[9],W=i[13],L=i[2],ee=i[6],ae=i[10],Y=i[14],se=i[3],ce=i[7],ye=i[11],Z=i[15];return s[0]=o*j+l*D+c*L+u*se,s[4]=o*k+l*G+c*ee+u*ce,s[8]=o*R+l*U+c*ae+u*ye,s[12]=o*M+l*W+c*Y+u*Z,s[1]=d*j+h*D+f*L+p*se,s[5]=d*k+h*G+f*ee+p*ce,s[9]=d*R+h*U+f*ae+p*ye,s[13]=d*M+h*W+f*Y+p*Z,s[2]=x*j+v*D+g*L+y*se,s[6]=x*k+v*G+g*ee+y*ce,s[10]=x*R+v*U+g*ae+y*ye,s[14]=x*M+v*W+g*Y+y*Z,s[3]=_*j+N*D+A*L+C*se,s[7]=_*k+N*G+A*ee+C*ce,s[11]=_*R+N*U+A*ae+C*ye,s[15]=_*M+N*W+A*Y+C*Z,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],f=e[10],p=e[14],x=e[3],v=e[7],g=e[11],y=e[15];return x*(+s*c*h-i*u*h-s*l*f+r*u*f+i*l*p-r*c*p)+v*(+n*c*p-n*u*f+s*o*f-i*o*p+i*u*d-s*c*d)+g*(+n*u*h-n*l*p-s*o*h+r*o*p+s*l*d-r*u*d)+y*(-i*l*d-n*c*h+n*l*f+i*o*h-r*o*f+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],f=e[10],p=e[11],x=e[12],v=e[13],g=e[14],y=e[15],_=h*g*u-v*f*u+v*c*p-l*g*p-h*c*y+l*f*y,N=x*f*u-d*g*u-x*c*p+o*g*p+d*c*y-o*f*y,A=d*v*u-x*h*u+x*l*p-o*v*p-d*l*y+o*h*y,C=x*h*c-d*v*c-x*l*f+o*v*f+d*l*g-o*h*g,j=n*_+r*N+i*A+s*C;if(j===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/j;return e[0]=_*k,e[1]=(v*f*s-h*g*s-v*i*p+r*g*p+h*i*y-r*f*y)*k,e[2]=(l*g*s-v*c*s+v*i*u-r*g*u-l*i*y+r*c*y)*k,e[3]=(h*c*s-l*f*s-h*i*u+r*f*u+l*i*p-r*c*p)*k,e[4]=N*k,e[5]=(d*g*s-x*f*s+x*i*p-n*g*p-d*i*y+n*f*y)*k,e[6]=(x*c*s-o*g*s-x*i*u+n*g*u+o*i*y-n*c*y)*k,e[7]=(o*f*s-d*c*s+d*i*u-n*f*u-o*i*p+n*c*p)*k,e[8]=A*k,e[9]=(x*h*s-d*v*s-x*r*p+n*v*p+d*r*y-n*h*y)*k,e[10]=(o*v*s-x*l*s+x*r*u-n*v*u-o*r*y+n*l*y)*k,e[11]=(d*l*s-o*h*s-d*r*u+n*h*u+o*r*p-n*l*p)*k,e[12]=C*k,e[13]=(d*v*i-x*h*i+x*r*f-n*v*f-d*r*g+n*h*g)*k,e[14]=(x*l*i-o*v*i-x*r*c+n*v*c+o*r*g-n*l*g)*k,e[15]=(o*h*i-d*l*i+d*r*c-n*h*c-o*r*f+n*l*f)*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,f=s*u,p=s*d,x=s*h,v=o*d,g=o*h,y=l*h,_=c*u,N=c*d,A=c*h,C=r.x,j=r.y,k=r.z;return i[0]=(1-(v+y))*C,i[1]=(p+A)*C,i[2]=(x-N)*C,i[3]=0,i[4]=(p-A)*j,i[5]=(1-(f+y))*j,i[6]=(g+_)*j,i[7]=0,i[8]=(x+N)*k,i[9]=(g-_)*k,i[10]=(1-(f+v))*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=gg.set(i[0],i[1],i[2]).length();const o=gg.set(i[4],i[5],i[6]).length(),l=gg.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],Bl.copy(this);const u=1/s,d=1/o,h=1/l;return Bl.elements[0]*=u,Bl.elements[1]*=u,Bl.elements[2]*=u,Bl.elements[4]*=d,Bl.elements[5]*=d,Bl.elements[6]*=d,Bl.elements[8]*=h,Bl.elements[9]*=h,Bl.elements[10]*=h,n.setFromRotationMatrix(Bl),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=Mc){const c=this.elements,u=2*s/(n-e),d=2*s/(r-i),h=(n+e)/(n-e),f=(r+i)/(r-i);let p,x;if(l===Mc)p=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(l===F0)p=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=Mc){const c=this.elements,u=1/(n-e),d=1/(r-i),h=1/(o-s),f=(n+e)*u,p=(r+i)*d;let x,v;if(l===Mc)x=(o+s)*h,v=-2*h;else if(l===F0)x=s*h,v=-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]=-f,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=v,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const gg=new rt,Bl=new ia,h1e=new rt(0,0,0),m1e=new rt(1,1,1),eh=new rt,HS=new rt,ko=new rt,eH=new ia,tH=new qf;class _v{constructor(e=0,n=0,r=0,i=_v.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],f=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(Ji(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Ji(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ji(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Ji(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Ji(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-Ji(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return eH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(eH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return tH.setFromEuler(this),this.setFromQuaternion(tH,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}}_v.DEFAULT_ORDER="XYZ";class iQ{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 f1e=0;const nH=new rt,bg=new qf,Nu=new ia,$S=new rt,yy=new rt,p1e=new rt,g1e=new qf,rH=new rt(1,0,0),aH=new rt(0,1,0),iH=new rt(0,0,1),b1e={type:"added"},x1e={type:"removed"};class Os extends up{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:f1e++}),this.uuid=Yu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Os.DEFAULT_UP.clone();const e=new rt,n=new _v,r=new qf,i=new rt(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 ia},normalMatrix:{value:new Zn}}),this.matrix=new ia,this.matrixWorld=new ia,this.matrixAutoUpdate=Os.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Os.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new iQ,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 bg.setFromAxisAngle(e,n),this.quaternion.multiply(bg),this}rotateOnWorldAxis(e,n){return bg.setFromAxisAngle(e,n),this.quaternion.premultiply(bg),this}rotateX(e){return this.rotateOnAxis(rH,e)}rotateY(e){return this.rotateOnAxis(aH,e)}rotateZ(e){return this.rotateOnAxis(iH,e)}translateOnAxis(e,n){return nH.copy(e).applyQuaternion(this.quaternion),this.position.add(nH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(rH,e)}translateY(e){return this.translateOnAxis(aH,e)}translateZ(e){return this.translateOnAxis(iH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Nu.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?$S.copy(e):$S.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),yy.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Nu.lookAt(yy,$S,this.up):Nu.lookAt($S,yy,this.up),this.quaternion.setFromRotationMatrix(Nu),i&&(Nu.extractRotation(i.matrixWorld),bg.setFromRotationMatrix(Nu),this.quaternion.premultiply(bg.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(b1e)):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(x1e)),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),Nu.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Nu.multiply(e.parent.matrixWorld)),e.applyMatrix4(Nu),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(yy,e,p1e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yy,g1e,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),f=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),h.length>0&&(r.shapes=h),f.length>0&&(r.skeletons=f),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Os.DEFAULT_UP=new rt(0,1,0);Os.DEFAULT_MATRIX_AUTO_UPDATE=!0;Os.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Hl=new rt,ku=new rt,qM=new rt,Cu=new rt,xg=new rt,yg=new rt,sH=new rt,GM=new rt,WM=new rt,KM=new rt;let VS=!1;class $l{constructor(e=new rt,n=new rt,r=new rt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Hl.subVectors(e,n),i.cross(Hl);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){Hl.subVectors(i,n),ku.subVectors(r,n),qM.subVectors(e,n);const o=Hl.dot(Hl),l=Hl.dot(ku),c=Hl.dot(qM),u=ku.dot(ku),d=ku.dot(qM),h=o*u-l*l;if(h===0)return s.set(-2,-1,-1);const f=1/h,p=(u*c-l*d)*f,x=(o*d-l*c)*f;return s.set(1-p-x,x,p)}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 VS===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),VS=!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 Hl.subVectors(r,n),ku.subVectors(e,n),Hl.cross(ku).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 Hl.subVectors(this.c,this.b),ku.subVectors(this.a,this.b),Hl.cross(ku).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return $l.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return $l.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return VS===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),VS=!0),$l.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return $l.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return $l.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return $l.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;xg.subVectors(i,r),yg.subVectors(s,r),GM.subVectors(e,r);const c=xg.dot(GM),u=yg.dot(GM);if(c<=0&&u<=0)return n.copy(r);WM.subVectors(e,i);const d=xg.dot(WM),h=yg.dot(WM);if(d>=0&&h<=d)return n.copy(i);const f=c*h-d*u;if(f<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(xg,o);KM.subVectors(e,s);const p=xg.dot(KM),x=yg.dot(KM);if(x>=0&&p<=x)return n.copy(s);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(yg,l);const g=d*x-p*h;if(g<=0&&h-d>=0&&p-x>=0)return sH.subVectors(s,i),l=(h-d)/(h-d+(p-x)),n.copy(i).addScaledVector(sH,l);const y=1/(g+v+f);return o=v*y,l=f*y,n.copy(r).addScaledVector(xg,o).addScaledVector(yg,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const sQ={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},th={h:0,s:0,l:0},qS={h:0,s:0,l:0};function YM(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=Zi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Hr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Hr.workingColorSpace){return this.r=e,this.g=n,this.b=r,Hr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Hr.workingColorSpace){if(e=m4(e,1),n=Ji(n,0,1),r=Ji(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=YM(o,s,e+1/3),this.g=YM(o,s,e),this.b=YM(o,s,e-1/3)}return Hr.toWorkingColorSpace(this,i),this}setStyle(e,n=Zi){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=Zi){const r=sQ[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=lb(e.r),this.g=lb(e.g),this.b=lb(e.b),this}copyLinearToSRGB(e){return this.r=OM(e.r),this.g=OM(e.g),this.b=OM(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Zi){return Hr.fromWorkingColorSpace(ds.copy(this),e),Math.round(Ji(ds.r*255,0,255))*65536+Math.round(Ji(ds.g*255,0,255))*256+Math.round(Ji(ds.b*255,0,255))}getHexString(e=Zi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Hr.workingColorSpace){Hr.fromWorkingColorSpace(ds.copy(this),n);const r=ds.r,i=ds.g,s=ds.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=Hr.workingColorSpace){return Hr.fromWorkingColorSpace(ds.copy(this),n),e.r=ds.r,e.g=ds.g,e.b=ds.b,e}getStyle(e=Zi){Hr.fromWorkingColorSpace(ds.copy(this),e);const n=ds.r,r=ds.g,i=ds.b;return e!==Zi?`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(th),this.setHSL(th.h+e,th.s+n,th.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(th),e.getHSL(qS);const r=Jy(th.h,qS.h,n),i=Jy(th.s,qS.s,n),s=Jy(th.l,qS.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 ds=new fn;fn.NAMES=sQ;let y1e=0;class ax extends up{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:y1e++}),this.uuid=Yu(),this.name="",this.type="Material",this.blending=ob,this.side=Jh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=fD,this.blendDst=pD,this.blendEquation=Jm,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new fn(0,0,0),this.blendAlpha=0,this.depthFunc=H1,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=W6,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=dg,this.stencilZFail=dg,this.stencilZPass=dg,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!==ob&&(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!==fD&&(r.blendSrc=this.blendSrc),this.blendDst!==pD&&(r.blendDst=this.blendDst),this.blendEquation!==Jm&&(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!==H1&&(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!==W6&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==dg&&(r.stencilFail=this.stencilFail),this.stencilZFail!==dg&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==dg&&(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 oQ extends ax{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.combine=u4,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 ei=new rt,GS=new Tn;class Ro{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=vD,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Hu,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++)GS.fromBufferAttribute(this,n),GS.applyMatrix3(e),this.setXY(n,GS.x,GS.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)ei.fromBufferAttribute(this,n),ei.applyMatrix3(e),this.setXYZ(n,ei.x,ei.y,ei.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)ei.fromBufferAttribute(this,n),ei.applyMatrix4(e),this.setXYZ(n,ei.x,ei.y,ei.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ei.fromBufferAttribute(this,n),ei.applyNormalMatrix(e),this.setXYZ(n,ei.x,ei.y,ei.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ei.fromBufferAttribute(this,n),ei.transformDirection(e),this.setXYZ(n,ei.x,ei.y,ei.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=Br(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=Br(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=Br(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=Br(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=Br(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Br(n,this.array),r=Br(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=Br(n,this.array),r=Br(r,this.array),i=Br(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=Br(n,this.array),r=Br(r,this.array),i=Br(i,this.array),s=Br(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!==vD&&(e.usage=this.usage),e}}class lQ extends Ro{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class cQ extends Ro{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Wa extends Ro{constructor(e,n,r){super(new Float32Array(e),n,r)}}let v1e=0;const Qo=new ia,XM=new Os,vg=new rt,Co=new xl,vy=new xl,Ti=new rt;class Ss extends up{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:v1e++}),this.uuid=Yu(),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(tQ(e)?cQ:lQ)(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 Zn().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 Qo.makeRotationFromQuaternion(e),this.applyMatrix4(Qo),this}rotateX(e){return Qo.makeRotationX(e),this.applyMatrix4(Qo),this}rotateY(e){return Qo.makeRotationY(e),this.applyMatrix4(Qo),this}rotateZ(e){return Qo.makeRotationZ(e),this.applyMatrix4(Qo),this}translate(e,n,r){return Qo.makeTranslation(e,n,r),this.applyMatrix4(Qo),this}scale(e,n,r){return Qo.makeScale(e,n,r),this.applyMatrix4(Qo),this}lookAt(e){return XM.lookAt(e),XM.updateMatrix(),this.applyMatrix4(XM.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vg).negate(),this.translate(vg.x,vg.y,vg.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 Wa(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xl);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 rt(-1/0,-1/0,-1/0),new rt(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];Co.setFromBufferAttribute(s),this.morphTargetsRelative?(Ti.addVectors(this.boundingBox.min,Co.min),this.boundingBox.expandByPoint(Ti),Ti.addVectors(this.boundingBox.max,Co.max),this.boundingBox.expandByPoint(Ti)):(this.boundingBox.expandByPoint(Co.min),this.boundingBox.expandByPoint(Co.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 Rc);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 rt,1/0);return}if(e){const r=this.boundingSphere.center;if(Co.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];vy.setFromBufferAttribute(l),this.morphTargetsRelative?(Ti.addVectors(Co.min,vy.min),Co.expandByPoint(Ti),Ti.addVectors(Co.max,vy.max),Co.expandByPoint(Ti)):(Co.expandByPoint(vy.min),Co.expandByPoint(vy.max))}Co.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)Ti.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ti));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++)Ti.fromBufferAttribute(l,u),c&&(vg.fromBufferAttribute(e,u),Ti.add(vg)),i=Math.max(i,r.distanceToSquared(Ti))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,s=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ro(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let D=0;D<l;D++)u[D]=new rt,d[D]=new rt;const h=new rt,f=new rt,p=new rt,x=new Tn,v=new Tn,g=new Tn,y=new rt,_=new rt;function N(D,G,U){h.fromArray(i,D*3),f.fromArray(i,G*3),p.fromArray(i,U*3),x.fromArray(o,D*2),v.fromArray(o,G*2),g.fromArray(o,U*2),f.sub(h),p.sub(h),v.sub(x),g.sub(x);const W=1/(v.x*g.y-g.x*v.y);isFinite(W)&&(y.copy(f).multiplyScalar(g.y).addScaledVector(p,-v.y).multiplyScalar(W),_.copy(p).multiplyScalar(v.x).addScaledVector(f,-g.x).multiplyScalar(W),u[D].add(y),u[G].add(y),u[U].add(y),d[D].add(_),d[G].add(_),d[U].add(_))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let D=0,G=A.length;D<G;++D){const U=A[D],W=U.start,L=U.count;for(let ee=W,ae=W+L;ee<ae;ee+=3)N(r[ee+0],r[ee+1],r[ee+2])}const C=new rt,j=new rt,k=new rt,R=new rt;function M(D){k.fromArray(s,D*3),R.copy(k);const G=u[D];C.copy(G),C.sub(k.multiplyScalar(k.dot(G))).normalize(),j.crossVectors(R,G);const W=j.dot(d[D])<0?-1:1;c[D*4]=C.x,c[D*4+1]=C.y,c[D*4+2]=C.z,c[D*4+3]=W}for(let D=0,G=A.length;D<G;++D){const U=A[D],W=U.start,L=U.count;for(let ee=W,ae=W+L;ee<ae;ee+=3)M(r[ee+0]),M(r[ee+1]),M(r[ee+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 Ro(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let f=0,p=r.count;f<p;f++)r.setXYZ(f,0,0,0);const i=new rt,s=new rt,o=new rt,l=new rt,c=new rt,u=new rt,d=new rt,h=new rt;if(e)for(let f=0,p=e.count;f<p;f+=3){const x=e.getX(f+0),v=e.getX(f+1),g=e.getX(f+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,v),o.fromBufferAttribute(n,g),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,g),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(g,u.x,u.y,u.z)}else for(let f=0,p=n.count;f<p;f+=3)i.fromBufferAttribute(n,f+0),s.fromBufferAttribute(n,f+1),o.fromBufferAttribute(n,f+2),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),r.setXYZ(f+0,d.x,d.y,d.z),r.setXYZ(f+1,d.x,d.y,d.z),r.setXYZ(f+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ti.fromBufferAttribute(e,n),Ti.normalize(),e.setXYZ(n,Ti.x,Ti.y,Ti.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,h=l.normalized,f=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,g=c.length;v<g;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let y=0;y<d;y++)f[x++]=u[p++]}return new Ro(f,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 f=u[d],p=e(f,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let h=0,f=u.length;h<f;h++){const p=u[h];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],h=s[u];for(let f=0,p=h.length;f<p;f++)d.push(h[f].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 oH=new ia,zm=new f4,WS=new Rc,lH=new rt,wg=new rt,Sg=new rt,_g=new rt,QM=new rt,KS=new rt,YS=new Tn,XS=new Tn,QS=new Tn,cH=new rt,uH=new rt,dH=new rt,ZS=new rt,JS=new rt;class Xl extends Os{constructor(e=new Ss,n=new oQ){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){KS.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],h=s[c];d!==0&&(QM.fromBufferAttribute(h,e),o?KS.addScaledVector(QM,d):KS.addScaledVector(QM.sub(n),d))}n.add(KS)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),WS.copy(r.boundingSphere),WS.applyMatrix4(s),zm.copy(e.ray).recast(e.near),!(WS.containsPoint(zm.origin)===!1&&(zm.intersectSphere(WS,lH)===null||zm.origin.distanceToSquared(lH)>(e.far-e.near)**2))&&(oH.copy(s).invert(),zm.copy(e.ray).applyMatrix4(oH),!(r.boundingBox!==null&&zm.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,zm)))}_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,f=s.groups,p=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,v=f.length;x<v;x++){const g=f[x],y=o[g.materialIndex],_=Math.max(g.start,p.start),N=Math.min(l.count,Math.min(g.start+g.count,p.start+p.count));for(let A=_,C=N;A<C;A+=3){const j=l.getX(A),k=l.getX(A+1),R=l.getX(A+2);i=e_(this,y,e,r,u,d,h,j,k,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=g.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let g=x,y=v;g<y;g+=3){const _=l.getX(g),N=l.getX(g+1),A=l.getX(g+2);i=e_(this,o,e,r,u,d,h,_,N,A),i&&(i.faceIndex=Math.floor(g/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,v=f.length;x<v;x++){const g=f[x],y=o[g.materialIndex],_=Math.max(g.start,p.start),N=Math.min(c.count,Math.min(g.start+g.count,p.start+p.count));for(let A=_,C=N;A<C;A+=3){const j=A,k=A+1,R=A+2;i=e_(this,y,e,r,u,d,h,j,k,R),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=g.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let g=x,y=v;g<y;g+=3){const _=g,N=g+1,A=g+2;i=e_(this,o,e,r,u,d,h,_,N,A),i&&(i.faceIndex=Math.floor(g/3),n.push(i))}}}}function w1e(t,e,n,r,i,s,o,l){let c;if(e.side===io?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===Jh,l),c===null)return null;JS.copy(l),JS.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(JS);return u<n.near||u>n.far?null:{distance:u,point:JS.clone(),object:t}}function e_(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,wg),t.getVertexPosition(c,Sg),t.getVertexPosition(u,_g);const d=w1e(t,e,n,r,wg,Sg,_g,ZS);if(d){i&&(YS.fromBufferAttribute(i,l),XS.fromBufferAttribute(i,c),QS.fromBufferAttribute(i,u),d.uv=$l.getInterpolation(ZS,wg,Sg,_g,YS,XS,QS,new Tn)),s&&(YS.fromBufferAttribute(s,l),XS.fromBufferAttribute(s,c),QS.fromBufferAttribute(s,u),d.uv1=$l.getInterpolation(ZS,wg,Sg,_g,YS,XS,QS,new Tn),d.uv2=d.uv1),o&&(cH.fromBufferAttribute(o,l),uH.fromBufferAttribute(o,c),dH.fromBufferAttribute(o,u),d.normal=$l.getInterpolation(ZS,wg,Sg,_g,cH,uH,dH,new rt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const h={a:l,b:c,c:u,normal:new rt,materialIndex:0};$l.getNormal(wg,Sg,_g,h.normal),d.face=h}return d}class Nv 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 f=0,p=0;x("z","y","x",-1,-1,r,n,e,o,s,0),x("z","y","x",1,-1,r,n,-e,o,s,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new Wa(u,3)),this.setAttribute("normal",new Wa(d,3)),this.setAttribute("uv",new Wa(h,2));function x(v,g,y,_,N,A,C,j,k,R,M){const D=A/k,G=C/R,U=A/2,W=C/2,L=j/2,ee=k+1,ae=R+1;let Y=0,se=0;const ce=new rt;for(let ye=0;ye<ae;ye++){const Z=ye*G-W;for(let ue=0;ue<ee;ue++){const pe=ue*D-U;ce[v]=pe*_,ce[g]=Z*N,ce[y]=L,u.push(ce.x,ce.y,ce.z),ce[v]=0,ce[g]=0,ce[y]=j>0?1:-1,d.push(ce.x,ce.y,ce.z),h.push(ue/k),h.push(1-ye/R),Y+=1}}for(let ye=0;ye<R;ye++)for(let Z=0;Z<k;Z++){const ue=f+Z+ee*ye,pe=f+Z+ee*(ye+1),be=f+(Z+1)+ee*(ye+1),Ee=f+(Z+1)+ee*ye;c.push(ue,pe,Ee),c.push(pe,be,Ee),se+=6}l.addGroup(p,se,M),p+=se,f+=Y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Nv(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Pb(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 Ms(t){const e={};for(let n=0;n<t.length;n++){const r=Pb(t[n]);for(const i in r)e[i]=r[i]}return e}function S1e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function uQ(t){return t.getRenderTarget()===null?t.outputColorSpace:Hr.workingColorSpace}const p4={clone:Pb,merge:Ms};var _1e=`void main() {
  3840. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3841. }`,N1e=`void main() {
  3842. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3843. }`;class em extends ax{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=_1e,this.fragmentShader=N1e,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=Pb(e.uniforms),this.uniformsGroups=S1e(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 dQ extends Os{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ia,this.projectionMatrix=new ia,this.projectionMatrixInverse=new ia,this.coordinateSystem=Mc}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 To extends dQ{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=L0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Zy*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return L0*2*Math.atan(Math.tan(Zy*.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(Zy*.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 Ng=-90,kg=1;class k1e extends Os{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new To(Ng,kg,e,n);i.layers=this.layers,this.add(i);const s=new To(Ng,kg,e,n);s.layers=this.layers,this.add(s);const o=new To(Ng,kg,e,n);o.layers=this.layers,this.add(o);const l=new To(Ng,kg,e,n);l.layers=this.layers,this.add(l);const c=new To(Ng,kg,e,n);c.layers=this.layers,this.add(c);const u=new To(Ng,kg,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===Mc)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===F0)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(),f=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,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=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(h,f,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class hQ extends so{constructor(e,n,r,i,s,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Ab,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 C1e extends Vf{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===Sf?Zi:hl),this.texture=new hQ(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:ul}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
  3844. varying vec3 vWorldDirection;
  3845. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3846. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3847. }
  3848. void main() {
  3849. vWorldDirection = transformDirection( position, modelMatrix );
  3850. #include <begin_vertex>
  3851. #include <project_vertex>
  3852. }
  3853. `,fragmentShader:`
  3854. uniform sampler2D tEquirect;
  3855. varying vec3 vWorldDirection;
  3856. #include <common>
  3857. void main() {
  3858. vec3 direction = normalize( vWorldDirection );
  3859. vec2 sampleUV = equirectUv( direction );
  3860. gl_FragColor = texture2D( tEquirect, sampleUV );
  3861. }
  3862. `},i=new Nv(5,5,5),s=new em({name:"CubemapFromEquirect",uniforms:Pb(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:io,blending:Bh});s.uniforms.tEquirect.value=n;const o=new Xl(i,s),l=n.minFilter;return n.minFilter===D0&&(n.minFilter=ul),new k1e(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 ZM=new rt,A1e=new rt,T1e=new Zn;class ch{constructor(e=new rt(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=ZM.subVectors(r,n).cross(A1e.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(ZM),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||T1e.getNormalMatrix(e),i=this.coplanarPoint(ZM).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 Um=new Rc,t_=new rt;class xC{constructor(e=new ch,n=new ch,r=new ch,i=new ch,s=new ch,o=new ch){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=Mc){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],f=i[7],p=i[8],x=i[9],v=i[10],g=i[11],y=i[12],_=i[13],N=i[14],A=i[15];if(r[0].setComponents(c-s,f-u,g-p,A-y).normalize(),r[1].setComponents(c+s,f+u,g+p,A+y).normalize(),r[2].setComponents(c+o,f+d,g+x,A+_).normalize(),r[3].setComponents(c-o,f-d,g-x,A-_).normalize(),r[4].setComponents(c-l,f-h,g-v,A-N).normalize(),n===Mc)r[5].setComponents(c+l,f+h,g+v,A+N).normalize();else if(n===F0)r[5].setComponents(l,h,v,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(),Um.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Um.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Um)}intersectsSprite(e){return Um.center.set(0,0,0),Um.radius=.7071067811865476,Um.applyMatrix4(e.matrixWorld),this.intersectsSphere(Um)}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(t_.x=i.normal.x>0?e.max.x:e.min.x,t_.y=i.normal.y>0?e.max.y:e.min.y,t_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(t_)<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 mQ(){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 M1e(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const h=u.array,f=u.usage,p=h.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,h,f),u.onUploadCallback();let v;if(h instanceof Float32Array)v=t.FLOAT;else if(h instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)v=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=t.UNSIGNED_SHORT;else if(h instanceof Int16Array)v=t.SHORT;else if(h instanceof Uint32Array)v=t.UNSIGNED_INT;else if(h instanceof Int32Array)v=t.INT;else if(h instanceof Int8Array)v=t.BYTE;else if(h instanceof Uint8Array)v=t.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)v=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:x,type:v,bytesPerElement:h.BYTES_PER_ELEMENT,version:u.version,size:p}}function s(u,d,h){const f=d.array,p=d._updateRange,x=d.updateRanges;if(t.bindBuffer(h,u),p.count===-1&&x.length===0&&t.bufferSubData(h,0,f),x.length!==0){for(let v=0,g=x.length;v<g;v++){const y=x[v];n?t.bufferSubData(h,y.start*f.BYTES_PER_ELEMENT,f,y.start,y.count):t.bufferSubData(h,y.start*f.BYTES_PER_ELEMENT,f.subarray(y.start,y.start+y.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(h,p.offset*f.BYTES_PER_ELEMENT,f,p.offset,p.count):t.bufferSubData(h,p.offset*f.BYTES_PER_ELEMENT,f.subarray(p.offset,p.offset+p.count)),p.count=-1),d.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const f=r.get(u);(!f||f.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 g4 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,f=n/c,p=[],x=[],v=[],g=[];for(let y=0;y<d;y++){const _=y*f-o;for(let N=0;N<u;N++){const A=N*h-s;x.push(A,-_,0),v.push(0,0,1),g.push(N/l),g.push(1-y/c)}}for(let y=0;y<c;y++)for(let _=0;_<l;_++){const N=_+u*y,A=_+u*(y+1),C=_+1+u*(y+1),j=_+1+u*y;p.push(N,A,j),p.push(A,C,j)}this.setIndex(p),this.setAttribute("position",new Wa(x,3)),this.setAttribute("normal",new Wa(v,3)),this.setAttribute("uv",new Wa(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new g4(e.width,e.height,e.widthSegments,e.heightSegments)}}var P1e=`#ifdef USE_ALPHAHASH
  3863. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3864. #endif`,j1e=`#ifdef USE_ALPHAHASH
  3865. const float ALPHA_HASH_SCALE = 0.05;
  3866. float hash2D( vec2 value ) {
  3867. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3868. }
  3869. float hash3D( vec3 value ) {
  3870. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3871. }
  3872. float getAlphaHashThreshold( vec3 position ) {
  3873. float maxDeriv = max(
  3874. length( dFdx( position.xyz ) ),
  3875. length( dFdy( position.xyz ) )
  3876. );
  3877. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3878. vec2 pixScales = vec2(
  3879. exp2( floor( log2( pixScale ) ) ),
  3880. exp2( ceil( log2( pixScale ) ) )
  3881. );
  3882. vec2 alpha = vec2(
  3883. hash3D( floor( pixScales.x * position.xyz ) ),
  3884. hash3D( floor( pixScales.y * position.xyz ) )
  3885. );
  3886. float lerpFactor = fract( log2( pixScale ) );
  3887. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3888. float a = min( lerpFactor, 1.0 - lerpFactor );
  3889. vec3 cases = vec3(
  3890. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3891. ( x - 0.5 * a ) / ( 1.0 - a ),
  3892. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3893. );
  3894. float threshold = ( x < ( 1.0 - a ) )
  3895. ? ( ( x < a ) ? cases.x : cases.y )
  3896. : cases.z;
  3897. return clamp( threshold , 1.0e-6, 1.0 );
  3898. }
  3899. #endif`,E1e=`#ifdef USE_ALPHAMAP
  3900. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3901. #endif`,D1e=`#ifdef USE_ALPHAMAP
  3902. uniform sampler2D alphaMap;
  3903. #endif`,R1e=`#ifdef USE_ALPHATEST
  3904. if ( diffuseColor.a < alphaTest ) discard;
  3905. #endif`,F1e=`#ifdef USE_ALPHATEST
  3906. uniform float alphaTest;
  3907. #endif`,L1e=`#ifdef USE_AOMAP
  3908. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3909. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3910. #if defined( USE_CLEARCOAT )
  3911. clearcoatSpecularIndirect *= ambientOcclusion;
  3912. #endif
  3913. #if defined( USE_SHEEN )
  3914. sheenSpecularIndirect *= ambientOcclusion;
  3915. #endif
  3916. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3917. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3918. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3919. #endif
  3920. #endif`,O1e=`#ifdef USE_AOMAP
  3921. uniform sampler2D aoMap;
  3922. uniform float aoMapIntensity;
  3923. #endif`,I1e=`#ifdef USE_BATCHING
  3924. attribute float batchId;
  3925. uniform highp sampler2D batchingTexture;
  3926. mat4 getBatchingMatrix( const in float i ) {
  3927. int size = textureSize( batchingTexture, 0 ).x;
  3928. int j = int( i ) * 4;
  3929. int x = j % size;
  3930. int y = j / size;
  3931. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  3932. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  3933. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  3934. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  3935. return mat4( v1, v2, v3, v4 );
  3936. }
  3937. #endif`,z1e=`#ifdef USE_BATCHING
  3938. mat4 batchingMatrix = getBatchingMatrix( batchId );
  3939. #endif`,U1e=`vec3 transformed = vec3( position );
  3940. #ifdef USE_ALPHAHASH
  3941. vPosition = vec3( position );
  3942. #endif`,B1e=`vec3 objectNormal = vec3( normal );
  3943. #ifdef USE_TANGENT
  3944. vec3 objectTangent = vec3( tangent.xyz );
  3945. #endif`,H1e=`float G_BlinnPhong_Implicit( ) {
  3946. return 0.25;
  3947. }
  3948. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  3949. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  3950. }
  3951. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  3952. vec3 halfDir = normalize( lightDir + viewDir );
  3953. float dotNH = saturate( dot( normal, halfDir ) );
  3954. float dotVH = saturate( dot( viewDir, halfDir ) );
  3955. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  3956. float G = G_BlinnPhong_Implicit( );
  3957. float D = D_BlinnPhong( shininess, dotNH );
  3958. return F * ( G * D );
  3959. } // validated`,$1e=`#ifdef USE_IRIDESCENCE
  3960. const mat3 XYZ_TO_REC709 = mat3(
  3961. 3.2404542, -0.9692660, 0.0556434,
  3962. -1.5371385, 1.8760108, -0.2040259,
  3963. -0.4985314, 0.0415560, 1.0572252
  3964. );
  3965. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  3966. vec3 sqrtF0 = sqrt( fresnel0 );
  3967. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  3968. }
  3969. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  3970. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  3971. }
  3972. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  3973. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  3974. }
  3975. vec3 evalSensitivity( float OPD, vec3 shift ) {
  3976. float phase = 2.0 * PI * OPD * 1.0e-9;
  3977. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  3978. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  3979. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  3980. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  3981. xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
  3982. xyz /= 1.0685e-7;
  3983. vec3 rgb = XYZ_TO_REC709 * xyz;
  3984. return rgb;
  3985. }
  3986. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  3987. vec3 I;
  3988. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  3989. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  3990. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  3991. if ( cosTheta2Sq < 0.0 ) {
  3992. return vec3( 1.0 );
  3993. }
  3994. float cosTheta2 = sqrt( cosTheta2Sq );
  3995. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  3996. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  3997. float T121 = 1.0 - R12;
  3998. float phi12 = 0.0;
  3999. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4000. float phi21 = PI - phi12;
  4001. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4002. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4003. vec3 phi23 = vec3( 0.0 );
  4004. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4005. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4006. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4007. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4008. vec3 phi = vec3( phi21 ) + phi23;
  4009. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4010. vec3 r123 = sqrt( R123 );
  4011. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4012. vec3 C0 = R12 + Rs;
  4013. I = C0;
  4014. vec3 Cm = Rs - T121;
  4015. for ( int m = 1; m <= 2; ++ m ) {
  4016. Cm *= r123;
  4017. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4018. I += Cm * Sm;
  4019. }
  4020. return max( I, vec3( 0.0 ) );
  4021. }
  4022. #endif`,V1e=`#ifdef USE_BUMPMAP
  4023. uniform sampler2D bumpMap;
  4024. uniform float bumpScale;
  4025. vec2 dHdxy_fwd() {
  4026. vec2 dSTdx = dFdx( vBumpMapUv );
  4027. vec2 dSTdy = dFdy( vBumpMapUv );
  4028. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4029. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4030. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4031. return vec2( dBx, dBy );
  4032. }
  4033. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4034. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4035. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4036. vec3 vN = surf_norm;
  4037. vec3 R1 = cross( vSigmaY, vN );
  4038. vec3 R2 = cross( vN, vSigmaX );
  4039. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4040. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4041. return normalize( abs( fDet ) * surf_norm - vGrad );
  4042. }
  4043. #endif`,q1e=`#if NUM_CLIPPING_PLANES > 0
  4044. vec4 plane;
  4045. #pragma unroll_loop_start
  4046. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4047. plane = clippingPlanes[ i ];
  4048. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4049. }
  4050. #pragma unroll_loop_end
  4051. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4052. bool clipped = true;
  4053. #pragma unroll_loop_start
  4054. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4055. plane = clippingPlanes[ i ];
  4056. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4057. }
  4058. #pragma unroll_loop_end
  4059. if ( clipped ) discard;
  4060. #endif
  4061. #endif`,G1e=`#if NUM_CLIPPING_PLANES > 0
  4062. varying vec3 vClipPosition;
  4063. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4064. #endif`,W1e=`#if NUM_CLIPPING_PLANES > 0
  4065. varying vec3 vClipPosition;
  4066. #endif`,K1e=`#if NUM_CLIPPING_PLANES > 0
  4067. vClipPosition = - mvPosition.xyz;
  4068. #endif`,Y1e=`#if defined( USE_COLOR_ALPHA )
  4069. diffuseColor *= vColor;
  4070. #elif defined( USE_COLOR )
  4071. diffuseColor.rgb *= vColor;
  4072. #endif`,X1e=`#if defined( USE_COLOR_ALPHA )
  4073. varying vec4 vColor;
  4074. #elif defined( USE_COLOR )
  4075. varying vec3 vColor;
  4076. #endif`,Q1e=`#if defined( USE_COLOR_ALPHA )
  4077. varying vec4 vColor;
  4078. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4079. varying vec3 vColor;
  4080. #endif`,Z1e=`#if defined( USE_COLOR_ALPHA )
  4081. vColor = vec4( 1.0 );
  4082. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4083. vColor = vec3( 1.0 );
  4084. #endif
  4085. #ifdef USE_COLOR
  4086. vColor *= color;
  4087. #endif
  4088. #ifdef USE_INSTANCING_COLOR
  4089. vColor.xyz *= instanceColor.xyz;
  4090. #endif`,J1e=`#define PI 3.141592653589793
  4091. #define PI2 6.283185307179586
  4092. #define PI_HALF 1.5707963267948966
  4093. #define RECIPROCAL_PI 0.3183098861837907
  4094. #define RECIPROCAL_PI2 0.15915494309189535
  4095. #define EPSILON 1e-6
  4096. #ifndef saturate
  4097. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4098. #endif
  4099. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4100. float pow2( const in float x ) { return x*x; }
  4101. vec3 pow2( const in vec3 x ) { return x*x; }
  4102. float pow3( const in float x ) { return x*x*x; }
  4103. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4104. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4105. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4106. highp float rand( const in vec2 uv ) {
  4107. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4108. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4109. return fract( sin( sn ) * c );
  4110. }
  4111. #ifdef HIGH_PRECISION
  4112. float precisionSafeLength( vec3 v ) { return length( v ); }
  4113. #else
  4114. float precisionSafeLength( vec3 v ) {
  4115. float maxComponent = max3( abs( v ) );
  4116. return length( v / maxComponent ) * maxComponent;
  4117. }
  4118. #endif
  4119. struct IncidentLight {
  4120. vec3 color;
  4121. vec3 direction;
  4122. bool visible;
  4123. };
  4124. struct ReflectedLight {
  4125. vec3 directDiffuse;
  4126. vec3 directSpecular;
  4127. vec3 indirectDiffuse;
  4128. vec3 indirectSpecular;
  4129. };
  4130. #ifdef USE_ALPHAHASH
  4131. varying vec3 vPosition;
  4132. #endif
  4133. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4134. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4135. }
  4136. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4137. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4138. }
  4139. mat3 transposeMat3( const in mat3 m ) {
  4140. mat3 tmp;
  4141. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4142. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4143. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4144. return tmp;
  4145. }
  4146. float luminance( const in vec3 rgb ) {
  4147. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4148. return dot( weights, rgb );
  4149. }
  4150. bool isPerspectiveMatrix( mat4 m ) {
  4151. return m[ 2 ][ 3 ] == - 1.0;
  4152. }
  4153. vec2 equirectUv( in vec3 dir ) {
  4154. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4155. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4156. return vec2( u, v );
  4157. }
  4158. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4159. return RECIPROCAL_PI * diffuseColor;
  4160. }
  4161. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4162. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4163. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4164. }
  4165. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4166. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4167. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4168. } // validated`,eNe=`#ifdef ENVMAP_TYPE_CUBE_UV
  4169. #define cubeUV_minMipLevel 4.0
  4170. #define cubeUV_minTileSize 16.0
  4171. float getFace( vec3 direction ) {
  4172. vec3 absDirection = abs( direction );
  4173. float face = - 1.0;
  4174. if ( absDirection.x > absDirection.z ) {
  4175. if ( absDirection.x > absDirection.y )
  4176. face = direction.x > 0.0 ? 0.0 : 3.0;
  4177. else
  4178. face = direction.y > 0.0 ? 1.0 : 4.0;
  4179. } else {
  4180. if ( absDirection.z > absDirection.y )
  4181. face = direction.z > 0.0 ? 2.0 : 5.0;
  4182. else
  4183. face = direction.y > 0.0 ? 1.0 : 4.0;
  4184. }
  4185. return face;
  4186. }
  4187. vec2 getUV( vec3 direction, float face ) {
  4188. vec2 uv;
  4189. if ( face == 0.0 ) {
  4190. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4191. } else if ( face == 1.0 ) {
  4192. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4193. } else if ( face == 2.0 ) {
  4194. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4195. } else if ( face == 3.0 ) {
  4196. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4197. } else if ( face == 4.0 ) {
  4198. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4199. } else {
  4200. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4201. }
  4202. return 0.5 * ( uv + 1.0 );
  4203. }
  4204. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4205. float face = getFace( direction );
  4206. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4207. mipInt = max( mipInt, cubeUV_minMipLevel );
  4208. float faceSize = exp2( mipInt );
  4209. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4210. if ( face > 2.0 ) {
  4211. uv.y += faceSize;
  4212. face -= 3.0;
  4213. }
  4214. uv.x += face * faceSize;
  4215. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4216. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4217. uv.x *= CUBEUV_TEXEL_WIDTH;
  4218. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4219. #ifdef texture2DGradEXT
  4220. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4221. #else
  4222. return texture2D( envMap, uv ).rgb;
  4223. #endif
  4224. }
  4225. #define cubeUV_r0 1.0
  4226. #define cubeUV_v0 0.339
  4227. #define cubeUV_m0 - 2.0
  4228. #define cubeUV_r1 0.8
  4229. #define cubeUV_v1 0.276
  4230. #define cubeUV_m1 - 1.0
  4231. #define cubeUV_r4 0.4
  4232. #define cubeUV_v4 0.046
  4233. #define cubeUV_m4 2.0
  4234. #define cubeUV_r5 0.305
  4235. #define cubeUV_v5 0.016
  4236. #define cubeUV_m5 3.0
  4237. #define cubeUV_r6 0.21
  4238. #define cubeUV_v6 0.0038
  4239. #define cubeUV_m6 4.0
  4240. float roughnessToMip( float roughness ) {
  4241. float mip = 0.0;
  4242. if ( roughness >= cubeUV_r1 ) {
  4243. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4244. } else if ( roughness >= cubeUV_r4 ) {
  4245. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4246. } else if ( roughness >= cubeUV_r5 ) {
  4247. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4248. } else if ( roughness >= cubeUV_r6 ) {
  4249. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4250. } else {
  4251. mip = - 2.0 * log2( 1.16 * roughness ); }
  4252. return mip;
  4253. }
  4254. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4255. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4256. float mipF = fract( mip );
  4257. float mipInt = floor( mip );
  4258. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4259. if ( mipF == 0.0 ) {
  4260. return vec4( color0, 1.0 );
  4261. } else {
  4262. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4263. return vec4( mix( color0, color1, mipF ), 1.0 );
  4264. }
  4265. }
  4266. #endif`,tNe=`vec3 transformedNormal = objectNormal;
  4267. #ifdef USE_TANGENT
  4268. vec3 transformedTangent = objectTangent;
  4269. #endif
  4270. #ifdef USE_BATCHING
  4271. mat3 bm = mat3( batchingMatrix );
  4272. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4273. transformedNormal = bm * transformedNormal;
  4274. #ifdef USE_TANGENT
  4275. transformedTangent = bm * transformedTangent;
  4276. #endif
  4277. #endif
  4278. #ifdef USE_INSTANCING
  4279. mat3 im = mat3( instanceMatrix );
  4280. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4281. transformedNormal = im * transformedNormal;
  4282. #ifdef USE_TANGENT
  4283. transformedTangent = im * transformedTangent;
  4284. #endif
  4285. #endif
  4286. transformedNormal = normalMatrix * transformedNormal;
  4287. #ifdef FLIP_SIDED
  4288. transformedNormal = - transformedNormal;
  4289. #endif
  4290. #ifdef USE_TANGENT
  4291. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4292. #ifdef FLIP_SIDED
  4293. transformedTangent = - transformedTangent;
  4294. #endif
  4295. #endif`,nNe=`#ifdef USE_DISPLACEMENTMAP
  4296. uniform sampler2D displacementMap;
  4297. uniform float displacementScale;
  4298. uniform float displacementBias;
  4299. #endif`,rNe=`#ifdef USE_DISPLACEMENTMAP
  4300. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4301. #endif`,aNe=`#ifdef USE_EMISSIVEMAP
  4302. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4303. totalEmissiveRadiance *= emissiveColor.rgb;
  4304. #endif`,iNe=`#ifdef USE_EMISSIVEMAP
  4305. uniform sampler2D emissiveMap;
  4306. #endif`,sNe="gl_FragColor = linearToOutputTexel( gl_FragColor );",oNe=`
  4307. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4308. vec3( 0.8224621, 0.177538, 0.0 ),
  4309. vec3( 0.0331941, 0.9668058, 0.0 ),
  4310. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4311. );
  4312. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4313. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4314. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4315. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4316. );
  4317. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4318. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4319. }
  4320. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4321. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4322. }
  4323. vec4 LinearTransferOETF( in vec4 value ) {
  4324. return value;
  4325. }
  4326. vec4 sRGBTransferOETF( in vec4 value ) {
  4327. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  4328. }
  4329. vec4 LinearToLinear( in vec4 value ) {
  4330. return value;
  4331. }
  4332. vec4 LinearTosRGB( in vec4 value ) {
  4333. return sRGBTransferOETF( value );
  4334. }`,lNe=`#ifdef USE_ENVMAP
  4335. #ifdef ENV_WORLDPOS
  4336. vec3 cameraToFrag;
  4337. if ( isOrthographic ) {
  4338. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4339. } else {
  4340. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4341. }
  4342. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4343. #ifdef ENVMAP_MODE_REFLECTION
  4344. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4345. #else
  4346. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4347. #endif
  4348. #else
  4349. vec3 reflectVec = vReflect;
  4350. #endif
  4351. #ifdef ENVMAP_TYPE_CUBE
  4352. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4353. #else
  4354. vec4 envColor = vec4( 0.0 );
  4355. #endif
  4356. #ifdef ENVMAP_BLENDING_MULTIPLY
  4357. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4358. #elif defined( ENVMAP_BLENDING_MIX )
  4359. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4360. #elif defined( ENVMAP_BLENDING_ADD )
  4361. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4362. #endif
  4363. #endif`,cNe=`#ifdef USE_ENVMAP
  4364. uniform float envMapIntensity;
  4365. uniform float flipEnvMap;
  4366. #ifdef ENVMAP_TYPE_CUBE
  4367. uniform samplerCube envMap;
  4368. #else
  4369. uniform sampler2D envMap;
  4370. #endif
  4371. #endif`,uNe=`#ifdef USE_ENVMAP
  4372. uniform float reflectivity;
  4373. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4374. #define ENV_WORLDPOS
  4375. #endif
  4376. #ifdef ENV_WORLDPOS
  4377. varying vec3 vWorldPosition;
  4378. uniform float refractionRatio;
  4379. #else
  4380. varying vec3 vReflect;
  4381. #endif
  4382. #endif`,dNe=`#ifdef USE_ENVMAP
  4383. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4384. #define ENV_WORLDPOS
  4385. #endif
  4386. #ifdef ENV_WORLDPOS
  4387. varying vec3 vWorldPosition;
  4388. #else
  4389. varying vec3 vReflect;
  4390. uniform float refractionRatio;
  4391. #endif
  4392. #endif`,hNe=`#ifdef USE_ENVMAP
  4393. #ifdef ENV_WORLDPOS
  4394. vWorldPosition = worldPosition.xyz;
  4395. #else
  4396. vec3 cameraToVertex;
  4397. if ( isOrthographic ) {
  4398. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4399. } else {
  4400. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4401. }
  4402. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4403. #ifdef ENVMAP_MODE_REFLECTION
  4404. vReflect = reflect( cameraToVertex, worldNormal );
  4405. #else
  4406. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4407. #endif
  4408. #endif
  4409. #endif`,mNe=`#ifdef USE_FOG
  4410. vFogDepth = - mvPosition.z;
  4411. #endif`,fNe=`#ifdef USE_FOG
  4412. varying float vFogDepth;
  4413. #endif`,pNe=`#ifdef USE_FOG
  4414. #ifdef FOG_EXP2
  4415. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4416. #else
  4417. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4418. #endif
  4419. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4420. #endif`,gNe=`#ifdef USE_FOG
  4421. uniform vec3 fogColor;
  4422. varying float vFogDepth;
  4423. #ifdef FOG_EXP2
  4424. uniform float fogDensity;
  4425. #else
  4426. uniform float fogNear;
  4427. uniform float fogFar;
  4428. #endif
  4429. #endif`,bNe=`#ifdef USE_GRADIENTMAP
  4430. uniform sampler2D gradientMap;
  4431. #endif
  4432. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4433. float dotNL = dot( normal, lightDirection );
  4434. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4435. #ifdef USE_GRADIENTMAP
  4436. return vec3( texture2D( gradientMap, coord ).r );
  4437. #else
  4438. vec2 fw = fwidth( coord ) * 0.5;
  4439. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4440. #endif
  4441. }`,xNe=`#ifdef USE_LIGHTMAP
  4442. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4443. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4444. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4445. #endif`,yNe=`#ifdef USE_LIGHTMAP
  4446. uniform sampler2D lightMap;
  4447. uniform float lightMapIntensity;
  4448. #endif`,vNe=`LambertMaterial material;
  4449. material.diffuseColor = diffuseColor.rgb;
  4450. material.specularStrength = specularStrength;`,wNe=`varying vec3 vViewPosition;
  4451. struct LambertMaterial {
  4452. vec3 diffuseColor;
  4453. float specularStrength;
  4454. };
  4455. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  4456. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4457. vec3 irradiance = dotNL * directLight.color;
  4458. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4459. }
  4460. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  4461. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4462. }
  4463. #define RE_Direct RE_Direct_Lambert
  4464. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,SNe=`uniform bool receiveShadow;
  4465. uniform vec3 ambientLightColor;
  4466. #if defined( USE_LIGHT_PROBES )
  4467. uniform vec3 lightProbe[ 9 ];
  4468. #endif
  4469. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4470. float x = normal.x, y = normal.y, z = normal.z;
  4471. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4472. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4473. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4474. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4475. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4476. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4477. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4478. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4479. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4480. return result;
  4481. }
  4482. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4483. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4484. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4485. return irradiance;
  4486. }
  4487. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4488. vec3 irradiance = ambientLightColor;
  4489. return irradiance;
  4490. }
  4491. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4492. #if defined ( LEGACY_LIGHTS )
  4493. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4494. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4495. }
  4496. return 1.0;
  4497. #else
  4498. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4499. if ( cutoffDistance > 0.0 ) {
  4500. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4501. }
  4502. return distanceFalloff;
  4503. #endif
  4504. }
  4505. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4506. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4507. }
  4508. #if NUM_DIR_LIGHTS > 0
  4509. struct DirectionalLight {
  4510. vec3 direction;
  4511. vec3 color;
  4512. };
  4513. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4514. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4515. light.color = directionalLight.color;
  4516. light.direction = directionalLight.direction;
  4517. light.visible = true;
  4518. }
  4519. #endif
  4520. #if NUM_POINT_LIGHTS > 0
  4521. struct PointLight {
  4522. vec3 position;
  4523. vec3 color;
  4524. float distance;
  4525. float decay;
  4526. };
  4527. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4528. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4529. vec3 lVector = pointLight.position - geometryPosition;
  4530. light.direction = normalize( lVector );
  4531. float lightDistance = length( lVector );
  4532. light.color = pointLight.color;
  4533. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4534. light.visible = ( light.color != vec3( 0.0 ) );
  4535. }
  4536. #endif
  4537. #if NUM_SPOT_LIGHTS > 0
  4538. struct SpotLight {
  4539. vec3 position;
  4540. vec3 direction;
  4541. vec3 color;
  4542. float distance;
  4543. float decay;
  4544. float coneCos;
  4545. float penumbraCos;
  4546. };
  4547. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4548. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4549. vec3 lVector = spotLight.position - geometryPosition;
  4550. light.direction = normalize( lVector );
  4551. float angleCos = dot( light.direction, spotLight.direction );
  4552. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4553. if ( spotAttenuation > 0.0 ) {
  4554. float lightDistance = length( lVector );
  4555. light.color = spotLight.color * spotAttenuation;
  4556. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4557. light.visible = ( light.color != vec3( 0.0 ) );
  4558. } else {
  4559. light.color = vec3( 0.0 );
  4560. light.visible = false;
  4561. }
  4562. }
  4563. #endif
  4564. #if NUM_RECT_AREA_LIGHTS > 0
  4565. struct RectAreaLight {
  4566. vec3 color;
  4567. vec3 position;
  4568. vec3 halfWidth;
  4569. vec3 halfHeight;
  4570. };
  4571. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4572. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4573. #endif
  4574. #if NUM_HEMI_LIGHTS > 0
  4575. struct HemisphereLight {
  4576. vec3 direction;
  4577. vec3 skyColor;
  4578. vec3 groundColor;
  4579. };
  4580. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4581. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4582. float dotNL = dot( normal, hemiLight.direction );
  4583. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4584. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4585. return irradiance;
  4586. }
  4587. #endif`,_Ne=`#ifdef USE_ENVMAP
  4588. vec3 getIBLIrradiance( const in vec3 normal ) {
  4589. #ifdef ENVMAP_TYPE_CUBE_UV
  4590. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4591. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4592. return PI * envMapColor.rgb * envMapIntensity;
  4593. #else
  4594. return vec3( 0.0 );
  4595. #endif
  4596. }
  4597. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4598. #ifdef ENVMAP_TYPE_CUBE_UV
  4599. vec3 reflectVec = reflect( - viewDir, normal );
  4600. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4601. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4602. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4603. return envMapColor.rgb * envMapIntensity;
  4604. #else
  4605. return vec3( 0.0 );
  4606. #endif
  4607. }
  4608. #ifdef USE_ANISOTROPY
  4609. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4610. #ifdef ENVMAP_TYPE_CUBE_UV
  4611. vec3 bentNormal = cross( bitangent, viewDir );
  4612. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4613. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4614. return getIBLRadiance( viewDir, bentNormal, roughness );
  4615. #else
  4616. return vec3( 0.0 );
  4617. #endif
  4618. }
  4619. #endif
  4620. #endif`,NNe=`ToonMaterial material;
  4621. material.diffuseColor = diffuseColor.rgb;`,kNe=`varying vec3 vViewPosition;
  4622. struct ToonMaterial {
  4623. vec3 diffuseColor;
  4624. };
  4625. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  4626. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4627. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4628. }
  4629. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  4630. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4631. }
  4632. #define RE_Direct RE_Direct_Toon
  4633. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,CNe=`BlinnPhongMaterial material;
  4634. material.diffuseColor = diffuseColor.rgb;
  4635. material.specularColor = specular;
  4636. material.specularShininess = shininess;
  4637. material.specularStrength = specularStrength;`,ANe=`varying vec3 vViewPosition;
  4638. struct BlinnPhongMaterial {
  4639. vec3 diffuseColor;
  4640. vec3 specularColor;
  4641. float specularShininess;
  4642. float specularStrength;
  4643. };
  4644. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  4645. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4646. vec3 irradiance = dotNL * directLight.color;
  4647. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4648. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4649. }
  4650. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  4651. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4652. }
  4653. #define RE_Direct RE_Direct_BlinnPhong
  4654. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,TNe=`PhysicalMaterial material;
  4655. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4656. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4657. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4658. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4659. material.roughness = min( material.roughness, 1.0 );
  4660. #ifdef IOR
  4661. material.ior = ior;
  4662. #ifdef USE_SPECULAR
  4663. float specularIntensityFactor = specularIntensity;
  4664. vec3 specularColorFactor = specularColor;
  4665. #ifdef USE_SPECULAR_COLORMAP
  4666. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4667. #endif
  4668. #ifdef USE_SPECULAR_INTENSITYMAP
  4669. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4670. #endif
  4671. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4672. #else
  4673. float specularIntensityFactor = 1.0;
  4674. vec3 specularColorFactor = vec3( 1.0 );
  4675. material.specularF90 = 1.0;
  4676. #endif
  4677. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4678. #else
  4679. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4680. material.specularF90 = 1.0;
  4681. #endif
  4682. #ifdef USE_CLEARCOAT
  4683. material.clearcoat = clearcoat;
  4684. material.clearcoatRoughness = clearcoatRoughness;
  4685. material.clearcoatF0 = vec3( 0.04 );
  4686. material.clearcoatF90 = 1.0;
  4687. #ifdef USE_CLEARCOATMAP
  4688. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4689. #endif
  4690. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4691. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4692. #endif
  4693. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4694. material.clearcoatRoughness += geometryRoughness;
  4695. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4696. #endif
  4697. #ifdef USE_IRIDESCENCE
  4698. material.iridescence = iridescence;
  4699. material.iridescenceIOR = iridescenceIOR;
  4700. #ifdef USE_IRIDESCENCEMAP
  4701. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4702. #endif
  4703. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4704. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4705. #else
  4706. material.iridescenceThickness = iridescenceThicknessMaximum;
  4707. #endif
  4708. #endif
  4709. #ifdef USE_SHEEN
  4710. material.sheenColor = sheenColor;
  4711. #ifdef USE_SHEEN_COLORMAP
  4712. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4713. #endif
  4714. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4715. #ifdef USE_SHEEN_ROUGHNESSMAP
  4716. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4717. #endif
  4718. #endif
  4719. #ifdef USE_ANISOTROPY
  4720. #ifdef USE_ANISOTROPYMAP
  4721. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4722. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4723. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4724. #else
  4725. vec2 anisotropyV = anisotropyVector;
  4726. #endif
  4727. material.anisotropy = length( anisotropyV );
  4728. if( material.anisotropy == 0.0 ) {
  4729. anisotropyV = vec2( 1.0, 0.0 );
  4730. } else {
  4731. anisotropyV /= material.anisotropy;
  4732. material.anisotropy = saturate( material.anisotropy );
  4733. }
  4734. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4735. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4736. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4737. #endif`,MNe=`struct PhysicalMaterial {
  4738. vec3 diffuseColor;
  4739. float roughness;
  4740. vec3 specularColor;
  4741. float specularF90;
  4742. #ifdef USE_CLEARCOAT
  4743. float clearcoat;
  4744. float clearcoatRoughness;
  4745. vec3 clearcoatF0;
  4746. float clearcoatF90;
  4747. #endif
  4748. #ifdef USE_IRIDESCENCE
  4749. float iridescence;
  4750. float iridescenceIOR;
  4751. float iridescenceThickness;
  4752. vec3 iridescenceFresnel;
  4753. vec3 iridescenceF0;
  4754. #endif
  4755. #ifdef USE_SHEEN
  4756. vec3 sheenColor;
  4757. float sheenRoughness;
  4758. #endif
  4759. #ifdef IOR
  4760. float ior;
  4761. #endif
  4762. #ifdef USE_TRANSMISSION
  4763. float transmission;
  4764. float transmissionAlpha;
  4765. float thickness;
  4766. float attenuationDistance;
  4767. vec3 attenuationColor;
  4768. #endif
  4769. #ifdef USE_ANISOTROPY
  4770. float anisotropy;
  4771. float alphaT;
  4772. vec3 anisotropyT;
  4773. vec3 anisotropyB;
  4774. #endif
  4775. };
  4776. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4777. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4778. vec3 sheenSpecularDirect = vec3( 0.0 );
  4779. vec3 sheenSpecularIndirect = vec3(0.0 );
  4780. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4781. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4782. float x2 = x * x;
  4783. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4784. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4785. }
  4786. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4787. float a2 = pow2( alpha );
  4788. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4789. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4790. return 0.5 / max( gv + gl, EPSILON );
  4791. }
  4792. float D_GGX( const in float alpha, const in float dotNH ) {
  4793. float a2 = pow2( alpha );
  4794. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4795. return RECIPROCAL_PI * a2 / pow2( denom );
  4796. }
  4797. #ifdef USE_ANISOTROPY
  4798. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  4799. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4800. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4801. float v = 0.5 / ( gv + gl );
  4802. return saturate(v);
  4803. }
  4804. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4805. float a2 = alphaT * alphaB;
  4806. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4807. highp float v2 = dot( v, v );
  4808. float w2 = a2 / v2;
  4809. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4810. }
  4811. #endif
  4812. #ifdef USE_CLEARCOAT
  4813. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4814. vec3 f0 = material.clearcoatF0;
  4815. float f90 = material.clearcoatF90;
  4816. float roughness = material.clearcoatRoughness;
  4817. float alpha = pow2( roughness );
  4818. vec3 halfDir = normalize( lightDir + viewDir );
  4819. float dotNL = saturate( dot( normal, lightDir ) );
  4820. float dotNV = saturate( dot( normal, viewDir ) );
  4821. float dotNH = saturate( dot( normal, halfDir ) );
  4822. float dotVH = saturate( dot( viewDir, halfDir ) );
  4823. vec3 F = F_Schlick( f0, f90, dotVH );
  4824. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4825. float D = D_GGX( alpha, dotNH );
  4826. return F * ( V * D );
  4827. }
  4828. #endif
  4829. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4830. vec3 f0 = material.specularColor;
  4831. float f90 = material.specularF90;
  4832. float roughness = material.roughness;
  4833. float alpha = pow2( roughness );
  4834. vec3 halfDir = normalize( lightDir + viewDir );
  4835. float dotNL = saturate( dot( normal, lightDir ) );
  4836. float dotNV = saturate( dot( normal, viewDir ) );
  4837. float dotNH = saturate( dot( normal, halfDir ) );
  4838. float dotVH = saturate( dot( viewDir, halfDir ) );
  4839. vec3 F = F_Schlick( f0, f90, dotVH );
  4840. #ifdef USE_IRIDESCENCE
  4841. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4842. #endif
  4843. #ifdef USE_ANISOTROPY
  4844. float dotTL = dot( material.anisotropyT, lightDir );
  4845. float dotTV = dot( material.anisotropyT, viewDir );
  4846. float dotTH = dot( material.anisotropyT, halfDir );
  4847. float dotBL = dot( material.anisotropyB, lightDir );
  4848. float dotBV = dot( material.anisotropyB, viewDir );
  4849. float dotBH = dot( material.anisotropyB, halfDir );
  4850. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4851. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4852. #else
  4853. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4854. float D = D_GGX( alpha, dotNH );
  4855. #endif
  4856. return F * ( V * D );
  4857. }
  4858. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4859. const float LUT_SIZE = 64.0;
  4860. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4861. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4862. float dotNV = saturate( dot( N, V ) );
  4863. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4864. uv = uv * LUT_SCALE + LUT_BIAS;
  4865. return uv;
  4866. }
  4867. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4868. float l = length( f );
  4869. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4870. }
  4871. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4872. float x = dot( v1, v2 );
  4873. float y = abs( x );
  4874. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4875. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4876. float v = a / b;
  4877. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4878. return cross( v1, v2 ) * theta_sintheta;
  4879. }
  4880. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4881. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4882. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4883. vec3 lightNormal = cross( v1, v2 );
  4884. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4885. vec3 T1, T2;
  4886. T1 = normalize( V - N * dot( V, N ) );
  4887. T2 = - cross( N, T1 );
  4888. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4889. vec3 coords[ 4 ];
  4890. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4891. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4892. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4893. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4894. coords[ 0 ] = normalize( coords[ 0 ] );
  4895. coords[ 1 ] = normalize( coords[ 1 ] );
  4896. coords[ 2 ] = normalize( coords[ 2 ] );
  4897. coords[ 3 ] = normalize( coords[ 3 ] );
  4898. vec3 vectorFormFactor = vec3( 0.0 );
  4899. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4900. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4901. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4902. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4903. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4904. return vec3( result );
  4905. }
  4906. #if defined( USE_SHEEN )
  4907. float D_Charlie( float roughness, float dotNH ) {
  4908. float alpha = pow2( roughness );
  4909. float invAlpha = 1.0 / alpha;
  4910. float cos2h = dotNH * dotNH;
  4911. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4912. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4913. }
  4914. float V_Neubelt( float dotNV, float dotNL ) {
  4915. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4916. }
  4917. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4918. vec3 halfDir = normalize( lightDir + viewDir );
  4919. float dotNL = saturate( dot( normal, lightDir ) );
  4920. float dotNV = saturate( dot( normal, viewDir ) );
  4921. float dotNH = saturate( dot( normal, halfDir ) );
  4922. float D = D_Charlie( sheenRoughness, dotNH );
  4923. float V = V_Neubelt( dotNV, dotNL );
  4924. return sheenColor * ( D * V );
  4925. }
  4926. #endif
  4927. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4928. float dotNV = saturate( dot( normal, viewDir ) );
  4929. float r2 = roughness * roughness;
  4930. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  4931. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  4932. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  4933. return saturate( DG * RECIPROCAL_PI );
  4934. }
  4935. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4936. float dotNV = saturate( dot( normal, viewDir ) );
  4937. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  4938. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  4939. vec4 r = roughness * c0 + c1;
  4940. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  4941. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  4942. return fab;
  4943. }
  4944. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  4945. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4946. return specularColor * fab.x + specularF90 * fab.y;
  4947. }
  4948. #ifdef USE_IRIDESCENCE
  4949. void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  4950. #else
  4951. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  4952. #endif
  4953. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4954. #ifdef USE_IRIDESCENCE
  4955. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  4956. #else
  4957. vec3 Fr = specularColor;
  4958. #endif
  4959. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  4960. float Ess = fab.x + fab.y;
  4961. float Ems = 1.0 - Ess;
  4962. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  4963. singleScatter += FssEss;
  4964. multiScatter += Fms * Ems;
  4965. }
  4966. #if NUM_RECT_AREA_LIGHTS > 0
  4967. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  4968. vec3 normal = geometryNormal;
  4969. vec3 viewDir = geometryViewDir;
  4970. vec3 position = geometryPosition;
  4971. vec3 lightPos = rectAreaLight.position;
  4972. vec3 halfWidth = rectAreaLight.halfWidth;
  4973. vec3 halfHeight = rectAreaLight.halfHeight;
  4974. vec3 lightColor = rectAreaLight.color;
  4975. float roughness = material.roughness;
  4976. vec3 rectCoords[ 4 ];
  4977. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  4978. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  4979. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  4980. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  4981. vec4 t1 = texture2D( ltc_1, uv );
  4982. vec4 t2 = texture2D( ltc_2, uv );
  4983. mat3 mInv = mat3(
  4984. vec3( t1.x, 0, t1.y ),
  4985. vec3( 0, 1, 0 ),
  4986. vec3( t1.z, 0, t1.w )
  4987. );
  4988. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  4989. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  4990. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  4991. }
  4992. #endif
  4993. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  4994. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4995. vec3 irradiance = dotNL * directLight.color;
  4996. #ifdef USE_CLEARCOAT
  4997. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  4998. vec3 ccIrradiance = dotNLcc * directLight.color;
  4999. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5000. #endif
  5001. #ifdef USE_SHEEN
  5002. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5003. #endif
  5004. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5005. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5006. }
  5007. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  5008. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5009. }
  5010. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  5011. #ifdef USE_CLEARCOAT
  5012. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5013. #endif
  5014. #ifdef USE_SHEEN
  5015. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5016. #endif
  5017. vec3 singleScattering = vec3( 0.0 );
  5018. vec3 multiScattering = vec3( 0.0 );
  5019. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5020. #ifdef USE_IRIDESCENCE
  5021. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5022. #else
  5023. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5024. #endif
  5025. vec3 totalScattering = singleScattering + multiScattering;
  5026. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5027. reflectedLight.indirectSpecular += radiance * singleScattering;
  5028. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5029. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5030. }
  5031. #define RE_Direct RE_Direct_Physical
  5032. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5033. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5034. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5035. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5036. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5037. }`,PNe=`
  5038. vec3 geometryPosition = - vViewPosition;
  5039. vec3 geometryNormal = normal;
  5040. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5041. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5042. #ifdef USE_CLEARCOAT
  5043. geometryClearcoatNormal = clearcoatNormal;
  5044. #endif
  5045. #ifdef USE_IRIDESCENCE
  5046. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5047. if ( material.iridescenceThickness == 0.0 ) {
  5048. material.iridescence = 0.0;
  5049. } else {
  5050. material.iridescence = saturate( material.iridescence );
  5051. }
  5052. if ( material.iridescence > 0.0 ) {
  5053. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5054. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5055. }
  5056. #endif
  5057. IncidentLight directLight;
  5058. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5059. PointLight pointLight;
  5060. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5061. PointLightShadow pointLightShadow;
  5062. #endif
  5063. #pragma unroll_loop_start
  5064. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5065. pointLight = pointLights[ i ];
  5066. getPointLightInfo( pointLight, geometryPosition, directLight );
  5067. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5068. pointLightShadow = pointLightShadows[ i ];
  5069. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5070. #endif
  5071. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5072. }
  5073. #pragma unroll_loop_end
  5074. #endif
  5075. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5076. SpotLight spotLight;
  5077. vec4 spotColor;
  5078. vec3 spotLightCoord;
  5079. bool inSpotLightMap;
  5080. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5081. SpotLightShadow spotLightShadow;
  5082. #endif
  5083. #pragma unroll_loop_start
  5084. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5085. spotLight = spotLights[ i ];
  5086. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5087. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5088. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5089. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5090. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5091. #else
  5092. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5093. #endif
  5094. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5095. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5096. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5097. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5098. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5099. #endif
  5100. #undef SPOT_LIGHT_MAP_INDEX
  5101. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5102. spotLightShadow = spotLightShadows[ i ];
  5103. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5104. #endif
  5105. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5106. }
  5107. #pragma unroll_loop_end
  5108. #endif
  5109. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5110. DirectionalLight directionalLight;
  5111. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5112. DirectionalLightShadow directionalLightShadow;
  5113. #endif
  5114. #pragma unroll_loop_start
  5115. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5116. directionalLight = directionalLights[ i ];
  5117. getDirectionalLightInfo( directionalLight, directLight );
  5118. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5119. directionalLightShadow = directionalLightShadows[ i ];
  5120. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5121. #endif
  5122. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5123. }
  5124. #pragma unroll_loop_end
  5125. #endif
  5126. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5127. RectAreaLight rectAreaLight;
  5128. #pragma unroll_loop_start
  5129. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5130. rectAreaLight = rectAreaLights[ i ];
  5131. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5132. }
  5133. #pragma unroll_loop_end
  5134. #endif
  5135. #if defined( RE_IndirectDiffuse )
  5136. vec3 iblIrradiance = vec3( 0.0 );
  5137. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5138. #if defined( USE_LIGHT_PROBES )
  5139. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5140. #endif
  5141. #if ( NUM_HEMI_LIGHTS > 0 )
  5142. #pragma unroll_loop_start
  5143. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5144. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5145. }
  5146. #pragma unroll_loop_end
  5147. #endif
  5148. #endif
  5149. #if defined( RE_IndirectSpecular )
  5150. vec3 radiance = vec3( 0.0 );
  5151. vec3 clearcoatRadiance = vec3( 0.0 );
  5152. #endif`,jNe=`#if defined( RE_IndirectDiffuse )
  5153. #ifdef USE_LIGHTMAP
  5154. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5155. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5156. irradiance += lightMapIrradiance;
  5157. #endif
  5158. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5159. iblIrradiance += getIBLIrradiance( geometryNormal );
  5160. #endif
  5161. #endif
  5162. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5163. #ifdef USE_ANISOTROPY
  5164. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5165. #else
  5166. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5167. #endif
  5168. #ifdef USE_CLEARCOAT
  5169. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5170. #endif
  5171. #endif`,ENe=`#if defined( RE_IndirectDiffuse )
  5172. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5173. #endif
  5174. #if defined( RE_IndirectSpecular )
  5175. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5176. #endif`,DNe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5177. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5178. #endif`,RNe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5179. uniform float logDepthBufFC;
  5180. varying float vFragDepth;
  5181. varying float vIsPerspective;
  5182. #endif`,FNe=`#ifdef USE_LOGDEPTHBUF
  5183. #ifdef USE_LOGDEPTHBUF_EXT
  5184. varying float vFragDepth;
  5185. varying float vIsPerspective;
  5186. #else
  5187. uniform float logDepthBufFC;
  5188. #endif
  5189. #endif`,LNe=`#ifdef USE_LOGDEPTHBUF
  5190. #ifdef USE_LOGDEPTHBUF_EXT
  5191. vFragDepth = 1.0 + gl_Position.w;
  5192. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5193. #else
  5194. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5195. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5196. gl_Position.z *= gl_Position.w;
  5197. }
  5198. #endif
  5199. #endif`,ONe=`#ifdef USE_MAP
  5200. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5201. #ifdef DECODE_VIDEO_TEXTURE
  5202. sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
  5203. #endif
  5204. diffuseColor *= sampledDiffuseColor;
  5205. #endif`,INe=`#ifdef USE_MAP
  5206. uniform sampler2D map;
  5207. #endif`,zNe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5208. #if defined( USE_POINTS_UV )
  5209. vec2 uv = vUv;
  5210. #else
  5211. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5212. #endif
  5213. #endif
  5214. #ifdef USE_MAP
  5215. diffuseColor *= texture2D( map, uv );
  5216. #endif
  5217. #ifdef USE_ALPHAMAP
  5218. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5219. #endif`,UNe=`#if defined( USE_POINTS_UV )
  5220. varying vec2 vUv;
  5221. #else
  5222. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5223. uniform mat3 uvTransform;
  5224. #endif
  5225. #endif
  5226. #ifdef USE_MAP
  5227. uniform sampler2D map;
  5228. #endif
  5229. #ifdef USE_ALPHAMAP
  5230. uniform sampler2D alphaMap;
  5231. #endif`,BNe=`float metalnessFactor = metalness;
  5232. #ifdef USE_METALNESSMAP
  5233. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5234. metalnessFactor *= texelMetalness.b;
  5235. #endif`,HNe=`#ifdef USE_METALNESSMAP
  5236. uniform sampler2D metalnessMap;
  5237. #endif`,$Ne=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5238. vColor *= morphTargetBaseInfluence;
  5239. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5240. #if defined( USE_COLOR_ALPHA )
  5241. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5242. #elif defined( USE_COLOR )
  5243. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5244. #endif
  5245. }
  5246. #endif`,VNe=`#ifdef USE_MORPHNORMALS
  5247. objectNormal *= morphTargetBaseInfluence;
  5248. #ifdef MORPHTARGETS_TEXTURE
  5249. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5250. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5251. }
  5252. #else
  5253. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5254. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5255. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5256. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5257. #endif
  5258. #endif`,qNe=`#ifdef USE_MORPHTARGETS
  5259. uniform float morphTargetBaseInfluence;
  5260. #ifdef MORPHTARGETS_TEXTURE
  5261. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5262. uniform sampler2DArray morphTargetsTexture;
  5263. uniform ivec2 morphTargetsTextureSize;
  5264. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5265. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5266. int y = texelIndex / morphTargetsTextureSize.x;
  5267. int x = texelIndex - y * morphTargetsTextureSize.x;
  5268. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5269. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5270. }
  5271. #else
  5272. #ifndef USE_MORPHNORMALS
  5273. uniform float morphTargetInfluences[ 8 ];
  5274. #else
  5275. uniform float morphTargetInfluences[ 4 ];
  5276. #endif
  5277. #endif
  5278. #endif`,GNe=`#ifdef USE_MORPHTARGETS
  5279. transformed *= morphTargetBaseInfluence;
  5280. #ifdef MORPHTARGETS_TEXTURE
  5281. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5282. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5283. }
  5284. #else
  5285. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5286. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5287. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5288. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5289. #ifndef USE_MORPHNORMALS
  5290. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5291. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5292. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5293. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5294. #endif
  5295. #endif
  5296. #endif`,WNe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5297. #ifdef FLAT_SHADED
  5298. vec3 fdx = dFdx( vViewPosition );
  5299. vec3 fdy = dFdy( vViewPosition );
  5300. vec3 normal = normalize( cross( fdx, fdy ) );
  5301. #else
  5302. vec3 normal = normalize( vNormal );
  5303. #ifdef DOUBLE_SIDED
  5304. normal *= faceDirection;
  5305. #endif
  5306. #endif
  5307. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5308. #ifdef USE_TANGENT
  5309. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5310. #else
  5311. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5312. #if defined( USE_NORMALMAP )
  5313. vNormalMapUv
  5314. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5315. vClearcoatNormalMapUv
  5316. #else
  5317. vUv
  5318. #endif
  5319. );
  5320. #endif
  5321. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5322. tbn[0] *= faceDirection;
  5323. tbn[1] *= faceDirection;
  5324. #endif
  5325. #endif
  5326. #ifdef USE_CLEARCOAT_NORMALMAP
  5327. #ifdef USE_TANGENT
  5328. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5329. #else
  5330. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5331. #endif
  5332. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5333. tbn2[0] *= faceDirection;
  5334. tbn2[1] *= faceDirection;
  5335. #endif
  5336. #endif
  5337. vec3 nonPerturbedNormal = normal;`,KNe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5338. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5339. #ifdef FLIP_SIDED
  5340. normal = - normal;
  5341. #endif
  5342. #ifdef DOUBLE_SIDED
  5343. normal = normal * faceDirection;
  5344. #endif
  5345. normal = normalize( normalMatrix * normal );
  5346. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5347. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5348. mapN.xy *= normalScale;
  5349. normal = normalize( tbn * mapN );
  5350. #elif defined( USE_BUMPMAP )
  5351. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5352. #endif`,YNe=`#ifndef FLAT_SHADED
  5353. varying vec3 vNormal;
  5354. #ifdef USE_TANGENT
  5355. varying vec3 vTangent;
  5356. varying vec3 vBitangent;
  5357. #endif
  5358. #endif`,XNe=`#ifndef FLAT_SHADED
  5359. varying vec3 vNormal;
  5360. #ifdef USE_TANGENT
  5361. varying vec3 vTangent;
  5362. varying vec3 vBitangent;
  5363. #endif
  5364. #endif`,QNe=`#ifndef FLAT_SHADED
  5365. vNormal = normalize( transformedNormal );
  5366. #ifdef USE_TANGENT
  5367. vTangent = normalize( transformedTangent );
  5368. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5369. #endif
  5370. #endif`,ZNe=`#ifdef USE_NORMALMAP
  5371. uniform sampler2D normalMap;
  5372. uniform vec2 normalScale;
  5373. #endif
  5374. #ifdef USE_NORMALMAP_OBJECTSPACE
  5375. uniform mat3 normalMatrix;
  5376. #endif
  5377. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5378. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5379. vec3 q0 = dFdx( eye_pos.xyz );
  5380. vec3 q1 = dFdy( eye_pos.xyz );
  5381. vec2 st0 = dFdx( uv.st );
  5382. vec2 st1 = dFdy( uv.st );
  5383. vec3 N = surf_norm;
  5384. vec3 q1perp = cross( q1, N );
  5385. vec3 q0perp = cross( N, q0 );
  5386. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5387. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5388. float det = max( dot( T, T ), dot( B, B ) );
  5389. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5390. return mat3( T * scale, B * scale, N );
  5391. }
  5392. #endif`,JNe=`#ifdef USE_CLEARCOAT
  5393. vec3 clearcoatNormal = nonPerturbedNormal;
  5394. #endif`,eke=`#ifdef USE_CLEARCOAT_NORMALMAP
  5395. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5396. clearcoatMapN.xy *= clearcoatNormalScale;
  5397. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5398. #endif`,tke=`#ifdef USE_CLEARCOATMAP
  5399. uniform sampler2D clearcoatMap;
  5400. #endif
  5401. #ifdef USE_CLEARCOAT_NORMALMAP
  5402. uniform sampler2D clearcoatNormalMap;
  5403. uniform vec2 clearcoatNormalScale;
  5404. #endif
  5405. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5406. uniform sampler2D clearcoatRoughnessMap;
  5407. #endif`,nke=`#ifdef USE_IRIDESCENCEMAP
  5408. uniform sampler2D iridescenceMap;
  5409. #endif
  5410. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5411. uniform sampler2D iridescenceThicknessMap;
  5412. #endif`,rke=`#ifdef OPAQUE
  5413. diffuseColor.a = 1.0;
  5414. #endif
  5415. #ifdef USE_TRANSMISSION
  5416. diffuseColor.a *= material.transmissionAlpha;
  5417. #endif
  5418. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ake=`vec3 packNormalToRGB( const in vec3 normal ) {
  5419. return normalize( normal ) * 0.5 + 0.5;
  5420. }
  5421. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5422. return 2.0 * rgb.xyz - 1.0;
  5423. }
  5424. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5425. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5426. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5427. const float ShiftRight8 = 1. / 256.;
  5428. vec4 packDepthToRGBA( const in float v ) {
  5429. vec4 r = vec4( fract( v * PackFactors ), v );
  5430. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5431. }
  5432. float unpackRGBAToDepth( const in vec4 v ) {
  5433. return dot( v, UnpackFactors );
  5434. }
  5435. vec2 packDepthToRG( in highp float v ) {
  5436. return packDepthToRGBA( v ).yx;
  5437. }
  5438. float unpackRGToDepth( const in highp vec2 v ) {
  5439. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5440. }
  5441. vec4 pack2HalfToRGBA( vec2 v ) {
  5442. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5443. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5444. }
  5445. vec2 unpackRGBATo2Half( vec4 v ) {
  5446. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5447. }
  5448. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5449. return ( viewZ + near ) / ( near - far );
  5450. }
  5451. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5452. return depth * ( near - far ) - near;
  5453. }
  5454. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5455. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5456. }
  5457. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5458. return ( near * far ) / ( ( far - near ) * depth - far );
  5459. }`,ike=`#ifdef PREMULTIPLIED_ALPHA
  5460. gl_FragColor.rgb *= gl_FragColor.a;
  5461. #endif`,ske=`vec4 mvPosition = vec4( transformed, 1.0 );
  5462. #ifdef USE_BATCHING
  5463. mvPosition = batchingMatrix * mvPosition;
  5464. #endif
  5465. #ifdef USE_INSTANCING
  5466. mvPosition = instanceMatrix * mvPosition;
  5467. #endif
  5468. mvPosition = modelViewMatrix * mvPosition;
  5469. gl_Position = projectionMatrix * mvPosition;`,oke=`#ifdef DITHERING
  5470. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5471. #endif`,lke=`#ifdef DITHERING
  5472. vec3 dithering( vec3 color ) {
  5473. float grid_position = rand( gl_FragCoord.xy );
  5474. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5475. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5476. return color + dither_shift_RGB;
  5477. }
  5478. #endif`,cke=`float roughnessFactor = roughness;
  5479. #ifdef USE_ROUGHNESSMAP
  5480. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5481. roughnessFactor *= texelRoughness.g;
  5482. #endif`,uke=`#ifdef USE_ROUGHNESSMAP
  5483. uniform sampler2D roughnessMap;
  5484. #endif`,dke=`#if NUM_SPOT_LIGHT_COORDS > 0
  5485. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5486. #endif
  5487. #if NUM_SPOT_LIGHT_MAPS > 0
  5488. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5489. #endif
  5490. #ifdef USE_SHADOWMAP
  5491. #if NUM_DIR_LIGHT_SHADOWS > 0
  5492. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5493. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5494. struct DirectionalLightShadow {
  5495. float shadowBias;
  5496. float shadowNormalBias;
  5497. float shadowRadius;
  5498. vec2 shadowMapSize;
  5499. };
  5500. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5501. #endif
  5502. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5503. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5504. struct SpotLightShadow {
  5505. float shadowBias;
  5506. float shadowNormalBias;
  5507. float shadowRadius;
  5508. vec2 shadowMapSize;
  5509. };
  5510. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5511. #endif
  5512. #if NUM_POINT_LIGHT_SHADOWS > 0
  5513. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5514. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5515. struct PointLightShadow {
  5516. float shadowBias;
  5517. float shadowNormalBias;
  5518. float shadowRadius;
  5519. vec2 shadowMapSize;
  5520. float shadowCameraNear;
  5521. float shadowCameraFar;
  5522. };
  5523. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5524. #endif
  5525. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5526. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5527. }
  5528. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5529. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5530. }
  5531. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5532. float occlusion = 1.0;
  5533. vec2 distribution = texture2DDistribution( shadow, uv );
  5534. float hard_shadow = step( compare , distribution.x );
  5535. if (hard_shadow != 1.0 ) {
  5536. float distance = compare - distribution.x ;
  5537. float variance = max( 0.00000, distribution.y * distribution.y );
  5538. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  5539. }
  5540. return occlusion;
  5541. }
  5542. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5543. float shadow = 1.0;
  5544. shadowCoord.xyz /= shadowCoord.w;
  5545. shadowCoord.z += shadowBias;
  5546. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5547. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5548. if ( frustumTest ) {
  5549. #if defined( SHADOWMAP_TYPE_PCF )
  5550. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5551. float dx0 = - texelSize.x * shadowRadius;
  5552. float dy0 = - texelSize.y * shadowRadius;
  5553. float dx1 = + texelSize.x * shadowRadius;
  5554. float dy1 = + texelSize.y * shadowRadius;
  5555. float dx2 = dx0 / 2.0;
  5556. float dy2 = dy0 / 2.0;
  5557. float dx3 = dx1 / 2.0;
  5558. float dy3 = dy1 / 2.0;
  5559. shadow = (
  5560. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5561. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5562. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5563. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5564. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5565. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5566. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5567. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5568. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5569. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5570. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5571. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5572. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5573. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5574. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5575. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5576. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5577. ) * ( 1.0 / 17.0 );
  5578. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5579. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5580. float dx = texelSize.x;
  5581. float dy = texelSize.y;
  5582. vec2 uv = shadowCoord.xy;
  5583. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5584. uv -= f * texelSize;
  5585. shadow = (
  5586. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5587. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5588. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5589. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5590. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5591. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5592. f.x ) +
  5593. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5594. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5595. f.x ) +
  5596. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5597. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5598. f.y ) +
  5599. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5600. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5601. f.y ) +
  5602. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5603. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5604. f.x ),
  5605. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5606. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5607. f.x ),
  5608. f.y )
  5609. ) * ( 1.0 / 9.0 );
  5610. #elif defined( SHADOWMAP_TYPE_VSM )
  5611. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5612. #else
  5613. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5614. #endif
  5615. }
  5616. return shadow;
  5617. }
  5618. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5619. vec3 absV = abs( v );
  5620. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5621. absV *= scaleToCube;
  5622. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5623. vec2 planar = v.xy;
  5624. float almostATexel = 1.5 * texelSizeY;
  5625. float almostOne = 1.0 - almostATexel;
  5626. if ( absV.z >= almostOne ) {
  5627. if ( v.z > 0.0 )
  5628. planar.x = 4.0 - v.x;
  5629. } else if ( absV.x >= almostOne ) {
  5630. float signX = sign( v.x );
  5631. planar.x = v.z * signX + 2.0 * signX;
  5632. } else if ( absV.y >= almostOne ) {
  5633. float signY = sign( v.y );
  5634. planar.x = v.x + 2.0 * signY + 2.0;
  5635. planar.y = v.z * signY - 2.0;
  5636. }
  5637. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5638. }
  5639. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5640. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5641. vec3 lightToPosition = shadowCoord.xyz;
  5642. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5643. vec3 bd3D = normalize( lightToPosition );
  5644. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5645. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5646. return (
  5647. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5648. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5649. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5650. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5651. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5652. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5653. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5654. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5655. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5656. ) * ( 1.0 / 9.0 );
  5657. #else
  5658. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5659. #endif
  5660. }
  5661. #endif`,hke=`#if NUM_SPOT_LIGHT_COORDS > 0
  5662. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5663. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5664. #endif
  5665. #ifdef USE_SHADOWMAP
  5666. #if NUM_DIR_LIGHT_SHADOWS > 0
  5667. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5668. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5669. struct DirectionalLightShadow {
  5670. float shadowBias;
  5671. float shadowNormalBias;
  5672. float shadowRadius;
  5673. vec2 shadowMapSize;
  5674. };
  5675. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5676. #endif
  5677. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5678. struct SpotLightShadow {
  5679. float shadowBias;
  5680. float shadowNormalBias;
  5681. float shadowRadius;
  5682. vec2 shadowMapSize;
  5683. };
  5684. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5685. #endif
  5686. #if NUM_POINT_LIGHT_SHADOWS > 0
  5687. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5688. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5689. struct PointLightShadow {
  5690. float shadowBias;
  5691. float shadowNormalBias;
  5692. float shadowRadius;
  5693. vec2 shadowMapSize;
  5694. float shadowCameraNear;
  5695. float shadowCameraFar;
  5696. };
  5697. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5698. #endif
  5699. #endif`,mke=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5700. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5701. vec4 shadowWorldPosition;
  5702. #endif
  5703. #if defined( USE_SHADOWMAP )
  5704. #if NUM_DIR_LIGHT_SHADOWS > 0
  5705. #pragma unroll_loop_start
  5706. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5707. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5708. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5709. }
  5710. #pragma unroll_loop_end
  5711. #endif
  5712. #if NUM_POINT_LIGHT_SHADOWS > 0
  5713. #pragma unroll_loop_start
  5714. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5715. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5716. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5717. }
  5718. #pragma unroll_loop_end
  5719. #endif
  5720. #endif
  5721. #if NUM_SPOT_LIGHT_COORDS > 0
  5722. #pragma unroll_loop_start
  5723. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5724. shadowWorldPosition = worldPosition;
  5725. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5726. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5727. #endif
  5728. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5729. }
  5730. #pragma unroll_loop_end
  5731. #endif`,fke=`float getShadowMask() {
  5732. float shadow = 1.0;
  5733. #ifdef USE_SHADOWMAP
  5734. #if NUM_DIR_LIGHT_SHADOWS > 0
  5735. DirectionalLightShadow directionalLight;
  5736. #pragma unroll_loop_start
  5737. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5738. directionalLight = directionalLightShadows[ i ];
  5739. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5740. }
  5741. #pragma unroll_loop_end
  5742. #endif
  5743. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5744. SpotLightShadow spotLight;
  5745. #pragma unroll_loop_start
  5746. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5747. spotLight = spotLightShadows[ i ];
  5748. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5749. }
  5750. #pragma unroll_loop_end
  5751. #endif
  5752. #if NUM_POINT_LIGHT_SHADOWS > 0
  5753. PointLightShadow pointLight;
  5754. #pragma unroll_loop_start
  5755. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5756. pointLight = pointLightShadows[ i ];
  5757. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5758. }
  5759. #pragma unroll_loop_end
  5760. #endif
  5761. #endif
  5762. return shadow;
  5763. }`,pke=`#ifdef USE_SKINNING
  5764. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5765. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5766. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5767. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5768. #endif`,gke=`#ifdef USE_SKINNING
  5769. uniform mat4 bindMatrix;
  5770. uniform mat4 bindMatrixInverse;
  5771. uniform highp sampler2D boneTexture;
  5772. mat4 getBoneMatrix( const in float i ) {
  5773. int size = textureSize( boneTexture, 0 ).x;
  5774. int j = int( i ) * 4;
  5775. int x = j % size;
  5776. int y = j / size;
  5777. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5778. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5779. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5780. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5781. return mat4( v1, v2, v3, v4 );
  5782. }
  5783. #endif`,bke=`#ifdef USE_SKINNING
  5784. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5785. vec4 skinned = vec4( 0.0 );
  5786. skinned += boneMatX * skinVertex * skinWeight.x;
  5787. skinned += boneMatY * skinVertex * skinWeight.y;
  5788. skinned += boneMatZ * skinVertex * skinWeight.z;
  5789. skinned += boneMatW * skinVertex * skinWeight.w;
  5790. transformed = ( bindMatrixInverse * skinned ).xyz;
  5791. #endif`,xke=`#ifdef USE_SKINNING
  5792. mat4 skinMatrix = mat4( 0.0 );
  5793. skinMatrix += skinWeight.x * boneMatX;
  5794. skinMatrix += skinWeight.y * boneMatY;
  5795. skinMatrix += skinWeight.z * boneMatZ;
  5796. skinMatrix += skinWeight.w * boneMatW;
  5797. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5798. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5799. #ifdef USE_TANGENT
  5800. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5801. #endif
  5802. #endif`,yke=`float specularStrength;
  5803. #ifdef USE_SPECULARMAP
  5804. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5805. specularStrength = texelSpecular.r;
  5806. #else
  5807. specularStrength = 1.0;
  5808. #endif`,vke=`#ifdef USE_SPECULARMAP
  5809. uniform sampler2D specularMap;
  5810. #endif`,wke=`#if defined( TONE_MAPPING )
  5811. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5812. #endif`,Ske=`#ifndef saturate
  5813. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5814. #endif
  5815. uniform float toneMappingExposure;
  5816. vec3 LinearToneMapping( vec3 color ) {
  5817. return saturate( toneMappingExposure * color );
  5818. }
  5819. vec3 ReinhardToneMapping( vec3 color ) {
  5820. color *= toneMappingExposure;
  5821. return saturate( color / ( vec3( 1.0 ) + color ) );
  5822. }
  5823. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5824. color *= toneMappingExposure;
  5825. color = max( vec3( 0.0 ), color - 0.004 );
  5826. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5827. }
  5828. vec3 RRTAndODTFit( vec3 v ) {
  5829. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5830. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5831. return a / b;
  5832. }
  5833. vec3 ACESFilmicToneMapping( vec3 color ) {
  5834. const mat3 ACESInputMat = mat3(
  5835. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5836. vec3( 0.04823, 0.01566, 0.83777 )
  5837. );
  5838. const mat3 ACESOutputMat = mat3(
  5839. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5840. vec3( -0.07367, -0.00605, 1.07602 )
  5841. );
  5842. color *= toneMappingExposure / 0.6;
  5843. color = ACESInputMat * color;
  5844. color = RRTAndODTFit( color );
  5845. color = ACESOutputMat * color;
  5846. return saturate( color );
  5847. }
  5848. vec3 CustomToneMapping( vec3 color ) { return color; }`,_ke=`#ifdef USE_TRANSMISSION
  5849. material.transmission = transmission;
  5850. material.transmissionAlpha = 1.0;
  5851. material.thickness = thickness;
  5852. material.attenuationDistance = attenuationDistance;
  5853. material.attenuationColor = attenuationColor;
  5854. #ifdef USE_TRANSMISSIONMAP
  5855. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5856. #endif
  5857. #ifdef USE_THICKNESSMAP
  5858. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5859. #endif
  5860. vec3 pos = vWorldPosition;
  5861. vec3 v = normalize( cameraPosition - pos );
  5862. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5863. vec4 transmitted = getIBLVolumeRefraction(
  5864. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5865. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5866. material.attenuationColor, material.attenuationDistance );
  5867. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5868. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5869. #endif`,Nke=`#ifdef USE_TRANSMISSION
  5870. uniform float transmission;
  5871. uniform float thickness;
  5872. uniform float attenuationDistance;
  5873. uniform vec3 attenuationColor;
  5874. #ifdef USE_TRANSMISSIONMAP
  5875. uniform sampler2D transmissionMap;
  5876. #endif
  5877. #ifdef USE_THICKNESSMAP
  5878. uniform sampler2D thicknessMap;
  5879. #endif
  5880. uniform vec2 transmissionSamplerSize;
  5881. uniform sampler2D transmissionSamplerMap;
  5882. uniform mat4 modelMatrix;
  5883. uniform mat4 projectionMatrix;
  5884. varying vec3 vWorldPosition;
  5885. float w0( float a ) {
  5886. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5887. }
  5888. float w1( float a ) {
  5889. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5890. }
  5891. float w2( float a ){
  5892. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5893. }
  5894. float w3( float a ) {
  5895. return ( 1.0 / 6.0 ) * ( a * a * a );
  5896. }
  5897. float g0( float a ) {
  5898. return w0( a ) + w1( a );
  5899. }
  5900. float g1( float a ) {
  5901. return w2( a ) + w3( a );
  5902. }
  5903. float h0( float a ) {
  5904. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5905. }
  5906. float h1( float a ) {
  5907. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5908. }
  5909. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5910. uv = uv * texelSize.zw + 0.5;
  5911. vec2 iuv = floor( uv );
  5912. vec2 fuv = fract( uv );
  5913. float g0x = g0( fuv.x );
  5914. float g1x = g1( fuv.x );
  5915. float h0x = h0( fuv.x );
  5916. float h1x = h1( fuv.x );
  5917. float h0y = h0( fuv.y );
  5918. float h1y = h1( fuv.y );
  5919. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5920. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5921. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5922. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5923. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  5924. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  5925. }
  5926. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  5927. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  5928. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  5929. vec2 fLodSizeInv = 1.0 / fLodSize;
  5930. vec2 cLodSizeInv = 1.0 / cLodSize;
  5931. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  5932. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  5933. return mix( fSample, cSample, fract( lod ) );
  5934. }
  5935. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  5936. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  5937. vec3 modelScale;
  5938. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  5939. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  5940. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  5941. return normalize( refractionVector ) * thickness * modelScale;
  5942. }
  5943. float applyIorToRoughness( const in float roughness, const in float ior ) {
  5944. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  5945. }
  5946. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  5947. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  5948. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  5949. }
  5950. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  5951. if ( isinf( attenuationDistance ) ) {
  5952. return vec3( 1.0 );
  5953. } else {
  5954. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  5955. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  5956. }
  5957. }
  5958. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  5959. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  5960. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  5961. const in vec3 attenuationColor, const in float attenuationDistance ) {
  5962. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  5963. vec3 refractedRayExit = position + transmissionRay;
  5964. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  5965. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  5966. refractionCoords += 1.0;
  5967. refractionCoords /= 2.0;
  5968. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  5969. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  5970. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  5971. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  5972. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  5973. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  5974. }
  5975. #endif`,kke=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  5976. varying vec2 vUv;
  5977. #endif
  5978. #ifdef USE_MAP
  5979. varying vec2 vMapUv;
  5980. #endif
  5981. #ifdef USE_ALPHAMAP
  5982. varying vec2 vAlphaMapUv;
  5983. #endif
  5984. #ifdef USE_LIGHTMAP
  5985. varying vec2 vLightMapUv;
  5986. #endif
  5987. #ifdef USE_AOMAP
  5988. varying vec2 vAoMapUv;
  5989. #endif
  5990. #ifdef USE_BUMPMAP
  5991. varying vec2 vBumpMapUv;
  5992. #endif
  5993. #ifdef USE_NORMALMAP
  5994. varying vec2 vNormalMapUv;
  5995. #endif
  5996. #ifdef USE_EMISSIVEMAP
  5997. varying vec2 vEmissiveMapUv;
  5998. #endif
  5999. #ifdef USE_METALNESSMAP
  6000. varying vec2 vMetalnessMapUv;
  6001. #endif
  6002. #ifdef USE_ROUGHNESSMAP
  6003. varying vec2 vRoughnessMapUv;
  6004. #endif
  6005. #ifdef USE_ANISOTROPYMAP
  6006. varying vec2 vAnisotropyMapUv;
  6007. #endif
  6008. #ifdef USE_CLEARCOATMAP
  6009. varying vec2 vClearcoatMapUv;
  6010. #endif
  6011. #ifdef USE_CLEARCOAT_NORMALMAP
  6012. varying vec2 vClearcoatNormalMapUv;
  6013. #endif
  6014. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6015. varying vec2 vClearcoatRoughnessMapUv;
  6016. #endif
  6017. #ifdef USE_IRIDESCENCEMAP
  6018. varying vec2 vIridescenceMapUv;
  6019. #endif
  6020. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6021. varying vec2 vIridescenceThicknessMapUv;
  6022. #endif
  6023. #ifdef USE_SHEEN_COLORMAP
  6024. varying vec2 vSheenColorMapUv;
  6025. #endif
  6026. #ifdef USE_SHEEN_ROUGHNESSMAP
  6027. varying vec2 vSheenRoughnessMapUv;
  6028. #endif
  6029. #ifdef USE_SPECULARMAP
  6030. varying vec2 vSpecularMapUv;
  6031. #endif
  6032. #ifdef USE_SPECULAR_COLORMAP
  6033. varying vec2 vSpecularColorMapUv;
  6034. #endif
  6035. #ifdef USE_SPECULAR_INTENSITYMAP
  6036. varying vec2 vSpecularIntensityMapUv;
  6037. #endif
  6038. #ifdef USE_TRANSMISSIONMAP
  6039. uniform mat3 transmissionMapTransform;
  6040. varying vec2 vTransmissionMapUv;
  6041. #endif
  6042. #ifdef USE_THICKNESSMAP
  6043. uniform mat3 thicknessMapTransform;
  6044. varying vec2 vThicknessMapUv;
  6045. #endif`,Cke=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6046. varying vec2 vUv;
  6047. #endif
  6048. #ifdef USE_MAP
  6049. uniform mat3 mapTransform;
  6050. varying vec2 vMapUv;
  6051. #endif
  6052. #ifdef USE_ALPHAMAP
  6053. uniform mat3 alphaMapTransform;
  6054. varying vec2 vAlphaMapUv;
  6055. #endif
  6056. #ifdef USE_LIGHTMAP
  6057. uniform mat3 lightMapTransform;
  6058. varying vec2 vLightMapUv;
  6059. #endif
  6060. #ifdef USE_AOMAP
  6061. uniform mat3 aoMapTransform;
  6062. varying vec2 vAoMapUv;
  6063. #endif
  6064. #ifdef USE_BUMPMAP
  6065. uniform mat3 bumpMapTransform;
  6066. varying vec2 vBumpMapUv;
  6067. #endif
  6068. #ifdef USE_NORMALMAP
  6069. uniform mat3 normalMapTransform;
  6070. varying vec2 vNormalMapUv;
  6071. #endif
  6072. #ifdef USE_DISPLACEMENTMAP
  6073. uniform mat3 displacementMapTransform;
  6074. varying vec2 vDisplacementMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. uniform mat3 emissiveMapTransform;
  6078. varying vec2 vEmissiveMapUv;
  6079. #endif
  6080. #ifdef USE_METALNESSMAP
  6081. uniform mat3 metalnessMapTransform;
  6082. varying vec2 vMetalnessMapUv;
  6083. #endif
  6084. #ifdef USE_ROUGHNESSMAP
  6085. uniform mat3 roughnessMapTransform;
  6086. varying vec2 vRoughnessMapUv;
  6087. #endif
  6088. #ifdef USE_ANISOTROPYMAP
  6089. uniform mat3 anisotropyMapTransform;
  6090. varying vec2 vAnisotropyMapUv;
  6091. #endif
  6092. #ifdef USE_CLEARCOATMAP
  6093. uniform mat3 clearcoatMapTransform;
  6094. varying vec2 vClearcoatMapUv;
  6095. #endif
  6096. #ifdef USE_CLEARCOAT_NORMALMAP
  6097. uniform mat3 clearcoatNormalMapTransform;
  6098. varying vec2 vClearcoatNormalMapUv;
  6099. #endif
  6100. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6101. uniform mat3 clearcoatRoughnessMapTransform;
  6102. varying vec2 vClearcoatRoughnessMapUv;
  6103. #endif
  6104. #ifdef USE_SHEEN_COLORMAP
  6105. uniform mat3 sheenColorMapTransform;
  6106. varying vec2 vSheenColorMapUv;
  6107. #endif
  6108. #ifdef USE_SHEEN_ROUGHNESSMAP
  6109. uniform mat3 sheenRoughnessMapTransform;
  6110. varying vec2 vSheenRoughnessMapUv;
  6111. #endif
  6112. #ifdef USE_IRIDESCENCEMAP
  6113. uniform mat3 iridescenceMapTransform;
  6114. varying vec2 vIridescenceMapUv;
  6115. #endif
  6116. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6117. uniform mat3 iridescenceThicknessMapTransform;
  6118. varying vec2 vIridescenceThicknessMapUv;
  6119. #endif
  6120. #ifdef USE_SPECULARMAP
  6121. uniform mat3 specularMapTransform;
  6122. varying vec2 vSpecularMapUv;
  6123. #endif
  6124. #ifdef USE_SPECULAR_COLORMAP
  6125. uniform mat3 specularColorMapTransform;
  6126. varying vec2 vSpecularColorMapUv;
  6127. #endif
  6128. #ifdef USE_SPECULAR_INTENSITYMAP
  6129. uniform mat3 specularIntensityMapTransform;
  6130. varying vec2 vSpecularIntensityMapUv;
  6131. #endif
  6132. #ifdef USE_TRANSMISSIONMAP
  6133. uniform mat3 transmissionMapTransform;
  6134. varying vec2 vTransmissionMapUv;
  6135. #endif
  6136. #ifdef USE_THICKNESSMAP
  6137. uniform mat3 thicknessMapTransform;
  6138. varying vec2 vThicknessMapUv;
  6139. #endif`,Ake=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6140. vUv = vec3( uv, 1 ).xy;
  6141. #endif
  6142. #ifdef USE_MAP
  6143. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6144. #endif
  6145. #ifdef USE_ALPHAMAP
  6146. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6147. #endif
  6148. #ifdef USE_LIGHTMAP
  6149. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6150. #endif
  6151. #ifdef USE_AOMAP
  6152. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6153. #endif
  6154. #ifdef USE_BUMPMAP
  6155. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6156. #endif
  6157. #ifdef USE_NORMALMAP
  6158. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6159. #endif
  6160. #ifdef USE_DISPLACEMENTMAP
  6161. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6162. #endif
  6163. #ifdef USE_EMISSIVEMAP
  6164. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6165. #endif
  6166. #ifdef USE_METALNESSMAP
  6167. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6168. #endif
  6169. #ifdef USE_ROUGHNESSMAP
  6170. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6171. #endif
  6172. #ifdef USE_ANISOTROPYMAP
  6173. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6174. #endif
  6175. #ifdef USE_CLEARCOATMAP
  6176. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6177. #endif
  6178. #ifdef USE_CLEARCOAT_NORMALMAP
  6179. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6180. #endif
  6181. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6182. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6183. #endif
  6184. #ifdef USE_IRIDESCENCEMAP
  6185. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6186. #endif
  6187. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6188. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6189. #endif
  6190. #ifdef USE_SHEEN_COLORMAP
  6191. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6192. #endif
  6193. #ifdef USE_SHEEN_ROUGHNESSMAP
  6194. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6195. #endif
  6196. #ifdef USE_SPECULARMAP
  6197. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6198. #endif
  6199. #ifdef USE_SPECULAR_COLORMAP
  6200. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6201. #endif
  6202. #ifdef USE_SPECULAR_INTENSITYMAP
  6203. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6204. #endif
  6205. #ifdef USE_TRANSMISSIONMAP
  6206. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6207. #endif
  6208. #ifdef USE_THICKNESSMAP
  6209. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6210. #endif`,Tke=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6211. vec4 worldPosition = vec4( transformed, 1.0 );
  6212. #ifdef USE_BATCHING
  6213. worldPosition = batchingMatrix * worldPosition;
  6214. #endif
  6215. #ifdef USE_INSTANCING
  6216. worldPosition = instanceMatrix * worldPosition;
  6217. #endif
  6218. worldPosition = modelMatrix * worldPosition;
  6219. #endif`;const Mke=`varying vec2 vUv;
  6220. uniform mat3 uvTransform;
  6221. void main() {
  6222. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6223. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6224. }`,Pke=`uniform sampler2D t2D;
  6225. uniform float backgroundIntensity;
  6226. varying vec2 vUv;
  6227. void main() {
  6228. vec4 texColor = texture2D( t2D, vUv );
  6229. #ifdef DECODE_VIDEO_TEXTURE
  6230. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  6231. #endif
  6232. texColor.rgb *= backgroundIntensity;
  6233. gl_FragColor = texColor;
  6234. #include <tonemapping_fragment>
  6235. #include <colorspace_fragment>
  6236. }`,jke=`varying vec3 vWorldDirection;
  6237. #include <common>
  6238. void main() {
  6239. vWorldDirection = transformDirection( position, modelMatrix );
  6240. #include <begin_vertex>
  6241. #include <project_vertex>
  6242. gl_Position.z = gl_Position.w;
  6243. }`,Eke=`#ifdef ENVMAP_TYPE_CUBE
  6244. uniform samplerCube envMap;
  6245. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6246. uniform sampler2D envMap;
  6247. #endif
  6248. uniform float flipEnvMap;
  6249. uniform float backgroundBlurriness;
  6250. uniform float backgroundIntensity;
  6251. varying vec3 vWorldDirection;
  6252. #include <cube_uv_reflection_fragment>
  6253. void main() {
  6254. #ifdef ENVMAP_TYPE_CUBE
  6255. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6256. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6257. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6258. #else
  6259. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6260. #endif
  6261. texColor.rgb *= backgroundIntensity;
  6262. gl_FragColor = texColor;
  6263. #include <tonemapping_fragment>
  6264. #include <colorspace_fragment>
  6265. }`,Dke=`varying vec3 vWorldDirection;
  6266. #include <common>
  6267. void main() {
  6268. vWorldDirection = transformDirection( position, modelMatrix );
  6269. #include <begin_vertex>
  6270. #include <project_vertex>
  6271. gl_Position.z = gl_Position.w;
  6272. }`,Rke=`uniform samplerCube tCube;
  6273. uniform float tFlip;
  6274. uniform float opacity;
  6275. varying vec3 vWorldDirection;
  6276. void main() {
  6277. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6278. gl_FragColor = texColor;
  6279. gl_FragColor.a *= opacity;
  6280. #include <tonemapping_fragment>
  6281. #include <colorspace_fragment>
  6282. }`,Fke=`#include <common>
  6283. #include <batching_pars_vertex>
  6284. #include <uv_pars_vertex>
  6285. #include <displacementmap_pars_vertex>
  6286. #include <morphtarget_pars_vertex>
  6287. #include <skinning_pars_vertex>
  6288. #include <logdepthbuf_pars_vertex>
  6289. #include <clipping_planes_pars_vertex>
  6290. varying vec2 vHighPrecisionZW;
  6291. void main() {
  6292. #include <uv_vertex>
  6293. #include <batching_vertex>
  6294. #include <skinbase_vertex>
  6295. #ifdef USE_DISPLACEMENTMAP
  6296. #include <beginnormal_vertex>
  6297. #include <morphnormal_vertex>
  6298. #include <skinnormal_vertex>
  6299. #endif
  6300. #include <begin_vertex>
  6301. #include <morphtarget_vertex>
  6302. #include <skinning_vertex>
  6303. #include <displacementmap_vertex>
  6304. #include <project_vertex>
  6305. #include <logdepthbuf_vertex>
  6306. #include <clipping_planes_vertex>
  6307. vHighPrecisionZW = gl_Position.zw;
  6308. }`,Lke=`#if DEPTH_PACKING == 3200
  6309. uniform float opacity;
  6310. #endif
  6311. #include <common>
  6312. #include <packing>
  6313. #include <uv_pars_fragment>
  6314. #include <map_pars_fragment>
  6315. #include <alphamap_pars_fragment>
  6316. #include <alphatest_pars_fragment>
  6317. #include <alphahash_pars_fragment>
  6318. #include <logdepthbuf_pars_fragment>
  6319. #include <clipping_planes_pars_fragment>
  6320. varying vec2 vHighPrecisionZW;
  6321. void main() {
  6322. #include <clipping_planes_fragment>
  6323. vec4 diffuseColor = vec4( 1.0 );
  6324. #if DEPTH_PACKING == 3200
  6325. diffuseColor.a = opacity;
  6326. #endif
  6327. #include <map_fragment>
  6328. #include <alphamap_fragment>
  6329. #include <alphatest_fragment>
  6330. #include <alphahash_fragment>
  6331. #include <logdepthbuf_fragment>
  6332. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6333. #if DEPTH_PACKING == 3200
  6334. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6335. #elif DEPTH_PACKING == 3201
  6336. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6337. #endif
  6338. }`,Oke=`#define DISTANCE
  6339. varying vec3 vWorldPosition;
  6340. #include <common>
  6341. #include <batching_pars_vertex>
  6342. #include <uv_pars_vertex>
  6343. #include <displacementmap_pars_vertex>
  6344. #include <morphtarget_pars_vertex>
  6345. #include <skinning_pars_vertex>
  6346. #include <clipping_planes_pars_vertex>
  6347. void main() {
  6348. #include <uv_vertex>
  6349. #include <batching_vertex>
  6350. #include <skinbase_vertex>
  6351. #ifdef USE_DISPLACEMENTMAP
  6352. #include <beginnormal_vertex>
  6353. #include <morphnormal_vertex>
  6354. #include <skinnormal_vertex>
  6355. #endif
  6356. #include <begin_vertex>
  6357. #include <morphtarget_vertex>
  6358. #include <skinning_vertex>
  6359. #include <displacementmap_vertex>
  6360. #include <project_vertex>
  6361. #include <worldpos_vertex>
  6362. #include <clipping_planes_vertex>
  6363. vWorldPosition = worldPosition.xyz;
  6364. }`,Ike=`#define DISTANCE
  6365. uniform vec3 referencePosition;
  6366. uniform float nearDistance;
  6367. uniform float farDistance;
  6368. varying vec3 vWorldPosition;
  6369. #include <common>
  6370. #include <packing>
  6371. #include <uv_pars_fragment>
  6372. #include <map_pars_fragment>
  6373. #include <alphamap_pars_fragment>
  6374. #include <alphatest_pars_fragment>
  6375. #include <alphahash_pars_fragment>
  6376. #include <clipping_planes_pars_fragment>
  6377. void main () {
  6378. #include <clipping_planes_fragment>
  6379. vec4 diffuseColor = vec4( 1.0 );
  6380. #include <map_fragment>
  6381. #include <alphamap_fragment>
  6382. #include <alphatest_fragment>
  6383. #include <alphahash_fragment>
  6384. float dist = length( vWorldPosition - referencePosition );
  6385. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6386. dist = saturate( dist );
  6387. gl_FragColor = packDepthToRGBA( dist );
  6388. }`,zke=`varying vec3 vWorldDirection;
  6389. #include <common>
  6390. void main() {
  6391. vWorldDirection = transformDirection( position, modelMatrix );
  6392. #include <begin_vertex>
  6393. #include <project_vertex>
  6394. }`,Uke=`uniform sampler2D tEquirect;
  6395. varying vec3 vWorldDirection;
  6396. #include <common>
  6397. void main() {
  6398. vec3 direction = normalize( vWorldDirection );
  6399. vec2 sampleUV = equirectUv( direction );
  6400. gl_FragColor = texture2D( tEquirect, sampleUV );
  6401. #include <tonemapping_fragment>
  6402. #include <colorspace_fragment>
  6403. }`,Bke=`uniform float scale;
  6404. attribute float lineDistance;
  6405. varying float vLineDistance;
  6406. #include <common>
  6407. #include <uv_pars_vertex>
  6408. #include <color_pars_vertex>
  6409. #include <fog_pars_vertex>
  6410. #include <morphtarget_pars_vertex>
  6411. #include <logdepthbuf_pars_vertex>
  6412. #include <clipping_planes_pars_vertex>
  6413. void main() {
  6414. vLineDistance = scale * lineDistance;
  6415. #include <uv_vertex>
  6416. #include <color_vertex>
  6417. #include <morphcolor_vertex>
  6418. #include <begin_vertex>
  6419. #include <morphtarget_vertex>
  6420. #include <project_vertex>
  6421. #include <logdepthbuf_vertex>
  6422. #include <clipping_planes_vertex>
  6423. #include <fog_vertex>
  6424. }`,Hke=`uniform vec3 diffuse;
  6425. uniform float opacity;
  6426. uniform float dashSize;
  6427. uniform float totalSize;
  6428. varying float vLineDistance;
  6429. #include <common>
  6430. #include <color_pars_fragment>
  6431. #include <uv_pars_fragment>
  6432. #include <map_pars_fragment>
  6433. #include <fog_pars_fragment>
  6434. #include <logdepthbuf_pars_fragment>
  6435. #include <clipping_planes_pars_fragment>
  6436. void main() {
  6437. #include <clipping_planes_fragment>
  6438. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6439. discard;
  6440. }
  6441. vec3 outgoingLight = vec3( 0.0 );
  6442. vec4 diffuseColor = vec4( diffuse, opacity );
  6443. #include <logdepthbuf_fragment>
  6444. #include <map_fragment>
  6445. #include <color_fragment>
  6446. outgoingLight = diffuseColor.rgb;
  6447. #include <opaque_fragment>
  6448. #include <tonemapping_fragment>
  6449. #include <colorspace_fragment>
  6450. #include <fog_fragment>
  6451. #include <premultiplied_alpha_fragment>
  6452. }`,$ke=`#include <common>
  6453. #include <batching_pars_vertex>
  6454. #include <uv_pars_vertex>
  6455. #include <envmap_pars_vertex>
  6456. #include <color_pars_vertex>
  6457. #include <fog_pars_vertex>
  6458. #include <morphtarget_pars_vertex>
  6459. #include <skinning_pars_vertex>
  6460. #include <logdepthbuf_pars_vertex>
  6461. #include <clipping_planes_pars_vertex>
  6462. void main() {
  6463. #include <uv_vertex>
  6464. #include <color_vertex>
  6465. #include <morphcolor_vertex>
  6466. #include <batching_vertex>
  6467. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6468. #include <beginnormal_vertex>
  6469. #include <morphnormal_vertex>
  6470. #include <skinbase_vertex>
  6471. #include <skinnormal_vertex>
  6472. #include <defaultnormal_vertex>
  6473. #endif
  6474. #include <begin_vertex>
  6475. #include <morphtarget_vertex>
  6476. #include <skinning_vertex>
  6477. #include <project_vertex>
  6478. #include <logdepthbuf_vertex>
  6479. #include <clipping_planes_vertex>
  6480. #include <worldpos_vertex>
  6481. #include <envmap_vertex>
  6482. #include <fog_vertex>
  6483. }`,Vke=`uniform vec3 diffuse;
  6484. uniform float opacity;
  6485. #ifndef FLAT_SHADED
  6486. varying vec3 vNormal;
  6487. #endif
  6488. #include <common>
  6489. #include <dithering_pars_fragment>
  6490. #include <color_pars_fragment>
  6491. #include <uv_pars_fragment>
  6492. #include <map_pars_fragment>
  6493. #include <alphamap_pars_fragment>
  6494. #include <alphatest_pars_fragment>
  6495. #include <alphahash_pars_fragment>
  6496. #include <aomap_pars_fragment>
  6497. #include <lightmap_pars_fragment>
  6498. #include <envmap_common_pars_fragment>
  6499. #include <envmap_pars_fragment>
  6500. #include <fog_pars_fragment>
  6501. #include <specularmap_pars_fragment>
  6502. #include <logdepthbuf_pars_fragment>
  6503. #include <clipping_planes_pars_fragment>
  6504. void main() {
  6505. #include <clipping_planes_fragment>
  6506. vec4 diffuseColor = vec4( diffuse, opacity );
  6507. #include <logdepthbuf_fragment>
  6508. #include <map_fragment>
  6509. #include <color_fragment>
  6510. #include <alphamap_fragment>
  6511. #include <alphatest_fragment>
  6512. #include <alphahash_fragment>
  6513. #include <specularmap_fragment>
  6514. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6515. #ifdef USE_LIGHTMAP
  6516. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6517. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6518. #else
  6519. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6520. #endif
  6521. #include <aomap_fragment>
  6522. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6523. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6524. #include <envmap_fragment>
  6525. #include <opaque_fragment>
  6526. #include <tonemapping_fragment>
  6527. #include <colorspace_fragment>
  6528. #include <fog_fragment>
  6529. #include <premultiplied_alpha_fragment>
  6530. #include <dithering_fragment>
  6531. }`,qke=`#define LAMBERT
  6532. varying vec3 vViewPosition;
  6533. #include <common>
  6534. #include <batching_pars_vertex>
  6535. #include <uv_pars_vertex>
  6536. #include <displacementmap_pars_vertex>
  6537. #include <envmap_pars_vertex>
  6538. #include <color_pars_vertex>
  6539. #include <fog_pars_vertex>
  6540. #include <normal_pars_vertex>
  6541. #include <morphtarget_pars_vertex>
  6542. #include <skinning_pars_vertex>
  6543. #include <shadowmap_pars_vertex>
  6544. #include <logdepthbuf_pars_vertex>
  6545. #include <clipping_planes_pars_vertex>
  6546. void main() {
  6547. #include <uv_vertex>
  6548. #include <color_vertex>
  6549. #include <morphcolor_vertex>
  6550. #include <batching_vertex>
  6551. #include <beginnormal_vertex>
  6552. #include <morphnormal_vertex>
  6553. #include <skinbase_vertex>
  6554. #include <skinnormal_vertex>
  6555. #include <defaultnormal_vertex>
  6556. #include <normal_vertex>
  6557. #include <begin_vertex>
  6558. #include <morphtarget_vertex>
  6559. #include <skinning_vertex>
  6560. #include <displacementmap_vertex>
  6561. #include <project_vertex>
  6562. #include <logdepthbuf_vertex>
  6563. #include <clipping_planes_vertex>
  6564. vViewPosition = - mvPosition.xyz;
  6565. #include <worldpos_vertex>
  6566. #include <envmap_vertex>
  6567. #include <shadowmap_vertex>
  6568. #include <fog_vertex>
  6569. }`,Gke=`#define LAMBERT
  6570. uniform vec3 diffuse;
  6571. uniform vec3 emissive;
  6572. uniform float opacity;
  6573. #include <common>
  6574. #include <packing>
  6575. #include <dithering_pars_fragment>
  6576. #include <color_pars_fragment>
  6577. #include <uv_pars_fragment>
  6578. #include <map_pars_fragment>
  6579. #include <alphamap_pars_fragment>
  6580. #include <alphatest_pars_fragment>
  6581. #include <alphahash_pars_fragment>
  6582. #include <aomap_pars_fragment>
  6583. #include <lightmap_pars_fragment>
  6584. #include <emissivemap_pars_fragment>
  6585. #include <envmap_common_pars_fragment>
  6586. #include <envmap_pars_fragment>
  6587. #include <fog_pars_fragment>
  6588. #include <bsdfs>
  6589. #include <lights_pars_begin>
  6590. #include <normal_pars_fragment>
  6591. #include <lights_lambert_pars_fragment>
  6592. #include <shadowmap_pars_fragment>
  6593. #include <bumpmap_pars_fragment>
  6594. #include <normalmap_pars_fragment>
  6595. #include <specularmap_pars_fragment>
  6596. #include <logdepthbuf_pars_fragment>
  6597. #include <clipping_planes_pars_fragment>
  6598. void main() {
  6599. #include <clipping_planes_fragment>
  6600. vec4 diffuseColor = vec4( diffuse, opacity );
  6601. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6602. vec3 totalEmissiveRadiance = emissive;
  6603. #include <logdepthbuf_fragment>
  6604. #include <map_fragment>
  6605. #include <color_fragment>
  6606. #include <alphamap_fragment>
  6607. #include <alphatest_fragment>
  6608. #include <alphahash_fragment>
  6609. #include <specularmap_fragment>
  6610. #include <normal_fragment_begin>
  6611. #include <normal_fragment_maps>
  6612. #include <emissivemap_fragment>
  6613. #include <lights_lambert_fragment>
  6614. #include <lights_fragment_begin>
  6615. #include <lights_fragment_maps>
  6616. #include <lights_fragment_end>
  6617. #include <aomap_fragment>
  6618. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6619. #include <envmap_fragment>
  6620. #include <opaque_fragment>
  6621. #include <tonemapping_fragment>
  6622. #include <colorspace_fragment>
  6623. #include <fog_fragment>
  6624. #include <premultiplied_alpha_fragment>
  6625. #include <dithering_fragment>
  6626. }`,Wke=`#define MATCAP
  6627. varying vec3 vViewPosition;
  6628. #include <common>
  6629. #include <batching_pars_vertex>
  6630. #include <uv_pars_vertex>
  6631. #include <color_pars_vertex>
  6632. #include <displacementmap_pars_vertex>
  6633. #include <fog_pars_vertex>
  6634. #include <normal_pars_vertex>
  6635. #include <morphtarget_pars_vertex>
  6636. #include <skinning_pars_vertex>
  6637. #include <logdepthbuf_pars_vertex>
  6638. #include <clipping_planes_pars_vertex>
  6639. void main() {
  6640. #include <uv_vertex>
  6641. #include <color_vertex>
  6642. #include <morphcolor_vertex>
  6643. #include <batching_vertex>
  6644. #include <beginnormal_vertex>
  6645. #include <morphnormal_vertex>
  6646. #include <skinbase_vertex>
  6647. #include <skinnormal_vertex>
  6648. #include <defaultnormal_vertex>
  6649. #include <normal_vertex>
  6650. #include <begin_vertex>
  6651. #include <morphtarget_vertex>
  6652. #include <skinning_vertex>
  6653. #include <displacementmap_vertex>
  6654. #include <project_vertex>
  6655. #include <logdepthbuf_vertex>
  6656. #include <clipping_planes_vertex>
  6657. #include <fog_vertex>
  6658. vViewPosition = - mvPosition.xyz;
  6659. }`,Kke=`#define MATCAP
  6660. uniform vec3 diffuse;
  6661. uniform float opacity;
  6662. uniform sampler2D matcap;
  6663. varying vec3 vViewPosition;
  6664. #include <common>
  6665. #include <dithering_pars_fragment>
  6666. #include <color_pars_fragment>
  6667. #include <uv_pars_fragment>
  6668. #include <map_pars_fragment>
  6669. #include <alphamap_pars_fragment>
  6670. #include <alphatest_pars_fragment>
  6671. #include <alphahash_pars_fragment>
  6672. #include <fog_pars_fragment>
  6673. #include <normal_pars_fragment>
  6674. #include <bumpmap_pars_fragment>
  6675. #include <normalmap_pars_fragment>
  6676. #include <logdepthbuf_pars_fragment>
  6677. #include <clipping_planes_pars_fragment>
  6678. void main() {
  6679. #include <clipping_planes_fragment>
  6680. vec4 diffuseColor = vec4( diffuse, opacity );
  6681. #include <logdepthbuf_fragment>
  6682. #include <map_fragment>
  6683. #include <color_fragment>
  6684. #include <alphamap_fragment>
  6685. #include <alphatest_fragment>
  6686. #include <alphahash_fragment>
  6687. #include <normal_fragment_begin>
  6688. #include <normal_fragment_maps>
  6689. vec3 viewDir = normalize( vViewPosition );
  6690. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6691. vec3 y = cross( viewDir, x );
  6692. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6693. #ifdef USE_MATCAP
  6694. vec4 matcapColor = texture2D( matcap, uv );
  6695. #else
  6696. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6697. #endif
  6698. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6699. #include <opaque_fragment>
  6700. #include <tonemapping_fragment>
  6701. #include <colorspace_fragment>
  6702. #include <fog_fragment>
  6703. #include <premultiplied_alpha_fragment>
  6704. #include <dithering_fragment>
  6705. }`,Yke=`#define NORMAL
  6706. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6707. varying vec3 vViewPosition;
  6708. #endif
  6709. #include <common>
  6710. #include <batching_pars_vertex>
  6711. #include <uv_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <normal_pars_vertex>
  6714. #include <morphtarget_pars_vertex>
  6715. #include <skinning_pars_vertex>
  6716. #include <logdepthbuf_pars_vertex>
  6717. #include <clipping_planes_pars_vertex>
  6718. void main() {
  6719. #include <uv_vertex>
  6720. #include <batching_vertex>
  6721. #include <beginnormal_vertex>
  6722. #include <morphnormal_vertex>
  6723. #include <skinbase_vertex>
  6724. #include <skinnormal_vertex>
  6725. #include <defaultnormal_vertex>
  6726. #include <normal_vertex>
  6727. #include <begin_vertex>
  6728. #include <morphtarget_vertex>
  6729. #include <skinning_vertex>
  6730. #include <displacementmap_vertex>
  6731. #include <project_vertex>
  6732. #include <logdepthbuf_vertex>
  6733. #include <clipping_planes_vertex>
  6734. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6735. vViewPosition = - mvPosition.xyz;
  6736. #endif
  6737. }`,Xke=`#define NORMAL
  6738. uniform float opacity;
  6739. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6740. varying vec3 vViewPosition;
  6741. #endif
  6742. #include <packing>
  6743. #include <uv_pars_fragment>
  6744. #include <normal_pars_fragment>
  6745. #include <bumpmap_pars_fragment>
  6746. #include <normalmap_pars_fragment>
  6747. #include <logdepthbuf_pars_fragment>
  6748. #include <clipping_planes_pars_fragment>
  6749. void main() {
  6750. #include <clipping_planes_fragment>
  6751. #include <logdepthbuf_fragment>
  6752. #include <normal_fragment_begin>
  6753. #include <normal_fragment_maps>
  6754. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6755. #ifdef OPAQUE
  6756. gl_FragColor.a = 1.0;
  6757. #endif
  6758. }`,Qke=`#define PHONG
  6759. varying vec3 vViewPosition;
  6760. #include <common>
  6761. #include <batching_pars_vertex>
  6762. #include <uv_pars_vertex>
  6763. #include <displacementmap_pars_vertex>
  6764. #include <envmap_pars_vertex>
  6765. #include <color_pars_vertex>
  6766. #include <fog_pars_vertex>
  6767. #include <normal_pars_vertex>
  6768. #include <morphtarget_pars_vertex>
  6769. #include <skinning_pars_vertex>
  6770. #include <shadowmap_pars_vertex>
  6771. #include <logdepthbuf_pars_vertex>
  6772. #include <clipping_planes_pars_vertex>
  6773. void main() {
  6774. #include <uv_vertex>
  6775. #include <color_vertex>
  6776. #include <morphcolor_vertex>
  6777. #include <batching_vertex>
  6778. #include <beginnormal_vertex>
  6779. #include <morphnormal_vertex>
  6780. #include <skinbase_vertex>
  6781. #include <skinnormal_vertex>
  6782. #include <defaultnormal_vertex>
  6783. #include <normal_vertex>
  6784. #include <begin_vertex>
  6785. #include <morphtarget_vertex>
  6786. #include <skinning_vertex>
  6787. #include <displacementmap_vertex>
  6788. #include <project_vertex>
  6789. #include <logdepthbuf_vertex>
  6790. #include <clipping_planes_vertex>
  6791. vViewPosition = - mvPosition.xyz;
  6792. #include <worldpos_vertex>
  6793. #include <envmap_vertex>
  6794. #include <shadowmap_vertex>
  6795. #include <fog_vertex>
  6796. }`,Zke=`#define PHONG
  6797. uniform vec3 diffuse;
  6798. uniform vec3 emissive;
  6799. uniform vec3 specular;
  6800. uniform float shininess;
  6801. uniform float opacity;
  6802. #include <common>
  6803. #include <packing>
  6804. #include <dithering_pars_fragment>
  6805. #include <color_pars_fragment>
  6806. #include <uv_pars_fragment>
  6807. #include <map_pars_fragment>
  6808. #include <alphamap_pars_fragment>
  6809. #include <alphatest_pars_fragment>
  6810. #include <alphahash_pars_fragment>
  6811. #include <aomap_pars_fragment>
  6812. #include <lightmap_pars_fragment>
  6813. #include <emissivemap_pars_fragment>
  6814. #include <envmap_common_pars_fragment>
  6815. #include <envmap_pars_fragment>
  6816. #include <fog_pars_fragment>
  6817. #include <bsdfs>
  6818. #include <lights_pars_begin>
  6819. #include <normal_pars_fragment>
  6820. #include <lights_phong_pars_fragment>
  6821. #include <shadowmap_pars_fragment>
  6822. #include <bumpmap_pars_fragment>
  6823. #include <normalmap_pars_fragment>
  6824. #include <specularmap_pars_fragment>
  6825. #include <logdepthbuf_pars_fragment>
  6826. #include <clipping_planes_pars_fragment>
  6827. void main() {
  6828. #include <clipping_planes_fragment>
  6829. vec4 diffuseColor = vec4( diffuse, opacity );
  6830. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6831. vec3 totalEmissiveRadiance = emissive;
  6832. #include <logdepthbuf_fragment>
  6833. #include <map_fragment>
  6834. #include <color_fragment>
  6835. #include <alphamap_fragment>
  6836. #include <alphatest_fragment>
  6837. #include <alphahash_fragment>
  6838. #include <specularmap_fragment>
  6839. #include <normal_fragment_begin>
  6840. #include <normal_fragment_maps>
  6841. #include <emissivemap_fragment>
  6842. #include <lights_phong_fragment>
  6843. #include <lights_fragment_begin>
  6844. #include <lights_fragment_maps>
  6845. #include <lights_fragment_end>
  6846. #include <aomap_fragment>
  6847. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6848. #include <envmap_fragment>
  6849. #include <opaque_fragment>
  6850. #include <tonemapping_fragment>
  6851. #include <colorspace_fragment>
  6852. #include <fog_fragment>
  6853. #include <premultiplied_alpha_fragment>
  6854. #include <dithering_fragment>
  6855. }`,Jke=`#define STANDARD
  6856. varying vec3 vViewPosition;
  6857. #ifdef USE_TRANSMISSION
  6858. varying vec3 vWorldPosition;
  6859. #endif
  6860. #include <common>
  6861. #include <batching_pars_vertex>
  6862. #include <uv_pars_vertex>
  6863. #include <displacementmap_pars_vertex>
  6864. #include <color_pars_vertex>
  6865. #include <fog_pars_vertex>
  6866. #include <normal_pars_vertex>
  6867. #include <morphtarget_pars_vertex>
  6868. #include <skinning_pars_vertex>
  6869. #include <shadowmap_pars_vertex>
  6870. #include <logdepthbuf_pars_vertex>
  6871. #include <clipping_planes_pars_vertex>
  6872. void main() {
  6873. #include <uv_vertex>
  6874. #include <color_vertex>
  6875. #include <morphcolor_vertex>
  6876. #include <batching_vertex>
  6877. #include <beginnormal_vertex>
  6878. #include <morphnormal_vertex>
  6879. #include <skinbase_vertex>
  6880. #include <skinnormal_vertex>
  6881. #include <defaultnormal_vertex>
  6882. #include <normal_vertex>
  6883. #include <begin_vertex>
  6884. #include <morphtarget_vertex>
  6885. #include <skinning_vertex>
  6886. #include <displacementmap_vertex>
  6887. #include <project_vertex>
  6888. #include <logdepthbuf_vertex>
  6889. #include <clipping_planes_vertex>
  6890. vViewPosition = - mvPosition.xyz;
  6891. #include <worldpos_vertex>
  6892. #include <shadowmap_vertex>
  6893. #include <fog_vertex>
  6894. #ifdef USE_TRANSMISSION
  6895. vWorldPosition = worldPosition.xyz;
  6896. #endif
  6897. }`,eCe=`#define STANDARD
  6898. #ifdef PHYSICAL
  6899. #define IOR
  6900. #define USE_SPECULAR
  6901. #endif
  6902. uniform vec3 diffuse;
  6903. uniform vec3 emissive;
  6904. uniform float roughness;
  6905. uniform float metalness;
  6906. uniform float opacity;
  6907. #ifdef IOR
  6908. uniform float ior;
  6909. #endif
  6910. #ifdef USE_SPECULAR
  6911. uniform float specularIntensity;
  6912. uniform vec3 specularColor;
  6913. #ifdef USE_SPECULAR_COLORMAP
  6914. uniform sampler2D specularColorMap;
  6915. #endif
  6916. #ifdef USE_SPECULAR_INTENSITYMAP
  6917. uniform sampler2D specularIntensityMap;
  6918. #endif
  6919. #endif
  6920. #ifdef USE_CLEARCOAT
  6921. uniform float clearcoat;
  6922. uniform float clearcoatRoughness;
  6923. #endif
  6924. #ifdef USE_IRIDESCENCE
  6925. uniform float iridescence;
  6926. uniform float iridescenceIOR;
  6927. uniform float iridescenceThicknessMinimum;
  6928. uniform float iridescenceThicknessMaximum;
  6929. #endif
  6930. #ifdef USE_SHEEN
  6931. uniform vec3 sheenColor;
  6932. uniform float sheenRoughness;
  6933. #ifdef USE_SHEEN_COLORMAP
  6934. uniform sampler2D sheenColorMap;
  6935. #endif
  6936. #ifdef USE_SHEEN_ROUGHNESSMAP
  6937. uniform sampler2D sheenRoughnessMap;
  6938. #endif
  6939. #endif
  6940. #ifdef USE_ANISOTROPY
  6941. uniform vec2 anisotropyVector;
  6942. #ifdef USE_ANISOTROPYMAP
  6943. uniform sampler2D anisotropyMap;
  6944. #endif
  6945. #endif
  6946. varying vec3 vViewPosition;
  6947. #include <common>
  6948. #include <packing>
  6949. #include <dithering_pars_fragment>
  6950. #include <color_pars_fragment>
  6951. #include <uv_pars_fragment>
  6952. #include <map_pars_fragment>
  6953. #include <alphamap_pars_fragment>
  6954. #include <alphatest_pars_fragment>
  6955. #include <alphahash_pars_fragment>
  6956. #include <aomap_pars_fragment>
  6957. #include <lightmap_pars_fragment>
  6958. #include <emissivemap_pars_fragment>
  6959. #include <iridescence_fragment>
  6960. #include <cube_uv_reflection_fragment>
  6961. #include <envmap_common_pars_fragment>
  6962. #include <envmap_physical_pars_fragment>
  6963. #include <fog_pars_fragment>
  6964. #include <lights_pars_begin>
  6965. #include <normal_pars_fragment>
  6966. #include <lights_physical_pars_fragment>
  6967. #include <transmission_pars_fragment>
  6968. #include <shadowmap_pars_fragment>
  6969. #include <bumpmap_pars_fragment>
  6970. #include <normalmap_pars_fragment>
  6971. #include <clearcoat_pars_fragment>
  6972. #include <iridescence_pars_fragment>
  6973. #include <roughnessmap_pars_fragment>
  6974. #include <metalnessmap_pars_fragment>
  6975. #include <logdepthbuf_pars_fragment>
  6976. #include <clipping_planes_pars_fragment>
  6977. void main() {
  6978. #include <clipping_planes_fragment>
  6979. vec4 diffuseColor = vec4( diffuse, opacity );
  6980. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6981. vec3 totalEmissiveRadiance = emissive;
  6982. #include <logdepthbuf_fragment>
  6983. #include <map_fragment>
  6984. #include <color_fragment>
  6985. #include <alphamap_fragment>
  6986. #include <alphatest_fragment>
  6987. #include <alphahash_fragment>
  6988. #include <roughnessmap_fragment>
  6989. #include <metalnessmap_fragment>
  6990. #include <normal_fragment_begin>
  6991. #include <normal_fragment_maps>
  6992. #include <clearcoat_normal_fragment_begin>
  6993. #include <clearcoat_normal_fragment_maps>
  6994. #include <emissivemap_fragment>
  6995. #include <lights_physical_fragment>
  6996. #include <lights_fragment_begin>
  6997. #include <lights_fragment_maps>
  6998. #include <lights_fragment_end>
  6999. #include <aomap_fragment>
  7000. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7001. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7002. #include <transmission_fragment>
  7003. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7004. #ifdef USE_SHEEN
  7005. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7006. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7007. #endif
  7008. #ifdef USE_CLEARCOAT
  7009. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7010. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7011. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7012. #endif
  7013. #include <opaque_fragment>
  7014. #include <tonemapping_fragment>
  7015. #include <colorspace_fragment>
  7016. #include <fog_fragment>
  7017. #include <premultiplied_alpha_fragment>
  7018. #include <dithering_fragment>
  7019. }`,tCe=`#define TOON
  7020. varying vec3 vViewPosition;
  7021. #include <common>
  7022. #include <batching_pars_vertex>
  7023. #include <uv_pars_vertex>
  7024. #include <displacementmap_pars_vertex>
  7025. #include <color_pars_vertex>
  7026. #include <fog_pars_vertex>
  7027. #include <normal_pars_vertex>
  7028. #include <morphtarget_pars_vertex>
  7029. #include <skinning_pars_vertex>
  7030. #include <shadowmap_pars_vertex>
  7031. #include <logdepthbuf_pars_vertex>
  7032. #include <clipping_planes_pars_vertex>
  7033. void main() {
  7034. #include <uv_vertex>
  7035. #include <color_vertex>
  7036. #include <morphcolor_vertex>
  7037. #include <batching_vertex>
  7038. #include <beginnormal_vertex>
  7039. #include <morphnormal_vertex>
  7040. #include <skinbase_vertex>
  7041. #include <skinnormal_vertex>
  7042. #include <defaultnormal_vertex>
  7043. #include <normal_vertex>
  7044. #include <begin_vertex>
  7045. #include <morphtarget_vertex>
  7046. #include <skinning_vertex>
  7047. #include <displacementmap_vertex>
  7048. #include <project_vertex>
  7049. #include <logdepthbuf_vertex>
  7050. #include <clipping_planes_vertex>
  7051. vViewPosition = - mvPosition.xyz;
  7052. #include <worldpos_vertex>
  7053. #include <shadowmap_vertex>
  7054. #include <fog_vertex>
  7055. }`,nCe=`#define TOON
  7056. uniform vec3 diffuse;
  7057. uniform vec3 emissive;
  7058. uniform float opacity;
  7059. #include <common>
  7060. #include <packing>
  7061. #include <dithering_pars_fragment>
  7062. #include <color_pars_fragment>
  7063. #include <uv_pars_fragment>
  7064. #include <map_pars_fragment>
  7065. #include <alphamap_pars_fragment>
  7066. #include <alphatest_pars_fragment>
  7067. #include <alphahash_pars_fragment>
  7068. #include <aomap_pars_fragment>
  7069. #include <lightmap_pars_fragment>
  7070. #include <emissivemap_pars_fragment>
  7071. #include <gradientmap_pars_fragment>
  7072. #include <fog_pars_fragment>
  7073. #include <bsdfs>
  7074. #include <lights_pars_begin>
  7075. #include <normal_pars_fragment>
  7076. #include <lights_toon_pars_fragment>
  7077. #include <shadowmap_pars_fragment>
  7078. #include <bumpmap_pars_fragment>
  7079. #include <normalmap_pars_fragment>
  7080. #include <logdepthbuf_pars_fragment>
  7081. #include <clipping_planes_pars_fragment>
  7082. void main() {
  7083. #include <clipping_planes_fragment>
  7084. vec4 diffuseColor = vec4( diffuse, opacity );
  7085. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7086. vec3 totalEmissiveRadiance = emissive;
  7087. #include <logdepthbuf_fragment>
  7088. #include <map_fragment>
  7089. #include <color_fragment>
  7090. #include <alphamap_fragment>
  7091. #include <alphatest_fragment>
  7092. #include <alphahash_fragment>
  7093. #include <normal_fragment_begin>
  7094. #include <normal_fragment_maps>
  7095. #include <emissivemap_fragment>
  7096. #include <lights_toon_fragment>
  7097. #include <lights_fragment_begin>
  7098. #include <lights_fragment_maps>
  7099. #include <lights_fragment_end>
  7100. #include <aomap_fragment>
  7101. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7102. #include <opaque_fragment>
  7103. #include <tonemapping_fragment>
  7104. #include <colorspace_fragment>
  7105. #include <fog_fragment>
  7106. #include <premultiplied_alpha_fragment>
  7107. #include <dithering_fragment>
  7108. }`,rCe=`uniform float size;
  7109. uniform float scale;
  7110. #include <common>
  7111. #include <color_pars_vertex>
  7112. #include <fog_pars_vertex>
  7113. #include <morphtarget_pars_vertex>
  7114. #include <logdepthbuf_pars_vertex>
  7115. #include <clipping_planes_pars_vertex>
  7116. #ifdef USE_POINTS_UV
  7117. varying vec2 vUv;
  7118. uniform mat3 uvTransform;
  7119. #endif
  7120. void main() {
  7121. #ifdef USE_POINTS_UV
  7122. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7123. #endif
  7124. #include <color_vertex>
  7125. #include <morphcolor_vertex>
  7126. #include <begin_vertex>
  7127. #include <morphtarget_vertex>
  7128. #include <project_vertex>
  7129. gl_PointSize = size;
  7130. #ifdef USE_SIZEATTENUATION
  7131. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7132. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7133. #endif
  7134. #include <logdepthbuf_vertex>
  7135. #include <clipping_planes_vertex>
  7136. #include <worldpos_vertex>
  7137. #include <fog_vertex>
  7138. }`,aCe=`uniform vec3 diffuse;
  7139. uniform float opacity;
  7140. #include <common>
  7141. #include <color_pars_fragment>
  7142. #include <map_particle_pars_fragment>
  7143. #include <alphatest_pars_fragment>
  7144. #include <alphahash_pars_fragment>
  7145. #include <fog_pars_fragment>
  7146. #include <logdepthbuf_pars_fragment>
  7147. #include <clipping_planes_pars_fragment>
  7148. void main() {
  7149. #include <clipping_planes_fragment>
  7150. vec3 outgoingLight = vec3( 0.0 );
  7151. vec4 diffuseColor = vec4( diffuse, opacity );
  7152. #include <logdepthbuf_fragment>
  7153. #include <map_particle_fragment>
  7154. #include <color_fragment>
  7155. #include <alphatest_fragment>
  7156. #include <alphahash_fragment>
  7157. outgoingLight = diffuseColor.rgb;
  7158. #include <opaque_fragment>
  7159. #include <tonemapping_fragment>
  7160. #include <colorspace_fragment>
  7161. #include <fog_fragment>
  7162. #include <premultiplied_alpha_fragment>
  7163. }`,iCe=`#include <common>
  7164. #include <batching_pars_vertex>
  7165. #include <fog_pars_vertex>
  7166. #include <morphtarget_pars_vertex>
  7167. #include <skinning_pars_vertex>
  7168. #include <logdepthbuf_pars_vertex>
  7169. #include <shadowmap_pars_vertex>
  7170. void main() {
  7171. #include <batching_vertex>
  7172. #include <beginnormal_vertex>
  7173. #include <morphnormal_vertex>
  7174. #include <skinbase_vertex>
  7175. #include <skinnormal_vertex>
  7176. #include <defaultnormal_vertex>
  7177. #include <begin_vertex>
  7178. #include <morphtarget_vertex>
  7179. #include <skinning_vertex>
  7180. #include <project_vertex>
  7181. #include <logdepthbuf_vertex>
  7182. #include <worldpos_vertex>
  7183. #include <shadowmap_vertex>
  7184. #include <fog_vertex>
  7185. }`,sCe=`uniform vec3 color;
  7186. uniform float opacity;
  7187. #include <common>
  7188. #include <packing>
  7189. #include <fog_pars_fragment>
  7190. #include <bsdfs>
  7191. #include <lights_pars_begin>
  7192. #include <logdepthbuf_pars_fragment>
  7193. #include <shadowmap_pars_fragment>
  7194. #include <shadowmask_pars_fragment>
  7195. void main() {
  7196. #include <logdepthbuf_fragment>
  7197. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7198. #include <tonemapping_fragment>
  7199. #include <colorspace_fragment>
  7200. #include <fog_fragment>
  7201. }`,oCe=`uniform float rotation;
  7202. uniform vec2 center;
  7203. #include <common>
  7204. #include <uv_pars_vertex>
  7205. #include <fog_pars_vertex>
  7206. #include <logdepthbuf_pars_vertex>
  7207. #include <clipping_planes_pars_vertex>
  7208. void main() {
  7209. #include <uv_vertex>
  7210. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7211. vec2 scale;
  7212. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7213. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7214. #ifndef USE_SIZEATTENUATION
  7215. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7216. if ( isPerspective ) scale *= - mvPosition.z;
  7217. #endif
  7218. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7219. vec2 rotatedPosition;
  7220. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7221. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7222. mvPosition.xy += rotatedPosition;
  7223. gl_Position = projectionMatrix * mvPosition;
  7224. #include <logdepthbuf_vertex>
  7225. #include <clipping_planes_vertex>
  7226. #include <fog_vertex>
  7227. }`,lCe=`uniform vec3 diffuse;
  7228. uniform float opacity;
  7229. #include <common>
  7230. #include <uv_pars_fragment>
  7231. #include <map_pars_fragment>
  7232. #include <alphamap_pars_fragment>
  7233. #include <alphatest_pars_fragment>
  7234. #include <alphahash_pars_fragment>
  7235. #include <fog_pars_fragment>
  7236. #include <logdepthbuf_pars_fragment>
  7237. #include <clipping_planes_pars_fragment>
  7238. void main() {
  7239. #include <clipping_planes_fragment>
  7240. vec3 outgoingLight = vec3( 0.0 );
  7241. vec4 diffuseColor = vec4( diffuse, opacity );
  7242. #include <logdepthbuf_fragment>
  7243. #include <map_fragment>
  7244. #include <alphamap_fragment>
  7245. #include <alphatest_fragment>
  7246. #include <alphahash_fragment>
  7247. outgoingLight = diffuseColor.rgb;
  7248. #include <opaque_fragment>
  7249. #include <tonemapping_fragment>
  7250. #include <colorspace_fragment>
  7251. #include <fog_fragment>
  7252. }`,Hn={alphahash_fragment:P1e,alphahash_pars_fragment:j1e,alphamap_fragment:E1e,alphamap_pars_fragment:D1e,alphatest_fragment:R1e,alphatest_pars_fragment:F1e,aomap_fragment:L1e,aomap_pars_fragment:O1e,batching_pars_vertex:I1e,batching_vertex:z1e,begin_vertex:U1e,beginnormal_vertex:B1e,bsdfs:H1e,iridescence_fragment:$1e,bumpmap_pars_fragment:V1e,clipping_planes_fragment:q1e,clipping_planes_pars_fragment:G1e,clipping_planes_pars_vertex:W1e,clipping_planes_vertex:K1e,color_fragment:Y1e,color_pars_fragment:X1e,color_pars_vertex:Q1e,color_vertex:Z1e,common:J1e,cube_uv_reflection_fragment:eNe,defaultnormal_vertex:tNe,displacementmap_pars_vertex:nNe,displacementmap_vertex:rNe,emissivemap_fragment:aNe,emissivemap_pars_fragment:iNe,colorspace_fragment:sNe,colorspace_pars_fragment:oNe,envmap_fragment:lNe,envmap_common_pars_fragment:cNe,envmap_pars_fragment:uNe,envmap_pars_vertex:dNe,envmap_physical_pars_fragment:_Ne,envmap_vertex:hNe,fog_vertex:mNe,fog_pars_vertex:fNe,fog_fragment:pNe,fog_pars_fragment:gNe,gradientmap_pars_fragment:bNe,lightmap_fragment:xNe,lightmap_pars_fragment:yNe,lights_lambert_fragment:vNe,lights_lambert_pars_fragment:wNe,lights_pars_begin:SNe,lights_toon_fragment:NNe,lights_toon_pars_fragment:kNe,lights_phong_fragment:CNe,lights_phong_pars_fragment:ANe,lights_physical_fragment:TNe,lights_physical_pars_fragment:MNe,lights_fragment_begin:PNe,lights_fragment_maps:jNe,lights_fragment_end:ENe,logdepthbuf_fragment:DNe,logdepthbuf_pars_fragment:RNe,logdepthbuf_pars_vertex:FNe,logdepthbuf_vertex:LNe,map_fragment:ONe,map_pars_fragment:INe,map_particle_fragment:zNe,map_particle_pars_fragment:UNe,metalnessmap_fragment:BNe,metalnessmap_pars_fragment:HNe,morphcolor_vertex:$Ne,morphnormal_vertex:VNe,morphtarget_pars_vertex:qNe,morphtarget_vertex:GNe,normal_fragment_begin:WNe,normal_fragment_maps:KNe,normal_pars_fragment:YNe,normal_pars_vertex:XNe,normal_vertex:QNe,normalmap_pars_fragment:ZNe,clearcoat_normal_fragment_begin:JNe,clearcoat_normal_fragment_maps:eke,clearcoat_pars_fragment:tke,iridescence_pars_fragment:nke,opaque_fragment:rke,packing:ake,premultiplied_alpha_fragment:ike,project_vertex:ske,dithering_fragment:oke,dithering_pars_fragment:lke,roughnessmap_fragment:cke,roughnessmap_pars_fragment:uke,shadowmap_pars_fragment:dke,shadowmap_pars_vertex:hke,shadowmap_vertex:mke,shadowmask_pars_fragment:fke,skinbase_vertex:pke,skinning_pars_vertex:gke,skinning_vertex:bke,skinnormal_vertex:xke,specularmap_fragment:yke,specularmap_pars_fragment:vke,tonemapping_fragment:wke,tonemapping_pars_fragment:Ske,transmission_fragment:_ke,transmission_pars_fragment:Nke,uv_pars_fragment:kke,uv_pars_vertex:Cke,uv_vertex:Ake,worldpos_vertex:Tke,background_vert:Mke,background_frag:Pke,backgroundCube_vert:jke,backgroundCube_frag:Eke,cube_vert:Dke,cube_frag:Rke,depth_vert:Fke,depth_frag:Lke,distanceRGBA_vert:Oke,distanceRGBA_frag:Ike,equirect_vert:zke,equirect_frag:Uke,linedashed_vert:Bke,linedashed_frag:Hke,meshbasic_vert:$ke,meshbasic_frag:Vke,meshlambert_vert:qke,meshlambert_frag:Gke,meshmatcap_vert:Wke,meshmatcap_frag:Kke,meshnormal_vert:Yke,meshnormal_frag:Xke,meshphong_vert:Qke,meshphong_frag:Zke,meshphysical_vert:Jke,meshphysical_frag:eCe,meshtoon_vert:tCe,meshtoon_frag:nCe,points_vert:rCe,points_frag:aCe,shadow_vert:iCe,shadow_frag:sCe,sprite_vert:oCe,sprite_frag:lCe},Ht={common:{diffuse:{value:new fn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Zn},alphaMap:{value:null},alphaMapTransform:{value:new Zn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Zn}},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 Zn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Zn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Zn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Zn},normalScale:{value:new Tn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Zn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Zn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Zn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Zn}},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:{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 fn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Zn},alphaTest:{value:0},uvTransform:{value:new Zn}},sprite:{diffuse:{value:new fn(16777215)},opacity:{value:1},center:{value:new Tn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Zn},alphaMap:{value:null},alphaMapTransform:{value:new Zn},alphaTest:{value:0}}},Js={basic:{uniforms:Ms([Ht.common,Ht.specularmap,Ht.envmap,Ht.aomap,Ht.lightmap,Ht.fog]),vertexShader:Hn.meshbasic_vert,fragmentShader:Hn.meshbasic_frag},lambert:{uniforms:Ms([Ht.common,Ht.specularmap,Ht.envmap,Ht.aomap,Ht.lightmap,Ht.emissivemap,Ht.bumpmap,Ht.normalmap,Ht.displacementmap,Ht.fog,Ht.lights,{emissive:{value:new fn(0)}}]),vertexShader:Hn.meshlambert_vert,fragmentShader:Hn.meshlambert_frag},phong:{uniforms:Ms([Ht.common,Ht.specularmap,Ht.envmap,Ht.aomap,Ht.lightmap,Ht.emissivemap,Ht.bumpmap,Ht.normalmap,Ht.displacementmap,Ht.fog,Ht.lights,{emissive:{value:new fn(0)},specular:{value:new fn(1118481)},shininess:{value:30}}]),vertexShader:Hn.meshphong_vert,fragmentShader:Hn.meshphong_frag},standard:{uniforms:Ms([Ht.common,Ht.envmap,Ht.aomap,Ht.lightmap,Ht.emissivemap,Ht.bumpmap,Ht.normalmap,Ht.displacementmap,Ht.roughnessmap,Ht.metalnessmap,Ht.fog,Ht.lights,{emissive:{value:new fn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Hn.meshphysical_vert,fragmentShader:Hn.meshphysical_frag},toon:{uniforms:Ms([Ht.common,Ht.aomap,Ht.lightmap,Ht.emissivemap,Ht.bumpmap,Ht.normalmap,Ht.displacementmap,Ht.gradientmap,Ht.fog,Ht.lights,{emissive:{value:new fn(0)}}]),vertexShader:Hn.meshtoon_vert,fragmentShader:Hn.meshtoon_frag},matcap:{uniforms:Ms([Ht.common,Ht.bumpmap,Ht.normalmap,Ht.displacementmap,Ht.fog,{matcap:{value:null}}]),vertexShader:Hn.meshmatcap_vert,fragmentShader:Hn.meshmatcap_frag},points:{uniforms:Ms([Ht.points,Ht.fog]),vertexShader:Hn.points_vert,fragmentShader:Hn.points_frag},dashed:{uniforms:Ms([Ht.common,Ht.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Hn.linedashed_vert,fragmentShader:Hn.linedashed_frag},depth:{uniforms:Ms([Ht.common,Ht.displacementmap]),vertexShader:Hn.depth_vert,fragmentShader:Hn.depth_frag},normal:{uniforms:Ms([Ht.common,Ht.bumpmap,Ht.normalmap,Ht.displacementmap,{opacity:{value:1}}]),vertexShader:Hn.meshnormal_vert,fragmentShader:Hn.meshnormal_frag},sprite:{uniforms:Ms([Ht.sprite,Ht.fog]),vertexShader:Hn.sprite_vert,fragmentShader:Hn.sprite_frag},background:{uniforms:{uvTransform:{value:new Zn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Hn.background_vert,fragmentShader:Hn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Hn.backgroundCube_vert,fragmentShader:Hn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Hn.cube_vert,fragmentShader:Hn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Hn.equirect_vert,fragmentShader:Hn.equirect_frag},distanceRGBA:{uniforms:Ms([Ht.common,Ht.displacementmap,{referencePosition:{value:new rt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Hn.distanceRGBA_vert,fragmentShader:Hn.distanceRGBA_frag},shadow:{uniforms:Ms([Ht.lights,Ht.fog,{color:{value:new fn(0)},opacity:{value:1}}]),vertexShader:Hn.shadow_vert,fragmentShader:Hn.shadow_frag}};Js.physical={uniforms:Ms([Js.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Zn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Zn},clearcoatNormalScale:{value:new Tn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Zn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Zn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Zn},sheen:{value:0},sheenColor:{value:new fn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Zn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Zn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Zn},transmissionSamplerSize:{value:new Tn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Zn},attenuationDistance:{value:0},attenuationColor:{value:new fn(0)},specularColor:{value:new fn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Zn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Zn},anisotropyVector:{value:new Tn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Zn}}]),vertexShader:Hn.meshphysical_vert,fragmentShader:Hn.meshphysical_frag};const n_={r:0,b:0,g:0};function cCe(t,e,n,r,i,s,o){const l=new fn(0);let c=s===!0?0:1,u,d,h=null,f=0,p=null;function x(g,y){let _=!1,N=y.isScene===!0?y.background:null;N&&N.isTexture&&(N=(y.backgroundBlurriness>0?n:e).get(N)),N===null?v(l,c):N&&N.isColor&&(v(N,1),_=!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.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),N&&(N.isCubeTexture||N.mapping===gC)?(d===void 0&&(d=new Xl(new Nv(1,1,1),new em({name:"BackgroundCubeMaterial",uniforms:Pb(Js.backgroundCube.uniforms),vertexShader:Js.backgroundCube.vertexShader,fragmentShader:Js.backgroundCube.fragmentShader,side:io,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,j,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=y.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,d.material.toneMapped=Hr.getTransfer(N.colorSpace)!==ca,(h!==N||f!==N.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,h=N,f=N.version,p=t.toneMapping),d.layers.enableAll(),g.unshift(d,d.geometry,d.material,0,0,null)):N&&N.isTexture&&(u===void 0&&(u=new Xl(new g4(2,2),new em({name:"BackgroundMaterial",uniforms:Pb(Js.background.uniforms),vertexShader:Js.background.vertexShader,fragmentShader:Js.background.fragmentShader,side:Jh,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=y.backgroundIntensity,u.material.toneMapped=Hr.getTransfer(N.colorSpace)!==ca,N.matrixAutoUpdate===!0&&N.updateMatrix(),u.material.uniforms.uvTransform.value.copy(N.matrix),(h!==N||f!==N.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,h=N,f=N.version,p=t.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null))}function v(g,y){g.getRGB(n_,uQ(t)),r.buffers.color.setClear(n_.r,n_.g,n_.b,y,o)}return{getClearColor:function(){return l},setClearColor:function(g,y=1){l.set(g),c=y,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(g){c=g,v(l,c)},render:x}}function uCe(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=g(null);let u=c,d=!1;function h(L,ee,ae,Y,se){let ce=!1;if(o){const ye=v(Y,ae,ee);u!==ye&&(u=ye,p(u.object)),ce=y(L,Y,ae,se),ce&&_(L,Y,ae,se)}else{const ye=ee.wireframe===!0;(u.geometry!==Y.id||u.program!==ae.id||u.wireframe!==ye)&&(u.geometry=Y.id,u.program=ae.id,u.wireframe=ye,ce=!0)}se!==null&&n.update(se,t.ELEMENT_ARRAY_BUFFER),(ce||d)&&(d=!1,R(L,ee,ae,Y),se!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(se).buffer))}function f(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function p(L){return r.isWebGL2?t.bindVertexArray(L):s.bindVertexArrayOES(L)}function x(L){return r.isWebGL2?t.deleteVertexArray(L):s.deleteVertexArrayOES(L)}function v(L,ee,ae){const Y=ae.wireframe===!0;let se=l[L.id];se===void 0&&(se={},l[L.id]=se);let ce=se[ee.id];ce===void 0&&(ce={},se[ee.id]=ce);let ye=ce[Y];return ye===void 0&&(ye=g(f()),ce[Y]=ye),ye}function g(L){const ee=[],ae=[],Y=[];for(let se=0;se<i;se++)ee[se]=0,ae[se]=0,Y[se]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:ee,enabledAttributes:ae,attributeDivisors:Y,object:L,attributes:{},index:null}}function y(L,ee,ae,Y){const se=u.attributes,ce=ee.attributes;let ye=0;const Z=ae.getAttributes();for(const ue in Z)if(Z[ue].location>=0){const be=se[ue];let Ee=ce[ue];if(Ee===void 0&&(ue==="instanceMatrix"&&L.instanceMatrix&&(Ee=L.instanceMatrix),ue==="instanceColor"&&L.instanceColor&&(Ee=L.instanceColor)),be===void 0||be.attribute!==Ee||Ee&&be.data!==Ee.data)return!0;ye++}return u.attributesNum!==ye||u.index!==Y}function _(L,ee,ae,Y){const se={},ce=ee.attributes;let ye=0;const Z=ae.getAttributes();for(const ue in Z)if(Z[ue].location>=0){let be=ce[ue];be===void 0&&(ue==="instanceMatrix"&&L.instanceMatrix&&(be=L.instanceMatrix),ue==="instanceColor"&&L.instanceColor&&(be=L.instanceColor));const Ee={};Ee.attribute=be,be&&be.data&&(Ee.data=be.data),se[ue]=Ee,ye++}u.attributes=se,u.attributesNum=ye,u.index=Y}function N(){const L=u.newAttributes;for(let ee=0,ae=L.length;ee<ae;ee++)L[ee]=0}function A(L){C(L,0)}function C(L,ee){const ae=u.newAttributes,Y=u.enabledAttributes,se=u.attributeDivisors;ae[L]=1,Y[L]===0&&(t.enableVertexAttribArray(L),Y[L]=1),se[L]!==ee&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](L,ee),se[L]=ee)}function j(){const L=u.newAttributes,ee=u.enabledAttributes;for(let ae=0,Y=ee.length;ae<Y;ae++)ee[ae]!==L[ae]&&(t.disableVertexAttribArray(ae),ee[ae]=0)}function k(L,ee,ae,Y,se,ce,ye){ye===!0?t.vertexAttribIPointer(L,ee,ae,se,ce):t.vertexAttribPointer(L,ee,ae,Y,se,ce)}function R(L,ee,ae,Y){if(r.isWebGL2===!1&&(L.isInstancedMesh||Y.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;N();const se=Y.attributes,ce=ae.getAttributes(),ye=ee.defaultAttributeValues;for(const Z in ce){const ue=ce[Z];if(ue.location>=0){let pe=se[Z];if(pe===void 0&&(Z==="instanceMatrix"&&L.instanceMatrix&&(pe=L.instanceMatrix),Z==="instanceColor"&&L.instanceColor&&(pe=L.instanceColor)),pe!==void 0){const be=pe.normalized,Ee=pe.itemSize,$=n.get(pe);if($===void 0)continue;const K=$.buffer,T=$.type,E=$.bytesPerElement,O=r.isWebGL2===!0&&(T===t.INT||T===t.UNSIGNED_INT||pe.gpuType===VX);if(pe.isInterleavedBufferAttribute){const q=pe.data,B=q.stride,re=pe.offset;if(q.isInstancedInterleavedBuffer){for(let z=0;z<ue.locationSize;z++)C(ue.location+z,q.meshPerAttribute);L.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=q.meshPerAttribute*q.count)}else for(let z=0;z<ue.locationSize;z++)A(ue.location+z);t.bindBuffer(t.ARRAY_BUFFER,K);for(let z=0;z<ue.locationSize;z++)k(ue.location+z,Ee/ue.locationSize,T,be,B*E,(re+Ee/ue.locationSize*z)*E,O)}else{if(pe.isInstancedBufferAttribute){for(let q=0;q<ue.locationSize;q++)C(ue.location+q,pe.meshPerAttribute);L.isInstancedMesh!==!0&&Y._maxInstanceCount===void 0&&(Y._maxInstanceCount=pe.meshPerAttribute*pe.count)}else for(let q=0;q<ue.locationSize;q++)A(ue.location+q);t.bindBuffer(t.ARRAY_BUFFER,K);for(let q=0;q<ue.locationSize;q++)k(ue.location+q,Ee/ue.locationSize,T,be,Ee*E,Ee/ue.locationSize*q*E,O)}}else if(ye!==void 0){const be=ye[Z];if(be!==void 0)switch(be.length){case 2:t.vertexAttrib2fv(ue.location,be);break;case 3:t.vertexAttrib3fv(ue.location,be);break;case 4:t.vertexAttrib4fv(ue.location,be);break;default:t.vertexAttrib1fv(ue.location,be)}}}}j()}function M(){U();for(const L in l){const ee=l[L];for(const ae in ee){const Y=ee[ae];for(const se in Y)x(Y[se].object),delete Y[se];delete ee[ae]}delete l[L]}}function D(L){if(l[L.id]===void 0)return;const ee=l[L.id];for(const ae in ee){const Y=ee[ae];for(const se in Y)x(Y[se].object),delete Y[se];delete ee[ae]}delete l[L.id]}function G(L){for(const ee in l){const ae=l[ee];if(ae[L.id]===void 0)continue;const Y=ae[L.id];for(const se in Y)x(Y[se].object),delete Y[se];delete ae[L.id]}}function U(){W(),d=!0,u!==c&&(u=c,p(u.object))}function W(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:U,resetDefaultState:W,dispose:M,releaseStatesOfGeometry:D,releaseStatesOfProgram:G,initAttributes:N,enableAttribute:A,disableUnusedAttributes:j}}function dCe(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,f){if(f===0)return;let p,x;if(i)p=t,x="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[x](s,d,h,f),n.update(h,s,f)}function u(d,h,f){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<f;x++)this.render(d[x],h[x]);else{p.multiDrawArraysWEBGL(s,d,0,h,0,f);let x=0;for(let v=0;v<f;v++)x+=h[v];n.update(x,s,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function hCe(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),f=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),g=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),y=t.getParameter(t.MAX_VARYING_VECTORS),_=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),N=f>0,A=o||e.has("OES_texture_float"),C=N&&A,j=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:l,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:g,maxVaryings:y,maxFragmentUniforms:_,vertexTextures:N,floatFragmentTextures:A,floatVertexTextures:C,maxSamples:j}}function mCe(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new ch,l=new Zn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){const p=h.length!==0||f||r!==0||i;return i=f,r=h.length,p},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){n=d(h,f,0)},this.setState=function(h,f,p){const x=h.clippingPlanes,v=h.clipIntersection,g=h.clipShadows,y=t.get(h);if(!i||x===null||x.length===0||s&&!g)s?d(null):u();else{const _=s?0:r,N=_*4;let A=y.clippingState||null;c.value=A,A=d(x,f,N,p);for(let C=0;C!==N;++C)A[C]=n[C];y.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(h,f,p,x){const v=h!==null?h.length:0;let g=null;if(v!==0){if(g=c.value,x!==!0||g===null){const y=p+v*4,_=f.matrixWorldInverse;l.getNormalMatrix(_),(g===null||g.length<y)&&(g=new Float32Array(y));for(let N=0,A=p;N!==v;++N,A+=4)o.copy(h[N]).applyMatrix4(_,l),o.normal.toArray(g,A),g[A+3]=o.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,g}}function fCe(t){let e=new WeakMap;function n(o,l){return l===gD?o.mapping=Ab:l===bD&&(o.mapping=Tb),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===gD||l===bD)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 C1e(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 pCe extends dQ{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 Yg=4,hH=[.125,.215,.35,.446,.526,.582],ef=20,JM=new pCe,mH=new fn;let eP=null,tP=0,nP=0;const Wm=(1+Math.sqrt(5))/2,Cg=1/Wm,fH=[new rt(1,1,1),new rt(-1,1,1),new rt(1,1,-1),new rt(-1,1,-1),new rt(0,Wm,Cg),new rt(0,Wm,-Cg),new rt(Cg,0,Wm),new rt(-Cg,0,Wm),new rt(Wm,Cg,0),new rt(-Wm,Cg,0)];class pH{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){eP=this._renderer.getRenderTarget(),tP=this._renderer.getActiveCubeFace(),nP=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=xH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=bH(),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(eP,tP,nP),e.scissorTest=!1,r_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Ab||e.mapping===Tb?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),eP=this._renderer.getRenderTarget(),tP=this._renderer.getActiveCubeFace(),nP=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:ul,minFilter:ul,generateMipmaps:!1,type:R0,format:dl,colorSpace:ld,depthBuffer:!1},i=gH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=gH(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=gCe(s)),this._blurMaterial=bCe(s,e,n)}return i}_compileMaterial(e){const n=new Xl(this._lodPlanes[0],e);this._renderer.compile(n,JM)}_sceneToCubeUV(e,n,r,i){const l=new To(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,h=d.autoClear,f=d.toneMapping;d.getClearColor(mH),d.toneMapping=Hh,d.autoClear=!1;const p=new oQ({name:"PMREM.Background",side:io,depthWrite:!1,depthTest:!1}),x=new Xl(new Nv,p);let v=!1;const g=e.background;g?g.isColor&&(p.color.copy(g),e.background=null,v=!0):(p.color.copy(mH),v=!0);for(let y=0;y<6;y++){const _=y%3;_===0?(l.up.set(0,c[y],0),l.lookAt(u[y],0,0)):_===1?(l.up.set(0,0,c[y]),l.lookAt(0,u[y],0)):(l.up.set(0,c[y],0),l.lookAt(0,0,u[y]));const N=this._cubeSize;r_(i,_*N,y>2?N:0,N,N),d.setRenderTarget(i),v&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=f,d.autoClear=h,e.background=g}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Ab||e.mapping===Tb;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=xH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=bH());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Xl(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;r_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,JM)}_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=fH[(i-1)%fH.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 Xl(this._lodPlanes[i],u),f=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*ef-1),v=s/x,g=isFinite(s)?1+Math.floor(d*v):ef;g>ef&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ef}`);const y=[];let _=0;for(let k=0;k<ef;++k){const R=k/v,M=Math.exp(-R*R/2);y.push(M),k===0?_+=M:k<g&&(_+=2*M)}for(let k=0;k<y.length;k++)y[k]=y[k]/_;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=y,f.latitudinal.value=o==="latitudinal",l&&(f.poleAxis.value=l);const{_lodMax:N}=this;f.dTheta.value=x,f.mipInt.value=N-r;const A=this._sizeLods[i],C=3*A*(i>N-Yg?i-N+Yg:0),j=4*(this._cubeSize-A);r_(n,C,j,3*A,2*A),c.setRenderTarget(n),c.render(h,JM)}}function gCe(t){const e=[],n=[],r=[];let i=t;const s=t-Yg+1+hH.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Yg?c=hH[o-t+Yg-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,h=1+u,f=[d,d,h,d,h,h,d,d,h,h,d,h],p=6,x=6,v=3,g=2,y=1,_=new Float32Array(v*x*p),N=new Float32Array(g*x*p),A=new Float32Array(y*x*p);for(let j=0;j<p;j++){const k=j%3*2/3-1,R=j>2?0:-1,M=[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];_.set(M,v*x*j),N.set(f,g*x*j);const D=[j,j,j,j,j,j];A.set(D,y*x*j)}const C=new Ss;C.setAttribute("position",new Ro(_,v)),C.setAttribute("uv",new Ro(N,g)),C.setAttribute("faceIndex",new Ro(A,y)),e.push(C),i>Yg&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function gH(t,e,n){const r=new Vf(t,e,n);return r.texture.mapping=gC,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function r_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function bCe(t,e,n){const r=new Float32Array(ef),i=new rt(0,1,0);return new em({name:"SphericalGaussianBlur",defines:{n:ef,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:b4(),fragmentShader:`
  7253. precision mediump float;
  7254. precision mediump int;
  7255. varying vec3 vOutputDirection;
  7256. uniform sampler2D envMap;
  7257. uniform int samples;
  7258. uniform float weights[ n ];
  7259. uniform bool latitudinal;
  7260. uniform float dTheta;
  7261. uniform float mipInt;
  7262. uniform vec3 poleAxis;
  7263. #define ENVMAP_TYPE_CUBE_UV
  7264. #include <cube_uv_reflection_fragment>
  7265. vec3 getSample( float theta, vec3 axis ) {
  7266. float cosTheta = cos( theta );
  7267. // Rodrigues' axis-angle rotation
  7268. vec3 sampleDirection = vOutputDirection * cosTheta
  7269. + cross( axis, vOutputDirection ) * sin( theta )
  7270. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7271. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7272. }
  7273. void main() {
  7274. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7275. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7276. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7277. }
  7278. axis = normalize( axis );
  7279. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7280. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7281. for ( int i = 1; i < n; i++ ) {
  7282. if ( i >= samples ) {
  7283. break;
  7284. }
  7285. float theta = dTheta * float( i );
  7286. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7287. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7288. }
  7289. }
  7290. `,blending:Bh,depthTest:!1,depthWrite:!1})}function bH(){return new em({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:b4(),fragmentShader:`
  7291. precision mediump float;
  7292. precision mediump int;
  7293. varying vec3 vOutputDirection;
  7294. uniform sampler2D envMap;
  7295. #include <common>
  7296. void main() {
  7297. vec3 outputDirection = normalize( vOutputDirection );
  7298. vec2 uv = equirectUv( outputDirection );
  7299. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7300. }
  7301. `,blending:Bh,depthTest:!1,depthWrite:!1})}function xH(){return new em({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:b4(),fragmentShader:`
  7302. precision mediump float;
  7303. precision mediump int;
  7304. uniform float flipEnvMap;
  7305. varying vec3 vOutputDirection;
  7306. uniform samplerCube envMap;
  7307. void main() {
  7308. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7309. }
  7310. `,blending:Bh,depthTest:!1,depthWrite:!1})}function b4(){return`
  7311. precision mediump float;
  7312. precision mediump int;
  7313. attribute float faceIndex;
  7314. varying vec3 vOutputDirection;
  7315. // RH coordinate system; PMREM face-indexing convention
  7316. vec3 getDirection( vec2 uv, float face ) {
  7317. uv = 2.0 * uv - 1.0;
  7318. vec3 direction = vec3( uv, 1.0 );
  7319. if ( face == 0.0 ) {
  7320. direction = direction.zyx; // ( 1, v, u ) pos x
  7321. } else if ( face == 1.0 ) {
  7322. direction = direction.xzy;
  7323. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7324. } else if ( face == 2.0 ) {
  7325. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7326. } else if ( face == 3.0 ) {
  7327. direction = direction.zyx;
  7328. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7329. } else if ( face == 4.0 ) {
  7330. direction = direction.xzy;
  7331. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7332. } else if ( face == 5.0 ) {
  7333. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7334. }
  7335. return direction;
  7336. }
  7337. void main() {
  7338. vOutputDirection = getDirection( uv, faceIndex );
  7339. gl_Position = vec4( position, 1.0 );
  7340. }
  7341. `}function xCe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===gD||c===bD,d=c===Ab||c===Tb;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let h=e.get(l);return n===null&&(n=new pH(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 pH(t));const f=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,f),l.addEventListener("dispose",s),f.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 yCe(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 vCe(t,e,n,r){const i={},s=new WeakMap;function o(h){const f=h.target;f.index!==null&&e.remove(f.index);for(const x in f.attributes)e.remove(f.attributes[x]);for(const x in f.morphAttributes){const v=f.morphAttributes[x];for(let g=0,y=v.length;g<y;g++)e.remove(v[g])}f.removeEventListener("dispose",o),delete i[f.id];const p=s.get(f);p&&(e.remove(p),s.delete(f)),r.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,n.memory.geometries--}function l(h,f){return i[f.id]===!0||(f.addEventListener("dispose",o),i[f.id]=!0,n.memory.geometries++),f}function c(h){const f=h.attributes;for(const x in f)e.update(f[x],t.ARRAY_BUFFER);const p=h.morphAttributes;for(const x in p){const v=p[x];for(let g=0,y=v.length;g<y;g++)e.update(v[g],t.ARRAY_BUFFER)}}function u(h){const f=[],p=h.index,x=h.attributes.position;let v=0;if(p!==null){const _=p.array;v=p.version;for(let N=0,A=_.length;N<A;N+=3){const C=_[N+0],j=_[N+1],k=_[N+2];f.push(C,j,j,k,k,C)}}else if(x!==void 0){const _=x.array;v=x.version;for(let N=0,A=_.length/3-1;N<A;N+=3){const C=N+0,j=N+1,k=N+2;f.push(C,j,j,k,k,C)}}else return;const g=new(tQ(f)?cQ:lQ)(f,1);g.version=v;const y=s.get(h);y&&e.remove(y),s.set(h,g)}function d(h){const f=s.get(h);if(f){const p=h.index;p!==null&&f.version<p.version&&u(h)}else u(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:d}}function wCe(t,e,n,r){const i=r.isWebGL2;let s;function o(p){s=p}let l,c;function u(p){l=p.type,c=p.bytesPerElement}function d(p,x){t.drawElements(s,x,l,p*c),n.update(x,s,1)}function h(p,x,v){if(v===0)return;let g,y;if(i)g=t,y="drawElementsInstanced";else if(g=e.get("ANGLE_instanced_arrays"),y="drawElementsInstancedANGLE",g===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[y](s,x,l,p*c,v),n.update(x,s,v)}function f(p,x,v){if(v===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let y=0;y<v;y++)this.render(p[y]/c,x[y]);else{g.multiDrawElementsWEBGL(s,x,0,l,p,0,v);let y=0;for(let _=0;_<v;_++)y+=x[_];n.update(y,s,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=h,this.renderMultiDraw=f}function SCe(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 _Ce(t,e){return t[0]-e[0]}function NCe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function kCe(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,o=new Vr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,h){const f=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,v=x!==void 0?x.length:0;let g=s.get(d);if(g===void 0||g.count!==v){let ee=function(){W.dispose(),s.delete(d),d.removeEventListener("dispose",ee)};var p=ee;g!==void 0&&g.texture.dispose();const N=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,C=d.morphAttributes.color!==void 0,j=d.morphAttributes.position||[],k=d.morphAttributes.normal||[],R=d.morphAttributes.color||[];let M=0;N===!0&&(M=1),A===!0&&(M=2),C===!0&&(M=3);let D=d.attributes.position.count*M,G=1;D>e.maxTextureSize&&(G=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const U=new Float32Array(D*G*4*v),W=new aQ(U,D,G,v);W.type=Hu,W.needsUpdate=!0;const L=M*4;for(let ae=0;ae<v;ae++){const Y=j[ae],se=k[ae],ce=R[ae],ye=D*G*4*ae;for(let Z=0;Z<Y.count;Z++){const ue=Z*L;N===!0&&(o.fromBufferAttribute(Y,Z),U[ye+ue+0]=o.x,U[ye+ue+1]=o.y,U[ye+ue+2]=o.z,U[ye+ue+3]=0),A===!0&&(o.fromBufferAttribute(se,Z),U[ye+ue+4]=o.x,U[ye+ue+5]=o.y,U[ye+ue+6]=o.z,U[ye+ue+7]=0),C===!0&&(o.fromBufferAttribute(ce,Z),U[ye+ue+8]=o.x,U[ye+ue+9]=o.y,U[ye+ue+10]=o.z,U[ye+ue+11]=ce.itemSize===4?o.w:1)}}g={count:v,texture:W,size:new Tn(D,G)},s.set(d,g),d.addEventListener("dispose",ee)}let y=0;for(let N=0;N<f.length;N++)y+=f[N];const _=d.morphTargetsRelative?1:1-y;h.getUniforms().setValue(t,"morphTargetBaseInfluence",_),h.getUniforms().setValue(t,"morphTargetInfluences",f),h.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),h.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}else{const x=f===void 0?0:f.length;let v=r[d.id];if(v===void 0||v.length!==x){v=[];for(let A=0;A<x;A++)v[A]=[A,0];r[d.id]=v}for(let A=0;A<x;A++){const C=v[A];C[0]=A,C[1]=f[A]}v.sort(NCe);for(let A=0;A<8;A++)A<x&&v[A][1]?(l[A][0]=v[A][0],l[A][1]=v[A][1]):(l[A][0]=Number.MAX_SAFE_INTEGER,l[A][1]=0);l.sort(_Ce);const g=d.morphAttributes.position,y=d.morphAttributes.normal;let _=0;for(let A=0;A<8;A++){const C=l[A],j=C[0],k=C[1];j!==Number.MAX_SAFE_INTEGER&&k?(g&&d.getAttribute("morphTarget"+A)!==g[j]&&d.setAttribute("morphTarget"+A,g[j]),y&&d.getAttribute("morphNormal"+A)!==y[j]&&d.setAttribute("morphNormal"+A,y[j]),i[A]=k,_+=k):(g&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),y&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const N=d.morphTargetsRelative?1:1-_;h.getUniforms().setValue(t,"morphTargetBaseInfluence",N),h.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function CCe(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 f=c.skeleton;i.get(f)!==u&&(f.update(),i.set(f,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 fQ extends so{constructor(e,n,r,i,s,o,l,c,u,d){if(d=d!==void 0?d:wf,d!==wf&&d!==Mb)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===wf&&(r=kh),r===void 0&&d===Mb&&(r=vf),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:Qi,this.minFilter=c!==void 0?c:Qi,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 pQ=new so,gQ=new fQ(1,1);gQ.compareFunction=JX;const bQ=new aQ,xQ=new u1e,yQ=new hQ,yH=[],vH=[],wH=new Float32Array(16),SH=new Float32Array(9),_H=new Float32Array(4);function ix(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=yH[i];if(s===void 0&&(s=new Float32Array(i),yH[i]=s),e!==0){r.toArray(s,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(s,l)}return s}function xi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function yi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function yC(t,e){let n=vH[e];n===void 0&&(n=new Int32Array(e),vH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function ACe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function TCe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(xi(n,e))return;t.uniform2fv(this.addr,e),yi(n,e)}}function MCe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(xi(n,e))return;t.uniform3fv(this.addr,e),yi(n,e)}}function PCe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(xi(n,e))return;t.uniform4fv(this.addr,e),yi(n,e)}}function jCe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(xi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),yi(n,e)}else{if(xi(n,r))return;_H.set(r),t.uniformMatrix2fv(this.addr,!1,_H),yi(n,r)}}function ECe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(xi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),yi(n,e)}else{if(xi(n,r))return;SH.set(r),t.uniformMatrix3fv(this.addr,!1,SH),yi(n,r)}}function DCe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(xi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),yi(n,e)}else{if(xi(n,r))return;wH.set(r),t.uniformMatrix4fv(this.addr,!1,wH),yi(n,r)}}function RCe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function FCe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(xi(n,e))return;t.uniform2iv(this.addr,e),yi(n,e)}}function LCe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(xi(n,e))return;t.uniform3iv(this.addr,e),yi(n,e)}}function OCe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(xi(n,e))return;t.uniform4iv(this.addr,e),yi(n,e)}}function ICe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function zCe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(xi(n,e))return;t.uniform2uiv(this.addr,e),yi(n,e)}}function UCe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(xi(n,e))return;t.uniform3uiv(this.addr,e),yi(n,e)}}function BCe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(xi(n,e))return;t.uniform4uiv(this.addr,e),yi(n,e)}}function HCe(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?gQ:pQ;n.setTexture2D(e||s,i)}function $Ce(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||xQ,i)}function VCe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||yQ,i)}function qCe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||bQ,i)}function GCe(t){switch(t){case 5126:return ACe;case 35664:return TCe;case 35665:return MCe;case 35666:return PCe;case 35674:return jCe;case 35675:return ECe;case 35676:return DCe;case 5124:case 35670:return RCe;case 35667:case 35671:return FCe;case 35668:case 35672:return LCe;case 35669:case 35673:return OCe;case 5125:return ICe;case 36294:return zCe;case 36295:return UCe;case 36296:return BCe;case 35678:case 36198:case 36298:case 36306:case 35682:return HCe;case 35679:case 36299:case 36307:return $Ce;case 35680:case 36300:case 36308:case 36293:return VCe;case 36289:case 36303:case 36311:case 36292:return qCe}}function WCe(t,e){t.uniform1fv(this.addr,e)}function KCe(t,e){const n=ix(e,this.size,2);t.uniform2fv(this.addr,n)}function YCe(t,e){const n=ix(e,this.size,3);t.uniform3fv(this.addr,n)}function XCe(t,e){const n=ix(e,this.size,4);t.uniform4fv(this.addr,n)}function QCe(t,e){const n=ix(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ZCe(t,e){const n=ix(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function JCe(t,e){const n=ix(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function eAe(t,e){t.uniform1iv(this.addr,e)}function tAe(t,e){t.uniform2iv(this.addr,e)}function nAe(t,e){t.uniform3iv(this.addr,e)}function rAe(t,e){t.uniform4iv(this.addr,e)}function aAe(t,e){t.uniform1uiv(this.addr,e)}function iAe(t,e){t.uniform2uiv(this.addr,e)}function sAe(t,e){t.uniform3uiv(this.addr,e)}function oAe(t,e){t.uniform4uiv(this.addr,e)}function lAe(t,e,n){const r=this.cache,i=e.length,s=yC(n,i);xi(r,s)||(t.uniform1iv(this.addr,s),yi(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||pQ,s[o])}function cAe(t,e,n){const r=this.cache,i=e.length,s=yC(n,i);xi(r,s)||(t.uniform1iv(this.addr,s),yi(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||xQ,s[o])}function uAe(t,e,n){const r=this.cache,i=e.length,s=yC(n,i);xi(r,s)||(t.uniform1iv(this.addr,s),yi(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||yQ,s[o])}function dAe(t,e,n){const r=this.cache,i=e.length,s=yC(n,i);xi(r,s)||(t.uniform1iv(this.addr,s),yi(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||bQ,s[o])}function hAe(t){switch(t){case 5126:return WCe;case 35664:return KCe;case 35665:return YCe;case 35666:return XCe;case 35674:return QCe;case 35675:return ZCe;case 35676:return JCe;case 5124:case 35670:return eAe;case 35667:case 35671:return tAe;case 35668:case 35672:return nAe;case 35669:case 35673:return rAe;case 5125:return aAe;case 36294:return iAe;case 36295:return sAe;case 36296:return oAe;case 35678:case 36198:case 36298:case 36306:case 35682:return lAe;case 35679:case 36299:case 36307:return cAe;case 35680:case 36300:case 36308:case 36293:return uAe;case 36289:case 36303:case 36311:case 36292:return dAe}}class mAe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=GCe(n.type)}}class fAe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=hAe(n.type)}}class pAe{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 rP=/(\w+)(\])?(\[|\.)?/g;function NH(t,e){t.seq.push(e),t.map[e.id]=e}function gAe(t,e,n){const r=t.name,i=r.length;for(rP.lastIndex=0;;){const s=rP.exec(r),o=rP.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){NH(n,u===void 0?new mAe(l,t,e):new fAe(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new pAe(l),NH(n,h)),n=h}}}class o1{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);gAe(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 kH(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const bAe=37297;let xAe=0;function yAe(t,e){const n=t.split(`
  7342. `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  7343. `)}function vAe(t){const e=Hr.getPrimaries(Hr.workingColorSpace),n=Hr.getPrimaries(t);let r;switch(e===n?r="":e===q1&&n===V1?r="LinearDisplayP3ToLinearSRGB":e===V1&&n===q1&&(r="LinearSRGBToLinearDisplayP3"),t){case ld:case bC:return[r,"LinearTransferOETF"];case Zi:case h4:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function CH(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
  7344. `+i+`
  7345. `+yAe(t.getShaderSource(e),o)}else return i}function wAe(t,e){const n=vAe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function SAe(t,e){let n;switch(e){case w_e:n="Linear";break;case S_e:n="Reinhard";break;case __e:n="OptimizedCineon";break;case N_e:n="ACESFilmic";break;case k_e:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function _Ae(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(Oy).join(`
  7346. `)}function NAe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7347. `)}function kAe(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 Oy(t){return t!==""}function AH(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function TH(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const CAe=/^[ \t]*#include +<([\w\d./]+)>/gm;function _D(t){return t.replace(CAe,TAe)}const AAe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function TAe(t,e){let n=Hn[e];if(n===void 0){const r=AAe.get(e);if(r!==void 0)n=Hn[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return _D(n)}const MAe=/#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 MH(t){return t.replace(MAe,PAe)}function PAe(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 PH(t){let e="precision "+t.precision+` float;
  7348. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7349. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7350. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7351. #define LOW_PRECISION`),e}function jAe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===HX?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===YSe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Eu&&(e="SHADOWMAP_TYPE_VSM"),e}function EAe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Ab:case Tb:e="ENVMAP_TYPE_CUBE";break;case gC:e="ENVMAP_TYPE_CUBE_UV";break}return e}function DAe(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===Tb&&(e="ENVMAP_MODE_REFRACTION"),e}function RAe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case u4:e="ENVMAP_BLENDING_MULTIPLY";break;case y_e:e="ENVMAP_BLENDING_MIX";break;case v_e:e="ENVMAP_BLENDING_ADD";break}return e}function FAe(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 LAe(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=jAe(n),u=EAe(n),d=DAe(n),h=RAe(n),f=FAe(n),p=n.isWebGL2?"":_Ae(n),x=NAe(s),v=i.createProgram();let g,y,_=n.glslVersion?"#version "+n.glslVersion+`
  7352. `:"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Oy).join(`
  7353. `),g.length>0&&(g+=`
  7354. `),y=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Oy).join(`
  7355. `),y.length>0&&(y+=`
  7356. `)):(g=[PH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7357. `].filter(Oy).join(`
  7358. `),y=[p,PH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.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!==Hh?"#define TONE_MAPPING":"",n.toneMapping!==Hh?Hn.tonemapping_pars_fragment:"",n.toneMapping!==Hh?SAe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Hn.colorspace_pars_fragment,wAe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7359. `].filter(Oy).join(`
  7360. `)),o=_D(o),o=AH(o,n),o=TH(o,n),l=_D(l),l=AH(l,n),l=TH(l,n),o=MH(o),l=MH(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(_=`#version 300 es
  7361. `,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7362. `)+`
  7363. `+g,y=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===K6?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===K6?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  7364. `)+`
  7365. `+y);const N=_+g+o,A=_+y+l,C=kH(i,i.VERTEX_SHADER,N),j=kH(i,i.FRAGMENT_SHADER,A);i.attachShader(v,C),i.attachShader(v,j),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function k(G){if(t.debug.checkShaderErrors){const U=i.getProgramInfoLog(v).trim(),W=i.getShaderInfoLog(C).trim(),L=i.getShaderInfoLog(j).trim();let ee=!0,ae=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(ee=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,C,j);else{const Y=CH(i,C,"vertex"),se=CH(i,j,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  7366. Program Info Log: `+U+`
  7367. `+Y+`
  7368. `+se)}else U!==""?console.warn("THREE.WebGLProgram: Program Info Log:",U):(W===""||L==="")&&(ae=!1);ae&&(G.diagnostics={runnable:ee,programLog:U,vertexShader:{log:W,prefix:g},fragmentShader:{log:L,prefix:y}})}i.deleteShader(C),i.deleteShader(j),R=new o1(i,v),M=kAe(i,v)}let R;this.getUniforms=function(){return R===void 0&&k(this),R};let M;this.getAttributes=function(){return M===void 0&&k(this),M};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(v,bAe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=xAe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=C,this.fragmentShader=j,this}let OAe=0;class IAe{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 zAe(e),n.set(e,r)),r}}class zAe{constructor(e){this.id=OAe++,this.code=e,this.usedTimes=0}}function UAe(t,e,n,r,i,s,o){const l=new iQ,c=new IAe,u=[],d=i.isWebGL2,h=i.logarithmicDepthBuffer,f=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(M){return M===0?"uv":`uv${M}`}function g(M,D,G,U,W){const L=U.fog,ee=W.geometry,ae=M.isMeshStandardMaterial?U.environment:null,Y=(M.isMeshStandardMaterial?n:e).get(M.envMap||ae),se=Y&&Y.mapping===gC?Y.image.height:null,ce=x[M.type];M.precision!==null&&(p=i.getMaxPrecision(M.precision),p!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",p,"instead."));const ye=ee.morphAttributes.position||ee.morphAttributes.normal||ee.morphAttributes.color,Z=ye!==void 0?ye.length:0;let ue=0;ee.morphAttributes.position!==void 0&&(ue=1),ee.morphAttributes.normal!==void 0&&(ue=2),ee.morphAttributes.color!==void 0&&(ue=3);let pe,be,Ee,$;if(ce){const Mt=Js[ce];pe=Mt.vertexShader,be=Mt.fragmentShader}else pe=M.vertexShader,be=M.fragmentShader,c.update(M),Ee=c.getVertexShaderID(M),$=c.getFragmentShaderID(M);const K=t.getRenderTarget(),T=W.isInstancedMesh===!0,E=W.isBatchedMesh===!0,O=!!M.map,q=!!M.matcap,B=!!Y,re=!!M.aoMap,z=!!M.lightMap,V=!!M.bumpMap,te=!!M.normalMap,Q=!!M.displacementMap,ne=!!M.emissiveMap,ie=!!M.metalnessMap,me=!!M.roughnessMap,fe=M.anisotropy>0,oe=M.clearcoat>0,I=M.iridescence>0,F=M.sheen>0,J=M.transmission>0,xe=fe&&!!M.anisotropyMap,he=oe&&!!M.clearcoatMap,le=oe&&!!M.clearcoatNormalMap,Ce=oe&&!!M.clearcoatRoughnessMap,Ne=I&&!!M.iridescenceMap,Ue=I&&!!M.iridescenceThicknessMap,He=F&&!!M.sheenColorMap,de=F&&!!M.sheenRoughnessMap,we=!!M.specularMap,ke=!!M.specularColorMap,_e=!!M.specularIntensityMap,Ae=J&&!!M.transmissionMap,Ve=J&&!!M.thicknessMap,Te=!!M.gradientMap,Ke=!!M.alphaMap,je=M.alphaTest>0,qe=!!M.alphaHash,Re=!!M.extensions,Pe=!!ee.attributes.uv1,Be=!!ee.attributes.uv2,We=!!ee.attributes.uv3;let ct=Hh;return M.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(ct=t.toneMapping),{isWebGL2:d,shaderID:ce,shaderType:M.type,shaderName:M.name,vertexShader:pe,fragmentShader:be,defines:M.defines,customVertexShaderID:Ee,customFragmentShaderID:$,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:p,batching:E,instancing:T,instancingColor:T&&W.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:K===null?t.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:ld,map:O,matcap:q,envMap:B,envMapMode:B&&Y.mapping,envMapCubeUVHeight:se,aoMap:re,lightMap:z,bumpMap:V,normalMap:te,displacementMap:f&&Q,emissiveMap:ne,normalMapObjectSpace:te&&M.normalMapType===O_e,normalMapTangentSpace:te&&M.normalMapType===ZX,metalnessMap:ie,roughnessMap:me,anisotropy:fe,anisotropyMap:xe,clearcoat:oe,clearcoatMap:he,clearcoatNormalMap:le,clearcoatRoughnessMap:Ce,iridescence:I,iridescenceMap:Ne,iridescenceThicknessMap:Ue,sheen:F,sheenColorMap:He,sheenRoughnessMap:de,specularMap:we,specularColorMap:ke,specularIntensityMap:_e,transmission:J,transmissionMap:Ae,thicknessMap:Ve,gradientMap:Te,opaque:M.transparent===!1&&M.blending===ob,alphaMap:Ke,alphaTest:je,alphaHash:qe,combine:M.combine,mapUv:O&&v(M.map.channel),aoMapUv:re&&v(M.aoMap.channel),lightMapUv:z&&v(M.lightMap.channel),bumpMapUv:V&&v(M.bumpMap.channel),normalMapUv:te&&v(M.normalMap.channel),displacementMapUv:Q&&v(M.displacementMap.channel),emissiveMapUv:ne&&v(M.emissiveMap.channel),metalnessMapUv:ie&&v(M.metalnessMap.channel),roughnessMapUv:me&&v(M.roughnessMap.channel),anisotropyMapUv:xe&&v(M.anisotropyMap.channel),clearcoatMapUv:he&&v(M.clearcoatMap.channel),clearcoatNormalMapUv:le&&v(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ce&&v(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Ne&&v(M.iridescenceMap.channel),iridescenceThicknessMapUv:Ue&&v(M.iridescenceThicknessMap.channel),sheenColorMapUv:He&&v(M.sheenColorMap.channel),sheenRoughnessMapUv:de&&v(M.sheenRoughnessMap.channel),specularMapUv:we&&v(M.specularMap.channel),specularColorMapUv:ke&&v(M.specularColorMap.channel),specularIntensityMapUv:_e&&v(M.specularIntensityMap.channel),transmissionMapUv:Ae&&v(M.transmissionMap.channel),thicknessMapUv:Ve&&v(M.thicknessMap.channel),alphaMapUv:Ke&&v(M.alphaMap.channel),vertexTangents:!!ee.attributes.tangent&&(te||fe),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!ee.attributes.color&&ee.attributes.color.itemSize===4,vertexUv1s:Pe,vertexUv2s:Be,vertexUv3s:We,pointsUvs:W.isPoints===!0&&!!ee.attributes.uv&&(O||Ke),fog:!!L,useFog:M.fog===!0,fogExp2:L&&L.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:W.isSkinnedMesh===!0,morphTargets:ee.morphAttributes.position!==void 0,morphNormals:ee.morphAttributes.normal!==void 0,morphColors:ee.morphAttributes.color!==void 0,morphTargetsCount:Z,morphTextureStride:ue,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:t.shadowMap.enabled&&G.length>0,shadowMapType:t.shadowMap.type,toneMapping:ct,useLegacyLights:t._useLegacyLights,decodeVideoTexture:O&&M.map.isVideoTexture===!0&&Hr.getTransfer(M.map.colorSpace)===ca,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Lu,flipSided:M.side===io,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionDerivatives:Re&&M.extensions.derivatives===!0,extensionFragDepth:Re&&M.extensions.fragDepth===!0,extensionDrawBuffers:Re&&M.extensions.drawBuffers===!0,extensionShaderTextureLOD:Re&&M.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:M.customProgramCacheKey()}}function y(M){const D=[];if(M.shaderID?D.push(M.shaderID):(D.push(M.customVertexShaderID),D.push(M.customFragmentShaderID)),M.defines!==void 0)for(const G in M.defines)D.push(G),D.push(M.defines[G]);return M.isRawShaderMaterial===!1&&(_(D,M),N(D,M),D.push(t.outputColorSpace)),D.push(M.customProgramCacheKey),D.join()}function _(M,D){M.push(D.precision),M.push(D.outputColorSpace),M.push(D.envMapMode),M.push(D.envMapCubeUVHeight),M.push(D.mapUv),M.push(D.alphaMapUv),M.push(D.lightMapUv),M.push(D.aoMapUv),M.push(D.bumpMapUv),M.push(D.normalMapUv),M.push(D.displacementMapUv),M.push(D.emissiveMapUv),M.push(D.metalnessMapUv),M.push(D.roughnessMapUv),M.push(D.anisotropyMapUv),M.push(D.clearcoatMapUv),M.push(D.clearcoatNormalMapUv),M.push(D.clearcoatRoughnessMapUv),M.push(D.iridescenceMapUv),M.push(D.iridescenceThicknessMapUv),M.push(D.sheenColorMapUv),M.push(D.sheenRoughnessMapUv),M.push(D.specularMapUv),M.push(D.specularColorMapUv),M.push(D.specularIntensityMapUv),M.push(D.transmissionMapUv),M.push(D.thicknessMapUv),M.push(D.combine),M.push(D.fogExp2),M.push(D.sizeAttenuation),M.push(D.morphTargetsCount),M.push(D.morphAttributeCount),M.push(D.numDirLights),M.push(D.numPointLights),M.push(D.numSpotLights),M.push(D.numSpotLightMaps),M.push(D.numHemiLights),M.push(D.numRectAreaLights),M.push(D.numDirLightShadows),M.push(D.numPointLightShadows),M.push(D.numSpotLightShadows),M.push(D.numSpotLightShadowsWithMaps),M.push(D.numLightProbes),M.push(D.shadowMapType),M.push(D.toneMapping),M.push(D.numClippingPlanes),M.push(D.numClipIntersection),M.push(D.depthPacking)}function N(M,D){l.disableAll(),D.isWebGL2&&l.enable(0),D.supportsVertexTextures&&l.enable(1),D.instancing&&l.enable(2),D.instancingColor&&l.enable(3),D.matcap&&l.enable(4),D.envMap&&l.enable(5),D.normalMapObjectSpace&&l.enable(6),D.normalMapTangentSpace&&l.enable(7),D.clearcoat&&l.enable(8),D.iridescence&&l.enable(9),D.alphaTest&&l.enable(10),D.vertexColors&&l.enable(11),D.vertexAlphas&&l.enable(12),D.vertexUv1s&&l.enable(13),D.vertexUv2s&&l.enable(14),D.vertexUv3s&&l.enable(15),D.vertexTangents&&l.enable(16),D.anisotropy&&l.enable(17),D.alphaHash&&l.enable(18),D.batching&&l.enable(19),M.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.skinning&&l.enable(4),D.morphTargets&&l.enable(5),D.morphNormals&&l.enable(6),D.morphColors&&l.enable(7),D.premultipliedAlpha&&l.enable(8),D.shadowMapEnabled&&l.enable(9),D.useLegacyLights&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),M.push(l.mask)}function A(M){const D=x[M.type];let G;if(D){const U=Js[D];G=p4.clone(U.uniforms)}else G=M.uniforms;return G}function C(M,D){let G;for(let U=0,W=u.length;U<W;U++){const L=u[U];if(L.cacheKey===D){G=L,++G.usedTimes;break}}return G===void 0&&(G=new LAe(t,D,M,s),u.push(G)),G}function j(M){if(--M.usedTimes===0){const D=u.indexOf(M);u[D]=u[u.length-1],u.pop(),M.destroy()}}function k(M){c.remove(M)}function R(){c.dispose()}return{getParameters:g,getProgramCacheKey:y,getUniforms:A,acquireProgram:C,releaseProgram:j,releaseShaderCache:k,programs:u,dispose:R}}function BAe(){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 HAe(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 jH(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 EH(){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,f,p,x,v,g){let y=t[e];return y===void 0?(y={id:h.id,object:h,geometry:f,material:p,groupOrder:x,renderOrder:h.renderOrder,z:v,group:g},t[e]=y):(y.id=h.id,y.object=h,y.geometry=f,y.material=p,y.groupOrder=x,y.renderOrder=h.renderOrder,y.z=v,y.group=g),e++,y}function l(h,f,p,x,v,g){const y=o(h,f,p,x,v,g);p.transmission>0?r.push(y):p.transparent===!0?i.push(y):n.push(y)}function c(h,f,p,x,v,g){const y=o(h,f,p,x,v,g);p.transmission>0?r.unshift(y):p.transparent===!0?i.unshift(y):n.unshift(y)}function u(h,f){n.length>1&&n.sort(h||HAe),r.length>1&&r.sort(f||jH),i.length>1&&i.sort(f||jH)}function d(){for(let h=e,f=t.length;h<f;h++){const p=t[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function $Ae(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new EH,t.set(r,[o])):i>=s.length?(o=new EH,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function VAe(){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 rt,color:new fn};break;case"SpotLight":n={position:new rt,direction:new rt,color:new fn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new rt,color:new fn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new rt,skyColor:new fn,groundColor:new fn};break;case"RectAreaLight":n={color:new fn,position:new rt,halfWidth:new rt,halfHeight:new rt};break}return t[e.id]=n,n}}}function qAe(){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 Tn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let GAe=0;function WAe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function KAe(t,e){const n=new VAe,r=qAe(),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 rt);const s=new rt,o=new ia,l=new ia;function c(d,h){let f=0,p=0,x=0;for(let U=0;U<9;U++)i.probe[U].set(0,0,0);let v=0,g=0,y=0,_=0,N=0,A=0,C=0,j=0,k=0,R=0,M=0;d.sort(WAe);const D=h===!0?Math.PI:1;for(let U=0,W=d.length;U<W;U++){const L=d[U],ee=L.color,ae=L.intensity,Y=L.distance,se=L.shadow&&L.shadow.map?L.shadow.map.texture:null;if(L.isAmbientLight)f+=ee.r*ae*D,p+=ee.g*ae*D,x+=ee.b*ae*D;else if(L.isLightProbe){for(let ce=0;ce<9;ce++)i.probe[ce].addScaledVector(L.sh.coefficients[ce],ae);M++}else if(L.isDirectionalLight){const ce=n.get(L);if(ce.color.copy(L.color).multiplyScalar(L.intensity*D),L.castShadow){const ye=L.shadow,Z=r.get(L);Z.shadowBias=ye.bias,Z.shadowNormalBias=ye.normalBias,Z.shadowRadius=ye.radius,Z.shadowMapSize=ye.mapSize,i.directionalShadow[v]=Z,i.directionalShadowMap[v]=se,i.directionalShadowMatrix[v]=L.shadow.matrix,A++}i.directional[v]=ce,v++}else if(L.isSpotLight){const ce=n.get(L);ce.position.setFromMatrixPosition(L.matrixWorld),ce.color.copy(ee).multiplyScalar(ae*D),ce.distance=Y,ce.coneCos=Math.cos(L.angle),ce.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),ce.decay=L.decay,i.spot[y]=ce;const ye=L.shadow;if(L.map&&(i.spotLightMap[k]=L.map,k++,ye.updateMatrices(L),L.castShadow&&R++),i.spotLightMatrix[y]=ye.matrix,L.castShadow){const Z=r.get(L);Z.shadowBias=ye.bias,Z.shadowNormalBias=ye.normalBias,Z.shadowRadius=ye.radius,Z.shadowMapSize=ye.mapSize,i.spotShadow[y]=Z,i.spotShadowMap[y]=se,j++}y++}else if(L.isRectAreaLight){const ce=n.get(L);ce.color.copy(ee).multiplyScalar(ae),ce.halfWidth.set(L.width*.5,0,0),ce.halfHeight.set(0,L.height*.5,0),i.rectArea[_]=ce,_++}else if(L.isPointLight){const ce=n.get(L);if(ce.color.copy(L.color).multiplyScalar(L.intensity*D),ce.distance=L.distance,ce.decay=L.decay,L.castShadow){const ye=L.shadow,Z=r.get(L);Z.shadowBias=ye.bias,Z.shadowNormalBias=ye.normalBias,Z.shadowRadius=ye.radius,Z.shadowMapSize=ye.mapSize,Z.shadowCameraNear=ye.camera.near,Z.shadowCameraFar=ye.camera.far,i.pointShadow[g]=Z,i.pointShadowMap[g]=se,i.pointShadowMatrix[g]=L.shadow.matrix,C++}i.point[g]=ce,g++}else if(L.isHemisphereLight){const ce=n.get(L);ce.skyColor.copy(L.color).multiplyScalar(ae*D),ce.groundColor.copy(L.groundColor).multiplyScalar(ae*D),i.hemi[N]=ce,N++}}_>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ht.LTC_FLOAT_1,i.rectAreaLTC2=Ht.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Ht.LTC_HALF_1,i.rectAreaLTC2=Ht.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=p,i.ambient[2]=x;const G=i.hash;(G.directionalLength!==v||G.pointLength!==g||G.spotLength!==y||G.rectAreaLength!==_||G.hemiLength!==N||G.numDirectionalShadows!==A||G.numPointShadows!==C||G.numSpotShadows!==j||G.numSpotMaps!==k||G.numLightProbes!==M)&&(i.directional.length=v,i.spot.length=y,i.rectArea.length=_,i.point.length=g,i.hemi.length=N,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=C,i.pointShadowMap.length=C,i.spotShadow.length=j,i.spotShadowMap.length=j,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=C,i.spotLightMatrix.length=j+k-R,i.spotLightMap.length=k,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=M,G.directionalLength=v,G.pointLength=g,G.spotLength=y,G.rectAreaLength=_,G.hemiLength=N,G.numDirectionalShadows=A,G.numPointShadows=C,G.numSpotShadows=j,G.numSpotMaps=k,G.numLightProbes=M,i.version=GAe++)}function u(d,h){let f=0,p=0,x=0,v=0,g=0;const y=h.matrixWorldInverse;for(let _=0,N=d.length;_<N;_++){const A=d[_];if(A.isDirectionalLight){const C=i.directional[f];C.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),C.direction.sub(s),C.direction.transformDirection(y),f++}else if(A.isSpotLight){const C=i.spot[x];C.position.setFromMatrixPosition(A.matrixWorld),C.position.applyMatrix4(y),C.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),C.direction.sub(s),C.direction.transformDirection(y),x++}else if(A.isRectAreaLight){const C=i.rectArea[v];C.position.setFromMatrixPosition(A.matrixWorld),C.position.applyMatrix4(y),l.identity(),o.copy(A.matrixWorld),o.premultiply(y),l.extractRotation(o),C.halfWidth.set(A.width*.5,0,0),C.halfHeight.set(0,A.height*.5,0),C.halfWidth.applyMatrix4(l),C.halfHeight.applyMatrix4(l),v++}else if(A.isPointLight){const C=i.point[p];C.position.setFromMatrixPosition(A.matrixWorld),C.position.applyMatrix4(y),p++}else if(A.isHemisphereLight){const C=i.hemi[g];C.direction.setFromMatrixPosition(A.matrixWorld),C.direction.transformDirection(y),g++}}}return{setup:c,setupView:u,state:i}}function DH(t,e){const n=new KAe(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 YAe(t,e){let n=new WeakMap;function r(s,o=0){const l=n.get(s);let c;return l===void 0?(c=new DH(t,e),n.set(s,[c])):o>=l.length?(c=new DH(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class XAe extends ax{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=F_e,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 QAe extends ax{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 ZAe=`void main() {
  7369. gl_Position = vec4( position, 1.0 );
  7370. }`,JAe=`uniform sampler2D shadow_pass;
  7371. uniform vec2 resolution;
  7372. uniform float radius;
  7373. #include <packing>
  7374. void main() {
  7375. const float samples = float( VSM_SAMPLES );
  7376. float mean = 0.0;
  7377. float squared_mean = 0.0;
  7378. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7379. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7380. for ( float i = 0.0; i < samples; i ++ ) {
  7381. float uvOffset = uvStart + i * uvStride;
  7382. #ifdef HORIZONTAL_PASS
  7383. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7384. mean += distribution.x;
  7385. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7386. #else
  7387. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7388. mean += depth;
  7389. squared_mean += depth * depth;
  7390. #endif
  7391. }
  7392. mean = mean / samples;
  7393. squared_mean = squared_mean / samples;
  7394. float std_dev = sqrt( squared_mean - mean * mean );
  7395. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7396. }`;function eTe(t,e,n){let r=new xC;const i=new Tn,s=new Tn,o=new Vr,l=new XAe({depthPacking:L_e}),c=new QAe,u={},d=n.maxTextureSize,h={[Jh]:io,[io]:Jh,[Lu]:Lu},f=new em({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Tn},radius:{value:4}},vertexShader:ZAe,fragmentShader:JAe}),p=f.clone();p.defines.HORIZONTAL_PASS=1;const x=new Ss;x.setAttribute("position",new Ro(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Xl(x,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=HX;let y=this.type;this.render=function(C,j,k){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||C.length===0)return;const R=t.getRenderTarget(),M=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),G=t.state;G.setBlending(Bh),G.buffers.color.setClear(1,1,1,1),G.buffers.depth.setTest(!0),G.setScissorTest(!1);const U=y!==Eu&&this.type===Eu,W=y===Eu&&this.type!==Eu;for(let L=0,ee=C.length;L<ee;L++){const ae=C[L],Y=ae.shadow;if(Y===void 0){console.warn("THREE.WebGLShadowMap:",ae,"has no shadow.");continue}if(Y.autoUpdate===!1&&Y.needsUpdate===!1)continue;i.copy(Y.mapSize);const se=Y.getFrameExtents();if(i.multiply(se),s.copy(Y.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/se.x),i.x=s.x*se.x,Y.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/se.y),i.y=s.y*se.y,Y.mapSize.y=s.y)),Y.map===null||U===!0||W===!0){const ye=this.type!==Eu?{minFilter:Qi,magFilter:Qi}:{};Y.map!==null&&Y.map.dispose(),Y.map=new Vf(i.x,i.y,ye),Y.map.texture.name=ae.name+".shadowMap",Y.camera.updateProjectionMatrix()}t.setRenderTarget(Y.map),t.clear();const ce=Y.getViewportCount();for(let ye=0;ye<ce;ye++){const Z=Y.getViewport(ye);o.set(s.x*Z.x,s.y*Z.y,s.x*Z.z,s.y*Z.w),G.viewport(o),Y.updateMatrices(ae,ye),r=Y.getFrustum(),A(j,k,Y.camera,ae,this.type)}Y.isPointLightShadow!==!0&&this.type===Eu&&_(Y,k),Y.needsUpdate=!1}y=this.type,g.needsUpdate=!1,t.setRenderTarget(R,M,D)};function _(C,j){const k=e.update(v);f.defines.VSM_SAMPLES!==C.blurSamples&&(f.defines.VSM_SAMPLES=C.blurSamples,p.defines.VSM_SAMPLES=C.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new Vf(i.x,i.y)),f.uniforms.shadow_pass.value=C.map.texture,f.uniforms.resolution.value=C.mapSize,f.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(j,null,k,f,v,null),p.uniforms.shadow_pass.value=C.mapPass.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(j,null,k,p,v,null)}function N(C,j,k,R){let M=null;const D=k.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(D!==void 0)M=D;else if(M=k.isPointLight===!0?c:l,t.localClippingEnabled&&j.clipShadows===!0&&Array.isArray(j.clippingPlanes)&&j.clippingPlanes.length!==0||j.displacementMap&&j.displacementScale!==0||j.alphaMap&&j.alphaTest>0||j.map&&j.alphaTest>0){const G=M.uuid,U=j.uuid;let W=u[G];W===void 0&&(W={},u[G]=W);let L=W[U];L===void 0&&(L=M.clone(),W[U]=L),M=L}if(M.visible=j.visible,M.wireframe=j.wireframe,R===Eu?M.side=j.shadowSide!==null?j.shadowSide:j.side:M.side=j.shadowSide!==null?j.shadowSide:h[j.side],M.alphaMap=j.alphaMap,M.alphaTest=j.alphaTest,M.map=j.map,M.clipShadows=j.clipShadows,M.clippingPlanes=j.clippingPlanes,M.clipIntersection=j.clipIntersection,M.displacementMap=j.displacementMap,M.displacementScale=j.displacementScale,M.displacementBias=j.displacementBias,M.wireframeLinewidth=j.wireframeLinewidth,M.linewidth=j.linewidth,k.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const G=t.properties.get(M);G.light=k}return M}function A(C,j,k,R,M){if(C.visible===!1)return;if(C.layers.test(j.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&M===Eu)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,C.matrixWorld);const U=e.update(C),W=C.material;if(Array.isArray(W)){const L=U.groups;for(let ee=0,ae=L.length;ee<ae;ee++){const Y=L[ee],se=W[Y.materialIndex];if(se&&se.visible){const ce=N(C,se,R,M);C.onBeforeShadow(t,C,j,k,U,ce,Y),t.renderBufferDirect(k,null,U,ce,C,Y),C.onAfterShadow(t,C,j,k,U,ce,Y)}}}else if(W.visible){const L=N(C,W,R,M);C.onBeforeShadow(t,C,j,k,U,L,null),t.renderBufferDirect(k,null,U,L,C,null),C.onAfterShadow(t,C,j,k,U,L,null)}}const G=C.children;for(let U=0,W=G.length;U<W;U++)A(G[U],j,k,R,M)}}function tTe(t,e,n){const r=n.isWebGL2;function i(){let je=!1;const qe=new Vr;let Re=null;const Pe=new Vr(0,0,0,0);return{setMask:function(Be){Re!==Be&&!je&&(t.colorMask(Be,Be,Be,Be),Re=Be)},setLocked:function(Be){je=Be},setClear:function(Be,We,ct,St,Mt){Mt===!0&&(Be*=St,We*=St,ct*=St),qe.set(Be,We,ct,St),Pe.equals(qe)===!1&&(t.clearColor(Be,We,ct,St),Pe.copy(qe))},reset:function(){je=!1,Re=null,Pe.set(-1,0,0,0)}}}function s(){let je=!1,qe=null,Re=null,Pe=null;return{setTest:function(Be){Be?E(t.DEPTH_TEST):O(t.DEPTH_TEST)},setMask:function(Be){qe!==Be&&!je&&(t.depthMask(Be),qe=Be)},setFunc:function(Be){if(Re!==Be){switch(Be){case h_e:t.depthFunc(t.NEVER);break;case m_e:t.depthFunc(t.ALWAYS);break;case f_e:t.depthFunc(t.LESS);break;case H1:t.depthFunc(t.LEQUAL);break;case p_e:t.depthFunc(t.EQUAL);break;case g_e:t.depthFunc(t.GEQUAL);break;case b_e:t.depthFunc(t.GREATER);break;case x_e:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Re=Be}},setLocked:function(Be){je=Be},setClear:function(Be){Pe!==Be&&(t.clearDepth(Be),Pe=Be)},reset:function(){je=!1,qe=null,Re=null,Pe=null}}}function o(){let je=!1,qe=null,Re=null,Pe=null,Be=null,We=null,ct=null,St=null,Mt=null;return{setTest:function(yt){je||(yt?E(t.STENCIL_TEST):O(t.STENCIL_TEST))},setMask:function(yt){qe!==yt&&!je&&(t.stencilMask(yt),qe=yt)},setFunc:function(yt,$e,dt){(Re!==yt||Pe!==$e||Be!==dt)&&(t.stencilFunc(yt,$e,dt),Re=yt,Pe=$e,Be=dt)},setOp:function(yt,$e,dt){(We!==yt||ct!==$e||St!==dt)&&(t.stencilOp(yt,$e,dt),We=yt,ct=$e,St=dt)},setLocked:function(yt){je=yt},setClear:function(yt){Mt!==yt&&(t.clearStencil(yt),Mt=yt)},reset:function(){je=!1,qe=null,Re=null,Pe=null,Be=null,We=null,ct=null,St=null,Mt=null}}}const l=new i,c=new s,u=new o,d=new WeakMap,h=new WeakMap;let f={},p={},x=new WeakMap,v=[],g=null,y=!1,_=null,N=null,A=null,C=null,j=null,k=null,R=null,M=new fn(0,0,0),D=0,G=!1,U=null,W=null,L=null,ee=null,ae=null;const Y=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let se=!1,ce=0;const ye=t.getParameter(t.VERSION);ye.indexOf("WebGL")!==-1?(ce=parseFloat(/^WebGL (\d)/.exec(ye)[1]),se=ce>=1):ye.indexOf("OpenGL ES")!==-1&&(ce=parseFloat(/^OpenGL ES (\d)/.exec(ye)[1]),se=ce>=2);let Z=null,ue={};const pe=t.getParameter(t.SCISSOR_BOX),be=t.getParameter(t.VIEWPORT),Ee=new Vr().fromArray(pe),$=new Vr().fromArray(be);function K(je,qe,Re,Pe){const Be=new Uint8Array(4),We=t.createTexture();t.bindTexture(je,We),t.texParameteri(je,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(je,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let ct=0;ct<Re;ct++)r&&(je===t.TEXTURE_3D||je===t.TEXTURE_2D_ARRAY)?t.texImage3D(qe,0,t.RGBA,1,1,Pe,0,t.RGBA,t.UNSIGNED_BYTE,Be):t.texImage2D(qe+ct,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Be);return We}const T={};T[t.TEXTURE_2D]=K(t.TEXTURE_2D,t.TEXTURE_2D,1),T[t.TEXTURE_CUBE_MAP]=K(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(T[t.TEXTURE_2D_ARRAY]=K(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),T[t.TEXTURE_3D]=K(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),E(t.DEPTH_TEST),c.setFunc(H1),ne(!1),ie(p6),E(t.CULL_FACE),te(Bh);function E(je){f[je]!==!0&&(t.enable(je),f[je]=!0)}function O(je){f[je]!==!1&&(t.disable(je),f[je]=!1)}function q(je,qe){return p[je]!==qe?(t.bindFramebuffer(je,qe),p[je]=qe,r&&(je===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=qe),je===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=qe)),!0):!1}function B(je,qe){let Re=v,Pe=!1;if(je)if(Re=x.get(qe),Re===void 0&&(Re=[],x.set(qe,Re)),je.isWebGLMultipleRenderTargets){const Be=je.texture;if(Re.length!==Be.length||Re[0]!==t.COLOR_ATTACHMENT0){for(let We=0,ct=Be.length;We<ct;We++)Re[We]=t.COLOR_ATTACHMENT0+We;Re.length=Be.length,Pe=!0}}else Re[0]!==t.COLOR_ATTACHMENT0&&(Re[0]=t.COLOR_ATTACHMENT0,Pe=!0);else Re[0]!==t.BACK&&(Re[0]=t.BACK,Pe=!0);Pe&&(n.isWebGL2?t.drawBuffers(Re):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Re))}function re(je){return g!==je?(t.useProgram(je),g=je,!0):!1}const z={[Jm]:t.FUNC_ADD,[QSe]:t.FUNC_SUBTRACT,[ZSe]:t.FUNC_REVERSE_SUBTRACT};if(r)z[y6]=t.MIN,z[v6]=t.MAX;else{const je=e.get("EXT_blend_minmax");je!==null&&(z[y6]=je.MIN_EXT,z[v6]=je.MAX_EXT)}const V={[JSe]:t.ZERO,[e_e]:t.ONE,[t_e]:t.SRC_COLOR,[fD]:t.SRC_ALPHA,[o_e]:t.SRC_ALPHA_SATURATE,[i_e]:t.DST_COLOR,[r_e]:t.DST_ALPHA,[n_e]:t.ONE_MINUS_SRC_COLOR,[pD]:t.ONE_MINUS_SRC_ALPHA,[s_e]:t.ONE_MINUS_DST_COLOR,[a_e]:t.ONE_MINUS_DST_ALPHA,[l_e]:t.CONSTANT_COLOR,[c_e]:t.ONE_MINUS_CONSTANT_COLOR,[u_e]:t.CONSTANT_ALPHA,[d_e]:t.ONE_MINUS_CONSTANT_ALPHA};function te(je,qe,Re,Pe,Be,We,ct,St,Mt,yt){if(je===Bh){y===!0&&(O(t.BLEND),y=!1);return}if(y===!1&&(E(t.BLEND),y=!0),je!==XSe){if(je!==_||yt!==G){if((N!==Jm||j!==Jm)&&(t.blendEquation(t.FUNC_ADD),N=Jm,j=Jm),yt)switch(je){case ob:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case g6:t.blendFunc(t.ONE,t.ONE);break;case b6:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case x6:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",je);break}else switch(je){case ob:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case g6:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case b6:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case x6:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",je);break}A=null,C=null,k=null,R=null,M.set(0,0,0),D=0,_=je,G=yt}return}Be=Be||qe,We=We||Re,ct=ct||Pe,(qe!==N||Be!==j)&&(t.blendEquationSeparate(z[qe],z[Be]),N=qe,j=Be),(Re!==A||Pe!==C||We!==k||ct!==R)&&(t.blendFuncSeparate(V[Re],V[Pe],V[We],V[ct]),A=Re,C=Pe,k=We,R=ct),(St.equals(M)===!1||Mt!==D)&&(t.blendColor(St.r,St.g,St.b,Mt),M.copy(St),D=Mt),_=je,G=!1}function Q(je,qe){je.side===Lu?O(t.CULL_FACE):E(t.CULL_FACE);let Re=je.side===io;qe&&(Re=!Re),ne(Re),je.blending===ob&&je.transparent===!1?te(Bh):te(je.blending,je.blendEquation,je.blendSrc,je.blendDst,je.blendEquationAlpha,je.blendSrcAlpha,je.blendDstAlpha,je.blendColor,je.blendAlpha,je.premultipliedAlpha),c.setFunc(je.depthFunc),c.setTest(je.depthTest),c.setMask(je.depthWrite),l.setMask(je.colorWrite);const Pe=je.stencilWrite;u.setTest(Pe),Pe&&(u.setMask(je.stencilWriteMask),u.setFunc(je.stencilFunc,je.stencilRef,je.stencilFuncMask),u.setOp(je.stencilFail,je.stencilZFail,je.stencilZPass)),fe(je.polygonOffset,je.polygonOffsetFactor,je.polygonOffsetUnits),je.alphaToCoverage===!0?E(t.SAMPLE_ALPHA_TO_COVERAGE):O(t.SAMPLE_ALPHA_TO_COVERAGE)}function ne(je){U!==je&&(je?t.frontFace(t.CW):t.frontFace(t.CCW),U=je)}function ie(je){je!==WSe?(E(t.CULL_FACE),je!==W&&(je===p6?t.cullFace(t.BACK):je===KSe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):O(t.CULL_FACE),W=je}function me(je){je!==L&&(se&&t.lineWidth(je),L=je)}function fe(je,qe,Re){je?(E(t.POLYGON_OFFSET_FILL),(ee!==qe||ae!==Re)&&(t.polygonOffset(qe,Re),ee=qe,ae=Re)):O(t.POLYGON_OFFSET_FILL)}function oe(je){je?E(t.SCISSOR_TEST):O(t.SCISSOR_TEST)}function I(je){je===void 0&&(je=t.TEXTURE0+Y-1),Z!==je&&(t.activeTexture(je),Z=je)}function F(je,qe,Re){Re===void 0&&(Z===null?Re=t.TEXTURE0+Y-1:Re=Z);let Pe=ue[Re];Pe===void 0&&(Pe={type:void 0,texture:void 0},ue[Re]=Pe),(Pe.type!==je||Pe.texture!==qe)&&(Z!==Re&&(t.activeTexture(Re),Z=Re),t.bindTexture(je,qe||T[je]),Pe.type=je,Pe.texture=qe)}function J(){const je=ue[Z];je!==void 0&&je.type!==void 0&&(t.bindTexture(je.type,null),je.type=void 0,je.texture=void 0)}function xe(){try{t.compressedTexImage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function he(){try{t.compressedTexImage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function le(){try{t.texSubImage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function Ce(){try{t.texSubImage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function Ne(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function Ue(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function He(){try{t.texStorage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function de(){try{t.texStorage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function we(){try{t.texImage2D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function ke(){try{t.texImage3D.apply(t,arguments)}catch(je){console.error("THREE.WebGLState:",je)}}function _e(je){Ee.equals(je)===!1&&(t.scissor(je.x,je.y,je.z,je.w),Ee.copy(je))}function Ae(je){$.equals(je)===!1&&(t.viewport(je.x,je.y,je.z,je.w),$.copy(je))}function Ve(je,qe){let Re=h.get(qe);Re===void 0&&(Re=new WeakMap,h.set(qe,Re));let Pe=Re.get(je);Pe===void 0&&(Pe=t.getUniformBlockIndex(qe,je.name),Re.set(je,Pe))}function Te(je,qe){const Pe=h.get(qe).get(je);d.get(qe)!==Pe&&(t.uniformBlockBinding(qe,Pe,je.__bindingPointIndex),d.set(qe,Pe))}function Ke(){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),f={},Z=null,ue={},p={},x=new WeakMap,v=[],g=null,y=!1,_=null,N=null,A=null,C=null,j=null,k=null,R=null,M=new fn(0,0,0),D=0,G=!1,U=null,W=null,L=null,ee=null,ae=null,Ee.set(0,0,t.canvas.width,t.canvas.height),$.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:E,disable:O,bindFramebuffer:q,drawBuffers:B,useProgram:re,setBlending:te,setMaterial:Q,setFlipSided:ne,setCullFace:ie,setLineWidth:me,setPolygonOffset:fe,setScissorTest:oe,activeTexture:I,bindTexture:F,unbindTexture:J,compressedTexImage2D:xe,compressedTexImage3D:he,texImage2D:we,texImage3D:ke,updateUBOMapping:Ve,uniformBlockBinding:Te,texStorage2D:He,texStorage3D:de,texSubImage2D:le,texSubImage3D:Ce,compressedTexSubImage2D:Ne,compressedTexSubImage3D:Ue,scissor:_e,viewport:Ae,reset:Ke}}function nTe(t,e,n,r,i,s,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,h=i.maxSamples,f=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let v;const g=new WeakMap;let y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(I,F){return y?new OffscreenCanvas(I,F):W1("canvas")}function N(I,F,J,xe){let he=1;if((I.width>xe||I.height>xe)&&(he=xe/Math.max(I.width,I.height)),he<1||F===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){const le=F?G1:Math.floor,Ce=le(he*I.width),Ne=le(he*I.height);v===void 0&&(v=_(Ce,Ne));const Ue=J?_(Ce,Ne):v;return Ue.width=Ce,Ue.height=Ne,Ue.getContext("2d").drawImage(I,0,0,Ce,Ne),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+Ce+"x"+Ne+")."),Ue}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function A(I){return SD(I.width)&&SD(I.height)}function C(I){return l?!1:I.wrapS!==Vl||I.wrapT!==Vl||I.minFilter!==Qi&&I.minFilter!==ul}function j(I,F){return I.generateMipmaps&&F&&I.minFilter!==Qi&&I.minFilter!==ul}function k(I){t.generateMipmap(I)}function R(I,F,J,xe,he=!1){if(l===!1)return F;if(I!==null){if(t[I]!==void 0)return t[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let le=F;if(F===t.RED&&(J===t.FLOAT&&(le=t.R32F),J===t.HALF_FLOAT&&(le=t.R16F),J===t.UNSIGNED_BYTE&&(le=t.R8)),F===t.RED_INTEGER&&(J===t.UNSIGNED_BYTE&&(le=t.R8UI),J===t.UNSIGNED_SHORT&&(le=t.R16UI),J===t.UNSIGNED_INT&&(le=t.R32UI),J===t.BYTE&&(le=t.R8I),J===t.SHORT&&(le=t.R16I),J===t.INT&&(le=t.R32I)),F===t.RG&&(J===t.FLOAT&&(le=t.RG32F),J===t.HALF_FLOAT&&(le=t.RG16F),J===t.UNSIGNED_BYTE&&(le=t.RG8)),F===t.RGBA){const Ce=he?$1:Hr.getTransfer(xe);J===t.FLOAT&&(le=t.RGBA32F),J===t.HALF_FLOAT&&(le=t.RGBA16F),J===t.UNSIGNED_BYTE&&(le=Ce===ca?t.SRGB8_ALPHA8:t.RGBA8),J===t.UNSIGNED_SHORT_4_4_4_4&&(le=t.RGBA4),J===t.UNSIGNED_SHORT_5_5_5_1&&(le=t.RGB5_A1)}return(le===t.R16F||le===t.R32F||le===t.RG16F||le===t.RG32F||le===t.RGBA16F||le===t.RGBA32F)&&e.get("EXT_color_buffer_float"),le}function M(I,F,J){return j(I,J)===!0||I.isFramebufferTexture&&I.minFilter!==Qi&&I.minFilter!==ul?Math.log2(Math.max(F.width,F.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?F.mipmaps.length:1}function D(I){return I===Qi||I===w6||I===PM?t.NEAREST:t.LINEAR}function G(I){const F=I.target;F.removeEventListener("dispose",G),W(F),F.isVideoTexture&&x.delete(F)}function U(I){const F=I.target;F.removeEventListener("dispose",U),ee(F)}function W(I){const F=r.get(I);if(F.__webglInit===void 0)return;const J=I.source,xe=g.get(J);if(xe){const he=xe[F.__cacheKey];he.usedTimes--,he.usedTimes===0&&L(I),Object.keys(xe).length===0&&g.delete(J)}r.remove(I)}function L(I){const F=r.get(I);t.deleteTexture(F.__webglTexture);const J=I.source,xe=g.get(J);delete xe[F.__cacheKey],o.memory.textures--}function ee(I){const F=I.texture,J=r.get(I),xe=r.get(F);if(xe.__webglTexture!==void 0&&(t.deleteTexture(xe.__webglTexture),o.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let he=0;he<6;he++){if(Array.isArray(J.__webglFramebuffer[he]))for(let le=0;le<J.__webglFramebuffer[he].length;le++)t.deleteFramebuffer(J.__webglFramebuffer[he][le]);else t.deleteFramebuffer(J.__webglFramebuffer[he]);J.__webglDepthbuffer&&t.deleteRenderbuffer(J.__webglDepthbuffer[he])}else{if(Array.isArray(J.__webglFramebuffer))for(let he=0;he<J.__webglFramebuffer.length;he++)t.deleteFramebuffer(J.__webglFramebuffer[he]);else t.deleteFramebuffer(J.__webglFramebuffer);if(J.__webglDepthbuffer&&t.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&t.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let he=0;he<J.__webglColorRenderbuffer.length;he++)J.__webglColorRenderbuffer[he]&&t.deleteRenderbuffer(J.__webglColorRenderbuffer[he]);J.__webglDepthRenderbuffer&&t.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(I.isWebGLMultipleRenderTargets)for(let he=0,le=F.length;he<le;he++){const Ce=r.get(F[he]);Ce.__webglTexture&&(t.deleteTexture(Ce.__webglTexture),o.memory.textures--),r.remove(F[he])}r.remove(F),r.remove(I)}let ae=0;function Y(){ae=0}function se(){const I=ae;return I>=c&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+c),ae+=1,I}function ce(I){const F=[];return F.push(I.wrapS),F.push(I.wrapT),F.push(I.wrapR||0),F.push(I.magFilter),F.push(I.minFilter),F.push(I.anisotropy),F.push(I.internalFormat),F.push(I.format),F.push(I.type),F.push(I.generateMipmaps),F.push(I.premultiplyAlpha),F.push(I.flipY),F.push(I.unpackAlignment),F.push(I.colorSpace),F.join()}function ye(I,F){const J=r.get(I);if(I.isVideoTexture&&fe(I),I.isRenderTargetTexture===!1&&I.version>0&&J.__version!==I.version){const xe=I.image;if(xe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(xe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{E(J,I,F);return}}n.bindTexture(t.TEXTURE_2D,J.__webglTexture,t.TEXTURE0+F)}function Z(I,F){const J=r.get(I);if(I.version>0&&J.__version!==I.version){E(J,I,F);return}n.bindTexture(t.TEXTURE_2D_ARRAY,J.__webglTexture,t.TEXTURE0+F)}function ue(I,F){const J=r.get(I);if(I.version>0&&J.__version!==I.version){E(J,I,F);return}n.bindTexture(t.TEXTURE_3D,J.__webglTexture,t.TEXTURE0+F)}function pe(I,F){const J=r.get(I);if(I.version>0&&J.__version!==I.version){O(J,I,F);return}n.bindTexture(t.TEXTURE_CUBE_MAP,J.__webglTexture,t.TEXTURE0+F)}const be={[xD]:t.REPEAT,[Vl]:t.CLAMP_TO_EDGE,[yD]:t.MIRRORED_REPEAT},Ee={[Qi]:t.NEAREST,[w6]:t.NEAREST_MIPMAP_NEAREST,[PM]:t.NEAREST_MIPMAP_LINEAR,[ul]:t.LINEAR,[C_e]:t.LINEAR_MIPMAP_NEAREST,[D0]:t.LINEAR_MIPMAP_LINEAR},$={[I_e]:t.NEVER,[V_e]:t.ALWAYS,[z_e]:t.LESS,[JX]:t.LEQUAL,[U_e]:t.EQUAL,[$_e]:t.GEQUAL,[B_e]:t.GREATER,[H_e]:t.NOTEQUAL};function K(I,F,J){if(J?(t.texParameteri(I,t.TEXTURE_WRAP_S,be[F.wrapS]),t.texParameteri(I,t.TEXTURE_WRAP_T,be[F.wrapT]),(I===t.TEXTURE_3D||I===t.TEXTURE_2D_ARRAY)&&t.texParameteri(I,t.TEXTURE_WRAP_R,be[F.wrapR]),t.texParameteri(I,t.TEXTURE_MAG_FILTER,Ee[F.magFilter]),t.texParameteri(I,t.TEXTURE_MIN_FILTER,Ee[F.minFilter])):(t.texParameteri(I,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(I,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(I===t.TEXTURE_3D||I===t.TEXTURE_2D_ARRAY)&&t.texParameteri(I,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(F.wrapS!==Vl||F.wrapT!==Vl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(I,t.TEXTURE_MAG_FILTER,D(F.magFilter)),t.texParameteri(I,t.TEXTURE_MIN_FILTER,D(F.minFilter)),F.minFilter!==Qi&&F.minFilter!==ul&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),F.compareFunction&&(t.texParameteri(I,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(I,t.TEXTURE_COMPARE_FUNC,$[F.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const xe=e.get("EXT_texture_filter_anisotropic");if(F.magFilter===Qi||F.minFilter!==PM&&F.minFilter!==D0||F.type===Hu&&e.has("OES_texture_float_linear")===!1||l===!1&&F.type===R0&&e.has("OES_texture_half_float_linear")===!1)return;(F.anisotropy>1||r.get(F).__currentAnisotropy)&&(t.texParameterf(I,xe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(F.anisotropy,i.getMaxAnisotropy())),r.get(F).__currentAnisotropy=F.anisotropy)}}function T(I,F){let J=!1;I.__webglInit===void 0&&(I.__webglInit=!0,F.addEventListener("dispose",G));const xe=F.source;let he=g.get(xe);he===void 0&&(he={},g.set(xe,he));const le=ce(F);if(le!==I.__cacheKey){he[le]===void 0&&(he[le]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,J=!0),he[le].usedTimes++;const Ce=he[I.__cacheKey];Ce!==void 0&&(he[I.__cacheKey].usedTimes--,Ce.usedTimes===0&&L(F)),I.__cacheKey=le,I.__webglTexture=he[le].texture}return J}function E(I,F,J){let xe=t.TEXTURE_2D;(F.isDataArrayTexture||F.isCompressedArrayTexture)&&(xe=t.TEXTURE_2D_ARRAY),F.isData3DTexture&&(xe=t.TEXTURE_3D);const he=T(I,F),le=F.source;n.bindTexture(xe,I.__webglTexture,t.TEXTURE0+J);const Ce=r.get(le);if(le.version!==Ce.__version||he===!0){n.activeTexture(t.TEXTURE0+J);const Ne=Hr.getPrimaries(Hr.workingColorSpace),Ue=F.colorSpace===hl?null:Hr.getPrimaries(F.colorSpace),He=F.colorSpace===hl||Ne===Ue?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,F.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,F.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);const de=C(F)&&A(F.image)===!1;let we=N(F.image,de,!1,d);we=oe(F,we);const ke=A(we)||l,_e=s.convert(F.format,F.colorSpace);let Ae=s.convert(F.type),Ve=R(F.internalFormat,_e,Ae,F.colorSpace,F.isVideoTexture);K(xe,F,ke);let Te;const Ke=F.mipmaps,je=l&&F.isVideoTexture!==!0&&Ve!==XX,qe=Ce.__version===void 0||he===!0,Re=M(F,we,ke);if(F.isDepthTexture)Ve=t.DEPTH_COMPONENT,l?F.type===Hu?Ve=t.DEPTH_COMPONENT32F:F.type===kh?Ve=t.DEPTH_COMPONENT24:F.type===vf?Ve=t.DEPTH24_STENCIL8:Ve=t.DEPTH_COMPONENT16:F.type===Hu&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),F.format===wf&&Ve===t.DEPTH_COMPONENT&&F.type!==d4&&F.type!==kh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),F.type=kh,Ae=s.convert(F.type)),F.format===Mb&&Ve===t.DEPTH_COMPONENT&&(Ve=t.DEPTH_STENCIL,F.type!==vf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),F.type=vf,Ae=s.convert(F.type))),qe&&(je?n.texStorage2D(t.TEXTURE_2D,1,Ve,we.width,we.height):n.texImage2D(t.TEXTURE_2D,0,Ve,we.width,we.height,0,_e,Ae,null));else if(F.isDataTexture)if(Ke.length>0&&ke){je&&qe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,Ke[0].width,Ke[0].height);for(let Pe=0,Be=Ke.length;Pe<Be;Pe++)Te=Ke[Pe],je?n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,Te.width,Te.height,_e,Ae,Te.data):n.texImage2D(t.TEXTURE_2D,Pe,Ve,Te.width,Te.height,0,_e,Ae,Te.data);F.generateMipmaps=!1}else je?(qe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,we.width,we.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,we.width,we.height,_e,Ae,we.data)):n.texImage2D(t.TEXTURE_2D,0,Ve,we.width,we.height,0,_e,Ae,we.data);else if(F.isCompressedTexture)if(F.isCompressedArrayTexture){je&&qe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Re,Ve,Ke[0].width,Ke[0].height,we.depth);for(let Pe=0,Be=Ke.length;Pe<Be;Pe++)Te=Ke[Pe],F.format!==dl?_e!==null?je?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,0,Te.width,Te.height,we.depth,_e,Te.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Pe,Ve,Te.width,Te.height,we.depth,0,Te.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):je?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,0,Te.width,Te.height,we.depth,_e,Ae,Te.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Pe,Ve,Te.width,Te.height,we.depth,0,_e,Ae,Te.data)}else{je&&qe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,Ke[0].width,Ke[0].height);for(let Pe=0,Be=Ke.length;Pe<Be;Pe++)Te=Ke[Pe],F.format!==dl?_e!==null?je?n.compressedTexSubImage2D(t.TEXTURE_2D,Pe,0,0,Te.width,Te.height,_e,Te.data):n.compressedTexImage2D(t.TEXTURE_2D,Pe,Ve,Te.width,Te.height,0,Te.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):je?n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,Te.width,Te.height,_e,Ae,Te.data):n.texImage2D(t.TEXTURE_2D,Pe,Ve,Te.width,Te.height,0,_e,Ae,Te.data)}else if(F.isDataArrayTexture)je?(qe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Re,Ve,we.width,we.height,we.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,we.width,we.height,we.depth,_e,Ae,we.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ve,we.width,we.height,we.depth,0,_e,Ae,we.data);else if(F.isData3DTexture)je?(qe&&n.texStorage3D(t.TEXTURE_3D,Re,Ve,we.width,we.height,we.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,we.width,we.height,we.depth,_e,Ae,we.data)):n.texImage3D(t.TEXTURE_3D,0,Ve,we.width,we.height,we.depth,0,_e,Ae,we.data);else if(F.isFramebufferTexture){if(qe)if(je)n.texStorage2D(t.TEXTURE_2D,Re,Ve,we.width,we.height);else{let Pe=we.width,Be=we.height;for(let We=0;We<Re;We++)n.texImage2D(t.TEXTURE_2D,We,Ve,Pe,Be,0,_e,Ae,null),Pe>>=1,Be>>=1}}else if(Ke.length>0&&ke){je&&qe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,Ke[0].width,Ke[0].height);for(let Pe=0,Be=Ke.length;Pe<Be;Pe++)Te=Ke[Pe],je?n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,_e,Ae,Te):n.texImage2D(t.TEXTURE_2D,Pe,Ve,_e,Ae,Te);F.generateMipmaps=!1}else je?(qe&&n.texStorage2D(t.TEXTURE_2D,Re,Ve,we.width,we.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,_e,Ae,we)):n.texImage2D(t.TEXTURE_2D,0,Ve,_e,Ae,we);j(F,ke)&&k(xe),Ce.__version=le.version,F.onUpdate&&F.onUpdate(F)}I.__version=F.version}function O(I,F,J){if(F.image.length!==6)return;const xe=T(I,F),he=F.source;n.bindTexture(t.TEXTURE_CUBE_MAP,I.__webglTexture,t.TEXTURE0+J);const le=r.get(he);if(he.version!==le.__version||xe===!0){n.activeTexture(t.TEXTURE0+J);const Ce=Hr.getPrimaries(Hr.workingColorSpace),Ne=F.colorSpace===hl?null:Hr.getPrimaries(F.colorSpace),Ue=F.colorSpace===hl||Ce===Ne?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,F.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,F.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ue);const He=F.isCompressedTexture||F.image[0].isCompressedTexture,de=F.image[0]&&F.image[0].isDataTexture,we=[];for(let Pe=0;Pe<6;Pe++)!He&&!de?we[Pe]=N(F.image[Pe],!1,!0,u):we[Pe]=de?F.image[Pe].image:F.image[Pe],we[Pe]=oe(F,we[Pe]);const ke=we[0],_e=A(ke)||l,Ae=s.convert(F.format,F.colorSpace),Ve=s.convert(F.type),Te=R(F.internalFormat,Ae,Ve,F.colorSpace),Ke=l&&F.isVideoTexture!==!0,je=le.__version===void 0||xe===!0;let qe=M(F,ke,_e);K(t.TEXTURE_CUBE_MAP,F,_e);let Re;if(He){Ke&&je&&n.texStorage2D(t.TEXTURE_CUBE_MAP,qe,Te,ke.width,ke.height);for(let Pe=0;Pe<6;Pe++){Re=we[Pe].mipmaps;for(let Be=0;Be<Re.length;Be++){const We=Re[Be];F.format!==dl?Ae!==null?Ke?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be,0,0,We.width,We.height,Ae,We.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be,Te,We.width,We.height,0,We.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be,0,0,We.width,We.height,Ae,Ve,We.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be,Te,We.width,We.height,0,Ae,Ve,We.data)}}}else{Re=F.mipmaps,Ke&&je&&(Re.length>0&&qe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,qe,Te,we[0].width,we[0].height));for(let Pe=0;Pe<6;Pe++)if(de){Ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0,0,0,we[Pe].width,we[Pe].height,Ae,Ve,we[Pe].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0,Te,we[Pe].width,we[Pe].height,0,Ae,Ve,we[Pe].data);for(let Be=0;Be<Re.length;Be++){const ct=Re[Be].image[Pe].image;Ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be+1,0,0,ct.width,ct.height,Ae,Ve,ct.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be+1,Te,ct.width,ct.height,0,Ae,Ve,ct.data)}}else{Ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0,0,0,Ae,Ve,we[Pe]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,0,Te,Ae,Ve,we[Pe]);for(let Be=0;Be<Re.length;Be++){const We=Re[Be];Ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be+1,0,0,Ae,Ve,We.image[Pe]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Pe,Be+1,Te,Ae,Ve,We.image[Pe])}}}j(F,_e)&&k(t.TEXTURE_CUBE_MAP),le.__version=he.version,F.onUpdate&&F.onUpdate(F)}I.__version=F.version}function q(I,F,J,xe,he,le){const Ce=s.convert(J.format,J.colorSpace),Ne=s.convert(J.type),Ue=R(J.internalFormat,Ce,Ne,J.colorSpace);if(!r.get(F).__hasExternalTextures){const de=Math.max(1,F.width>>le),we=Math.max(1,F.height>>le);he===t.TEXTURE_3D||he===t.TEXTURE_2D_ARRAY?n.texImage3D(he,le,Ue,de,we,F.depth,0,Ce,Ne,null):n.texImage2D(he,le,Ue,de,we,0,Ce,Ne,null)}n.bindFramebuffer(t.FRAMEBUFFER,I),me(F)?f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,xe,he,r.get(J).__webglTexture,0,ie(F)):(he===t.TEXTURE_2D||he>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&he<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,xe,he,r.get(J).__webglTexture,le),n.bindFramebuffer(t.FRAMEBUFFER,null)}function B(I,F,J){if(t.bindRenderbuffer(t.RENDERBUFFER,I),F.depthBuffer&&!F.stencilBuffer){let xe=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(J||me(F)){const he=F.depthTexture;he&&he.isDepthTexture&&(he.type===Hu?xe=t.DEPTH_COMPONENT32F:he.type===kh&&(xe=t.DEPTH_COMPONENT24));const le=ie(F);me(F)?f.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,le,xe,F.width,F.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,le,xe,F.width,F.height)}else t.renderbufferStorage(t.RENDERBUFFER,xe,F.width,F.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,I)}else if(F.depthBuffer&&F.stencilBuffer){const xe=ie(F);J&&me(F)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,xe,t.DEPTH24_STENCIL8,F.width,F.height):me(F)?f.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,xe,t.DEPTH24_STENCIL8,F.width,F.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,F.width,F.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,I)}else{const xe=F.isWebGLMultipleRenderTargets===!0?F.texture:[F.texture];for(let he=0;he<xe.length;he++){const le=xe[he],Ce=s.convert(le.format,le.colorSpace),Ne=s.convert(le.type),Ue=R(le.internalFormat,Ce,Ne,le.colorSpace),He=ie(F);J&&me(F)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,He,Ue,F.width,F.height):me(F)?f.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,He,Ue,F.width,F.height):t.renderbufferStorage(t.RENDERBUFFER,Ue,F.width,F.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function re(I,F){if(F&&F.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,I),!(F.depthTexture&&F.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(F.depthTexture).__webglTexture||F.depthTexture.image.width!==F.width||F.depthTexture.image.height!==F.height)&&(F.depthTexture.image.width=F.width,F.depthTexture.image.height=F.height,F.depthTexture.needsUpdate=!0),ye(F.depthTexture,0);const xe=r.get(F.depthTexture).__webglTexture,he=ie(F);if(F.depthTexture.format===wf)me(F)?f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,xe,0,he):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,xe,0);else if(F.depthTexture.format===Mb)me(F)?f.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,xe,0,he):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,xe,0);else throw new Error("Unknown depthTexture format")}function z(I){const F=r.get(I),J=I.isWebGLCubeRenderTarget===!0;if(I.depthTexture&&!F.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");re(F.__webglFramebuffer,I)}else if(J){F.__webglDepthbuffer=[];for(let xe=0;xe<6;xe++)n.bindFramebuffer(t.FRAMEBUFFER,F.__webglFramebuffer[xe]),F.__webglDepthbuffer[xe]=t.createRenderbuffer(),B(F.__webglDepthbuffer[xe],I,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,F.__webglFramebuffer),F.__webglDepthbuffer=t.createRenderbuffer(),B(F.__webglDepthbuffer,I,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function V(I,F,J){const xe=r.get(I);F!==void 0&&q(xe.__webglFramebuffer,I,I.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),J!==void 0&&z(I)}function te(I){const F=I.texture,J=r.get(I),xe=r.get(F);I.addEventListener("dispose",U),I.isWebGLMultipleRenderTargets!==!0&&(xe.__webglTexture===void 0&&(xe.__webglTexture=t.createTexture()),xe.__version=F.version,o.memory.textures++);const he=I.isWebGLCubeRenderTarget===!0,le=I.isWebGLMultipleRenderTargets===!0,Ce=A(I)||l;if(he){J.__webglFramebuffer=[];for(let Ne=0;Ne<6;Ne++)if(l&&F.mipmaps&&F.mipmaps.length>0){J.__webglFramebuffer[Ne]=[];for(let Ue=0;Ue<F.mipmaps.length;Ue++)J.__webglFramebuffer[Ne][Ue]=t.createFramebuffer()}else J.__webglFramebuffer[Ne]=t.createFramebuffer()}else{if(l&&F.mipmaps&&F.mipmaps.length>0){J.__webglFramebuffer=[];for(let Ne=0;Ne<F.mipmaps.length;Ne++)J.__webglFramebuffer[Ne]=t.createFramebuffer()}else J.__webglFramebuffer=t.createFramebuffer();if(le)if(i.drawBuffers){const Ne=I.texture;for(let Ue=0,He=Ne.length;Ue<He;Ue++){const de=r.get(Ne[Ue]);de.__webglTexture===void 0&&(de.__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&&I.samples>0&&me(I)===!1){const Ne=le?F:[F];J.__webglMultisampledFramebuffer=t.createFramebuffer(),J.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,J.__webglMultisampledFramebuffer);for(let Ue=0;Ue<Ne.length;Ue++){const He=Ne[Ue];J.__webglColorRenderbuffer[Ue]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,J.__webglColorRenderbuffer[Ue]);const de=s.convert(He.format,He.colorSpace),we=s.convert(He.type),ke=R(He.internalFormat,de,we,He.colorSpace,I.isXRRenderTarget===!0),_e=ie(I);t.renderbufferStorageMultisample(t.RENDERBUFFER,_e,ke,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ue,t.RENDERBUFFER,J.__webglColorRenderbuffer[Ue])}t.bindRenderbuffer(t.RENDERBUFFER,null),I.depthBuffer&&(J.__webglDepthRenderbuffer=t.createRenderbuffer(),B(J.__webglDepthRenderbuffer,I,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(he){n.bindTexture(t.TEXTURE_CUBE_MAP,xe.__webglTexture),K(t.TEXTURE_CUBE_MAP,F,Ce);for(let Ne=0;Ne<6;Ne++)if(l&&F.mipmaps&&F.mipmaps.length>0)for(let Ue=0;Ue<F.mipmaps.length;Ue++)q(J.__webglFramebuffer[Ne][Ue],I,F,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Ue);else q(J.__webglFramebuffer[Ne],I,F,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0);j(F,Ce)&&k(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(le){const Ne=I.texture;for(let Ue=0,He=Ne.length;Ue<He;Ue++){const de=Ne[Ue],we=r.get(de);n.bindTexture(t.TEXTURE_2D,we.__webglTexture),K(t.TEXTURE_2D,de,Ce),q(J.__webglFramebuffer,I,de,t.COLOR_ATTACHMENT0+Ue,t.TEXTURE_2D,0),j(de,Ce)&&k(t.TEXTURE_2D)}n.unbindTexture()}else{let Ne=t.TEXTURE_2D;if((I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(l?Ne=I.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ne,xe.__webglTexture),K(Ne,F,Ce),l&&F.mipmaps&&F.mipmaps.length>0)for(let Ue=0;Ue<F.mipmaps.length;Ue++)q(J.__webglFramebuffer[Ue],I,F,t.COLOR_ATTACHMENT0,Ne,Ue);else q(J.__webglFramebuffer,I,F,t.COLOR_ATTACHMENT0,Ne,0);j(F,Ce)&&k(Ne),n.unbindTexture()}I.depthBuffer&&z(I)}function Q(I){const F=A(I)||l,J=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let xe=0,he=J.length;xe<he;xe++){const le=J[xe];if(j(le,F)){const Ce=I.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ne=r.get(le).__webglTexture;n.bindTexture(Ce,Ne),k(Ce),n.unbindTexture()}}}function ne(I){if(l&&I.samples>0&&me(I)===!1){const F=I.isWebGLMultipleRenderTargets?I.texture:[I.texture],J=I.width,xe=I.height;let he=t.COLOR_BUFFER_BIT;const le=[],Ce=I.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ne=r.get(I),Ue=I.isWebGLMultipleRenderTargets===!0;if(Ue)for(let He=0;He<F.length;He++)n.bindFramebuffer(t.FRAMEBUFFER,Ne.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ne.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ne.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ne.__webglFramebuffer);for(let He=0;He<F.length;He++){le.push(t.COLOR_ATTACHMENT0+He),I.depthBuffer&&le.push(Ce);const de=Ne.__ignoreDepthValues!==void 0?Ne.__ignoreDepthValues:!1;if(de===!1&&(I.depthBuffer&&(he|=t.DEPTH_BUFFER_BIT),I.stencilBuffer&&(he|=t.STENCIL_BUFFER_BIT)),Ue&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ne.__webglColorRenderbuffer[He]),de===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Ce]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Ce])),Ue){const we=r.get(F[He]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,we,0)}t.blitFramebuffer(0,0,J,xe,0,0,J,xe,he,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,le)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ue)for(let He=0;He<F.length;He++){n.bindFramebuffer(t.FRAMEBUFFER,Ne.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.RENDERBUFFER,Ne.__webglColorRenderbuffer[He]);const de=r.get(F[He]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ne.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.TEXTURE_2D,de,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ne.__webglMultisampledFramebuffer)}}function ie(I){return Math.min(h,I.samples)}function me(I){const F=r.get(I);return l&&I.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&F.__useRenderToTexture!==!1}function fe(I){const F=o.render.frame;x.get(I)!==F&&(x.set(I,F),I.update())}function oe(I,F){const J=I.colorSpace,xe=I.format,he=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||I.format===wD||J!==ld&&J!==hl&&(Hr.getTransfer(J)===ca?l===!1?e.has("EXT_sRGB")===!0&&xe===dl?(I.format=wD,I.minFilter=ul,I.generateMipmaps=!1):F=nQ.sRGBToLinear(F):(xe!==dl||he!==$h)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",J)),F}this.allocateTextureUnit=se,this.resetTextureUnits=Y,this.setTexture2D=ye,this.setTexture2DArray=Z,this.setTexture3D=ue,this.setTextureCube=pe,this.rebindTextures=V,this.setupRenderTarget=te,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=ne,this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=q,this.useMultisampledRTT=me}function rTe(t,e,n){const r=n.isWebGL2;function i(s,o=hl){let l;const c=Hr.getTransfer(o);if(s===$h)return t.UNSIGNED_BYTE;if(s===qX)return t.UNSIGNED_SHORT_4_4_4_4;if(s===GX)return t.UNSIGNED_SHORT_5_5_5_1;if(s===A_e)return t.BYTE;if(s===T_e)return t.SHORT;if(s===d4)return t.UNSIGNED_SHORT;if(s===VX)return t.INT;if(s===kh)return t.UNSIGNED_INT;if(s===Hu)return t.FLOAT;if(s===R0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(s===M_e)return t.ALPHA;if(s===dl)return t.RGBA;if(s===P_e)return t.LUMINANCE;if(s===j_e)return t.LUMINANCE_ALPHA;if(s===wf)return t.DEPTH_COMPONENT;if(s===Mb)return t.DEPTH_STENCIL;if(s===wD)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(s===E_e)return t.RED;if(s===WX)return t.RED_INTEGER;if(s===D_e)return t.RG;if(s===KX)return t.RG_INTEGER;if(s===YX)return t.RGBA_INTEGER;if(s===jM||s===EM||s===DM||s===RM)if(c===ca)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(s===jM)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===EM)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===DM)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===RM)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(s===jM)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===EM)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===DM)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===RM)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===S6||s===_6||s===N6||s===k6)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(s===S6)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===_6)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===N6)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===k6)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===XX)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===C6||s===A6)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(s===C6)return c===ca?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(s===A6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===T6||s===M6||s===P6||s===j6||s===E6||s===D6||s===R6||s===F6||s===L6||s===O6||s===I6||s===z6||s===U6||s===B6)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(s===T6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===M6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===P6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===j6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===E6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===D6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===R6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===F6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===L6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===O6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===I6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===z6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===U6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===B6)return c===ca?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===FM||s===H6||s===$6)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(s===FM)return c===ca?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===H6)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===$6)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===R_e||s===V6||s===q6||s===G6)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(s===FM)return l.COMPRESSED_RED_RGTC1_EXT;if(s===V6)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===q6)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===G6)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===vf?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 aTe extends To{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Iy extends Os{constructor(){super(),this.isGroup=!0,this.type="Group"}}const iTe={type:"move"};class aP{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Iy,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 Iy,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new rt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new rt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Iy,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new rt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new rt),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 v of e.hand.values()){const g=n.getJointPose(v,r),y=this._getHandJoint(u,v);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=g.radius),y.visible=g!==null}const d=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],f=d.position.distanceTo(h.position),p=.02,x=.005;u.inputState.pinching&&f>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&f<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(iTe)))}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 Iy;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class sTe extends up{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,f=null,p=null,x=null;const v=n.getContextAttributes();let g=null,y=null;const _=[],N=[],A=new Tn;let C=null;const j=new To;j.layers.enable(1),j.viewport=new Vr;const k=new To;k.layers.enable(2),k.viewport=new Vr;const R=[j,k],M=new aTe;M.layers.enable(1),M.layers.enable(2);let D=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(pe){let be=_[pe];return be===void 0&&(be=new aP,_[pe]=be),be.getTargetRaySpace()},this.getControllerGrip=function(pe){let be=_[pe];return be===void 0&&(be=new aP,_[pe]=be),be.getGripSpace()},this.getHand=function(pe){let be=_[pe];return be===void 0&&(be=new aP,_[pe]=be),be.getHandSpace()};function U(pe){const be=N.indexOf(pe.inputSource);if(be===-1)return;const Ee=_[be];Ee!==void 0&&(Ee.update(pe.inputSource,pe.frame,u||o),Ee.dispatchEvent({type:pe.type,data:pe.inputSource}))}function W(){i.removeEventListener("select",U),i.removeEventListener("selectstart",U),i.removeEventListener("selectend",U),i.removeEventListener("squeeze",U),i.removeEventListener("squeezestart",U),i.removeEventListener("squeezeend",U),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",L);for(let pe=0;pe<_.length;pe++){const be=N[pe];be!==null&&(N[pe]=null,_[pe].disconnect(be))}D=null,G=null,e.setRenderTarget(g),p=null,f=null,h=null,i=null,y=null,ue.stop(),r.isPresenting=!1,e.setPixelRatio(C),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(pe){s=pe,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(pe){l=pe,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(pe){u=pe},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return h},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(pe){if(i=pe,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",U),i.addEventListener("selectstart",U),i.addEventListener("selectend",U),i.addEventListener("squeeze",U),i.addEventListener("squeezestart",U),i.addEventListener("squeezeend",U),i.addEventListener("end",W),i.addEventListener("inputsourceschange",L),v.xrCompatible!==!0&&await n.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const be={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(i,n,be),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new Vf(p.framebufferWidth,p.framebufferHeight,{format:dl,type:$h,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let be=null,Ee=null,$=null;v.depth&&($=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,be=v.stencil?Mb:wf,Ee=v.stencil?vf:kh);const K={colorFormat:n.RGBA8,depthFormat:$,scaleFactor:s};h=new XRWebGLBinding(i,n),f=h.createProjectionLayer(K),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),y=new Vf(f.textureWidth,f.textureHeight,{format:dl,type:$h,depthTexture:new fQ(f.textureWidth,f.textureHeight,Ee,void 0,void 0,void 0,void 0,void 0,void 0,be),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const T=e.properties.get(y);T.__ignoreDepthValues=f.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),ue.setContext(i),ue.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function L(pe){for(let be=0;be<pe.removed.length;be++){const Ee=pe.removed[be],$=N.indexOf(Ee);$>=0&&(N[$]=null,_[$].disconnect(Ee))}for(let be=0;be<pe.added.length;be++){const Ee=pe.added[be];let $=N.indexOf(Ee);if($===-1){for(let T=0;T<_.length;T++)if(T>=N.length){N.push(Ee),$=T;break}else if(N[T]===null){N[T]=Ee,$=T;break}if($===-1)break}const K=_[$];K&&K.connect(Ee)}}const ee=new rt,ae=new rt;function Y(pe,be,Ee){ee.setFromMatrixPosition(be.matrixWorld),ae.setFromMatrixPosition(Ee.matrixWorld);const $=ee.distanceTo(ae),K=be.projectionMatrix.elements,T=Ee.projectionMatrix.elements,E=K[14]/(K[10]-1),O=K[14]/(K[10]+1),q=(K[9]+1)/K[5],B=(K[9]-1)/K[5],re=(K[8]-1)/K[0],z=(T[8]+1)/T[0],V=E*re,te=E*z,Q=$/(-re+z),ne=Q*-re;be.matrixWorld.decompose(pe.position,pe.quaternion,pe.scale),pe.translateX(ne),pe.translateZ(Q),pe.matrixWorld.compose(pe.position,pe.quaternion,pe.scale),pe.matrixWorldInverse.copy(pe.matrixWorld).invert();const ie=E+Q,me=O+Q,fe=V-ne,oe=te+($-ne),I=q*O/me*ie,F=B*O/me*ie;pe.projectionMatrix.makePerspective(fe,oe,I,F,ie,me),pe.projectionMatrixInverse.copy(pe.projectionMatrix).invert()}function se(pe,be){be===null?pe.matrixWorld.copy(pe.matrix):pe.matrixWorld.multiplyMatrices(be.matrixWorld,pe.matrix),pe.matrixWorldInverse.copy(pe.matrixWorld).invert()}this.updateCamera=function(pe){if(i===null)return;M.near=k.near=j.near=pe.near,M.far=k.far=j.far=pe.far,(D!==M.near||G!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),D=M.near,G=M.far);const be=pe.parent,Ee=M.cameras;se(M,be);for(let $=0;$<Ee.length;$++)se(Ee[$],be);Ee.length===2?Y(M,j,k):M.projectionMatrix.copy(j.projectionMatrix),ce(pe,M,be)};function ce(pe,be,Ee){Ee===null?pe.matrix.copy(be.matrixWorld):(pe.matrix.copy(Ee.matrixWorld),pe.matrix.invert(),pe.matrix.multiply(be.matrixWorld)),pe.matrix.decompose(pe.position,pe.quaternion,pe.scale),pe.updateMatrixWorld(!0),pe.projectionMatrix.copy(be.projectionMatrix),pe.projectionMatrixInverse.copy(be.projectionMatrixInverse),pe.isPerspectiveCamera&&(pe.fov=L0*2*Math.atan(1/pe.projectionMatrix.elements[5]),pe.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(f===null&&p===null))return c},this.setFoveation=function(pe){c=pe,f!==null&&(f.fixedFoveation=pe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=pe)};let ye=null;function Z(pe,be){if(d=be.getViewerPose(u||o),x=be,d!==null){const Ee=d.views;p!==null&&(e.setRenderTargetFramebuffer(y,p.framebuffer),e.setRenderTarget(y));let $=!1;Ee.length!==M.cameras.length&&(M.cameras.length=0,$=!0);for(let K=0;K<Ee.length;K++){const T=Ee[K];let E=null;if(p!==null)E=p.getViewport(T);else{const q=h.getViewSubImage(f,T);E=q.viewport,K===0&&(e.setRenderTargetTextures(y,q.colorTexture,f.ignoreDepthValues?void 0:q.depthStencilTexture),e.setRenderTarget(y))}let O=R[K];O===void 0&&(O=new To,O.layers.enable(K),O.viewport=new Vr,R[K]=O),O.matrix.fromArray(T.transform.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale),O.projectionMatrix.fromArray(T.projectionMatrix),O.projectionMatrixInverse.copy(O.projectionMatrix).invert(),O.viewport.set(E.x,E.y,E.width,E.height),K===0&&(M.matrix.copy(O.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),$===!0&&M.cameras.push(O)}}for(let Ee=0;Ee<_.length;Ee++){const $=N[Ee],K=_[Ee];$!==null&&K!==void 0&&K.update($,be,u||o)}ye&&ye(pe,be),be.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:be}),x=null}const ue=new mQ;ue.setAnimationLoop(Z),this.setAnimationLoop=function(pe){ye=pe},this.dispose=function(){}}}function oTe(t,e){function n(g,y){g.matrixAutoUpdate===!0&&g.updateMatrix(),y.value.copy(g.matrix)}function r(g,y){y.color.getRGB(g.fogColor.value,uQ(t)),y.isFog?(g.fogNear.value=y.near,g.fogFar.value=y.far):y.isFogExp2&&(g.fogDensity.value=y.density)}function i(g,y,_,N,A){y.isMeshBasicMaterial||y.isMeshLambertMaterial?s(g,y):y.isMeshToonMaterial?(s(g,y),h(g,y)):y.isMeshPhongMaterial?(s(g,y),d(g,y)):y.isMeshStandardMaterial?(s(g,y),f(g,y),y.isMeshPhysicalMaterial&&p(g,y,A)):y.isMeshMatcapMaterial?(s(g,y),x(g,y)):y.isMeshDepthMaterial?s(g,y):y.isMeshDistanceMaterial?(s(g,y),v(g,y)):y.isMeshNormalMaterial?s(g,y):y.isLineBasicMaterial?(o(g,y),y.isLineDashedMaterial&&l(g,y)):y.isPointsMaterial?c(g,y,_,N):y.isSpriteMaterial?u(g,y):y.isShadowMaterial?(g.color.value.copy(y.color),g.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function s(g,y){g.opacity.value=y.opacity,y.color&&g.diffuse.value.copy(y.color),y.emissive&&g.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(g.map.value=y.map,n(y.map,g.mapTransform)),y.alphaMap&&(g.alphaMap.value=y.alphaMap,n(y.alphaMap,g.alphaMapTransform)),y.bumpMap&&(g.bumpMap.value=y.bumpMap,n(y.bumpMap,g.bumpMapTransform),g.bumpScale.value=y.bumpScale,y.side===io&&(g.bumpScale.value*=-1)),y.normalMap&&(g.normalMap.value=y.normalMap,n(y.normalMap,g.normalMapTransform),g.normalScale.value.copy(y.normalScale),y.side===io&&g.normalScale.value.negate()),y.displacementMap&&(g.displacementMap.value=y.displacementMap,n(y.displacementMap,g.displacementMapTransform),g.displacementScale.value=y.displacementScale,g.displacementBias.value=y.displacementBias),y.emissiveMap&&(g.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,g.emissiveMapTransform)),y.specularMap&&(g.specularMap.value=y.specularMap,n(y.specularMap,g.specularMapTransform)),y.alphaTest>0&&(g.alphaTest.value=y.alphaTest);const _=e.get(y).envMap;if(_&&(g.envMap.value=_,g.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=y.reflectivity,g.ior.value=y.ior,g.refractionRatio.value=y.refractionRatio),y.lightMap){g.lightMap.value=y.lightMap;const N=t._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=y.lightMapIntensity*N,n(y.lightMap,g.lightMapTransform)}y.aoMap&&(g.aoMap.value=y.aoMap,g.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,g.aoMapTransform))}function o(g,y){g.diffuse.value.copy(y.color),g.opacity.value=y.opacity,y.map&&(g.map.value=y.map,n(y.map,g.mapTransform))}function l(g,y){g.dashSize.value=y.dashSize,g.totalSize.value=y.dashSize+y.gapSize,g.scale.value=y.scale}function c(g,y,_,N){g.diffuse.value.copy(y.color),g.opacity.value=y.opacity,g.size.value=y.size*_,g.scale.value=N*.5,y.map&&(g.map.value=y.map,n(y.map,g.uvTransform)),y.alphaMap&&(g.alphaMap.value=y.alphaMap,n(y.alphaMap,g.alphaMapTransform)),y.alphaTest>0&&(g.alphaTest.value=y.alphaTest)}function u(g,y){g.diffuse.value.copy(y.color),g.opacity.value=y.opacity,g.rotation.value=y.rotation,y.map&&(g.map.value=y.map,n(y.map,g.mapTransform)),y.alphaMap&&(g.alphaMap.value=y.alphaMap,n(y.alphaMap,g.alphaMapTransform)),y.alphaTest>0&&(g.alphaTest.value=y.alphaTest)}function d(g,y){g.specular.value.copy(y.specular),g.shininess.value=Math.max(y.shininess,1e-4)}function h(g,y){y.gradientMap&&(g.gradientMap.value=y.gradientMap)}function f(g,y){g.metalness.value=y.metalness,y.metalnessMap&&(g.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,g.metalnessMapTransform)),g.roughness.value=y.roughness,y.roughnessMap&&(g.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,g.roughnessMapTransform)),e.get(y).envMap&&(g.envMapIntensity.value=y.envMapIntensity)}function p(g,y,_){g.ior.value=y.ior,y.sheen>0&&(g.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),g.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(g.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,g.sheenColorMapTransform)),y.sheenRoughnessMap&&(g.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,g.sheenRoughnessMapTransform))),y.clearcoat>0&&(g.clearcoat.value=y.clearcoat,g.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(g.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,g.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(g.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===io&&g.clearcoatNormalScale.value.negate())),y.iridescence>0&&(g.iridescence.value=y.iridescence,g.iridescenceIOR.value=y.iridescenceIOR,g.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(g.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,g.iridescenceMapTransform)),y.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),y.transmission>0&&(g.transmission.value=y.transmission,g.transmissionSamplerMap.value=_.texture,g.transmissionSamplerSize.value.set(_.width,_.height),y.transmissionMap&&(g.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,g.transmissionMapTransform)),g.thickness.value=y.thickness,y.thicknessMap&&(g.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=y.attenuationDistance,g.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(g.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(g.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=y.specularIntensity,g.specularColor.value.copy(y.specularColor),y.specularColorMap&&(g.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,g.specularColorMapTransform)),y.specularIntensityMap&&(g.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,g.specularIntensityMapTransform))}function x(g,y){y.matcap&&(g.matcap.value=y.matcap)}function v(g,y){const _=e.get(y).light;g.referencePosition.value.setFromMatrixPosition(_.matrixWorld),g.nearDistance.value=_.shadow.camera.near,g.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function lTe(t,e,n,r){let i={},s={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(_,N){const A=N.program;r.uniformBlockBinding(_,A)}function u(_,N){let A=i[_.id];A===void 0&&(x(_),A=d(_),i[_.id]=A,_.addEventListener("dispose",g));const C=N.program;r.updateUBOMapping(_,C);const j=e.render.frame;s[_.id]!==j&&(f(_),s[_.id]=j)}function d(_){const N=h();_.__bindingPointIndex=N;const A=t.createBuffer(),C=_.__size,j=_.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,C,j),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,A),A}function h(){for(let _=0;_<l;_++)if(o.indexOf(_)===-1)return o.push(_),_;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(_){const N=i[_.id],A=_.uniforms,C=_.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let j=0,k=A.length;j<k;j++){const R=A[j];if(p(R,j,C)===!0){const M=R.__offset,D=Array.isArray(R.value)?R.value:[R.value];let G=0;for(let U=0;U<D.length;U++){const W=D[U],L=v(W);typeof W=="number"?(R.__data[0]=W,t.bufferSubData(t.UNIFORM_BUFFER,M+G,R.__data)):W.isMatrix3?(R.__data[0]=W.elements[0],R.__data[1]=W.elements[1],R.__data[2]=W.elements[2],R.__data[3]=W.elements[0],R.__data[4]=W.elements[3],R.__data[5]=W.elements[4],R.__data[6]=W.elements[5],R.__data[7]=W.elements[0],R.__data[8]=W.elements[6],R.__data[9]=W.elements[7],R.__data[10]=W.elements[8],R.__data[11]=W.elements[0]):(W.toArray(R.__data,G),G+=L.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,M,R.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(_,N,A){const C=_.value;if(A[N]===void 0){if(typeof C=="number")A[N]=C;else{const j=Array.isArray(C)?C:[C],k=[];for(let R=0;R<j.length;R++)k.push(j[R].clone());A[N]=k}return!0}else if(typeof C=="number"){if(A[N]!==C)return A[N]=C,!0}else{const j=Array.isArray(A[N])?A[N]:[A[N]],k=Array.isArray(C)?C:[C];for(let R=0;R<j.length;R++){const M=j[R];if(M.equals(k[R])===!1)return M.copy(k[R]),!0}}return!1}function x(_){const N=_.uniforms;let A=0;const C=16;let j=0;for(let k=0,R=N.length;k<R;k++){const M=N[k],D={boundary:0,storage:0},G=Array.isArray(M.value)?M.value:[M.value];for(let U=0,W=G.length;U<W;U++){const L=G[U],ee=v(L);D.boundary+=ee.boundary,D.storage+=ee.storage}if(M.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=A,k>0){j=A%C;const U=C-j;j!==0&&U-D.boundary<0&&(A+=C-j,M.__offset=A)}A+=D.storage}return j=A%C,j>0&&(A+=C-j),_.__size=A,_.__cache={},this}function v(_){const N={boundary:0,storage:0};return typeof _=="number"?(N.boundary=4,N.storage=4):_.isVector2?(N.boundary=8,N.storage=8):_.isVector3||_.isColor?(N.boundary=16,N.storage=12):_.isVector4?(N.boundary=16,N.storage=16):_.isMatrix3?(N.boundary=48,N.storage=48):_.isMatrix4?(N.boundary=64,N.storage=64):_.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",_),N}function g(_){const N=_.target;N.removeEventListener("dispose",g);const A=o.indexOf(N.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete s[N.id]}function y(){for(const _ in i)t.deleteBuffer(i[_]);o=[],i={},s={}}return{bind:c,update:u,dispose:y}}class ND{constructor(e={}){const{canvas:n=i1e(),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 f;r!==null?f=r.getContextAttributes().alpha:f=o;const p=new Uint32Array(4),x=new Int32Array(4);let v=null,g=null;const y=[],_=[];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=Zi,this._useLegacyLights=!1,this.toneMapping=Hh,this.toneMappingExposure=1;const N=this;let A=!1,C=0,j=0,k=null,R=-1,M=null;const D=new Vr,G=new Vr;let U=null;const W=new fn(0);let L=0,ee=n.width,ae=n.height,Y=1,se=null,ce=null;const ye=new Vr(0,0,ee,ae),Z=new Vr(0,0,ee,ae);let ue=!1;const pe=new xC;let be=!1,Ee=!1,$=null;const K=new ia,T=new Tn,E=new rt,O={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return k===null?Y:1}let B=r;function re(ze,De){for(let Ze=0;Ze<ze.length;Ze++){const st=ze[Ze],Ye=n.getContext(st,De);if(Ye!==null)return Ye}return null}try{const ze={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${pC}`),n.addEventListener("webglcontextlost",Ke,!1),n.addEventListener("webglcontextrestored",je,!1),n.addEventListener("webglcontextcreationerror",qe,!1),B===null){const De=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&De.shift(),B=re(De,ze),B===null)throw re(De)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&B instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),B.getShaderPrecisionFormat===void 0&&(B.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(ze){throw console.error("THREE.WebGLRenderer: "+ze.message),ze}let z,V,te,Q,ne,ie,me,fe,oe,I,F,J,xe,he,le,Ce,Ne,Ue,He,de,we,ke,_e,Ae;function Ve(){z=new yCe(B),V=new hCe(B,z,e),z.init(V),ke=new rTe(B,z,V),te=new tTe(B,z,V),Q=new SCe(B),ne=new BAe,ie=new nTe(B,z,te,ne,V,ke,Q),me=new fCe(N),fe=new xCe(N),oe=new M1e(B,V),_e=new uCe(B,z,oe,V),I=new vCe(B,oe,Q,_e),F=new CCe(B,I,oe,Q),He=new kCe(B,V,ie),Ce=new mCe(ne),J=new UAe(N,me,fe,z,V,_e,Ce),xe=new oTe(N,ne),he=new $Ae,le=new YAe(z,V),Ue=new cCe(N,me,fe,te,F,f,c),Ne=new eTe(N,F,V),Ae=new lTe(B,Q,V,te),de=new dCe(B,z,Q,V),we=new wCe(B,z,Q,V),Q.programs=J.programs,N.capabilities=V,N.extensions=z,N.properties=ne,N.renderLists=he,N.shadowMap=Ne,N.state=te,N.info=Q}Ve();const Te=new sTe(N,B);this.xr=Te,this.getContext=function(){return B},this.getContextAttributes=function(){return B.getContextAttributes()},this.forceContextLoss=function(){const ze=z.get("WEBGL_lose_context");ze&&ze.loseContext()},this.forceContextRestore=function(){const ze=z.get("WEBGL_lose_context");ze&&ze.restoreContext()},this.getPixelRatio=function(){return Y},this.setPixelRatio=function(ze){ze!==void 0&&(Y=ze,this.setSize(ee,ae,!1))},this.getSize=function(ze){return ze.set(ee,ae)},this.setSize=function(ze,De,Ze=!0){if(Te.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ee=ze,ae=De,n.width=Math.floor(ze*Y),n.height=Math.floor(De*Y),Ze===!0&&(n.style.width=ze+"px",n.style.height=De+"px"),this.setViewport(0,0,ze,De)},this.getDrawingBufferSize=function(ze){return ze.set(ee*Y,ae*Y).floor()},this.setDrawingBufferSize=function(ze,De,Ze){ee=ze,ae=De,Y=Ze,n.width=Math.floor(ze*Ze),n.height=Math.floor(De*Ze),this.setViewport(0,0,ze,De)},this.getCurrentViewport=function(ze){return ze.copy(D)},this.getViewport=function(ze){return ze.copy(ye)},this.setViewport=function(ze,De,Ze,st){ze.isVector4?ye.set(ze.x,ze.y,ze.z,ze.w):ye.set(ze,De,Ze,st),te.viewport(D.copy(ye).multiplyScalar(Y).floor())},this.getScissor=function(ze){return ze.copy(Z)},this.setScissor=function(ze,De,Ze,st){ze.isVector4?Z.set(ze.x,ze.y,ze.z,ze.w):Z.set(ze,De,Ze,st),te.scissor(G.copy(Z).multiplyScalar(Y).floor())},this.getScissorTest=function(){return ue},this.setScissorTest=function(ze){te.setScissorTest(ue=ze)},this.setOpaqueSort=function(ze){se=ze},this.setTransparentSort=function(ze){ce=ze},this.getClearColor=function(ze){return ze.copy(Ue.getClearColor())},this.setClearColor=function(){Ue.setClearColor.apply(Ue,arguments)},this.getClearAlpha=function(){return Ue.getClearAlpha()},this.setClearAlpha=function(){Ue.setClearAlpha.apply(Ue,arguments)},this.clear=function(ze=!0,De=!0,Ze=!0){let st=0;if(ze){let Ye=!1;if(k!==null){const It=k.texture.format;Ye=It===YX||It===KX||It===WX}if(Ye){const It=k.texture.type,Me=It===$h||It===kh||It===d4||It===vf||It===qX||It===GX,Ge=Ue.getClearColor(),et=Ue.getClearAlpha(),Qe=Ge.r,Le=Ge.g,ht=Ge.b;Me?(p[0]=Qe,p[1]=Le,p[2]=ht,p[3]=et,B.clearBufferuiv(B.COLOR,0,p)):(x[0]=Qe,x[1]=Le,x[2]=ht,x[3]=et,B.clearBufferiv(B.COLOR,0,x))}else st|=B.COLOR_BUFFER_BIT}De&&(st|=B.DEPTH_BUFFER_BIT),Ze&&(st|=B.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B.clear(st)},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",Ke,!1),n.removeEventListener("webglcontextrestored",je,!1),n.removeEventListener("webglcontextcreationerror",qe,!1),he.dispose(),le.dispose(),ne.dispose(),me.dispose(),fe.dispose(),F.dispose(),_e.dispose(),Ae.dispose(),J.dispose(),Te.dispose(),Te.removeEventListener("sessionstart",Mt),Te.removeEventListener("sessionend",yt),$&&($.dispose(),$=null),$e.stop()};function Ke(ze){ze.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function je(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const ze=Q.autoReset,De=Ne.enabled,Ze=Ne.autoUpdate,st=Ne.needsUpdate,Ye=Ne.type;Ve(),Q.autoReset=ze,Ne.enabled=De,Ne.autoUpdate=Ze,Ne.needsUpdate=st,Ne.type=Ye}function qe(ze){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ze.statusMessage)}function Re(ze){const De=ze.target;De.removeEventListener("dispose",Re),Pe(De)}function Pe(ze){Be(ze),ne.remove(ze)}function Be(ze){const De=ne.get(ze).programs;De!==void 0&&(De.forEach(function(Ze){J.releaseProgram(Ze)}),ze.isShaderMaterial&&J.releaseShaderCache(ze))}this.renderBufferDirect=function(ze,De,Ze,st,Ye,It){De===null&&(De=O);const Me=Ye.isMesh&&Ye.matrixWorld.determinant()<0,Ge=On(ze,De,Ze,st,Ye);te.setMaterial(st,Me);let et=Ze.index,Qe=1;if(st.wireframe===!0){if(et=I.getWireframeAttribute(Ze),et===void 0)return;Qe=2}const Le=Ze.drawRange,ht=Ze.attributes.position;let it=Le.start*Qe,tt=(Le.start+Le.count)*Qe;It!==null&&(it=Math.max(it,It.start*Qe),tt=Math.min(tt,(It.start+It.count)*Qe)),et!==null?(it=Math.max(it,0),tt=Math.min(tt,et.count)):ht!=null&&(it=Math.max(it,0),tt=Math.min(tt,ht.count));const _t=tt-it;if(_t<0||_t===1/0)return;_e.setup(Ye,st,Ge,Ze,et);let jt,Dt=de;if(et!==null&&(jt=oe.get(et),Dt=we,Dt.setIndex(jt)),Ye.isMesh)st.wireframe===!0?(te.setLineWidth(st.wireframeLinewidth*q()),Dt.setMode(B.LINES)):Dt.setMode(B.TRIANGLES);else if(Ye.isLine){let Rt=st.linewidth;Rt===void 0&&(Rt=1),te.setLineWidth(Rt*q()),Ye.isLineSegments?Dt.setMode(B.LINES):Ye.isLineLoop?Dt.setMode(B.LINE_LOOP):Dt.setMode(B.LINE_STRIP)}else Ye.isPoints?Dt.setMode(B.POINTS):Ye.isSprite&&Dt.setMode(B.TRIANGLES);if(Ye.isBatchedMesh)Dt.renderMultiDraw(Ye._multiDrawStarts,Ye._multiDrawCounts,Ye._multiDrawCount);else if(Ye.isInstancedMesh)Dt.renderInstances(it,_t,Ye.count);else if(Ze.isInstancedBufferGeometry){const Rt=Ze._maxInstanceCount!==void 0?Ze._maxInstanceCount:1/0,tn=Math.min(Ze.instanceCount,Rt);Dt.renderInstances(it,_t,tn)}else Dt.render(it,_t)};function We(ze,De,Ze){ze.transparent===!0&&ze.side===Lu&&ze.forceSinglePass===!1?(ze.side=io,ze.needsUpdate=!0,_n(ze,De,Ze),ze.side=Jh,ze.needsUpdate=!0,_n(ze,De,Ze),ze.side=Lu):_n(ze,De,Ze)}this.compile=function(ze,De,Ze=null){Ze===null&&(Ze=ze),g=le.get(Ze),g.init(),_.push(g),Ze.traverseVisible(function(Ye){Ye.isLight&&Ye.layers.test(De.layers)&&(g.pushLight(Ye),Ye.castShadow&&g.pushShadow(Ye))}),ze!==Ze&&ze.traverseVisible(function(Ye){Ye.isLight&&Ye.layers.test(De.layers)&&(g.pushLight(Ye),Ye.castShadow&&g.pushShadow(Ye))}),g.setupLights(N._useLegacyLights);const st=new Set;return ze.traverse(function(Ye){const It=Ye.material;if(It)if(Array.isArray(It))for(let Me=0;Me<It.length;Me++){const Ge=It[Me];We(Ge,Ze,Ye),st.add(Ge)}else We(It,Ze,Ye),st.add(It)}),_.pop(),g=null,st},this.compileAsync=function(ze,De,Ze=null){const st=this.compile(ze,De,Ze);return new Promise(Ye=>{function It(){if(st.forEach(function(Me){ne.get(Me).currentProgram.isReady()&&st.delete(Me)}),st.size===0){Ye(ze);return}setTimeout(It,10)}z.get("KHR_parallel_shader_compile")!==null?It():setTimeout(It,10)})};let ct=null;function St(ze){ct&&ct(ze)}function Mt(){$e.stop()}function yt(){$e.start()}const $e=new mQ;$e.setAnimationLoop(St),typeof self<"u"&&$e.setContext(self),this.setAnimationLoop=function(ze){ct=ze,Te.setAnimationLoop(ze),ze===null?$e.stop():$e.start()},Te.addEventListener("sessionstart",Mt),Te.addEventListener("sessionend",yt),this.render=function(ze,De){if(De!==void 0&&De.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;ze.matrixWorldAutoUpdate===!0&&ze.updateMatrixWorld(),De.parent===null&&De.matrixWorldAutoUpdate===!0&&De.updateMatrixWorld(),Te.enabled===!0&&Te.isPresenting===!0&&(Te.cameraAutoUpdate===!0&&Te.updateCamera(De),De=Te.getCamera()),ze.isScene===!0&&ze.onBeforeRender(N,ze,De,k),g=le.get(ze,_.length),g.init(),_.push(g),K.multiplyMatrices(De.projectionMatrix,De.matrixWorldInverse),pe.setFromProjectionMatrix(K),Ee=this.localClippingEnabled,be=Ce.init(this.clippingPlanes,Ee),v=he.get(ze,y.length),v.init(),y.push(v),dt(ze,De,0,N.sortObjects),v.finish(),N.sortObjects===!0&&v.sort(se,ce),this.info.render.frame++,be===!0&&Ce.beginShadows();const Ze=g.state.shadowsArray;if(Ne.render(Ze,ze,De),be===!0&&Ce.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ue.render(v,ze),g.setupLights(N._useLegacyLights),De.isArrayCamera){const st=De.cameras;for(let Ye=0,It=st.length;Ye<It;Ye++){const Me=st[Ye];gt(v,ze,Me,Me.viewport)}}else gt(v,ze,De);k!==null&&(ie.updateMultisampleRenderTarget(k),ie.updateRenderTargetMipmap(k)),ze.isScene===!0&&ze.onAfterRender(N,ze,De),_e.resetDefaultState(),R=-1,M=null,_.pop(),_.length>0?g=_[_.length-1]:g=null,y.pop(),y.length>0?v=y[y.length-1]:v=null};function dt(ze,De,Ze,st){if(ze.visible===!1)return;if(ze.layers.test(De.layers)){if(ze.isGroup)Ze=ze.renderOrder;else if(ze.isLOD)ze.autoUpdate===!0&&ze.update(De);else if(ze.isLight)g.pushLight(ze),ze.castShadow&&g.pushShadow(ze);else if(ze.isSprite){if(!ze.frustumCulled||pe.intersectsSprite(ze)){st&&E.setFromMatrixPosition(ze.matrixWorld).applyMatrix4(K);const Me=F.update(ze),Ge=ze.material;Ge.visible&&v.push(ze,Me,Ge,Ze,E.z,null)}}else if((ze.isMesh||ze.isLine||ze.isPoints)&&(!ze.frustumCulled||pe.intersectsObject(ze))){const Me=F.update(ze),Ge=ze.material;if(st&&(ze.boundingSphere!==void 0?(ze.boundingSphere===null&&ze.computeBoundingSphere(),E.copy(ze.boundingSphere.center)):(Me.boundingSphere===null&&Me.computeBoundingSphere(),E.copy(Me.boundingSphere.center)),E.applyMatrix4(ze.matrixWorld).applyMatrix4(K)),Array.isArray(Ge)){const et=Me.groups;for(let Qe=0,Le=et.length;Qe<Le;Qe++){const ht=et[Qe],it=Ge[ht.materialIndex];it&&it.visible&&v.push(ze,Me,it,Ze,E.z,ht)}}else Ge.visible&&v.push(ze,Me,Ge,Ze,E.z,null)}}const It=ze.children;for(let Me=0,Ge=It.length;Me<Ge;Me++)dt(It[Me],De,Ze,st)}function gt(ze,De,Ze,st){const Ye=ze.opaque,It=ze.transmissive,Me=ze.transparent;g.setupLightsView(Ze),be===!0&&Ce.setGlobalState(N.clippingPlanes,Ze),It.length>0&&Lt(Ye,It,De,Ze),st&&te.viewport(D.copy(st)),Ye.length>0&&en(Ye,De,Ze),It.length>0&&en(It,De,Ze),Me.length>0&&en(Me,De,Ze),te.buffers.depth.setTest(!0),te.buffers.depth.setMask(!0),te.buffers.color.setMask(!0),te.setPolygonOffset(!1)}function Lt(ze,De,Ze,st){if((Ze.isScene===!0?Ze.overrideMaterial:null)!==null)return;const It=V.isWebGL2;$===null&&($=new Vf(1,1,{generateMipmaps:!0,type:z.has("EXT_color_buffer_half_float")?R0:$h,minFilter:D0,samples:It?4:0})),N.getDrawingBufferSize(T),It?$.setSize(T.x,T.y):$.setSize(G1(T.x),G1(T.y));const Me=N.getRenderTarget();N.setRenderTarget($),N.getClearColor(W),L=N.getClearAlpha(),L<1&&N.setClearColor(16777215,.5),N.clear();const Ge=N.toneMapping;N.toneMapping=Hh,en(ze,Ze,st),ie.updateMultisampleRenderTarget($),ie.updateRenderTargetMipmap($);let et=!1;for(let Qe=0,Le=De.length;Qe<Le;Qe++){const ht=De[Qe],it=ht.object,tt=ht.geometry,_t=ht.material,jt=ht.group;if(_t.side===Lu&&it.layers.test(st.layers)){const Dt=_t.side;_t.side=io,_t.needsUpdate=!0,pn(it,Ze,st,tt,_t,jt),_t.side=Dt,_t.needsUpdate=!0,et=!0}}et===!0&&(ie.updateMultisampleRenderTarget($),ie.updateRenderTargetMipmap($)),N.setRenderTarget(Me),N.setClearColor(W,L),N.toneMapping=Ge}function en(ze,De,Ze){const st=De.isScene===!0?De.overrideMaterial:null;for(let Ye=0,It=ze.length;Ye<It;Ye++){const Me=ze[Ye],Ge=Me.object,et=Me.geometry,Qe=st===null?Me.material:st,Le=Me.group;Ge.layers.test(Ze.layers)&&pn(Ge,De,Ze,et,Qe,Le)}}function pn(ze,De,Ze,st,Ye,It){ze.onBeforeRender(N,De,Ze,st,Ye,It),ze.modelViewMatrix.multiplyMatrices(Ze.matrixWorldInverse,ze.matrixWorld),ze.normalMatrix.getNormalMatrix(ze.modelViewMatrix),Ye.onBeforeRender(N,De,Ze,st,ze,It),Ye.transparent===!0&&Ye.side===Lu&&Ye.forceSinglePass===!1?(Ye.side=io,Ye.needsUpdate=!0,N.renderBufferDirect(Ze,De,st,Ye,ze,It),Ye.side=Jh,Ye.needsUpdate=!0,N.renderBufferDirect(Ze,De,st,Ye,ze,It),Ye.side=Lu):N.renderBufferDirect(Ze,De,st,Ye,ze,It),ze.onAfterRender(N,De,Ze,st,Ye,It)}function _n(ze,De,Ze){De.isScene!==!0&&(De=O);const st=ne.get(ze),Ye=g.state.lights,It=g.state.shadowsArray,Me=Ye.state.version,Ge=J.getParameters(ze,Ye.state,It,De,Ze),et=J.getProgramCacheKey(Ge);let Qe=st.programs;st.environment=ze.isMeshStandardMaterial?De.environment:null,st.fog=De.fog,st.envMap=(ze.isMeshStandardMaterial?fe:me).get(ze.envMap||st.environment),Qe===void 0&&(ze.addEventListener("dispose",Re),Qe=new Map,st.programs=Qe);let Le=Qe.get(et);if(Le!==void 0){if(st.currentProgram===Le&&st.lightsStateVersion===Me)return gn(ze,Ge),Le}else Ge.uniforms=J.getUniforms(ze),ze.onBuild(Ze,Ge,N),ze.onBeforeCompile(Ge,N),Le=J.acquireProgram(Ge,et),Qe.set(et,Le),st.uniforms=Ge.uniforms;const ht=st.uniforms;return(!ze.isShaderMaterial&&!ze.isRawShaderMaterial||ze.clipping===!0)&&(ht.clippingPlanes=Ce.uniform),gn(ze,Ge),st.needsLights=zn(ze),st.lightsStateVersion=Me,st.needsLights&&(ht.ambientLightColor.value=Ye.state.ambient,ht.lightProbe.value=Ye.state.probe,ht.directionalLights.value=Ye.state.directional,ht.directionalLightShadows.value=Ye.state.directionalShadow,ht.spotLights.value=Ye.state.spot,ht.spotLightShadows.value=Ye.state.spotShadow,ht.rectAreaLights.value=Ye.state.rectArea,ht.ltc_1.value=Ye.state.rectAreaLTC1,ht.ltc_2.value=Ye.state.rectAreaLTC2,ht.pointLights.value=Ye.state.point,ht.pointLightShadows.value=Ye.state.pointShadow,ht.hemisphereLights.value=Ye.state.hemi,ht.directionalShadowMap.value=Ye.state.directionalShadowMap,ht.directionalShadowMatrix.value=Ye.state.directionalShadowMatrix,ht.spotShadowMap.value=Ye.state.spotShadowMap,ht.spotLightMatrix.value=Ye.state.spotLightMatrix,ht.spotLightMap.value=Ye.state.spotLightMap,ht.pointShadowMap.value=Ye.state.pointShadowMap,ht.pointShadowMatrix.value=Ye.state.pointShadowMatrix),st.currentProgram=Le,st.uniformsList=null,Le}function hn(ze){if(ze.uniformsList===null){const De=ze.currentProgram.getUniforms();ze.uniformsList=o1.seqWithValue(De.seq,ze.uniforms)}return ze.uniformsList}function gn(ze,De){const Ze=ne.get(ze);Ze.outputColorSpace=De.outputColorSpace,Ze.batching=De.batching,Ze.instancing=De.instancing,Ze.instancingColor=De.instancingColor,Ze.skinning=De.skinning,Ze.morphTargets=De.morphTargets,Ze.morphNormals=De.morphNormals,Ze.morphColors=De.morphColors,Ze.morphTargetsCount=De.morphTargetsCount,Ze.numClippingPlanes=De.numClippingPlanes,Ze.numIntersection=De.numClipIntersection,Ze.vertexAlphas=De.vertexAlphas,Ze.vertexTangents=De.vertexTangents,Ze.toneMapping=De.toneMapping}function On(ze,De,Ze,st,Ye){De.isScene!==!0&&(De=O),ie.resetTextureUnits();const It=De.fog,Me=st.isMeshStandardMaterial?De.environment:null,Ge=k===null?N.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:ld,et=(st.isMeshStandardMaterial?fe:me).get(st.envMap||Me),Qe=st.vertexColors===!0&&!!Ze.attributes.color&&Ze.attributes.color.itemSize===4,Le=!!Ze.attributes.tangent&&(!!st.normalMap||st.anisotropy>0),ht=!!Ze.morphAttributes.position,it=!!Ze.morphAttributes.normal,tt=!!Ze.morphAttributes.color;let _t=Hh;st.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(_t=N.toneMapping);const jt=Ze.morphAttributes.position||Ze.morphAttributes.normal||Ze.morphAttributes.color,Dt=jt!==void 0?jt.length:0,Rt=ne.get(st),tn=g.state.lights;if(be===!0&&(Ee===!0||ze!==M)){const yn=ze===M&&st.id===R;Ce.setState(st,ze,yn)}let nn=!1;st.version===Rt.__version?(Rt.needsLights&&Rt.lightsStateVersion!==tn.state.version||Rt.outputColorSpace!==Ge||Ye.isBatchedMesh&&Rt.batching===!1||!Ye.isBatchedMesh&&Rt.batching===!0||Ye.isInstancedMesh&&Rt.instancing===!1||!Ye.isInstancedMesh&&Rt.instancing===!0||Ye.isSkinnedMesh&&Rt.skinning===!1||!Ye.isSkinnedMesh&&Rt.skinning===!0||Ye.isInstancedMesh&&Rt.instancingColor===!0&&Ye.instanceColor===null||Ye.isInstancedMesh&&Rt.instancingColor===!1&&Ye.instanceColor!==null||Rt.envMap!==et||st.fog===!0&&Rt.fog!==It||Rt.numClippingPlanes!==void 0&&(Rt.numClippingPlanes!==Ce.numPlanes||Rt.numIntersection!==Ce.numIntersection)||Rt.vertexAlphas!==Qe||Rt.vertexTangents!==Le||Rt.morphTargets!==ht||Rt.morphNormals!==it||Rt.morphColors!==tt||Rt.toneMapping!==_t||V.isWebGL2===!0&&Rt.morphTargetsCount!==Dt)&&(nn=!0):(nn=!0,Rt.__version=st.version);let ln=Rt.currentProgram;nn===!0&&(ln=_n(st,De,Ye));let vn=!1,Rn=!1,Zt=!1;const xn=ln.getUniforms(),mn=Rt.uniforms;if(te.useProgram(ln.program)&&(vn=!0,Rn=!0,Zt=!0),st.id!==R&&(R=st.id,Rn=!0),vn||M!==ze){xn.setValue(B,"projectionMatrix",ze.projectionMatrix),xn.setValue(B,"viewMatrix",ze.matrixWorldInverse);const yn=xn.map.cameraPosition;yn!==void 0&&yn.setValue(B,E.setFromMatrixPosition(ze.matrixWorld)),V.logarithmicDepthBuffer&&xn.setValue(B,"logDepthBufFC",2/(Math.log(ze.far+1)/Math.LN2)),(st.isMeshPhongMaterial||st.isMeshToonMaterial||st.isMeshLambertMaterial||st.isMeshBasicMaterial||st.isMeshStandardMaterial||st.isShaderMaterial)&&xn.setValue(B,"isOrthographic",ze.isOrthographicCamera===!0),M!==ze&&(M=ze,Rn=!0,Zt=!0)}if(Ye.isSkinnedMesh){xn.setOptional(B,Ye,"bindMatrix"),xn.setOptional(B,Ye,"bindMatrixInverse");const yn=Ye.skeleton;yn&&(V.floatVertexTextures?(yn.boneTexture===null&&yn.computeBoneTexture(),xn.setValue(B,"boneTexture",yn.boneTexture,ie)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Ye.isBatchedMesh&&(xn.setOptional(B,Ye,"batchingTexture"),xn.setValue(B,"batchingTexture",Ye._matricesTexture,ie));const Gr=Ze.morphAttributes;if((Gr.position!==void 0||Gr.normal!==void 0||Gr.color!==void 0&&V.isWebGL2===!0)&&He.update(Ye,Ze,ln),(Rn||Rt.receiveShadow!==Ye.receiveShadow)&&(Rt.receiveShadow=Ye.receiveShadow,xn.setValue(B,"receiveShadow",Ye.receiveShadow)),st.isMeshGouraudMaterial&&st.envMap!==null&&(mn.envMap.value=et,mn.flipEnvMap.value=et.isCubeTexture&&et.isRenderTargetTexture===!1?-1:1),Rn&&(xn.setValue(B,"toneMappingExposure",N.toneMappingExposure),Rt.needsLights&&Dn(mn,Zt),It&&st.fog===!0&&xe.refreshFogUniforms(mn,It),xe.refreshMaterialUniforms(mn,st,Y,ae,$),o1.upload(B,hn(Rt),mn,ie)),st.isShaderMaterial&&st.uniformsNeedUpdate===!0&&(o1.upload(B,hn(Rt),mn,ie),st.uniformsNeedUpdate=!1),st.isSpriteMaterial&&xn.setValue(B,"center",Ye.center),xn.setValue(B,"modelViewMatrix",Ye.modelViewMatrix),xn.setValue(B,"normalMatrix",Ye.normalMatrix),xn.setValue(B,"modelMatrix",Ye.matrixWorld),st.isShaderMaterial||st.isRawShaderMaterial){const yn=st.uniformsGroups;for(let dr=0,as=yn.length;dr<as;dr++)if(V.isWebGL2){const wn=yn[dr];Ae.update(wn,ln),Ae.bind(wn,ln)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ln}function Dn(ze,De){ze.ambientLightColor.needsUpdate=De,ze.lightProbe.needsUpdate=De,ze.directionalLights.needsUpdate=De,ze.directionalLightShadows.needsUpdate=De,ze.pointLights.needsUpdate=De,ze.pointLightShadows.needsUpdate=De,ze.spotLights.needsUpdate=De,ze.spotLightShadows.needsUpdate=De,ze.rectAreaLights.needsUpdate=De,ze.hemisphereLights.needsUpdate=De}function zn(ze){return ze.isMeshLambertMaterial||ze.isMeshToonMaterial||ze.isMeshPhongMaterial||ze.isMeshStandardMaterial||ze.isShadowMaterial||ze.isShaderMaterial&&ze.lights===!0}this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return j},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(ze,De,Ze){ne.get(ze.texture).__webglTexture=De,ne.get(ze.depthTexture).__webglTexture=Ze;const st=ne.get(ze);st.__hasExternalTextures=!0,st.__hasExternalTextures&&(st.__autoAllocateDepthBuffer=Ze===void 0,st.__autoAllocateDepthBuffer||z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),st.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ze,De){const Ze=ne.get(ze);Ze.__webglFramebuffer=De,Ze.__useDefaultFramebuffer=De===void 0},this.setRenderTarget=function(ze,De=0,Ze=0){k=ze,C=De,j=Ze;let st=!0,Ye=null,It=!1,Me=!1;if(ze){const et=ne.get(ze);et.__useDefaultFramebuffer!==void 0?(te.bindFramebuffer(B.FRAMEBUFFER,null),st=!1):et.__webglFramebuffer===void 0?ie.setupRenderTarget(ze):et.__hasExternalTextures&&ie.rebindTextures(ze,ne.get(ze.texture).__webglTexture,ne.get(ze.depthTexture).__webglTexture);const Qe=ze.texture;(Qe.isData3DTexture||Qe.isDataArrayTexture||Qe.isCompressedArrayTexture)&&(Me=!0);const Le=ne.get(ze).__webglFramebuffer;ze.isWebGLCubeRenderTarget?(Array.isArray(Le[De])?Ye=Le[De][Ze]:Ye=Le[De],It=!0):V.isWebGL2&&ze.samples>0&&ie.useMultisampledRTT(ze)===!1?Ye=ne.get(ze).__webglMultisampledFramebuffer:Array.isArray(Le)?Ye=Le[Ze]:Ye=Le,D.copy(ze.viewport),G.copy(ze.scissor),U=ze.scissorTest}else D.copy(ye).multiplyScalar(Y).floor(),G.copy(Z).multiplyScalar(Y).floor(),U=ue;if(te.bindFramebuffer(B.FRAMEBUFFER,Ye)&&V.drawBuffers&&st&&te.drawBuffers(ze,Ye),te.viewport(D),te.scissor(G),te.setScissorTest(U),It){const et=ne.get(ze.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+De,et.__webglTexture,Ze)}else if(Me){const et=ne.get(ze.texture),Qe=De||0;B.framebufferTextureLayer(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,et.__webglTexture,Ze||0,Qe)}R=-1},this.readRenderTargetPixels=function(ze,De,Ze,st,Ye,It,Me){if(!(ze&&ze.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ge=ne.get(ze).__webglFramebuffer;if(ze.isWebGLCubeRenderTarget&&Me!==void 0&&(Ge=Ge[Me]),Ge){te.bindFramebuffer(B.FRAMEBUFFER,Ge);try{const et=ze.texture,Qe=et.format,Le=et.type;if(Qe!==dl&&ke.convert(Qe)!==B.getParameter(B.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ht=Le===R0&&(z.has("EXT_color_buffer_half_float")||V.isWebGL2&&z.has("EXT_color_buffer_float"));if(Le!==$h&&ke.convert(Le)!==B.getParameter(B.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Le===Hu&&(V.isWebGL2||z.has("OES_texture_float")||z.has("WEBGL_color_buffer_float")))&&!ht){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}De>=0&&De<=ze.width-st&&Ze>=0&&Ze<=ze.height-Ye&&B.readPixels(De,Ze,st,Ye,ke.convert(Qe),ke.convert(Le),It)}finally{const et=k!==null?ne.get(k).__webglFramebuffer:null;te.bindFramebuffer(B.FRAMEBUFFER,et)}}},this.copyFramebufferToTexture=function(ze,De,Ze=0){const st=Math.pow(2,-Ze),Ye=Math.floor(De.image.width*st),It=Math.floor(De.image.height*st);ie.setTexture2D(De,0),B.copyTexSubImage2D(B.TEXTURE_2D,Ze,0,0,ze.x,ze.y,Ye,It),te.unbindTexture()},this.copyTextureToTexture=function(ze,De,Ze,st=0){const Ye=De.image.width,It=De.image.height,Me=ke.convert(Ze.format),Ge=ke.convert(Ze.type);ie.setTexture2D(Ze,0),B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,Ze.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ze.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,Ze.unpackAlignment),De.isDataTexture?B.texSubImage2D(B.TEXTURE_2D,st,ze.x,ze.y,Ye,It,Me,Ge,De.image.data):De.isCompressedTexture?B.compressedTexSubImage2D(B.TEXTURE_2D,st,ze.x,ze.y,De.mipmaps[0].width,De.mipmaps[0].height,Me,De.mipmaps[0].data):B.texSubImage2D(B.TEXTURE_2D,st,ze.x,ze.y,Me,Ge,De.image),st===0&&Ze.generateMipmaps&&B.generateMipmap(B.TEXTURE_2D),te.unbindTexture()},this.copyTextureToTexture3D=function(ze,De,Ze,st,Ye=0){if(N.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const It=ze.max.x-ze.min.x+1,Me=ze.max.y-ze.min.y+1,Ge=ze.max.z-ze.min.z+1,et=ke.convert(st.format),Qe=ke.convert(st.type);let Le;if(st.isData3DTexture)ie.setTexture3D(st,0),Le=B.TEXTURE_3D;else if(st.isDataArrayTexture)ie.setTexture2DArray(st,0),Le=B.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,st.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,st.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,st.unpackAlignment);const ht=B.getParameter(B.UNPACK_ROW_LENGTH),it=B.getParameter(B.UNPACK_IMAGE_HEIGHT),tt=B.getParameter(B.UNPACK_SKIP_PIXELS),_t=B.getParameter(B.UNPACK_SKIP_ROWS),jt=B.getParameter(B.UNPACK_SKIP_IMAGES),Dt=Ze.isCompressedTexture?Ze.mipmaps[0]:Ze.image;B.pixelStorei(B.UNPACK_ROW_LENGTH,Dt.width),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,Dt.height),B.pixelStorei(B.UNPACK_SKIP_PIXELS,ze.min.x),B.pixelStorei(B.UNPACK_SKIP_ROWS,ze.min.y),B.pixelStorei(B.UNPACK_SKIP_IMAGES,ze.min.z),Ze.isDataTexture||Ze.isData3DTexture?B.texSubImage3D(Le,Ye,De.x,De.y,De.z,It,Me,Ge,et,Qe,Dt.data):Ze.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),B.compressedTexSubImage3D(Le,Ye,De.x,De.y,De.z,It,Me,Ge,et,Dt.data)):B.texSubImage3D(Le,Ye,De.x,De.y,De.z,It,Me,Ge,et,Qe,Dt),B.pixelStorei(B.UNPACK_ROW_LENGTH,ht),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,it),B.pixelStorei(B.UNPACK_SKIP_PIXELS,tt),B.pixelStorei(B.UNPACK_SKIP_ROWS,_t),B.pixelStorei(B.UNPACK_SKIP_IMAGES,jt),Ye===0&&st.generateMipmaps&&B.generateMipmap(Le),te.unbindTexture()},this.initTexture=function(ze){ze.isCubeTexture?ie.setTextureCube(ze,0):ze.isData3DTexture?ie.setTexture3D(ze,0):ze.isDataArrayTexture||ze.isCompressedArrayTexture?ie.setTexture2DArray(ze,0):ie.setTexture2D(ze,0),te.unbindTexture()},this.resetState=function(){C=0,j=0,k=null,te.reset(),_e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Mc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===h4?"display-p3":"srgb",n.unpackColorSpace=Hr.workingColorSpace===bC?"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===Zi?Sf:QX}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Sf?Zi:ld}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 cTe extends ND{}cTe.prototype.isWebGL1Renderer=!0;class x4{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new fn(e),this.near=n,this.far=r}clone(){return new x4(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class uTe extends Os{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 dTe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=vD,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Yu()}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=Yu()),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=Yu()),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 As=new rt;class Ch{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++)As.fromBufferAttribute(this,n),As.applyMatrix4(e),this.setXYZ(n,As.x,As.y,As.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)As.fromBufferAttribute(this,n),As.applyNormalMatrix(e),this.setXYZ(n,As.x,As.y,As.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)As.fromBufferAttribute(this,n),As.transformDirection(e),this.setXYZ(n,As.x,As.y,As.z);return this}setX(e,n){return this.normalized&&(n=Br(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Br(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Br(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Br(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=Br(n,this.array),r=Br(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=Br(n,this.array),r=Br(r,this.array),i=Br(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=Br(n,this.array),r=Br(r,this.array),i=Br(i,this.array),s=Br(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 Ro(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 Ch(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 hTe extends so{constructor(e=null,n=1,r=1,i,s,o,l,c,u=Qi,d=Qi,h,f){super(null,o,l,c,u,d,i,s,h,f),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function mTe(t,e){return t.z-e.z}function fTe(t,e){return e.z-t.z}class pTe{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 Ag="batchId",nh=new ia,RH=new ia,gTe=new ia,FH=new ia,iP=new xC,a_=new xl,Bm=new Rc,wy=new rt,sP=new pTe,hs=new Xl,i_=[];function bTe(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 xTe extends Xl{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 hTe(n,e,e,dl,Hu);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,f=new u.constructor(r*d),p=new c.constructor(f,d,h);p.setUsage(c.usage),n.setAttribute(l,p)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new Ro(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Ag,new Ro(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Ag))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Ag}"`);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===Ag)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 xl);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,nh),this.getBoundingBoxAt(i,a_).applyMatrix4(nh),n.union(a_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rc);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,nh),this.getBoundingSphereAt(i,Bm).applyMatrix4(nh),n.union(Bm))}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,f=this._active,p=this._matricesTexture,x=this._matricesTexture.image.data;h.push(!0),f.push(!0);const v=this._geometryCount;this._geometryCount++,gTe.toArray(x,v*16),p.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new xl,sphereInitialized:!1,sphere:new Rc});const g=this.geometry.getAttribute(Ag);for(let y=0;y<i.vertexCount;y++)g.setX(i.vertexStart+y,v);return g.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,s=r.getIndex(),o=n.getIndex(),l=this._reservedRanges[e];if(i&&o.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const p in r.attributes){if(p===Ag)continue;const x=n.getAttribute(p),v=r.getAttribute(p);bTe(x,v,c);const g=x.itemSize;for(let y=x.count,_=u;y<_;y++){const N=c+y;for(let A=0;A<g;A++)v.setComponent(N,A,0)}v.needsUpdate=!0}if(i){const p=l.indexStart;for(let x=0;x<o.count;x++)s.setX(p+x,c+o.getX(x));for(let x=o.count,v=l.indexCount;x<v;x++)s.setX(p+x,c);s.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const h=this._drawRanges[e],f=n.getAttribute("position");return h.count=i?o.count:f.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 f=d;l&&(f=l.getX(f)),s.expandByPoint(wy.fromBufferAttribute(c,f))}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,a_),a_.getCenter(s.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let h=u.start,f=u.start+u.count;h<f;h++){let p=h;l&&(p=l.getX(p)),wy.fromBufferAttribute(c,p),d=Math.max(d,s.center.distanceToSquared(wy))}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;hs.material=this.material,hs.geometry.index=c.index,hs.geometry.attributes=c.attributes,hs.geometry.boundingBox===null&&(hs.geometry.boundingBox=new xl),hs.geometry.boundingSphere===null&&(hs.geometry.boundingSphere=new Rc);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=s[u];hs.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,hs.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,hs.geometry.boundingBox),this.getBoundingSphereAt(u,hs.geometry.boundingSphere),hs.raycast(e,i_);for(let h=0,f=i_.length;h<f;h++){const p=i_[h];p.object=this,p.batchId=u,n.push(p)}i_.length=0}hs.material=null,hs.geometry.index=null,hs.geometry.attributes={},hs.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,f=this.perObjectFrustumCulled;f&&(FH.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),iP.setFromProjectionMatrix(FH,e.isWebGPURenderer?F0:Mc));let p=0;if(this.sortObjects){RH.copy(this.matrixWorld).invert(),wy.setFromMatrixPosition(r.matrixWorld).applyMatrix4(RH);for(let g=0,y=c.length;g<y;g++)if(c[g]){this.getMatrixAt(g,nh),this.getBoundingSphereAt(g,Bm).applyMatrix4(nh);let _=!1;if(f&&(_=!iP.intersectsSphere(Bm)),!_){const N=wy.distanceTo(Bm.center);sP.push(h[g],N)}}const x=sP.list,v=this.customSort;v===null?x.sort(s.transparent?fTe:mTe):v.call(this,x,r);for(let g=0,y=x.length;g<y;g++){const _=x[g];u[p]=_.start*l,d[p]=_.count,p++}sP.reset()}else for(let x=0,v=c.length;x<v;x++)if(c[x]){let g=!1;if(f&&(this.getMatrixAt(x,nh),this.getBoundingSphereAt(x,Bm).applyMatrix4(nh),g=!iP.intersectsSphere(Bm)),!g){const y=h[x];u[p]=y.start*l,d[p]=y.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,o){this.onBeforeRender(e,null,i,s,o)}}class kv extends ax{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 LH=new rt,OH=new rt,IH=new ia,oP=new f4,s_=new Rc;let yTe=class extends Os{constructor(e=new Ss,n=new kv){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++)LH.fromBufferAttribute(n,i-1),OH.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=LH.distanceTo(OH);e.setAttribute("lineDistance",new Wa(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(),s_.copy(r.boundingSphere),s_.applyMatrix4(i),s_.radius+=s,e.ray.intersectsSphere(s_)===!1)return;IH.copy(i).invert(),oP.copy(e.ray).applyMatrix4(IH);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new rt,d=new rt,h=new rt,f=new rt,p=this.isLineSegments?2:1,x=r.index,g=r.attributes.position;if(x!==null){const y=Math.max(0,o.start),_=Math.min(x.count,o.start+o.count);for(let N=y,A=_-1;N<A;N+=p){const C=x.getX(N),j=x.getX(N+1);if(u.fromBufferAttribute(g,C),d.fromBufferAttribute(g,j),oP.distanceSqToSegment(u,d,f,h)>c)continue;f.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(f);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 y=Math.max(0,o.start),_=Math.min(g.count,o.start+o.count);for(let N=y,A=_-1;N<A;N+=p){if(u.fromBufferAttribute(g,N),d.fromBufferAttribute(g,N+1),oP.distanceSqToSegment(u,d,f,h)>c)continue;f.applyMatrix4(this.matrixWorld);const j=e.ray.origin.distanceTo(f);j<e.near||j>e.far||n.push({distance:j,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 zH=new rt,UH=new rt;class vC extends yTe{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)zH.fromBufferAttribute(n,i),UH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+zH.distanceTo(UH);e.setAttribute("lineDistance",new Wa(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class vTe extends Ss{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new rt,s=new rt;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],f=h.start,p=h.count;for(let x=f,v=f+p;x<v;x+=3)for(let g=0;g<3;g++){const y=l.getX(x+g),_=l.getX(x+(g+1)%3);i.fromBufferAttribute(o,y),s.fromBufferAttribute(o,_),BH(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),BH(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new Wa(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function BH(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 wTe extends ax{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new fn(16777215),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=ZX,this.normalScale=new Tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=u4,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 STe extends kv{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 vQ extends Os{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()),n}}const lP=new ia,HH=new rt,$H=new rt;class _Te{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Tn(512,512),this.map=null,this.mapPass=null,this.matrix=new ia,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new xC,this._frameExtents=new Tn(1,1),this._viewportCount=1,this._viewports=[new Vr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;HH.setFromMatrixPosition(e.matrixWorld),n.position.copy(HH),$H.setFromMatrixPosition(e.target.matrixWorld),n.lookAt($H),n.updateMatrixWorld(),lP.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lP),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(lP)}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 VH=new ia,Sy=new rt,cP=new rt;class NTe extends _Te{constructor(){super(new To(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Tn(4,2),this._viewportCount=6,this._viewports=[new Vr(2,1,1,1),new Vr(0,1,1,1),new Vr(3,1,1,1),new Vr(1,1,1,1),new Vr(3,0,1,1),new Vr(1,0,1,1)],this._cubeDirections=[new rt(1,0,0),new rt(-1,0,0),new rt(0,0,1),new rt(0,0,-1),new rt(0,1,0),new rt(0,-1,0)],this._cubeUps=[new rt(0,1,0),new rt(0,1,0),new rt(0,1,0),new rt(0,1,0),new rt(0,0,1),new rt(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()),Sy.setFromMatrixPosition(e.matrixWorld),r.position.copy(Sy),cP.copy(r.position),cP.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(cP),r.updateMatrixWorld(),i.makeTranslation(-Sy.x,-Sy.y,-Sy.z),VH.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(VH)}}class kTe extends vQ{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 NTe}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 CTe extends vQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class ATe 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 kD extends dTe{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 qH{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(Ji(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const GH=new rt,o_=new rt;class TTe{constructor(e=new rt,n=new rt){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){GH.subVectors(e,this.start),o_.subVectors(this.end,this.start);const r=o_.dot(o_);let s=o_.dot(GH)/r;return n&&(s=Ji(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 MTe extends vC{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 Wa(n,3)),i.setAttribute("color",new Wa(r,3));const s=new kv({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new fn,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:pC}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pC);class Fc{constructor(e,n,r,i,s="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(s),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),Fc.nextNameID=Fc.nextNameID||0,this.$name.id=`lil-gui-name-${++Fc.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class PTe extends Fc{constructor(e,n,r){super(e,n,r,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function CD(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 jTe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:CD,toHexString:CD},O0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},ETe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=O0.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 O0.toHexString(i)}},DTe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=O0.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 O0.toHexString(i)}},RTe=[jTe,O0,ETe,DTe];function FTe(t){return RTe.find(e=>e.match(t))}class LTe extends Fc{constructor(e,n,r,i){super(e,n,r,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=FTe(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=CD(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 uP extends Fc{constructor(e,n,r){super(e,n,r,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class OTe extends Fc{constructor(e,n,r,i,s,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(s);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let _=parseFloat(this.$input.value);isNaN(_)||(this._stepExplicit&&(_=this._snap(_)),this.setValue(this._clamp(_)))},r=_=>{const N=parseFloat(this.$input.value);isNaN(N)||(this._snapClampSetValue(N+_),this.$input.value=this.getValue())},i=_=>{_.key==="Enter"&&this.$input.blur(),_.code==="ArrowUp"&&(_.preventDefault(),r(this._step*this._arrowKeyMultiplier(_))),_.code==="ArrowDown"&&(_.preventDefault(),r(this._step*this._arrowKeyMultiplier(_)*-1))},s=_=>{this._inputFocused&&(_.preventDefault(),r(this._step*this._normalizeMouseWheel(_)))};let o=!1,l,c,u,d,h;const f=5,p=_=>{l=_.clientX,c=u=_.clientY,o=!0,d=this.getValue(),h=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",v)},x=_=>{if(o){const N=_.clientX-l,A=_.clientY-c;Math.abs(A)>f?(_.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(N)>f&&v()}if(!o){const N=_.clientY-u;h-=N*this._step*this._arrowKeyMultiplier(_),d+h>this._max?h=this._max-d:d+h<this._min&&(h=this._min-d),this._snapClampSetValue(d+h)}u=_.clientY},v=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",v)},g=()=>{this._inputFocused=!0},y=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",g),this.$input.addEventListener("blur",y)}_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=(y,_,N,A,C)=>(y-_)/(N-_)*(C-A)+A,n=y=>{const _=this.$slider.getBoundingClientRect();let N=e(y,_.left,_.right,this._min,this._max);this._snapClampSetValue(N)},r=y=>{this._setDraggingStyle(!0),n(y.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=y=>{n(y.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let o=!1,l,c;const u=y=>{y.preventDefault(),this._setDraggingStyle(!0),n(y.touches[0].clientX),o=!1},d=y=>{y.touches.length>1||(this._hasScrollBar?(l=y.touches[0].clientX,c=y.touches[0].clientY,o=!0):u(y),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",f))},h=y=>{if(o){const _=y.touches[0].clientX-l,N=y.touches[0].clientY-c;Math.abs(_)>Math.abs(N)?u(y):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",f))}else y.preventDefault(),n(y.touches[0].clientX)},f=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",f)},p=this._callOnFinishChange.bind(this),x=400;let v;const g=y=>{if(Math.abs(y.deltaX)<Math.abs(y.deltaY)&&this._hasScrollBar)return;y.preventDefault();const N=this._normalizeMouseWheel(y)*this._step;this._snapClampSetValue(this.getValue()+N),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(p,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",g,{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 ITe extends Fc{constructor(e,n,r,i){super(e,n,r,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(i)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(n=>{const r=document.createElement("option");r.textContent=n,this.$select.appendChild(r)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),n=this._values.indexOf(e);return this.$select.selectedIndex=n,this.$display.textContent=n===-1?e:this._names[n],this}}class zTe extends Fc{constructor(e,n,r){super(e,n,r,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("spellcheck","false"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",i=>{i.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const UTe=`.lil-gui {
  7397. font-family: var(--font-family);
  7398. font-size: var(--font-size);
  7399. line-height: 1;
  7400. font-weight: normal;
  7401. font-style: normal;
  7402. text-align: left;
  7403. color: var(--text-color);
  7404. user-select: none;
  7405. -webkit-user-select: none;
  7406. touch-action: manipulation;
  7407. --background-color: #1f1f1f;
  7408. --text-color: #ebebeb;
  7409. --title-background-color: #111111;
  7410. --title-text-color: #ebebeb;
  7411. --widget-color: #424242;
  7412. --hover-color: #4f4f4f;
  7413. --focus-color: #595959;
  7414. --number-color: #2cc9ff;
  7415. --string-color: #a2db3c;
  7416. --font-size: 11px;
  7417. --input-font-size: 11px;
  7418. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7419. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7420. --padding: 4px;
  7421. --spacing: 4px;
  7422. --widget-height: 20px;
  7423. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7424. --name-width: 45%;
  7425. --slider-knob-width: 2px;
  7426. --slider-input-width: 27%;
  7427. --color-input-width: 27%;
  7428. --slider-input-min-width: 45px;
  7429. --color-input-min-width: 45px;
  7430. --folder-indent: 7px;
  7431. --widget-padding: 0 0 0 3px;
  7432. --widget-border-radius: 2px;
  7433. --checkbox-size: calc(0.75 * var(--widget-height));
  7434. --scrollbar-width: 5px;
  7435. }
  7436. .lil-gui, .lil-gui * {
  7437. box-sizing: border-box;
  7438. margin: 0;
  7439. padding: 0;
  7440. }
  7441. .lil-gui.root {
  7442. width: var(--width, 245px);
  7443. display: flex;
  7444. flex-direction: column;
  7445. background: var(--background-color);
  7446. }
  7447. .lil-gui.root > .title {
  7448. background: var(--title-background-color);
  7449. color: var(--title-text-color);
  7450. }
  7451. .lil-gui.root > .children {
  7452. overflow-x: hidden;
  7453. overflow-y: auto;
  7454. }
  7455. .lil-gui.root > .children::-webkit-scrollbar {
  7456. width: var(--scrollbar-width);
  7457. height: var(--scrollbar-width);
  7458. background: var(--background-color);
  7459. }
  7460. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7461. border-radius: var(--scrollbar-width);
  7462. background: var(--focus-color);
  7463. }
  7464. @media (pointer: coarse) {
  7465. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7466. --widget-height: 28px;
  7467. --padding: 6px;
  7468. --spacing: 6px;
  7469. --font-size: 13px;
  7470. --input-font-size: 16px;
  7471. --folder-indent: 10px;
  7472. --scrollbar-width: 7px;
  7473. --slider-input-min-width: 50px;
  7474. --color-input-min-width: 65px;
  7475. }
  7476. }
  7477. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7478. --widget-height: 28px;
  7479. --padding: 6px;
  7480. --spacing: 6px;
  7481. --font-size: 13px;
  7482. --input-font-size: 16px;
  7483. --folder-indent: 10px;
  7484. --scrollbar-width: 7px;
  7485. --slider-input-min-width: 50px;
  7486. --color-input-min-width: 65px;
  7487. }
  7488. .lil-gui.autoPlace {
  7489. max-height: 100%;
  7490. position: fixed;
  7491. top: 0;
  7492. right: 15px;
  7493. z-index: 1001;
  7494. }
  7495. .lil-gui .controller {
  7496. display: flex;
  7497. align-items: center;
  7498. padding: 0 var(--padding);
  7499. margin: var(--spacing) 0;
  7500. }
  7501. .lil-gui .controller.disabled {
  7502. opacity: 0.5;
  7503. }
  7504. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7505. pointer-events: none !important;
  7506. }
  7507. .lil-gui .controller > .name {
  7508. min-width: var(--name-width);
  7509. flex-shrink: 0;
  7510. white-space: pre;
  7511. padding-right: var(--spacing);
  7512. line-height: var(--widget-height);
  7513. }
  7514. .lil-gui .controller .widget {
  7515. position: relative;
  7516. display: flex;
  7517. align-items: center;
  7518. width: 100%;
  7519. min-height: var(--widget-height);
  7520. }
  7521. .lil-gui .controller.string input {
  7522. color: var(--string-color);
  7523. }
  7524. .lil-gui .controller.boolean {
  7525. cursor: pointer;
  7526. }
  7527. .lil-gui .controller.color .display {
  7528. width: 100%;
  7529. height: var(--widget-height);
  7530. border-radius: var(--widget-border-radius);
  7531. position: relative;
  7532. }
  7533. @media (hover: hover) {
  7534. .lil-gui .controller.color .display:hover:before {
  7535. content: " ";
  7536. display: block;
  7537. position: absolute;
  7538. border-radius: var(--widget-border-radius);
  7539. border: 1px solid #fff9;
  7540. top: 0;
  7541. right: 0;
  7542. bottom: 0;
  7543. left: 0;
  7544. }
  7545. }
  7546. .lil-gui .controller.color input[type=color] {
  7547. opacity: 0;
  7548. width: 100%;
  7549. height: 100%;
  7550. cursor: pointer;
  7551. }
  7552. .lil-gui .controller.color input[type=text] {
  7553. margin-left: var(--spacing);
  7554. font-family: var(--font-family-mono);
  7555. min-width: var(--color-input-min-width);
  7556. width: var(--color-input-width);
  7557. flex-shrink: 0;
  7558. }
  7559. .lil-gui .controller.option select {
  7560. opacity: 0;
  7561. position: absolute;
  7562. width: 100%;
  7563. max-width: 100%;
  7564. }
  7565. .lil-gui .controller.option .display {
  7566. position: relative;
  7567. pointer-events: none;
  7568. border-radius: var(--widget-border-radius);
  7569. height: var(--widget-height);
  7570. line-height: var(--widget-height);
  7571. max-width: 100%;
  7572. overflow: hidden;
  7573. word-break: break-all;
  7574. padding-left: 0.55em;
  7575. padding-right: 1.75em;
  7576. background: var(--widget-color);
  7577. }
  7578. @media (hover: hover) {
  7579. .lil-gui .controller.option .display.focus {
  7580. background: var(--focus-color);
  7581. }
  7582. }
  7583. .lil-gui .controller.option .display.active {
  7584. background: var(--focus-color);
  7585. }
  7586. .lil-gui .controller.option .display:after {
  7587. font-family: "lil-gui";
  7588. content: "↕";
  7589. position: absolute;
  7590. top: 0;
  7591. right: 0;
  7592. bottom: 0;
  7593. padding-right: 0.375em;
  7594. }
  7595. .lil-gui .controller.option .widget,
  7596. .lil-gui .controller.option select {
  7597. cursor: pointer;
  7598. }
  7599. @media (hover: hover) {
  7600. .lil-gui .controller.option .widget:hover .display {
  7601. background: var(--hover-color);
  7602. }
  7603. }
  7604. .lil-gui .controller.number input {
  7605. color: var(--number-color);
  7606. }
  7607. .lil-gui .controller.number.hasSlider input {
  7608. margin-left: var(--spacing);
  7609. width: var(--slider-input-width);
  7610. min-width: var(--slider-input-min-width);
  7611. flex-shrink: 0;
  7612. }
  7613. .lil-gui .controller.number .slider {
  7614. width: 100%;
  7615. height: var(--widget-height);
  7616. background: var(--widget-color);
  7617. border-radius: var(--widget-border-radius);
  7618. padding-right: var(--slider-knob-width);
  7619. overflow: hidden;
  7620. cursor: ew-resize;
  7621. touch-action: pan-y;
  7622. }
  7623. @media (hover: hover) {
  7624. .lil-gui .controller.number .slider:hover {
  7625. background: var(--hover-color);
  7626. }
  7627. }
  7628. .lil-gui .controller.number .slider.active {
  7629. background: var(--focus-color);
  7630. }
  7631. .lil-gui .controller.number .slider.active .fill {
  7632. opacity: 0.95;
  7633. }
  7634. .lil-gui .controller.number .fill {
  7635. height: 100%;
  7636. border-right: var(--slider-knob-width) solid var(--number-color);
  7637. box-sizing: content-box;
  7638. }
  7639. .lil-gui-dragging .lil-gui {
  7640. --hover-color: var(--widget-color);
  7641. }
  7642. .lil-gui-dragging * {
  7643. cursor: ew-resize !important;
  7644. }
  7645. .lil-gui-dragging.lil-gui-vertical * {
  7646. cursor: ns-resize !important;
  7647. }
  7648. .lil-gui .title {
  7649. height: var(--title-height);
  7650. line-height: calc(var(--title-height) - 4px);
  7651. font-weight: 600;
  7652. padding: 0 var(--padding);
  7653. -webkit-tap-highlight-color: transparent;
  7654. cursor: pointer;
  7655. outline: none;
  7656. text-decoration-skip: objects;
  7657. }
  7658. .lil-gui .title:before {
  7659. font-family: "lil-gui";
  7660. content: "▾";
  7661. padding-right: 2px;
  7662. display: inline-block;
  7663. }
  7664. .lil-gui .title:active {
  7665. background: var(--title-background-color);
  7666. opacity: 0.75;
  7667. }
  7668. @media (hover: hover) {
  7669. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7670. background: var(--title-background-color);
  7671. opacity: 0.85;
  7672. }
  7673. .lil-gui .title:focus {
  7674. text-decoration: underline var(--focus-color);
  7675. }
  7676. }
  7677. .lil-gui.root > .title:focus {
  7678. text-decoration: none !important;
  7679. }
  7680. .lil-gui.closed > .title:before {
  7681. content: "▸";
  7682. }
  7683. .lil-gui.closed > .children {
  7684. transform: translateY(-7px);
  7685. opacity: 0;
  7686. }
  7687. .lil-gui.closed:not(.transition) > .children {
  7688. display: none;
  7689. }
  7690. .lil-gui.transition > .children {
  7691. transition-duration: 300ms;
  7692. transition-property: height, opacity, transform;
  7693. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7694. overflow: hidden;
  7695. pointer-events: none;
  7696. }
  7697. .lil-gui .children:empty:before {
  7698. content: "Empty";
  7699. padding: 0 var(--padding);
  7700. margin: var(--spacing) 0;
  7701. display: block;
  7702. height: var(--widget-height);
  7703. font-style: italic;
  7704. line-height: var(--widget-height);
  7705. opacity: 0.5;
  7706. }
  7707. .lil-gui.root > .children > .lil-gui > .title {
  7708. border: 0 solid var(--widget-color);
  7709. border-width: 1px 0;
  7710. transition: border-color 300ms;
  7711. }
  7712. .lil-gui.root > .children > .lil-gui.closed > .title {
  7713. border-bottom-color: transparent;
  7714. }
  7715. .lil-gui + .controller {
  7716. border-top: 1px solid var(--widget-color);
  7717. margin-top: 0;
  7718. padding-top: var(--spacing);
  7719. }
  7720. .lil-gui .lil-gui .lil-gui > .title {
  7721. border: none;
  7722. }
  7723. .lil-gui .lil-gui .lil-gui > .children {
  7724. border: none;
  7725. margin-left: var(--folder-indent);
  7726. border-left: 2px solid var(--widget-color);
  7727. }
  7728. .lil-gui .lil-gui .controller {
  7729. border: none;
  7730. }
  7731. .lil-gui label, .lil-gui input, .lil-gui button {
  7732. -webkit-tap-highlight-color: transparent;
  7733. }
  7734. .lil-gui input {
  7735. border: 0;
  7736. outline: none;
  7737. font-family: var(--font-family);
  7738. font-size: var(--input-font-size);
  7739. border-radius: var(--widget-border-radius);
  7740. height: var(--widget-height);
  7741. background: var(--widget-color);
  7742. color: var(--text-color);
  7743. width: 100%;
  7744. }
  7745. @media (hover: hover) {
  7746. .lil-gui input:hover {
  7747. background: var(--hover-color);
  7748. }
  7749. .lil-gui input:active {
  7750. background: var(--focus-color);
  7751. }
  7752. }
  7753. .lil-gui input:disabled {
  7754. opacity: 1;
  7755. }
  7756. .lil-gui input[type=text],
  7757. .lil-gui input[type=number] {
  7758. padding: var(--widget-padding);
  7759. -moz-appearance: textfield;
  7760. }
  7761. .lil-gui input[type=text]:focus,
  7762. .lil-gui input[type=number]:focus {
  7763. background: var(--focus-color);
  7764. }
  7765. .lil-gui input[type=checkbox] {
  7766. appearance: none;
  7767. width: var(--checkbox-size);
  7768. height: var(--checkbox-size);
  7769. border-radius: var(--widget-border-radius);
  7770. text-align: center;
  7771. cursor: pointer;
  7772. }
  7773. .lil-gui input[type=checkbox]:checked:before {
  7774. font-family: "lil-gui";
  7775. content: "✓";
  7776. font-size: var(--checkbox-size);
  7777. line-height: var(--checkbox-size);
  7778. }
  7779. @media (hover: hover) {
  7780. .lil-gui input[type=checkbox]:focus {
  7781. box-shadow: inset 0 0 0 1px var(--focus-color);
  7782. }
  7783. }
  7784. .lil-gui button {
  7785. outline: none;
  7786. cursor: pointer;
  7787. font-family: var(--font-family);
  7788. font-size: var(--font-size);
  7789. color: var(--text-color);
  7790. width: 100%;
  7791. height: var(--widget-height);
  7792. text-transform: none;
  7793. background: var(--widget-color);
  7794. border-radius: var(--widget-border-radius);
  7795. border: none;
  7796. }
  7797. @media (hover: hover) {
  7798. .lil-gui button:hover {
  7799. background: var(--hover-color);
  7800. }
  7801. .lil-gui button:focus {
  7802. box-shadow: inset 0 0 0 1px var(--focus-color);
  7803. }
  7804. }
  7805. .lil-gui button:active {
  7806. background: var(--focus-color);
  7807. }
  7808. @font-face {
  7809. font-family: "lil-gui";
  7810. src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
  7811. }`;function BTe(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 WH=!1;class K1{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"),!WH&&l&&(BTe(UTe),WH=!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 ITe(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new OTe(this,e,n,r,i,s);case"boolean":return new PTe(this,e,n);case"string":return new zTe(this,e,n);case"function":return new uP(this,e,n)}console.error(`gui.add failed
  7812. property:`,n,`
  7813. object:`,e,`
  7814. value:`,o)}addColor(e,n,r=1){return new LTe(this,e,n,r)}addFolder(e){const n=new K1({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof uP||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 uP)){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 dP(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 y4{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 y4(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 v4{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class KH extends v4{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class rh extends v4{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class YH{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class Y1{constructor(e){this.lines=[],this.preamble=new YH(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
  7815. `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((s=>s.comment))).thumbnails;for(const[s,o]of Object.entries(i))this.metadata.thumbnails[s]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),s=i[0],o=n&&i[1]||void 0,l=s.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new KH(e,c,u,o);case"t0":return new rh(e,c,o,0);case"t1":return new rh(e,c,o,1);case"t2":return new rh(e,c,o,2);case"t3":return new rh(e,c,o,3);case"t4":return new rh(e,c,o,4);case"t5":return new rh(e,c,o,5);case"t6":return new rh(e,c,o,6);case"t7":return new rh(e,c,o,7);default:return new v4(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 KH){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 YH(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=y4.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}}}Y1.prototype.parseGcode=Y1.prototype.parseGCode;const XH={type:"change"},hP={type:"start"},QH={type:"end"},l_=new f4,ZH=new ch,HTe=Math.cos(70*eQ.DEG2RAD);class $Te extends up{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new rt,this.cursor=new rt,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:cg.ROTATE,MIDDLE:cg.DOLLY,RIGHT:cg.PAN},this.touches={ONE:ug.ROTATE,TWO:ug.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(V){V.addEventListener("keydown",q),this._domElementKeyEvents=V},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",q),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(XH),r.update(),s=i.NONE},this.update=(function(){const V=new rt,te=new qf().setFromUnitVectors(e.up,new rt(0,1,0)),Q=te.clone().invert(),ne=new rt,ie=new qf,me=new rt,fe=2*Math.PI;return function(oe=null){const I=r.object.position;V.copy(I).sub(r.target),V.applyQuaternion(te),l.setFromVector3(V),r.autoRotate&&s===i.NONE&&D((function(he){return he!==null?2*Math.PI/60*r.autoRotateSpeed*he:2*Math.PI/60/60*r.autoRotateSpeed})(oe)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let F=r.minAzimuthAngle,J=r.maxAzimuthAngle;isFinite(F)&&isFinite(J)&&(F<-Math.PI?F+=fe:F>Math.PI&&(F-=fe),J<-Math.PI?J+=fe:J>Math.PI&&(J-=fe),l.theta=F<=J?Math.max(F,Math.min(J,l.theta)):l.theta>(F+J)/2?Math.max(F,l.theta):Math.min(J,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&&j||r.object.isOrthographicCamera?l.radius=se(l.radius):l.radius=se(l.radius*u),V.setFromSpherical(l),V.applyQuaternion(Q),I.copy(r.target).add(V),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 xe=!1;if(r.zoomToCursor&&j){let he=null;if(r.object.isPerspectiveCamera){const le=V.length();he=se(le*u);const Ce=le-he;r.object.position.addScaledVector(A,Ce),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const le=new rt(C.x,C.y,0);le.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),xe=!0;const Ce=new rt(C.x,C.y,0);Ce.unproject(r.object),r.object.position.sub(Ce).add(le),r.object.updateMatrixWorld(),he=V.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;he!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(he).add(r.object.position):(l_.origin.copy(r.object.position),l_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(l_.direction))<HTe?e.lookAt(r.target):(ZH.setFromNormalAndCoplanarPoint(r.object.up,r.target),l_.intersectPlane(ZH,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),xe=!0);return u=1,j=!1,!!(xe||ne.distanceToSquared(r.object.position)>o||8*(1-ie.dot(r.object.quaternion))>o||me.distanceToSquared(r.target)>0)&&(r.dispatchEvent(XH),ne.copy(r.object.position),ie.copy(r.object.quaternion),me.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",B),r.domElement.removeEventListener("pointerdown",K),r.domElement.removeEventListener("pointercancel",E),r.domElement.removeEventListener("wheel",O),r.domElement.removeEventListener("pointermove",T),r.domElement.removeEventListener("pointerup",E),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",q),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 qH,c=new qH;let u=1;const d=new rt,h=new Tn,f=new Tn,p=new Tn,x=new Tn,v=new Tn,g=new Tn,y=new Tn,_=new Tn,N=new Tn,A=new rt,C=new Tn;let j=!1;const k=[],R={};function M(){return Math.pow(.95,r.zoomSpeed)}function D(V){c.theta-=V}function G(V){c.phi-=V}const U=(function(){const V=new rt;return function(te,Q){V.setFromMatrixColumn(Q,0),V.multiplyScalar(-te),d.add(V)}})(),W=(function(){const V=new rt;return function(te,Q){r.screenSpacePanning===!0?V.setFromMatrixColumn(Q,1):(V.setFromMatrixColumn(Q,0),V.crossVectors(r.object.up,V)),V.multiplyScalar(te),d.add(V)}})(),L=(function(){const V=new rt;return function(te,Q){const ne=r.domElement;if(r.object.isPerspectiveCamera){const ie=r.object.position;V.copy(ie).sub(r.target);let me=V.length();me*=Math.tan(r.object.fov/2*Math.PI/180),U(2*te*me/ne.clientHeight,r.object.matrix),W(2*Q*me/ne.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(U(te*(r.object.right-r.object.left)/r.object.zoom/ne.clientWidth,r.object.matrix),W(Q*(r.object.top-r.object.bottom)/r.object.zoom/ne.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function ee(V){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=V:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function ae(V){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=V:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function Y(V){if(!r.zoomToCursor)return;j=!0;const te=r.domElement.getBoundingClientRect(),Q=V.clientX-te.left,ne=V.clientY-te.top,ie=te.width,me=te.height;C.x=Q/ie*2-1,C.y=-ne/me*2+1,A.set(C.x,C.y,1).unproject(r.object).sub(r.object.position).normalize()}function se(V){return Math.max(r.minDistance,Math.min(r.maxDistance,V))}function ce(V){h.set(V.clientX,V.clientY)}function ye(V){x.set(V.clientX,V.clientY)}function Z(){if(k.length===1)h.set(k[0].pageX,k[0].pageY);else{const V=.5*(k[0].pageX+k[1].pageX),te=.5*(k[0].pageY+k[1].pageY);h.set(V,te)}}function ue(){if(k.length===1)x.set(k[0].pageX,k[0].pageY);else{const V=.5*(k[0].pageX+k[1].pageX),te=.5*(k[0].pageY+k[1].pageY);x.set(V,te)}}function pe(){const V=k[0].pageX-k[1].pageX,te=k[0].pageY-k[1].pageY,Q=Math.sqrt(V*V+te*te);y.set(0,Q)}function be(V){if(k.length==1)f.set(V.pageX,V.pageY);else{const Q=z(V),ne=.5*(V.pageX+Q.x),ie=.5*(V.pageY+Q.y);f.set(ne,ie)}p.subVectors(f,h).multiplyScalar(r.rotateSpeed);const te=r.domElement;D(2*Math.PI*p.x/te.clientHeight),G(2*Math.PI*p.y/te.clientHeight),h.copy(f)}function Ee(V){if(k.length===1)v.set(V.pageX,V.pageY);else{const te=z(V),Q=.5*(V.pageX+te.x),ne=.5*(V.pageY+te.y);v.set(Q,ne)}g.subVectors(v,x).multiplyScalar(r.panSpeed),L(g.x,g.y),x.copy(v)}function $(V){const te=z(V),Q=V.pageX-te.x,ne=V.pageY-te.y,ie=Math.sqrt(Q*Q+ne*ne);_.set(0,ie),N.set(0,Math.pow(_.y/y.y,r.zoomSpeed)),ee(N.y),y.copy(_)}function K(V){r.enabled!==!1&&(k.length===0&&(r.domElement.setPointerCapture(V.pointerId),r.domElement.addEventListener("pointermove",T),r.domElement.addEventListener("pointerup",E)),(function(te){k.push(te)})(V),V.pointerType==="touch"?(function(te){switch(re(te),k.length){case 1:switch(r.touches.ONE){case ug.ROTATE:if(r.enableRotate===!1)return;Z(),s=i.TOUCH_ROTATE;break;case ug.PAN:if(r.enablePan===!1)return;ue(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case ug.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&pe(),r.enablePan&&ue(),s=i.TOUCH_DOLLY_PAN;break;case ug.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&pe(),r.enableRotate&&Z(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(hP)})(V):(function(te){let Q;switch(te.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 cg.DOLLY:if(r.enableZoom===!1)return;(function(ne){Y(ne),y.set(ne.clientX,ne.clientY)})(te),s=i.DOLLY;break;case cg.ROTATE:if(te.ctrlKey||te.metaKey||te.shiftKey){if(r.enablePan===!1)return;ye(te),s=i.PAN}else{if(r.enableRotate===!1)return;ce(te),s=i.ROTATE}break;case cg.PAN:if(te.ctrlKey||te.metaKey||te.shiftKey){if(r.enableRotate===!1)return;ce(te),s=i.ROTATE}else{if(r.enablePan===!1)return;ye(te),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(hP)})(V))}function T(V){r.enabled!==!1&&(V.pointerType==="touch"?(function(te){switch(re(te),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;be(te),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;Ee(te),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(Q){r.enableZoom&&$(Q),r.enablePan&&Ee(Q)})(te),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(Q){r.enableZoom&&$(Q),r.enableRotate&&be(Q)})(te),r.update();break;default:s=i.NONE}})(V):(function(te){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(Q){f.set(Q.clientX,Q.clientY),p.subVectors(f,h).multiplyScalar(r.rotateSpeed);const ne=r.domElement;D(2*Math.PI*p.x/ne.clientHeight),G(2*Math.PI*p.y/ne.clientHeight),h.copy(f),r.update()})(te);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(Q){_.set(Q.clientX,Q.clientY),N.subVectors(_,y),N.y>0?ee(M()):N.y<0&&ae(M()),y.copy(_),r.update()})(te);break;case i.PAN:if(r.enablePan===!1)return;(function(Q){v.set(Q.clientX,Q.clientY),g.subVectors(v,x).multiplyScalar(r.panSpeed),L(g.x,g.y),x.copy(v),r.update()})(te)}})(V))}function E(V){(function(te){delete R[te.pointerId];for(let Q=0;Q<k.length;Q++)if(k[Q].pointerId==te.pointerId)return void k.splice(Q,1)})(V),k.length===0&&(r.domElement.releasePointerCapture(V.pointerId),r.domElement.removeEventListener("pointermove",T),r.domElement.removeEventListener("pointerup",E)),r.dispatchEvent(QH),s=i.NONE}function O(V){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(V.preventDefault(),r.dispatchEvent(hP),(function(te){Y(te),te.deltaY<0?ae(M()):te.deltaY>0&&ee(M()),r.update()})(V),r.dispatchEvent(QH))}function q(V){r.enabled!==!1&&r.enablePan!==!1&&(function(te){let Q=!1;switch(te.code){case r.keys.UP:te.ctrlKey||te.metaKey||te.shiftKey?G(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):L(0,r.keyPanSpeed),Q=!0;break;case r.keys.BOTTOM:te.ctrlKey||te.metaKey||te.shiftKey?G(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):L(0,-r.keyPanSpeed),Q=!0;break;case r.keys.LEFT:te.ctrlKey||te.metaKey||te.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):L(r.keyPanSpeed,0),Q=!0;break;case r.keys.RIGHT:te.ctrlKey||te.metaKey||te.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):L(-r.keyPanSpeed,0),Q=!0}Q&&(te.preventDefault(),r.update())})(V)}function B(V){r.enabled!==!1&&V.preventDefault()}function re(V){let te=R[V.pointerId];te===void 0&&(te=new Tn,R[V.pointerId]=te),te.set(V.pageX,V.pageY)}function z(V){const te=V.pointerId===k[0].pointerId?k[1]:k[0];return R[te.pointerId]}r.domElement.addEventListener("contextmenu",B),r.domElement.addEventListener("pointerdown",K),r.domElement.addEventListener("pointercancel",E),r.domElement.addEventListener("wheel",O,{passive:!1}),this.update()}}Ht.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Tn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Js.line={uniforms:p4.merge([Ht.common,Ht.fog,Ht.line]),vertexShader:`
  7816. #include <common>
  7817. #include <color_pars_vertex>
  7818. #include <fog_pars_vertex>
  7819. #include <logdepthbuf_pars_vertex>
  7820. #include <clipping_planes_pars_vertex>
  7821. uniform float linewidth;
  7822. uniform vec2 resolution;
  7823. attribute vec3 instanceStart;
  7824. attribute vec3 instanceEnd;
  7825. attribute vec3 instanceColorStart;
  7826. attribute vec3 instanceColorEnd;
  7827. #ifdef WORLD_UNITS
  7828. varying vec4 worldPos;
  7829. varying vec3 worldStart;
  7830. varying vec3 worldEnd;
  7831. #ifdef USE_DASH
  7832. varying vec2 vUv;
  7833. #endif
  7834. #else
  7835. varying vec2 vUv;
  7836. #endif
  7837. #ifdef USE_DASH
  7838. uniform float dashScale;
  7839. attribute float instanceDistanceStart;
  7840. attribute float instanceDistanceEnd;
  7841. varying float vLineDistance;
  7842. #endif
  7843. void trimSegment( const in vec4 start, inout vec4 end ) {
  7844. // trim end segment so it terminates between the camera plane and the near plane
  7845. // conservative estimate of the near plane
  7846. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7847. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7848. float nearEstimate = - 0.5 * b / a;
  7849. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7850. end.xyz = mix( start.xyz, end.xyz, alpha );
  7851. }
  7852. void main() {
  7853. #ifdef USE_COLOR
  7854. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7855. #endif
  7856. #ifdef USE_DASH
  7857. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7858. vUv = uv;
  7859. #endif
  7860. float aspect = resolution.x / resolution.y;
  7861. // camera space
  7862. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7863. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7864. #ifdef WORLD_UNITS
  7865. worldStart = start.xyz;
  7866. worldEnd = end.xyz;
  7867. #else
  7868. vUv = uv;
  7869. #endif
  7870. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7871. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7872. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7873. // perhaps there is a more elegant solution -- WestLangley
  7874. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7875. if ( perspective ) {
  7876. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7877. trimSegment( start, end );
  7878. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7879. trimSegment( end, start );
  7880. }
  7881. }
  7882. // clip space
  7883. vec4 clipStart = projectionMatrix * start;
  7884. vec4 clipEnd = projectionMatrix * end;
  7885. // ndc space
  7886. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7887. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7888. // direction
  7889. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7890. // account for clip-space aspect ratio
  7891. dir.x *= aspect;
  7892. dir = normalize( dir );
  7893. #ifdef WORLD_UNITS
  7894. // get the offset direction as perpendicular to the view vector
  7895. vec3 worldDir = normalize( end.xyz - start.xyz );
  7896. vec3 offset;
  7897. if ( position.y < 0.5 ) {
  7898. offset = normalize( cross( start.xyz, worldDir ) );
  7899. } else {
  7900. offset = normalize( cross( end.xyz, worldDir ) );
  7901. }
  7902. // sign flip
  7903. if ( position.x < 0.0 ) offset *= - 1.0;
  7904. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7905. // don't extend the line if we're rendering dashes because we
  7906. // won't be rendering the endcaps
  7907. #ifndef USE_DASH
  7908. // extend the line bounds to encompass endcaps
  7909. start.xyz += - worldDir * linewidth * 0.5;
  7910. end.xyz += worldDir * linewidth * 0.5;
  7911. // shift the position of the quad so it hugs the forward edge of the line
  7912. offset.xy -= dir * forwardOffset;
  7913. offset.z += 0.5;
  7914. #endif
  7915. // endcaps
  7916. if ( position.y > 1.0 || position.y < 0.0 ) {
  7917. offset.xy += dir * 2.0 * forwardOffset;
  7918. }
  7919. // adjust for linewidth
  7920. offset *= linewidth * 0.5;
  7921. // set the world position
  7922. worldPos = ( position.y < 0.5 ) ? start : end;
  7923. worldPos.xyz += offset;
  7924. // project the worldpos
  7925. vec4 clip = projectionMatrix * worldPos;
  7926. // shift the depth of the projected points so the line
  7927. // segments overlap neatly
  7928. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  7929. clip.z = clipPose.z * clip.w;
  7930. #else
  7931. vec2 offset = vec2( dir.y, - dir.x );
  7932. // undo aspect ratio adjustment
  7933. dir.x /= aspect;
  7934. offset.x /= aspect;
  7935. // sign flip
  7936. if ( position.x < 0.0 ) offset *= - 1.0;
  7937. // endcaps
  7938. if ( position.y < 0.0 ) {
  7939. offset += - dir;
  7940. } else if ( position.y > 1.0 ) {
  7941. offset += dir;
  7942. }
  7943. // adjust for linewidth
  7944. offset *= linewidth;
  7945. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  7946. offset /= resolution.y;
  7947. // select end
  7948. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  7949. // back to clip space
  7950. offset *= clip.w;
  7951. clip.xy += offset;
  7952. #endif
  7953. gl_Position = clip;
  7954. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  7955. #include <logdepthbuf_vertex>
  7956. #include <clipping_planes_vertex>
  7957. #include <fog_vertex>
  7958. }
  7959. `,fragmentShader:`
  7960. uniform vec3 diffuse;
  7961. uniform float opacity;
  7962. uniform float linewidth;
  7963. #ifdef USE_DASH
  7964. uniform float dashOffset;
  7965. uniform float dashSize;
  7966. uniform float gapSize;
  7967. #endif
  7968. varying float vLineDistance;
  7969. #ifdef WORLD_UNITS
  7970. varying vec4 worldPos;
  7971. varying vec3 worldStart;
  7972. varying vec3 worldEnd;
  7973. #ifdef USE_DASH
  7974. varying vec2 vUv;
  7975. #endif
  7976. #else
  7977. varying vec2 vUv;
  7978. #endif
  7979. #include <common>
  7980. #include <color_pars_fragment>
  7981. #include <fog_pars_fragment>
  7982. #include <logdepthbuf_pars_fragment>
  7983. #include <clipping_planes_pars_fragment>
  7984. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  7985. float mua;
  7986. float mub;
  7987. vec3 p13 = p1 - p3;
  7988. vec3 p43 = p4 - p3;
  7989. vec3 p21 = p2 - p1;
  7990. float d1343 = dot( p13, p43 );
  7991. float d4321 = dot( p43, p21 );
  7992. float d1321 = dot( p13, p21 );
  7993. float d4343 = dot( p43, p43 );
  7994. float d2121 = dot( p21, p21 );
  7995. float denom = d2121 * d4343 - d4321 * d4321;
  7996. float numer = d1343 * d4321 - d1321 * d4343;
  7997. mua = numer / denom;
  7998. mua = clamp( mua, 0.0, 1.0 );
  7999. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8000. mub = clamp( mub, 0.0, 1.0 );
  8001. return vec2( mua, mub );
  8002. }
  8003. void main() {
  8004. #include <clipping_planes_fragment>
  8005. #ifdef USE_DASH
  8006. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8007. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8008. #endif
  8009. float alpha = opacity;
  8010. #ifdef WORLD_UNITS
  8011. // Find the closest points on the view ray and the line segment
  8012. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8013. vec3 lineDir = worldEnd - worldStart;
  8014. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8015. vec3 p1 = worldStart + lineDir * params.x;
  8016. vec3 p2 = rayEnd * params.y;
  8017. vec3 delta = p1 - p2;
  8018. float len = length( delta );
  8019. float norm = len / linewidth;
  8020. #ifndef USE_DASH
  8021. #ifdef USE_ALPHA_TO_COVERAGE
  8022. float dnorm = fwidth( norm );
  8023. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8024. #else
  8025. if ( norm > 0.5 ) {
  8026. discard;
  8027. }
  8028. #endif
  8029. #endif
  8030. #else
  8031. #ifdef USE_ALPHA_TO_COVERAGE
  8032. // artifacts appear on some hardware if a derivative is taken within a conditional
  8033. float a = vUv.x;
  8034. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8035. float len2 = a * a + b * b;
  8036. float dlen = fwidth( len2 );
  8037. if ( abs( vUv.y ) > 1.0 ) {
  8038. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8039. }
  8040. #else
  8041. if ( abs( vUv.y ) > 1.0 ) {
  8042. float a = vUv.x;
  8043. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8044. float len2 = a * a + b * b;
  8045. if ( len2 > 1.0 ) discard;
  8046. }
  8047. #endif
  8048. #endif
  8049. vec4 diffuseColor = vec4( diffuse, alpha );
  8050. #include <logdepthbuf_fragment>
  8051. #include <color_fragment>
  8052. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8053. #include <tonemapping_fragment>
  8054. #include <colorspace_fragment>
  8055. #include <fog_fragment>
  8056. #include <premultiplied_alpha_fragment>
  8057. }
  8058. `};class wQ extends em{constructor(e){super({type:"LineMaterial",uniforms:p4.clone(Js.line.uniforms),vertexShader:Js.line.vertexShader,fragmentShader:Js.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 JH=new xl,c_=new rt;class SQ extends ATe{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 Wa([-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 Wa([-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 kD(n,6,1);return this.setAttribute("instanceStart",new Ch(r,3,0)),this.setAttribute("instanceEnd",new Ch(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 kD(n,6,1);return this.setAttribute("instanceColorStart",new Ch(r,3,0)),this.setAttribute("instanceColorEnd",new Ch(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 vTe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xl);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),JH.setFromBufferAttribute(n),this.boundingBox.union(JH))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rc),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++)c_.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(c_)),c_.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(c_));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 e$=new rt,t$=new rt,qi=new Vr,Gi=new Vr,fc=new Vr,mP=new rt,fP=new ia,Wi=new TTe,n$=new rt,u_=new xl,d_=new Rc,pc=new Vr;let gc,tf;function r$(t,e,n){return pc.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),pc.multiplyScalar(1/pc.w),pc.x=tf/n.width,pc.y=tf/n.height,pc.applyMatrix4(t.projectionMatrixInverse),pc.multiplyScalar(1/pc.w),Math.abs(Math.max(pc.x,pc.y))}class VTe extends Xl{constructor(e=new SQ,n=new wQ({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)e$.fromBufferAttribute(n,o),t$.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+e$.distanceTo(t$);const s=new kD(i,2,1);return e.setAttribute("instanceDistanceStart",new Ch(s,1,0)),e.setAttribute("instanceDistanceEnd",new Ch(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;gc=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;tf=c.linewidth+s,l.boundingSphere===null&&l.computeBoundingSphere(),d_.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*tf:u=r$(i,Math.max(i.near,d_.distanceToPoint(gc.origin)),c.resolution),d_.radius+=u,gc.intersectsSphere(d_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),u_.copy(l.boundingBox).applyMatrix4(o),r?d=.5*tf:d=r$(i,Math.max(i.near,u_.distanceToPoint(gc.origin)),c.resolution),u_.expandByScalar(d),gc.intersectsBox(u_)!==!1&&(r?(function(h,f){const p=h.matrixWorld,x=h.geometry,v=x.attributes.instanceStart,g=x.attributes.instanceEnd;for(let y=0,_=Math.min(x.instanceCount,v.count);y<_;y++){Wi.start.fromBufferAttribute(v,y),Wi.end.fromBufferAttribute(g,y),Wi.applyMatrix4(p);const N=new rt,A=new rt;gc.distanceSqToSegment(Wi.start,Wi.end,A,N),A.distanceTo(N)<.5*tf&&f.push({point:A,pointOnLine:N,distance:gc.origin.distanceTo(A),object:h,face:null,faceIndex:y,uv:null,uv1:null})}})(this,n):(function(h,f,p){const x=f.projectionMatrix,v=h.material.resolution,g=h.matrixWorld,y=h.geometry,_=y.attributes.instanceStart,N=y.attributes.instanceEnd,A=Math.min(y.instanceCount,_.count),C=-f.near;gc.at(1,fc),fc.w=1,fc.applyMatrix4(f.matrixWorldInverse),fc.applyMatrix4(x),fc.multiplyScalar(1/fc.w),fc.x*=v.x/2,fc.y*=v.y/2,fc.z=0,mP.copy(fc),fP.multiplyMatrices(f.matrixWorldInverse,g);for(let j=0,k=A;j<k;j++){if(qi.fromBufferAttribute(_,j),Gi.fromBufferAttribute(N,j),qi.w=1,Gi.w=1,qi.applyMatrix4(fP),Gi.applyMatrix4(fP),qi.z>C&&Gi.z>C)continue;if(qi.z>C){const U=qi.z-Gi.z,W=(qi.z-C)/U;qi.lerp(Gi,W)}else if(Gi.z>C){const U=Gi.z-qi.z,W=(Gi.z-C)/U;Gi.lerp(qi,W)}qi.applyMatrix4(x),Gi.applyMatrix4(x),qi.multiplyScalar(1/qi.w),Gi.multiplyScalar(1/Gi.w),qi.x*=v.x/2,qi.y*=v.y/2,Gi.x*=v.x/2,Gi.y*=v.y/2,Wi.start.copy(qi),Wi.start.z=0,Wi.end.copy(Gi),Wi.end.z=0;const R=Wi.closestPointToPointParameter(mP,!0);Wi.at(R,n$);const M=eQ.lerp(qi.z,Gi.z,R),D=M>=-1&&M<=1,G=mP.distanceTo(n$)<.5*tf;if(D&&G){Wi.start.fromBufferAttribute(_,j),Wi.end.fromBufferAttribute(N,j),Wi.start.applyMatrix4(g),Wi.end.applyMatrix4(g);const U=new rt,W=new rt;gc.distanceSqToSegment(Wi.start,Wi.end,W,U),p.push({point:W,pointOnLine:U,distance:gc.origin.distanceTo(W),object:h,face:null,faceIndex:j,uv:null,uv1:null})}}})(this,i,n)))}}class qTe extends vC{constructor(e,n,r,i,s=4473924,o=8947848){s=new fn(s),o=new fn(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let f=-1*(e=l*n/2);f<=e;f+=n){c.push(f,0,-1*r,f,0,r);const p=f===0?s:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let f=-1*r;f<=r;f+=i){c.push(-1*e,0,f,e,0,f);const p=f===0?s:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const h=new Ss;h.setAttribute("position",new Wa(c,3)),h.setAttribute("color",new Wa(u,3)),super(h,new kv({vertexColors:!0,toneMapped:!1}))}}function GTe(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 Wa(d,3)),u})(t,e,n),s=new vC(i,new STe({color:new fn(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,f=15*o,p=74*o,x=30*o,v=document.createElement("canvas");v.width=l,v.height=c,v.style.cssText="width:80px;height:48px";var g=v.getContext("2d");return g.font="bold "+9*o+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,l,c),g.fillStyle=e,g.fillText(t,u,d),g.fillRect(h,f,p,x),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(h,f,p,x),{dom:v,update:function(y,_){r=Math.min(r,y),i=Math.max(i,y),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,l,f),g.fillStyle=e,g.fillText(s(y)+" "+t+" ("+s(r)+"-"+s(i)+")",u,d),g.drawImage(v,h+o,f,p-o,x,h,f,p-o,x),g.fillRect(h+p-o,f,o,x),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(h+p-o,f,o,s((1-y/_)*x))}}};var WTe=t0;class a${constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new K1,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 K1,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 KTe extends Ss{constructor(e=[new rt],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 rt,o=new rt,l=new Tn,c=[],u=[],d=[],h=[];function f(p){const[x,v,g]=(function(y){const _=e[y],N=new rt,A=new rt,C=new rt,j=new rt;N.copy(_).sub(e[y-1]||_).normalize().add((e[y+1]||_).clone().sub(_).normalize()).normalize();let k=Number.MAX_VALUE;const R=Math.abs(N.x),M=Math.abs(N.y),D=Math.abs(N.z);return R<=k&&(k=R,A.set(1,0,0)),M<=k&&(k=M,A.set(0,1,0)),D<=k&&A.set(0,0,1),j.crossVectors(N,A).normalize(),A.crossVectors(N,j),C.crossVectors(N,A),[_,A,C]})(p);for(let y=0;y<=i;y++){const _=y/i*Math.PI*2,N=Math.sin(_),A=-Math.cos(_);o.x=A*v.x+N*g.x,o.y=A*v.y+N*g.y,o.z=A*v.z+N*g.z,o.normalize(),u.push(o.x,o.y,o.z),s.x=x.x+n*o.x*.5,s.y=x.y+n*o.y*.5,s.z=x.z+r*o.z*.5,c.push(s.x,s.y,s.z)}}(function(){for(let p=0;p<e.length;p++)f(p);f(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let x=0;x<=i;x++)l.x=p/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let x=1;x<=i;x++){const v=(i+1)*(p-1)+(x-1),g=(i+1)*p+(x-1),y=(i+1)*p+x,_=(i+1)*(p-1)+x;h.push(v,g,_),h.push(g,y,_)}})()})(),this.setIndex(h),this.setAttribute("position",new Wa(c,3)),this.setAttribute("normal",new Wa(u,3)),this.setAttribute("uv",new Wa(d,2))}}class n0{static get initial(){const e=new n0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const pP={h:0,s:0,l:0};class cb{constructor(e){var n,r,i,s,o,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=n0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=cb.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new fn(14737632),this._travelColor=new fn(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 Y1(this.minLayerThreshold),this.scene=new uTe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new fn(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 WTe:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new fn(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new fn(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new fn(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new fn(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+pC),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 ND({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const p=document.getElementById(this.targetId);if(!p)throw new Error("Unable to find element "+this.targetId);this.renderer=new ND({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new To(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const h=this.camera.far,f=.8*h;this.scene.fog=new x4(this._backgroundColor,f,h),this.resize(),this.controls=new $Te(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 fn(r)}else this._extrusionColor=new fn(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?cb.defaultExtrusionColor:this._extrusionColor instanceof fn?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:cb.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new fn(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new fn(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new fn(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new fn(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 MTe(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 CTe(13421772,.3*Math.PI),n=new kTe(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 Iy;return n.name=e,n.quaternion.setFromEuler(new _v(-Math.PI/2,0,0)),this.buildVolume?n.position.set(-this.buildVolume.x/2,0,this.buildVolume.y/2):n.position.set(-100,0,100),n}render(){const e=performance.now();this.group=this.createGroup("allLayers"),this.state=n0.initial,this.initScene();for(let n=0;n<this.layers.length;n++)this.renderLayer(n);this.batchGeometries(),this.scene.add(this.group),this.renderer.render(this.scene,this.camera),this._lastRenderTime=performance.now()-e}renderAnimated(e=1){return dP(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 f of d.commands)if(f.gcode!="g20"){if(f.gcode.startsWith("t")){this.doRenderExtrusion(h,e),h.extrusion=[];const p=f;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(f.gcode)>-1){const p=f,x={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(s=p.params.r)!==null&&s!==void 0?s:this.state.r,e:(o=p.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=p.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const v=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(f.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(v&&this.renderExtrusion||!v&&this.renderTravel)&&(f.gcode=="g2"||f.gcode=="g3"||f.gcode=="g02"||f.gcode=="g03"?this.addArcSegment(h,this.state,x,v,f.gcode=="g2"||f.gcode=="g02"):this.addLineSegment(h,this.state,x,v))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(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(pP),s=new fn().setHSL(pP.h,pP.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 qTe(this.buildVolume.x,10,this.buildVolume.y,10));const e=GTe(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 Y1(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=n0.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,s){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,h=r.y,f=r.z;let p=r.r,x=r.i,v=r.j;if(p){const ee=d-l,ae=h-c,Y=Math.sqrt(Math.pow(ee/2,2)+Math.pow(ae/2,2));p=Math.max(p,Y);const se=Math.pow(ee,2)+Math.pow(ae,2),ce=Math.pow(p,2)-se/4;let ye=Math.sqrt(ce/se);(s&&p<0||!s&&p>0)&&(ye=-ye),x=ee/2+ae*ye,v=ae/2-ee*ye}const g=l==d&&c==h,y=l+x,_=c+v,N=Math.sqrt(x*x+v*v),A=Math.atan2(-v,-x),C=Math.atan2(h-_,d-y);let j;g?j=2*Math.PI:(j=s?A-C:C-A,j<0&&(j+=2*Math.PI));let k=N*j/1.8;this.inches&&(k*=25),k<1&&(k=1);let R=j/k;R*=s?-1:1;const M=[];M.push({x:l,y:c,z:u});const D=(u-f)/k;let G=l,U=c,W=u,L=A;for(let ee=0;ee<k-1;ee++)L+=R,G=y+N*Math.cos(L),U=_+N*Math.sin(L),W+=D,M.push({x:G,y:U,z:W});M.push({x:r.x,y:r.y,z:r.z});for(let ee=0;ee<M.length-1;ee++)o.push(M[ee].x,M[ee].y,M[ee].z,M[ee+1].x,M[ee+1].y,M[ee+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 Wa(e,3)),this.disposables.push(i);const s=new kv({color:n});this.disposables.push(s);const o=new vC(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 rt(l[0],l[1],l[2]),u=new rt(l[3],l[4],l[5]),d=new rt(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 KTe(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 SQ;this.disposables.push(i);const s=new wQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const o=new VTe(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=>dP(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 wTe({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new xTe(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 dP(this,void 0,void 0,(function*(){const i=e.getReader();let s,o="",l=0;do{console.debug("reading from stream"),s=yield i.read(),l+=(r=(n=s.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=s.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
  8059. `),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 a$(this):typeof this.devMode=="object"&&(this.devGui=new a$(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())}}cb.defaultExtrusionColor=new fn("hotpink");function _Q({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),s=w.useRef(null),o=w.useRef(null),l=w.useRef(!1),[c,u]=w.useState(!0),[d,h]=w.useState(null),[f,p]=w.useState(!1),[x,v]=w.useState(0),[g,y]=w.useState(0),_=w.useMemo(()=>JSON.stringify(n),[n]);w.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const C=i.current,j=C.parentElement?.getBoundingClientRect();j&&(C.width=j.width,C.height=j.height);const k=n&&n.length>1,R=n?.[0]||"#00ae42",M=new cb({canvas:C,buildVolume:e,backgroundColor:1710618,extrusionColor:k?n:R,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});s.current=M;const D={},G=sd();G&&(D.Authorization=`Bearer ${G}`),fetch(t,{headers:D}).then(async W=>{if(!W.ok)throw W.status===404&&(await W.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return W.text()}).then(W=>{const L=new Set,ee=/^(\s*)T(\d+)(\s*;.*)?$/gim;let ae;for(;(ae=ee.exec(W))!==null;){const ue=parseInt(ae[2],10);ue<=15&&L.add(ue)}const Y=new Map,se=Array.from(L).sort((ue,pe)=>ue-pe);se.forEach((ue,pe)=>{Y.set(ue,pe%8)});const ce=[];se.forEach((ue,pe)=>{const be=n?.[ue]||"#00ae42";ce[pe%8]=be});const ye=W.split(`
  8060. `).map(ue=>{const pe=ue.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(pe){const be=parseInt(pe[2],10);if(be>15)return`; FILTERED: ${ue.trim()}`;const Ee=Y.get(be)??0;return`${pe[1]}T${Ee}${pe[3]||""}`}return ue}).join(`
  8061. `);ce.length>0&&(M.extrusionColor=ce),M.processGCode(ye);const Z=M.layers?.length||0;y(Z),v(Z),M.render(),u(!1)}).catch(W=>{W.message!=="not_sliced"&&h(W.message),u(!1)});const U=()=>{if(C.parentElement&&s.current){const W=C.parentElement.getBoundingClientRect();C.width=W.width,C.height=W.height,s.current.resize()}};return window.addEventListener("resize",U),()=>{window.removeEventListener("resize",U),o.current&&cancelAnimationFrame(o.current),s.current&&(s.current.dispose(),s.current=null),l.current=!1}},[t,_]);const N=w.useCallback(C=>{if(!s.current)return;const j=Math.max(1,Math.min(C,g));v(j),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{s.current&&(s.current.endLayer=j,s.current.render())})},[g]),A=C=>{N(parseInt(C.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..."})]})}),f&&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(Ime,{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&&!f&&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&&!f&&g>0&&a.jsx("div",{className:"mt-4 px-2",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ga,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("button",{onClick:()=>N(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(Jl,{className:"w-4 h-4"})}),a.jsx("input",{type:"range",min:1,max:g,value:x,onChange:A,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),a.jsx("button",{onClick:()=>N(x+1),disabled:x>=g,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(pi,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",g]})]})})]})}function ml(t){if(t===0)return"0 B";const e=["B","KB","MB","GB","TB"],n=1024,r=Math.floor(Math.log(t)/Math.log(n)),i=t/Math.pow(n,r);return r===0?`${i} ${e[r]}`:`${i.toFixed(1)} ${e[r]}`}function YTe({printerId:t,filePath:e,filename:n,onClose:r}){const[i,s]=w.useState(null),[o,l]=w.useState([]),[c,u]=w.useState(!1),[d,h]=w.useState(null),f=n.toLowerCase().split(".").pop()||"",p=f==="3mf"||f==="stl",x=f==="gcode"||f==="3mf";w.useEffect(()=>{s(p?"3d":x?"gcode":null)},[p,x]),w.useEffect(()=>{l([]),h(null),p&&(u(!0),ge.getPrinterFilePlates(t,e).then(y=>l(y.plates||[])).catch(()=>l([])).finally(()=>u(!1)))},[e,p,t]);const v=o.length>1,g=d==null?null:o.find(y=>y.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:y=>y.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(Oe,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>p&&s("3d"),disabled:!p,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="3d"?"text-bambu-green border-b-2 border-bambu-green":p?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(ni,{className:"w-4 h-4"}),"3D Model",!p&&a.jsx("span",{className:"text-xs",children:"(not available)"})]}),a.jsxs("button",{onClick:()=>x&&s("gcode"),disabled:!x,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="gcode"?"text-bambu-green border-b-2 border-bambu-green":x?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(Es,{className:"w-4 h-4"}),"G-code Preview",!x&&a.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:i==="3d"&&p?a.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[v&&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(ni,{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(ni,{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(uo,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]}),o.map(y=>a.jsxs("button",{type:"button",onClick:()=>h(y.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d===y.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[y.has_thumbnail?a.jsx("img",{src:ge.getPrinterFilePlateThumbnail(t,y.index,e),alt:`Plate ${y.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(ni,{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:y.name||`Plate ${y.index}`}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:y.objects.length>0?y.objects.slice(0,2).join(", ")+(y.objects.length>2?"…":""):`${y.filaments.length} filament${y.filaments.length!==1?"s":""}`})]}),d===y.index&&a.jsx(uo,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},y.index))]}),g&&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 ",g.index]}),g.print_time_seconds!=null&&a.jsxs("span",{children:["ETA ",Math.round(g.print_time_seconds/60)," min"]}),g.filament_used_grams!=null&&a.jsxs("span",{children:[g.filament_used_grams.toFixed(1)," g"]}),g.filaments.length>0&&a.jsxs("span",{children:[g.filaments.length," filament",g.filaments.length!==1?"s":""]})]})]}),a.jsx("div",{className:"flex-1",children:a.jsx(BX,{url:ge.getPrinterFileDownloadUrl(t,e),fileType:f,selectedPlateId:d,className:"w-full h-full"})})]}):i==="gcode"&&x?a.jsx(_Q,{gcodeUrl:ge.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 i$(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 XTe(t,e){if(e)return IY;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return yf;case"gcode":return Es;case"mp4":case"avi":return Fh;case"png":case"jpg":case"jpeg":return nd;default:return Zk}}const QTe=[{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 ZTe({printerId:t,printerName:e,onClose:n}){const{t:r}=Et(),{showToast:i}=dn(),s=Qt(),[o,l]=w.useState("/"),[c,u]=w.useState(new Set),[d,h]=w.useState(""),[f,p]=w.useState([]),[x,v]=w.useState("name-asc"),[g,y]=w.useState(null),[_,N]=w.useState(null);w.useEffect(()=>{const Y=se=>{se.key==="Escape"&&n()};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[n]);const{data:A,isLoading:C,refetch:j}=Je({queryKey:["printerFiles",t,o],queryFn:()=>ge.getPrinterFiles(t,o)}),{data:k}=Je({queryKey:["printerStorage",t],queryFn:()=>ge.getPrinterStorage(t),staleTime:3e4}),R=ut({mutationFn:async Y=>{for(const se of Y)await ge.deletePrinterFile(t,se)},onSuccess:()=>{i(r("printerFiles.toast.filesDeleted",{count:f.length})),s.invalidateQueries({queryKey:["printerFiles",t]}),u(new Set),p([])},onError:Y=>{i(r("printerFiles.toast.deleteFailed",{error:Y.message}),"error")}}),M=Y=>{l(Y),u(new Set)},D=()=>{if(o==="/")return;const Y=o.split("/").filter(Boolean);Y.pop(),l(Y.length?"/"+Y.join("/"):"/"),u(new Set)},G=(Y,se)=>{se.stopPropagation(),u(ce=>{const ye=new Set(ce);return ye.has(Y)?ye.delete(Y):ye.add(Y),ye})},U=()=>{if(!A?.files)return;const Y=A.files.filter(se=>!se.is_directory&&(!d||se.name.toLowerCase().includes(d.toLowerCase()))).map(se=>se.path);u(new Set(Y))},W=()=>{u(new Set)},L=async()=>{if(c.size===0)return;const Y=Array.from(c);if(Y.length===1){ge.downloadPrinterFile(t,Y[0]).catch(se=>{console.error("Printer file download failed:",se)}),u(new Set);return}y({current:0,total:Y.length});try{const se=await ge.downloadPrinterFilesAsZip(t,Y),ce=URL.createObjectURL(se),ye=document.createElement("a");ye.href=ce,ye.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(ye),ye.click(),document.body.removeChild(ye),URL.revokeObjectURL(ce),i(`Downloaded ${Y.length} files as ZIP`),u(new Set)}catch(se){i(`Download failed: ${se instanceof Error?se.message:"Unknown error"}`,"error")}finally{y(null)}},ee=()=>{c.size!==0&&p(Array.from(c))},ae=[{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:Y=>Y.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(Jb,{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")," ",i$(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")," ",i$(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(Ut,{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:[ae.map(Y=>a.jsx("button",{onClick:()=>{M(Y.path),h("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===Y.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:Y.label},Y.path)),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"relative",children:[a.jsx(Er,{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:Y=>h(Y.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(OF,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("select",{value:x,onChange:Y=>v(Y.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:QTe.map(Y=>a.jsx("option",{value:Y.value,children:Y.label},Y.value))})]}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>j(),disabled:C,children:a.jsx(wr,{className:`w-4 h-4 ${C?"animate-spin":""}`})})]}),a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[a.jsx("button",{onClick:D,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(Jl,{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:C?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"})}):A?.files?.length?a.jsx("div",{className:"space-y-1",children:[...A.files].filter(Y=>!d||Y.name.toLowerCase().includes(d.toLowerCase())).sort((Y,se)=>{if(Y.is_directory&&!se.is_directory)return-1;if(!Y.is_directory&&se.is_directory)return 1;switch(x){case"name-asc":return Y.name.localeCompare(se.name);case"name-desc":return se.name.localeCompare(Y.name);case"size-asc":return Y.size-se.size;case"size-desc":return se.size-Y.size;case"date-asc":{const ce=Y.mtime?Jn(Y.mtime)?.getTime()??0:0,ye=se.mtime?Jn(se.mtime)?.getTime()??0:0;return ce-ye}case"date-desc":{const ce=Y.mtime?Jn(Y.mtime)?.getTime()??0:0;return(se.mtime?Jn(se.mtime)?.getTime()??0:0)-ce}default:return Y.name.localeCompare(se.name)}}).map(Y=>{const se=XTe(Y.name,Y.is_directory),ce=c.has(Y.path);return a.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${ce?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{Y.is_directory&&M(Y.path)},children:[Y.is_directory?null:a.jsx("button",{onClick:ye=>G(Y.path,ye),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:ce?a.jsx(uo,{className:"w-5 h-5 text-bambu-green"}):a.jsx(_l,{className:"w-5 h-5"})}),a.jsx(se,{className:`w-5 h-5 flex-shrink-0 ${Y.is_directory?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:"flex-1 text-white truncate",children:Y.name}),!Y.is_directory&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:ml(Y.size)}),(Y.name.toLowerCase().endsWith(".3mf")||Y.name.toLowerCase().endsWith(".gcode")||Y.name.toLowerCase().endsWith(".stl"))&&a.jsx("button",{onClick:ye=>{ye.stopPropagation(),N({path:Y.path,name:Y.name})},className:"p-1 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green",title:"3D View",children:a.jsx(ni,{className:"w-4 h-4"})})]}),Y.is_directory&&a.jsx(Jl,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},Y.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?`${A?.files?.filter(Y=>Y.name.toLowerCase().includes(d.toLowerCase())).length||0} of ${A?.files?.length||0} items`:`${A?.files?.length||0} items`}),A?.files?.some(Y=>!Y.is_directory)&&a.jsx("div",{className:"flex items-center gap-2",children:c.size>0?a.jsxs("button",{onClick:W,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(Ype,{className:"w-4 h-4"}),"Deselect All"]}):a.jsxs("button",{onClick:U,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(uo,{className:"w-4 h-4"}),"Select All"]})})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Oe,{variant:"secondary",disabled:c.size===0||g!==null,onClick:L,children:g?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),g.current,"/",g.total]}):a.jsxs(a.Fragment,{children:[a.jsx(ba,{className:"w-4 h-4"}),"Download",c.size>1?` (${c.size})`:""]})}),a.jsxs(Oe,{variant:"secondary",disabled:c.size===0||R.isPending,onClick:ee,className:"text-red-400 hover:text-red-300",children:[R.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"}),r("printerFiles.deleteButton"),c.size>1?` (${c.size})`:""]})]})]})]}),f.length>0&&a.jsx(Sn,{title:f.length>1?r("printerFiles.deleteFiles",{count:f.length}):r("fileManager.deleteFile"),message:f.length>1?r("printerFiles.deleteFilesConfirm",{count:f.length}):r("printerFiles.deleteFileConfirm",{name:f[0].split("/").pop()}),confirmText:r("common.delete"),variant:"danger",onConfirm:()=>{R.mutate(f)},onCancel:()=>p([])}),_&&a.jsx(YTe,{printerId:t,filePath:_.path,filename:_.name,onClose:()=>N(null)})]})}function w4({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 wC=({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 S4({printerId:t,isOpen:e,onClose:n}){const{t:r}=Et(),{showToast:i}=dn(),{hasPermission:s}=Rr(),[o,l]=w.useState(null),[c,u]=w.useState(!1),{data:d}=Je({queryKey:["printerStatus",t],queryFn:()=>ge.getPrinterStatus(t),refetchInterval:3e4,enabled:e}),{data:h,refetch:f}=Je({queryKey:["printableObjects",t],queryFn:()=>ge.getPrintableObjects(t),enabled:e,refetchInterval:e?5e3:!1}),p=ut({mutationFn:x=>ge.skipObjects(t,x),onSuccess:x=>{i(x.message||r("printers.skipObjects.objectsSkipped")),l(null),f()},onError:x=>i(x.message||r("printers.toast.failedToSkipObjects"),"error")});return e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,onKeyDown:x=>{x.key==="Escape"&&(c?u(!1):n())},tabIndex:-1,ref:x=>x?.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:x=>x.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(wC,{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(Ut,{className:"w-4 h-4"})})]}),h?h.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(epe,{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:[h.skipped_count,"/",h.total," ",r("printers.skipObjects.skipped")]})]}),(d?.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(qa,{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:d?.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 cursor-pointer group",onClick:()=>u(!0),children:[d?.cover_url?a.jsx("img",{src:`${d.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(ni,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),a.jsx("div",{className:"absolute top-2 right-2 p-1 bg-black/60 rounded opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(nC,{className:"w-3.5 h-3.5 text-white"})}),h.objects.length>0&&a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:h.objects.map((x,v)=>{let g,y;if(x.x!=null&&x.y!=null&&h.bbox_all){const[_,N,A,C]=h.bbox_all,j=A-_,k=C-N,R=8,M=100-R*2;g=R+(x.x-_)/j*M,y=R+(C-x.y)/k*M,g=Math.max(5,Math.min(95,g)),y=Math.max(5,Math.min(95,y))}else if(x.x!=null&&x.y!=null)g=x.x/256*100,y=100-x.y/256*100,g=Math.max(5,Math.min(95,g)),y=Math.max(5,Math.min(95,y));else{const _=Math.ceil(Math.sqrt(h.objects.length)),N=Math.floor(v/_),A=v%_,C=Math.ceil(h.objects.length/_);g=15+A*(70/_)+35/_,y=15+N*(70/C)+35/C}return a.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${x.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${g}%`,top:`${y}%`,transform:"translate(-50%, -50%)"},title:x.name,children:x.id},x.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:h.objects.filter(x=>!x.skipped).length})})]})}),a.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:h.objects.map(x=>a.jsxs("div",{className:`
  8062. flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
  8063. ${x.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  8064. `,children:[a.jsxs("div",{className:`
  8065. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  8066. ${x.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"}
  8067. `,children:[a.jsx("span",{className:`text-lg font-mono font-bold ${x.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:x.id}),a.jsx("span",{className:`text-[8px] uppercase tracking-wider ${x.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 ${x.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:x.name}),x.skipped&&a.jsx("span",{className:"text-[10px] text-red-400/60",children:r("printers.willBeSkipped")})]}),x.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:()=>l({id:x.id,name:x.name}),disabled:p.isPending||(d?.layer_num??0)<=1||!s("printers:control"),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(d?.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")?(d?.layer_num??0)<=1?r("printers.skipObjects.waitForLayer",{layer:d?.layer_num??0}):r("printers.skipObjects.skip"):r("printers.permission.noControl"),children:r("printers.skipObjects.skip")})]},x.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"})})]})]}),o&&a.jsx(Sn,{variant:"warning",title:r("printers.skipObjects.confirmTitle"),message:r("printers.skipObjects.confirmMessage",{name:o.name}),confirmText:r("printers.skipObjects.skip"),isLoading:p.isPending,onConfirm:()=>p.mutate([o.id]),onCancel:()=>l(null)}),c&&h&&a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>u(!1),children:[a.jsx("button",{onClick:()=>u(!1),className:"absolute top-4 right-4 p-2 text-white/70 hover:text-white transition-colors",children:a.jsx(Ut,{className:"w-6 h-6"})}),a.jsxs("div",{className:"relative max-w-[600px] max-h-[80vh] aspect-square",onClick:x=>x.stopPropagation(),children:[d?.cover_url?a.jsx("img",{src:`${d.cover_url}?view=top`,alt:r("printers.printPreview"),className:"w-full h-full object-contain rounded-lg bg-gray-900"}):a.jsx("div",{className:"w-full h-full rounded-lg bg-gray-800 flex items-center justify-center",children:a.jsx(ni,{className:"w-16 h-16 text-gray-500"})}),h.objects.length>0&&a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:h.objects.map((x,v)=>{let g,y;if(x.x!=null&&x.y!=null&&h.bbox_all){const[_,N,A,C]=h.bbox_all,j=A-_,k=C-N,R=8,M=100-R*2;g=R+(x.x-_)/j*M,y=R+(C-x.y)/k*M,g=Math.max(5,Math.min(95,g)),y=Math.max(5,Math.min(95,y))}else if(x.x!=null&&x.y!=null)g=x.x/256*100,y=100-x.y/256*100,g=Math.max(5,Math.min(95,g)),y=Math.max(5,Math.min(95,y));else{const _=Math.ceil(Math.sqrt(h.objects.length)),N=Math.floor(v/_),A=v%_,C=Math.ceil(h.objects.length/_);g=15+A*(70/_)+35/_,y=15+N*(70/C)+35/C}return a.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${x.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${g}%`,top:`${y}%`,transform:"translate(-50%, -50%)"},title:x.name,children:x.id},x.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:h.objects.filter(x=>!x.skipped).length})})]})]})]}):null}const JTe="embeddedCameraState_",s$=5,e2e=2e3,t2e=3e4,n2e=5e3,gP={x:window.innerWidth-420,y:20,width:400,height:300};function r2e({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const{t:i}=Et(),s=Qt(),{showToast:o}=dn(),{hasPermission:l}=Rr(),c=`${JTe}${t}`,u=()=>{try{const Pe=localStorage.getItem(c);if(Pe){const Be=JSON.parse(Pe);return{x:Math.min(Math.max(0,Be.x),window.innerWidth-100),y:Math.min(Math.max(0,Be.y),window.innerHeight-100),width:Math.max(200,Math.min(Be.width,window.innerWidth-20)),height:Math.max(150,Math.min(Be.height,window.innerHeight-20))}}}catch{}const Re=n*30;return{...gP,x:Math.max(0,gP.x-Re),y:Math.max(0,gP.y+Re)}},[d,h]=w.useState(u),[f,p]=w.useState(!1),[x,v]=w.useState(!1),[g,y]=w.useState({x:0,y:0}),[_,N]=w.useState(!1),[A,C]=w.useState(!1),[j,k]=w.useState(1),[R,M]=w.useState({x:0,y:0}),[D,G]=w.useState(!1),[U,W]=w.useState({x:0,y:0}),[L,ee]=w.useState(null),[ae,Y]=w.useState(null),[se,ce]=w.useState(!1),[ye,Z]=w.useState(!0),[ue,pe]=w.useState(Date.now()),[be,Ee]=w.useState(0),[$,K]=w.useState(!1),[T,E]=w.useState(0),O=w.useRef(null),q=w.useRef(null),B=w.useRef(null),re=w.useRef(null),z=w.useRef(null),[V,te]=w.useState(!1),{data:Q}=Je({queryKey:["printer",t],queryFn:()=>ge.getPrinter(t),enabled:t>0}),{data:ne}=Je({queryKey:["printerStatus",t],queryFn:()=>ge.getPrinterStatus(t),refetchInterval:3e4,enabled:t>0}),ie=ut({mutationFn:Re=>ge.setChamberLight(t,Re),onMutate:async Re=>{await s.cancelQueries({queryKey:["printerStatus",t]});const Pe=s.getQueryData(["printerStatus",t]);return s.setQueryData(["printerStatus",t],Be=>({...Be,chamber_light:Re})),{previousStatus:Pe}},onSuccess:(Re,Pe)=>{o(`Chamber light ${Pe?"on":"off"}`)},onError:(Re,Pe,Be)=>{Be?.previousStatus&&s.setQueryData(["printerStatus",t],Be.previousStatus),o(Re.message||i("printers.toast.failedToControlChamberLight"),"error")}}),me=(ne?.state==="RUNNING"||ne?.state==="PAUSE")&&(ne?.printable_objects_count??0)>=2;w.useEffect(()=>{const Re=setTimeout(()=>{localStorage.setItem(c,JSON.stringify(d))},500);return()=>clearTimeout(Re)},[d,c]);const fe=w.useRef(!1);w.useEffect(()=>{fe.current=!1;const Re=`/api/v1/printers/${t}/camera/stop`,Pe=()=>{if(t>0&&!fe.current){fe.current=!0;const We={},ct=sd();ct&&(We.Authorization=`Bearer ${ct}`),fetch(Re,{method:"POST",keepalive:!0,headers:We}).catch(()=>{})}},Be=q.current;return()=>{Be&&(Be.src=""),Pe(),B.current&&clearTimeout(B.current),re.current&&clearInterval(re.current),z.current&&clearInterval(z.current)}},[t]),w.useEffect(()=>{if(ye){const Re=setTimeout(()=>Z(!1),3e3);return()=>clearTimeout(Re)}},[ye,ue]);const oe=w.useCallback(()=>{if(be>=s$){K(!1),ce(!0);return}const Re=Math.min(e2e*Math.pow(2,be),t2e);K(!0),E(Math.ceil(Re/1e3)),re.current=setInterval(()=>{E(Pe=>Pe<=1?(re.current&&clearInterval(re.current),0):Pe-1)},1e3),B.current=setTimeout(()=>{Ee(Pe=>Pe+1),K(!1),Z(!0),ce(!1),q.current&&(q.current.src=""),pe(Date.now())},Re)},[be]);w.useEffect(()=>{if(ye||$||_){z.current&&(clearInterval(z.current),z.current=null);return}return z.current=setInterval(async()=>{try{const Re=await ge.getCameraStatus(t);(Re.stalled||!Re.active&&!se)&&(z.current&&(clearInterval(z.current),z.current=null),Z(!1),oe())}catch{}},n2e),()=>{z.current&&(clearInterval(z.current),z.current=null)}},[ye,se,$,_,t,oe]),w.useEffect(()=>{const Re=()=>{const Pe=!!document.fullscreenElement;C(Pe),Pe||(k(1),M({x:0,y:0}))};return document.addEventListener("fullscreenchange",Re),()=>document.removeEventListener("fullscreenchange",Re)},[]);const I=()=>{O.current&&(document.fullscreenElement?document.exitFullscreen():O.current.requestFullscreen())},F=()=>{k(Re=>Math.min(Re+.5,4))},J=()=>{k(Re=>{const Pe=Math.max(Re-.5,1);return Pe===1&&M({x:0,y:0}),Pe})},xe=Re=>{Re.preventDefault(),Re.deltaY<0?F():J()},he=Re=>{j>1&&(Re.preventDefault(),G(!0),W({x:Re.clientX-R.x,y:Re.clientY-R.y}))},le=w.useCallback(()=>{if(!O.current||!q.current)return{x:200,y:150};const Re=O.current.getBoundingClientRect(),Pe=Re.width*(j-1)/2,Be=Re.height*(j-1)/2;return{x:Math.max(50,Pe),y:Math.max(50,Be)}},[j]),Ce=Re=>{if(D&&j>1){const Pe=Re.clientX-U.x,Be=Re.clientY-U.y,We=le();M({x:Math.max(-We.x,Math.min(We.x,Pe)),y:Math.max(-We.y,Math.min(We.y,Be))})}},Ne=()=>{G(!1)},Ue=Re=>{if(Re.length<2)return 0;const Pe=Re[0].clientX-Re[1].clientX,Be=Re[0].clientY-Re[1].clientY;return Math.sqrt(Pe*Pe+Be*Be)},He=Re=>Re.length<2?{x:Re[0].clientX,y:Re[0].clientY}:{x:(Re[0].clientX+Re[1].clientX)/2,y:(Re[0].clientY+Re[1].clientY)/2},de=Re=>{Re.touches.length===2?(Re.preventDefault(),ee(Ue(Re.touches)),Y(He(Re.touches))):Re.touches.length===1&&j>1&&(Re.preventDefault(),G(!0),W({x:Re.touches[0].clientX-R.x,y:Re.touches[0].clientY-R.y}))},we=Re=>{if(Re.touches.length===2&&L!==null){Re.preventDefault();const Pe=Ue(Re.touches),Be=Pe/L;k(ct=>{const St=Math.max(1,Math.min(4,ct*Be));return St===1&&M({x:0,y:0}),St}),ee(Pe);const We=He(Re.touches);if(ae){const ct=le();M(St=>({x:Math.max(-ct.x,Math.min(ct.x,St.x+(We.x-ae.x))),y:Math.max(-ct.y,Math.min(ct.y,St.y+(We.y-ae.y)))}))}Y(We)}else if(Re.touches.length===1&&D&&j>1){Re.preventDefault();const Pe=Re.touches[0].clientX-U.x,Be=Re.touches[0].clientY-U.y,We=le();M({x:Math.max(-We.x,Math.min(We.x,Pe)),y:Math.max(-We.y,Math.min(We.y,Be))})}},ke=Re=>{Re.touches.length<2&&(ee(null),Y(null)),Re.touches.length===0&&G(!1)},_e=()=>{k(1),M({x:0,y:0})},Ae=()=>{Z(!1),be<s$?oe():ce(!0)},Ve=()=>{Z(!1),ce(!1),Ee(0),K(!1),B.current&&clearTimeout(B.current),re.current&&clearInterval(re.current)},Te=()=>{Z(!0),ce(!1),Ee(0),K(!1),B.current&&clearTimeout(B.current),re.current&&clearInterval(re.current);const Re={},Pe=sd();Pe&&(Re.Authorization=`Bearer ${Pe}`),fetch(`/api/v1/printers/${t}/camera/stop`,{method:"POST",headers:Re}).catch(()=>{}),q.current&&(q.current.src=""),setTimeout(()=>pe(Date.now()),100)},Ke=Re=>{Re.target.closest(".no-drag")||(p(!0),y({x:Re.clientX-d.x,y:Re.clientY-d.y}))},je=Re=>{Re.stopPropagation(),v(!0)};w.useEffect(()=>{const Re=Be=>{if(f)h(We=>({...We,x:Math.max(0,Math.min(Be.clientX-g.x,window.innerWidth-We.width)),y:Math.max(0,Math.min(Be.clientY-g.y,window.innerHeight-We.height))}));else if(x&&O.current){const We=O.current.getBoundingClientRect();h(ct=>({...ct,width:Math.max(200,Math.min(Be.clientX-We.left,window.innerWidth-ct.x-10)),height:Math.max(150,Math.min(Be.clientY-We.top,window.innerHeight-ct.y-10))}))}},Pe=()=>{p(!1),v(!1)};if(f||x)return document.addEventListener("mousemove",Re),document.addEventListener("mouseup",Pe),()=>{document.removeEventListener("mousemove",Re),document.removeEventListener("mouseup",Pe)}},[f,x,g]);const qe=`/api/v1/printers/${t}/camera/stream?fps=15&t=${ue}`;return a.jsxs("div",{ref:O,className:`${A?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:A?void 0:{left:d.x,top:d.y,width:_?200:d.width,height:_?40:d.height,cursor:f?"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:Ke,children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[a.jsx(Oh,{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:()=>ie.mutate(!ne?.chamber_light),disabled:!ne?.connected||ie.isPending||!l("printers:control"),className:`p-1 rounded disabled:opacity-50 ${ne?.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(w4,{on:ne?.chamber_light??!1,className:"w-3.5 h-3.5"})}),a.jsx("button",{onClick:()=>te(!0),disabled:!me||!l("printers:control"),className:`p-1 rounded disabled:opacity-50 ${me&&l("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:l("printers:control")?i(me?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):i("printers.permission.noControl"),children:a.jsx(wC,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:Te,disabled:ye||$,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:a.jsx(wr,{className:`w-3.5 h-3.5 text-bambu-gray ${ye?"animate-spin":""}`})}),a.jsx("button",{onClick:I,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:A?"Exit fullscreen":"Fullscreen",children:A?a.jsx(BY,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(Jme,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:()=>N(!_),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:_?"Expand":"Minimize",children:_?a.jsx(nC,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(zF,{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(Ut,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!_&&a.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:xe,onMouseMove:Ce,onMouseUp:Ne,onMouseLeave:Ne,onTouchStart:de,onTouchMove:we,onTouchEnd:ke,style:{touchAction:"none"},children:[ye&&!$&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsx(wr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),$&&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(Xh,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",T,"s..."]})]})}),se&&!$&&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(Mn,{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:Te,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),a.jsx("img",{ref:q,src:qe,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${j}) translate(${R.x/j}px, ${R.y/j}px)`,cursor:j>1?D?"grabbing":"grab":"default"},onError:Ae,onLoad:Ve,onMouseDown:he,draggable:!1},ue),a.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag",children:[a.jsx("button",{onClick:J,disabled:j<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:a.jsx(qF,{className:"w-3.5 h-3.5 text-white"})}),a.jsxs("button",{onClick:_e,className:"px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]",title:"Reset zoom",children:[Math.round(j*100),"%"]}),a.jsx("button",{onClick:F,disabled:j>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:a.jsx(VF,{className:"w-3.5 h-3.5 text-white"})})]}),!A&&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:je,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(S4,{printerId:t,isOpen:V,onClose:()=>te(!1)})]})}function a2e({printerId:t,printerName:e,onClose:n}){const{t:r}=Et(),i=Qt(),[s,o]=w.useState(!0),[l,c]=w.useState(new Set),[u,d]=w.useState(""),[h,f]=w.useState("all"),p=w.useRef(null),{data:x,isLoading:v,refetch:g}=Je({queryKey:["mqtt-logs",t],queryFn:()=>ge.getMQTTLogs(t),refetchInterval:1e3}),y=ut({mutationFn:()=>ge.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),_=ut({mutationFn:()=>ge.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),N=ut({mutationFn:()=>ge.clearMQTTLogs(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const D=G=>{G.key==="Escape"&&n()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[n]),w.useEffect(()=>{s&&p.current&&(p.current.scrollTop=p.current.scrollHeight)},[x?.logs,s]);const A=D=>{c(G=>{const U=new Set(G);return U.has(D)?U.delete(D):U.add(D),U})},C=D=>new Date(D).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),j=(D,G)=>{if(D==null)return"<empty>";const U=typeof D=="string"?JSON.parse(D):D,W=JSON.stringify(U,null,G?2:0);return!G&&W.length>100?W.substring(0,100)+"...":W},k=x?.logging_enabled??!1,R=w.useMemo(()=>x?.logs??[],[x?.logs]),M=w.useMemo(()=>R.filter(D=>{if(h!=="all"&&D.direction!==h)return!1;if(u.trim()){const G=u.toLowerCase(),U=D.topic.toLowerCase().includes(G),L=JSON.stringify(D.payload).toLowerCase().includes(G);return U||L}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(Ut,{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(Oe,{size:"sm",variant:"secondary",onClick:()=>_.mutate(),disabled:_.isPending,children:[a.jsx(_l,{className:"w-4 h-4"}),r("mqttDebug.stopLogging")]}):a.jsxs(Oe,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:[a.jsx(lo,{className:"w-4 h-4"}),r("mqttDebug.startLogging")]}),a.jsxs(Oe,{size:"sm",variant:"secondary",onClick:()=>N.mutate(),disabled:N.isPending||R.length===0,children:[a.jsx(Xt,{className:"w-4 h-4"}),r("mqttDebug.clearLog")]}),a.jsx(Oe,{size:"sm",variant:"secondary",onClick:()=>g(),disabled:v,children:a.jsx(wr,{className:`w-4 h-4 ${v?"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:D=>o(D.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[M.length,"/",R.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Er,{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:D=>d(D.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),u&&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(Ut,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${h==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:r("mqttDebug.all")}),a.jsxs("button",{onClick:()=>f("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(bb,{className:"w-3 h-3"}),r("mqttDebug.incoming")]}),a.jsxs("button",{onClick:()=>f("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(Lf,{className:"w-3 h-3"}),r("mqttDebug.outgoing")]})]})]})]}),a.jsx("div",{ref:p,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")})]}):M.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:M.map((D,G)=>{const U=l.has(G),W=D.direction==="in";return a.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${U?"bg-bambu-dark-secondary":""}`,onClick:()=>A(G),children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray shrink-0",children:C(D.timestamp)}),a.jsx("span",{className:`shrink-0 ${W?"text-blue-400":"text-green-400"}`,title:r(W?"mqttDebug.incoming":"mqttDebug.outgoing"),children:W?a.jsx(bb,{className:"w-3 h-3"}):a.jsx(Lf,{className:"w-3 h-3"})}),a.jsx("span",{className:"text-purple-400 shrink-0",children:D.topic})]}),U?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:j(D.payload,!0)}):a.jsx("pre",{className:"mt-1 text-white/80 truncate",children:j(D.payload,!1)})]},G)})})}),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(Oe,{variant:"secondary",onClick:n,children:r("common.close")})]})]})})}const AD={"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 i2e(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Mn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Mn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:qa};default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:to}}}function TD(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 s2e(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=TD(e.attr,n);return AD[r]!==void 0})}function o2e(){return"https://wiki.bambulab.com/en/hms/home"}function l2e({printerName:t,errors:e,onClose:n,printerId:r,hasPermission:i}){const{t:s}=Et(),{showToast:o}=dn(),l=ut({mutationFn:()=>ge.clearHMSErrors(r),onSuccess:()=>{o(s("hmsErrors.clearSuccess"),"success"),n()},onError:()=>{o(s("hmsErrors.clearFailed"),"error")}}),c=e.filter(u=>{const d=parseInt(u.code.replace("0x",""),16)||0,h=TD(u.attr,d);return AD[h]!==void 0});return w.useEffect(()=>{const u=d=>{d.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[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(Mn,{className:"w-5 h-5 text-orange-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:s("hmsErrors.title",{name:t})})]}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ut,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:c.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(qa,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{children:s("hmsErrors.noErrors")})]}):a.jsx("div",{className:"space-y-3",children:c.map((u,d)=>{const{label:h,color:f,bgColor:p,Icon:x}=i2e(u.severity),v=parseInt(u.code.replace("0x",""),16)||0,g=TD(u.attr,v),y=AD[g],_=o2e(),N=g.replace("_","-");return a.jsx("div",{className:`p-4 rounded-lg ${p} border border-white/10`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(x,{className:`w-5 h-5 ${f} 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 ${f}`,children:["[",N,"]"]}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${p} ${f}`,children:h})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:y}),a.jsxs("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[a.jsx(aa,{className:"w-3 h-3"}),s("hmsErrors.viewOnWiki")]})]})]})},`${u.code}-${d}`)})})}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex items-center justify-between gap-3",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:s("hmsErrors.clearInstructions")}),c.length>0&&a.jsxs("button",{onClick:()=>l.mutate(),disabled:!i("printers:control")||l.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-lg bg-red-500/20 text-red-400 hover:bg-red-500/30 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex-shrink-0",children:[l.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"}),s("hmsErrors.clearErrors")]})]})]})})}function c2e({printerId:t,printerModel:e,printerState:n,plateCleared:r,loadedFilamentTypes:i,loadedFilaments:s}){const{t:o}=Et(),l=Qt(),{showToast:c}=dn(),{hasPermission:u}=Rr(),{data:d}=Je({queryKey:["queue",t,"pending",e],queryFn:()=>ge.getQueue(t,"pending",e||void 0),refetchInterval:3e4}),h=ut({mutationFn:()=>ge.clearPlate(t),onSuccess:()=>{l.invalidateQueries({queryKey:["queue",t]}),l.invalidateQueries({queryKey:["printerStatus",t]}),c(o("queue.clearPlateSuccess"),"success")},onError:g=>{c(g.message,"error")}}),f=d?.filter(g=>!(g.required_filament_types?.length&&i?.size&&!g.required_filament_types.every(y=>i.has(y.toUpperCase()))||g.filament_overrides?.length&&s?.size&&!g.filament_overrides.some(_=>{const N=(_.type||"").toUpperCase(),A=(_.color||"").replace("#","").toLowerCase().slice(0,6);return s.has(`${N}:${A}`)}))),p=f?.[0],x=f?.length||0;return x===0?null:(n==="FINISH"||n==="FAILED")&&!r?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(Xr,{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:o("queue.nextInQueue")}),a.jsx("p",{className:"text-sm text-white truncate",children:p?.archive_name||p?.library_file_name||`File #${p?.archive_id||p?.library_file_id}`})]}),x>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:["+",x-1]})]}),h.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(yb,{className:"w-4 h-4"}),o("queue.plateReady")]}):a.jsxs("button",{onClick:()=>h.mutate(),disabled:h.isPending||!u("printers:clear_plate"),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:[h.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(yb,{className:"w-4 h-4"}),o("queue.clearPlate")]})]}):a.jsx(Zs,{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(Xr,{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:o("queue.nextInQueue")}),a.jsx("p",{className:"text-sm text-white truncate",children:p?.archive_name||p?.library_file_name||`File #${p?.archive_id||p?.library_file_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(Xn,{className:"w-3 h-3"}),p?.scheduled_time?C0(p.scheduled_time,"system",o):o("time.waiting")]}),x>1&&a.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",x-1]}),a.jsx(pi,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function NQ(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=NQ(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function hr(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=NQ(t))&&(r&&(r+=" "),r+=e);return r}var u2e=["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 _4(t){if(typeof t!="string")return!1;var e=u2e;return e.includes(t)}var d2e=["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"],h2e=new Set(d2e);function kQ(t){return typeof t!="string"?!1:h2e.has(t)}function CQ(t){return typeof t=="string"&&t.startsWith("data-")}function Is(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(kQ(n)||CQ(n))&&(e[n]=t[n]);return e}function Gf(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Is(e)}return typeof t=="object"&&!Array.isArray(t)?Is(t):null}function rs(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(kQ(n)||CQ(n)||_4(n))&&(e[n]=t[n]);return e}function m2e(t){return t==null?null:w.isValidElement(t)?rs(t.props):typeof t=="object"&&!Array.isArray(t)?rs(t):null}var f2e=["children","width","height","viewBox","className","style","title","desc"];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 p2e(t,e){if(t==null)return{};var n,r,i=g2e(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 g2e(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 N4=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:o,style:l,title:c,desc:u}=t,d=p2e(t,f2e),h=s||{width:r,height:i,x:0,y:0},f=hr("recharts-surface",o);return w.createElement("svg",MD({},rs(d),{className:f,width:r,height:i,style:l,viewBox:"".concat(h.x," ").concat(h.y," ").concat(h.width," ").concat(h.height),ref:e}),w.createElement("title",null,c),w.createElement("desc",null,u),n)}),b2e=["children","className"];function PD(){return PD=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},PD.apply(null,arguments)}function x2e(t,e){if(t==null)return{};var n,r,i=y2e(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 y2e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Sa=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=x2e(t,b2e),s=hr("recharts-layer",r);return w.createElement("g",PD({className:s},rs(i),{ref:e}),n)}),AQ=w.createContext(null),v2e=()=>w.useContext(AQ);function ra(t){return function(){return t}}const TQ=Math.cos,X1=Math.sin,oc=Math.sqrt,Q1=Math.PI,SC=2*Q1,jD=Math.PI,ED=2*jD,Km=1e-6,w2e=ED-Km;function MQ(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function S2e(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return MQ;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 _2e{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?MQ:S2e(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,f=d*d+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(f>Km)if(!(Math.abs(h*c-u*d)>Km)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,x=i-l,v=c*c+u*u,g=p*p+x*x,y=Math.sqrt(v),_=Math.sqrt(f),N=s*Math.tan((jD-Math.acos((v+f-g)/(2*y*_)))/2),A=N/_,C=N/y;Math.abs(A-1)>Km&&this._append`L${e+A*d},${n+A*h}`,this._append`A${s},${s},0,0,${+(h*p>d*x)},${this._x1=e+C*c},${this._y1=n+C*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,f=o?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Km||Math.abs(this._y1-d)>Km)&&this._append`L${u},${d}`,r&&(f<0&&(f=f%ED+ED),f>w2e?this._append`A${r},${r},0,1,${h},${e-l},${n-c}A${r},${r},0,1,${h},${this._x1=u},${this._y1=d}`:f>Km&&this._append`A${r},${r},0,${+(f>=jD)},${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 k4(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 _2e(e)}function C4(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function PQ(t){this._context=t}PQ.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 _C(t){return new PQ(t)}function jQ(t){return t[0]}function EQ(t){return t[1]}function DQ(t,e){var n=ra(!0),r=null,i=_C,s=null,o=k4(l);t=typeof t=="function"?t:t===void 0?jQ:ra(t),e=typeof e=="function"?e:e===void 0?EQ:ra(e);function l(c){var u,d=(c=C4(c)).length,h,f=!1,p;for(r==null&&(s=i(p=o())),u=0;u<=d;++u)!(u<d&&n(h=c[u],u,c))===f&&((f=!f)?s.lineStart():s.lineEnd()),f&&s.point(+t(h,u,c),+e(h,u,c));if(p)return s=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:ra(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:ra(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:ra(!!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 h_(t,e,n){var r=null,i=ra(!0),s=null,o=_C,l=null,c=k4(u);t=typeof t=="function"?t:t===void 0?jQ:ra(+t),e=typeof e=="function"?e:ra(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?EQ:ra(+n);function u(h){var f,p,x,v=(h=C4(h)).length,g,y=!1,_,N=new Array(v),A=new Array(v);for(s==null&&(l=o(_=c())),f=0;f<=v;++f){if(!(f<v&&i(g=h[f],f,h))===y)if(y=!y)p=f,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=f-1;x>=p;--x)l.point(N[x],A[x]);l.lineEnd(),l.areaEnd()}y&&(N[f]=+t(g,f,h),A[f]=+e(g,f,h),l.point(r?+r(g,f,h):N[f],n?+n(g,f,h):A[f]))}if(_)return l=null,_+""||null}function d(){return DQ().defined(i).curve(o).context(s)}return u.x=function(h){return arguments.length?(t=typeof h=="function"?h:ra(+h),r=null,u):t},u.x0=function(h){return arguments.length?(t=typeof h=="function"?h:ra(+h),u):t},u.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:ra(+h),u):r},u.y=function(h){return arguments.length?(e=typeof h=="function"?h:ra(+h),n=null,u):e},u.y0=function(h){return arguments.length?(e=typeof h=="function"?h:ra(+h),u):e},u.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:ra(+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:ra(!!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 RQ{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 N2e(t){return new RQ(t,!0)}function k2e(t){return new RQ(t,!1)}const A4={draw(t,e){const n=oc(e/Q1);t.moveTo(n,0),t.arc(0,0,n,0,SC)}},C2e={draw(t,e){const n=oc(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()}},FQ=oc(1/3),A2e=FQ*2,T2e={draw(t,e){const n=oc(e/A2e),r=n*FQ;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},M2e={draw(t,e){const n=oc(e),r=-n/2;t.rect(r,r,n,n)}},P2e=.8908130915292852,LQ=X1(Q1/10)/X1(7*Q1/10),j2e=X1(SC/10)*LQ,E2e=-TQ(SC/10)*LQ,D2e={draw(t,e){const n=oc(e*P2e),r=j2e*n,i=E2e*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const o=SC*s/5,l=TQ(o),c=X1(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},bP=oc(3),R2e={draw(t,e){const n=-oc(e/(bP*3));t.moveTo(0,n*2),t.lineTo(-bP*n,-n),t.lineTo(bP*n,-n),t.closePath()}},Zo=-.5,Jo=oc(3)/2,DD=1/oc(12),F2e=(DD/2+1)*3,L2e={draw(t,e){const n=oc(e/F2e),r=n/2,i=n*DD,s=r,o=n*DD+n,l=-s,c=o;t.moveTo(r,i),t.lineTo(s,o),t.lineTo(l,c),t.lineTo(Zo*r-Jo*i,Jo*r+Zo*i),t.lineTo(Zo*s-Jo*o,Jo*s+Zo*o),t.lineTo(Zo*l-Jo*c,Jo*l+Zo*c),t.lineTo(Zo*r+Jo*i,Zo*i-Jo*r),t.lineTo(Zo*s+Jo*o,Zo*o-Jo*s),t.lineTo(Zo*l+Jo*c,Zo*c-Jo*l),t.closePath()}};function O2e(t,e){let n=null,r=k4(i);t=typeof t=="function"?t:ra(t||A4),e=typeof e=="function"?e:ra(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:ra(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:ra(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function Z1(){}function J1(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 OQ(t){this._context=t}OQ.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:J1(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:J1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function I2e(t){return new OQ(t)}function IQ(t){this._context=t}IQ.prototype={areaStart:Z1,areaEnd:Z1,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:J1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function z2e(t){return new IQ(t)}function zQ(t){this._context=t}zQ.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:J1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function U2e(t){return new zQ(t)}function UQ(t){this._context=t}UQ.prototype={areaStart:Z1,areaEnd:Z1,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 B2e(t){return new UQ(t)}function o$(t){return t<0?-1:1}function l$(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(o$(s)+o$(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(l))||0}function c$(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function xP(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 eN(t){this._context=t}eN.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:xP(this,this._t0,c$(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,xP(this,c$(this,n=l$(this,t,e)),n);break;default:xP(this,this._t0,n=l$(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function BQ(t){this._context=new HQ(t)}(BQ.prototype=Object.create(eN.prototype)).point=function(t,e){eN.prototype.point.call(this,e,t)};function HQ(t){this._context=t}HQ.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 H2e(t){return new eN(t)}function $2e(t){return new BQ(t)}function $Q(t){this._context=t}$Q.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=u$(t),i=u$(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 u$(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 V2e(t){return new $Q(t)}function NC(t,e){this._context=t,this._t=e}NC.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 q2e(t){return new NC(t,.5)}function G2e(t){return new NC(t,0)}function W2e(t){return new NC(t,1)}function Wf(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 RD(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function K2e(t,e){return t[e]}function Y2e(t){const e=[];return e.key=t,e}function X2e(){var t=ra([]),e=RD,n=Wf,r=K2e;function i(s){var o=Array.from(t.apply(this,arguments),Y2e),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=C4(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:ra(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:ra(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?RD:typeof s=="function"?s:ra(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??Wf,i):n},i}function Q2e(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}Wf(t,e)}}function Z2e(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}Wf(t,e)}}function J2e(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,f=d[r-1][1]||0,p=(h-f)/2,x=0;x<l;++x){var v=t[e[x]],g=v[r][1]||0,y=v[r-1][1]||0;p+=g-y}c+=h,u+=p*h}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,Wf(t,e)}}var yP={},vP={},d$;function eMe(){return d$||(d$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(vP)),vP}var wP={},h$;function VQ(){return h$||(h$=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})(wP)),wP}var SP={},m$;function T4(){return m$||(m$=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})(SP)),SP}var _P={},NP={},f$;function tMe(){return f$||(f$=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})(NP)),NP}var p$;function M4(){return p$||(p$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tMe(),n=T4();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})(_P)),_P}var g$;function P4(){return g$||(g$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eMe(),n=VQ(),r=T4(),i=M4();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})(yP)),yP}var kP,b$;function nMe(){return b$||(b$=1,kP=P4().get),kP}var rMe=nMe();const Kf=Ml(rMe);var aMe=4;function Ah(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:aMe,n=10**e,r=Math.round(t*n)/n;return Object.is(r,-0)?0:r}function Ea(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return t.reduce((i,s,o)=>{var l=n[o-1];return typeof l=="string"?i+l+s:l!==void 0?i+Ah(l)+s:i+s},"")}var Ri=t=>t===0?0:t>0?1:-1,rc=t=>typeof t=="number"&&t!=+t,Yf=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Vt=t=>(typeof t=="number"||t instanceof Number)&&!rc(t),Cl=t=>Vt(t)||typeof t=="string",iMe=0,I0=t=>{var e=++iMe;return"".concat(t||"").concat(e)},vs=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(!Vt(e)&&typeof e!="string")return r;var s;if(Yf(e)){if(n==null)return r;var o=e.indexOf("%");s=n*parseFloat(e.slice(0,o))/100}else s=+e;return rc(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},qQ=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},r=0;r<e;r++)if(!n[String(t[r])])n[String(t[r])]=!0;else return!0;return!1};function _r(t,e,n){return Vt(t)&&Vt(e)?Ah(t+n*(e-t)):e}function GQ(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Kf(r,e))===n)}var xa=t=>t===null||typeof t>"u",Cv=t=>xa(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function no(t){return t!=null}function sm(){}var sMe=["type","size","sizeType"];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 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 y$(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){oMe(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 oMe(t,e,n){return(e=lMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lMe(t){var e=cMe(t,"string");return typeof e=="symbol"?e:e+""}function cMe(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 uMe(t,e){if(t==null)return{};var n,r,i=dMe(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 dMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var WQ={symbolCircle:A4,symbolCross:C2e,symbolDiamond:T2e,symbolSquare:M2e,symbolStar:D2e,symbolTriangle:R2e,symbolWye:L2e},hMe=Math.PI/180,mMe=t=>{var e="symbol".concat(Cv(t));return WQ[e]||A4},fMe=(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*hMe;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}},pMe=(t,e)=>{WQ["symbol".concat(Cv(t))]=e},j4=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=uMe(t,sMe),s=y$(y$({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var f=mMe(o),p=O2e().type(f).size(fMe(n,r,o)),x=p();if(x!==null)return x},{className:c,cx:u,cy:d}=s,h=rs(s);return Vt(u)&&Vt(d)&&Vt(n)?w.createElement("path",FD({},h,{className:hr("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};j4.registerSymbol=pMe;var KQ=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,E4=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(w.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{_4(i)&&(r[i]=(s=>n[i](n,s)))}),r},gMe=(t,e,n)=>r=>(t(e,n,r),null),Av=(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];_4(i)&&typeof s=="function"&&(r||(r={}),r[i]=gMe(s,e,n))}),r};function v$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function bMe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v$(Object(n),!0).forEach(function(r){xMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xMe(t,e,n){return(e=yMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yMe(t){var e=vMe(t,"string");return typeof e=="symbol"?e:e+""}function vMe(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 _a(t,e){var n=bMe({},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 tN(){return tN=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},tN.apply(null,arguments)}function w$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function wMe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w$(Object(n),!0).forEach(function(r){SMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SMe(t,e,n){return(e=_Me(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Me(t){var e=NMe(t,"string");return typeof e=="symbol"?e:e+""}function NMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var nl=32,kMe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function CMe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=nl/2,s=nl/6,o=nl/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return w.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:nl,y2:i,className:"recharts-legend-icon"})}if(c==="line")return w.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
  8068. A`).concat(s,",").concat(s,",0,1,1,").concat(2*o,",").concat(i,`
  8069. H`).concat(nl,"M").concat(2*o,",").concat(i,`
  8070. A`).concat(s,",").concat(s,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(nl/8,"h").concat(nl,"v").concat(nl*3/4,"h").concat(-nl,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=wMe({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(j4,{fill:l,cx:i,cy:i,size:nl,sizeType:"diameter",type:c})}function AMe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:o}=t,l={x:0,y:0,width:nl,height:nl},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,h)=>{var f=d.formatter||i,p=hr({"recharts-legend-item":!0,["legend-item-".concat(h)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?s:d.color,v=f?f(d.value,d,h):d.value;return w.createElement("li",tN({className:p,style:c,key:"legend-item-".concat(h)},Av(t,d,h)),w.createElement(N4,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(v," legend icon")},w.createElement(CMe,{data:d,iconType:o,inactiveColor:s})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},v))})}var TMe=t=>{var e=_a(t,kMe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var s={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return w.createElement("ul",{className:"recharts-default-legend",style:s},w.createElement(AMe,tN({},e,{payload:n})))},CP={},AP={},S$;function MMe(){return S$||(S$=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,s,n);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(AP)),AP}var TP={},_$;function PMe(){return _$||(_$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return function(...i){return n.apply(this,i.slice(0,r))}}t.ary=e})(TP)),TP}var MP={},N$;function YQ(){return N$||(N$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(MP)),MP}var PP={},jP={},EP={},k$;function jMe(){return k$||(k$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(EP)),EP}var C$;function D4(){return C$||(C$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jMe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(jP)),jP}var DP={},A$;function EMe(){return A$||(A$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(DP)),DP}var T$;function DMe(){return T$||(T$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=D4(),n=EMe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(PP)),PP}var RP={},FP={},M$;function RMe(){return M$||(M$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=P4();function n(r){return function(i){return e.get(i,r)}}t.property=n})(FP)),FP}var LP={},OP={},IP={},zP={},P$;function XQ(){return P$||(P$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(zP)),zP}var UP={},j$;function QQ(){return j$||(j$=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})(UP)),UP}var BP={},E$;function ZQ(){return E$||(E$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}t.isEqualsSameValueZero=e})(BP)),BP}var D$;function FMe(){return D$||(D$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=XQ(),n=QQ(),r=ZQ();function i(d,h,f){return typeof f!="function"?i(d,h,()=>{}):s(d,h,function p(x,v,g,y,_,N){const A=f(x,v,g,y,_,N);return A!==void 0?!!A:s(x,v,p,N)},new Map)}function s(d,h,f,p){if(h===d)return!0;switch(typeof h){case"object":return o(d,h,f,p);case"function":return Object.keys(h).length>0?s(d,{...h},f,p):r.isEqualsSameValueZero(d,h);default:return e.isObject(d)?typeof h=="string"?h==="":!0:r.isEqualsSameValueZero(d,h)}}function o(d,h,f,p){if(h==null)return!0;if(Array.isArray(h))return c(d,h,f,p);if(h instanceof Map)return l(d,h,f,p);if(h instanceof Set)return u(d,h,f,p);const x=Object.keys(h);if(d==null||n.isPrimitive(d))return x.length===0;if(x.length===0)return!0;if(p?.has(h))return p.get(h)===d;p?.set(h,d);try{for(let v=0;v<x.length;v++){const g=x[v];if(!n.isPrimitive(d)&&!(g in d)||h[g]===void 0&&d[g]!==void 0||h[g]===null&&d[g]!==null||!f(d[g],h[g],g,d,h,p))return!1}return!0}finally{p?.delete(h)}}function l(d,h,f,p){if(h.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,v]of h.entries()){const g=d.get(x);if(f(g,v,x,d,h,p)===!1)return!1}return!0}function c(d,h,f,p){if(h.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let v=0;v<h.length;v++){const g=h[v];let y=!1;for(let _=0;_<d.length;_++){if(x.has(_))continue;const N=d[_];let A=!1;if(f(N,g,v,d,h,p)&&(A=!0),A){x.add(_),y=!0;break}}if(!y)return!1}return!0}function u(d,h,f,p){return h.size===0?!0:d instanceof Set?c([...d],[...h],f,p):!1}t.isMatchWith=i,t.isSetMatch=u})(IP)),IP}var R$;function JQ(){return R$||(R$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=FMe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(OP)),OP}var HP={},$P={},VP={},F$;function LMe(){return F$||(F$=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})(VP)),VP}var qP={},L$;function R4(){return L$||(L$=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})(qP)),qP}var GP={},O$;function eZ(){return O$||(O$=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]",f="[object ArrayBuffer]",p="[object Object]",x="[object Error]",v="[object DataView]",g="[object Uint8Array]",y="[object Uint8ClampedArray]",_="[object Uint16Array]",N="[object Uint32Array]",A="[object BigUint64Array]",C="[object Int8Array]",j="[object Int16Array]",k="[object Int32Array]",R="[object BigInt64Array]",M="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=f,t.arrayTag=d,t.bigInt64ArrayTag=R,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=v,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=M,t.float64ArrayTag=D,t.functionTag=h,t.int16ArrayTag=j,t.int32ArrayTag=k,t.int8ArrayTag=C,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=_,t.uint32ArrayTag=N,t.uint8ArrayTag=g,t.uint8ClampedArrayTag=y})(GP)),GP}var WP={},I$;function OMe(){return I$||(I$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(WP)),WP}var z$;function tZ(){return z$||(z$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LMe(),n=R4(),r=eZ(),i=QQ(),s=OMe();function o(d,h){return l(d,void 0,d,new Map,h)}function l(d,h,f,p=new Map,x=void 0){const v=x?.(d,h,f,p);if(v!==void 0)return v;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const g=new Array(d.length);p.set(d,g);for(let y=0;y<d.length;y++)g[y]=l(d[y],y,f,p,x);return Object.hasOwn(d,"index")&&(g.index=d.index),Object.hasOwn(d,"input")&&(g.input=d.input),g}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const g=new RegExp(d.source,d.flags);return g.lastIndex=d.lastIndex,g}if(d instanceof Map){const g=new Map;p.set(d,g);for(const[y,_]of d)g.set(y,l(_,y,f,p,x));return g}if(d instanceof Set){const g=new Set;p.set(d,g);for(const y of d)g.add(l(y,void 0,f,p,x));return g}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(s.isTypedArray(d)){const g=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,g);for(let y=0;y<d.length;y++)g[y]=l(d[y],y,f,p,x);return g}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const g=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,g),c(g,d,f,p,x),g}if(typeof File<"u"&&d instanceof File){const g=new File([d],d.name,{type:d.type});return p.set(d,g),c(g,d,f,p,x),g}if(typeof Blob<"u"&&d instanceof Blob){const g=new Blob([d],{type:d.type});return p.set(d,g),c(g,d,f,p,x),g}if(d instanceof Error){const g=new d.constructor;return p.set(d,g),g.message=d.message,g.name=d.name,g.stack=d.stack,g.cause=d.cause,c(g,d,f,p,x),g}if(d instanceof Boolean){const g=new Boolean(d.valueOf());return p.set(d,g),c(g,d,f,p,x),g}if(d instanceof Number){const g=new Number(d.valueOf());return p.set(d,g),c(g,d,f,p,x),g}if(d instanceof String){const g=new String(d.valueOf());return p.set(d,g),c(g,d,f,p,x),g}if(typeof d=="object"&&u(d)){const g=Object.create(Object.getPrototypeOf(d));return p.set(d,g),c(g,d,f,p,x),g}return d}function c(d,h,f=d,p,x){const v=[...Object.keys(h),...e.getSymbols(h)];for(let g=0;g<v.length;g++){const y=v[g],_=Object.getOwnPropertyDescriptor(d,y);(_==null||_.writable)&&(d[y]=l(h[y],y,f,p,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})($P)),$P}var U$;function IMe(){return U$||(U$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tZ();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(HP)),HP}var B$;function zMe(){return B$||(B$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=JQ(),n=IMe();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(LP)),LP}var KP={},YP={},XP={},H$;function UMe(){return H$||(H$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tZ(),n=R4(),r=eZ();function i(s,o){return e.cloneDeepWith(s,(l,c,u,d)=>{const h=o?.(l,c,u,d);if(h!==void 0)return h;if(typeof s=="object"){if(n.getTag(s)===r.objectTag&&typeof s.constructor!="function"){const f={};return d.set(s,f),e.copyProperties(f,s,u,d),f}switch(Object.prototype.toString.call(s)){case r.numberTag:case r.stringTag:case r.booleanTag:{const f=new s.constructor(s?.valueOf());return e.copyProperties(f,s),f}case r.argumentsTag:{const f={};return e.copyProperties(f,s),f.length=s.length,f[Symbol.iterator]=s[Symbol.iterator],f}default:return}}})}t.cloneDeepWith=i})(XP)),XP}var $$;function BMe(){return $$||($$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UMe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(YP)),YP}var QP={},ZP={},V$;function nZ(){return V$||(V$=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})(ZP)),ZP}var JP={},q$;function HMe(){return q$||(q$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=R4();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(JP)),JP}var G$;function $Me(){return G$||(G$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VQ(),n=nZ(),r=HMe(),i=M4();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})(QP)),QP}var W$;function VMe(){return W$||(W$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=JQ(),n=T4(),r=BMe(),i=P4(),s=$Me();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})(KP)),KP}var K$;function qMe(){return K$||(K$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YQ(),n=RMe(),r=zMe(),i=VMe();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})(RP)),RP}var Y$;function GMe(){return Y$||(Y$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=MMe(),n=PMe(),r=YQ(),i=DMe(),s=qMe();function o(l,c=r.identity){return i.isArrayLikeObject(l)?e.uniqBy(Array.from(l),n.ary(s.iteratee(c),1)):[]}t.uniqBy=o})(CP)),CP}var ej,X$;function WMe(){return X$||(X$=1,ej=GMe().uniqBy),ej}var KMe=WMe();const Q$=Ml(KMe);function rZ(t,e,n){return e===!0?Q$(t,n):typeof e=="function"?Q$(t,e):t}var tj={exports:{}},nj={};var Z$;function YMe(){if(Z$)return nj;Z$=1;var t=sp(),e=GK();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 nj.useSyncExternalStoreWithSelector=function(u,d,h,f,p){var x=s(null);if(x.current===null){var v={hasValue:!1,value:null};x.current=v}else v=x.current;x=l(function(){function y(j){if(!_){if(_=!0,N=j,j=f(j),p!==void 0&&v.hasValue){var k=v.value;if(p(k,j))return A=k}return A=j}if(k=A,r(N,j))return k;var R=f(j);return p!==void 0&&p(k,R)?(N=j,k):(N=j,A=R)}var _=!1,N,A,C=h===void 0?null:h;return[function(){return y(d())},C===null?void 0:function(){return y(C())}]},[d,h,f,p]);var g=i(u,x[0],x[1]);return o(function(){v.hasValue=!0,v.value=g},[g]),c(g),g},nj}var J$;function XMe(){return J$||(J$=1,tj.exports=YMe()),tj.exports}var aZ=XMe(),F4=w.createContext(null),QMe=t=>t,Jr=()=>{var t=w.useContext(F4);return t?t.store.dispatch:QMe},l1=()=>{},ZMe=()=>l1,JMe=(t,e)=>t===e;function Gt(t){var e=w.useContext(F4),n=w.useMemo(()=>e?r=>{if(r!=null)return t(r)}:l1,[e,t]);return aZ.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:ZMe,e?e.store.getState:l1,e?e.store.getState:l1,n,JMe)}function ePe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function tPe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function nPe(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 e7=t=>Array.isArray(t)?t:[t];function rPe(t){const e=Array.isArray(t[0])?t[0]:t;return nPe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function aPe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var iPe=class{constructor(t){this.value=t}deref(){return this.value}},sPe=typeof WeakRef<"u"?WeakRef:iPe,oPe=0,t7=1;function m_(){return{s:oPe,v:void 0,o:null,p:null}}function iZ(t,e={}){let n=m_();const{resultEqualityCheck:r}=e;let i,s=0;function o(){let l=n;const{length:c}=arguments;for(let h=0,f=c;h<f;h++){const p=arguments[h];if(typeof p=="function"||typeof p=="object"&&p!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const v=x.get(p);v===void 0?(l=m_(),x.set(p,l)):l=v}else{let x=l.p;x===null&&(l.p=x=new Map);const v=x.get(p);v===void 0?(l=m_(),x.set(p,l)):l=v}}const u=l;let d;if(l.s===t7)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 sPe(d):d}return u.s=t7,u.v=d,d}return o.clearCache=()=>{n=m_(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function lPe(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()),ePe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:h,memoizeOptions:f=[],argsMemoize:p=iZ,argsMemoizeOptions:x=[]}=d,v=e7(f),g=e7(x),y=rPe(i),_=h(function(){return s++,u.apply(null,arguments)},...v),N=p(function(){o++;const C=aPe(y,arguments);return l=_.apply(null,C),l},...g);return Object.assign(N,{resultFunc:u,memoizedResultFunc:_,dependencies:y,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:h,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var mt=lPe(iZ),cPe=Object.assign((t,e=mt)=>{tPe(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:()=>cPe}),rj={},aj={},ij={},n7;function uPe(){return n7||(n7=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})(ij)),ij}var sj={},oj={},r7;function sZ(){return r7||(r7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(oj)),oj}var a7;function dPe(){return a7||(a7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sZ(),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})(sj)),sj}var i7;function hPe(){return i7||(i7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uPe(),n=dPe(),r=M4();function i(s,o,l,c){if(s==null)return[];l=c?void 0:l,Array.isArray(s)||(s=Object.values(s)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(p=>String(p));const u=(p,x)=>{let v=p;for(let g=0;g<x.length&&v!=null;++g)v=v[x[g]];return v},d=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:u(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?u(x,p):typeof x=="object"?x[p]:x,h=o.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return s.map(p=>({original:p,criteria:h.map(x=>d(x,p))})).slice().sort((p,x)=>{for(let v=0;v<h.length;v++){const g=e.compareValues(p.criteria[v],x.criteria[v],l[v]);if(g!==0)return g}return 0}).map(p=>p.original)}t.orderBy=i})(aj)),aj}var lj={},s7;function mPe(){return s7||(s7=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})(lj)),lj}var cj={},o7;function oZ(){return o7||(o7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nZ(),n=D4(),r=XQ(),i=ZQ();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.isEqualsSameValueZero(c[l],o):!1}t.isIterateeCall=s})(cj)),cj}var l7;function fPe(){return l7||(l7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hPe(),n=mPe(),r=oZ();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})(rj)),rj}var uj,c7;function pPe(){return c7||(c7=1,uj=fPe().sortBy),uj}var gPe=pPe();const kC=Ml(gPe);var lZ=t=>t.legend.settings,bPe=t=>t.legend.size,xPe=t=>t.legend.payload,yPe=mt([xPe,lZ],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?kC(r,n):r});function vPe(){return Gt(yPe)}var f_=1;function cZ(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=w.useState({height:0,left:0,top:0,width:0}),r=w.useCallback(i=>{if(i!=null){var s=i.getBoundingClientRect(),o={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(o.height-e.height)>f_||Math.abs(o.left-e.left)>f_||Math.abs(o.top-e.top)>f_||Math.abs(o.width-e.width)>f_)&&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 Ki(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 wPe=typeof Symbol=="function"&&Symbol.observable||"@@observable",u7=wPe,dj=()=>Math.random().toString(36).substring(7).split("").join("."),SPe={INIT:`@@redux/INIT${dj()}`,REPLACE:`@@redux/REPLACE${dj()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${dj()}`},nN=SPe;function L4(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 uZ(t,e,n){if(typeof t!="function")throw new Error(Ki(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Ki(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Ki(1));return n(uZ)(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((g,y)=>{o.set(y,g)}))}function d(){if(c)throw new Error(Ki(3));return i}function h(g){if(typeof g!="function")throw new Error(Ki(4));if(c)throw new Error(Ki(5));let y=!0;u();const _=l++;return o.set(_,g),function(){if(y){if(c)throw new Error(Ki(6));y=!1,u(),o.delete(_),s=null}}}function f(g){if(!L4(g))throw new Error(Ki(7));if(typeof g.type>"u")throw new Error(Ki(8));if(typeof g.type!="string")throw new Error(Ki(17));if(c)throw new Error(Ki(9));try{c=!0,i=r(i,g)}finally{c=!1}return(s=o).forEach(_=>{_()}),g}function p(g){if(typeof g!="function")throw new Error(Ki(10));r=g,f({type:nN.REPLACE})}function x(){const g=h;return{subscribe(y){if(typeof y!="object"||y===null)throw new Error(Ki(11));function _(){const A=y;A.next&&A.next(d())}return _(),{unsubscribe:g(_)}},[u7](){return this}}}return f({type:nN.INIT}),{dispatch:f,subscribe:h,getState:d,replaceReducer:p,[u7]:x}}function _Pe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:nN.INIT})>"u")throw new Error(Ki(12));if(typeof n(void 0,{type:nN.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Ki(13))})}function dZ(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{_Pe(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],f=n[h],p=o[h],x=f(p,l);if(typeof x>"u")throw l&&l.type,new Error(Ki(14));u[h]=x,c=c||x!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function rN(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function NPe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Ki(15))};const o={getState:i.getState,dispatch:(c,...u)=>s(c,...u)},l=t.map(c=>c(o));return s=rN(...l)(i.dispatch),{...i,dispatch:s}}}function hZ(t){return L4(t)&&"type"in t&&typeof t.type=="string"}var mZ=Symbol.for("immer-nothing"),d7=Symbol.for("immer-draftable"),zs=Symbol.for("immer-state");function ql(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var jo=Object,jb=jo.getPrototypeOf,aN="constructor",CC="prototype",LD="configurable",iN="enumerable",c1="writable",z0="value",cd=t=>!!t&&!!t[zs];function ac(t){return t?fZ(t)||TC(t)||!!t[d7]||!!t[aN]?.[d7]||MC(t)||PC(t):!1}var kPe=jo[CC][aN].toString(),h7=new WeakMap;function fZ(t){if(!t||!O4(t))return!1;const e=jb(t);if(e===null||e===jo[CC])return!0;const n=jo.hasOwnProperty.call(e,aN)&&e[aN];if(n===Object)return!0;if(!Bg(n))return!1;let r=h7.get(n);return r===void 0&&(r=Function.toString.call(n),h7.set(n,r)),r===kPe}function AC(t,e,n=!0){Tv(t)===0?(n?Reflect.ownKeys(t):jo.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Tv(t){const e=t[zs];return e?e.type_:TC(t)?1:MC(t)?2:PC(t)?3:0}var m7=(t,e,n=Tv(t))=>n===2?t.has(e):jo[CC].hasOwnProperty.call(t,e),OD=(t,e,n=Tv(t))=>n===2?t.get(e):t[e],sN=(t,e,n,r=Tv(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function CPe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var TC=Array.isArray,MC=t=>t instanceof Map,PC=t=>t instanceof Set,O4=t=>typeof t=="object",Bg=t=>typeof t=="function",hj=t=>typeof t=="boolean";function APe(t){const e=+t;return Number.isInteger(e)&&String(e)===t}var Fu=t=>t.copy_||t.base_,I4=t=>t.modified_?t.copy_:t.base_;function ID(t,e){if(MC(t))return new Map(t);if(PC(t))return new Set(t);if(TC(t))return Array[CC].slice.call(t);const n=fZ(t);if(e===!0||e==="class_only"&&!n){const r=jo.getOwnPropertyDescriptors(t);delete r[zs];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l[c1]===!1&&(l[c1]=!0,l[LD]=!0),(l.get||l.set)&&(r[o]={[LD]:!0,[c1]:!0,[iN]:l[iN],[z0]:t[o]})}return jo.create(jb(t),r)}else{const r=jb(t);if(r!==null&&n)return{...t};const i=jo.create(r);return jo.assign(i,t)}}function z4(t,e=!1){return jC(t)||cd(t)||!ac(t)||(Tv(t)>1&&jo.defineProperties(t,{set:p_,add:p_,clear:p_,delete:p_}),jo.freeze(t),e&&AC(t,(n,r)=>{z4(r,!0)},!1)),t}function TPe(){ql(2)}var p_={[z0]:TPe};function jC(t){return t===null||!O4(t)?!0:jo.isFrozen(t)}var oN="MapSet",zD="Patches",f7="ArrayMethods",pZ={};function Xf(t){const e=pZ[t];return e||ql(0,t),e}var p7=t=>!!pZ[t],U0,gZ=()=>U0,MPe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:p7(oN)?Xf(oN):void 0,arrayMethodsPlugin_:p7(f7)?Xf(f7):void 0});function g7(t,e){e&&(t.patchPlugin_=Xf(zD),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function UD(t){BD(t),t.drafts_.forEach(PPe),t.drafts_=null}function BD(t){t===U0&&(U0=t.parent_)}var b7=t=>U0=MPe(U0,t);function PPe(t){const e=t[zs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function x7(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[zs].modified_&&(UD(e),ql(4)),ac(t)&&(t=y7(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[zs].base_,t,e)}else t=y7(e,n);return jPe(e,t,!0),UD(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==mZ?t:void 0}function y7(t,e){if(jC(e))return e;const n=e[zs];if(!n)return lN(e,t.handledSet_,t);if(!EC(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);yZ(n,t)}return n.copy_}function jPe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&z4(e,n)}function bZ(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var EC=(t,e)=>t.scope_===e,EPe=[];function xZ(t,e,n,r){const i=Fu(t),s=t.type_;if(r!==void 0&&OD(i,r,s)===e){sN(i,r,n,s);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;AC(i,(c,u)=>{if(cd(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??EPe;for(const l of o)sN(i,l,n,s)}function DPe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!EC(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const o=I4(s);xZ(t,s.draft_??s,o,n),yZ(s,i)})}function yZ(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(t.assigned_?.size??0)>0)){const{patchPlugin_:r}=e;if(r){const i=r.getPath(t);i&&r.generatePatches_(t,i,e)}bZ(t)}}function RPe(t,e,n){const{scope_:r}=t;if(cd(n)){const i=n[zs];EC(i,r)&&i.callbacks_.push(function(){u1(t);const o=I4(i);xZ(t,n,o,e)})}else ac(n)&&t.callbacks_.push(function(){const s=Fu(t);t.type_===3?s.has(n)&&lN(n,r.handledSet_,r):OD(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&lN(OD(t.copy_,e,t.type_),r.handledSet_,r)})}function lN(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||cd(t)||e.has(t)||!ac(t)||jC(t)||(e.add(t),AC(t,(r,i)=>{if(cd(i)){const s=i[zs];if(EC(s,n)){const o=I4(s);sN(t,r,o,t.type_),bZ(s)}}else ac(i)&&lN(i,e,n)})),t}function FPe(t,e){const n=TC(t),r={type_:n?1:0,scope_:e?e.scope_:gZ(),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=cN;n&&(i=[r],s=B0);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,[l,r]}var cN={get(t,e){if(e===zs)return t;let n=t.scope_.arrayMethodsPlugin_;const r=t.type_===1&&typeof e=="string";if(r&&n?.isArrayOperationMethod(e))return n.createMethodInterceptor(t,e);const i=Fu(t);if(!m7(i,e,t.type_))return LPe(t,i,e);const s=i[e];if(t.finalized_||!ac(s)||r&&t.operationMethod&&n?.isMutatingArrayMethod(t.operationMethod)&&APe(e))return s;if(s===mj(t.base_,e)){u1(t);const o=t.type_===1?+e:e,l=$D(t.scope_,s,t,o);return t.copy_[o]=l}return s},has(t,e){return e in Fu(t)},ownKeys(t){return Reflect.ownKeys(Fu(t))},set(t,e,n){const r=vZ(Fu(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=mj(Fu(t),e),s=i?.[zs];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(CPe(n,i)&&(n!==void 0||m7(t.base_,e,t.type_)))return!0;u1(t),HD(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),RPe(t,e,n)),!0},deleteProperty(t,e){return u1(t),mj(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),HD(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Fu(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[c1]:!0,[LD]:t.type_!==1||e!=="length",[iN]:r[iN],[z0]:n[e]}},defineProperty(){ql(11)},getPrototypeOf(t){return jb(t.base_)},setPrototypeOf(){ql(12)}},B0={};for(let t in cN){let e=cN[t];B0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}B0.deleteProperty=function(t,e){return B0.set.call(this,t,e,void 0)};B0.set=function(t,e,n){return cN.set.call(this,t[0],e,n,t[0])};function mj(t,e){const n=t[zs];return(n?Fu(n):t)[e]}function LPe(t,e,n){const r=vZ(e,n);return r?z0 in r?r[z0]:r.get?.call(t.draft_):void 0}function vZ(t,e){if(!(e in t))return;let n=jb(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=jb(n)}}function HD(t){t.modified_||(t.modified_=!0,t.parent_&&HD(t.parent_))}function u1(t){t.copy_||(t.assigned_=new Map,t.copy_=ID(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var OPe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Bg(n)&&!Bg(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,h=>r.call(this,h,...d))}}Bg(r)||ql(6),i!==void 0&&!Bg(i)&&ql(7);let s;if(ac(n)){const o=b7(this),l=$D(o,n,void 0);let c=!0;try{s=r(l),c=!1}finally{c?UD(o):BD(o)}return g7(o,i),x7(s,o)}else if(!n||!O4(n)){if(s=r(n),s===void 0&&(s=n),s===mZ&&(s=void 0),this.autoFreeze_&&z4(s,!0),i){const o=[],l=[];Xf(zD).generateReplacementPatches_(n,s,{patches_:o,inversePatches_:l}),i(o,l)}return s}else ql(1,n)},this.produceWithPatches=(n,r)=>{if(Bg(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]},hj(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),hj(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),hj(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ac(e)||ql(8),cd(e)&&(e=Zl(e));const n=b7(this),r=$D(n,e,void 0);return r[zs].isManual_=!0,BD(n),r}finishDraft(e,n){const r=e&&e[zs];(!r||!r.isManual_)&&ql(9);const{scope_:i}=r;return g7(i,n),x7(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=Xf(zD).applyPatches_;return cd(e)?i(e,n):this.produce(e,s=>i(s,n))}};function $D(t,e,n,r){const[i,s]=MC(e)?Xf(oN).proxyMap_(e,n):PC(e)?Xf(oN).proxySet_(e,n):FPe(e,n);return(n?.scope_??gZ()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?DPe(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 Zl(t){return cd(t)||ql(10,t),wZ(t)}function wZ(t){if(!ac(t)||jC(t))return t;const e=t[zs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=ID(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=ID(t,!0);return AC(n,(i,s)=>{sN(n,i,wZ(s))},r),e&&(e.finalized_=!1),n}var IPe=new OPe,SZ=IPe.produce;function _Z(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var zPe=_Z(),UPe=_Z,BPe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?rN:rN.apply(null,arguments)};function Al(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Fo(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=>hZ(r)&&r.type===t,n}var NZ=class zy extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,zy.prototype)}static get[Symbol.species](){return zy}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new zy(...e[0].concat(this)):new zy(...e.concat(this))}};function v7(t){return ac(t)?SZ(t,()=>{}):t}function g_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function HPe(t){return typeof t=="boolean"}var $Pe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let o=new NZ;return n&&(HPe(n)?o.push(zPe):o.push(UPe(n.extraArgument))),o},kZ="RTK_autoBatch",fa=()=>t=>({payload:t,meta:{[kZ]:!0}}),w7=t=>e=>{setTimeout(e,t)},CZ=(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:w7(10):t.type==="callback"?t.queueNotification:w7(t.timeout),u=()=>{o=!1,s&&(s=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const h=()=>i&&d(),f=r.subscribe(h);return l.add(d),()=>{f(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[kZ],s=!i,s&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},VPe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new NZ(t);return r&&i.push(CZ(typeof r=="object"?r:void 0)),i};function qPe(t){const e=$Pe(),{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(L4(n))l=dZ(n);else throw new Error(Fo(1));let c;typeof r=="function"?c=r(e):c=e();let u=rN;i&&(u=BPe({trace:!1,...typeof i=="object"&&i}));const d=NPe(...c),h=VPe(d);let f=typeof o=="function"?o(h):h();const p=u(...f);return uZ(l,s,p)}function AZ(t){const e={},n=[];let r;const i={addCase(s,o){const l=typeof s=="string"?s:s.type;if(!l)throw new Error(Fo(28));if(l in e)throw new Error(Fo(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 GPe(t){return typeof t=="function"}function WPe(t,e){let[n,r,i]=AZ(e),s;if(GPe(t))s=()=>v7(t());else{const l=v7(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(cd(d)){const p=h(d,c);return p===void 0?d:p}else{if(ac(d))return SZ(d,f=>h(f,c));{const f=h(d,c);if(f===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return f}}return d},l)}return o.getInitialState=s,o}var KPe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",YPe=(t=21)=>{let e="",n=t;for(;n--;)e+=KPe[Math.random()*64|0];return e},XPe=Symbol.for("rtk-slice-createasyncthunk");function QPe(t,e){return`${t}/${e}`}function ZPe({creators:t}={}){const e=t?.asyncThunk?.[XPe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(Fo(11));const o=(typeof r.reducers=="function"?r.reducers(eje()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(N,A){const C=typeof N=="string"?N:N.type;if(!C)throw new Error(Fo(12));if(C in c.sliceCaseReducersByType)throw new Error(Fo(13));return c.sliceCaseReducersByType[C]=A,u},addMatcher(N,A){return c.sliceMatchers.push({matcher:N,reducer:A}),u},exposeAction(N,A){return c.actionCreators[N]=A,u},exposeCaseReducer(N,A){return c.sliceCaseReducersByName[N]=A,u}};l.forEach(N=>{const A=o[N],C={reducerName:N,type:QPe(i,N),createNotation:typeof r.reducers=="function"};nje(A)?aje(C,A,u,e):tje(C,A,u)});function d(){const[N={},A=[],C=void 0]=typeof r.extraReducers=="function"?AZ(r.extraReducers):[r.extraReducers],j={...N,...c.sliceCaseReducersByType};return WPe(r.initialState,k=>{for(let R in j)k.addCase(R,j[R]);for(let R of c.sliceMatchers)k.addMatcher(R.matcher,R.reducer);for(let R of A)k.addMatcher(R.matcher,R.reducer);C&&k.addDefaultCase(C)})}const h=N=>N,f=new Map,p=new WeakMap;let x;function v(N,A){return x||(x=d()),x(N,A)}function g(){return x||(x=d()),x.getInitialState()}function y(N,A=!1){function C(k){let R=k[N];return typeof R>"u"&&A&&(R=g_(p,C,g)),R}function j(k=h){const R=g_(f,A,()=>new WeakMap);return g_(R,k,()=>{const M={};for(const[D,G]of Object.entries(r.selectors??{}))M[D]=JPe(G,k,()=>g_(p,k,g),A);return M})}return{reducerPath:N,getSelectors:j,get selectors(){return j(C)},selectSlice:C}}const _={name:i,reducer:v,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:g,...y(s),injectInto(N,{reducerPath:A,...C}={}){const j=A??s;return N.inject({reducerPath:j,reducer:v},C),{..._,...y(j,!0)}}};return _}}function JPe(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 ho=ZPe();function eje(){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 tje({type:t,reducerName:e,createNotation:n},r,i){let s,o;if("reducer"in r){if(n&&!rje(r))throw new Error(Fo(17));s=r.reducer,o=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,o?Al(t,o):Al(t))}function nje(t){return t._reducerDefinitionType==="asyncThunk"}function rje(t){return t._reducerDefinitionType==="reducerWithPrepare"}function aje({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Fo(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||b_,pending:l||b_,rejected:c||b_,settled:u||b_})}function b_(){}var ije="task",TZ="listener",MZ="completed",U4="cancelled",sje=`task-${U4}`,oje=`task-${MZ}`,VD=`${TZ}-${U4}`,lje=`${TZ}-${MZ}`,DC=class{constructor(t){this.code=t,this.message=`${ije} ${U4} (reason: ${t})`}name="TaskAbortError";message},B4=(t,e)=>{if(typeof t!="function")throw new TypeError(Fo(32))},uN=()=>{},PZ=(t,e=uN)=>(t.catch(e),t),jZ=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),_f=t=>{if(t.aborted)throw new DC(t.reason)};function EZ(t,e){let n=uN;return new Promise((r,i)=>{const s=()=>i(new DC(t.reason));if(t.aborted){s();return}n=jZ(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=uN})}var cje=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof DC?"cancelled":"rejected",error:n}}finally{e?.()}},dN=t=>e=>PZ(EZ(t,e).then(n=>(_f(t),n))),DZ=t=>{const e=dN(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:ub}=Object,S7={},RC="listenerMiddleware",uje=(t,e)=>{const n=r=>jZ(t,()=>r.abort(t.reason));return(r,i)=>{B4(r);const s=new AbortController;n(s);const o=cje(async()=>{_f(t),_f(s.signal);const l=await r({pause:dN(s.signal),delay:DZ(s.signal),signal:s.signal});return _f(s.signal),l},()=>s.abort(oje));return i?.autoJoin&&e.push(o.catch(uN)),{result:dN(t)(o),cancel(){s.abort(sje)}}}},dje=(t,e)=>{const n=async(r,i)=>{_f(e);let s=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(h,f)=>{f.unsubscribe(),c([h,f.getState(),f.getOriginalState()])}});s=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await EZ(e,Promise.race(l));return _f(e),c}finally{s()}};return(r,i)=>PZ(n(r,i))},RZ=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=Al(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Fo(21));return B4(s),{predicate:i,type:e,effect:s}},FZ=ub(t=>{const{type:e,predicate:n,effect:r}=RZ(t);return{id:YPe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Fo(22))}}},{withTypes:()=>FZ}),_7=(t,e)=>{const{type:n,effect:r,predicate:i}=RZ(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},qD=t=>{t.pending.forEach(e=>{e.abort(VD)})},hje=(t,e)=>()=>{for(const n of e.keys())qD(n);t.clear()},N7=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},LZ=ub(Al(`${RC}/add`),{withTypes:()=>LZ}),mje=Al(`${RC}/removeAll`),OZ=ub(Al(`${RC}/remove`),{withTypes:()=>OZ}),fje=(...t)=>{console.error(`${RC}/error`,...t)},Mv=(t={})=>{const e=new Map,n=new Map,r=p=>{const x=n.get(p)??0;n.set(p,x+1)},i=p=>{const x=n.get(p)??1;x===1?n.delete(p):n.set(p,x-1)},{extra:s,onError:o=fje}=t;B4(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&qD(p)}),c=p=>{const x=_7(e,p)??FZ(p);return l(x)};ub(c,{withTypes:()=>c});const u=p=>{const x=_7(e,p);return x&&(x.unsubscribe(),p.cancelActive&&qD(x)),!!x};ub(u,{withTypes:()=>u});const d=async(p,x,v,g)=>{const y=new AbortController,_=dje(c,y.signal),N=[];try{p.pending.add(y),r(p),await Promise.resolve(p.effect(x,ub({},v,{getOriginalState:g,condition:(A,C)=>_(A,C).then(Boolean),take:_,delay:DZ(y.signal),pause:dN(y.signal),extra:s,signal:y.signal,fork:uje(y.signal,N),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((A,C,j)=>{A!==y&&(A.abort(VD),j.delete(A))})},cancel:()=>{y.abort(VD),p.pending.delete(y)},throwIfCancelled:()=>{_f(y.signal)}})))}catch(A){A instanceof DC||N7(o,A,{raisedBy:"effect"})}finally{await Promise.all(N),y.abort(lje),i(p),p.pending.delete(y)}},h=hje(e,n);return{middleware:p=>x=>v=>{if(!hZ(v))return x(v);if(LZ.match(v))return c(v.payload);if(mje.match(v)){h();return}if(OZ.match(v))return u(v.payload);let g=p.getState();const y=()=>{if(g===S7)throw new Error(Fo(23));return g};let _;try{if(_=x(v),e.size>0){const N=p.getState(),A=Array.from(e.values());for(const C of A){let j=!1;try{j=C.predicate(v,N,g)}catch(k){j=!1,N7(o,k,{raisedBy:"predicate"})}j&&d(C,v,p,y)}}}finally{g=S7}return _},startListening:c,stopListening:u,clearListeners:h}};function Fo(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 pje={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},IZ=ho({name:"chartLayout",initialState:pje,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:gje,setLayout:bje,setChartSize:xje,setScale:yje}=IZ.actions,vje=IZ.reducer;function zZ(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function Pn(t){return Number.isFinite(t)}function Uc(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function k7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k7(Object(n),!0).forEach(function(r){wje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wje(t,e,n){return(e=Sje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sje(t){var e=_je(t,"string");return typeof e=="symbol"?e:e+""}function _je(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 Nr(t,e,n){return xa(t)||xa(e)?n:Cl(e)?Kf(t,e,n):typeof e=="function"?e(t):n}var Nje=(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"&&Vt(t[s]))return Xg(Xg({},t),{},{[s]:t[s]+(r||0)});if((l==="horizontal"||l==="vertical"&&s==="center")&&o!=="middle"&&Vt(t[o]))return Xg(Xg({},t),{},{[o]:t[o]+(i||0)})}return t},lc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",UZ=(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},BZ=(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:f,axisType:p}=t;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,v=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(v=p==="angleAxis"&&s&&s.length>=2?Ri(s[0]-s[1])*2*v:v,h||f){var g=(h||f||[]).map((y,_)=>{var N=r?r.indexOf(y):y,A=o.map(N);return Pn(A)?{coordinate:A+v,value:y,offset:v,index:_}:null}).filter(no);return g}return c&&u?u.map((y,_)=>{var N=o.map(y);return Pn(N)?{coordinate:N+v,value:y,index:_,offset:v}:null}).filter(no):o.ticks&&d!=null?o.ticks(d).map((y,_)=>{var N=o.map(y);return Pn(N)?{coordinate:N+v,value:y,index:_,offset:v}:null}).filter(no):o.domain().map((y,_)=>{var N=o.map(y);return Pn(N)?{coordinate:N+v,value:r?r[y]:y,index:_,offset:v}:null}).filter(no)},kje=(t,e)=>{if(!e||e.length!==2||!Vt(e[0])||!Vt(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(!Vt(t[0])||t[0]<n)&&(i[0]=n),(!Vt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Cje=t=>{var e,n=t.length;if(!(n<=0)){var r=(e=t[0])===null||e===void 0?void 0:e.length;if(!(r==null||r<=0))for(var i=0;i<r;++i)for(var s=0,o=0,l=0;l<n;++l){var c=t[l],u=c?.[i];if(u!=null){var d=u[1],h=u[0],f=rc(d)?h:d;f>=0?(u[0]=s,s+=f,u[1]=s):(u[0]=o,o+=f,u[1]=o)}}}},Aje=t=>{var e,n=t.length;if(!(n<=0)){var r=(e=t[0])===null||e===void 0?void 0:e.length;if(!(r==null||r<=0))for(var i=0;i<r;++i)for(var s=0,o=0;o<n;++o){var l=t[o],c=l?.[i];if(c!=null){var u=rc(c[1])?c[0]:c[1];u>=0?(c[0]=s,s+=u,c[1]=s):(c[0]=0,c[1]=0)}}}},Tje={sign:Cje,expand:Q2e,none:Wf,silhouette:Z2e,wiggle:J2e,positive:Aje},Mje=(t,e,n)=>{var r,i=(r=Tje[n])!==null&&r!==void 0?r:Wf,s=X2e().keys(e).value((l,c)=>Number(Nr(l,c,0))).order(RD).offset(i),o=s(t);return o.forEach((l,c)=>{l.forEach((u,d)=>{var h=Nr(t[d],e[c],0);Array.isArray(h)&&h.length===2&&Vt(h[0])&&Vt(h[1])&&(u[0]=h[0],u[1]=h[1])})}),o};function HZ(t){return t==null?void 0:String(t)}function hN(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!xa(i[e.dataKey])){var l=GQ(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n!=null&&n[s]?n[s].coordinate+r/2:null}var c=Nr(i,xa(o)?e.dataKey:o),u=e.scale.map(c);return Vt(u)?u:null}var C7=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=Nr(s,e.dataKey,e.scale.domain()[o]);if(xa(l))return null;var c=e.scale.map(l);return Vt(c)?c-i/2+r:null},Pje=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]},jje=t=>{var e=t.flat(2).filter(Vt);return[Math.min(...e),Math.max(...e)]},Eje=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Dje=(t,e,n)=>{if(t!=null)return Eje(Object.keys(t).reduce((r,i)=>{var s=t[i];if(!s)return r;var{stackedData:o}=s,l=o.reduce((c,u)=>{var d=zZ(u,e,n),h=jje(d);return!Pn(h[0])||!Pn(h[1])?c:[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]))},A7=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,T7=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,tm=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=kC(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 M7(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return Xg(Xg({},e),{},{dataKey:n,payload:r,value:i,name:s})}function om(t,e){if(t)return String(t);if(typeof e=="string")return e}var Rje=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Fje=(t,e)=>e==="centric"?t.angle:t.radius,bd=t=>t.layout.width,xd=t=>t.layout.height,Lje=t=>t.layout.scale,$Z=t=>t.layout.margin,FC=mt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),LC=mt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),VZ="data-recharts-item-index",qZ="data-recharts-item-id",Pv=60;function P7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function x_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P7(Object(n),!0).forEach(function(r){Oje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Oje(t,e,n){return(e=Ije(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ije(t){var e=zje(t,"string");return typeof e=="symbol"?e:e+""}function zje(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Uje=t=>t.brush.height;function Bje(t){var e=LC(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Pv;return n+i}return n},0)}function Hje(t){var e=LC(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Pv;return n+i}return n},0)}function $je(t){var e=FC(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Vje(t){var e=FC(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var vi=mt([bd,xd,$Z,Uje,Bje,Hje,$je,Vje,lZ,bPe],(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},f=x_(x_({},h),d),p=f.bottom;f.bottom+=r,f=Nje(f,c,u);var x=t-f.left-f.right,v=e-f.top-f.bottom;return x_(x_({brushBottom:p},f),{},{width:Math.max(x,0),height:Math.max(v,0)})}),qje=mt(vi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),H4=mt(bd,xd,(t,e)=>({x:0,y:0,width:t,height:e})),Gje=w.createContext(null),wi=()=>w.useContext(Gje)!=null,OC=t=>t.brush,IC=mt([OC,vi,$Z],(t,e,n)=>({height:t.height,x:Vt(t.x)?t.x:e.left,y:Vt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Vt(t.width)?t.width:e.width})),fj={},pj={},gj={},j7;function Wje(){return j7||(j7=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(),v()};let f=null;const p=()=>{f!=null&&clearTimeout(f),f=setTimeout(()=>{f=null,h()},r)},x=()=>{f!==null&&(clearTimeout(f),f=null)},v=()=>{x(),o=void 0,l=null},g=()=>{d()},y=function(..._){if(i?.aborted)return;o=this,l=_;const N=f==null;p(),c&&N&&d()};return y.schedule=p,y.cancel=v,y.flush=g,i?.addEventListener("abort",v,{once:!0}),y}t.debounce=e})(gj)),gj}var E7;function Kje(){return E7||(E7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Wje();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 f=e.debounce(function(...v){d=r.apply(this,v),h=null},i,{edges:u}),p=function(...v){return c!=null&&(h===null&&(h=Date.now()),Date.now()-h>=c)?(d=r.apply(this,v),h=Date.now(),f.cancel(),f.schedule(),d):(f.apply(this,v),d)},x=()=>(f.flush(),d);return p.cancel=f.cancel,p.flush=x,p}t.debounce=n})(pj)),pj}var D7;function Yje(){return D7||(D7=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kje();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})(fj)),fj}var bj,R7;function Xje(){return R7||(R7=1,bj=Yje().throttle),bj}var Qje=Xje();const Zje=Ml(Qje);var mN=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++]))}},Pc={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},GZ=(t,e,n)=>{var{width:r=Pc.width,height:i=Pc.height,aspect:s,maxHeight:o}=n,l=Yf(r)?t:Number(r),c=Yf(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}},Jje={width:0,height:0,overflow:"visible"},eEe={width:0,overflowX:"visible"},tEe={height:0,overflowY:"visible"},nEe={},rEe=t=>{var{width:e,height:n}=t,r=Yf(e),i=Yf(n);return r&&i?Jje:r?eEe:i?tEe:nEe};function aEe(t){var{width:e,height:n,aspect:r}=t,i=e,s=n;return i===void 0&&s===void 0?(i=Pc.width,s=Pc.height):i===void 0?i=r&&r>0?void 0:Pc.width:s===void 0&&(s=r&&r>0?void 0:Pc.height),{width:i,height:s}}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 F7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function L7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F7(Object(n),!0).forEach(function(r){iEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iEe(t,e,n){return(e=sEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sEe(t){var e=oEe(t,"string");return typeof e=="symbol"?e:e+""}function oEe(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 WZ=w.createContext(Pc.initialDimension);function lEe(t){return Uc(t.width)&&Uc(t.height)}function KZ(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return lEe(i)?w.createElement(WZ.Provider,{value:i},e):null}var $4=()=>w.useContext(WZ),cEe=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r=Pc.initialDimension,width:i,height:s,minWidth:o=Pc.minWidth,minHeight:l,maxHeight:c,children:u,debounce:d=Pc.debounce,id:h,className:f,onResize:p,style:x={}}=t,v=w.useRef(null),g=w.useRef();g.current=p,w.useImperativeHandle(e,()=>v.current);var[y,_]=w.useState({containerWidth:r.width,containerHeight:r.height}),N=w.useCallback((R,M)=>{_(D=>{var G=Math.round(R),U=Math.round(M);return D.containerWidth===G&&D.containerHeight===U?D:{containerWidth:G,containerHeight:U}})},[]);w.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return sm;var R=U=>{var W,L=U[0];if(L!=null){var{width:ee,height:ae}=L.contentRect;N(ee,ae),(W=g.current)===null||W===void 0||W.call(g,ee,ae)}};d>0&&(R=Zje(R,d,{trailing:!0,leading:!1}));var M=new ResizeObserver(R),{width:D,height:G}=v.current.getBoundingClientRect();return N(D,G),M.observe(v.current),()=>{M.disconnect()}},[N,d]);var{containerWidth:A,containerHeight:C}=y;mN(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:j,calculatedHeight:k}=GZ(A,C,{width:i,height:s,aspect:n,maxHeight:c});return mN(j!=null&&j>0||k!=null&&k>0,`The width(%s) and height(%s) of chart should be greater than 0,
  8071. please check the style of container, or the props width(%s) and height(%s),
  8072. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  8073. height and width.`,j,k,i,s,o,l,n),w.createElement("div",{id:h?"".concat(h):void 0,className:hr("recharts-responsive-container",f),style:L7(L7({},x),{},{width:i,height:s,minWidth:o,minHeight:l,maxHeight:c}),ref:v},w.createElement("div",{style:rEe({width:i,height:s})},w.createElement(KZ,{width:j,height:k},u)))}),Th=w.forwardRef((t,e)=>{var n=$4();if(Uc(n.width)&&Uc(n.height))return t.children;var{width:r,height:i}=aEe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:o}=GZ(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Vt(s)&&Vt(o)?w.createElement(KZ,{width:s,height:o},t.children):w.createElement(cEe,GD({},t,{width:r,height:i,ref:e}))});function V4(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 jv=()=>{var t,e=wi(),n=Gt(qje),r=Gt(IC),i=(t=Gt(OC))===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}},uEe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},YZ=()=>{var t;return(t=Gt(vi))!==null&&t!==void 0?t:uEe},q4=()=>Gt(bd),G4=()=>Gt(xd),dEe=()=>Gt(t=>t.layout.margin),ur=t=>t.layout.layoutType,lm=()=>Gt(ur),W4=()=>{var t=lm();if(t==="horizontal"||t==="vertical")return t},XZ=t=>{var e=t.layout.layoutType;if(e==="centric"||e==="radial")return e},hEe=()=>{var t=lm();return t!==void 0},Ev=t=>{var e=Jr(),n=wi(),{width:r,height:i}=t,s=$4(),o=r,l=i;return s&&(o=s.width>0?s.width:r,l=s.height>0?s.height:i),w.useEffect(()=>{!n&&Uc(o)&&Uc(l)&&e(xje({width:o,height:l}))},[e,n,o,l]),null},QZ=Symbol.for("immer-nothing"),O7=Symbol.for("immer-draftable"),Io=Symbol.for("immer-state");function Gl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var H0=Object.getPrototypeOf;function Eb(t){return!!t&&!!t[Io]}function Qf(t){return t?ZZ(t)||Array.isArray(t)||!!t[O7]||!!t.constructor?.[O7]||Dv(t)||UC(t):!1}var mEe=Object.prototype.constructor.toString(),I7=new WeakMap;function ZZ(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=I7.get(n);return r===void 0&&(r=Function.toString.call(n),I7.set(n,r)),r===mEe}function fN(t,e,n=!0){zC(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 zC(t){const e=t[Io];return e?e.type_:Array.isArray(t)?1:Dv(t)?2:UC(t)?3:0}function WD(t,e){return zC(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function JZ(t,e,n){const r=zC(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function fEe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Dv(t){return t instanceof Map}function UC(t){return t instanceof Set}function Ym(t){return t.copy_||t.base_}function KD(t,e){if(Dv(t))return new Map(t);if(UC(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=ZZ(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Io];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(H0(t),r)}else{const r=H0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function K4(t,e=!1){return BC(t)||Eb(t)||!Qf(t)||(zC(t)>1&&Object.defineProperties(t,{set:y_,add:y_,clear:y_,delete:y_}),Object.freeze(t),e&&Object.values(t).forEach(n=>K4(n,!0))),t}function pEe(){Gl(2)}var y_={value:pEe};function BC(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var gEe={};function Zf(t){const e=gEe[t];return e||Gl(0,t),e}var $0;function eJ(){return $0}function bEe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function z7(t,e){e&&(Zf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function YD(t){XD(t),t.drafts_.forEach(xEe),t.drafts_=null}function XD(t){t===$0&&($0=t.parent_)}function U7(t){return $0=bEe($0,t)}function xEe(t){const e=t[Io];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function B7(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Io].modified_&&(YD(e),Gl(4)),Qf(t)&&(t=pN(e,t),e.parent_||gN(e,t)),e.patches_&&Zf("Patches").generateReplacementPatches_(n[Io].base_,t,e.patches_,e.inversePatches_)):t=pN(e,n,[]),YD(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==QZ?t:void 0}function pN(t,e,n){if(BC(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Io];if(!i)return fN(e,(s,o)=>H7(t,i,e,s,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return gN(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),fN(o,(c,u)=>H7(t,i,s,c,u,n,l),r),gN(t,s,!1),n&&t.patches_&&Zf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function H7(t,e,n,r,i,s,o){if(i==null||typeof i!="object"&&!o)return;const l=BC(i);if(!(l&&!o)){if(Eb(i)){const c=s&&e&&e.type_!==3&&!WD(e.assigned_,r)?s.concat(r):void 0,u=pN(t,i,c);if(JZ(n,r,u),Eb(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Qf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;pN(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Dv(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&gN(t,i)}}}function gN(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&K4(e,n)}function yEe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:eJ(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=Y4;n&&(i=[r],s=V0);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,l}var Y4={get(t,e){if(e===Io)return t;const n=Ym(t);if(!WD(n,e))return vEe(t,n,e);const r=n[e];return t.finalized_||!Qf(r)?r:r===xj(t.base_,e)?(yj(t),t.copy_[e]=ZD(r,t)):r},has(t,e){return e in Ym(t)},ownKeys(t){return Reflect.ownKeys(Ym(t))},set(t,e,n){const r=tJ(Ym(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=xj(Ym(t),e),s=i?.[Io];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(fEe(n,i)&&(n!==void 0||WD(t.base_,e)))return!0;yj(t),QD(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 xj(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,yj(t),QD(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Ym(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Gl(11)},getPrototypeOf(t){return H0(t.base_)},setPrototypeOf(){Gl(12)}},V0={};fN(Y4,(t,e)=>{V0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});V0.deleteProperty=function(t,e){return V0.set.call(this,t,e,void 0)};V0.set=function(t,e,n){return Y4.set.call(this,t[0],e,n,t[0])};function xj(t,e){const n=t[Io];return(n?Ym(n):t)[e]}function vEe(t,e,n){const r=tJ(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function tJ(t,e){if(!(e in t))return;let n=H0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=H0(n)}}function QD(t){t.modified_||(t.modified_=!0,t.parent_&&QD(t.parent_))}function yj(t){t.copy_||(t.copy_=KD(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var wEe=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"&&Gl(6),r!==void 0&&typeof r!="function"&&Gl(7);let i;if(Qf(e)){const s=U7(this),o=ZD(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?YD(s):XD(s)}return z7(s,r),B7(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===QZ&&(i=void 0),this.autoFreeze_&&K4(i,!0),r){const s=[],o=[];Zf("Patches").generateReplacementPatches_(e,i,s,o),r(s,o)}return i}else Gl(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){Qf(t)||Gl(8),Eb(t)&&(t=SEe(t));const e=U7(this),n=ZD(t,void 0);return n[Io].isManual_=!0,XD(e),n}finishDraft(t,e){const n=t&&t[Io];(!n||!n.isManual_)&&Gl(9);const{scope_:r}=n;return z7(r,e),B7(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=Zf("Patches").applyPatches_;return Eb(t)?r(t,e):this.produce(t,i=>r(i,e))}};function ZD(t,e){const n=Dv(t)?Zf("MapSet").proxyMap_(t,e):UC(t)?Zf("MapSet").proxySet_(t,e):yEe(t,e);return(e?e.scope_:eJ()).drafts_.push(n),n}function SEe(t){return Eb(t)||Gl(10,t),nJ(t)}function nJ(t){if(!Qf(t)||BC(t))return t;const e=t[Io];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=KD(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=KD(t,!0);return fN(n,(i,s)=>{JZ(n,i,nJ(s))},r),e&&(e.finalized_=!1),n}var _Ee=new wEe;_Ee.produce;var NEe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},rJ=ho({name:"legend",initialState:NEe,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:fa()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Zl(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:fa()},removeLegendPayload:{reducer(t,e){var n=Zl(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:fa()}}}),{setLegendSize:$7,setLegendSettings:kEe,addLegendPayload:aJ,replaceLegendPayload:iJ,removeLegendPayload:sJ}=rJ.actions,CEe=rJ.reducer,AEe=["contextPayload"];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 V7(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 Db(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V7(Object(n),!0).forEach(function(r){TEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function TEe(t,e,n){return(e=MEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MEe(t){var e=PEe(t,"string");return typeof e=="symbol"?e:e+""}function PEe(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 jEe(t,e){if(t==null)return{};var n,r,i=EEe(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 EEe(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 DEe(t){return t.value}function REe(t){var{contextPayload:e}=t,n=jEe(t,AEe),r=rZ(e,t.payloadUniqBy,DEe),i=Db(Db({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(TMe,i)}function FEe(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}),Db(Db({},u),d)}function LEe(t){var e=Jr();return w.useEffect(()=>{e(kEe(t))},[e,t]),null}function OEe(t){var e=Jr();return w.useEffect(()=>(e($7(t)),()=>{e($7({width:0,height:0}))}),[e,t]),null}function IEe(t,e,n,r){return t==="vertical"&&e!=null?{height:e}:t==="horizontal"?{width:n||r}:null}var zEe={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function oJ(t){var e=_a(t,zEe),n=vPe(),r=v2e(),i=dEe(),{width:s,height:o,wrapperStyle:l,portal:c}=e,[u,d]=cZ([n]),h=q4(),f=G4();if(h==null||f==null)return null;var p=h-(i?.left||0)-(i?.right||0),x=IEe(e.layout,o,s,p),v=c?l:Db(Db({position:"absolute",width:x?.width||s||"auto",height:x?.height||o||"auto"},FEe(l,e,i,h,f,u)),l),g=c??r;if(g==null||n==null)return null;var y=w.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:d},w.createElement(LEe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(OEe,{width:u.width,height:u.height}),w.createElement(REe,JD({},e,x,{margin:i,chartWidth:h,chartHeight:f,contextPayload:n})));return Iu.createPortal(y,g)}oJ.displayName="Legend";function eR(){return eR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},eR.apply(null,arguments)}function q7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _y(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q7(Object(n),!0).forEach(function(r){UEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function UEe(t,e,n){return(e=BEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BEe(t){var e=HEe(t,"string");return typeof e=="symbol"?e:e+""}function HEe(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 $Ee(t){return Array.isArray(t)&&Cl(t[0])&&Cl(t[1])?t.join(" ~ "):t}var Tg={separator:" : ",contentStyle:{margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},itemStyle:{display:"block",paddingTop:4,paddingBottom:4,color:"#000"},labelStyle:{},accessibilityLayer:!1},VEe=t=>{var{separator:e=Tg.separator,contentStyle:n,itemStyle:r,labelStyle:i=Tg.labelStyle,payload:s,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:h,accessibilityLayer:f=Tg.accessibilityLayer}=t,p=()=>{if(s&&s.length){var C={padding:0,margin:0},j=(l?kC(s,l):s).map((k,R)=>{if(k.type==="none")return null;var M=k.formatter||o||$Ee,{value:D,name:G}=k,U=D,W=G;if(M){var L=M(D,G,k,R,s);if(Array.isArray(L))[U,W]=L;else if(L!=null)U=L;else return null}var ee=_y(_y({},Tg.itemStyle),{},{color:k.color||Tg.itemStyle.color},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(R),style:ee},Cl(W)?w.createElement("span",{className:"recharts-tooltip-item-name"},W):null,Cl(W)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},U),w.createElement("span",{className:"recharts-tooltip-item-unit"},k.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:C},j)}return null},x=_y(_y({},Tg.contentStyle),n),v=_y({margin:0},i),g=!xa(d),y=g?d:"",_=hr("recharts-default-tooltip",c),N=hr("recharts-tooltip-label",u);g&&h&&s!==void 0&&s!==null&&(y=h(d,s));var A=f?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",eR({className:_,style:x},A),w.createElement("p",{className:N,style:v},w.isValidElement(y)?y:"".concat(y)),p())},Ny="recharts-tooltip-wrapper",qEe={visibility:"hidden"};function GEe(t){var{coordinate:e,translateX:n,translateY:r}=t;return hr(Ny,{["".concat(Ny,"-right")]:Vt(n)&&e&&Vt(e.x)&&n>=e.x,["".concat(Ny,"-left")]:Vt(n)&&e&&Vt(e.x)&&n<e.x,["".concat(Ny,"-bottom")]:Vt(r)&&e&&Vt(e.y)&&r>=e.y,["".concat(Ny,"-top")]:Vt(r)&&e&&Vt(e.y)&&r<e.y})}function G7(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offset:i,position:s,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(s&&Vt(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 f=c[r];if(f==null)return 0;if(o[r]){var p=d,x=f;return p<x?Math.max(h,f):Math.max(d,f)}if(u==null)return 0;var v=h+l,g=f+u;return v>g?Math.max(d,f):Math.max(h,f)}function WEe(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 KEe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTop:r,offsetLeft:i,position:s,reverseDirection:o,tooltipBox:l,useTranslate3d:c,viewBox:u}=t,d,h,f;return l.height>0&&l.width>0&&n?(h=G7({allowEscapeViewBox:e,coordinate:n,key:"x",offset:i,position:s,reverseDirection:o,tooltipDimension:l.width,viewBox:u,viewBoxDimension:u.width}),f=G7({allowEscapeViewBox:e,coordinate:n,key:"y",offset:r,position:s,reverseDirection:o,tooltipDimension:l.height,viewBox:u,viewBoxDimension:u.height}),d=WEe({translateX:h,translateY:f,useTranslate3d:c})):d=qEe,{cssProperties:d,cssClasses:GEe({translateX:h,translateY:f,coordinate:n})}}function W7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W7(Object(n),!0).forEach(function(r){tR(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tR(t,e,n){return(e=YEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YEe(t){var e=XEe(t,"string");return typeof e=="symbol"?e:e+""}function XEe(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 QEe extends w.PureComponent{constructor(){super(...arguments),tR(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),tR(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:f,viewBox:p,wrapperStyle:x,lastBoundingBox:v,innerRef:g,hasPortalFromProps:y}=this.props,_=typeof u=="number"?u:u.x,N=typeof u=="number"?u:u.y,{cssClasses:A,cssProperties:C}=KEe({allowEscapeViewBox:n,coordinate:o,offsetLeft:_,offsetTop:N,position:d,reverseDirection:h,tooltipBox:{height:v.height,width:v.width},useTranslate3d:f,viewBox:p}),j=y?{}:v_(v_({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},C),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),k=v_(v_({},j),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:A,style:k,ref:g},s)}}var lJ=()=>{var t;return(t=Gt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function nR(){return nR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},nR.apply(null,arguments)}function K7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Y7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K7(Object(n),!0).forEach(function(r){ZEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZEe(t,e,n){return(e=JEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JEe(t){var e=e3e(t,"string");return typeof e=="symbol"?e:e+""}function e3e(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 X7={curveBasisClosed:z2e,curveBasisOpen:U2e,curveBasis:I2e,curveBumpX:N2e,curveBumpY:k2e,curveLinearClosed:B2e,curveLinear:_C,curveMonotoneX:H2e,curveMonotoneY:$2e,curveNatural:V2e,curveStep:q2e,curveStepAfter:W2e,curveStepBefore:G2e},bN=t=>Pn(t.x)&&Pn(t.y),Q7=t=>t.base!=null&&bN(t.base)&&bN(t),ky=t=>t.x,Cy=t=>t.y,t3e=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Cv(t));if((n==="curveMonotone"||n==="curveBump")&&e){var r=X7["".concat(n).concat(e==="vertical"?"Y":"X")];if(r)return r}return X7[n]||_C},Z7={connectNulls:!1,type:"linear"},n3e=t=>{var{type:e=Z7.type,points:n=[],baseLine:r,layout:i,connectNulls:s=Z7.connectNulls}=t,o=t3e(e,i),l=s?n.filter(bN):n;if(Array.isArray(r)){var c,u=n.map((x,v)=>Y7(Y7({},x),{},{base:r[v]}));i==="vertical"?c=h_().y(Cy).x1(ky).x0(x=>x.base.x):c=h_().x(ky).y1(Cy).y0(x=>x.base.y);var d=c.defined(Q7).curve(o),h=s?u.filter(Q7):u;return d(h)}var f;i==="vertical"&&Vt(r)?f=h_().y(Cy).x1(ky).x0(r):Vt(r)?f=h_().x(ky).y1(Cy).y0(r):f=DQ().x(ky).y(Cy);var p=f.defined(bN).curve(o);return p(l)},db=t=>{var{className:e,points:n,path:r,pathRef:i}=t,s=lm();if((!n||!n.length)&&!r)return null;var o={type:t.type,points:t.points,baseLine:t.baseLine,layout:t.layout||s,connectNulls:t.connectNulls},l=n&&n.length?n3e(o):r;return w.createElement("path",nR({},Is(t),E4(t),{className:hr("recharts-curve",e),d:l===null?void 0:l,ref:i}))},r3e=["x","y","top","left","width","height","className"];function rR(){return rR=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},rR.apply(null,arguments)}function J7(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 a3e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J7(Object(n),!0).forEach(function(r){i3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function i3e(t,e,n){return(e=s3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s3e(t){var e=o3e(t,"string");return typeof e=="symbol"?e:e+""}function o3e(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 l3e(t,e){if(t==null)return{};var n,r,i=c3e(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 c3e(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 u3e=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),d3e=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:o=0,className:l}=t,c=l3e(t,r3e),u=a3e({x:e,y:n,top:r,left:i,width:s,height:o},c);return!Vt(e)||!Vt(n)||!Vt(s)||!Vt(o)||!Vt(r)||!Vt(i)?null:w.createElement("path",rR({},rs(u),{className:hr("recharts-cross",l),d:u3e(e,n,s,o,r,i)}))};function h3e(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 eV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?eV(Object(n),!0).forEach(function(r){m3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):eV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function m3e(t,e,n){return(e=f3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f3e(t){var e=p3e(t,"string");return typeof e=="symbol"?e:e+""}function p3e(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 g3e=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),cJ=(t,e,n)=>t.map(r=>"".concat(g3e(r)," ").concat(e,"ms ").concat(n)).join(","),b3e=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),q0=(t,e)=>Object.keys(e).reduce((n,r)=>tV(tV({},n),{},{[r]:t(r,e[r])}),{});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 mi(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){x3e(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 x3e(t,e,n){return(e=y3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function y3e(t){var e=v3e(t,"string");return typeof e=="symbol"?e:e+""}function v3e(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 xN=(t,e,n)=>t+(e-t)*n,aR=t=>{var{from:e,to:n}=t;return e!==n},uJ=(t,e,n)=>{var r=q0((i,s)=>{if(aR(s)){var[o,l]=t(s.from,s.to,s.velocity);return mi(mi({},s),{},{from:o,velocity:l})}return s},e);return n<1?q0((i,s)=>aR(s)&&r[i]!=null?mi(mi({},s),{},{velocity:xN(s.velocity,r[i].velocity,n),from:xN(s.from,r[i].from,n)}):s,e):uJ(t,r,n-1)};function w3e(t,e,n,r,i,s){var o,l=r.reduce((f,p)=>mi(mi({},f),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>q0((f,p)=>p.from,l),u=()=>!Object.values(l).filter(aR).length,d=null,h=f=>{o||(o=f);var p=f-o,x=p/n.dt;l=uJ(n,l,x),i(mi(mi(mi({},t),e),c())),o=f,u()||(d=s.setTimeout(h))};return()=>(d=s.setTimeout(h),()=>{var f;(f=d)===null||f===void 0||f()})}function S3e(t,e,n,r,i,s,o){var l=null,c=i.reduce((h,f)=>{var p=t[f],x=e[f];return p==null||x==null?h:mi(mi({},h),{},{[f]:[p,x]})},{}),u,d=h=>{u||(u=h);var f=(h-u)/r,p=q0((v,g)=>xN(...g,n(f)),c);if(s(mi(mi(mi({},t),e),p)),f<1)l=o.setTimeout(d);else{var x=q0((v,g)=>xN(...g,n(1)),c);s(mi(mi(mi({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var h;(h=l)===null||h===void 0||h()})}const _3e=(t,e,n,r,i,s)=>{var o=b3e(t,e);return n==null?()=>(i(mi(mi({},t),e)),()=>{}):n.isStepper===!0?w3e(t,e,n,o,i,s):S3e(t,e,n,r,o,i,s)};var yN=1e-4,dJ=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],hJ=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),rV=(t,e)=>n=>{var r=dJ(t,e);return hJ(r,n)},N3e=(t,e)=>n=>{var r=dJ(t,e),i=[...r.map((s,o)=>s*o).slice(1),0];return hJ(i,n)},k3e=t=>{var e,n=t.split("(");if(n.length!==2||n[0]!=="cubic-bezier")return null;var r=(e=n[1])===null||e===void 0||(e=e.split(")")[0])===null||e===void 0?void 0:e.split(",");if(r==null||r.length!==4)return null;var i=r.map(s=>parseFloat(s));return[i[0],i[1],i[2],i[3]]},C3e=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=k3e(n[0]);if(i)return i}}return n.length===4?n:[0,0,1,1]},A3e=(t,e,n,r)=>{var i=rV(t,n),s=rV(e,r),o=N3e(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,h=d,f=0;f<8;++f){var p=i(h)-d,x=o(h);if(Math.abs(p-d)<yN||x<yN)return s(h);h=l(h-p/x)}return s(h)};return c.isStepper=!1,c},aV=function(){return A3e(...C3e(...arguments))},T3e=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,f=c*i/1e3+o;return Math.abs(f-l)<yN&&Math.abs(h)<yN?[l,0]:[f,h]};return s.isStepper=!0,s.dt=i,s},M3e=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return aV(t);case"spring":return T3e();default:if(t.split("(")[0]==="cubic-bezier")return aV(t)}return typeof t=="function"?t:null};function P3e(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 j3e{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 E3e(){return P3e(new j3e)}var D3e=w.createContext(E3e);function R3e(t,e){var n=w.useContext(D3e);return w.useMemo(()=>e??n(t),[t,e,n])}var F3e=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Rv={isSsr:F3e()},L3e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},iV={t:0},vj={t:1};function sx(t){var e=_a(t,L3e),{isActive:n,canBegin:r,duration:i,easing:s,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Rv.isSsr:n,h=R3e(e.animationId,e.animationManager),[f,p]=w.useState(d?iV:vj),x=w.useRef(null);return w.useEffect(()=>{d||p(vj)},[d]),w.useEffect(()=>{if(!d||!r)return sm;var v=_3e(iV,vj,M3e(s),i,p,h.getTimeoutController()),g=()=>{x.current=v()};return h.start([c,o,g,i,l]),()=>{h.stop(),x.current&&x.current(),l()}},[d,r,i,s,o,c,l,h]),u(f.t)}function ox(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(I0(e)),r=w.useRef(t);return r.current!==t&&(n.current=I0(e),r.current=t),n.current}var O3e=["radius"],I3e=["radius"],sV,oV,lV,cV,uV,dV,hV,mV,fV,pV;function gV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function bV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gV(Object(n),!0).forEach(function(r){z3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function z3e(t,e,n){return(e=U3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U3e(t){var e=B3e(t,"string");return typeof e=="symbol"?e:e+""}function B3e(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 vN(){return vN=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},vN.apply(null,arguments)}function xV(t,e){if(t==null)return{};var n,r,i=H3e(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 H3e(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 bc(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var yV=(t,e,n,r,i)=>{var s=Ah(n),o=Ah(r),l=Math.min(Math.abs(s)/2,Math.abs(o)/2),c=o>=0?1:-1,u=s>=0?1:-1,d=o>=0&&s>=0||o<0&&s<0?1:0,h;if(l>0&&Array.isArray(i)){for(var f=[0,0,0,0],p=0,x=4;p<x;p++){var v,g=(v=i[p])!==null&&v!==void 0?v:0;f[p]=g>l?l:g}h=Ea(sV||(sV=bc(["M",",",""])),t,e+c*f[0]),f[0]>0&&(h+=Ea(oV||(oV=bc(["A ",",",",0,0,",",",",",""])),f[0],f[0],d,t+u*f[0],e)),h+=Ea(lV||(lV=bc(["L ",",",""])),t+n-u*f[1],e),f[1]>0&&(h+=Ea(cV||(cV=bc(["A ",",",",0,0,",`,
  8074. `,",",""])),f[1],f[1],d,t+n,e+c*f[1])),h+=Ea(uV||(uV=bc(["L ",",",""])),t+n,e+r-c*f[2]),f[2]>0&&(h+=Ea(dV||(dV=bc(["A ",",",",0,0,",`,
  8075. `,",",""])),f[2],f[2],d,t+n-u*f[2],e+r)),h+=Ea(hV||(hV=bc(["L ",",",""])),t+u*f[3],e+r),f[3]>0&&(h+=Ea(mV||(mV=bc(["A ",",",",0,0,",`,
  8076. `,",",""])),f[3],f[3],d,t,e+r-c*f[3])),h+="Z"}else if(l>0&&i===+i&&i>0){var y=Math.min(l,i);h=Ea(fV||(fV=bc(["M ",",",`
  8077. A `,",",",0,0,",",",",",`
  8078. L `,",",`
  8079. A `,",",",0,0,",",",",",`
  8080. L `,",",`
  8081. A `,",",",0,0,",",",",",`
  8082. L `,",",`
  8083. A `,",",",0,0,",",",","," Z"])),t,e+c*y,y,y,d,t+u*y,e,t+n-u*y,e,y,y,d,t+n,e+c*y,t+n,e+r-c*y,y,y,d,t+n-u*y,e+r,t+u*y,e+r,y,y,d,t,e+r-c*y)}else h=Ea(pV||(pV=bc(["M ",","," h "," v "," h "," Z"])),t,e,n,r,-n);return h},vV={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},mJ=t=>{var e=_a(t,vV),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var Y=n.current.getTotalLength();Y&&i(Y)}catch{}},[]);var{x:s,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:h,animationDuration:f,animationBegin:p,isAnimationActive:x,isUpdateAnimationActive:v}=e,g=w.useRef(l),y=w.useRef(c),_=w.useRef(s),N=w.useRef(o),A=w.useMemo(()=>({x:s,y:o,width:l,height:c,radius:u}),[s,o,l,c,u]),C=ox(A,"rectangle-");if(s!==+s||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var j=hr("recharts-rectangle",d);if(!v){var k=rs(e),{radius:R}=k,M=xV(k,O3e);return w.createElement("path",vN({},M,{x:Ah(s),y:Ah(o),width:Ah(l),height:Ah(c),radius:typeof u=="number"?u:void 0,className:j,d:yV(s,o,l,c,u)}))}var D=g.current,G=y.current,U=_.current,W=N.current,L="0px ".concat(r===-1?1:r,"px"),ee="".concat(r,"px 0px"),ae=cJ(["strokeDasharray"],f,typeof h=="string"?h:vV.animationEasing);return w.createElement(sx,{animationId:C,key:C,canBegin:r>0,duration:f,easing:h,isActive:v,begin:p},Y=>{var se=_r(D,l,Y),ce=_r(G,c,Y),ye=_r(U,s,Y),Z=_r(W,o,Y);n.current&&(g.current=se,y.current=ce,_.current=ye,N.current=Z);var ue;x?Y>0?ue={transition:ae,strokeDasharray:ee}:ue={strokeDasharray:L}:ue={strokeDasharray:ee};var pe=rs(e),{radius:be}=pe,Ee=xV(pe,I3e);return w.createElement("path",vN({},Ee,{radius:typeof u=="number"?u:void 0,className:j,d:yV(ye,Z,se,ce,u),ref:n,style:bV(bV({},ue),e.style)}))})};function wV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function SV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wV(Object(n),!0).forEach(function(r){$3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $3e(t,e,n){return(e=V3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function V3e(t){var e=q3e(t,"string");return typeof e=="symbol"?e:e+""}function q3e(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 wN=Math.PI/180,G3e=t=>t*180/Math.PI,ri=(t,e,n,r)=>({x:t+Math.cos(-wN*r)*n,y:e+Math.sin(-wN*r)*n}),fJ=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},W3e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},K3e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,o=W3e({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:G3e(c),angleInRadian:c}},Y3e=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}},X3e=(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},Q3e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=K3e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=Y3e(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?SV(SV({},e),{},{radius:i,angle:X3e(d,e)}):null};function pJ(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,o=ri(e,n,r,i),l=ri(e,n,r,s);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}var _V,NV,kV,CV,AV,TV,MV;function iR(){return iR=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},iR.apply(null,arguments)}function of(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var Z3e=(t,e)=>{var n=Ri(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},w_=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/wN,h=c?i:i+s*d,f=ri(e,n,u,h),p=ri(e,n,r,h),x=c?i-s*d:i,v=ri(e,n,u*Math.cos(d*wN),x);return{center:f,circleTangency:p,lineTangency:v,theta:d}},gJ=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:o}=t,l=Z3e(s,o),c=s+l,u=ri(e,n,i,s),d=ri(e,n,i,c),h=Ea(_V||(_V=of(["M ",",",`
  8084. A `,",",`,0,
  8085. `,",",`,
  8086. `,",",`
  8087. `])),u.x,u.y,i,i,+(Math.abs(l)>180),+(s>c),d.x,d.y);if(r>0){var f=ri(e,n,r,s),p=ri(e,n,r,c);h+=Ea(NV||(NV=of(["L ",",",`
  8088. A `,",",`,0,
  8089. `,",",`,
  8090. `,","," Z"])),p.x,p.y,r,r,+(Math.abs(l)>180),+(s<=c),f.x,f.y)}else h+=Ea(kV||(kV=of(["L ",","," Z"])),e,n);return h},J3e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Ri(u-c),{circleTangency:h,lineTangency:f,theta:p}=w_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:s,cornerIsExternal:l}),{circleTangency:x,lineTangency:v,theta:g}=w_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:s,cornerIsExternal:l}),y=l?Math.abs(c-u):Math.abs(c-u)-p-g;if(y<0)return o?Ea(CV||(CV=of(["M ",",",`
  8091. a`,",",",0,0,1,",`,0
  8092. a`,",",",0,0,1,",`,0
  8093. `])),f.x,f.y,s,s,s*2,s,s,-s*2):gJ({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var _=Ea(AV||(AV=of(["M ",",",`
  8094. A`,",",",0,0,",",",",",`
  8095. A`,",",",0,",",",",",",",`
  8096. A`,",",",0,0,",",",",",`
  8097. `])),f.x,f.y,s,s,+(d<0),h.x,h.y,i,i,+(y>180),+(d<0),x.x,x.y,s,s,+(d<0),v.x,v.y);if(r>0){var{circleTangency:N,lineTangency:A,theta:C}=w_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),{circleTangency:j,lineTangency:k,theta:R}=w_({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),M=l?Math.abs(c-u):Math.abs(c-u)-C-R;if(M<0&&s===0)return"".concat(_,"L").concat(e,",").concat(n,"Z");_+=Ea(TV||(TV=of(["L",",",`
  8098. A`,",",",0,0,",",",",",`
  8099. A`,",",",0,",",",",",",",`
  8100. A`,",",",0,0,",",",",","Z"])),k.x,k.y,s,s,+(d<0),j.x,j.y,r,r,+(M>180),+(d>0),N.x,N.y,s,s,+(d<0),A.x,A.y)}else _+=Ea(MV||(MV=of(["L",",","Z"])),e,n);return _},eDe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},bJ=t=>{var e=_a(t,eDe),{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 f=hr("recharts-sector",h),p=s-i,x=vs(o,p,0,!0),v;return x>0&&Math.abs(u-d)<360?v=J3e({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):v=gJ({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:u,endAngle:d}),w.createElement("path",iR({},rs(e),{className:f,d:v}))};function tDe(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(KQ(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:o,angle:l}=e,c=ri(r,i,s,l),u=ri(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return pJ(e)}}var wj={},Sj={},_j={},PV;function nDe(){return PV||(PV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sZ();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(_j)),_j}var jV;function rDe(){return jV||(jV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nDe();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})(Sj)),Sj}var EV;function aDe(){return EV||(EV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oZ(),n=rDe();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})(wj)),wj}var Nj,DV;function iDe(){return DV||(DV=1,Nj=aDe().range),Nj}var sDe=iDe();const xJ=Ml(sDe);function Vh(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function oDe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function X4(t){let e,n,r;t.length!==2?(e=Vh,n=(l,c)=>Vh(t(l),c),r=(l,c)=>t(l)-c):(e=t===Vh||t===oDe?t:lDe,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 lDe(){return 0}function yJ(t){return t===null?NaN:+t}function*cDe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const uDe=X4(Vh),Fv=uDe.right;X4(yJ).center;class RV extends Map{constructor(e,n=mDe){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(FV(this,e))}has(e){return super.has(FV(this,e))}set(e,n){return super.set(dDe(this,e),n)}delete(e){return super.delete(hDe(this,e))}}function FV({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function dDe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function hDe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function mDe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function fDe(t=Vh){if(t===Vh)return vJ;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 vJ(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const pDe=Math.sqrt(50),gDe=Math.sqrt(10),bDe=Math.sqrt(2);function SN(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>=pDe?10:s>=gDe?5:s>=bDe?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?SN(t,e,n*2):[l,c,u]}function sR(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?SN(e,t,n):SN(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 oR(t,e,n){return e=+e,t=+t,n=+n,SN(t,e,n)[2]}function lR(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?oR(e,t,n):oR(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function LV(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function OV(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function wJ(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?vJ:fDe(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),f=.5*Math.sqrt(d*h*(c-h)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*h/c+f)),x=Math.min(r,Math.floor(e+(c-u)*h/c+f));wJ(t,e,p,x,i)}const s=t[e];let o=n,l=r;for(Ay(t,n,e),i(t[r],s)>0&&Ay(t,n,r);o<l;){for(Ay(t,o,l),++o,--l;i(t[o],s)<0;)++o;for(;i(t[l],s)>0;)--l}i(t[n],s)===0?Ay(t,n,l):(++l,Ay(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function Ay(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function xDe(t,e,n){if(t=Float64Array.from(cDe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return OV(t);if(e>=1)return LV(t);var r,i=(r-1)*e,s=Math.floor(i),o=LV(wJ(t,s).subarray(0,s+1)),l=OV(t.subarray(s+1));return o+(l-o)*(i-s)}}function yDe(t,e,n=yJ){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 vDe(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 El(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function yd(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 cR=Symbol("implicit");function Q4(){var t=new RV,e=[],n=[],r=cR;function i(s){let o=t.get(s);if(o===void 0){if(r!==cR)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 RV;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 Q4(e,n).unknown(r)},El.apply(i,arguments),i}function Z4(){var t=Q4().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 f=e().length,p=i<r,x=p?i:r,v=p?r:i;s=(v-x)/Math.max(1,f-c+u*2),l&&(s=Math.floor(s)),x+=(v-x-s*(f-c))*d,o=s*(1-c),l&&(x=Math.round(x),o=Math.round(o));var g=vDe(f).map(function(y){return x+s*y});return n(p?g.reverse():g)}return t.domain=function(f){return arguments.length?(e(f),h()):e()},t.range=function(f){return arguments.length?([r,i]=f,r=+r,i=+i,h()):[r,i]},t.rangeRound=function(f){return[r,i]=f,r=+r,i=+i,l=!0,h()},t.bandwidth=function(){return o},t.step=function(){return s},t.round=function(f){return arguments.length?(l=!!f,h()):l},t.padding=function(f){return arguments.length?(c=Math.min(1,u=+f),h()):c},t.paddingInner=function(f){return arguments.length?(c=Math.min(1,f),h()):c},t.paddingOuter=function(f){return arguments.length?(u=+f,h()):u},t.align=function(f){return arguments.length?(d=Math.max(0,Math.min(1,f)),h()):d},t.copy=function(){return Z4(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},El.apply(h(),arguments)}function SJ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return SJ(e())},t}function wDe(){return SJ(Z4.apply(null,arguments).paddingInner(1))}function J4(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function _J(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Lv(){}var G0=.7,_N=1/G0,hb="\\s*([+-]?\\d+)\\s*",W0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Lc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",SDe=/^#([0-9a-f]{3,8})$/,_De=new RegExp(`^rgb\\(${hb},${hb},${hb}\\)$`),NDe=new RegExp(`^rgb\\(${Lc},${Lc},${Lc}\\)$`),kDe=new RegExp(`^rgba\\(${hb},${hb},${hb},${W0}\\)$`),CDe=new RegExp(`^rgba\\(${Lc},${Lc},${Lc},${W0}\\)$`),ADe=new RegExp(`^hsl\\(${W0},${Lc},${Lc}\\)$`),TDe=new RegExp(`^hsla\\(${W0},${Lc},${Lc},${W0}\\)$`),IV={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};J4(Lv,K0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:zV,formatHex:zV,formatHex8:MDe,formatHsl:PDe,formatRgb:UV,toString:UV});function zV(){return this.rgb().formatHex()}function MDe(){return this.rgb().formatHex8()}function PDe(){return NJ(this).formatHsl()}function UV(){return this.rgb().formatRgb()}function K0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=SDe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?BV(e):n===3?new ro(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?S_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?S_(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=_De.exec(t))?new ro(e[1],e[2],e[3],1):(e=NDe.exec(t))?new ro(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=kDe.exec(t))?S_(e[1],e[2],e[3],e[4]):(e=CDe.exec(t))?S_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=ADe.exec(t))?VV(e[1],e[2]/100,e[3]/100,1):(e=TDe.exec(t))?VV(e[1],e[2]/100,e[3]/100,e[4]):IV.hasOwnProperty(t)?BV(IV[t]):t==="transparent"?new ro(NaN,NaN,NaN,0):null}function BV(t){return new ro(t>>16&255,t>>8&255,t&255,1)}function S_(t,e,n,r){return r<=0&&(t=e=n=NaN),new ro(t,e,n,r)}function jDe(t){return t instanceof Lv||(t=K0(t)),t?(t=t.rgb(),new ro(t.r,t.g,t.b,t.opacity)):new ro}function uR(t,e,n,r){return arguments.length===1?jDe(t):new ro(t,e,n,r??1)}function ro(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}J4(ro,uR,_J(Lv,{brighter(t){return t=t==null?_N:Math.pow(_N,t),new ro(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?G0:Math.pow(G0,t),new ro(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ro(Nf(this.r),Nf(this.g),Nf(this.b),NN(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:HV,formatHex:HV,formatHex8:EDe,formatRgb:$V,toString:$V}));function HV(){return`#${lf(this.r)}${lf(this.g)}${lf(this.b)}`}function EDe(){return`#${lf(this.r)}${lf(this.g)}${lf(this.b)}${lf((isNaN(this.opacity)?1:this.opacity)*255)}`}function $V(){const t=NN(this.opacity);return`${t===1?"rgb(":"rgba("}${Nf(this.r)}, ${Nf(this.g)}, ${Nf(this.b)}${t===1?")":`, ${t})`}`}function NN(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Nf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function lf(t){return t=Nf(t),(t<16?"0":"")+t.toString(16)}function VV(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Wl(t,e,n,r)}function NJ(t){if(t instanceof Wl)return new Wl(t.h,t.s,t.l,t.opacity);if(t instanceof Lv||(t=K0(t)),!t)return new Wl;if(t instanceof Wl)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 Wl(o,l,c,t.opacity)}function DDe(t,e,n,r){return arguments.length===1?NJ(t):new Wl(t,e,n,r??1)}function Wl(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}J4(Wl,DDe,_J(Lv,{brighter(t){return t=t==null?_N:Math.pow(_N,t),new Wl(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?G0:Math.pow(G0,t),new Wl(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 ro(kj(t>=240?t-240:t+120,i,r),kj(t,i,r),kj(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Wl(qV(this.h),__(this.s),__(this.l),NN(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=NN(this.opacity);return`${t===1?"hsl(":"hsla("}${qV(this.h)}, ${__(this.s)*100}%, ${__(this.l)*100}%${t===1?")":`, ${t})`}`}}));function qV(t){return t=(t||0)%360,t<0?t+360:t}function __(t){return Math.max(0,Math.min(1,t||0))}function kj(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 eL=t=>()=>t;function RDe(t,e){return function(n){return t+n*e}}function FDe(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 LDe(t){return(t=+t)==1?kJ:function(e,n){return n-e?FDe(e,n,t):eL(isNaN(e)?n:e)}}function kJ(t,e){var n=e-t;return n?RDe(t,n):eL(isNaN(t)?e:t)}const GV=(function t(e){var n=LDe(e);function r(i,s){var o=n((i=uR(i)).r,(s=uR(s)).r),l=n(i.g,s.g),c=n(i.b,s.b),u=kJ(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 ODe(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 IDe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function zDe(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]=lx(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 UDe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function kN(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function BDe(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]=lx(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var dR=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Cj=new RegExp(dR.source,"g");function HDe(t){return function(){return t}}function $De(t){return function(e){return t(e)+""}}function VDe(t,e){var n=dR.lastIndex=Cj.lastIndex=0,r,i,s,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=dR.exec(t))&&(i=Cj.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:kN(r,i)})),n=Cj.lastIndex;return n<e.length&&(s=e.slice(n),l[o]?l[o]+=s:l[++o]=s),l.length<2?c[0]?$De(c[0].x):HDe(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 lx(t,e){var n=typeof e,r;return e==null||n==="boolean"?eL(e):(n==="number"?kN:n==="string"?(r=K0(e))?(e=r,GV):VDe:e instanceof K0?GV:e instanceof Date?UDe:IDe(e)?ODe:Array.isArray(e)?zDe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?BDe:kN)(t,e)}function tL(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function qDe(t,e){e===void 0&&(e=t,t=lx);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 GDe(t){return function(){return t}}function CN(t){return+t}var WV=[0,1];function Ds(t){return t}function hR(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:GDe(isNaN(e)?NaN:.5)}function WDe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function KDe(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=hR(i,r),s=n(o,s)):(r=hR(r,i),s=n(s,o)),function(l){return s(r(l))}}function YDe(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]=hR(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(l){var c=Fv(t,l,1,r)-1;return s[c](i[c](l))}}function Ov(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function HC(){var t=WV,e=WV,n=lx,r,i,s,o=Ds,l,c,u;function d(){var f=Math.min(t.length,e.length);return o!==Ds&&(o=WDe(t[0],t[f-1])),l=f>2?YDe:KDe,c=u=null,h}function h(f){return f==null||isNaN(f=+f)?s:(c||(c=l(t.map(r),e,n)))(r(o(f)))}return h.invert=function(f){return o(i((u||(u=l(e,t.map(r),kN)))(f)))},h.domain=function(f){return arguments.length?(t=Array.from(f,CN),d()):t.slice()},h.range=function(f){return arguments.length?(e=Array.from(f),d()):e.slice()},h.rangeRound=function(f){return e=Array.from(f),n=tL,d()},h.clamp=function(f){return arguments.length?(o=f?!0:Ds,d()):o!==Ds},h.interpolate=function(f){return arguments.length?(n=f,d()):n},h.unknown=function(f){return arguments.length?(s=f,h):s},function(f,p){return r=f,i=p,d()}}function nL(){return HC()(Ds,Ds)}function XDe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function AN(t,e){if(!isFinite(t)||t===0)return null;var n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Rb(t){return t=AN(Math.abs(t)),t?t[1]:NaN}function QDe(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 ZDe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var JDe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Y0(t){if(!(e=JDe.exec(t)))throw new Error("invalid format: "+t);var e;return new rL({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]})}Y0.prototype=rL.prototype;function rL(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+""}rL.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 eRe(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 TN;function tRe(t,e){var n=AN(t,e);if(!n)return TN=void 0,t.toPrecision(e);var r=n[0],i=n[1],s=i-(TN=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")+AN(t,Math.max(0,e+s-1))[0]}function KV(t,e){var n=AN(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 YV={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:XDe,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)=>KV(t*100,e),r:KV,s:tRe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function XV(t){return t}var QV=Array.prototype.map,ZV=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function nRe(t){var e=t.grouping===void 0||t.thousands===void 0?XV:QDe(QV.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?XV:ZDe(QV.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,f){h=Y0(h);var p=h.fill,x=h.align,v=h.sign,g=h.symbol,y=h.zero,_=h.width,N=h.comma,A=h.precision,C=h.trim,j=h.type;j==="n"?(N=!0,j="g"):YV[j]||(A===void 0&&(A=12),C=!0,j="g"),(y||p==="0"&&x==="=")&&(y=!0,p="0",x="=");var k=(f&&f.prefix!==void 0?f.prefix:"")+(g==="$"?n:g==="#"&&/[boxX]/.test(j)?"0"+j.toLowerCase():""),R=(g==="$"?r:/[%p]/.test(j)?o:"")+(f&&f.suffix!==void 0?f.suffix:""),M=YV[j],D=/[defgprs%]/.test(j);A=A===void 0?6:/[gprs]/.test(j)?Math.max(1,Math.min(21,A)):Math.max(0,Math.min(20,A));function G(U){var W=k,L=R,ee,ae,Y;if(j==="c")L=M(U)+L,U="";else{U=+U;var se=U<0||1/U<0;if(U=isNaN(U)?c:M(Math.abs(U),A),C&&(U=eRe(U)),se&&+U==0&&v!=="+"&&(se=!1),W=(se?v==="("?v:l:v==="-"||v==="("?"":v)+W,L=(j==="s"&&!isNaN(U)&&TN!==void 0?ZV[8+TN/3]:"")+L+(se&&v==="("?")":""),D){for(ee=-1,ae=U.length;++ee<ae;)if(Y=U.charCodeAt(ee),48>Y||Y>57){L=(Y===46?i+U.slice(ee+1):U.slice(ee))+L,U=U.slice(0,ee);break}}}N&&!y&&(U=e(U,1/0));var ce=W.length+U.length+L.length,ye=ce<_?new Array(_-ce+1).join(p):"";switch(N&&y&&(U=e(ye+U,ye.length?_-L.length:1/0),ye=""),x){case"<":U=W+U+L+ye;break;case"=":U=W+ye+U+L;break;case"^":U=ye.slice(0,ce=ye.length>>1)+W+U+L+ye.slice(ce);break;default:U=ye+W+U+L;break}return s(U)}return G.toString=function(){return h+""},G}function d(h,f){var p=Math.max(-8,Math.min(8,Math.floor(Rb(f)/3)))*3,x=Math.pow(10,-p),v=u((h=Y0(h),h.type="f",h),{suffix:ZV[8+p/3]});return function(g){return v(x*g)}}return{format:u,formatPrefix:d}}var N_,aL,CJ;rRe({thousands:",",grouping:[3],currency:["$",""]});function rRe(t){return N_=nRe(t),aL=N_.format,CJ=N_.formatPrefix,N_}function aRe(t){return Math.max(0,-Rb(Math.abs(t)))}function iRe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Rb(e)/3)))*3-Rb(Math.abs(t)))}function sRe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Rb(e)-Rb(t))+1}function AJ(t,e,n,r){var i=lR(t,e,n),s;switch(r=Y0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=iRe(i,o))&&(r.precision=s),CJ(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=sRe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=aRe(i))&&(r.precision=s-(r.type==="%")*2);break}}return aL(r)}function cm(t){var e=t.domain;return t.ticks=function(n){var r=e();return sR(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return AJ(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=oR(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 TJ(){var t=nL();return t.copy=function(){return Ov(t,TJ())},El.apply(t,arguments),cm(t)}function MJ(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,CN),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return MJ(t).unknown(e)},t=arguments.length?Array.from(t,CN):[0,1],cm(n)}function PJ(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 JV(t){return Math.log(t)}function eq(t){return Math.exp(t)}function oRe(t){return-Math.log(-t)}function lRe(t){return-Math.exp(-t)}function cRe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function uRe(t){return t===10?cRe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function dRe(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 tq(t){return(e,n)=>-t(-e,n)}function iL(t){const e=t(JV,eq),n=e.domain;let r=10,i,s;function o(){return i=dRe(r),s=uRe(r),n()[0]<0?(i=tq(i),s=tq(s),t(oRe,lRe)):t(JV,eq),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 f=i(u),p=i(d),x,v;const g=l==null?10:+l;let y=[];if(!(r%1)&&p-f<g){if(f=Math.floor(f),p=Math.ceil(p),u>0){for(;f<=p;++f)for(x=1;x<r;++x)if(v=f<0?x/s(-f):x*s(f),!(v<u)){if(v>d)break;y.push(v)}}else for(;f<=p;++f)for(x=r-1;x>=1;--x)if(v=f>0?x/s(-f):x*s(f),!(v<u)){if(v>d)break;y.push(v)}y.length*2<g&&(y=sR(u,d,g))}else y=sR(f,p,Math.min(p-f,g)).map(s);return h?y.reverse():y},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=Y0(c)).precision==null&&(c.trim=!0),c=aL(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(PJ(n(),{floor:l=>s(Math.floor(i(l))),ceil:l=>s(Math.ceil(i(l)))})),e}function jJ(){const t=iL(HC()).domain([1,10]);return t.copy=()=>Ov(t,jJ()).base(t.base()),El.apply(t,arguments),t}function nq(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function rq(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function sL(t){var e=1,n=t(nq(e),rq(e));return n.constant=function(r){return arguments.length?t(nq(e=+r),rq(e)):e},cm(n)}function EJ(){var t=sL(HC());return t.copy=function(){return Ov(t,EJ()).constant(t.constant())},El.apply(t,arguments)}function aq(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function hRe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function mRe(t){return t<0?-t*t:t*t}function oL(t){var e=t(Ds,Ds),n=1;function r(){return n===1?t(Ds,Ds):n===.5?t(hRe,mRe):t(aq(n),aq(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},cm(e)}function lL(){var t=oL(HC());return t.copy=function(){return Ov(t,lL()).exponent(t.exponent())},El.apply(t,arguments),t}function fRe(){return lL.apply(null,arguments).exponent(.5)}function iq(t){return Math.sign(t)*t*t}function pRe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function DJ(){var t=nL(),e=[0,1],n=!1,r;function i(s){var o=pRe(t(s));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(s){return t.invert(iq(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,CN)).map(iq)),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 DJ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},El.apply(i,arguments),cm(i)}function RJ(){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]=yDe(t,o/l);return s}function s(o){return o==null||isNaN(o=+o)?r:e[Fv(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(Vh),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 RJ().domain(t).range(e).unknown(r)},El.apply(s,arguments)}function FJ(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function o(c){return c!=null&&c<=c?i[Fv(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 FJ().domain([t,e]).range(i).unknown(s)},El.apply(cm(o),arguments)}function LJ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[Fv(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 LJ().domain(t).range(e).unknown(n)},El.apply(i,arguments)}const Aj=new Date,Tj=new Date;function Si(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=>Si(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)=>(Aj.setTime(+s),Tj.setTime(+o),t(Aj),t(Tj),Math.floor(n(Aj,Tj))),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 MN=Si(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);MN.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Si(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):MN);MN.range;const $u=1e3,gl=$u*60,Vu=gl*60,ud=Vu*24,cL=ud*7,sq=ud*30,Mj=ud*365,cf=Si(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*$u)},(t,e)=>(e-t)/$u,t=>t.getUTCSeconds());cf.range;const uL=Si(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*$u)},(t,e)=>{t.setTime(+t+e*gl)},(t,e)=>(e-t)/gl,t=>t.getMinutes());uL.range;const dL=Si(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*gl)},(t,e)=>(e-t)/gl,t=>t.getUTCMinutes());dL.range;const hL=Si(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*$u-t.getMinutes()*gl)},(t,e)=>{t.setTime(+t+e*Vu)},(t,e)=>(e-t)/Vu,t=>t.getHours());hL.range;const mL=Si(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Vu)},(t,e)=>(e-t)/Vu,t=>t.getUTCHours());mL.range;const Iv=Si(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*gl)/ud,t=>t.getDate()-1);Iv.range;const $C=Si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ud,t=>t.getUTCDate()-1);$C.range;const OJ=Si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ud,t=>Math.floor(t/ud));OJ.range;function dp(t){return Si(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())*gl)/cL)}const VC=dp(0),PN=dp(1),gRe=dp(2),bRe=dp(3),Fb=dp(4),xRe=dp(5),yRe=dp(6);VC.range;PN.range;gRe.range;bRe.range;Fb.range;xRe.range;yRe.range;function hp(t){return Si(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)/cL)}const qC=hp(0),jN=hp(1),vRe=hp(2),wRe=hp(3),Lb=hp(4),SRe=hp(5),_Re=hp(6);qC.range;jN.range;vRe.range;wRe.range;Lb.range;SRe.range;_Re.range;const fL=Si(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());fL.range;const pL=Si(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());pL.range;const dd=Si(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());dd.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Si(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)});dd.range;const hd=Si(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());hd.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Si(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)});hd.range;function IJ(t,e,n,r,i,s){const o=[[cf,1,$u],[cf,5,5*$u],[cf,15,15*$u],[cf,30,30*$u],[s,1,gl],[s,5,5*gl],[s,15,15*gl],[s,30,30*gl],[i,1,Vu],[i,3,3*Vu],[i,6,6*Vu],[i,12,12*Vu],[r,1,ud],[r,2,2*ud],[n,1,cL],[e,1,sq],[e,3,3*sq],[t,1,Mj]];function l(u,d,h){const f=d<u;f&&([u,d]=[d,u]);const p=h&&typeof h.range=="function"?h:c(u,d,h),x=p?p.range(u,+d+1):[];return f?x.reverse():x}function c(u,d,h){const f=Math.abs(d-u)/h,p=X4(([,,g])=>g).right(o,f);if(p===o.length)return t.every(lR(u/Mj,d/Mj,h));if(p===0)return MN.every(Math.max(lR(u,d,h),1));const[x,v]=o[f/o[p-1][2]<o[p][2]/f?p-1:p];return x.every(v)}return[l,c]}const[NRe,kRe]=IJ(hd,pL,qC,OJ,mL,dL),[CRe,ARe]=IJ(dd,fL,VC,Iv,hL,uL);function Pj(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 jj(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 Ty(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function TRe(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=My(i),d=Py(i),h=My(s),f=Py(s),p=My(o),x=Py(o),v=My(l),g=Py(l),y=My(c),_=Py(c),N={a:Y,A:se,b:ce,B:ye,c:null,d:hq,e:hq,f:QRe,g:oFe,G:cFe,H:KRe,I:YRe,j:XRe,L:zJ,m:ZRe,M:JRe,p:Z,q:ue,Q:pq,s:gq,S:eFe,u:tFe,U:nFe,V:rFe,w:aFe,W:iFe,x:null,X:null,y:sFe,Y:lFe,Z:uFe,"%":fq},A={a:pe,A:be,b:Ee,B:$,c:null,d:mq,e:mq,f:fFe,g:NFe,G:CFe,H:dFe,I:hFe,j:mFe,L:BJ,m:pFe,M:gFe,p:K,q:T,Q:pq,s:gq,S:bFe,u:xFe,U:yFe,V:vFe,w:wFe,W:SFe,x:null,X:null,y:_Fe,Y:kFe,Z:AFe,"%":fq},C={a:D,A:G,b:U,B:W,c:L,d:uq,e:uq,f:VRe,g:cq,G:lq,H:dq,I:dq,j:URe,L:$Re,m:zRe,M:BRe,p:M,q:IRe,Q:GRe,s:WRe,S:HRe,u:DRe,U:RRe,V:FRe,w:ERe,W:LRe,x:ee,X:ae,y:cq,Y:lq,Z:ORe,"%":qRe};N.x=j(n,N),N.X=j(r,N),N.c=j(e,N),A.x=j(n,A),A.X=j(r,A),A.c=j(e,A);function j(E,O){return function(q){var B=[],re=-1,z=0,V=E.length,te,Q,ne;for(q instanceof Date||(q=new Date(+q));++re<V;)E.charCodeAt(re)===37&&(B.push(E.slice(z,re)),(Q=oq[te=E.charAt(++re)])!=null?te=E.charAt(++re):Q=te==="e"?" ":"0",(ne=O[te])&&(te=ne(q,Q)),B.push(te),z=re+1);return B.push(E.slice(z,re)),B.join("")}}function k(E,O){return function(q){var B=Ty(1900,void 0,1),re=R(B,E,q+="",0),z,V;if(re!=q.length)return null;if("Q"in B)return new Date(B.Q);if("s"in B)return new Date(B.s*1e3+("L"in B?B.L:0));if(O&&!("Z"in B)&&(B.Z=0),"p"in B&&(B.H=B.H%12+B.p*12),B.m===void 0&&(B.m="q"in B?B.q:0),"V"in B){if(B.V<1||B.V>53)return null;"w"in B||(B.w=1),"Z"in B?(z=jj(Ty(B.y,0,1)),V=z.getUTCDay(),z=V>4||V===0?jN.ceil(z):jN(z),z=$C.offset(z,(B.V-1)*7),B.y=z.getUTCFullYear(),B.m=z.getUTCMonth(),B.d=z.getUTCDate()+(B.w+6)%7):(z=Pj(Ty(B.y,0,1)),V=z.getDay(),z=V>4||V===0?PN.ceil(z):PN(z),z=Iv.offset(z,(B.V-1)*7),B.y=z.getFullYear(),B.m=z.getMonth(),B.d=z.getDate()+(B.w+6)%7)}else("W"in B||"U"in B)&&("w"in B||(B.w="u"in B?B.u%7:"W"in B?1:0),V="Z"in B?jj(Ty(B.y,0,1)).getUTCDay():Pj(Ty(B.y,0,1)).getDay(),B.m=0,B.d="W"in B?(B.w+6)%7+B.W*7-(V+5)%7:B.w+B.U*7-(V+6)%7);return"Z"in B?(B.H+=B.Z/100|0,B.M+=B.Z%100,jj(B)):Pj(B)}}function R(E,O,q,B){for(var re=0,z=O.length,V=q.length,te,Q;re<z;){if(B>=V)return-1;if(te=O.charCodeAt(re++),te===37){if(te=O.charAt(re++),Q=C[te in oq?O.charAt(re++):te],!Q||(B=Q(E,q,B))<0)return-1}else if(te!=q.charCodeAt(B++))return-1}return B}function M(E,O,q){var B=u.exec(O.slice(q));return B?(E.p=d.get(B[0].toLowerCase()),q+B[0].length):-1}function D(E,O,q){var B=p.exec(O.slice(q));return B?(E.w=x.get(B[0].toLowerCase()),q+B[0].length):-1}function G(E,O,q){var B=h.exec(O.slice(q));return B?(E.w=f.get(B[0].toLowerCase()),q+B[0].length):-1}function U(E,O,q){var B=y.exec(O.slice(q));return B?(E.m=_.get(B[0].toLowerCase()),q+B[0].length):-1}function W(E,O,q){var B=v.exec(O.slice(q));return B?(E.m=g.get(B[0].toLowerCase()),q+B[0].length):-1}function L(E,O,q){return R(E,e,O,q)}function ee(E,O,q){return R(E,n,O,q)}function ae(E,O,q){return R(E,r,O,q)}function Y(E){return o[E.getDay()]}function se(E){return s[E.getDay()]}function ce(E){return c[E.getMonth()]}function ye(E){return l[E.getMonth()]}function Z(E){return i[+(E.getHours()>=12)]}function ue(E){return 1+~~(E.getMonth()/3)}function pe(E){return o[E.getUTCDay()]}function be(E){return s[E.getUTCDay()]}function Ee(E){return c[E.getUTCMonth()]}function $(E){return l[E.getUTCMonth()]}function K(E){return i[+(E.getUTCHours()>=12)]}function T(E){return 1+~~(E.getUTCMonth()/3)}return{format:function(E){var O=j(E+="",N);return O.toString=function(){return E},O},parse:function(E){var O=k(E+="",!1);return O.toString=function(){return E},O},utcFormat:function(E){var O=j(E+="",A);return O.toString=function(){return E},O},utcParse:function(E){var O=k(E+="",!0);return O.toString=function(){return E},O}}}var oq={"-":"",_:" ",0:"0"},Oi=/^\s*\d+/,MRe=/^%/,PRe=/[\\^$*+?|[\]().{}]/g;function yr(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 jRe(t){return t.replace(PRe,"\\$&")}function My(t){return new RegExp("^(?:"+t.map(jRe).join("|")+")","i")}function Py(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function ERe(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function DRe(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function RRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function FRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function LRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function lq(t,e,n){var r=Oi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function cq(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function ORe(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 IRe(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function zRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function uq(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function URe(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function dq(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function BRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function HRe(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function $Re(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function VRe(t,e,n){var r=Oi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function qRe(t,e,n){var r=MRe.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function GRe(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function WRe(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function hq(t,e){return yr(t.getDate(),e,2)}function KRe(t,e){return yr(t.getHours(),e,2)}function YRe(t,e){return yr(t.getHours()%12||12,e,2)}function XRe(t,e){return yr(1+Iv.count(dd(t),t),e,3)}function zJ(t,e){return yr(t.getMilliseconds(),e,3)}function QRe(t,e){return zJ(t,e)+"000"}function ZRe(t,e){return yr(t.getMonth()+1,e,2)}function JRe(t,e){return yr(t.getMinutes(),e,2)}function eFe(t,e){return yr(t.getSeconds(),e,2)}function tFe(t){var e=t.getDay();return e===0?7:e}function nFe(t,e){return yr(VC.count(dd(t)-1,t),e,2)}function UJ(t){var e=t.getDay();return e>=4||e===0?Fb(t):Fb.ceil(t)}function rFe(t,e){return t=UJ(t),yr(Fb.count(dd(t),t)+(dd(t).getDay()===4),e,2)}function aFe(t){return t.getDay()}function iFe(t,e){return yr(PN.count(dd(t)-1,t),e,2)}function sFe(t,e){return yr(t.getFullYear()%100,e,2)}function oFe(t,e){return t=UJ(t),yr(t.getFullYear()%100,e,2)}function lFe(t,e){return yr(t.getFullYear()%1e4,e,4)}function cFe(t,e){var n=t.getDay();return t=n>=4||n===0?Fb(t):Fb.ceil(t),yr(t.getFullYear()%1e4,e,4)}function uFe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+yr(e/60|0,"0",2)+yr(e%60,"0",2)}function mq(t,e){return yr(t.getUTCDate(),e,2)}function dFe(t,e){return yr(t.getUTCHours(),e,2)}function hFe(t,e){return yr(t.getUTCHours()%12||12,e,2)}function mFe(t,e){return yr(1+$C.count(hd(t),t),e,3)}function BJ(t,e){return yr(t.getUTCMilliseconds(),e,3)}function fFe(t,e){return BJ(t,e)+"000"}function pFe(t,e){return yr(t.getUTCMonth()+1,e,2)}function gFe(t,e){return yr(t.getUTCMinutes(),e,2)}function bFe(t,e){return yr(t.getUTCSeconds(),e,2)}function xFe(t){var e=t.getUTCDay();return e===0?7:e}function yFe(t,e){return yr(qC.count(hd(t)-1,t),e,2)}function HJ(t){var e=t.getUTCDay();return e>=4||e===0?Lb(t):Lb.ceil(t)}function vFe(t,e){return t=HJ(t),yr(Lb.count(hd(t),t)+(hd(t).getUTCDay()===4),e,2)}function wFe(t){return t.getUTCDay()}function SFe(t,e){return yr(jN.count(hd(t)-1,t),e,2)}function _Fe(t,e){return yr(t.getUTCFullYear()%100,e,2)}function NFe(t,e){return t=HJ(t),yr(t.getUTCFullYear()%100,e,2)}function kFe(t,e){return yr(t.getUTCFullYear()%1e4,e,4)}function CFe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Lb(t):Lb.ceil(t),yr(t.getUTCFullYear()%1e4,e,4)}function AFe(){return"+0000"}function fq(){return"%"}function pq(t){return+t}function gq(t){return Math.floor(+t/1e3)}var Mg,$J,VJ;TFe({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 TFe(t){return Mg=TRe(t),$J=Mg.format,Mg.parse,VJ=Mg.utcFormat,Mg.utcParse,Mg}function MFe(t){return new Date(t)}function PFe(t){return t instanceof Date?+t:+new Date(+t)}function gL(t,e,n,r,i,s,o,l,c,u){var d=nL(),h=d.invert,f=d.domain,p=u(".%L"),x=u(":%S"),v=u("%I:%M"),g=u("%I %p"),y=u("%a %d"),_=u("%b %d"),N=u("%B"),A=u("%Y");function C(j){return(c(j)<j?p:l(j)<j?x:o(j)<j?v:s(j)<j?g:r(j)<j?i(j)<j?y:_:n(j)<j?N:A)(j)}return d.invert=function(j){return new Date(h(j))},d.domain=function(j){return arguments.length?f(Array.from(j,PFe)):f().map(MFe)},d.ticks=function(j){var k=f();return t(k[0],k[k.length-1],j??10)},d.tickFormat=function(j,k){return k==null?C:u(k)},d.nice=function(j){var k=f();return(!j||typeof j.range!="function")&&(j=e(k[0],k[k.length-1],j??10)),j?f(PJ(k,j)):d},d.copy=function(){return Ov(d,gL(t,e,n,r,i,s,o,l,c,u))},d}function jFe(){return El.apply(gL(CRe,ARe,dd,fL,VC,Iv,hL,uL,cf,$J).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function EFe(){return El.apply(gL(NRe,kRe,hd,pL,qC,$C,mL,dL,cf,VJ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function GC(){var t=0,e=1,n,r,i,s,o=Ds,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(f){var p,x;return arguments.length?([p,x]=f,o=h(p,x),u):[o(0),o(1)]}}return u.range=d(lx),u.rangeRound=d(tL),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 um(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function qJ(){var t=cm(GC()(Ds));return t.copy=function(){return um(t,qJ())},yd.apply(t,arguments)}function GJ(){var t=iL(GC()).domain([1,10]);return t.copy=function(){return um(t,GJ()).base(t.base())},yd.apply(t,arguments)}function WJ(){var t=sL(GC());return t.copy=function(){return um(t,WJ()).constant(t.constant())},yd.apply(t,arguments)}function bL(){var t=oL(GC());return t.copy=function(){return um(t,bL()).exponent(t.exponent())},yd.apply(t,arguments)}function DFe(){return bL.apply(null,arguments).exponent(.5)}function KJ(){var t=[],e=Ds;function n(r){if(r!=null&&!isNaN(r=+r))return e((Fv(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(Vh),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)=>xDe(t,s/r))},n.copy=function(){return KJ(e).domain(t)},yd.apply(n,arguments)}function WC(){var t=0,e=.5,n=1,r=1,i,s,o,l,c,u=Ds,d,h=!1,f;function p(v){return isNaN(v=+v)?f:(v=.5+((v=+d(v))-s)*(r*v<r*s?l:c),u(h?Math.max(0,Math.min(1,v)):v))}p.domain=function(v){return arguments.length?([t,e,n]=v,i=d(t=+t),s=d(e=+e),o=d(n=+n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,p):[t,e,n]},p.clamp=function(v){return arguments.length?(h=!!v,p):h},p.interpolator=function(v){return arguments.length?(u=v,p):u};function x(v){return function(g){var y,_,N;return arguments.length?([y,_,N]=g,u=qDe(v,[y,_,N]),p):[u(0),u(.5),u(1)]}}return p.range=x(lx),p.rangeRound=x(tL),p.unknown=function(v){return arguments.length?(f=v,p):f},function(v){return d=v,i=v(t),s=v(e),o=v(n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,p}}function YJ(){var t=cm(WC()(Ds));return t.copy=function(){return um(t,YJ())},yd.apply(t,arguments)}function XJ(){var t=iL(WC()).domain([.1,1,10]);return t.copy=function(){return um(t,XJ()).base(t.base())},yd.apply(t,arguments)}function QJ(){var t=sL(WC());return t.copy=function(){return um(t,QJ()).constant(t.constant())},yd.apply(t,arguments)}function xL(){var t=oL(WC());return t.copy=function(){return um(t,xL()).exponent(t.exponent())},yd.apply(t,arguments)}function RFe(){return xL.apply(null,arguments).exponent(.5)}const Uy=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:Z4,scaleDiverging:YJ,scaleDivergingLog:XJ,scaleDivergingPow:xL,scaleDivergingSqrt:RFe,scaleDivergingSymlog:QJ,scaleIdentity:MJ,scaleImplicit:cR,scaleLinear:TJ,scaleLog:jJ,scaleOrdinal:Q4,scalePoint:wDe,scalePow:lL,scaleQuantile:RJ,scaleQuantize:FJ,scaleRadial:DJ,scaleSequential:qJ,scaleSequentialLog:GJ,scaleSequentialPow:bL,scaleSequentialQuantile:KJ,scaleSequentialSqrt:DFe,scaleSequentialSymlog:WJ,scaleSqrt:fRe,scaleSymlog:EJ,scaleThreshold:LJ,scaleTime:jFe,scaleUtc:EFe,tickFormat:AJ},Symbol.toStringTag,{value:"Module"}));var vd=t=>t.chartData,KC=mt([vd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),yL=(t,e,n,r)=>r?KC(t):vd(t),ZJ=(t,e,n)=>n?KC(t):vd(t);function md(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(Pn(e)&&Pn(n))return!0}return!1}function bq(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function JJ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(Pn(n))i=n;else if(typeof n=="function")return;if(Pn(r))s=r;else if(typeof r=="function")return;var o=[i,s];if(md(o))return o}}function FFe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(md(r))return bq(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(Vt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&A7.test(i)){var c=A7.exec(i);if(c==null||c[1]==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(Vt(s))l=s;else if(typeof s=="function")try{e!=null&&(l=s(e?.[1]))}catch{}else if(typeof s=="string"&&T7.test(s)){var d=T7.exec(s);if(d==null||d[1]==null||e==null)l=void 0;else{var h=+d[1];l=e[1]+h}}else l=e?.[1];var f=[o,l];if(md(f))return e==null?f:bq(f,e,n)}}}var cx=1e9,LFe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},wL,pa=!0,Tl="[DecimalError] ",kf=Tl+"Invalid argument: ",vL=Tl+"Exponent out of range: ",ux=Math.floor,Xm=Math.pow,OFe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Mo,ji=1e7,da=7,eee=9007199254740991,EN=ux(eee/da),Wt={};Wt.absoluteValue=Wt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Wt.comparedTo=Wt.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};Wt.decimalPlaces=Wt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*da;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Wt.dividedBy=Wt.div=function(t){return Xu(this,new this.constructor(t))};Wt.dividedToIntegerBy=Wt.idiv=function(t){var e=this,n=e.constructor;return Qr(Xu(e,new n(t),0,1),n.precision)};Wt.equals=Wt.eq=function(t){return!this.cmp(t)};Wt.exponent=function(){return li(this)};Wt.greaterThan=Wt.gt=function(t){return this.cmp(t)>0};Wt.greaterThanOrEqualTo=Wt.gte=function(t){return this.cmp(t)>=0};Wt.isInteger=Wt.isint=function(){return this.e>this.d.length-2};Wt.isNegative=Wt.isneg=function(){return this.s<0};Wt.isPositive=Wt.ispos=function(){return this.s>0};Wt.isZero=function(){return this.s===0};Wt.lessThan=Wt.lt=function(t){return this.cmp(t)<0};Wt.lessThanOrEqualTo=Wt.lte=function(t){return this.cmp(t)<1};Wt.logarithm=Wt.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(Mo))throw Error(Tl+"NaN");if(n.s<1)throw Error(Tl+(n.s?"NaN":"-Infinity"));return n.eq(Mo)?new r(0):(pa=!1,e=Xu(X0(n,s),X0(t,s),s),pa=!0,Qr(e,i))};Wt.minus=Wt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?ree(e,t):tee(e,(t.s=-t.s,t))};Wt.modulo=Wt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(Tl+"NaN");return n.s?(pa=!1,e=Xu(n,t,0,1).times(t),pa=!0,n.minus(e)):Qr(new r(n),i)};Wt.naturalExponential=Wt.exp=function(){return nee(this)};Wt.naturalLogarithm=Wt.ln=function(){return X0(this)};Wt.negated=Wt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Wt.plus=Wt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?tee(e,t):ree(e,(t.s=-t.s,t))};Wt.precision=Wt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(kf+t);if(e=li(i)+1,r=i.d.length-1,n=r*da+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};Wt.squareRoot=Wt.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(Tl+"NaN")}for(t=li(l),pa=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=jc(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=ux((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(Xu(l,s,o+2)).times(.5),jc(s.d).slice(0,o)===(e=jc(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Qr(s,n+1,0),s.times(s).eq(l)){r=s;break}}else if(e!="9999")break;o+=4}return pa=!0,Qr(r,n)};Wt.times=Wt.mul=function(t){var e,n,r,i,s,o,l,c,u,d=this,h=d.constructor,f=d.d,p=(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=f.length,u=p.length,c<u&&(s=f,f=p,p=s,o=c,c=u,u=o),s=[],o=c+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=s[i]+p[r]*f[i-r-1]+e,s[i--]=l%ji|0,e=l/ji|0;s[i]=(s[i]+e)%ji|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,pa?Qr(t,h.precision):t};Wt.toDecimalPlaces=Wt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Bc(t,0,cx),e===void 0?e=r.rounding:Bc(e,0,8),Qr(n,t+li(n)+1,e))};Wt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Jf(r,!0):(Bc(t,0,cx),e===void 0?e=i.rounding:Bc(e,0,8),r=Qr(new i(r),t+1,e),n=Jf(r,!0,t+1)),n};Wt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Jf(i):(Bc(t,0,cx),e===void 0?e=s.rounding:Bc(e,0,8),r=Qr(new s(i),t+li(i)+1,e),n=Jf(r.abs(),!1,t+li(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Wt.toInteger=Wt.toint=function(){var t=this,e=t.constructor;return Qr(new e(t),li(t)+1,e.rounding)};Wt.toNumber=function(){return+this};Wt.toPower=Wt.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(Mo);if(l=new c(l),!l.s){if(t.s<1)throw Error(Tl+"Infinity");return l}if(l.eq(Mo))return l;if(r=c.precision,t.eq(Mo))return Qr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,s=l.s,o){if((n=d<0?-d:d)<=eee){for(i=new c(Mo),e=Math.ceil(r/da+4),pa=!1;n%2&&(i=i.times(l),yq(i.d,e)),n=ux(n/2),n!==0;)l=l.times(l),yq(l.d,e);return pa=!0,t.s<0?new c(Mo).div(i):Qr(i,r)}}else if(s<0)throw Error(Tl+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,pa=!1,i=t.times(X0(l,r+u)),pa=!0,i=nee(i),i.s=s,i};Wt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=li(i),r=Jf(i,n<=s.toExpNeg||n>=s.toExpPos)):(Bc(t,1,cx),e===void 0?e=s.rounding:Bc(e,0,8),i=Qr(new s(i),t,e),n=li(i),r=Jf(i,t<=n||n<=s.toExpNeg,t)),r};Wt.toSignificantDigits=Wt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Bc(t,1,cx),e===void 0?e=r.rounding:Bc(e,0,8)),Qr(new r(n),t,e)};Wt.toString=Wt.valueOf=Wt.val=Wt.toJSON=Wt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=li(t),n=t.constructor;return Jf(t,e<=n.toExpNeg||e>=n.toExpPos)};function tee(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)),pa?Qr(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/da),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)/ji|0,c[s]%=ji;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,pa?Qr(e,h):e}function Bc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(kf+t)}function jc(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=da-r.length,n&&(s+=uh(n)),s+=r;o=t[e],r=o+"",n=da-r.length,n&&(s+=uh(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}var Xu=(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%ji|0,o=s/ji|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*ji+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o){var l,c,u,d,h,f,p,x,v,g,y,_,N,A,C,j,k,R,M=r.constructor,D=r.s==i.s?1:-1,G=r.d,U=i.d;if(!r.s)return new M(r);if(!i.s)throw Error(Tl+"Division by zero");for(c=r.e-i.e,k=U.length,C=G.length,p=new M(D),x=p.d=[],u=0;U[u]==(G[u]||0);)++u;if(U[u]>(G[u]||0)&&--c,s==null?_=s=M.precision:o?_=s+(li(r)-li(i))+1:_=s,_<0)return new M(0);if(_=_/da+2|0,u=0,k==1)for(d=0,U=U[0],_++;(u<C||d)&&_--;u++)N=d*ji+(G[u]||0),x[u]=N/U|0,d=N%U|0;else{for(d=ji/(U[0]+1)|0,d>1&&(U=t(U,d),G=t(G,d),k=U.length,C=G.length),A=k,v=G.slice(0,k),g=v.length;g<k;)v[g++]=0;R=U.slice(),R.unshift(0),j=U[0],U[1]>=ji/2&&++j;do d=0,l=e(U,v,k,g),l<0?(y=v[0],k!=g&&(y=y*ji+(v[1]||0)),d=y/j|0,d>1?(d>=ji&&(d=ji-1),h=t(U,d),f=h.length,g=v.length,l=e(h,v,f,g),l==1&&(d--,n(h,k<f?R:U,f))):(d==0&&(l=d=1),h=U.slice()),f=h.length,f<g&&h.unshift(0),n(v,h,g),l==-1&&(g=v.length,l=e(U,v,k,g),l<1&&(d++,n(v,k<g?R:U,g))),g=v.length):l===0&&(d++,v=[0]),x[u++]=d,l&&v[0]?v[g++]=G[A]||0:(v=[G[A]],g=1);while((A++<C||v[0]!==void 0)&&_--)}return x[0]||x.shift(),p.e=c,Qr(p,o?s+li(p)+1:s)}})();function nee(t,e){var n,r,i,s,o,l,c=0,u=0,d=t.constructor,h=d.precision;if(li(t)>16)throw Error(vL+li(t));if(!t.s)return new d(Mo);for(pa=!1,l=h,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Xm(2,u))/Math.LN10*2+5|0,l+=r,n=i=s=new d(Mo),d.precision=l;;){if(i=Qr(i.times(t),l),n=n.times(++c),o=s.plus(Xu(i,n,l)),jc(o.d).slice(0,l)===jc(s.d).slice(0,l)){for(;u--;)s=Qr(s.times(s),l);return d.precision=h,e==null?(pa=!0,Qr(s,h)):s}s=o}}function li(t){for(var e=t.e*da,n=t.d[0];n>=10;n/=10)e++;return e}function Ej(t,e,n){if(e>t.LN10.sd())throw pa=!0,n&&(t.precision=n),Error(Tl+"LN10 precision limit exceeded");return Qr(new t(t.LN10),e)}function uh(t){for(var e="";t--;)e+="0";return e}function X0(t,e){var n,r,i,s,o,l,c,u,d,h=1,f=10,p=t,x=p.d,v=p.constructor,g=v.precision;if(p.s<1)throw Error(Tl+(p.s?"NaN":"-Infinity"));if(p.eq(Mo))return new v(0);if(e==null?(pa=!1,u=g):u=e,p.eq(10))return e==null&&(pa=!0),Ej(v,u);if(u+=f,v.precision=u,n=jc(x),r=n.charAt(0),s=li(p),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=jc(p.d),r=n.charAt(0),h++;s=li(p),r>1?(p=new v("0."+n),s++):p=new v(r+"."+n.slice(1))}else return c=Ej(v,u+2,g).times(s+""),p=X0(new v(r+"."+n.slice(1)),u-f).plus(c),v.precision=g,e==null?(pa=!0,Qr(p,g)):p;for(l=o=p=Xu(p.minus(Mo),p.plus(Mo),u),d=Qr(p.times(p),u),i=3;;){if(o=Qr(o.times(d),u),c=l.plus(Xu(o,new v(i),u)),jc(c.d).slice(0,u)===jc(l.d).slice(0,u))return l=l.times(2),s!==0&&(l=l.plus(Ej(v,u+2,g).times(s+""))),l=Xu(l,new v(h),u),v.precision=g,e==null?(pa=!0,Qr(l,g)):l;l=c,i+=2}}function xq(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=ux(n/da),t.d=[],r=(n+1)%da,n<0&&(r+=da),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=da;r<i;)t.d.push(+e.slice(r,r+=da));e=e.slice(r),r=da-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),pa&&(t.e>EN||t.e<-EN))throw Error(vL+n)}else t.s=0,t.e=0,t.d=[0];return t}function Qr(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+=da,i=e,u=h[d=0];else{if(d=Math.ceil((r+1)/da),s=h.length,d>=s)return t;for(u=s=h[d],o=1;s>=10;s/=10)o++;r%=da,i=r-da+o}if(n!==void 0&&(s=Xm(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/Xm(10,o-i):0:h[d-1])%10&1||n==(t.s<0?8:7))),e<1||!h[0])return c?(s=li(t),h.length=1,e=e-s-1,h[0]=Xm(10,(da-e%da)%da),t.e=ux(-e/da)||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=Xm(10,da-r),h[d]=i>0?(u/Xm(10,o-i)%Xm(10,i)|0)*s:0),c)for(;;)if(d==0){(h[0]+=s)==ji&&(h[0]=1,++t.e);break}else{if(h[d]+=s,h[d]!=ji)break;h[d--]=0,s=1}for(r=h.length;h[--r]===0;)h.pop();if(pa&&(t.e>EN||t.e<-EN))throw Error(vL+li(t));return t}function ree(t,e){var n,r,i,s,o,l,c,u,d,h,f=t.constructor,p=f.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new f(t),pa?Qr(e,p):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(p/da),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]=ji-1;--c[s],c[i]+=ji}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,pa?Qr(e,p):e):new f(0)}function Jf(t,e,n){var r,i=li(t),s=jc(t.d),o=s.length;return e?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+uh(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+uh(-i-1)+s,n&&(r=n-o)>0&&(s+=uh(r))):i>=o?(s+=uh(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+uh(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=uh(r))),t.s<0?"-"+s:s}function yq(t,e){if(t.length>e)return t.length=e,!0}function aee(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(kf+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 xq(o,s.toString())}else if(typeof s!="string")throw Error(kf+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,OFe.test(s))xq(o,s);else throw Error(kf+s)}if(i.prototype=Wt,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=aee,i.config=i.set=IFe,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 IFe(t){if(!t||typeof t!="object")throw Error(Tl+"Object expected");var e,n,r,i=["precision",1,cx,"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(ux(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(kf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(kf+n+": "+r);return this}var wL=aee(LFe);Mo=new wL(1);const jr=wL;function iee(t){var e;return t===0?e=1:e=Math.floor(new jr(t).abs().log(10).toNumber())+1,e}function see(t,e,n){for(var r=new jr(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var oee=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},lee=(t,e,n)=>{if(t.lte(0))return new jr(0);var r=iee(t.toNumber()),i=new jr(10).pow(r),s=t.div(i),o=r!==1?.05:.1,l=new jr(Math.ceil(s.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new jr(c.toNumber()):new jr(Math.ceil(c.toNumber()))},zFe=(t,e,n)=>{var r=new jr(1),i=new jr(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new jr(10).pow(iee(t)-1),i=new jr(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new jr(Math.floor(t)))}else t===0?i=new jr(Math.floor((e-1)/2)):n||(i=new jr(Math.floor(t)));for(var o=Math.floor((e-1)/2),l=[],c=0;c<e;c++)l.push(i.add(new jr(c-o).mul(r)).toNumber());return l},cee=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 jr(0),tickMin:new jr(0),tickMax:new jr(0)};var o=lee(new jr(n).sub(e).div(r-1),i,s),l;e<=0&&n>=0?l=new jr(0):(l=new jr(e).add(n).div(2),l=l.sub(new jr(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new jr(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?cee(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 jr(c).mul(o)),tickMax:l.add(new jr(u).mul(o))})},UFe=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]=oee([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),c];return n>r?u.reverse():u}if(l===c)return zFe(l,i,s);var{step:d,tickMin:h,tickMax:f}=cee(l,c,o,s,0),p=see(h,f.add(new jr(.1).mul(d)),d);return n>r?p.reverse():p},BFe=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=oee([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=lee(new jr(l).sub(o).div(c-1),s,0),d=[...see(new jr(o),new jr(l),u),l];return s===!1&&(d=d.map(h=>Math.round(h))),r>i?d.reverse():d},uee=t=>t.rootProps.maxBarSize,HFe=t=>t.rootProps.barGap,dee=t=>t.rootProps.barCategoryGap,$Fe=t=>t.rootProps.barSize,zv=t=>t.rootProps.stackOffset,hee=t=>t.rootProps.reverseStackOrder,SL=t=>t.options.chartName,_L=t=>t.rootProps.syncId,mee=t=>t.rootProps.syncMethod,NL=t=>t.options.eventEmitter,VFe=t=>t.rootProps.baseValue,Oa={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Hm={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},xc={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},YC=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e};function XC(t,e,n){if(n!=="auto")return n;if(t!=null)return lc(t,e)?"category":"number"}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 DN(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){qFe(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 qFe(t,e,n){return(e=GFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GFe(t){var e=WFe(t,"string");return typeof e=="symbol"?e:e+""}function WFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var wq={allowDataOverflow:Hm.allowDataOverflow,allowDecimals:Hm.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Hm.angleAxisId,includeHidden:!1,name:void 0,reversed:Hm.reversed,scale:Hm.scale,tick:Hm.tick,tickCount:void 0,ticks:void 0,type:Hm.type,unit:void 0},Sq={allowDataOverflow:xc.allowDataOverflow,allowDecimals:xc.allowDecimals,allowDuplicatedCategory:xc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:xc.radiusAxisId,includeHidden:xc.includeHidden,name:void 0,reversed:xc.reversed,scale:xc.scale,tick:xc.tick,tickCount:xc.tickCount,ticks:void 0,type:xc.type,unit:void 0},KFe=(t,e)=>{if(e!=null)return t.polarAxis.angleAxis[e]},kL=mt([KFe,XZ],(t,e)=>{var n;if(t!=null)return t;var r=(n=XC(e,"angleAxis",wq.type))!==null&&n!==void 0?n:"category";return DN(DN({},wq),{},{type:r})}),YFe=(t,e)=>t.polarAxis.radiusAxis[e],CL=mt([YFe,XZ],(t,e)=>{var n;if(t!=null)return t;var r=(n=XC(e,"radiusAxis",Sq.type))!==null&&n!==void 0?n:"category";return DN(DN({},Sq),{},{type:r})}),QC=t=>t.polarOptions,AL=mt([bd,xd,vi],fJ),fee=mt([QC,AL],(t,e)=>{if(t!=null)return vs(t.innerRadius,e,0)}),pee=mt([QC,AL],(t,e)=>{if(t!=null)return vs(t.outerRadius,e,e*.8)}),XFe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},gee=mt([QC],XFe);mt([kL,gee],YC);var bee=mt([AL,fee,pee],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});mt([CL,bee],YC);var xee=mt([ur,QC,fee,pee,bd,xd],(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:vs(o,i,i/2),cy:vs(l,s,s/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Na=(t,e)=>e,Uv=(t,e,n)=>n;function ZC(t){return t?.id}function yee(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=ZC(l);u.forEach((h,f)=>{var p=s==null||i?f:String(Nr(h,s,null)),x=Nr(h,l.dataKey,0),v;o.has(p)?v=o.get(p):v={},Object.assign(v,{[d]:x}),o.set(p,v)})}}),Array.from(o.values())}function JC(t){return"stackId"in t&&t.stackId!=null&&t.dataKey!=null}var eA=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function tA(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function QFe(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 Ii=t=>{var e=ur(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},dx=t=>t.tooltip.settings.axisId;function ZFe(t){if(t in Uy)return Uy[t]();var e="scale".concat(Cv(t));if(e in Uy)return Uy[e]()}function _q(t){var e=t.ticks,n=t.bandwidth,r=t.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>t.domain(),range:(function(s){function o(){return s.apply(this,arguments)}return o.toString=function(){return s.toString()},o})(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(s){var o=i[0],l=i[1];return o<=l?s>=o&&s<=l:s>=l&&s<=o},bandwidth:n?()=>n.call(t):void 0,ticks:e?s=>e.call(t,s):void 0,map:(s,o)=>{var l=t(s);if(l!=null){if(t.bandwidth&&o!==null&&o!==void 0&&o.position){var c=t.bandwidth();switch(o.position){case"middle":l+=c/2;break;case"end":l+=c;break}}return l}}}}function Nq(t,e,n){if(typeof t=="function")return _q(t.copy().domain(e).range(n));if(t!=null){var r=ZFe(t);if(r!=null)return r.domain(e).range(n),_q(r)}}var vee=(t,e)=>{if(e!=null)switch(t){case"linear":{if(!md(e)){for(var n,r,i=0;i<e.length;i++){var s=e[i];Pn(s)&&((n===void 0||s<n)&&(n=s),(r===void 0||s>r)&&(r=s))}return n!==void 0&&r!==void 0?[n,r]:void 0}return e}default:return e}};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 RN(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){JFe(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 JFe(t,e,n){return(e=e4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e4e(t){var e=t4e(t,"string");return typeof e=="symbol"?e:e+""}function t4e(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 mR=[0,"auto"],Mi={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},wee=(t,e)=>t.cartesianAxis.xAxis[e],Kc=(t,e)=>{var n=wee(t,e);return n??Mi},Pi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:mR,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:Pv},See=(t,e)=>t.cartesianAxis.yAxis[e],Yc=(t,e)=>{var n=See(t,e);return n??Pi},n4e={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:""},TL=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??n4e},Ua=(t,e,n)=>{switch(e){case"xAxis":return Kc(t,n);case"yAxis":return Yc(t,n);case"zAxis":return TL(t,n);case"angleAxis":return kL(t,n);case"radiusAxis":return CL(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},r4e=(t,e,n)=>{switch(e){case"xAxis":return Kc(t,n);case"yAxis":return Yc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},hx=(t,e,n)=>{switch(e){case"xAxis":return Kc(t,n);case"yAxis":return Yc(t,n);case"angleAxis":return kL(t,n);case"radiusAxis":return CL(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},_ee=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function ML(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 Bv=t=>t.graphicalItems.cartesianItems,a4e=mt([Na,Uv],ML),PL=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Hv=mt([Bv,Ua,a4e],PL,{memoizeOptions:{resultEqualityCheck:tA}}),Nee=mt([Hv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(JC)),kee=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),i4e=mt([Hv],kee),jL=t=>t.map(e=>e.data).filter(Boolean).flat(1),s4e=mt([Hv],jL,{memoizeOptions:{resultEqualityCheck:tA}}),EL=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},DL=mt([s4e,yL],EL),RL=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Nr(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Nr(i,r)}))):t.map(r=>({value:r})),nA=mt([DL,Ua,Hv],RL);function Cee(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function d1(t){if(Cl(t)||t instanceof Date){var e=Number(t);if(Pn(e))return e}}function Cq(t){if(Array.isArray(t)){var e=[d1(t[0]),d1(t[1])];return md(e)?e:void 0}var n=d1(t);if(n!=null)return[n,n]}function fd(t){return t.map(d1).filter(no)}function o4e(t,e,n){return!n||typeof e!="number"||rc(e)?[]:n.length?fd(n.flatMap(r=>{var i=Nr(t,r.dataKey),s,o;if(Array.isArray(i)?[s,o]=i:s=o=i,!(!Pn(s)||!Pn(o)))return[e-s,e+o]})):[]}var _i=t=>{var e=Ii(t),n=dx(t);return hx(t,e,n)},$v=mt([_i],t=>t?.dataKey),l4e=mt([Nee,yL,_i],yee),Aee=(t,e,n,r)=>{var i={},s=e.reduce((o,l)=>{if(l.stackId==null)return o;var c=o[l.stackId];return c==null&&(c=[]),c.push(l),o[l.stackId]=c,o},i);return Object.fromEntries(Object.entries(s).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(ZC);return[l,{stackedData:Mje(t,d,n),graphicalItems:u}]}))},FN=mt([l4e,Nee,zv,hee],Aee),Tee=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var o=Dje(t,i,s);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},c4e=mt([Ua],t=>t.allowDataOverflow),FL=t=>{var e;if(t==null||!("domain"in t))return mR;if(t.domain!=null)return t.domain;if("ticks"in t&&t.ticks!=null){if(t.type==="number"){var n=fd(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:mR},LL=mt([Ua],FL),OL=mt([LL,c4e],JJ),u4e=mt([FN,vd,Na,OL],Tee,{memoizeOptions:{resultEqualityCheck:eA}}),rA=t=>t.errorBars,d4e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>Cee(n,r)),LN=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]}},IL=(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(y=>Cee(i,y)),f=Nr(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=o4e(l,f,h);if(p.length>=2){var x=Math.min(...p),v=Math.max(...p);(s==null||x<s)&&(s=x),(o==null||v>o)&&(o=v)}var g=Cq(f);g!=null&&(s=s==null?g[0]:Math.min(s,g[0]),o=o==null?g[1]:Math.max(o,g[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=Cq(Nr(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]))}),Pn(s)&&Pn(o))return[s,o]},h4e=mt([DL,Ua,i4e,rA,Na],IL,{memoizeOptions:{resultEqualityCheck:eA}});function m4e(t){var{value:e}=t;if(Cl(e)||e instanceof Date)return e}var f4e=(t,e,n)=>{var r=t.map(m4e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&qQ(r))?xJ(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},Mee=t=>t.referenceElements.dots,mx=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),p4e=mt([Mee,Na,Uv],mx),Pee=t=>t.referenceElements.areas,g4e=mt([Pee,Na,Uv],mx),jee=t=>t.referenceElements.lines,b4e=mt([jee,Na,Uv],mx),Eee=(t,e)=>{if(t!=null){var n=fd(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},x4e=mt(p4e,Na,Eee),Dee=(t,e)=>{if(t!=null){var n=fd(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)]}},y4e=mt([g4e,Na],Dee);function v4e(t){var e;if(t.x!=null)return fd([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:fd(n)}function w4e(t){var e;if(t.y!=null)return fd([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:fd(n)}var Ree=(t,e)=>{if(t!=null){var n=t.flatMap(r=>e==="xAxis"?v4e(r):w4e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},S4e=mt([b4e,Na],Ree),_4e=mt(x4e,S4e,y4e,(t,e,n)=>LN(t,n,e)),zL=(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?LN(r,s,i):LN(s,i);return FFe(e,u,t.allowDataOverflow)},N4e=mt([Ua,LL,OL,u4e,h4e,_4e,ur,Na],zL,{memoizeOptions:{resultEqualityCheck:eA}}),k4e=[0,1],UL=(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=lc(e,s);if(u&&l==null){var d;return xJ(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?f4e(r,t,u):i==="expand"?k4e:o}},BL=mt([Ua,ur,DL,nA,zv,Na,N4e],UL);function C4e(t){return t in Uy}var Fee=(t,e,n)=>{if(t!=null){var{scale:r,type:i}=t;if(r==="auto")return i==="category"&&n&&(n.indexOf("LineChart")>=0||n.indexOf("AreaChart")>=0||n.indexOf("ComposedChart")>=0&&!e)?"point":i==="category"?"band":"linear";if(typeof r=="string"){var s="scale".concat(Cv(r));return C4e(s)?s:"point"}}},dm=mt([Ua,_ee,SL],Fee);function HL(t,e,n,r){if(!(n==null||r==null))return typeof t.scale=="function"?Nq(t.scale,n,r):Nq(e,n,r)}var $L=(t,e,n)=>{var r=FL(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&md(t))return UFe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&md(t))return BFe(t,e.tickCount,e.allowDecimals)}},VL=mt([BL,hx,dm],$L),qL=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&md(e)&&Array.isArray(n)&&n.length>0){var i,s,o=e[0],l=(i=n[0])!==null&&i!==void 0?i:0,c=e[1],u=(s=n[n.length-1])!==null&&s!==void 0?s:0;return[Math.min(o,l),Math.max(c,u)]}return e},A4e=mt([Ua,BL,VL,Na],qL),T4e=mt(nA,Ua,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(fd(t.map(h=>h.value))).sort((h,f)=>h-f),i=r[0],s=r[r.length-1];if(i==null||s==null)return 1/0;var o=s-i;if(o===0)return 1/0;for(var l=0;l<r.length-1;l++){var c=r[l],u=r[l+1];if(!(c==null||u==null)){var d=u-c;n=Math.min(n,d)}}return n/o}}),Lee=mt(T4e,ur,dee,vi,(t,e,n,r,i)=>i,(t,e,n,r,i)=>{if(!Pn(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var o=vs(n,t*s),l=t*s/2;return l-o-(l-o)/s*o}return 0}),M4e=(t,e,n)=>{var r=Kc(t,e);return r==null||typeof r.padding!="string"?0:Lee(t,"xAxis",e,n,r.padding)},P4e=(t,e,n)=>{var r=Yc(t,e);return r==null||typeof r.padding!="string"?0:Lee(t,"yAxis",e,n,r.padding)},j4e=mt(Kc,M4e,(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}}),E4e=mt(Yc,P4e,(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}}),D4e=mt([vi,j4e,IC,OC,(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]}),R4e=mt([vi,ur,E4e,IC,OC,(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]}),Vv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return D4e(t,n,r);case"yAxis":return R4e(t,n,r);case"zAxis":return(i=TL(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return gee(t);case"radiusAxis":return bee(t,n);default:return}},Oee=mt([Ua,Vv],YC),F4e=mt([dm,A4e],vee),Ob=mt([Ua,dm,F4e,Oee],HL);mt([Hv,rA,Na],d4e);function Iee(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var aA=(t,e)=>e,iA=(t,e,n)=>n,L4e=mt(FC,aA,iA,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(Iee)),O4e=mt(LC,aA,iA,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(Iee)),zee=(t,e)=>({width:t.width,height:e.height}),I4e=(t,e)=>{var n=typeof e.width=="number"?e.width:Pv;return{width:n,height:t.height}},Uee=mt(vi,Kc,zee),z4e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},U4e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},B4e=mt(xd,vi,L4e,aA,iA,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=zee(e,l);o==null&&(o=z4e(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}),H4e=mt(bd,vi,O4e,aA,iA,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=I4e(e,l);o==null&&(o=U4e(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}),$4e=(t,e)=>{var n=Kc(t,e);if(n!=null)return B4e(t,n.orientation,n.mirror)},V4e=mt([vi,Kc,$4e,(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}}}),q4e=(t,e)=>{var n=Yc(t,e);if(n!=null)return H4e(t,n.orientation,n.mirror)},G4e=mt([vi,Yc,q4e,(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}}}),Bee=mt(vi,Yc,(t,e)=>{var n=typeof e.width=="number"?e.width:Pv;return{width:n,height:t.height}}),Aq=(t,e,n)=>{switch(e){case"xAxis":return Uee(t,n).width;case"yAxis":return Bee(t,n).height;default:return}},Hee=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:o}=n,l=lc(t,r),c=e.map(u=>u.value);if(o&&l&&s==="category"&&i&&qQ(c))return c}},GL=mt([ur,nA,Ua,Na],Hee),$ee=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,o=lc(t,r);if(o&&(i==="number"||s!=="auto"))return e.map(l=>l.value)}},WL=mt([ur,nA,hx,Na],$ee),Tq=mt([ur,r4e,dm,Ob,GL,WL,Vv,VL,Na],(t,e,n,r,i,s,o,l,c)=>{if(e!=null){var u=lc(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}}}),W4e=(t,e,n,r,i,s,o,l,c)=>{if(!(e==null||r==null)){var u=lc(t,c),{type:d,ticks:h,tickCount:f}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/p:0;x=c==="angleAxis"&&s!=null&&s.length>=2?Ri(s[0]-s[1])*2*x:x;var v=h||i;return v?v.map((g,y)=>{var _=o?o.indexOf(g):g,N=r.map(_);return Pn(N)?{index:y,coordinate:N+x,value:g,offset:x}:null}).filter(no):u&&l?l.map((g,y)=>{var _=r.map(g);return Pn(_)?{coordinate:_+x,value:g,index:y,offset:x}:null}).filter(no):r.ticks?r.ticks(f).map((g,y)=>{var _=r.map(g);return Pn(_)?{coordinate:_+x,value:g,index:y,offset:x}:null}).filter(no):r.domain().map((g,y)=>{var _=r.map(g);return Pn(_)?{coordinate:_+x,value:o?o[g]:g,index:y,offset:x}:null}).filter(no)}},Vee=mt([ur,hx,dm,Ob,VL,Vv,GL,WL,Na],W4e),K4e=(t,e,n,r,i,s,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=lc(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Ri(r[0]-r[1])*2*u:u,l&&s?s.map((d,h)=>{var f=n.map(d);return Pn(f)?{coordinate:f+u,value:d,index:h,offset:u}:null}).filter(no):n.ticks?n.ticks(c).map((d,h)=>{var f=n.map(d);return Pn(f)?{coordinate:f+u,value:d,index:h,offset:u}:null}).filter(no):n.domain().map((d,h)=>{var f=n.map(d);return Pn(f)?{coordinate:f+u,value:i?i[d]:d,index:h,offset:u}:null}).filter(no)}},Hc=mt([ur,hx,Ob,Vv,GL,WL,Na],K4e),$c=mt(Ua,Ob,(t,e)=>{if(!(t==null||e==null))return RN(RN({},t),{},{scale:e})}),Y4e=mt([Ua,dm,BL,Oee],HL);mt((t,e,n)=>TL(t,n),Y4e,(t,e)=>{if(!(t==null||e==null))return RN(RN({},t),{},{scale:e})});var X4e=mt([ur,FC,LC],(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}}),qee=t=>t.options.defaultTooltipEventType,Gee=t=>t.options.validateTooltipEventTypes;function Wee(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function KL(t,e){var n=qee(t),r=Gee(t);return Wee(e,n,r)}function Q4e(t){return Gt(e=>KL(e,t))}var Kee=(t,e)=>{var n,r=Number(e);if(!(rc(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},Z4e=t=>t.tooltip.settings,xh={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},J4e={itemInteraction:{click:xh,hover:xh},axisInteraction:{click:xh,hover:xh},keyboardInteraction:xh,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}},Yee=ho({name:"tooltip",initialState:J4e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:fa()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Zl(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:fa()},removeTooltipEntrySettings:{reducer(t,e){var n=Zl(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:fa()},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}}}),{addTooltipEntrySettings:eLe,replaceTooltipEntrySettings:tLe,removeTooltipEntrySettings:nLe,setTooltipSettingsState:rLe,setActiveMouseOverItemIndex:Xee,mouseLeaveItem:aLe,mouseLeaveChart:Qee,setActiveClickItemIndex:iLe,setMouseOverAxisIndex:Zee,setMouseClickAxisIndex:sLe,setSyncInteraction:fR,setKeyboardInteraction:pR}=Yee.actions,oLe=Yee.reducer;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 k_(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){lLe(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 lLe(t,e,n){return(e=cLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cLe(t){var e=uLe(t,"string");return typeof e=="symbol"?e:e+""}function uLe(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 dLe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function hLe(t){return t.index!=null}var Jee=(t,e,n,r)=>{if(e==null)return xh;var i=dLe(t,e,n);if(i==null)return xh;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(hLe(i)){if(s)return k_(k_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return k_(k_({},xh),{},{coordinate:i.coordinate})};function mLe(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 fLe(t,e){var n=mLe(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 pLe(t,e,n){if(n==null||e==null)return!0;var r=Nr(t,e);return r==null||!md(n)?!0:fLe(r,n)}var YL=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!Pn(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||pLe(u,n,r)?String(c):null},ete=(t,e,n,r,i,s,o)=>{if(s!=null){var l=o[0],c=l?.getPosition(s);if(c!=null)return c;var u=i?.[Number(s)];if(u)return n==="horizontal"?{x:u.coordinate,y:(r.top+e)/2}:{x:(r.left+t)/2,y:u.coordinate}}},tte=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;if(n==="hover"?i=t.itemInteraction.hover.graphicalItemId:i=t.itemInteraction.click.graphicalItemId,i==null&&r!=null){var s=t.tooltipItemPayloads[0];return s!=null?[s]:[]}return t.tooltipItemPayloads.filter(o=>{var l;return((l=o.settings)===null||l===void 0?void 0:l.graphicalItemId)===i})},nte=t=>t.options.tooltipPayloadSearcher,fx=t=>t.tooltip;function Pq(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 jq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Pq(Object(n),!0).forEach(function(r){gLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Pq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gLe(t,e,n){return(e=bLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bLe(t){var e=xLe(t,"string");return typeof e=="symbol"?e:e+""}function xLe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function yLe(t,e){return t??e}var rte=(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((f,p)=>{var x,{dataDefinedOnItem:v,settings:g}=p,y=yLe(v,l),_=Array.isArray(y)?zZ(y,u,d):y,N=(x=g?.dataKey)!==null&&x!==void 0?x:r,A=g?.nameKey,C;if(r&&Array.isArray(_)&&!Array.isArray(_[0])&&o==="axis"?C=GQ(_,r,i):C=s(_,e,c,A),Array.isArray(C))C.forEach(k=>{var R=jq(jq({},g),{},{name:k.name,unit:k.unit,color:void 0,fill:void 0});f.push(M7({tooltipEntrySettings:R,dataKey:k.dataKey,payload:k.payload,value:Nr(k.payload,k.dataKey),name:k.name}))});else{var j;f.push(M7({tooltipEntrySettings:g,dataKey:N,payload:C,value:Nr(C,N),name:(j=Nr(C,A))!==null&&j!==void 0?j:g?.name}))}return f},h)}},XL=mt([_i,_ee,SL],Fee),vLe=mt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),wLe=mt([Ii,dx],ML),px=mt([vLe,_i,wLe],PL,{memoizeOptions:{resultEqualityCheck:tA}}),SLe=mt([px],t=>t.filter(JC)),_Le=mt([px],jL,{memoizeOptions:{resultEqualityCheck:tA}}),gx=mt([_Le,vd],EL),NLe=mt([SLe,vd,_i],yee),QL=mt([gx,_i,px],RL),ate=mt([_i],FL),kLe=mt([_i],t=>t.allowDataOverflow),ite=mt([ate,kLe],JJ),CLe=mt([px],t=>t.filter(JC)),ALe=mt([NLe,CLe,zv,hee],Aee),TLe=mt([ALe,vd,Ii,ite],Tee),MLe=mt([px],kee),PLe=mt([gx,_i,MLe,rA,Ii],IL,{memoizeOptions:{resultEqualityCheck:eA}}),jLe=mt([Mee,Ii,dx],mx),ELe=mt([jLe,Ii],Eee),DLe=mt([Pee,Ii,dx],mx),RLe=mt([DLe,Ii],Dee),FLe=mt([jee,Ii,dx],mx),LLe=mt([FLe,Ii],Ree),OLe=mt([ELe,LLe,RLe],LN),ILe=mt([_i,ate,ite,TLe,PLe,OLe,ur,Ii],zL),qv=mt([_i,ur,gx,QL,zv,Ii,ILe],UL),zLe=mt([qv,_i,XL],$L),ULe=mt([_i,qv,zLe,Ii],qL),ste=t=>{var e=Ii(t),n=dx(t),r=!1;return Vv(t,e,n,r)},ote=mt([_i,ste],YC),lte=mt([_i,XL,ULe,ote],HL),BLe=mt([ur,QL,_i,Ii],Hee),HLe=mt([ur,QL,_i,Ii],$ee),$Le=(t,e,n,r,i,s,o,l)=>{if(e){var{type:c}=e,u=lc(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?Ri(i[0]-i[1])*2*h:h,u&&o?o.map((f,p)=>{var x=r.map(f);return Pn(x)?{coordinate:x+h,value:f,index:p,offset:h}:null}).filter(no):r.domain().map((f,p)=>{var x=r.map(f);return Pn(x)?{coordinate:x+h,value:s?s[f]:f,index:p,offset:h}:null}).filter(no)}}},wd=mt([ur,_i,XL,lte,ste,BLe,HLe,Ii],$Le),ZL=mt([qee,Gee,Z4e],(t,e,n)=>Wee(n.shared,t,e)),cte=t=>t.tooltip.settings.trigger,JL=t=>t.tooltip.settings.defaultIndex,Gv=mt([fx,ZL,cte,JL],Jee),nm=mt([Gv,gx,$v,qv],YL),ute=mt([wd,nm],Kee),eO=mt([Gv],t=>{if(t)return t.dataKey}),VLe=mt([Gv],t=>{if(t)return t.graphicalItemId}),dte=mt([fx,ZL,cte,JL],tte),qLe=mt([bd,xd,ur,vi,wd,JL,dte],ete),GLe=mt([Gv,qLe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),WLe=mt([Gv],t=>{var e;return(e=t?.active)!==null&&e!==void 0?e:!1}),KLe=mt([dte,nm,vd,$v,ute,nte,ZL],rte),YLe=mt([KLe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function Eq(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 Dq(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Eq(Object(n),!0).forEach(function(r){XLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Eq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XLe(t,e,n){return(e=QLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QLe(t){var e=ZLe(t,"string");return typeof e=="symbol"?e:e+""}function ZLe(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 JLe=()=>Gt(_i),eOe=()=>{var t=JLe(),e=Gt(wd),n=Gt(lte);return tm(!t||!n?void 0:Dq(Dq({},t),{},{scale:n}),e)};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 Pg(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){tOe(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 tOe(t,e,n){return(e=nOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nOe(t){var e=rOe(t,"string");return typeof e=="symbol"?e:e+""}function rOe(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 aOe=(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}},iOe=(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 Pg(Pg(Pg({},r),ri(r.cx,r.cy,o,s)),{},{angle:s,radius:o})}var l=i.coordinate,{angle:c}=r;return Pg(Pg(Pg({},r),ri(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 sOe(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 hte=(t,e,n,r,i)=>{var s,o=(s=e?.length)!==null&&s!==void 0?s:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var l=0;l<o;l++){var c,u,d,h,f,p=l>0?(c=n[l-1])===null||c===void 0?void 0:c.coordinate:(u=n[o-1])===null||u===void 0?void 0:u.coordinate,x=(d=n[l])===null||d===void 0?void 0:d.coordinate,v=l>=o-1?(h=n[0])===null||h===void 0?void 0:h.coordinate:(f=n[l+1])===null||f===void 0?void 0:f.coordinate,g=void 0;if(!(p==null||x==null||v==null))if(Ri(x-p)!==Ri(v-x)){var y=[];if(Ri(v-x)===Ri(i[1]-i[0])){g=v;var _=x+i[1]-i[0];y[0]=Math.min(_,(_+p)/2),y[1]=Math.max(_,(_+p)/2)}else{g=p;var N=v+i[1]-i[0];y[0]=Math.min(x,(N+x)/2),y[1]=Math.max(x,(N+x)/2)}var A=[Math.min(x,(g+x)/2),Math.max(x,(g+x)/2)];if(t>A[0]&&t<=A[1]||t>=y[0]&&t<=y[1]){var C;return(C=n[l])===null||C===void 0?void 0:C.index}}else{var j=Math.min(p,v),k=Math.max(p,v);if(t>(j+x)/2&&t<=(k+x)/2){var R;return(R=n[l])===null||R===void 0?void 0:R.index}}}else if(e)for(var M=0;M<o;M++){var D=e[M];if(D!=null){var G=e[M+1],U=e[M-1];if(M===0&&G!=null&&t<=(D.coordinate+G.coordinate)/2||M===o-1&&U!=null&&t>(D.coordinate+U.coordinate)/2||M>0&&M<o-1&&U!=null&&G!=null&&t>(D.coordinate+U.coordinate)/2&&t<=(D.coordinate+G.coordinate)/2)return D.index}}return-1},mte=()=>Gt(SL),tO=(t,e)=>e,fte=(t,e,n)=>n,nO=(t,e,n,r)=>r,oOe=mt(wd,t=>kC(t,e=>e.coordinate)),rO=mt([fx,tO,fte,nO],Jee),aO=mt([rO,gx,$v,qv],YL),lOe=(t,e,n)=>{if(e!=null){var r=fx(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},pte=mt([fx,tO,fte,nO],tte),ON=mt([bd,xd,ur,vi,wd,nO,pte],ete),cOe=mt([rO,ON],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),gte=mt([wd,aO],Kee),uOe=mt([pte,aO,vd,$v,gte,nte,tO],rte),dOe=mt([rO,aO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),hOe=(t,e,n,r,i,s,o)=>{if(!(!t||!n||!r||!i)&&sOe(t,o)){var l=Rje(t,e),c=hte(l,s,i,n,r),u=aOe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},mOe=(t,e,n,r,i,s,o)=>{if(!(!t||!r||!i||!s||!n)){var l=Q3e(t,n);if(l){var c=Fje(l,e),u=hte(c,o,s,r,i),d=iOe(e,s,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},fOe=(t,e,n,r,i,s,o,l)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?hOe(t,e,r,i,s,o,l):mOe(t,e,n,r,i,s,o)},pOe=mt(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.panoramaElement:r.element}}),gOe=mt(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Oa)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:QFe}});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 Lq(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){bOe(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 bOe(t,e,n){return(e=xOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xOe(t){var e=yOe(t,"string");return typeof e=="symbol"?e:e+""}function yOe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var vOe={},wOe={zIndexMap:Object.values(Oa).reduce((t,e)=>Lq(Lq({},t),{},{[e]:{element:void 0,panoramaElement:void 0,consumers:0}}),vOe)},SOe=new Set(Object.values(Oa));function _Oe(t){return SOe.has(t)}var bte=ho({name:"zIndex",initialState:wOe,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:fa()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!_Oe(n)&&delete t.zIndexMap[n])},prepare:fa()},registerZIndexPortalElement:{reducer:(t,e)=>{var{zIndex:n,element:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElement=r:t.zIndexMap[n].element=r:t.zIndexMap[n]={consumers:0,element:i?void 0:r,panoramaElement:i?r:void 0}},prepare:fa()},unregisterZIndexPortalElement:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElement=void 0:t.zIndexMap[n].element=void 0)},prepare:fa()}}}),{registerZIndexPortal:NOe,unregisterZIndexPortal:kOe,registerZIndexPortalElement:COe,unregisterZIndexPortalElement:AOe}=bte.actions,TOe=bte.reducer;function _s(t){var{zIndex:e,children:n}=t,r=hEe(),i=r&&e!==void 0&&e!==0,s=wi(),o=Jr();w.useLayoutEffect(()=>i?(o(NOe({zIndex:e})),()=>{o(kOe({zIndex:e}))}):sm,[o,e,i]);var l=Gt(c=>pOe(c,e,s));return i?l?Iu.createPortal(n,l):null:n}function gR(){return gR=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},gR.apply(null,arguments)}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 C_(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){MOe(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 MOe(t,e,n){return(e=POe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function POe(t){var e=jOe(t,"string");return typeof e=="symbol"?e:e+""}function jOe(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 EOe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function DOe(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,h=n,f=r,p=i;if(!c||!h||d!=="ScatterChart"&&u!=="axis")return null;var x,v,g;if(d==="ScatterChart")x=h,v=d3e,g=Oa.cursorLine;else if(d==="BarChart")x=h3e(l,h,s,o),v=mJ,g=Oa.cursorRectangle;else if(l==="radial"&&KQ(h)){var{cx:y,cy:_,radius:N,startAngle:A,endAngle:C}=pJ(h);x={cx:y,cy:_,startAngle:A,endAngle:C,innerRadius:N,outerRadius:N},v=bJ,g=Oa.cursorLine}else x={points:tDe(l,h,s)},v=db,g=Oa.cursorLine;var j=typeof c=="object"&&"className"in c?c.className:void 0,k=C_(C_(C_(C_({stroke:"#ccc",pointerEvents:"none"},s),x),Gf(c)),{},{payload:f,payloadIndex:p,className:hr("recharts-tooltip-cursor",j)});return w.createElement(_s,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:g},w.createElement(EOe,{cursor:c,cursorComp:v,cursorProps:k}))}function ROe(t){var e=eOe(),n=YZ(),r=lm(),i=mte();return e==null||n==null||r==null||i==null?null:w.createElement(DOe,gR({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var xte=w.createContext(null),FOe=()=>w.useContext(xte),Dj={exports:{}},Iq;function LOe(){return Iq||(Iq=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,f){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,h||c,f),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],p]:c._events[x].push(p):(c._events[x]=p,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,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 f=0,p=h.length,x=new Array(p);f<p;f++)x[f]=h[f].fn;return x},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,f,p,x){var v=n?n+u:u;if(!this._events[v])return!1;var g=this._events[v],y=arguments.length,_,N;if(g.fn){switch(g.once&&this.removeListener(u,g.fn,void 0,!0),y){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,d),!0;case 3:return g.fn.call(g.context,d,h),!0;case 4:return g.fn.call(g.context,d,h,f),!0;case 5:return g.fn.call(g.context,d,h,f,p),!0;case 6:return g.fn.call(g.context,d,h,f,p,x),!0}for(N=1,_=new Array(y-1);N<y;N++)_[N-1]=arguments[N];g.fn.apply(g.context,_)}else{var A=g.length,C;for(N=0;N<A;N++)switch(g[N].once&&this.removeListener(u,g[N].fn,void 0,!0),y){case 1:g[N].fn.call(g[N].context);break;case 2:g[N].fn.call(g[N].context,d);break;case 3:g[N].fn.call(g[N].context,d,h);break;case 4:g[N].fn.call(g[N].context,d,h,f);break;default:if(!_)for(C=1,_=new Array(y-1);C<y;C++)_[C-1]=arguments[C];g[N].fn.apply(g[N].context,_)}}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,f){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return o(this,p),this;var x=this._events[p];if(x.fn)x.fn===d&&(!f||x.once)&&(!h||x.context===h)&&o(this,p);else{for(var v=0,g=[],y=x.length;v<y;v++)(x[v].fn!==d||f&&!x[v].once||h&&x[v].context!==h)&&g.push(x[v]);g.length?this._events[p]=g.length===1?g[0]:g:o(this,p)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(Dj)),Dj.exports}var OOe=LOe();const IOe=Ml(OOe);var Q0=new IOe,bR="recharts.syncEvent.tooltip",zq="recharts.syncEvent.brush",sA=(t,e)=>{if(e&&Array.isArray(t)){var n=Number.parseInt(e,10);if(!rc(n))return t[n]}},zOe={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},yte=ho({name:"options",initialState:zOe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),UOe=yte.reducer,{createEventEmitter:BOe}=yte.actions;function HOe(t){return t.tooltip.syncInteraction}var $Oe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},vte=ho({name:"chartData",initialState:$Oe,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:Uq,setDataStartEndIndexes:VOe,setComputedData:Gnt}=vte.actions,qOe=vte.reducer,GOe=["x","y"];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 jg(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){WOe(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 WOe(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=YOe(t,"string");return typeof e=="symbol"?e:e+""}function YOe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function XOe(t,e){if(t==null)return{};var n,r,i=QOe(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 QOe(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 ZOe(){var t=Gt(_L),e=Gt(NL),n=Jr(),r=Gt(mee),i=Gt(wd),s=lm(),o=jv(),l=Gt(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return sm;var c=(u,d,h)=>{if(e!==h&&t===u){if(r==="index"){var f;if(o&&d!==null&&d!==void 0&&(f=d.payload)!==null&&f!==void 0&&f.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x,y:v}=p,g=XOe(p,GOe),{x:y,y:_,width:N,height:A}=d.payload.sourceViewBox,C=jg(jg({},g),{},{x:o.x+(N?(x-y)/N:0)*o.width,y:o.y+(A?(v-_)/A:0)*o.height});n(jg(jg({},d),{},{payload:jg(jg({},d.payload),{},{coordinate:C})}))}else n(d);return}if(i!=null){var j;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);j=i[R]}else r==="value"&&(j=i.find(ae=>String(ae.value)===d.payload.label));var{coordinate:M}=d.payload;if(j==null||d.payload.active===!1||M==null||o==null){n(fR({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:D,y:G}=M,U=Math.min(D,o.x+o.width),W=Math.min(G,o.y+o.height),L={x:s==="horizontal"?j.coordinate:U,y:s==="horizontal"?W:j.coordinate},ee=fR({active:d.payload.active,coordinate:L,dataKey:d.payload.dataKey,index:String(j.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(ee)}}};return Q0.on(bR,c),()=>{Q0.off(bR,c)}},[l,n,e,t,r,i,s,o])}function JOe(){var t=Gt(_L),e=Gt(NL),n=Jr();w.useEffect(()=>{if(t==null)return sm;var r=(i,s,o)=>{e!==o&&t===i&&n(VOe(s))};return Q0.on(zq,r),()=>{Q0.off(zq,r)}},[n,e,t])}function eIe(){var t=Jr();w.useEffect(()=>{t(BOe())},[t]),ZOe(),JOe()}function tIe(t,e,n,r,i,s){var o=Gt(p=>lOe(p,t,e)),l=Gt(NL),c=Gt(_L),u=Gt(mee),d=Gt(HOe),h=d?.active,f=jv();w.useEffect(()=>{if(!h&&c!=null&&l!=null){var p=fR({active:s,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:f,graphicalItemId:void 0});Q0.emit(bR,c,p,l)}},[h,n,o,i,r,l,c,u,s,f])}function Hq(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 $q(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Hq(Object(n),!0).forEach(function(r){nIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Hq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nIe(t,e,n){return(e=rIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rIe(t){var e=aIe(t,"string");return typeof e=="symbol"?e:e+""}function aIe(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 iIe(t){return t.dataKey}function sIe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(VEe,e)}var Vq=[],oIe={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,includeHidden:!1,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function Mh(t){var e,n,r=_a(t,oIe),{active:i,allowEscapeViewBox:s,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:h,payloadUniqBy:f,position:p,reverseDirection:x,useTranslate3d:v,wrapperStyle:g,cursor:y,shared:_,trigger:N,defaultIndex:A,portal:C,axisId:j}=r,k=Jr(),R=typeof A=="number"?String(A):A;w.useEffect(()=>{k(rLe({shared:_,trigger:N,axisId:j,active:i,defaultIndex:R}))},[k,_,N,j,i,R]);var M=jv(),D=lJ(),G=Q4e(_),{activeIndex:U,isActive:W}=(e=Gt(K=>dOe(K,G,N,R)))!==null&&e!==void 0?e:{},L=Gt(K=>uOe(K,G,N,R)),ee=Gt(K=>gte(K,G,N,R)),ae=Gt(K=>cOe(K,G,N,R)),Y=L,se=FOe(),ce=(n=i??W)!==null&&n!==void 0?n:!1,[ye,Z]=cZ([Y,ce]),ue=G==="axis"?ee:void 0;tIe(G,N,ae,ue,U,ce);var pe=C??se;if(pe==null||M==null||G==null)return null;var be=Y??Vq;ce||(be=Vq),u&&be.length&&(be=rZ(be.filter(K=>K.value!=null&&(K.hide!==!0||r.includeHidden)),f,iIe));var Ee=be.length>0,$=w.createElement(QEe,{allowEscapeViewBox:s,animationDuration:o,animationEasing:l,isAnimationActive:d,active:ce,coordinate:ae,hasPayload:Ee,offset:h,position:p,reverseDirection:x,useTranslate3d:v,viewBox:M,wrapperStyle:g,lastBoundingBox:ye,innerRef:Z,hasPortalFromProps:!!C},sIe(c,$q($q({},r),{},{payload:be,label:ue,active:ce,activeIndex:U,coordinate:ae,accessibilityLayer:D})));return w.createElement(w.Fragment,null,Iu.createPortal($,pe),ce&&w.createElement(ROe,{cursor:y,tooltipEventType:G,coordinate:ae,payload:be,index:U}))}var Ib=t=>null;Ib.displayName="Cell";function lIe(t,e,n){return(e=cIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cIe(t){var e=uIe(t,"string");return typeof e=="symbol"?e:e+""}function uIe(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 dIe{constructor(e){lIe(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 qq(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 hIe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qq(Object(n),!0).forEach(function(r){mIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qq(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mIe(t,e,n){return(e=fIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fIe(t){var e=pIe(t,"string");return typeof e=="symbol"?e:e+""}function pIe(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 gIe={cacheSize:2e3,enableCache:!0},wte=hIe({},gIe),Gq=new dIe(wte.cacheSize),bIe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},Wq="recharts_measurement_span";function xIe(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 Kq=(t,e)=>{try{var n=document.getElementById(Wq);n||(n=document.createElement("span"),n.setAttribute("id",Wq),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,bIe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},r0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Rv.isSsr)return{width:0,height:0};if(!wte.enableCache)return Kq(e,n);var r=xIe(e,n),i=Gq.get(r);if(i)return i;var s=Kq(e,n);return Gq.set(r,s),s},Ste;function yIe(t,e,n){return(e=vIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vIe(t){var e=wIe(t,"string");return typeof e=="symbol"?e:e+""}function wIe(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 Yq=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Xq=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,SIe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,_Ie=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,NIe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},kIe=["cm","mm","pt","pc","in","Q","px"];function CIe(t){return kIe.includes(t)}var Qg="NaN";function AIe(t,e){return t*NIe[e]}class Xi{static parse(e){var n,[,r,i]=(n=_Ie.exec(e))!==null&&n!==void 0?n:[];return r==null?Xi.NaN:new Xi(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,rc(e)&&(this.unit=""),n!==""&&!SIe.test(n)&&(this.num=NaN,this.unit=""),CIe(n)&&(this.num=AIe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Xi(NaN,""):new Xi(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Xi(NaN,""):new Xi(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Xi(NaN,""):new Xi(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Xi(NaN,""):new Xi(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return rc(this.num)}}Ste=Xi;yIe(Xi,"NaN",new Ste(NaN,""));function _te(t){if(t==null||t.includes(Qg))return Qg;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=Yq.exec(e))!==null&&n!==void 0?n:[],o=Xi.parse(r??""),l=Xi.parse(s??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Qg;e=e.replace(Yq,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,h,f]=(u=Xq.exec(e))!==null&&u!==void 0?u:[],p=Xi.parse(d??""),x=Xi.parse(f??""),v=h==="+"?p.add(x):p.subtract(x);if(v.isNaN())return Qg;e=e.replace(Xq,v.toString())}return e}var Qq=/\(([^()]*)\)/;function TIe(t){for(var e=t,n;(n=Qq.exec(e))!=null;){var[,r]=n;e=e.replace(Qq,_te(r))}return e}function MIe(t){var e=t.replace(/\s+/g,"");return e=TIe(e),e=_te(e),e}function PIe(t){try{return MIe(t)}catch{return Qg}}function Rj(t){var e=PIe(t.slice(5,-1));return e===Qg?"":e}var jIe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],EIe=["dx","dy","angle","className","breakAll"];function xR(){return xR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},xR.apply(null,arguments)}function Zq(t,e){if(t==null)return{};var n,r,i=DIe(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 DIe(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 Nte=/[ \f\n\r\t\v\u2028\u2029]+/,kte=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];xa(e)||(n?i=e.toString().split(""):i=e.toString().split(Nte));var s=i.map(l=>({word:l,width:r0(l,r).width})),o=n?0:r0(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:o}}catch{return null}};function RIe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var Cte=(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},[]),Ate=t=>t.reduce((e,n)=>e.width>n.width?e:n),FIe="…",Jq=(t,e,n,r,i,s,o,l)=>{var c=t.slice(0,e),u=kte({breakAll:n,style:r,children:c+FIe});if(!u)return[!1,[]];var d=Cte(u.wordsWithComputedWidth,s,o,l),h=d.length>i||Ate(d).width>Number(s);return[h,d]},LIe=(t,e,n,r,i)=>{var{maxLines:s,children:o,style:l,breakAll:c}=t,u=Vt(s),d=String(o),h=Cte(e,r,n,i);if(!u||i)return h;var f=h.length>s||Ate(h).width>Number(r);if(!f)return h;for(var p=0,x=d.length-1,v=0,g;p<=x&&v<=d.length-1;){var y=Math.floor((p+x)/2),_=y-1,[N,A]=Jq(d,_,c,l,s,r,n,i),[C]=Jq(d,y,c,l,s,r,n,i);if(!N&&!C&&(p=y+1),N&&C&&(x=y-1),!N&&C){g=A;break}v++}return g||h},e9=t=>{var e=xa(t)?[]:t.toString().split(Nte);return[{words:e,width:void 0}]},OIe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:o}=t;if((e||n)&&!Rv.isSsr){var l,c,u=kte({breakAll:s,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:h}=u;l=d,c=h}else return e9(r);return LIe({breakAll:s,children:r,maxLines:o,style:i},l,c,e,!!n)}return e9(r)},Tte="#808080",IIe={angle:0,breakAll:!1,capHeight:"0.71em",fill:Tte,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},oA=w.forwardRef((t,e)=>{var n=_a(t,IIe),{x:r,y:i,lineHeight:s,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,h=Zq(n,jIe),f=w.useMemo(()=>OIe({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:p,dy:x,angle:v,className:g,breakAll:y}=h,_=Zq(h,EIe);if(!Cl(r)||!Cl(i)||f.length===0)return null;var N=Number(r)+(Vt(p)?p:0),A=Number(i)+(Vt(x)?x:0);if(!Pn(N)||!Pn(A))return null;var C;switch(d){case"start":C=Rj("calc(".concat(o,")"));break;case"middle":C=Rj("calc(".concat((f.length-1)/2," * -").concat(s," + (").concat(o," / 2))"));break;default:C=Rj("calc(".concat(f.length-1," * -").concat(s,")"));break}var j=[],k=f[0];if(c&&k!=null){var R=k.width,{width:M}=h;j.push("scale(".concat(Vt(M)&&Vt(R)?M/R:1,")"))}return v&&j.push("rotate(".concat(v,", ").concat(N,", ").concat(A,")")),j.length&&(_.transform=j.join(" ")),w.createElement("text",xR({},rs(_),{ref:e,x:N,y:A,className:hr("recharts-text",g),textAnchor:u,fill:l.includes("url")?Tte:l}),f.map((D,G)=>{var U=D.words.join(y?"":" ");return w.createElement("tspan",{x:N,dy:G===0?C:s,key:"".concat(U,"-").concat(G)},U)}))});oA.displayName="Text";function t9(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 yc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t9(Object(n),!0).forEach(function(r){zIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zIe(t,e,n){return(e=UIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UIe(t){var e=BIe(t,"string");return typeof e=="symbol"?e:e+""}function BIe(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 HIe=t=>{var{viewBox:e,position:n,offset:r=0,parentViewBox:i}=t,{x:s,y:o,height:l,upperWidth:c,lowerWidth:u}=V4(e),d=s,h=s+(c-u)/2,f=(d+h)/2,p=(c+u)/2,x=d+c/2,v=l>=0?1:-1,g=v*r,y=v>0?"end":"start",_=v>0?"start":"end",N=c>=0?1:-1,A=N*r,C=N>0?"end":"start",j=N>0?"start":"end",k=i;if(n==="top"){var R={x:d+c/2,y:o-g,horizontalAnchor:"middle",verticalAnchor:y};return k&&(R.height=Math.max(o-k.y,0),R.width=c),R}if(n==="bottom"){var M={x:h+u/2,y:o+l+g,horizontalAnchor:"middle",verticalAnchor:_};return k&&(M.height=Math.max(k.y+k.height-(o+l),0),M.width=u),M}if(n==="left"){var D={x:f-A,y:o+l/2,horizontalAnchor:C,verticalAnchor:"middle"};return k&&(D.width=Math.max(D.x-k.x,0),D.height=l),D}if(n==="right"){var G={x:f+p+A,y:o+l/2,horizontalAnchor:j,verticalAnchor:"middle"};return k&&(G.width=Math.max(k.x+k.width-G.x,0),G.height=l),G}var U=k?{width:p,height:l}:{};return n==="insideLeft"?yc({x:f+A,y:o+l/2,horizontalAnchor:j,verticalAnchor:"middle"},U):n==="insideRight"?yc({x:f+p-A,y:o+l/2,horizontalAnchor:C,verticalAnchor:"middle"},U):n==="insideTop"?yc({x:d+c/2,y:o+g,horizontalAnchor:"middle",verticalAnchor:_},U):n==="insideBottom"?yc({x:h+u/2,y:o+l-g,horizontalAnchor:"middle",verticalAnchor:y},U):n==="insideTopLeft"?yc({x:d+A,y:o+g,horizontalAnchor:j,verticalAnchor:_},U):n==="insideTopRight"?yc({x:d+c-A,y:o+g,horizontalAnchor:C,verticalAnchor:_},U):n==="insideBottomLeft"?yc({x:h+A,y:o+l-g,horizontalAnchor:j,verticalAnchor:y},U):n==="insideBottomRight"?yc({x:h+u-A,y:o+l-g,horizontalAnchor:C,verticalAnchor:y},U):n&&typeof n=="object"&&(Vt(n.x)||Yf(n.x))&&(Vt(n.y)||Yf(n.y))?yc({x:s+vs(n.x,p),y:o+vs(n.y,l),horizontalAnchor:"end",verticalAnchor:"end"},U):yc({x,y:o+l/2,horizontalAnchor:"middle",verticalAnchor:"middle"},U)},$Ie=["labelRef"],VIe=["content"];function n9(t,e){if(t==null)return{};var n,r,i=qIe(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 qIe(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 r9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function By(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r9(Object(n),!0).forEach(function(r){GIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GIe(t,e,n){return(e=WIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WIe(t){var e=KIe(t,"string");return typeof e=="symbol"?e:e+""}function KIe(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 Ou(){return Ou=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},Ou.apply(null,arguments)}var Mte=w.createContext(null),Pte=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o,children:l}=t,c=w.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o}),[e,n,r,i,s,o]);return w.createElement(Mte.Provider,{value:c},l)},jte=()=>{var t=w.useContext(Mte),e=jv();return t||(e?V4(e):void 0)},YIe=w.createContext(null),XIe=()=>{var t=w.useContext(YIe),e=Gt(xee);return t||e},QIe=t=>{var{value:e,formatter:n}=t,r=xa(t.children)?e:t.children;return typeof n=="function"?n(r):r},iO=t=>t!=null&&typeof t=="function",ZIe=(t,e)=>{var n=Ri(e-t),r=Math.min(Math.abs(e-t),360);return n*r},JIe=(t,e,n,r,i)=>{var{offset:s,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:h,endAngle:f,clockWise:p}=i,x=(u+d)/2,v=ZIe(h,f),g=v>=0?1:-1,y,_;switch(e){case"insideStart":y=h+g*s,_=p;break;case"insideEnd":y=f-g*s,_=!p;break;case"end":y=f+g*s,_=p;break;default:throw new Error("Unsupported position ".concat(e))}_=v<=0?_:!_;var N=ri(l,c,x,y),A=ri(l,c,x,y+(_?1:-1)*359),C="M".concat(N.x,",").concat(N.y,`
  8101. A`).concat(x,",").concat(x,",0,1,").concat(_?0:1,`,
  8102. `).concat(A.x,",").concat(A.y),j=xa(t.id)?I0("recharts-radial-line-"):t.id;return w.createElement("text",Ou({},r,{dominantBaseline:"central",className:hr("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:j,d:C})),w.createElement("textPath",{xlinkHref:"#".concat(j)},n))},e5e=(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}=ri(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 f=(s+o)/2,{x:p,y:x}=ri(r,i,f,u);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},h1=t=>t!=null&&"cx"in t&&Vt(t.cx),t5e={angle:0,offset:5,zIndex:Oa.label,position:"middle",textBreakAll:!1};function n5e(t){if(!h1(t))return t;var{cx:e,cy:n,outerRadius:r}=t,i=r*2;return{x:e-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function dh(t){var e=_a(t,t5e),{viewBox:n,parentViewBox:r,position:i,value:s,children:o,content:l,className:c="",textBreakAll:u,labelRef:d}=e,h=XIe(),f=jte(),p=i==="center"?f:h??f,x,v,g;n==null?x=p:h1(n)?x=n:x=V4(n);var y=n5e(x);if(!x||xa(s)&&xa(o)&&!w.isValidElement(l)&&typeof l!="function")return null;var _=By(By({},e),{},{viewBox:x});if(w.isValidElement(l)){var{labelRef:N}=_,A=n9(_,$Ie);return w.cloneElement(l,A)}if(typeof l=="function"){var{content:C}=_,j=n9(_,VIe);if(v=w.createElement(l,j),w.isValidElement(v))return v}else v=QIe(e);var k=rs(e);if(h1(x)){if(i==="insideStart"||i==="insideEnd"||i==="end")return JIe(e,i,v,k,x);g=e5e(x,e.offset,e.position)}else{if(!y)return null;var R=HIe({viewBox:y,position:i,offset:e.offset,parentViewBox:h1(r)?void 0:r});g=By(By({x:R.x,y:R.y,textAnchor:R.horizontalAnchor,verticalAnchor:R.verticalAnchor},R.width!==void 0?{width:R.width}:{}),R.height!==void 0?{height:R.height}:{})}return w.createElement(_s,{zIndex:e.zIndex},w.createElement(oA,Ou({ref:d,className:hr("recharts-label",c)},k,g,{textAnchor:RIe(k.textAnchor)?k.textAnchor:g.textAnchor,breakAll:u}),v))}dh.displayName="Label";var r5e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(dh,Ou({key:"label-implicit"},r)):Cl(t)?w.createElement(dh,Ou({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===dh?w.cloneElement(t,By({key:"label-implicit"},r)):w.createElement(dh,Ou({key:"label-implicit",content:t},r)):iO(t)?w.createElement(dh,Ou({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(dh,Ou({},t,{key:"label-implicit"},r)):null};function Ete(t){var{label:e,labelRef:n}=t,r=jte();return r5e(e,r,n)||null}var Fj={},Lj={},a9;function a5e(){return a9||(a9=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(Lj)),Lj}var Oj={},i9;function i5e(){return i9||(i9=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(Oj)),Oj}var s9;function s5e(){return s9||(s9=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=a5e(),n=i5e(),r=D4();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(Fj)),Fj}var Ij,o9;function o5e(){return o9||(o9=1,Ij=s5e().last),Ij}var l5e=o5e();const c5e=Ml(l5e);var u5e=["valueAccessor"],d5e=["dataKey","clockWise","id","textBreakAll","zIndex"];function IN(){return IN=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},IN.apply(null,arguments)}function l9(t,e){if(t==null)return{};var n,r,i=h5e(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 h5e(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 m5e=t=>Array.isArray(t.value)?c5e(t.value):t.value,Dte=w.createContext(void 0),sO=Dte.Provider,Rte=w.createContext(void 0),f5e=Rte.Provider;function p5e(){return w.useContext(Dte)}function g5e(){return w.useContext(Rte)}function m1(t){var{valueAccessor:e=m5e}=t,n=l9(t,u5e),{dataKey:r,clockWise:i,id:s,textBreakAll:o,zIndex:l}=n,c=l9(n,d5e),u=p5e(),d=g5e(),h=u||d;return!h||!h.length?null:w.createElement(_s,{zIndex:l??Oa.label},w.createElement(Sa,{className:"recharts-label-list"},h.map((f,p)=>{var x,v=xa(r)?e(f,p):Nr(f.payload,r),g=xa(s)?{}:{id:"".concat(s,"-").concat(p)};return w.createElement(dh,IN({key:"label-".concat(p)},rs(f),c,g,{fill:(x=n.fill)!==null&&x!==void 0?x:f.fill,parentViewBox:f.parentViewBox,value:v,textBreakAll:o,viewBox:f.viewBox,index:p,zIndex:0}))})))}m1.displayName="LabelList";function lA(t){var{label:e}=t;return e?e===!0?w.createElement(m1,{key:"labelList-implicit"}):w.isValidElement(e)||iO(e)?w.createElement(m1,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(m1,IN({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function yR(){return yR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},yR.apply(null,arguments)}var Fte=t=>{var{cx:e,cy:n,r,className:i}=t,s=hr("recharts-dot",i);return Vt(e)&&Vt(n)&&Vt(r)?w.createElement("circle",yR({},Is(t),E4(t),{className:s,cx:e,cy:n,r})):null},Lte=t=>t.graphicalItems.polarItems,b5e=mt([Na,Uv],ML),cA=mt([Lte,Ua,b5e],PL),x5e=mt([cA],jL),uA=mt([x5e,KC],EL),y5e=mt([uA,Ua,cA],RL);mt([uA,Ua,cA],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,o=Nr(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Nr(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var c9=()=>{},v5e=mt([uA,Ua,cA,rA,Na],IL),w5e=mt([Ua,LL,OL,c9,v5e,c9,ur,Na],zL),Ote=mt([Ua,ur,uA,y5e,zv,Na,w5e],UL),S5e=mt([Ote,hx,dm],$L),_5e=mt([Ua,Ote,S5e,Na],qL);mt([dm,_5e],vee);var N5e={radiusAxis:{},angleAxis:{}},Ite=ho({name:"polarAxis",initialState:N5e,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:Wnt,removeRadiusAxis:Knt,addAngleAxis:Ynt,removeAngleAxis:Xnt}=Ite.actions,k5e=Ite.reducer;function zte(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}function u9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function d9(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u9(Object(n),!0).forEach(function(r){C5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function C5e(t,e,n){return(e=A5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function A5e(t){var e=T5e(t,"string");return typeof e=="symbol"?e:e+""}function T5e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var M5e=(t,e)=>e,oO=mt([Lte,M5e],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),P5e=[],lO=(t,e,n)=>n?.length===0?P5e:n,Ute=mt([KC,oO,lO],(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=>d9(d9({},e.presentationProps),s.props))),i!=null)return i}}),j5e=mt([Ute,oO,lO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,o=Nr(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:om(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),E5e=mt([Ute,oO,lO,vi],(t,e,n,r)=>{if(!(e==null||t==null))return Dze({offset:r,pieSettings:e,displayedData:t,cells:n})}),zj={exports:{}},zr={};var h9;function D5e(){if(h9)return zr;h9=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"),f=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function x(v){if(typeof v=="object"&&v!==null){var g=v.$$typeof;switch(g){case t:switch(v=v.type,v){case n:case i:case r:case c:case u:case f:return v;default:switch(v=v&&v.$$typeof,v){case o:case l:case h:case d:return v;case s:return v;default:return g}}case e:return g}}}return zr.ContextConsumer=s,zr.ContextProvider=o,zr.Element=t,zr.ForwardRef=l,zr.Fragment=n,zr.Lazy=h,zr.Memo=d,zr.Portal=e,zr.Profiler=i,zr.StrictMode=r,zr.Suspense=c,zr.SuspenseList=u,zr.isContextConsumer=function(v){return x(v)===s},zr.isContextProvider=function(v){return x(v)===o},zr.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},zr.isForwardRef=function(v){return x(v)===l},zr.isFragment=function(v){return x(v)===n},zr.isLazy=function(v){return x(v)===h},zr.isMemo=function(v){return x(v)===d},zr.isPortal=function(v){return x(v)===e},zr.isProfiler=function(v){return x(v)===i},zr.isStrictMode=function(v){return x(v)===r},zr.isSuspense=function(v){return x(v)===c},zr.isSuspenseList=function(v){return x(v)===u},zr.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===c||v===u||typeof v=="object"&&v!==null&&(v.$$typeof===h||v.$$typeof===d||v.$$typeof===o||v.$$typeof===s||v.$$typeof===l||v.$$typeof===p||v.getModuleId!==void 0)},zr.typeOf=x,zr}var m9;function R5e(){return m9||(m9=1,zj.exports=D5e()),zj.exports}var F5e=R5e(),f9=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",p9=null,Uj=null,Bte=t=>{if(t===p9&&Array.isArray(Uj))return Uj;var e=[];return w.Children.forEach(t,n=>{xa(n)||(F5e.isFragment(n)?e=e.concat(Bte(n.props.children)):e.push(n))}),Uj=e,p9=t,e};function cO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>f9(i)):r=[f9(e)],Bte(t).forEach(i=>{var s=Kf(i,"type.displayName")||Kf(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var uO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,Bj={},g9;function L5e(){return g9||(g9=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})(Bj)),Bj}var Hj,b9;function O5e(){return b9||(b9=1,Hj=L5e().isPlainObject),Hj}var I5e=O5e();const z5e=Ml(I5e);var x9,y9,v9,w9,S9;function _9(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 N9(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_9(Object(n),!0).forEach(function(r){U5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function U5e(t,e,n){return(e=B5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function B5e(t){var e=H5e(t,"string");return typeof e=="symbol"?e:e+""}function H5e(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 zN(){return zN=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},zN.apply(null,arguments)}function jy(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var k9=(t,e,n,r,i)=>{var s=n-r,o;return o=Ea(x9||(x9=jy(["M ",",",""])),t,e),o+=Ea(y9||(y9=jy(["L ",",",""])),t+n,e),o+=Ea(v9||(v9=jy(["L ",",",""])),t+n-s/2,e+i),o+=Ea(w9||(w9=jy(["L ",",",""])),t+n-s/2-r,e+i),o+=Ea(S9||(S9=jy(["L ",","," Z"])),t,e),o},$5e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},V5e=t=>{var e=_a(t,$5e),{x:n,y:r,upperWidth:i,lowerWidth:s,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:h}=e,f=w.useRef(null),[p,x]=w.useState(-1),v=w.useRef(i),g=w.useRef(s),y=w.useRef(o),_=w.useRef(n),N=w.useRef(r),A=ox(t,"trapezoid-");if(w.useEffect(()=>{if(f.current&&f.current.getTotalLength)try{var L=f.current.getTotalLength();L&&x(L)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||o!==+o||i===0&&s===0||o===0)return null;var C=hr("recharts-trapezoid",l);if(!h)return w.createElement("g",null,w.createElement("path",zN({},rs(e),{className:C,d:k9(n,r,i,s,o)})));var j=v.current,k=g.current,R=y.current,M=_.current,D=N.current,G="0px ".concat(p===-1?1:p,"px"),U="".concat(p,"px 0px"),W=cJ(["strokeDasharray"],u,c);return w.createElement(sx,{animationId:A,key:A,canBegin:p>0,duration:u,easing:c,isActive:h,begin:d},L=>{var ee=_r(j,i,L),ae=_r(k,s,L),Y=_r(R,o,L),se=_r(M,n,L),ce=_r(D,r,L);f.current&&(v.current=ee,g.current=ae,y.current=Y,_.current=se,N.current=ce);var ye=L>0?{transition:W,strokeDasharray:U}:{strokeDasharray:G};return w.createElement("path",zN({},rs(e),{className:C,d:k9(se,ce,ee,ae,Y),ref:f,style:N9(N9({},ye),e.style)}))})},q5e=["option","shapeType","activeClassName"];function G5e(t,e){if(t==null)return{};var n,r,i=W5e(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 W5e(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 C9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function UN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C9(Object(n),!0).forEach(function(r){K5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function K5e(t,e,n){return(e=Y5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Y5e(t){var e=X5e(t,"string");return typeof e=="symbol"?e:e+""}function X5e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Q5e(t,e){return UN(UN({},e),t)}function Z5e(t,e){return t==="symbols"}function A9(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(mJ,n);case"trapezoid":return w.createElement(V5e,n);case"sector":return w.createElement(bJ,n);case"symbols":if(Z5e(e))return w.createElement(j4,n);break;case"curve":return w.createElement(db,n);default:return null}}function J5e(t){return w.isValidElement(t)?t.props:t}function dO(t){var{option:e,shapeType:n,activeClassName:r="recharts-active-shape"}=t,i=G5e(t,q5e),s;if(w.isValidElement(e))s=w.cloneElement(e,UN(UN({},i),J5e(e)));else if(typeof e=="function")s=e(i,i.index);else if(z5e(e)&&typeof e!="boolean"){var o=Q5e(e,i);s=w.createElement(A9,{shapeType:n,elementProps:o})}else{var l=i;s=w.createElement(A9,{shapeType:n,elementProps:l})}return i.isActive?w.createElement(Sa,{className:r},s):s}var hO=(t,e,n)=>{var r=Jr();return(i,s)=>o=>{t?.(i,s,o),r(Xee({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},mO=t=>{var e=Jr();return(n,r)=>i=>{t?.(n,r,i),e(aLe())}},fO=(t,e,n)=>{var r=Jr();return(i,s)=>o=>{t?.(i,s,o),r(iLe({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function dA(t){var{tooltipEntrySettings:e}=t,n=Jr(),r=wi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(eLe(e)):i.current!==e&&n(tLe({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n(nLe(i.current)),i.current=null)},[n]),null}function pO(t){var{legendPayload:e}=t,n=Jr(),r=wi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(aJ(e)):i.current!==e&&n(iJ({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(sJ(i.current)),i.current=null)},[n]),null}function eze(t){var{legendPayload:e}=t,n=Jr(),r=Gt(ur),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(aJ(e)):i.current!==e&&n(iJ({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(sJ(i.current)),i.current=null)},[n]),null}var $j,tze=()=>{var[t]=w.useState(()=>I0("uid-"));return t},nze=($j=Ple.useId)!==null&&$j!==void 0?$j:tze;function rze(t,e){var n=nze();return e||(t?"".concat(t,"-").concat(n):n)}var aze=w.createContext(void 0),hA=t=>{var{id:e,type:n,children:r}=t,i=rze("recharts-".concat(n),e);return w.createElement(aze.Provider,{value:i},r(i))},ize={cartesianItems:[],polarItems:[]},Hte=ho({name:"graphicalItems",initialState:ize,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:fa()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Zl(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:fa()},removeCartesianGraphicalItem:{reducer(t,e){var n=Zl(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:fa()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:fa()},removePolarGraphicalItem:{reducer(t,e){var n=Zl(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:fa()}}}),{addCartesianGraphicalItem:sze,replaceCartesianGraphicalItem:oze,removeCartesianGraphicalItem:lze,addPolarGraphicalItem:cze,removePolarGraphicalItem:uze}=Hte.actions,dze=Hte.reducer,hze=t=>{var e=Jr(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(sze(t)):n.current!==t&&e(oze({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(lze(n.current)),n.current=null)},[e]),null},gO=w.memo(hze);function mze(t){var e=Jr();return w.useLayoutEffect(()=>(e(cze(t)),()=>{e(uze(t))}),[e,t]),null}var fze=["key"],pze=["onMouseEnter","onClick","onMouseLeave"],gze=["id"],bze=["id"];function T9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Da(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T9(Object(n),!0).forEach(function(r){xze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xze(t,e,n){return(e=yze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yze(t){var e=vze(t,"string");return typeof e=="symbol"?e:e+""}function vze(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 rm(){return rm=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},rm.apply(null,arguments)}function mA(t,e){if(t==null)return{};var n,r,i=wze(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 wze(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 Sze(t){var e=w.useMemo(()=>cO(t.children,Ib),[t.children]),n=Gt(r=>j5e(r,t.id,e));return n==null?null:w.createElement(eze,{legendPayload:n})}var _ze=w.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:o,name:l,hide:c,tooltipType:u,id:d}=t,h={dataDefinedOnItem:r.map(f=>f.tooltipPayload),getPosition:f=>{var p;return(p=r[Number(f)])===null||p===void 0?void 0:p.tooltipPosition},settings:{stroke:i,strokeWidth:s,fill:o,dataKey:e,nameKey:n,name:om(l,e),hide:c,type:u,color:o,unit:"",graphicalItemId:d}};return w.createElement(dA,{tooltipEntrySettings:h})}),Nze=(t,e)=>t>e?"start":t<e?"end":"middle",kze=(t,e,n)=>vs(typeof e=="function"?e(t):e,n,n*.8),Cze=(t,e,n)=>{var{top:r,left:i,width:s,height:o}=e,l=fJ(s,o),c=i+vs(t.cx,s,s/2),u=r+vs(t.cy,o,o/2),d=vs(t.innerRadius,l,0),h=kze(n,t.outerRadius,l),f=t.maxRadius||Math.sqrt(s*s+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:h,maxRadius:f}},Aze=(t,e)=>{var n=Ri(e-t),r=Math.min(Math.abs(e-t),360);return n*r},Tze=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=hr("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=mA(e,fze);return w.createElement(db,rm({},i,{type:"linear",className:n}))},Mze=(t,e,n)=>{if(w.isValidElement(t))return w.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),w.isValidElement(r)))return r;var i=hr("recharts-pie-label-text",zte(t));return w.createElement(oA,rm({},e,{alignmentBaseline:"middle",className:i}),r)};function Pze(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:o}=n;if(!r||!i||!e)return null;var l=Is(n),c=Gf(i),u=Gf(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,h=e.map((f,p)=>{var x=(f.startAngle+f.endAngle)/2,v=ri(f.cx,f.cy,f.outerRadius+d,x),g=Da(Da(Da(Da({},l),f),{},{stroke:"none"},c),{},{index:p,textAnchor:Nze(v.x,f.cx)},v),y=Da(Da(Da(Da({},l),f),{},{fill:"none",stroke:f.fill},u),{},{index:p,points:[ri(f.cx,f.cy,f.outerRadius,x),v],key:"line"});return w.createElement(_s,{zIndex:Oa.label,key:"label-".concat(f.startAngle,"-").concat(f.endAngle,"-").concat(f.midAngle,"-").concat(p)},w.createElement(Sa,null,s&&Tze(s,y),Mze(i,g,Nr(f,o))))});return w.createElement(Sa,{className:"recharts-pie-labels"},h)}function jze(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(lA,{label:i}):w.createElement(Pze,{sectors:e,props:n,showLabels:r})}function Eze(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:o}=t,l=Gt(nm),c=Gt(eO),u=Gt(VLe),{onMouseEnter:d,onClick:h,onMouseLeave:f}=i,p=mA(i,pze),x=hO(d,i.dataKey,o),v=mO(f),g=fO(h,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((y,_)=>{if(y?.startAngle===0&&y?.endAngle===0&&e.length!==1)return null;var N=u==null||u===o,A=String(_)===l&&(c==null||i.dataKey===c)&&N,C=l?r:null,j=n&&A?n:C,k=Da(Da({},y),{},{stroke:y.stroke,tabIndex:-1,[VZ]:_,[qZ]:o});return w.createElement(Sa,rm({key:"sector-".concat(y?.startAngle,"-").concat(y?.endAngle,"-").concat(y.midAngle,"-").concat(_),tabIndex:-1,className:"recharts-pie-sector"},Av(p,y,_),{onMouseEnter:x(y,_),onMouseLeave:v(y,_),onClick:g(y,_)}),w.createElement(dO,rm({option:s??j,index:_,shapeType:"sector",isActive:A},k)))}))}function Dze(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,f=Math.abs(n.minAngle),p=Aze(l,c),x=Math.abs(p),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,g=r.filter(j=>Nr(j,u,0)!==0).length,y=(x>=360?g:g-1)*v,_=x-g*f-y,N=r.reduce((j,k)=>{var R=Nr(k,u,0);return j+(Vt(R)?R:0)},0),A;if(N>0){var C;A=r.map((j,k)=>{var R=Nr(j,u,0),M=Nr(j,d,k),D=Cze(n,s,j),G=(Vt(R)?R:0)/N,U,W=Da(Da({},j),i&&i[k]&&i[k].props);k?U=C.endAngle+Ri(p)*v*(R!==0?1:0):U=l;var L=U+Ri(p)*((R!==0?f:0)+G*_),ee=(U+L)/2,ae=(D.innerRadius+D.outerRadius)/2,Y=[{name:M,value:R,payload:W,dataKey:u,type:h,graphicalItemId:n.id}],se=ri(D.cx,D.cy,ae,ee);return C=Da(Da(Da(Da({},n.presentationProps),{},{percent:G,cornerRadius:typeof o=="string"?parseFloat(o):o,name:M,tooltipPayload:Y,midAngle:ee,middleRadius:ae,tooltipPosition:se},W),D),{},{value:R,dataKey:u,startAngle:U,endAngle:L,payload:W,paddingAngle:Ri(p)*v}),C})}return A}function Rze(t){var{showLabels:e,sectors:n,children:r}=t,i=w.useMemo(()=>!e||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,e]);return w.createElement(f5e,{value:e?i:void 0},r)}function Fze(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:f}=e,p=ox(e,"recharts-pie-"),x=n.current,[v,g]=w.useState(!1),y=w.useCallback(()=>{typeof f=="function"&&f(),g(!1)},[f]),_=w.useCallback(()=>{typeof h=="function"&&h(),g(!0)},[h]);return w.createElement(Rze,{showLabels:!v,sectors:i},w.createElement(sx,{animationId:p,begin:o,duration:l,isActive:s,easing:c,onAnimationStart:_,onAnimationEnd:y,key:p},N=>{var A,C=[],j=i&&i[0],k=(A=j?.startAngle)!==null&&A!==void 0?A:0;return i?.forEach((R,M)=>{var D=x&&x[M],G=M>0?Kf(R,"paddingAngle",0):0;if(D){var U=_r(D.endAngle-D.startAngle,R.endAngle-R.startAngle,N),W=Da(Da({},R),{},{startAngle:k+G,endAngle:k+U+G});C.push(W),k=W.endAngle}else{var{endAngle:L,startAngle:ee}=R,ae=_r(0,L-ee,N),Y=Da(Da({},R),{},{startAngle:k+G,endAngle:k+ae+G});C.push(Y),k=Y.endAngle}}),n.current=C,w.createElement(Sa,null,w.createElement(Eze,{sectors:C,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(jze,{showLabels:!v,sectors:i,props:e}),e.children)}var Lze={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:Oa.area};function Oze(t){var{id:e}=t,n=mA(t,gze),{hide:r,className:i,rootTabIndex:s}=t,o=w.useMemo(()=>cO(t.children,Ib),[t.children]),l=Gt(d=>E5e(d,e,o)),c=w.useRef(null),u=hr("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(Sa,{tabIndex:s,className:u})):w.createElement(_s,{zIndex:t.zIndex},w.createElement(_ze,{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,id:e}),w.createElement(Sa,{tabIndex:s,className:u},w.createElement(Fze,{props:Da(Da({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function vR(t){var e=_a(t,Lze),{id:n}=e,r=mA(e,bze),i=Is(r);return w.createElement(hA,{id:n,type:"pie"},s=>w.createElement(w.Fragment,null,w.createElement(mze,{type:"pie",id:s,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),w.createElement(Sze,rm({},r,{id:s})),w.createElement(Oze,rm({},r,{id:s}))))}vR.displayName="Pie";var Ize=["points"];function M9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Vj(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M9(Object(n),!0).forEach(function(r){zze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 BN(){return BN=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},BN.apply(null,arguments)}function Hze(t,e){if(t==null)return{};var n,r,i=$ze(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 $ze(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 Vze(t){var{option:e,dotProps:n,className:r}=t;if(w.isValidElement(e))return w.cloneElement(e,n);if(typeof e=="function")return e(n);var i=hr(r,typeof e!="boolean"?e.className:""),s=n??{},{points:o}=s,l=Hze(s,Ize);return w.createElement(Fte,BN({},l,{className:i}))}function qze(t,e){return t==null?!1:e?!0:t.length===1}function $te(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:o,needClip:l,clipPathId:c,zIndex:u=Oa.scatter}=t;if(!qze(e,n))return null;var d=uO(n),h=m2e(n),f=e.map((x,v)=>{var g,y,_=Vj(Vj(Vj({r:3},o),h),{},{index:v,cx:(g=x.x)!==null&&g!==void 0?g:void 0,cy:(y=x.y)!==null&&y!==void 0?y:void 0,dataKey:s,value:x.value,payload:x.payload,points:e});return w.createElement(Vze,{key:"dot-".concat(v),option:n,dotProps:_,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),w.createElement(_s,{zIndex:u},w.createElement(Sa,BN({className:r},p),f))}function P9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function j9(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P9(Object(n),!0).forEach(function(r){Gze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Gze(t,e,n){return(e=Wze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wze(t){var e=Kze(t,"string");return typeof e=="symbol"?e:e+""}function Kze(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 Vte=0,Yze={xAxis:{},yAxis:{},zAxis:{}},qte=ho({name:"cartesianAxis",initialState:Yze,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:fa()},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:fa()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:fa()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:fa()},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:fa()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:fa()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:fa()},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:fa()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:fa()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var s,o=i.widthHistory||[];if(o.length===3&&o[0]===o[2]&&r===o[1]&&r!==i.width&&Math.abs(r-((s=o[0])!==null&&s!==void 0?s:0))<=1)return;var l=[...o,r].slice(-3);t.yAxis[n]=j9(j9({},i),{},{width:r,widthHistory:l})}}}}),{addXAxis:Xze,replaceXAxis:Qze,removeXAxis:Zze,addYAxis:Jze,replaceYAxis:eUe,removeYAxis:tUe,addZAxis:Qnt,replaceZAxis:Znt,removeZAxis:Jnt,updateYAxisWidth:nUe}=qte.actions,rUe=qte.reducer,aUe=mt([vi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),iUe=mt([aUe,bd,xd],(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)}}),fA=()=>Gt(iUe),sUe=()=>Gt(YLe);function E9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function qj(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E9(Object(n),!0).forEach(function(r){oUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oUe(t,e,n){return(e=lUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lUe(t){var e=cUe(t,"string");return typeof e=="symbol"?e:e+""}function cUe(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 uUe=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=qj(qj(qj({},l),Gf(i)),E4(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(Fte,c),w.createElement(Sa,{className:"recharts-active-dot",clipPath:o},u)};function wR(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:o=Oa.activeDot}=t,l=Gt(nm),c=sUe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return xa(u)?null:w.createElement(_s,{zIndex:o},w.createElement(uUe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var D9=(t,e,n)=>{var r=n??t;if(!xa(r))return vs(r,e,0)},dUe=(t,e,n)=>{var r={},i=t.filter(JC),s=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>{var h=u[d.stackId];return h==null&&(h=[]),h.push(d),u[d.stackId]=h,u},r),l=Object.entries(o).map(u=>{var d,[h,f]=u,p=f.map(v=>v.dataKey),x=D9(e,n,(d=f[0])===null||d===void 0?void 0:d.barSize);return{stackId:h,dataKeys:p,barSize:x}}),c=s.map(u=>{var d=[u.dataKey].filter(f=>f!=null),h=D9(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:h}});return[...l,...c]};function R9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function A_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R9(Object(n),!0).forEach(function(r){hUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hUe(t,e,n){return(e=mUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mUe(t){var e=fUe(t,"string");return typeof e=="symbol"?e:e+""}function fUe(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 pUe(t,e,n,r,i){var s,o=r.length;if(!(o<1)){var l=vs(t,n,0,!0),c,u=[];if(Pn((s=r[0])===null||s===void 0?void 0:s.barSize)){var d=!1,h=n/o,f=r.reduce((_,N)=>_+(N.barSize||0),0);f+=(o-1)*l,f>=n&&(f-=(o-1)*l,l=0),f>=n&&h>0&&(d=!0,h*=.9,f=o*h);var p=(n-f)/2>>0,x={offset:p-l,size:0};c=r.reduce((_,N)=>{var A,C={stackId:N.stackId,dataKeys:N.dataKeys,position:{offset:x.offset+x.size+l,size:d?h:(A=N.barSize)!==null&&A!==void 0?A:0}},j=[..._,C];return x=C.position,j},u)}else{var v=vs(e,n,0,!0);n-2*v-(o-1)*l<=0&&(l=0);var g=(n-2*v-(o-1)*l)/o;g>1&&(g>>=0);var y=Pn(i)?Math.min(g,i):g;c=r.reduce((_,N,A)=>[..._,{stackId:N.stackId,dataKeys:N.dataKeys,position:{offset:v+(g+l)*A+(g-y)/2,size:y}}],u)}return c}}var gUe=(t,e,n,r,i,s,o)=>{var l=xa(o)?e:o,c=pUe(n,r,i!==s?i:s,t,l);return i!==s&&c!=null&&(c=c.map(u=>A_(A_({},u),{},{position:A_(A_({},u.position),{},{offset:u.position.offset-i/2})}))),c},bUe=(t,e)=>{var n=ZC(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)}}}},xUe=(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}};function yUe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&Pn(t.zIndex)?t.zIndex:e}var Gte=t=>{var{chartData:e}=t,n=Jr(),r=wi();return w.useEffect(()=>r?()=>{}:(n(Uq(e)),()=>{n(Uq(void 0))}),[e,n,r]),null},F9={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},Wte=ho({name:"brush",initialState:F9,reducers:{setBrushSettings(t,e){return e.payload==null?F9:e.payload}}}),{setBrushSettings:ert}=Wte.actions,vUe=Wte.reducer,wUe=(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)}},SUe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return wUe({x:e,y:n},{x:r,y:i})};function _Ue(t){return(t%180+180)%180}var NUe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=_Ue(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)},kUe={dots:[],areas:[],lines:[]},Kte=ho({name:"referenceElements",initialState:kUe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Zl(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=Zl(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=Zl(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:trt,removeDot:nrt,addArea:rrt,removeArea:art,addLine:CUe,removeLine:AUe}=Kte.actions,TUe=Kte.reducer,Yte=w.createContext(void 0),MUe=t=>{var{children:e}=t,[n]=w.useState("".concat(I0("recharts"),"-clip")),r=fA();if(r==null)return null;var{x:i,y:s,width:o,height:l}=r;return w.createElement(Yte.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:s,height:l,width:o}))),e)},PUe=()=>w.useContext(Yte);class jUe{constructor(e){var{x:n,y:r}=e;this.xAxisScale=n,this.yAxisScale=r}map(e,n){var r,i,{position:s}=n;return{x:(r=this.xAxisScale.map(e.x,{position:s}))!==null&&r!==void 0?r:0,y:(i=this.yAxisScale.map(e.y,{position:s}))!==null&&i!==void 0?i:0}}mapWithFallback(e,n){var r,i,{position:s,fallback:o}=n,l,c;return o==="rangeMin"?l=this.yAxisScale.rangeMin():o==="rangeMax"?l=this.yAxisScale.rangeMax():l=0,o==="rangeMin"?c=this.xAxisScale.rangeMin():o==="rangeMax"?c=this.xAxisScale.rangeMax():c=0,{x:(r=this.xAxisScale.map(e.x,{position:s}))!==null&&r!==void 0?r:c,y:(i=this.yAxisScale.map(e.y,{position:s}))!==null&&i!==void 0?i:l}}isInRange(e){var{x:n,y:r}=e,i=n==null||this.xAxisScale.isInRange(n),s=r==null||this.yAxisScale.isInRange(r);return i&&s}}function L9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function O9(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L9(Object(n),!0).forEach(function(r){EUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function EUe(t,e,n){return(e=DUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DUe(t){var e=RUe(t,"string");return typeof e=="symbol"?e:e+""}function RUe(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 FUe=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!Pn(e.x1)||!Pn(e.y1)||!Pn(e.x2)||!Pn(e.y2))return null;n=w.createElement("line",HN({},e,{className:"recharts-reference-line-line"}))}return n},LUe=(t,e,n,r,i,s)=>{var{x:o,width:l}=s,c=i.map(t,{position:n});if(!Pn(c)||e==="discard"&&!i.isInRange(c))return null;var u=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?u.reverse():u},OUe=(t,e,n,r,i,s)=>{var{y:o,height:l}=s,c=i.map(t,{position:n});if(!Pn(c)||e==="discard"&&!i.isInRange(c))return null;var u=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?u.reverse():u},IUe=(t,e,n,r)=>{var i=[r.mapWithFallback(t[0],{position:n,fallback:"rangeMin"}),r.mapWithFallback(t[1],{position:n,fallback:"rangeMax"})];return e==="discard"&&i.some(s=>!r.isInRange(s))?null:i},zUe=(t,e,n,r,i,s,o)=>{var{x:l,y:c,segment:u,ifOverflow:d}=o,h=Cl(l),f=Cl(c);return f?LUe(c,d,r,s,e,n):h?OUe(l,d,r,i,t,n):u!=null&&u.length===2?IUe(u,d,r,new jUe({x:t,y:e})):null};function UUe(t){var e=Jr();return w.useEffect(()=>(e(CUe(t)),()=>{e(AUe(t))})),null}function BUe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,o=wi(),l=PUe(),c=Gt(k=>Kc(k,e)),u=Gt(k=>Yc(k,n)),d=Gt(k=>Ob(k,"xAxis",e,o)),h=Gt(k=>Ob(k,"yAxis",n,o)),f=jv();if(!l||!f||c==null||u==null||d==null||h==null)return null;var p=zUe(d,h,f,t.position,c.orientation,u.orientation,t);if(!p)return null;var x=p[0],v=p[1];if(x==null||v==null)return null;var{x:g,y}=x,{x:_,y:N}=v,A=s==="hidden"?"url(#".concat(l,")"):void 0,C=O9(O9({clipPath:A},rs(t)),{},{x1:g,y1:y,x2:_,y2:N}),j=SUe({x1:g,y1:y,x2:_,y2:N});return w.createElement(_s,{zIndex:t.zIndex},w.createElement(Sa,{className:hr("recharts-reference-line",i)},FUe(r,C),w.createElement(Pte,HN({},j,{lowerWidth:j.width,upperWidth:j.width}),w.createElement(Ete,{label:t.label}),t.children)))}var HUe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",label:!1,stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Oa.line};function Hy(t){var e=_a(t,HUe);return w.createElement(w.Fragment,null,w.createElement(UUe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(BUe,e))}Hy.displayName="ReferenceLine";function Xte(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e){var i=t[r];i!==void 0&&n.push(i)}return n}function $Ue(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return NUe(r,n)}function VUe(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 Z0(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 qUe(t,e){return Xte(t,e+1)}function GUe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,h=function(){var x=r?.[c];if(x===void 0)return{v:Xte(r,u)};var v=c,g,y=()=>(g===void 0&&(g=n(x,v)),g),_=x.coordinate,N=c===0||Z0(t,_,y,d,l);N||(c=0,d=o,u+=1),N&&(d=_+t*(y()/2+i),c+=u)},f;u<=s.length;)if(f=h(),f)return f.v;return[]}function WUe(t,e,n,r,i){var s=(r||[]).slice(),o=s.length;if(o===0)return[];for(var{start:l,end:c}=e,u=1;u<=o;u++){for(var d=(o-1)%u,h=l,f=!0,p=function(){var A=r[v];if(A==null)return 0;var C=v,j,k=()=>(j===void 0&&(j=n(A,C)),j),R=A.coordinate,M=v===d||Z0(t,R,k,h,c);if(!M)return f=!1,1;M&&(h=R+t*(k()/2+i))},x,v=d;v<o&&(x=p(),!(x!==0&&x===1));v+=u);if(f){for(var g=[],y=d;y<o;y+=u){var _=r[y];_!=null&&g.push(_)}return g}}return[]}function I9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ms(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I9(Object(n),!0).forEach(function(r){KUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KUe(t,e,n){return(e=YUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YUe(t){var e=XUe(t,"string");return typeof e=="symbol"?e:e+""}function XUe(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 QUe(t,e,n,r,i){for(var s=(r||[]).slice(),o=s.length,{start:l}=e,{end:c}=e,u=function(f){var p=s[f];if(p==null)return 1;var x=p,v,g=()=>(v===void 0&&(v=n(p,f)),v);if(f===o-1){var y=t*(x.coordinate+t*g()/2-c);s[f]=x=ms(ms({},x),{},{tickCoord:y>0?x.coordinate-y*t:x.coordinate})}else s[f]=x=ms(ms({},x),{},{tickCoord:x.coordinate});if(x.tickCoord!=null){var _=Z0(t,x.tickCoord,g,l,c);_&&(c=x.tickCoord-t*(g()/2+i),s[f]=ms(ms({},x),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return s}function ZUe(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];if(d!=null){var h=n(d,l-1),f=t*(d.coordinate+t*h/2-u);if(o[l-1]=d=ms(ms({},d),{},{tickCoord:f>0?d.coordinate-f*t:d.coordinate}),d.tickCoord!=null){var p=Z0(t,d.tickCoord,()=>h,c,u);p&&(u=d.tickCoord-t*(h/2+i),o[l-1]=ms(ms({},d),{},{isShow:!0}))}}}for(var x=s?l-1:l,v=function(_){var N=o[_];if(N==null)return 1;var A=N,C,j=()=>(C===void 0&&(C=n(N,_)),C);if(_===0){var k=t*(A.coordinate-t*j()/2-c);o[_]=A=ms(ms({},A),{},{tickCoord:k<0?A.coordinate-k*t:A.coordinate})}else o[_]=A=ms(ms({},A),{},{tickCoord:A.coordinate});if(A.tickCoord!=null){var R=Z0(t,A.tickCoord,j,c,u);R&&(c=A.tickCoord+t*(j()/2+i),o[_]=ms(ms({},A),{},{isShow:!0}))}},g=0;g<x;g++)v(g);return o}function bO(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(Vt(c)||Rv.isSsr){var f;return(f=qUe(i,Vt(c)?c:0))!==null&&f!==void 0?f:[]}var p=[],x=l==="top"||l==="bottom"?"width":"height",v=d&&x==="width"?r0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},g=(C,j)=>{var k=typeof u=="function"?u(C.value,j):C.value;return x==="width"?$Ue(r0(k,{fontSize:e,letterSpacing:n}),v,h):r0(k,{fontSize:e,letterSpacing:n})[x]},y=i[0],_=i[1],N=i.length>=2&&y!=null&&_!=null?Ri(_.coordinate-y.coordinate):1,A=VUe(s,N,x);return c==="equidistantPreserveStart"?GUe(N,A,g,i,o):c==="equidistantPreserveEnd"?WUe(N,A,g,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=ZUe(N,A,g,i,o,c==="preserveStartEnd"):p=QUe(N,A,g,i,o),p.filter(C=>C.isShow))}var JUe=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},eBe=["axisLine","width","height","className","hide","ticks","axisType"];function tBe(t,e){if(t==null)return{};var n,r,i=nBe(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 nBe(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 ep(){return ep=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ep.apply(null,arguments)}function z9(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 ja(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z9(Object(n),!0).forEach(function(r){rBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rBe(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=iBe(t,"string");return typeof e=="symbol"?e:e+""}function iBe(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 Qu={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:Oa.axis};function sBe(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=ja(ja(ja({},c),Is(l)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!o||s==="bottom"&&o);u=ja(ja({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var h=+(s==="left"&&!o||s==="right"&&o);u=ja(ja({},u),{},{x1:e+h*r,y1:n,x2:e+h*r,y2:n+i})}return w.createElement("line",ep({},u,{className:hr("recharts-cartesian-axis-line",Kf(l,"className"))}))}function oBe(t,e,n,r,i,s,o,l,c){var u,d,h,f,p,x,v=l?-1:1,g=t.tickSize||o,y=Vt(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":u=d=t.coordinate,f=n+ +!l*i,h=f-v*g,x=h-v*c,p=y;break;case"left":h=f=t.coordinate,d=e+ +!l*r,u=d-v*g,p=u-v*c,x=y;break;case"right":h=f=t.coordinate,d=e+ +l*r,u=d+v*g,p=u+v*c,x=y;break;default:u=d=t.coordinate,f=n+ +l*i,h=f+v*g,x=h+v*c,p=y;break}return{line:{x1:u,y1:h,x2:d,y2:f},tick:{x:p,y:x}}}function lBe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function cBe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function uBe(t){var{option:e,tickProps:n,value:r}=t,i,s=hr(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,ja(ja({},n),{},{className:s}));else if(typeof e=="function")i=e(ja(ja({},n),{},{className:s}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=hr(o,zte(e))),i=w.createElement(oA,ep({},n,{className:o}),r)}return i}var dBe=w.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:f,y:p,width:x,height:v,tickSize:g,tickMargin:y,fontSize:_,letterSpacing:N,getTicksConfig:A,events:C,axisType:j}=t,k=bO(ja(ja({},A),{},{ticks:n}),_,N),R=lBe(d,h),M=cBe(d,h),D=Is(A),G=Gf(r),U={};typeof i=="object"&&(U=i);var W=ja(ja({},D),{},{fill:"none"},U),L=k.map(Y=>ja({entry:Y},oBe(Y,f,p,x,v,d,g,h,y))),ee=L.map(Y=>{var{entry:se,line:ce}=Y;return w.createElement(Sa,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(se.value,"-").concat(se.coordinate,"-").concat(se.tickCoord)},i&&w.createElement("line",ep({},W,ce,{className:hr("recharts-cartesian-axis-tick-line",Kf(i,"className"))})))}),ae=L.map((Y,se)=>{var ce,ye,{entry:Z,tick:ue}=Y,pe=ja(ja(ja(ja({verticalAnchor:M},D),{},{textAnchor:R,stroke:"none",fill:s},ue),{},{index:se,payload:Z,visibleTicksCount:k.length,tickFormatter:o,padding:c},u),{},{angle:(ce=(ye=u?.angle)!==null&&ye!==void 0?ye:D.angle)!==null&&ce!==void 0?ce:0}),be=ja(ja({},pe),G);return w.createElement(Sa,ep({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},Av(C,Z,se)),r&&w.createElement(uBe,{option:r,tickProps:be,value:"".concat(typeof o=="function"?o(Z.value,se):Z.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(j,"-ticks")},ae.length>0&&w.createElement(_s,{zIndex:Oa.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(j,"-tick-labels"),ref:e},ae)),ee.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(j,"-tick-lines")},ee))}),hBe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:o,ticks:l,axisType:c}=t,u=tBe(t,eBe),[d,h]=w.useState(""),[f,p]=w.useState(""),x=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var g;return JUe({ticks:x.current,label:(g=t.labelRef)===null||g===void 0?void 0:g.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=w.useCallback(g=>{if(g){var y=g.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=y;var _=y[0];if(_){var N=window.getComputedStyle(_),A=N.fontSize,C=N.letterSpacing;(A!==d||C!==f)&&(h(A),p(C))}}},[d,f]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(_s,{zIndex:t.zIndex},w.createElement(Sa,{className:hr("recharts-cartesian-axis",s)},w.createElement(sBe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Is(t)}),w.createElement(dBe,{ref:v,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:f,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),w.createElement(Pte,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(Ete,{label:t.label,labelRef:t.labelRef}),t.children)))}),xO=w.forwardRef((t,e)=>{var n=_a(t,Qu);return w.createElement(hBe,ep({},n,{ref:e}))});xO.displayName="CartesianAxis";var mBe=["x1","y1","x2","y2","key"],fBe=["offset"],pBe=["xAxisId","yAxisId"],gBe=["xAxisId","yAxisId"];function U9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function gs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U9(Object(n),!0).forEach(function(r){bBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bBe(t,e,n){return(e=xBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xBe(t){var e=yBe(t,"string");return typeof e=="symbol"?e:e+""}function yBe(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 uf(){return uf=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},uf.apply(null,arguments)}function $N(t,e){if(t==null)return{};var n,r,i=vBe(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 vBe(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 wBe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:o,ry:l}=t;return w.createElement("rect",{x:r,y:i,ry:l,width:s,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Qte(t){var{option:e,lineItemProps:n}=t,r;if(w.isValidElement(e))r=w.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:s,y1:o,x2:l,y2:c,key:u}=n,d=$N(n,mBe),h=(i=Is(d))!==null&&i!==void 0?i:{},{offset:f}=h,p=$N(h,fBe);r=w.createElement("line",uf({},p,{x1:s,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function SBe(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=$N(t,pBe),c=i.map((u,d)=>{var h=gs(gs({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(Qte,{key:"line-".concat(d),option:r,lineItemProps:h})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function _Be(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=$N(t,gBe),c=i.map((u,d)=>{var h=gs(gs({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(Qte,{option:r,lineItemProps:h,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function NBe(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,f)=>h-f);i!==u[0]&&u.unshift(0);var d=u.map((h,f)=>{var p=u[f+1],x=p==null,v=x?i+o-h:p-h;if(v<=0)return null;var g=f%e.length;return w.createElement("rect",{key:"react-".concat(f),y:h,x:r,height:v,width:s,stroke:"none",fill:e[g],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function kBe(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,f)=>h-f);i!==u[0]&&u.unshift(0);var d=u.map((h,f)=>{var p=u[f+1],x=p==null,v=x?i+o-h:p-h;if(v<=0)return null;var g=f%n.length;return w.createElement("rect",{key:"react-".concat(f),x:h,y:s,width:v,height:l,stroke:"none",fill:n[g],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var CBe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return UZ(bO(gs(gs(gs({},Qu),n),{},{ticks:BZ(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},ABe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return UZ(bO(gs(gs(gs({},Qu),n),{},{ticks:BZ(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},TBe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Oa.grid};function df(t){var e=q4(),n=G4(),r=YZ(),i=gs(gs({},_a(t,TBe)),{},{x:Vt(t.x)?t.x:r.left,y:Vt(t.y)?t.y:r.top,width:Vt(t.width)?t.width:r.width,height:Vt(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:h,horizontalValues:f,verticalValues:p}=i,x=wi(),v=Gt(M=>Tq(M,"xAxis",s,x)),g=Gt(M=>Tq(M,"yAxis",o,x));if(!Uc(u)||!Uc(d)||!Vt(l)||!Vt(c))return null;var y=i.verticalCoordinatesGenerator||CBe,_=i.horizontalCoordinatesGenerator||ABe,{horizontalPoints:N,verticalPoints:A}=i;if((!N||!N.length)&&typeof _=="function"){var C=f&&f.length,j=_({yAxis:g?gs(gs({},g),{},{ticks:C?f:g.ticks}):void 0,width:e??u,height:n??d,offset:r},C?!0:h);mN(Array.isArray(j),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(N=j)}if((!A||!A.length)&&typeof y=="function"){var k=p&&p.length,R=y({xAxis:v?gs(gs({},v),{},{ticks:k?p:v.ticks}):void 0,width:e??u,height:n??d,offset:r},k?!0:h);mN(Array.isArray(R),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(A=R)}return w.createElement(_s,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(wBe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(NBe,uf({},i,{horizontalPoints:N})),w.createElement(kBe,uf({},i,{verticalPoints:A})),w.createElement(SBe,uf({},i,{offset:r,horizontalPoints:N,xAxis:v,yAxis:g})),w.createElement(_Be,uf({},i,{offset:r,verticalPoints:A,xAxis:v,yAxis:g}))))}df.displayName="CartesianGrid";var MBe={},Zte=ho({name:"errorBars",initialState:MBe,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:irt,replaceErrorBar:srt,removeErrorBar:ort}=Zte.actions,PBe=Zte.reducer,jBe=["children"];function EBe(t,e){if(t==null)return{};var n,r,i=DBe(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 DBe(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 RBe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},FBe=w.createContext(RBe);function Jte(t){var{children:e}=t,n=EBe(t,jBe);return w.createElement(FBe.Provider,{value:n},e)}function pA(t,e){var n,r,i=Gt(u=>Kc(u,t)),s=Gt(u=>Yc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Mi.allowDataOverflow,l=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Pi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function yO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=fA(),{needClipX:s,needClipY:o,needClip:l}=pA(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:h}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.createElement("rect",{x:s?c:c-d/2,y:o?u:u-h/2,width:s?d:d*2,height:o?h:h*2}))}var ene=(t,e,n,r)=>$c(t,"xAxis",e,r),tne=(t,e,n,r)=>Hc(t,"xAxis",e,r),nne=(t,e,n,r)=>$c(t,"yAxis",n,r),rne=(t,e,n,r)=>Hc(t,"yAxis",n,r),LBe=mt([ur,ene,nne,tne,rne],(t,e,n,r,i)=>lc(t,"xAxis")?tm(e,r,!1):tm(n,i,!1)),OBe=(t,e,n,r,i)=>i;function IBe(t){return t.type==="line"}var zBe=mt([Bv,OBe],(t,e)=>t.filter(IBe).find(n=>n.id===e)),UBe=mt([ur,ene,nne,tne,rne,zBe,LBe,yL],(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:f}=s,p;if(f!=null&&f.length>0?p=f:p=c?.slice(u,d+1),p!=null)return C8e({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:h,bandSize:o,displayedData:p})}});function ane(t){var e=Gf(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 Gj={exports:{}},Wj={};var B9;function BBe(){if(B9)return Wj;B9=1;var t=sp();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 Wj.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var x={hasValue:!1,value:null};p.current=x}else x=p.current;p=o(function(){function g(C){if(!y){if(y=!0,_=C,C=h(C),f!==void 0&&x.hasValue){var j=x.value;if(f(j,C))return N=j}return N=C}if(j=N,n(_,C))return j;var k=h(C);return f!==void 0&&f(j,k)?(_=C,j):(_=C,N=k)}var y=!1,_,N,A=d===void 0?null:d;return[function(){return g(u())},A===null?void 0:function(){return g(A())}]},[u,d,h,f]);var v=r(c,p[0],p[1]);return s(function(){x.hasValue=!0,x.value=v},[v]),l(v),v},Wj}var H9;function HBe(){return H9||(H9=1,Gj.exports=BBe()),Gj.exports}HBe();function $Be(t){t()}function VBe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){$Be(()=>{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 $9={notify(){},get:()=>[]};function qBe(t,e){let n,r=$9,i=0,s=!1;function o(v){d();const g=r.subscribe(v);let y=!1;return()=>{y||(y=!0,g(),h())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return s}function d(){i++,n||(n=t.subscribe(c),r=VBe())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=$9)}function f(){s||(s=!0,d())}function p(){s&&(s=!1,h())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:f,tryUnsubscribe:p,getListeners:()=>r};return x}var GBe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",WBe=GBe(),KBe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",YBe=KBe(),XBe=()=>WBe||YBe?w.useLayoutEffect:w.useEffect,QBe=XBe();function V9(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function ZBe(t,e){if(V9(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])||!V9(t[n[i]],e[n[i]]))return!1;return!0}var JBe=Symbol.for("react-redux-context"),e8e=typeof globalThis<"u"?globalThis:{};function t8e(){if(!w.createContext)return{};const t=e8e[JBe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var n8e=t8e();function r8e(t){const{children:e,context:n,serverState:r,store:i}=t,s=w.useMemo(()=>{const c=qBe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);QBe(()=>{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||n8e;return w.createElement(l.Provider,{value:s},e)}var a8e=r8e,i8e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle","radius"]);function s8e(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(i8e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!ZBe(t[r],e[r]))return!1}else if(!s8e(t[r],e[r]))return!1;return!0}var o8e=["id"],l8e=["type","layout","connectNulls","needClip","shape"],c8e=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function J0(){return J0=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},J0.apply(null,arguments)}function q9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Nc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q9(Object(n),!0).forEach(function(r){u8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function u8e(t,e,n){return(e=d8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d8e(t){var e=h8e(t,"string");return typeof e=="symbol"?e:e+""}function h8e(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 vO(t,e){if(t==null)return{};var n,r,i=m8e(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 m8e(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 f8e=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:om(n,e),payload:t}]},p8e=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u,id:d}=t,h={dataDefinedOnItem:n,getPosition:sm,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:om(o,e),hide:l,type:u,color:r,unit:c,graphicalItemId:d}};return w.createElement(dA,{tooltipEntrySettings:h})}),ine=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function g8e(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var b8e=(t,e,n)=>{var r=n.reduce((p,x)=>p+x);if(!r)return ine(e,t);for(var i=Math.floor(t/r),s=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=(d=n[c])!==null&&d!==void 0?d:0,++c){var d,h=n[c];if(h!=null&&u+h>s){l=[...n.slice(0,c),s-u];break}}var f=l.length%2===0?[0,o]:[o];return[...g8e(n,i),...l,...f].map(p=>"".concat(p,"px")).join(", ")};function x8e(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:o}=r,{id:l}=r,c=vO(r,o8e),u=Is(c);return w.createElement($te,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:u,needClip:o,clipPathId:e})}function y8e(t){var{showLabels:e,children:n,points:r}=t,i=w.useMemo(()=>r?.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Nc(Nc({},c),{},{value:s.value,payload:s.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(sO,{value:e?i:void 0},n)}function G9(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=vO(s,l8e),f=Nc(Nc({},rs(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 w.createElement(w.Fragment,null,r?.length>1&&w.createElement(dO,J0({shapeType:"curve",option:d},f,{pathRef:n})),w.createElement(x8e,{points:r,clipPathId:e,props:s}))}function v8e(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function w8e(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:f,width:p,height:x,onAnimationEnd:v,onAnimationStart:g}=n,y=i.current,_=ox(o,"recharts-line-"),N=w.useRef(_),[A,C]=w.useState(!1),j=!A,k=w.useCallback(()=>{typeof v=="function"&&v(),C(!1)},[v]),R=w.useCallback(()=>{typeof g=="function"&&g(),C(!0)},[g]),M=v8e(r.current),D=w.useRef(0);N.current!==_&&(D.current=s.current,N.current=_);var G=D.current;return w.createElement(y8e,{points:o,showLabels:j},n.children,w.createElement(sx,{animationId:_,begin:u,duration:d,isActive:c,easing:h,onAnimationEnd:k,onAnimationStart:R,key:_},U=>{var W=_r(G,M+G,U),L=Math.min(W,M),ee;if(c)if(l){var ae="".concat(l).split(/[,\s]+/gim).map(ce=>parseFloat(ce));ee=b8e(L,M,ae)}else ee=ine(M,L);else ee=l==null?void 0:String(l);if(U>0&&M>0&&(i.current=o,s.current=Math.max(s.current,L)),y){var Y=y.length/o.length,se=U===1?o:o.map((ce,ye)=>{var Z=Math.floor(ye*Y);if(y[Z]){var ue=y[Z];return Nc(Nc({},ce),{},{x:_r(ue.x,ce.x,U),y:_r(ue.y,ce.y,U)})}return f?Nc(Nc({},ce),{},{x:_r(p*2,ce.x,U),y:_r(x/2,ce.y,U)}):Nc(Nc({},ce),{},{x:ce.x,y:ce.y})});return i.current=se,w.createElement(G9,{props:n,points:se,clipPathId:e,pathRef:r,strokeDasharray:ee})}return w.createElement(G9,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:ee})}),w.createElement(lA,{label:n.label}))}function S8e(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),s=w.useRef(null);return w.createElement(w8e,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var _8e=(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:Nr(t.payload,e)}};class N8e extends w.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:s,yAxisId:o,top:l,left:c,width:u,height:d,id:h,needClip:f,zIndex:p}=this.props;if(e)return null;var x=hr("recharts-line",i),v=h,{r:g,strokeWidth:y}=ane(n),_=uO(n),N=g*2+y,A=f?"url(#clipPath-".concat(_?"":"dots-").concat(v,")"):void 0;return w.createElement(_s,{zIndex:p},w.createElement(Sa,{className:x},f&&w.createElement("defs",null,w.createElement(yO,{clipPathId:v,xAxisId:s,yAxisId:o}),!_&&w.createElement("clipPath",{id:"clipPath-dots-".concat(v)},w.createElement("rect",{x:c-N/2,y:l-N/2,width:u+N,height:d+N}))),w.createElement(Jte,{xAxisId:s,yAxisId:o,data:r,dataPointFormatter:_8e,errorBarOffset:0},w.createElement(S8e,{props:this.props,clipPathId:v}))),w.createElement(wR,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var sne={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:Oa.line,type:"linear"};function k8e(t){var e=_a(t,sne),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:h,legendType:f,xAxisId:p,yAxisId:x,id:v}=e,g=vO(e,c8e),{needClip:y}=pA(p,x),_=fA(),N=lm(),A=wi(),C=Gt(D=>UBe(D,p,x,A,v));if(N!=="horizontal"&&N!=="vertical"||C==null||_==null)return null;var{height:j,width:k,x:R,y:M}=_;return w.createElement(N8e,J0({},g,{id:v,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,isAnimationActive:d,hide:u,label:h,legendType:f,xAxisId:p,yAxisId:x,points:C,layout:N,height:j,width:k,left:R,top:M,needClip:y}))}function C8e(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=Nr(u,o);if(e==="horizontal"){var f=hN({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=xa(h)?null:r.scale.map(h);return{x:f,y:p??null,value:h,payload:u}}var x=xa(h)?null:n.scale.map(h),v=hN({axis:r,ticks:s,bandSize:l,entry:u,index:d});return x==null||v==null?null:{x,y:v,value:h,payload:u}}).filter(Boolean)}function A8e(t){var e=_a(t,sne),n=wi();return w.createElement(hA,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(pO,{legendPayload:f8e(e)}),w.createElement(p8e,{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,id:r}),w.createElement(gO,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),w.createElement(k8e,J0({},e,{id:r}))))}var one=w.memo(A8e,Wv);one.displayName="Line";function Xc(t,e){var n,r;return(n=(r=t.graphicalItems.cartesianItems.find(i=>i.id===e))===null||r===void 0?void 0:r.xAxisId)!==null&&n!==void 0?n:Vte}function Qc(t,e){var n,r;return(n=(r=t.graphicalItems.cartesianItems.find(i=>i.id===e))===null||r===void 0?void 0:r.yAxisId)!==null&&n!==void 0?n:Vte}var lne=(t,e,n)=>$c(t,"xAxis",Xc(t,e),n),cne=(t,e,n)=>Hc(t,"xAxis",Xc(t,e),n),une=(t,e,n)=>$c(t,"yAxis",Qc(t,e),n),dne=(t,e,n)=>Hc(t,"yAxis",Qc(t,e),n),T8e=mt([ur,lne,une,cne,dne],(t,e,n,r,i)=>lc(t,"xAxis")?tm(e,r,!1):tm(n,i,!1)),M8e=(t,e)=>e,hne=mt([Bv,M8e],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),mne=t=>{var e=ur(t),n=lc(e,"xAxis");return n?"yAxis":"xAxis"},P8e=(t,e)=>{var n=mne(t);return n==="yAxis"?Qc(t,e):Xc(t,e)},j8e=(t,e,n)=>FN(t,mne(t),P8e(t,e),n),E8e=mt([hne,j8e],(t,e)=>{var n;if(!(t==null||e==null)){var{stackId:r}=t,i=ZC(t);if(!(r==null||i==null)){var s=(n=e[r])===null||n===void 0?void 0:n.stackedData,o=s?.find(l=>l.key===i);if(o!=null)return o.map(l=>[l[0],l[1]])}}}),D8e=mt([ur,lne,une,cne,dne,E8e,ZJ,T8e,hne,VFe],(t,e,n,r,i,s,o,l,c,u)=>{var{chartData:d,dataStartIndex:h,dataEndIndex:f}=o;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:p}=c,x;if(p&&p.length>0?x=p:x=d?.slice(h,f+1),x!=null)return Z8e({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:c,stackedData:s,displayedData:x,chartBaseValue:u,bandSize:l})}}),R8e=["id"],F8e=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Cf(){return Cf=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},Cf.apply(null,arguments)}function fne(t,e){if(t==null)return{};var n,r,i=L8e(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 L8e(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 W9(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 Zg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W9(Object(n),!0).forEach(function(r){O8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function O8e(t,e,n){return(e=I8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function I8e(t){var e=z8e(t,"string");return typeof e=="symbol"?e:e+""}function z8e(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 VN(t,e){return t&&t!=="none"?t:e}var U8e=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:o}=t;return[{inactive:o,dataKey:e,type:s,color:VN(r,i),value:om(n,e),payload:t}]},B8e=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u,id:d}=t,h={dataDefinedOnItem:n,getPosition:sm,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:om(o,e),hide:l,type:u,color:VN(r,s),unit:c,graphicalItemId:d}};return w.createElement(dA,{tooltipEntrySettings:h})});function H8e(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:o}=r,l=Is(r);return w.createElement($te,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function $8e(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 Zg(Zg({},c),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(sO,{value:e?i:void 0},n)}function K9(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,f=fne(s,R8e),p=Is(f),x=rs(f);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(Sa,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(db,Cf({},x,{id:h,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(db,Cf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(db,Cf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(H8e,{points:e,props:f,clipPathId:i}))}function V8e(t){var e,n,{alpha:r,baseLine:i,points:s,strokeWidth:o}=t,l=(e=s[0])===null||e===void 0?void 0:e.y,c=(n=s[s.length-1])===null||n===void 0?void 0:n.y;if(!Pn(l)||!Pn(c))return null;var u=r*Math.abs(l-c),d=Math.max(...s.map(h=>h.x||0));return Vt(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(h=>h.x||0),d)),Vt(d)?w.createElement("rect",{x:0,y:l<c?l:l-u,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(u)}):null}function q8e(t){var e,n,{alpha:r,baseLine:i,points:s,strokeWidth:o}=t,l=(e=s[0])===null||e===void 0?void 0:e.x,c=(n=s[s.length-1])===null||n===void 0?void 0:n.x;if(!Pn(l)||!Pn(c))return null;var u=r*Math.abs(l-c),d=Math.max(...s.map(h=>h.y||0));return Vt(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(h=>h.y||0),d)),Vt(d)?w.createElement("rect",{x:l<c?l:l-u,y:0,width:u,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function G8e(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?w.createElement(V8e,{alpha:e,points:r,baseLine:i,strokeWidth:s}):w.createElement(q8e,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function W8e(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:f,onAnimationEnd:p}=r,x=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),v=ox(x,"recharts-area-"),g=W4(),[y,_]=w.useState(!1),N=!y,A=w.useCallback(()=>{typeof p=="function"&&p(),_(!1)},[p]),C=w.useCallback(()=>{typeof f=="function"&&f(),_(!0)},[f]);if(g==null)return null;var j=i.current,k=s.current;return w.createElement($8e,{showLabels:N,points:o},r.children,w.createElement(sx,{animationId:v,begin:u,duration:d,isActive:c,easing:h,onAnimationEnd:A,onAnimationStart:C,key:v},R=>{if(j){var M=j.length/o.length,D=R===1?o:o.map((U,W)=>{var L=Math.floor(W*M);if(j[L]){var ee=j[L];return Zg(Zg({},U),{},{x:_r(ee.x,U.x,R),y:_r(ee.y,U.y,R)})}return U}),G;return Vt(l)?G=_r(k,l,R):xa(l)||rc(l)?G=_r(k,0,R):G=l.map((U,W)=>{var L=Math.floor(W*M);if(Array.isArray(k)&&k[L]){var ee=k[L];return Zg(Zg({},U),{},{x:_r(ee.x,U.x,R),y:_r(ee.y,U.y,R)})}return U}),R>0&&(i.current=D,s.current=G),w.createElement(K9,{points:D,baseLine:G,needClip:e,clipPathId:n,props:r})}return R>0&&(i.current=o,s.current=l),w.createElement(Sa,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(G8e,{alpha:R,points:o,baseLine:l,layout:g,strokeWidth:r.strokeWidth}))),w.createElement(Sa,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(K9,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(lA,{label:r.label}))}function K8e(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),s=w.useRef();return w.createElement(W8e,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class Y8e extends w.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:h,id:f,baseLine:p,zIndex:x}=this.props;if(e)return null;var v=hr("recharts-area",i),g=f,{r:y,strokeWidth:_}=ane(n),N=uO(n),A=y*2+_,C=l?"url(#clipPath-".concat(N?"":"dots-").concat(g,")"):void 0;return w.createElement(_s,{zIndex:x},w.createElement(Sa,{className:v},l&&w.createElement("defs",null,w.createElement(yO,{clipPathId:g,xAxisId:c,yAxisId:u}),!N&&w.createElement("clipPath",{id:"clipPath-dots-".concat(g)},w.createElement("rect",{x:o-A/2,y:s-A/2,width:d+A,height:h+A}))),w.createElement(K8e,{needClip:l,clipPathId:g,props:this.props})),w.createElement(wR,{points:r,mainColor:VN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}),this.props.isRange&&Array.isArray(p)&&w.createElement(wR,{points:p,mainColor:VN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}))}}var pne={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:Oa.area};function X8e(t){var e,n=_a(t,pne),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:h,isAnimationActive:f,legendType:p,stroke:x,xAxisId:v,yAxisId:g}=n,y=fne(n,F8e),_=lm(),N=mte(),{needClip:A}=pA(v,g),C=wi(),{points:j,isRange:k,baseLine:R}=(e=Gt(L=>D8e(L,t.id,C)))!==null&&e!==void 0?e:{},M=fA();if(_!=="horizontal"&&_!=="vertical"||M==null||N!=="AreaChart"&&N!=="ComposedChart")return null;var{height:D,width:G,x:U,y:W}=M;return!j||!j.length?null:w.createElement(Y8e,Cf({},y,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,baseLine:R,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:D,hide:h,layout:_,isAnimationActive:f==="auto"?!Rv.isSsr:f,isRange:k,legendType:p,needClip:A,points:j,stroke:x,width:G,left:U,top:W,xAxisId:v,yAxisId:g}))}var Q8e=(t,e,n,r,i)=>{var s=n??e;if(Vt(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 Z8e(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:f,bandSize:p}=t,x=i&&i.length,v=Q8e(s,o,n,l,c),g=s==="horizontal",y=!1,_=u.map((A,C)=>{var j,k,R,M;if(x)M=i[d+C];else{var D=Nr(A,r);Array.isArray(D)?(M=D,y=!0):M=[v,D]}var G=(j=(k=M)===null||k===void 0?void 0:k[1])!==null&&j!==void 0?j:null,U=G==null||x&&!e&&Nr(A,r)==null;if(g){var W;return{x:hN({axis:l,ticks:h,bandSize:p,entry:A,index:C}),y:U?null:(W=c.scale.map(G))!==null&&W!==void 0?W:null,value:M,payload:A}}return{x:U?null:(R=l.scale.map(G))!==null&&R!==void 0?R:null,y:hN({axis:c,ticks:f,bandSize:p,entry:A,index:C}),value:M,payload:A}}),N;return x||y?N=_.map(A=>{var C,j=Array.isArray(A.value)?A.value[0]:null;if(g){var k;return{x:A.x,y:j!=null&&A.y!=null&&(k=c.scale.map(j))!==null&&k!==void 0?k:null,payload:A.payload}}return{x:j!=null&&(C=l.scale.map(j))!==null&&C!==void 0?C:null,y:A.y,payload:A.payload}}):N=g?c.scale.map(v):l.scale.map(v),{points:_,baseLine:N??0,isRange:y}}function J8e(t){var e=_a(t,pne),n=wi();return w.createElement(hA,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(pO,{legendPayload:U8e(e)}),w.createElement(B8e,{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,id:r}),w.createElement(gO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:HZ(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(X8e,Cf({},e,{id:r}))))}var gne=w.memo(J8e,Wv);gne.displayName="Area";var e6e="Invariant failed";function t6e(t,e){throw new Error(e6e)}function SR(){return SR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},SR.apply(null,arguments)}function qN(t){return w.createElement(dO,SR({shapeType:"rectangle",activeClassName:"recharts-active-bar"},t))}var n6e=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Vt(e))return e;var s=Vt(r)||xa(r);return s?e(r,i):(s||t6e(),n)}},r6e=(t,e,n)=>n,a6e=(t,e)=>e,Kv=mt([Bv,a6e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),i6e=mt([Kv],t=>t?.maxBarSize),s6e=(t,e,n,r)=>r,o6e=mt([ur,Bv,Xc,Qc,r6e],(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")),l6e=(t,e,n)=>{var r=ur(t),i=Xc(t,e),s=Qc(t,e);if(!(i==null||s==null))return r==="horizontal"?FN(t,"yAxis",s,n):FN(t,"xAxis",i,n)},c6e=(t,e)=>{var n=ur(t),r=Xc(t,e),i=Qc(t,e);if(!(r==null||i==null))return n==="horizontal"?Aq(t,"xAxis",r):Aq(t,"yAxis",i)},u6e=mt([o6e,$Fe,c6e],dUe),d6e=(t,e,n)=>{var r,i,s=Kv(t,e);if(s==null)return 0;var o=Xc(t,e),l=Qc(t,e);if(o==null||l==null)return 0;var c=ur(t),u=uee(t),{maxBarSize:d}=s,h=xa(d)?u:d,f,p;return c==="horizontal"?(f=$c(t,"xAxis",o,n),p=Hc(t,"xAxis",o,n)):(f=$c(t,"yAxis",l,n),p=Hc(t,"yAxis",l,n)),(r=(i=tm(f,p,!0))!==null&&i!==void 0?i:h)!==null&&r!==void 0?r:0},bne=(t,e,n)=>{var r=ur(t),i=Xc(t,e),s=Qc(t,e);if(!(i==null||s==null)){var o,l;return r==="horizontal"?(o=$c(t,"xAxis",i,n),l=Hc(t,"xAxis",i,n)):(o=$c(t,"yAxis",s,n),l=Hc(t,"yAxis",s,n)),tm(o,l)}},h6e=mt([u6e,uee,HFe,dee,d6e,bne,i6e],gUe),m6e=(t,e,n)=>{var r=Xc(t,e);if(r!=null)return $c(t,"xAxis",r,n)},f6e=(t,e,n)=>{var r=Qc(t,e);if(r!=null)return $c(t,"yAxis",r,n)},p6e=(t,e,n)=>{var r=Xc(t,e);if(r!=null)return Hc(t,"xAxis",r,n)},g6e=(t,e,n)=>{var r=Qc(t,e);if(r!=null)return Hc(t,"yAxis",r,n)},b6e=mt([h6e,Kv],xUe),x6e=mt([l6e,Kv],bUe),y6e=mt([vi,H4,m6e,f6e,p6e,g6e,b6e,ur,ZJ,bne,x6e,Kv,s6e],(t,e,n,r,i,s,o,l,c,u,d,h,f)=>{var{chartData:p,dataStartIndex:x,dataEndIndex:v}=c;if(!(h==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||s==null||u==null)){var{data:g}=h,y;if(g!=null&&g.length>0?y=g:y=p?.slice(x,v+1),y!=null)return W6e({layout:l,barSettings:h,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:y,offset:t,cells:f,dataStartIndex:x})}}),v6e=["index"];function _R(){return _R=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_R.apply(null,arguments)}function w6e(t,e){if(t==null)return{};var n,r,i=S6e(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 S6e(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 xne=w.createContext(void 0),_6e=t=>{var e=w.useContext(xne);if(e!=null)return e.stackId;if(t!=null)return HZ(t)},N6e=(t,e)=>"recharts-bar-stack-clip-path-".concat(t,"-").concat(e),k6e=t=>{var e=w.useContext(xne);if(e!=null){var{stackId:n}=e;return"url(#".concat(N6e(n,t),")")}},yne=t=>{var{index:e}=t,n=w6e(t,v6e),r=k6e(e);return w.createElement(Sa,_R({className:"recharts-bar-stack-layer",clipPath:r},n))},C6e=["onMouseEnter","onMouseLeave","onClick"],A6e=["value","background","tooltipPosition"],T6e=["id"],M6e=["onMouseEnter","onClick","onMouseLeave"];function pd(){return pd=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},pd.apply(null,arguments)}function Y9(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ps(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y9(Object(n),!0).forEach(function(r){P6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function P6e(t,e,n){return(e=j6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j6e(t){var e=E6e(t,"string");return typeof e=="symbol"?e:e+""}function E6e(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){if(t==null)return{};var n,r,i=D6e(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 D6e(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 R6e=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:om(n,e),payload:t}]},F6e=w.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:o,unit:l,tooltipType:c,id:u}=t,d={dataDefinedOnItem:void 0,getPosition:sm,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:om(s,e),hide:o,type:c,color:i,unit:l,graphicalItemId:u}};return w.createElement(dA,{tooltipEntrySettings:d})});function L6e(t){var e=Gt(nm),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=s,u=GN(s,C6e),d=hO(o,r,s.id),h=mO(l),f=fO(c,r,s.id);if(!i||n==null)return null;var p=Gf(i);return w.createElement(_s,{zIndex:yUe(i,Oa.barBackground)},n.map((x,v)=>{var{value:g,background:y,tooltipPosition:_}=x,N=GN(x,A6e);if(!y)return null;var A=d(x,v),C=h(x,v),j=f(x,v),k=Ps(Ps(Ps(Ps(Ps({option:i,isActive:String(v)===e},N),{},{fill:"#eee"},y),p),Av(u,x,v)),{},{onMouseEnter:A,onMouseLeave:C,onClick:j,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return w.createElement(qN,pd({key:"background-bar-".concat(v)},k))}))}function O6e(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 Ps(Ps({},o),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:o,fill:s.fill})});return w.createElement(sO,{value:e?i:void 0},n)}function I6e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:o}=t,l=Gt(nm),c=Gt(eO),u=n&&String(s)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement(_s,{zIndex:Oa.activeBar},w.createElement(yne,{index:s},w.createElement(qN,pd({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o})))):w.createElement(qN,pd({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))}function z6e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return w.createElement(qN,pd({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function U6e(t){var e,{data:n,props:r}=t,i=(e=Is(r))!==null&&e!==void 0?e:{},{id:s}=i,o=GN(i,T6e),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:h,onMouseLeave:f}=r,p=GN(r,M6e),x=hO(d,c,s),v=mO(f),g=fO(h,c,s);return n?w.createElement(w.Fragment,null,n.map((y,_)=>w.createElement(yne,pd({index:_,key:"rectangle-".concat(y?.x,"-").concat(y?.y,"-").concat(y?.value,"-").concat(_),className:"recharts-bar-rectangle"},Av(p,y,_),{onMouseEnter:x(y,_),onMouseLeave:v(y,_),onClick:g(y,_)}),u?w.createElement(I6e,{shape:l,activeBar:u,baseProps:o,entry:y,index:_,dataKey:c}):w.createElement(z6e,{shape:l,baseProps:o,entry:y,index:_,dataKey:c})))):null}function B6e(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,f=ox(e,"recharts-bar-"),[p,x]=w.useState(!1),v=!p,g=w.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),y=w.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return w.createElement(O6e,{showLabels:v,rects:r},w.createElement(sx,{animationId:f,begin:o,duration:l,isActive:s,easing:c,onAnimationEnd:g,onAnimationStart:y,key:f},_=>{var N=_===1?r:r?.map((A,C)=>{var j=h&&h[C];if(j)return Ps(Ps({},A),{},{x:_r(j.x,A.x,_),y:_r(j.y,A.y,_),width:_r(j.width,A.width,_),height:_r(j.height,A.height,_)});if(i==="horizontal"){var k=_r(0,A.height,_),R=_r(A.stackedBarStart,A.y,_);return Ps(Ps({},A),{},{y:R,height:k})}var M=_r(0,A.width,_),D=_r(A.stackedBarStart,A.x,_);return Ps(Ps({},A),{},{width:M,x:D})});return _>0&&(n.current=N??null),N==null?null:w.createElement(Sa,null,w.createElement(U6e,{props:e,data:N}))}),w.createElement(lA,{label:e.label}),e.children)}function H6e(t){var e=w.useRef(null);return w.createElement(B6e,{previousRectanglesRef:e,props:t})}var vne=0,$6e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Nr(t,e)}};class V6e extends w.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=hr("recharts-bar",i),h=u;return w.createElement(Sa,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(yO,{clipPathId:h,xAxisId:s,yAxisId:o})),w.createElement(Sa,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(h,")"):void 0},w.createElement(L6e,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(H6e,this.props)))}}var q6e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:vne,xAxisId:0,yAxisId:0,zIndex:Oa.bar};function G6e(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}=pA(e,n),f=lm(),p=wi(),x=cO(t.children,Ib),v=Gt(_=>y6e(_,t.id,p,x));if(f!=="vertical"&&f!=="horizontal")return null;var g,y=v?.[0];return y==null||y.height==null||y.width==null?g=0:g=f==="vertical"?y.height/2:y.width/2,w.createElement(Jte,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:$6e,errorBarOffset:g},w.createElement(V6e,pd({},t,{layout:f,needClip:h,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function W6e(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:f,cells:p,parentViewBox:x,dataStartIndex:v}=t,g=e==="horizontal"?l:o,y=d?g.scale.domain():null,_=Pje({numericAxis:g}),N=g.scale.map(_);return h.map((A,C)=>{var j,k,R,M,D,G;if(d){var U=d[C+v];if(U==null)return null;j=kje(U,y)}else j=Nr(A,n),Array.isArray(j)||(j=[_,j]);var W=n6e(r,vne)(j[1],C);if(e==="horizontal"){var L,ee=l.scale.map(j[0]),ae=l.scale.map(j[1]);if(ee==null||ae==null)return null;k=C7({axis:o,ticks:c,bandSize:s,offset:i.offset,entry:A,index:C}),R=(L=ae??ee)!==null&&L!==void 0?L:void 0,M=i.size;var Y=ee-ae;if(D=rc(Y)?0:Y,G={x:k,y:f.top,width:M,height:f.height},Math.abs(W)>0&&Math.abs(D)<Math.abs(W)){var se=Ri(D||W)*(Math.abs(W)-Math.abs(D));R-=se,D+=se}}else{var ce=o.scale.map(j[0]),ye=o.scale.map(j[1]);if(ce==null||ye==null)return null;if(k=ce,R=C7({axis:l,ticks:u,bandSize:s,offset:i.offset,entry:A,index:C}),M=ye-ce,D=i.size,G={x:f.left,y:R,width:f.width,height:D},Math.abs(W)>0&&Math.abs(M)<Math.abs(W)){var Z=Ri(M||W)*(Math.abs(W)-Math.abs(M));M+=Z}}if(k==null||R==null||M==null||D==null)return null;var ue=Ps(Ps({},A),{},{stackedBarStart:N,x:k,y:R,width:M,height:D,value:d?j:j[1],payload:A,background:G,tooltipPosition:{x:k+M/2,y:R+D/2},parentViewBox:x},p&&p[C]&&p[C].props);return ue}).filter(Boolean)}function K6e(t){var e=_a(t,q6e),n=_6e(e.stackId),r=wi();return w.createElement(hA,{id:e.id,type:"bar"},i=>w.createElement(w.Fragment,null,w.createElement(pO,{legendPayload:R6e(e)}),w.createElement(F6e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType,id:i}),w.createElement(gO,{type:"bar",id:i,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:n,hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:r}),w.createElement(_s,{zIndex:e.zIndex},w.createElement(G6e,pd({},e,{id:i})))))}var Hg=w.memo(K6e,Wv);Hg.displayName="Bar";var Y6e=["domain","range"],X6e=["domain","range"];function X9(t,e){if(t==null)return{};var n,r,i=Q6e(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 Q6e(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 Q9(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 wne(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=X9(t,Y6e),{domain:s,range:o}=e,l=X9(e,X6e);return!Q9(n,s)||!Q9(r,o)?!1:Wv(i,l)}var Z6e=["type"],J6e=["dangerouslySetInnerHTML","ticks","scale"],eHe=["id","scale"];function NR(){return NR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},NR.apply(null,arguments)}function Z9(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 J9(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z9(Object(n),!0).forEach(function(r){tHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z9(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tHe(t,e,n){return(e=nHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nHe(t){var e=rHe(t,"string");return typeof e=="symbol"?e:e+""}function rHe(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 kR(t,e){if(t==null)return{};var n,r,i=aHe(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 aHe(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 iHe(t){var e=Jr(),n=w.useRef(null),r=W4(),{type:i}=t,s=kR(t,Z6e),o=XC(r,"xAxis",i),l=w.useMemo(()=>{if(o!=null)return J9(J9({},s),{},{type:o})},[s,o]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(Xze(l)):n.current!==l&&e(Qze({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(Zze(n.current)),n.current=null)},[e]),null}var sHe=t=>{var{xAxisId:e,className:n}=t,r=Gt(H4),i=wi(),s="xAxis",o=Gt(y=>Vee(y,s,e,i)),l=Gt(y=>Uee(y,e)),c=Gt(y=>V4e(y,e)),u=Gt(y=>wee(y,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:d,ticks:h,scale:f}=t,p=kR(t,J6e),{id:x,scale:v}=u,g=kR(u,eHe);return w.createElement(xO,NR({},p,g,{x:c.x,y:c.y,width:l.width,height:l.height,className:hr("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},oHe={allowDataOverflow:Mi.allowDataOverflow,allowDecimals:Mi.allowDecimals,allowDuplicatedCategory:Mi.allowDuplicatedCategory,angle:Mi.angle,axisLine:Qu.axisLine,height:Mi.height,hide:!1,includeHidden:Mi.includeHidden,interval:Mi.interval,label:!1,minTickGap:Mi.minTickGap,mirror:Mi.mirror,orientation:Mi.orientation,padding:Mi.padding,reversed:Mi.reversed,scale:Mi.scale,tick:Mi.tick,tickCount:Mi.tickCount,tickLine:Qu.tickLine,tickSize:Qu.tickSize,type:Mi.type,xAxisId:0},lHe=t=>{var e=_a(t,oHe);return w.createElement(w.Fragment,null,w.createElement(iHe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),w.createElement(sHe,e))},hf=w.memo(lHe,wne);hf.displayName="XAxis";var cHe=["type"],uHe=["dangerouslySetInnerHTML","ticks","scale"],dHe=["id","scale"];function CR(){return CR=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},CR.apply(null,arguments)}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 tG(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){hHe(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 hHe(t,e,n){return(e=mHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mHe(t){var e=fHe(t,"string");return typeof e=="symbol"?e:e+""}function fHe(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 AR(t,e){if(t==null)return{};var n,r,i=pHe(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 pHe(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 gHe(t){var e=Jr(),n=w.useRef(null),r=W4(),{type:i}=t,s=AR(t,cHe),o=XC(r,"yAxis",i),l=w.useMemo(()=>{if(o!=null)return tG(tG({},s),{},{type:o})},[o,s]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(Jze(l)):n.current!==l&&e(eUe({prev:n.current,next:l})),n.current=l)},[l,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(tUe(n.current)),n.current=null)},[e]),null}function bHe(t){var{yAxisId:e,className:n,width:r,label:i}=t,s=w.useRef(null),o=w.useRef(null),l=Gt(H4),c=wi(),u=Jr(),d="yAxis",h=Gt(j=>Bee(j,e)),f=Gt(j=>G4e(j,e)),p=Gt(j=>Vee(j,d,e,c)),x=Gt(j=>See(j,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!h||iO(i)||w.isValidElement(i)||x==null)){var j=s.current;if(j){var k=j.getCalculatedWidth();Math.round(h.width)!==Math.round(k)&&u(nUe({id:e,width:k}))}}},[p,h,u,i,e,r,x]),h==null||f==null||x==null)return null;var{dangerouslySetInnerHTML:v,ticks:g,scale:y}=t,_=AR(t,uHe),{id:N,scale:A}=x,C=AR(x,dHe);return w.createElement(xO,CR({},_,C,{ref:s,labelRef:o,x:f.x,y:f.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:h.width,height:h.height,className:hr("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:p,axisType:d}))}var xHe={allowDataOverflow:Pi.allowDataOverflow,allowDecimals:Pi.allowDecimals,allowDuplicatedCategory:Pi.allowDuplicatedCategory,angle:Pi.angle,axisLine:Qu.axisLine,hide:!1,includeHidden:Pi.includeHidden,interval:Pi.interval,label:!1,minTickGap:Pi.minTickGap,mirror:Pi.mirror,orientation:Pi.orientation,padding:Pi.padding,reversed:Pi.reversed,scale:Pi.scale,tick:Pi.tick,tickCount:Pi.tickCount,tickLine:Qu.tickLine,tickSize:Qu.tickSize,type:Pi.type,width:Pi.width,yAxisId:0},yHe=t=>{var e=_a(t,xHe);return w.createElement(w.Fragment,null,w.createElement(gHe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),w.createElement(bHe,e))},mf=w.memo(yHe,wne);mf.displayName="YAxis";var vHe=(t,e)=>e,wO=mt([vHe,ur,xee,Ii,ote,wd,oOe,vi],fOe),SO=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)}},Sne=Al("mouseClick"),_ne=Mv();_ne.startListening({actionCreator:Sne,effect:(t,e)=>{var n=t.payload,r=wO(e.getState(),SO(n));r?.activeIndex!=null&&e.dispatch(sLe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var TR=Al("mouseMove"),Nne=Mv(),T_=null;Nne.startListening({actionCreator:TR,effect:(t,e)=>{var n=t.payload;T_!==null&&cancelAnimationFrame(T_);var r=SO(n);T_=requestAnimationFrame(()=>{var i=e.getState(),s=KL(i,i.tooltip.settings.shared);if(s==="axis"){var o=wO(i,r);o?.activeIndex!=null?e.dispatch(Zee({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(Qee())}T_=null})}});function wHe(t,e){return e instanceof HTMLElement?"HTMLElement <".concat(e.tagName,' class="').concat(e.className,'">'):e===window?"global.window":t==="children"&&typeof e=="object"&&e!==null?"<<CHILDREN>>":e}var nG={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},kne=ho({name:"rootProps",initialState:nG,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:nG.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}}}),SHe=kne.reducer,{updateOptions:_He}=kne.actions,NHe=null,kHe={updatePolarOptions:(t,e)=>e.payload},Cne=ho({name:"polarOptions",initialState:NHe,reducers:kHe}),{updatePolarOptions:CHe}=Cne.actions,AHe=Cne.reducer,Ane=Al("keyDown"),Tne=Al("focus"),_O=Mv();_O.startListening({actionCreator:Ane,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=YL(i,gx(n),$v(n),qv(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=wd(n);if(s==="Enter"){var u=ON(n,"axis","hover",String(i.index));e.dispatch(pR({active:!i.active,activeIndex:i.index,activeCoordinate:u}));return}var d=X4e(n),h=d==="left-to-right"?1:-1,f=s==="ArrowRight"?1:-1,p=l+f*h;if(!(c==null||p>=c.length||p<0)){var x=ON(n,"axis","hover",String(p));e.dispatch(pR({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}}}}}});_O.startListening({actionCreator:Tne,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=ON(n,"axis","hover",String(s));e.dispatch(pR({active:!0,activeIndex:s,activeCoordinate:o}))}}}});var tl=Al("externalEvent"),Mne=Mv(),Kj=new Map;Mne.startListening({actionCreator:tl,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=Kj.get(i);s!==void 0&&cancelAnimationFrame(s);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:GLe(l),activeDataKey:eO(l),activeIndex:nm(l),activeLabel:ute(l),activeTooltipIndex:nm(l),isTooltipActive:WLe(l)};n(c,r)}finally{Kj.delete(i)}});Kj.set(i,o)}}});var THe=mt([fx],t=>t.tooltipItemPayloads),MHe=mt([THe,(t,e)=>e,(t,e,n)=>n],(t,e,n)=>{if(e!=null){var r=t.find(s=>s.settings.graphicalItemId===n);if(r!=null){var{getPosition:i}=r;if(i!=null)return i(e)}}}),Pne=Al("touchMove"),jne=Mv();jne.startListening({actionCreator:Pne,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=KL(r,r.tooltip.settings.shared);if(i==="axis"){var s=n.touches[0];if(s==null)return;var o=wO(r,SO({clientX:s.clientX,clientY:s.clientY,currentTarget:n.currentTarget}));o?.activeIndex!=null&&e.dispatch(Zee({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate}))}else if(i==="item"){var l,c=n.touches[0];if(document.elementFromPoint==null||c==null)return;var u=document.elementFromPoint(c.clientX,c.clientY);if(!u||!u.getAttribute)return;var d=u.getAttribute(VZ),h=(l=u.getAttribute(qZ))!==null&&l!==void 0?l:void 0,f=px(r).find(v=>v.id===h);if(d==null||f==null||h==null)return;var{dataKey:p}=f,x=MHe(r,d,h);e.dispatch(Xee({activeDataKey:p,activeIndex:d,activeCoordinate:x,activeGraphicalItemId:h}))}}}});var PHe=dZ({brush:vUe,cartesianAxis:rUe,chartData:qOe,errorBars:PBe,graphicalItems:dze,layout:vje,legend:CEe,options:UOe,polarAxis:k5e,polarOptions:AHe,referenceElements:TUe,rootProps:SHe,tooltip:oLe,zIndex:TOe}),jHe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return qPe({reducer:PHe,preloadedState:e,middleware:r=>{var i;return r({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([_ne.middleware,Nne.middleware,_O.middleware,Mne.middleware,jne.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(CZ({type:"raf"}))},devTools:{serialize:{replacer:wHe},name:"recharts-".concat(n)}})};function Ene(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=wi(),s=w.useRef(null);if(i)return n;s.current==null&&(s.current=jHe(e,r));var o=F4;return w.createElement(a8e,{context:o,store:s.current},n)}function EHe(t){var{layout:e,margin:n}=t,r=Jr(),i=wi();return w.useEffect(()=>{i||(r(bje(e)),r(gje(n)))},[r,i,e,n]),null}var Dne=w.memo(EHe,Wv);function Rne(t){var e=Jr();return w.useEffect(()=>{e(_He(t))},[e,t]),null}function rG(t){var{zIndex:e,isPanorama:n}=t,r=w.useRef(null),i=Jr();return w.useLayoutEffect(()=>(r.current&&i(COe({zIndex:e,element:r.current,isPanorama:n})),()=>{i(AOe({zIndex:e,isPanorama:n}))}),[i,e,n]),w.createElement("g",{tabIndex:-1,ref:r})}function aG(t){var{children:e,isPanorama:n}=t,r=Gt(gOe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),s=r.filter(o=>o>0);return w.createElement(w.Fragment,null,i.map(o=>w.createElement(rG,{key:o,zIndex:o,isPanorama:n})),e,s.map(o=>w.createElement(rG,{key:o,zIndex:o,isPanorama:n})))}var DHe=["children"];function RHe(t,e){if(t==null)return{};var n,r,i=FHe(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 FHe(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 WN(){return WN=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},WN.apply(null,arguments)}var LHe={width:"100%",height:"100%",display:"block"},OHe=w.forwardRef((t,e)=>{var n=q4(),r=G4(),i=lJ();if(!Uc(n)||!Uc(r))return null;var{children:s,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),w.createElement(N4,WN({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:LHe,ref:e}),s)}),IHe=t=>{var{children:e}=t,n=Gt(IC);if(!n)return null;var{width:r,height:i,y:s,x:o}=n;return w.createElement(N4,{width:r,height:i,x:o,y:s},e)},iG=w.forwardRef((t,e)=>{var{children:n}=t,r=RHe(t,DHe),i=wi();return i?w.createElement(IHe,null,w.createElement(aG,{isPanorama:!0},n)):w.createElement(OHe,WN({ref:e},r),w.createElement(aG,{isPanorama:!1},n))});function zHe(){var t=Jr(),[e,n]=w.useState(null),r=Gt(Lje);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;Pn(s)&&s!==r&&t(yje(s))}},[e,t,r]),n}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 UHe(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){BHe(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 BHe(t,e,n){return(e=HHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HHe(t){var e=$He(t,"string");return typeof e=="symbol"?e:e+""}function $He(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 qh(){return qh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},qh.apply(null,arguments)}var VHe=()=>(eIe(),null);function KN(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var qHe=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[s,o]=w.useState({containerWidth:KN((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:KN((r=t.style)===null||r===void 0?void 0:r.height)}),l=w.useCallback((u,d)=>{o(h=>{var f=Math.round(u),p=Math.round(d);return h.containerWidth===f&&h.containerHeight===p?h:{containerWidth:f,containerHeight:p}})},[]),c=w.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:h}=u.getBoundingClientRect();l(d,h);var f=x=>{var v=x[0];if(v!=null){var{width:g,height:y}=v.contentRect;l(g,y)}},p=new ResizeObserver(f);p.observe(u),i.current=p}},[e,l]);return w.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(Ev,{width:s.containerWidth,height:s.containerHeight}),w.createElement("div",qh({ref:c},t)))}),GHe=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=w.useState({containerWidth:KN(n),containerHeight:KN(r)}),o=w.useCallback((c,u)=>{s(d=>{var h=Math.round(c),f=Math.round(u);return d.containerWidth===h&&d.containerHeight===f?d:{containerWidth:h,containerHeight:f}})},[]),l=w.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return w.createElement(w.Fragment,null,w.createElement(Ev,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",qh({ref:l},t)))}),WHe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(Ev,{width:n,height:r}),w.createElement("div",qh({ref:e},t)))}),KHe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return typeof n=="string"||typeof r=="string"?w.createElement(GHe,qh({},t,{ref:e})):typeof n=="number"&&typeof r=="number"?w.createElement(WHe,qh({},t,{width:n,height:r,ref:e})):w.createElement(w.Fragment,null,w.createElement(Ev,{width:n,height:r}),w.createElement("div",qh({ref:e},t)))});function YHe(t){return t?qHe:KHe}var XHe=w.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:f,onTouchEnd:p,onTouchMove:x,onTouchStart:v,style:g,width:y,responsive:_,dispatchTouchEvents:N=!0}=t,A=w.useRef(null),C=Jr(),[j,k]=w.useState(null),[R,M]=w.useState(null),D=zHe(),G=$4(),U=G?.width>0?G.width:y,W=G?.height>0?G.height:i,L=w.useCallback(E=>{D(E),typeof e=="function"&&e(E),k(E),M(E),E!=null&&(A.current=E)},[D,e,k,M]),ee=w.useCallback(E=>{C(Sne(E)),C(tl({handler:s,reactEvent:E}))},[C,s]),ae=w.useCallback(E=>{C(TR(E)),C(tl({handler:u,reactEvent:E}))},[C,u]),Y=w.useCallback(E=>{C(Qee()),C(tl({handler:d,reactEvent:E}))},[C,d]),se=w.useCallback(E=>{C(TR(E)),C(tl({handler:h,reactEvent:E}))},[C,h]),ce=w.useCallback(()=>{C(Tne())},[C]),ye=w.useCallback(E=>{C(Ane(E.key))},[C]),Z=w.useCallback(E=>{C(tl({handler:o,reactEvent:E}))},[C,o]),ue=w.useCallback(E=>{C(tl({handler:l,reactEvent:E}))},[C,l]),pe=w.useCallback(E=>{C(tl({handler:c,reactEvent:E}))},[C,c]),be=w.useCallback(E=>{C(tl({handler:f,reactEvent:E}))},[C,f]),Ee=w.useCallback(E=>{C(tl({handler:v,reactEvent:E}))},[C,v]),$=w.useCallback(E=>{N&&C(Pne(E)),C(tl({handler:x,reactEvent:E}))},[C,N,x]),K=w.useCallback(E=>{C(tl({handler:p,reactEvent:E}))},[C,p]),T=YHe(_);return w.createElement(xte.Provider,{value:j},w.createElement(AQ.Provider,{value:R},w.createElement(T,{width:U??g?.width,height:W??g?.height,className:hr("recharts-wrapper",r),style:UHe({position:"relative",cursor:"default",width:U,height:W},g),onClick:ee,onContextMenu:Z,onDoubleClick:ue,onFocus:ce,onKeyDown:ye,onMouseDown:pe,onMouseEnter:ae,onMouseLeave:Y,onMouseMove:se,onMouseUp:be,onTouchEnd:K,onTouchMove:$,onTouchStart:Ee,ref:L},w.createElement(VHe,null),n)))}),QHe=["width","height","responsive","children","className","style","compact","title","desc"];function ZHe(t,e){if(t==null)return{};var n,r,i=JHe(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 JHe(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 Fne=w.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:o,style:l,compact:c,title:u,desc:d}=t,h=ZHe(t,QHe),f=Is(h);return c?w.createElement(w.Fragment,null,w.createElement(Ev,{width:n,height:r}),w.createElement(iG,{otherAttributes:f,title:u,desc:d},s)):w.createElement(XHe,{className:o,style:l,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},w.createElement(iG,{otherAttributes:f,title:u,desc:d,ref:e},w.createElement(MUe,null,s)))});function MR(){return MR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},MR.apply(null,arguments)}var e$e={top:5,right:5,bottom:5,left:5},t$e={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:e$e,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},NO=w.forwardRef(function(e,n){var r,i=_a(e.categoricalChartProps,t$e),{chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return w.createElement(Ene,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:s},w.createElement(Gte,{chartData:u.data}),w.createElement(Dne,{layout:i.layout,margin:i.margin}),w.createElement(Rne,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),w.createElement(Fne,MR({},i,{ref:n})))}),n$e=["axis"],r$e=w.forwardRef((t,e)=>w.createElement(NO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:n$e,tooltipPayloadSearcher:sA,categoricalChartProps:t,ref:e})),a$e=["axis","item"],M_=w.forwardRef((t,e)=>w.createElement(NO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:a$e,tooltipPayloadSearcher:sA,categoricalChartProps:t,ref:e}));function i$e(t){var e=Jr();return w.useEffect(()=>{e(CHe(t))},[e,t]),null}var s$e=["layout"];function PR(){return PR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},PR.apply(null,arguments)}function o$e(t,e){if(t==null)return{};var n,r,i=l$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function l$e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var c$e={top:5,right:5,bottom:5,left:5},Lne={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:c$e,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},u$e=w.forwardRef(function(e,n){var r,i=_a(e.categoricalChartProps,Lne),{layout:s}=i,o=o$e(i,s$e),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,h={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(Ene,{preloadedState:{options:h},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(Gte,{chartData:i.data}),w.createElement(Dne,{layout:s,margin:i.margin}),w.createElement(Rne,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),w.createElement(i$e,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(Fne,PR({},o,{ref:n})))});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 lG(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){d$e(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 d$e(t,e,n){return(e=h$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h$e(t){var e=m$e(t,"string");return typeof e=="symbol"?e:e+""}function m$e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var f$e=["item"],p$e=lG(lG({},Lne),{},{layout:"centric",startAngle:0,endAngle:360}),cG=w.forwardRef((t,e)=>{var n=_a(t,p$e);return w.createElement(u$e,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:f$e,tooltipPayloadSearcher:sA,categoricalChartProps:n,ref:e})}),g$e=["axis"],b$e=w.forwardRef((t,e)=>w.createElement(NO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:g$e,tooltipPayloadSearcher:sA,categoricalChartProps:t,ref:e}));const uG=[{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 x$e({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:o="humidity",thresholds:l}){const{t:c}=Et(),{mode:u}=lp(),[d,h]=w.useState("24h"),[f,p]=w.useState(o),x=u==="dark",{data:v}=Je({queryKey:["settings"],queryFn:ge.getSettings}),g=v?.time_format||"system";w.useEffect(()=>{if(!t)return;const K=T=>{T.key==="Escape"&&e()};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[t,e]);const y=uG.find(K=>K.value===d)?.hours||24,{data:_,isLoading:N,error:A}=Je({queryKey:["ams-history",n,i,y],queryFn:()=>ge.getAMSHistory(n,i,y),enabled:t,refetchInterval:6e4});if(!t)return null;const C=_?.data.map(K=>({time:(Jn(K.recorded_at)||new Date).getTime(),humidity:K.humidity,temperature:K.temperature}))||[],j=Date.now()-y*60*60*1e3,k=Date.now(),R=[...C];if(R.length>0){const K=R[0];K.time>j&&R.unshift({...K,time:j});const T=R[R.length-1];T.time<k&&R.push({...T,time:k})}const M=l?.humidityGood||40,D=l?.humidityFair||60,G=l?.tempGood||30,U=l?.tempFair||35,W=R[R.length-1],L=W?.humidity,ee=W?.temperature,ae=K=>{const T=K.filter(z=>z!=null);if(T.length<4)return"stable";const E=T.slice(0,Math.floor(T.length/4)),O=T.slice(-Math.floor(T.length/4)),q=E.reduce((z,V)=>z+V,0)/E.length,re=O.reduce((z,V)=>z+V,0)/O.length-q;return Math.abs(re)<2?"stable":re>0?"up":"down"},Y=ae(R.map(K=>K.humidity)),se=ae(R.map(K=>K.temperature)),ce=({trend:K})=>K==="up"?a.jsx(w3,{className:"w-4 h-4 text-red-400"}):K==="down"?a.jsx(HF,{className:"w-4 h-4 text-green-400"}):a.jsx(E1,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),ye=K=>K==null?"#9ca3af":K<=M?"#22a352":K<=D?"#d4a017":"#c62828",Z=K=>K==null?"#9ca3af":K<=G?"#22a352":K<=U?"#d4a017":"#c62828",ue=x?"#2d2d2d":"#ffffff",pe=x?"#1d1d1d":"#f3f4f6",be=x?"#3d3d3d":"#e5e7eb",Ee=x?"#ffffff":"#111827",$=x?"#9ca3af":"#4b5563";return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:ue},onClick:K=>K.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:be},children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold",style:{color:Ee},children:[s," ",c("common.history","History")]}),a.jsx("p",{className:"text-sm",style:{color:$},children:r})]}),a.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:$},children:a.jsx(Ut,{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 max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-3",children:[a.jsxs("div",{className:"inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit",style:{backgroundColor:pe},children:[a.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${f==="humidity"?"bg-blue-600 text-white":""}`,style:f!=="humidity"?{color:$}:void 0,children:[a.jsx(IF,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),a.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${f==="temperature"?"bg-orange-600 text-white":""}`,style:f!=="temperature"?{color:$}:void 0,children:[a.jsx(lC,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),a.jsx("div",{className:"inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit",style:{backgroundColor:pe},children:uG.map(K=>a.jsx("button",{onClick:()=>h(K.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===K.value?"bg-bambu-green text-white":""}`,style:d!==K.value?{color:$}:void 0,children:K.label},K.value))})]}),a.jsx("div",{className:"grid grid-cols-4 gap-4 max-[550px]:grid-cols-2",children:f==="humidity"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-2",style:{backgroundColor:pe},children:[a.jsx("p",{className:"text-xs",style:{color:$},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:ye(L)},children:L!=null?`${L}%`:"—"}),a.jsx(ce,{trend:Y})]})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-4",style:{backgroundColor:pe},children:[a.jsx("p",{className:"text-xs",style:{color:$},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:Ee},children:_?.avg_humidity!=null?`${_.avg_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-1",style:{backgroundColor:pe},children:[a.jsx("p",{className:"text-xs",style:{color:$},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-green-500",children:_?.min_humidity!=null?`${_.min_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-3",style:{backgroundColor:pe},children:[a.jsx("p",{className:"text-xs",style:{color:$},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:_?.max_humidity!=null?`${_.max_humidity}%`:"—"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-2",style:{backgroundColor:pe},children:[a.jsx("p",{className:"text-xs",style:{color:$},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:Z(ee)},children:ee!=null?`${ee}°C`:"—"}),a.jsx(ce,{trend:se})]})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-4",style:{backgroundColor:pe},children:[a.jsx("p",{className:"text-xs",style:{color:$},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:Ee},children:_?.avg_temperature!=null?`${_.avg_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-1",style:{backgroundColor:pe},children:[a.jsx("p",{className:"text-xs",style:{color:$},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-blue-500",children:_?.min_temperature!=null?`${_.min_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4 max-[550px]:order-3",style:{backgroundColor:pe},children:[a.jsx("p",{className:"text-xs",style:{color:$},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:_?.max_temperature!=null?`${_.max_temperature}°C`:"—"})]})]})}),a.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:pe},children:N?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:$},children:c("common.loading","Loading...")}):A?a.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):R.length===0?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:$},children:c("common.noData","No data available for this time range")}):a.jsx(Th,{width:"100%",height:300,children:a.jsxs(r$e,{data:R,children:[a.jsx(df,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),a.jsx(hf,{dataKey:"time",type:"number",domain:[Date.now()-y*60*60*1e3,Date.now()],tickFormatter:K=>{const T=new Date(K);return y>24?T.toLocaleDateString([],{day:"numeric",month:"short"}):T.toLocaleTimeString([],L1({hour:"2-digit",minute:"2-digit"},g))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),a.jsx(mf,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:f==="humidity"?[0,100]:["auto","auto"],tickFormatter:K=>f==="humidity"?`${K}%`:`${K}°C`}),a.jsx(Mh,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:K=>new Date(K).toLocaleString(void 0,L1({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},g)),formatter:K=>[f==="humidity"?`${K??0}%`:`${K??0}°C`,f==="humidity"?"Humidity":"Temperature"]}),a.jsx(oJ,{}),f==="humidity"?a.jsxs(a.Fragment,{children:[a.jsx(Hy,{y:M,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(Hy,{y:D,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):a.jsxs(a.Fragment,{children:[a.jsx(Hy,{y:G,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(Hy,{y:U,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),a.jsx(one,{type:"monotone",dataKey:f,name:f==="humidity"?"Humidity":"Temperature",stroke:f==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4},connectNulls:!0})]})})}),a.jsx("div",{className:"text-xs text-center",style:{color:$},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function Yj({data:t,children:e,disabled:n,className:r="",spoolman:i,inventory:s,configureSlot:o}){const{t:l}=Et(),[c,u]=w.useState(!1),[d,h]=w.useState("top"),[f,p]=w.useState(!1),x=w.useRef(null),v=w.useRef(null),g=w.useRef(null),y=()=>{const M=t.trayUuid;M&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(M).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)}).catch(()=>{_(M)}):_(M))},_=M=>{const D=document.createElement("textarea");D.value=M,D.style.position="fixed",D.style.opacity="0",document.body.appendChild(D),D.select();try{document.execCommand("copy"),p(!0),setTimeout(()=>p(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(D)};w.useEffect(()=>{if(c&&x.current&&v.current){const M=x.current.getBoundingClientRect(),D=v.current.offsetHeight,U=M.top-56,W=window.innerHeight-M.bottom;U<D+12&&W>U?h("bottom"):h("top")}},[c]);const N=()=>{n||(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>u(!0),80))},A=()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>u(!1),100)};w.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const C=M=>M<=15?"#ef4444":M<=30?"#f97316":M<=50?"#eab308":"#22c55e",j=M=>{if(!M)return!1;const D=M.replace("#",""),G=parseInt(D.slice(0,2),16),U=parseInt(D.slice(2,4),16),W=parseInt(D.slice(4,6),16);return(.299*G+.587*U+.114*W)/255>.6},k=t.colorHex?`#${t.colorHex.replace("#","")}`:null,R=s?.assignedSpool?.remainingWeightGrams??null;return a.jsxs("div",{ref:x,className:`relative ${r}`,onMouseEnter:N,onMouseLeave:A,children:[e,c&&a.jsxs("div",{ref:v,className:`
  8103. absolute left-1/2 -translate-x-1/2 z-50
  8104. ${d==="top"?"bottom-full mb-2":"top-full mt-2"}
  8105. animate-in fade-in-0 zoom-in-95 duration-150
  8106. `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:`
  8107. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  8108. rounded-lg shadow-xl overflow-hidden
  8109. backdrop-blur-sm
  8110. `,children:[a.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:k||"#3d3d3d"},children:[a.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),a.jsx("div",{className:`
  8111. absolute inset-0 flex items-center justify-center
  8112. font-semibold text-sm tracking-wide
  8113. ${j(k)?"text-black/80":"text-white/90"}
  8114. `,children:t.colorName}),a.jsx("div",{className:`
  8115. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  8116. ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
  8117. `,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:l("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:l("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(IF,{className:"w-3 h-3"}),l("ams.fill")]}),a.jsxs("span",{className:"text-xs text-white font-semibold flex items-center gap-1",children:[a.jsx("span",{children:t.fillLevel!==null?`${t.fillLevel}%`:"—"}),R!==null&&t.fillLevel!==null&&a.jsxs("span",{className:"text-[9px] text-bambu-gray font-normal",children:["• ",R,"g"]}),t.fillSource==="spoolman"&&t.fillLevel!==null&&a.jsx("span",{className:"text-[9px] text-bambu-gray font-normal",children:l("spoolman.fillSourceLabel")}),t.fillSource==="inventory"&&t.fillLevel!==null&&a.jsx("span",{className:"text-[9px] text-bambu-gray font-normal",children:l("inventory.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:C(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:l("spoolman.spoolId")}),a.jsxs("button",{onClick:M=>{M.stopPropagation(),y()},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),"..."]}),f?a.jsx(Zr,{className:"w-3 h-3 text-bambu-green"}):a.jsx(ec,{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:M=>M.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:l("spoolman.openInSpoolman"),children:[a.jsx(aa,{className:"w-3.5 h-3.5"}),l("spoolman.openInSpoolman")]}),!i.linkedSpoolId&&i.onLinkSpool&&a.jsxs("button",{onClick:M=>{M.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?l("spoolman.noUnlinkedSpools"):l("spoolman.linkToSpoolman"),children:[a.jsx(Ih,{className:"w-3.5 h-3.5"}),l("spoolman.linkToSpoolman")]})]}),s&&t.vendor!=="Bambu Lab"&&a.jsx("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:s.assignedSpool?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(si,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:l("inventory.assigned")})]}),a.jsxs("p",{className:"text-xs text-white truncate",children:[s.assignedSpool.brand?`${s.assignedSpool.brand} `:"",s.assignedSpool.material,s.assignedSpool.color_name?` - ${s.assignedSpool.color_name}`:""]}),s.onUnassignSpool&&a.jsxs("button",{onClick:M=>{M.stopPropagation(),s.onUnassignSpool?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-red-500/20 hover:bg-red-500/30 text-red-400",children:[a.jsx(cC,{className:"w-3.5 h-3.5"}),l("inventory.unassignSpool")]})]}):s.onAssignSpool?a.jsxs("button",{onClick:M=>{M.stopPropagation(),s.onAssignSpool?.()},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",children:[a.jsx(si,{className:"w-3.5 h-3.5"}),l("inventory.assignSpool")]}):null}),o?.enabled&&a.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("button",{onClick:M=>{M.stopPropagation(),o.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:l("ams.configureSlot"),children:[a.jsx(rd,{className:"w-3.5 h-3.5"}),l("ams.configure")]})})]})]}),a.jsx("div",{className:`
  8118. absolute left-1/2 -translate-x-1/2 w-0 h-0
  8119. border-l-[6px] border-l-transparent
  8120. border-r-[6px] border-r-transparent
  8121. ${d==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  8122. `})]})]})}function Xj({children:t,className:e="",configureSlot:n}){const{t:r}=Et(),[i,s]=w.useState(!1),o=w.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 w.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),a.jsxs("div",{className:`relative ${e}`,onMouseEnter:l,onMouseLeave:c,children:[t,i&&a.jsxs("div",{className:`
  8123. absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
  8124. animate-in fade-in-0 zoom-in-95 duration-150
  8125. `,children:[a.jsxs("div",{className:`
  8126. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  8127. rounded-md shadow-lg overflow-hidden
  8128. `,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(rd,{className:"w-3.5 h-3.5"}),r("ams.configure")]})})]}),a.jsx("div",{className:`
  8129. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  8130. border-l-[5px] border-l-transparent
  8131. border-r-[5px] border-r-transparent
  8132. border-t-[5px] border-t-bambu-dark-tertiary
  8133. `})]})]})}function y$e({isOpen:t,onClose:e,tagUid:n,trayUuid:r,printerId:i,amsId:s,trayId:o}){const{t:l}=Et(),c=Qt(),{showToast:u}=dn(),[d,h]=w.useState(""),{data:f,isLoading:p}=Je({queryKey:["inventory-spools"],queryFn:()=>ge.getSpools(!1),enabled:t}),x=w.useMemo(()=>f?f.filter(g=>{if(g.tag_uid||g.tray_uuid)return!1;if(!d)return!0;const y=d.toLowerCase();return g.material.toLowerCase().includes(y)||g.brand&&g.brand.toLowerCase().includes(y)||g.color_name&&g.color_name.toLowerCase().includes(y)}):[],[f,d]),v=ut({mutationFn:g=>ge.linkTagToSpool(g,{tag_uid:n||void 0,tray_uuid:r||void 0,tag_type:r?"bambulab":"generic",data_origin:"nfc_link"}),onSuccess:()=>{c.invalidateQueries({queryKey:["inventory-spools"]}),c.invalidateQueries({queryKey:["inventory-assignments"]}),u(l("inventory.tagLinked"),"success"),e()},onError:g=>{u(g.message||l("inventory.tagLinkFailed"),"error")}});return t?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 bg-bambu-dark-secondary rounded-xl shadow-xl w-full max-w-md mx-4 max-h-[80vh] flex flex-col border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[a.jsxs("div",{children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(ex,{className:"w-5 h-5 text-bambu-green"}),l("inventory.linkToSpool")]}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["AMS ",s," T",o," · Printer #",i]})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 border-b border-white/10",children:[a.jsxs("div",{className:"relative",children:[a.jsx(Er,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:d,onChange:g=>h(g.target.value),placeholder:l("inventory.searchSpools"),className:"w-full pl-9 pr-3 py-2 bg-bambu-dark rounded-lg border border-white/10 text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green"})]}),(n||r)&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 font-mono truncate",title:n||r,children:["Tag: ",n||r]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:p?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):x.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8 text-sm",children:l("inventory.noSpoolsMatch")}):x.map(g=>a.jsxs("button",{onClick:()=>v.mutate(g.id),disabled:v.isPending,className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-white/5 transition-colors text-left",children:[a.jsx("span",{className:"w-6 h-6 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:g.rgba?`#${g.rgba.substring(0,6)}`:"#808080"}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"text-sm text-white font-medium truncate",children:[g.brand?`${g.brand} `:"",g.material,g.subtype?` ${g.subtype}`:""]}),a.jsxs("div",{className:"text-xs text-bambu-gray truncate",children:[g.color_name||"No color"," · #",g.id]})]}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(g.label_weight-g.weight_used),"g"]})]},g.id))}),a.jsx("div",{className:"p-4 border-t border-white/10 flex justify-end",children:a.jsx(Oe,{variant:"ghost",onClick:e,children:l("inventory.cancel")||"Cancel"})})]})]}):null}function v$e({isOpen:t,onClose:e,printerId:n,amsId:r,trayId:i,trayInfo:s}){const{t:o}=Et(),l=Qt(),{showToast:c}=dn(),[u,d]=w.useState(null),[h,f]=w.useState(""),{data:p,isLoading:x}=Je({queryKey:["inventory-spools"],queryFn:()=>ge.getSpools(),enabled:t}),{data:v}=Je({queryKey:["spool-assignments"],queryFn:()=>ge.getAssignments(),enabled:t}),g=ut({mutationFn:j=>ge.assignSpool({spool_id:j,printer_id:n,ams_id:r,tray_id:i}),onSuccess:j=>{l.setQueryData(["spool-assignments"],k=>{const R=(k||[]).filter(M=>!(M.printer_id===n&&M.ams_id===r&&M.tray_id===i));return R.push(j),R}),l.invalidateQueries({queryKey:["spool-assignments"]}),c(o("inventory.assignSuccess"),"success"),e()},onError:j=>{c(`${o("inventory.assignFailed")}: ${j.message}`,"error")}});if(!t)return null;const y=new Set((v||[]).filter(j=>!(j.printer_id===n&&j.ams_id===r&&j.tray_id===i)).map(j=>j.spool_id)),_=r===254||r===255,N=p?.filter(j=>!y.has(j.id)&&(_||!j.tag_uid&&!j.tray_uuid)),A=N?.filter(j=>{if(!h)return!0;const k=h.toLowerCase();return j.material.toLowerCase().includes(k)||(j.brand?.toLowerCase().includes(k)??!1)||(j.color_name?.toLowerCase().includes(k)??!1)||(j.subtype?.toLowerCase().includes(k)??!1)}),C=()=>{u&&g.mutate(u)};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(si,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:o("inventory.assignSpool")})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[s&&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:[o("inventory.selectSpool"),":"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[s.color&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${s.color}`}}),a.jsx("span",{className:"text-white font-medium",children:s.type||o("ams.emptySlot")}),a.jsxs("span",{className:"text-bambu-gray",children:["(",s.location,")"]})]})]}),a.jsxs("div",{className:"relative",children:[a.jsx(Er,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:h,onChange:j=>f(j.target.value),placeholder:o("inventory.searchSpools"),className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsx("div",{children:x?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):A&&A.length>0?a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:A.map(j=>a.jsx("button",{onClick:()=>d(j.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${u===j.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:[j.rgba&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${j.rgba.substring(0,6)}`}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("p",{className:"text-white font-medium truncate",children:[j.brand?`${j.brand} `:"",j.material,j.subtype?` ${j.subtype}`:""]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[j.color_name||"",j.label_weight?` - ${j.label_weight}g`:"",j.label_weight?` (${Math.max(0,Math.round(j.label_weight-j.weight_used))}g ${o("ams.remainingUnit")})`:""]})]}),u===j.id&&a.jsx(Zr,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},j.id))}):N&&N.length===0?a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:a.jsx("p",{children:o("inventory.noManualSpools")})}):a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:a.jsx("p",{children:o("inventory.noSpoolsMatch")})})})]}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Oe,{variant:"secondary",onClick:e,children:o("common.cancel")}),a.jsx(Oe,{onClick:C,disabled:!u||g.isPending,children:g.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),o("inventory.assigning")]}):a.jsxs(a.Fragment,{children:[a.jsx(si,{className:"w-4 h-4"}),o("inventory.assignSpool")]})})]}),g.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:g.error.message})]})]})}function dG(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 P_(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 w$e=["PLA","PETG","PCTG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function hG(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of w$e){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 S$e(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const _$e={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"},mG=[{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"}],fG=[{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 pG(t){const e=t.toLowerCase().trim();return _$e[e]||null}function N$e(t){const e=t.indexOf("@");if(e<0)return null;const r=t.slice(e+1).trim().match(/^BBL\s+(.+?)(?:\s+[\d.]+\s*nozzle)?$/i);return r?r[1].trim():null}function One({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",printerModel:s,onSuccess:o,fullScreen:l}){const{t:c}=Et(),[u,d]=w.useState(""),[h,f]=w.useState(null),[p,x]=w.useState(""),[v,g]=w.useState(""),[y,_]=w.useState(""),[N,A]=w.useState(!1),[C,j]=w.useState(!1),{data:k,isLoading:R,isError:M}=Je({queryKey:["cloudSettings"],queryFn:()=>ge.getCloudSettings(),enabled:t,retry:!1}),{data:D,isLoading:G}=Je({queryKey:["localPresets"],queryFn:()=>ge.getLocalPresets(),enabled:t}),{data:U,isLoading:W}=Je({queryKey:["builtinFilaments"],queryFn:()=>ge.getBuiltinFilaments(),enabled:t,staleTime:1/0}),{data:L,isLoading:ee}=Je({queryKey:["kprofiles",n,i],queryFn:()=>ge.getKProfiles(n,i),enabled:t&&!!n}),{data:ae}=Je({queryKey:["colorCatalog"],queryFn:()=>ge.getColorCatalog(),enabled:t,staleTime:1/0}),Y=ut({mutationFn:async()=>{if(!u)throw new Error("No filament preset selected");const T=u.startsWith("local_"),E=u.startsWith("builtin_"),O=T?parseInt(u.replace("local_",""),10):null,q=E?u.replace("builtin_",""):null,B=T?D?.filament.find(Ce=>Ce.id===O):null,re=E?U?.find(Ce=>Ce.filament_id===q):null,z=!T&&!E?k?.filament.find(Ce=>Ce.setting_id===u):null;if(!T&&!E&&!z)throw new Error("Selected preset not found");if(T&&!B)throw new Error("Selected local preset not found");if(E&&!re)throw new Error("Selected builtin preset not found");const V=T?B.name:E?re.name:z.name,te=hG(V),Q=h?.slot_id??-1,ne=p||r.trayColor?.slice(0,6)||"FFFFFF",ie=V.replace(/@.+$/,"").trim();let me,fe;if(T){const Ce=(B?.filament_type||te.material||"").toUpperCase(),Ne={PLA:"GFL99","PLA-CF":"GFL98","PLA SILK":"GFL96","PLA HIGH SPEED":"GFL95",PETG:"GFG99","PETG HF":"GFG96","PETG-CF":"GFG98",PCTG:"GFG97",ABS:"GFB99",ASA:"GFB98",PC:"GFC99",PA:"GFN99","PA-CF":"GFN98",NYLON:"GFN99",TPU:"GFU99",PVA:"GFS99",HIPS:"GFS98",PE:"GFP99",PP:"GFP97"};me=Ne[Ce]||Ne[Ce.replace(/[-\s]?CF$/,"")]||Ne[Ce.replace(/\+$/,"")]||Ne[Ce.split(/[-\s]/)[0]]||"",fe=""}else if(E)me=q,fe="";else if(me=P_(u),fe=u,!u.startsWith("GFS"))try{const Ce=await ge.getCloudSettingDetail(u);Ce.filament_id?me=Ce.filament_id:Ce.base_id&&(me=P_(Ce.base_id),console.log(`Derived tray_info_idx from base_id: ${Ce.base_id} -> ${me}`))}catch(Ce){console.warn("Failed to fetch preset detail for filament_id:",Ce)}let oe=T&&B?.nozzle_temp_min?B.nozzle_temp_min:190,I=T&&B?.nozzle_temp_max?B.nozzle_temp_max:230;if(!T||E||!B?.nozzle_temp_min&&!B?.nozzle_temp_max){const Ce=(T&&B?.filament_type||te.material).toUpperCase();Ce.includes("PLA")?(oe=190,I=230):Ce.includes("PETG")?(oe=220,I=260):Ce.includes("ABS")||Ce.includes("ASA")?(oe=240,I=280):Ce.includes("TPU")?(oe=200,I=240):Ce==="PCTG"?(oe=220,I=260):Ce.includes("PC")?(oe=260,I=300):(Ce.includes("PA")||Ce.includes("NYLON"))&&(oe=250,I=290)}const F=h?.k_value?parseFloat(h.k_value):0,J=T?B?.filament_type||te.material||"PLA":te.material||"PLA",xe=await ge.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:me,tray_type:J,tray_sub_brands:ie,tray_color:ne+"FF",nozzle_temp_min:oe,nozzle_temp_max:I,cali_idx:Q,nozzle_diameter:i,setting_id:fe,kprofile_filament_id:h?.filament_id,kprofile_setting_id:h?.setting_id||void 0,k_value:F}),he=T?`local_${O}`:E?`builtin_${q}`:u,le=T?"local":E?"builtin":"cloud";try{await ge.saveSlotPreset(n,r.amsId,r.trayId,he,ie,le)}catch(Ce){console.warn("Failed to save slot preset mapping:",Ce)}return xe},onSuccess:()=>{A(!0),o?.(),setTimeout(()=>{A(!1),e()},1500)}}),se=ut({mutationFn:async()=>ge.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{A(!0),o?.(),setTimeout(()=>{A(!1),e()},1500)}}),ce=w.useMemo(()=>{const T=y.toLowerCase(),E=[],O=new Set,q=r.savedPresetId,B=r.trayInfoIdx;if(k?.filament)for(const re of k.filament){O.add(re.setting_id);const z=q===re.setting_id||B&&(re.setting_id===B||P_(re.setting_id)===B);if(!(!z&&T&&!re.name.toLowerCase().includes(T))){if(!z&&s){const V=N$e(re.name);if(V&&V.toUpperCase()!==s.toUpperCase())continue}E.push({id:re.setting_id,name:re.name,source:"cloud",isUser:S$e(re.setting_id)})}}if(D?.filament)for(const re of D.filament){const z=`local_${re.id}`,V=q===z;if(!(!V&&T&&!re.name.toLowerCase().includes(T))){if(!V&&s&&re.compatible_printers){const te=re.compatible_printers.split(";").map(Q=>{const ne=Q.trim(),ie=ne.match(/^BBL\s+(.+)/i);return ie?ie[1].trim().toUpperCase():ne.toUpperCase()}).filter(Boolean);if(te.length>0&&!te.includes(s.toUpperCase()))continue}E.push({id:z,name:re.name,source:"local",isUser:!1})}}if(U)for(const re of U){if(O.has(re.filament_id))continue;const z=re.filament_id.startsWith("GF")?"GFS"+re.filament_id.slice(2):re.filament_id;O.has(z)||(!T||re.name.toLowerCase().includes(T))&&E.push({id:`builtin_${re.filament_id}`,name:re.name,source:"builtin",isUser:!1})}return E.sort((re,z)=>{const V={cloud:0,local:1,builtin:2};return re.source!==z.source?V[re.source]-V[z.source]:re.isUser&&!z.isUser?-1:!re.isUser&&z.isUser?1:re.name.localeCompare(z.name)})},[k?.filament,D?.filament,U,y,s,r.savedPresetId,r.trayInfoIdx]),ye=w.useMemo(()=>{if(!u)return null;let T=null;if(u.startsWith("local_")){const q=parseInt(u.replace("local_",""),10);T=D?.filament.find(re=>re.id===q)?.name||null}else if(u.startsWith("builtin_")){const q=u.replace("builtin_","");T=U?.find(re=>re.filament_id===q)?.name||null}else k?.filament&&(T=k.filament.find(B=>B.setting_id===u)?.name||null);if(!T)return null;let E=T.replace(/@.+$/,"").trim();E.startsWith("# ")&&(E=E.slice(2).trim());const O=hG(E);return{fullName:E,material:O.material,brand:O.brand}},[u,k?.filament,D?.filament,U]),Z=ye?.fullName||"",ue=w.useMemo(()=>{if(!ae||!ye)return[];const{fullName:T,brand:E}=ye,O=T.replace(/^(Bambu\s*(Lab)?|eSUN|Polymaker|Overture|Sunlu|Hatchbox)\s*/i,"").trim();return ae.filter(q=>{const B=(q.material||"").toUpperCase(),re=q.manufacturer.toUpperCase();if(!(B===O.toUpperCase()||B.includes(O.toUpperCase())||O.toUpperCase().includes(B)))return!1;if(E){const V=E.toUpperCase();if(!re.includes(V)&&!V.includes(re))return!1}return!0})},[ae,ye]),pe=w.useMemo(()=>{if(!L?.profiles||!ye)return[];const{fullName:T,material:E,brand:O}=ye,q=T.toUpperCase(),B=E.toUpperCase(),re=O.toUpperCase();if(!B||B.length<2)return[];const z=L.profiles.filter(te=>{const Q=te.name.toUpperCase();if(re)return!(!Q.includes(re)||!Q.includes(B));if(Q.includes(q)||Q.includes(B))return!0;const ie={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[B]||[];for(const me of ie)if(Q.includes(me))return!0;return!1}),V=new Map;for(const te of z){const Q=`${te.name}|${te.k_value}`,ne=V.get(Q);ne?r.extruderId!==void 0&&te.extruder_id===r.extruderId&&ne.extruder_id!==r.extruderId&&V.set(Q,te):V.set(Q,te)}return Array.from(V.values())},[L?.profiles,ye,r.extruderId]);w.useEffect(()=>{if(t){if(r.savedPresetId)d(r.savedPresetId);else if(r.trayInfoIdx&&k?.filament){let T=k.filament.find(E=>E.setting_id===r.trayInfoIdx);T||(T=k.filament.find(E=>P_(E.setting_id)===r.trayInfoIdx)),T&&d(T.setting_id)}if(r.trayColor){const T=r.trayColor.slice(0,6);T&&x(T)}}else d(""),f(null),x(""),g(""),_(""),A(!1)},[t,r.savedPresetId,r.trayInfoIdx,r.trayColor,k?.filament]),w.useEffect(()=>{if(pe.length>0){if(r.caliIdx!=null&&r.caliIdx>0){const T=pe.find(E=>E.slot_id===r.caliIdx);if(T){f(T);return}}f(pe[0])}else f(null)},[u,pe,r.caliIdx]);const be=w.useCallback(T=>{T.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[t,be]),!t)return null;const Ee=R&&!M||G||W||ee,$=u&&!Y.isPending,K=p||r.trayColor?.slice(0,6)||"FFFFFF";return a.jsxs("div",{className:`fixed inset-0 z-50 flex ${l?"":"items-center justify-center"}`,children:[!l&&a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:l?"relative w-full h-full bg-bambu-dark-secondary flex flex-col":"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 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rd,{className:"w-5 h-5 text-bambu-blue"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:c("configureAmsSlot.title")}),l&&a.jsxs("div",{className:"flex items-center gap-2 ml-4 text-sm text-bambu-gray",children:[a.jsx("span",{className:"text-white/30",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.jsx("span",{className:"text-white/70",children:c("configureAmsSlot.slotLabel",{ams:dG(r.amsId,r.trayCount),slot:r.trayId+1})}),r.traySubBrands&&a.jsxs("span",{children:["(",r.traySubBrands,")"]})]})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:`p-4 overflow-y-auto ${l?"flex-1 min-h-0":"space-y-4 max-h-[60vh]"}`,children:[N&&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(yb,{className:"w-16 h-16 text-bambu-green mx-auto"}),a.jsx("p",{className:"text-lg font-semibold text-white",children:c("configureAmsSlot.slotConfigured")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:c("configureAmsSlot.settingsSentToPrinter")})]})}),!l&&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:c("configureAmsSlot.configuringSlot")}),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.jsx("span",{className:"text-white font-medium",children:c("configureAmsSlot.slotLabel",{ams:dG(r.amsId,r.trayCount),slot:r.trayId+1})}),r.traySubBrands&&a.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),Ee?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):l?a.jsxs("div",{className:"flex gap-4 h-full",children:[a.jsxs("div",{className:"w-1/2 flex flex-col min-h-0",children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:[c("configureAmsSlot.filamentProfile")," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",placeholder:c("configureAmsSlot.searchPresets"),value:y,onChange:T=>_(T.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 shrink-0"}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-1",children:ce.length===0?a.jsx("p",{className:"text-center py-4 text-bambu-gray",children:k?.filament?.length===0&&!D?.filament?.length?c("configureAmsSlot.noPresetsAvailable"):c("configureAmsSlot.noMatchingPresets")}):ce.map(T=>a.jsx("button",{ref:u===T.id?E=>{E?.scrollIntoView({block:"nearest"})}:void 0,onClick:()=>d(T.id),className:`w-full p-2 rounded-lg border text-left transition-colors ${u===T.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:T.name}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[T.source==="local"&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/20 text-green-400",children:c("profiles.localProfiles.badge")}),T.source==="builtin"&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400",children:c("configureAmsSlot.builtin")}),T.isUser&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:c("configureAmsSlot.custom")})]})]})},T.id))})]}),a.jsxs("div",{className:"w-1/2 flex flex-col gap-4 min-h-0 overflow-y-auto",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:[c("configureAmsSlot.kProfileLabel"),Z&&a.jsx("span",{className:"ml-2 text-xs text-bambu-blue",children:c("configureAmsSlot.filteringFor",{material:Z})})]}),pe.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:h?.name||"",onChange:T=>{const E=pe.find(O=>O.name===T.target.value);f(E||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:c("configureAmsSlot.noKProfile")}),pe.map(T=>a.jsxs("option",{value:T.name,children:[T.name," (K=",T.k_value,")"]},`${T.name}-${T.extruder_id}`))]}),a.jsx(En,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):u?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:c("configureAmsSlot.noMatchingKProfiles")}):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:c("configureAmsSlot.selectFilamentFirst")}),h&&a.jsx("p",{className:"text-xs text-bambu-green mt-1",children:c("configureAmsSlot.kFromCalibration",{value:h.k_value})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:c("configureAmsSlot.customColorLabel")}),ue.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1.5",children:c("configureAmsSlot.presetColors",{name:ye?.fullName})}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:ue.map(T=>a.jsxs("button",{onClick:()=>{const E=T.hex_color.replace("#","").toUpperCase();x(E),g(T.color_name)},className:`h-7 px-2 rounded-md border-2 transition-all flex items-center gap-1.5 ${p===T.hex_color.replace("#","").toUpperCase()?"border-bambu-green scale-105":"border-white/20 hover:border-white/40"}`,title:T.color_name,children:[a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/30 flex-shrink-0",style:{backgroundColor:T.hex_color}}),a.jsx("span",{className:"text-xs text-white/80 whitespace-nowrap",children:T.color_name})]},T.id))})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[mG.map(T=>a.jsx("button",{onClick:()=>{x(T.hex),g(T.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===T.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${T.hex}`},title:T.name},T.hex)),a.jsx("button",{onClick:()=>j(!C),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:c(C?"configureAmsSlot.showLessColors":"configureAmsSlot.showMoreColors"),children:C?"−":"+"})]}),C&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:fG.map(T=>a.jsx("button",{onClick:()=>{x(T.hex),g(T.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===T.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${T.hex}`},title:T.name},T.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:`#${K}`}}),a.jsx("input",{type:"text",placeholder:c("configureAmsSlot.colorPlaceholder"),value:v,onChange:T=>{const E=T.target.value;g(E);const O=pG(E);if(O)x(O);else{const q=E.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();q.length===6?x(q):q.length===3&&x(q.split("").map(B=>B+B).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"}),p&&a.jsx("button",{onClick:()=>{x(""),g("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:c("configureAmsSlot.clearCustomColor"),children:c("configureAmsSlot.clear")})]}),p&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1.5",children:c("configureAmsSlot.hexLabel",{hex:p})})]})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:[c("configureAmsSlot.filamentProfile")," ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:c("configureAmsSlot.searchPresets"),value:y,onChange:T=>_(T.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:ce.length===0?a.jsx("p",{className:"text-center py-4 text-bambu-gray",children:k?.filament?.length===0&&!D?.filament?.length?c("configureAmsSlot.noPresetsAvailable"):c("configureAmsSlot.noMatchingPresets")}):ce.map(T=>a.jsx("button",{ref:u===T.id?E=>{E?.scrollIntoView({block:"nearest"})}:void 0,onClick:()=>d(T.id),className:`w-full p-2 rounded-lg border text-left transition-colors ${u===T.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:T.name}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[T.source==="local"&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/20 text-green-400",children:c("profiles.localProfiles.badge")}),T.source==="builtin"&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400",children:c("configureAmsSlot.builtin")}),T.isUser&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:c("configureAmsSlot.custom")})]})]})},T.id))})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:[c("configureAmsSlot.kProfileLabel"),Z&&a.jsx("span",{className:"ml-2 text-xs text-bambu-blue",children:c("configureAmsSlot.filteringFor",{material:Z})})]}),pe.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:h?.name||"",onChange:T=>{const E=pe.find(O=>O.name===T.target.value);f(E||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:c("configureAmsSlot.noKProfile")}),pe.map(T=>a.jsxs("option",{value:T.name,children:[T.name," (K=",T.k_value,")"]},`${T.name}-${T.extruder_id}`))]}),a.jsx(En,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):u?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:c("configureAmsSlot.noMatchingKProfiles")}):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:c("configureAmsSlot.selectFilamentFirst")}),h&&a.jsx("p",{className:"text-xs text-bambu-green mt-1",children:c("configureAmsSlot.kFromCalibration",{value:h.k_value})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:c("configureAmsSlot.customColorLabel")}),ue.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1.5",children:c("configureAmsSlot.presetColors",{name:ye?.fullName})}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:ue.map(T=>a.jsxs("button",{onClick:()=>{const E=T.hex_color.replace("#","").toUpperCase();x(E),g(T.color_name)},className:`h-7 px-2 rounded-md border-2 transition-all flex items-center gap-1.5 ${p===T.hex_color.replace("#","").toUpperCase()?"border-bambu-green scale-105":"border-white/20 hover:border-white/40"}`,title:T.color_name,children:[a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/30 flex-shrink-0",style:{backgroundColor:T.hex_color}}),a.jsx("span",{className:"text-xs text-white/80 whitespace-nowrap",children:T.color_name})]},T.id))})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[mG.map(T=>a.jsx("button",{onClick:()=>{x(T.hex),g(T.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===T.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${T.hex}`},title:T.name},T.hex)),a.jsx("button",{onClick:()=>j(!C),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:c(C?"configureAmsSlot.showLessColors":"configureAmsSlot.showMoreColors"),children:C?"−":"+"})]}),C&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:fG.map(T=>a.jsx("button",{onClick:()=>{x(T.hex),g(T.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===T.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${T.hex}`},title:T.name},T.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:`#${K}`}}),a.jsx("input",{type:"text",placeholder:c("configureAmsSlot.colorPlaceholder"),value:v,onChange:T=>{const E=T.target.value;g(E);const O=pG(E);if(O)x(O);else{const q=E.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();q.length===6?x(q):q.length===3&&x(q.split("").map(B=>B+B).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"}),p&&a.jsx("button",{onClick:()=>{x(""),g("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:c("configureAmsSlot.clearCustomColor"),children:c("configureAmsSlot.clear")})]}),p&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1.5",children:c("configureAmsSlot.hexLabel",{hex:p})})]})]})]}),a.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[a.jsx(Oe,{variant:"secondary",onClick:()=>se.mutate(),disabled:se.isPending||Y.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:se.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),c("configureAmsSlot.resetting")]}):a.jsxs(a.Fragment,{children:[a.jsx(co,{className:"w-4 h-4"}),c("configureAmsSlot.resetSlot")]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Oe,{variant:"secondary",onClick:e,children:c("configureAmsSlot.cancel")}),a.jsx(Oe,{onClick:()=>Y.mutate(),disabled:!$,children:Y.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),c("configureAmsSlot.configuring")]}):a.jsxs(a.Fragment,{children:[a.jsx(rd,{className:"w-4 h-4"}),c("configureAmsSlot.configureSlot")]})})]})]}),(Y.isError||se.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:Y.error?.message||se.error?.message})]})]})}function gG(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function La(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Oc(t,e,n=40){const r=La(t),i=La(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 kO(t,e,n,r){if(r)return"External";const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function YN(t,e,n){return n?254+e:t>=128?t:t*4+e}function bG(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return(Jn(t)?.getTime()??0)>e}const xG={"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"},k$e={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 Qj(t){if(!t)return null;if(xG[t])return xG[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return k$e[n]||null}function Zj(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,f=r/255;i===d?l=((h-f)/u+(h<f?6:0))/6:i===h?l=((f-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 Jj(t){return(t??.02).toFixed(3)}function yG({side:t}){const{mode:e}=lp(),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 CO(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 C$e(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 Ine(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 zne(t,e){return t?t.startsWith("HH")?e("printers.nozzleHighFlow"):t.startsWith("HS")?e("printers.nozzleStandardFlow"):"":""}function Une({slot:t,index:e,activeStatus:n,filamentName:r,children:i}){const{t:s}=Et(),[o,l]=w.useState(!1),[c,u]=w.useState("top"),d=w.useRef(null),h=w.useRef(null),f=w.useRef(null),p=!t.nozzle_diameter&&!t.nozzle_type,x=t.stat===1;w.useEffect(()=>{if(o&&d.current&&h.current){const A=d.current.getBoundingClientRect(),C=h.current.offsetHeight,k=A.top-56,R=window.innerHeight-A.bottom;k<C+12&&R>k?u("bottom"):u("top")}},[o]);const v=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>l(!0),80)},g=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const y=CO(t.filament_color),_=Ine(t.nozzle_type,s),N=zne(t.nozzle_type,s);return a.jsxs("div",{ref:d,className:"relative",onMouseEnter:v,onMouseLeave:g,children:[i,o&&a.jsxs("div",{ref:h,className:`
  8134. absolute left-1/2 -translate-x-1/2 z-50
  8135. ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
  8136. animate-in fade-in-0 zoom-in-95 duration-150
  8137. `,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:p?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"]})]}),_&&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:_})]}),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||x?"bg-green-900/50 text-green-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s(n?"printers.nozzleActive":x?"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})]}),(y||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:[y&&a.jsx("div",{className:"w-3 h-3 rounded-sm border border-white/20",style:{backgroundColor:y}}),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:`
  8138. absolute left-1/2 -translate-x-1/2 w-0 h-0
  8139. border-l-[6px] border-l-transparent
  8140. border-r-[6px] border-r-transparent
  8141. ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  8142. `})]})]})}function A$e({leftSlot:t,rightSlot:e,activeNozzle:n,filamentInfo:r,children:i}){const{t:s}=Et(),[o,l]=w.useState(!1),[c,u]=w.useState("top"),d=w.useRef(null),h=w.useRef(null),f=w.useRef(null);w.useEffect(()=>{if(o&&d.current&&h.current){const g=d.current.getBoundingClientRect(),y=h.current.offsetHeight,N=g.top-56,A=window.innerHeight-g.bottom;N<y+12&&A>N?u("bottom"):u("top")}},[o]);const p=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>l(!0),80)},x=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>l(!1),100)};if(w.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),!t&&!e)return a.jsx(a.Fragment,{children:i});const v=(g,y)=>{const _=n===y,N=Ine(g.nozzle_type,s),A=zne(g.nozzle_type,s),C=CO(g.filament_color),j=g.filament_id?r?.[g.filament_id]?.name:void 0;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 ${_?"text-amber-400":"text-bambu-gray"}`,children:s(y==="L"?"common.left":"common.right")}),g.nozzle_diameter&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:s("printers.nozzleDiameter")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[g.nozzle_diameter," mm"]})]}),N&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:s("printers.nozzleType")}),a.jsx("span",{className:"text-[10px] text-white font-semibold",children:N})]}),A&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:s("printers.nozzleFlow")}),a.jsx("span",{className:"text-[10px] text-white font-semibold",children:A})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:s("printers.nozzleStatus")}),a.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${_?"bg-green-900/50 text-green-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s(_?"printers.nozzleActive":"printers.nozzleIdle")})]}),g.wear!=null&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:s("printers.nozzleWear")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[g.wear,"%"]})]}),y==="R"&&g.max_temp>0&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:s("printers.nozzleMaxTemp")}),a.jsxs("span",{className:"text-xs text-white font-semibold",children:[g.max_temp,"°C"]})]}),y==="R"&&g.serial_number&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:s("printers.nozzleSerial")}),a.jsx("span",{className:"text-[10px] text-white font-mono",children:g.serial_number})]}),(C||g.filament_type||g.filament_id)&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] text-bambu-gray",children:s("printers.nozzleFilament")}),a.jsxs("div",{className:"flex items-center gap-1",children:[C&&a.jsx("div",{className:"w-3 h-3 rounded-sm border border-white/20",style:{backgroundColor:C}}),a.jsx("span",{className:"text-[10px] text-white font-semibold truncate max-w-[100px]",children:j||g.filament_type||g.filament_id||""})]})]})]})};return a.jsxs("div",{ref:d,className:"relative flex-1",onMouseEnter:p,onMouseLeave:x,children:[i,o&&a.jsxs("div",{ref:h,className:`
  8143. absolute left-1/2 -translate-x-1/2 z-50
  8144. ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
  8145. animate-in fade-in-0 zoom-in-95 duration-150
  8146. `,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&&v(t,"L"),t&&e&&a.jsx("div",{className:"w-px bg-bambu-dark-tertiary/50"}),e&&v(e,"R")]})}),a.jsx("div",{className:`
  8147. absolute left-1/2 -translate-x-1/2 w-0 h-0
  8148. border-l-[6px] border-l-transparent
  8149. border-r-[6px] border-r-transparent
  8150. ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  8151. `})]})]})}function T$e({slots:t,filamentInfo:e}){const{t:n}=Et(),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:CO(l.filament_color),h=d?C$e(l.filament_color):!1;return a.jsx(Une,{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 vG({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 M$e({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 P$e({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 j$e({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 E$e({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 D$e({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 eE({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 wG({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=vG:s<=l?d=M$e:d=P$e,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 SG({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=j$e):t<=o?(l="#d4a017",c="Fair",u=E$e):(l="#c62828",c="Bad",u=D$e),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 ah(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 tE(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function nE(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 R$e(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("h2dpro")||e.includes("h2d-pro")?"/img/printers/h2dpro.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 F$e(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 rE(t){return t?!!(t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function L$e({url:t,printName:e}){const{t:n}=Et(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(!1),u=w.useMemo(()=>{if(!t)return null;const d=t.includes("?")?"&":"?";return`${t}${d}v=${encodeURIComponent(e||Date.now().toString())}`},[t,e]);return w.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(ni,{className:"w-8 h-8 text-bambu-gray"})]}):a.jsx(ni,{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 O$e({printers:t}){const{t:e}=Et(),n=Qt(),[r,i]=w.useState(0);w.useEffect(()=>{let l=!1;const c=n.getQueryCache().subscribe(()=>{l||(l=!0,requestAnimationFrame(()=>{i(u=>u+1),l=!1}))});return()=>c()},[n]);const{counts:s,nextFinish:o}=w.useMemo(()=>{let l=0,c=0,u=0,d=0,h=null,f=null,p=0;return t?.forEach(x=>{const v=n.getQueryData(["printerStatus",x.id]);v===void 0?d++:v.connected?v.state==="RUNNING"?(l++,v.remaining_time!=null&&v.remaining_time>0&&(f===null||v.remaining_time<f)&&(f=v.remaining_time,h=x.name,p=v.progress||0)):c++:u++}),{counts:{printing:l,idle:c,offline:u,loading:d,total:t?.length||0},nextFinish:h&&f?{name:h,remainingMin:f,progress:p}:null}},[t,n,r]);return t?.length?a.jsxs("div",{className:"flex flex-wrap items-center gap-4 gap-y-2 text-sm",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${s.idle>0?"bg-bambu-green":"bg-gray-500"}`}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:s.idle})," ",e("printers.status.available").toLowerCase()]})]}),s.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:s.printing})," ",e("printers.status.printing").toLowerCase()]})]}),s.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:s.offline})," ",e("printers.status.offline").toLowerCase()]})]}),o&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-4 bg-bambu-dark-tertiary"}),a.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"text-bambu-green font-medium",children:[e("printers.nextAvailable"),":"]}),a.jsx("span",{className:"text-white font-medium",children:o.name})]}),a.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:[a.jsx("div",{className:"w-full sm:w-16 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:`${o.progress}%`}})}),a.jsxs("span",{className:"text-white font-medium",children:[Math.round(o.progress),"%"]}),a.jsxs("span",{className:"text-bambu-gray",children:["(",js(o.remainingMin*60),")"]})]})]})]})]}):null}function aE(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 jR(t){return t?{O1D:"H2D",O1E:"H2D Pro",O2D:"H2D Pro",O1C:"H2C",O1C2:"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"}[t]||t:""}function _G({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:s,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:u,onGetAssignment:d,onUnassignSpool:h,timeFormat:f="system",cameraViewMode:p="window",onOpenEmbeddedCamera:x,checkPrinterFirmware:v=!0}){const{t:g}=Et(),y=Qt(),_=jl(),{showToast:N}=dn(),{hasPermission:A}=Rr(),[C,j]=w.useState(!1),[k,R]=w.useState(!1),[M,D]=w.useState(!0),[G,U]=w.useState(!1),[W,L]=w.useState(!1),[ee,ae]=w.useState(!1),[Y,se]=w.useState(!1),[ce,ye]=w.useState(!1),[Z,ue]=w.useState(!1),[pe,be]=w.useState(!1),[Ee,$]=w.useState(!1),[K,T]=w.useState(!1),[E,O]=w.useState(!1),[q,B]=w.useState(null),[re,z]=w.useState(null),[V,te]=w.useState(null),[Q,ne]=w.useState(null),[ie,me]=w.useState(!1),[fe,oe]=w.useState(null),[I,F]=w.useState(!1),[J,xe]=w.useState(!1),[he,le]=w.useState(null),[Ce,Ne]=w.useState(!1),[Ue,He]=w.useState(!1),{data:de}=Je({queryKey:["printerStatus",t.id],queryFn:()=>ge.getPrinterStatus(t.id),refetchInterval:3e4}),{data:we}=Je({queryKey:["firmwareUpdate",t.id],queryFn:()=>Z_.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:v&&A("firmware:read")}),ke=w.useMemo(()=>{const vt=new Set;if(de?.ams)for(const Bt of de.ams)for(const Nn of Bt.tray||[])Nn.tray_info_idx&&vt.add(Nn.tray_info_idx);for(const Bt of de?.vt_tray??[])Bt.tray_info_idx&&vt.add(Bt.tray_info_idx);if(de?.nozzle_rack)for(const Bt of de.nozzle_rack)Bt.filament_id&&vt.add(Bt.filament_id);return Array.from(vt)},[de?.ams,de?.vt_tray,de?.nozzle_rack]),_e=w.useMemo(()=>{const vt=new Set;if(de?.ams)for(const Bt of de.ams)for(const Nn of Bt.tray||[])Nn.tray_type&&vt.add(Nn.tray_type.toUpperCase());for(const Bt of de?.vt_tray??[])Bt.tray_type&&vt.add(Bt.tray_type.toUpperCase());return vt},[de?.ams,de?.vt_tray]),Ae=w.useMemo(()=>{const vt=new Set;if(de?.ams){for(const Bt of de.ams)for(const Nn of Bt.tray||[])if(Nn.tray_type&&Nn.tray_color){const Nt=Nn.tray_color.replace("#","").toLowerCase().slice(0,6);vt.add(`${Nn.tray_type.toUpperCase()}:${Nt}`)}}for(const Bt of de?.vt_tray??[])if(Bt.tray_type&&Bt.tray_color){const Nn=Bt.tray_color.replace("#","").toLowerCase().slice(0,6);vt.add(`${Bt.tray_type.toUpperCase()}:${Nn}`)}return vt},[de?.ams,de?.vt_tray]),{data:Ve}=Je({queryKey:["filamentInfo",ke],queryFn:()=>ge.getFilamentInfo(ke),enabled:ke.length>0,staleTime:300*1e3}),{data:Te}=Je({queryKey:["slotPresets",t.id],queryFn:()=>ge.getSlotPresets(t.id),staleTime:120*1e3}),[Ke,je]=w.useState(null);w.useEffect(()=>{de?.wifi_signal!=null&&je(de.wifi_signal)},[de?.wifi_signal]);const qe=de?.wifi_signal??Ke,Re=w.useRef(void 0);w.useEffect(()=>{de?.connected!==void 0&&(Re.current=de.connected)},[de?.connected]);const Pe=de?.connected??Re.current,Be=w.useRef({});w.useEffect(()=>{de?.ams_extruder_map&&Object.keys(de.ams_extruder_map).length>0&&(Be.current=de.ams_extruder_map)},[de?.ams_extruder_map]);const We=de?.ams_extruder_map&&Object.keys(de.ams_extruder_map).length>0?de.ams_extruder_map:Be.current,ct=w.useRef([]);w.useEffect(()=>{de?.ams&&de.ams.length>0&&(ct.current=de.ams)},[de?.ams]);const St=de?.ams&&de.ams.length>0?de.ams:ct.current,Mt=w.useRef(void 0),yt=de?.tray_now;yt!==void 0&&yt!==255?Mt.current=yt:yt===255&&(Mt.current=void 0);const $e=yt!==void 0&&yt!==255?yt:Mt.current,{data:dt}=Je({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ge.getSmartPlugByPrinter(t.id)}),{data:gt}=Je({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>ge.getScriptPlugsByPrinter(t.id)}),{data:Lt}=Je({queryKey:["smartPlugStatus",dt?.id],queryFn:()=>dt?ge.getSmartPlugStatus(dt.id):null,enabled:!!dt,refetchInterval:1e4}),{data:en}=Je({queryKey:["queue",t.id,"pending"],queryFn:()=>ge.getQueue(t.id,"pending")}),pn=w.useMemo(()=>en?.length?en.filter(vt=>!(vt.required_filament_types?.length&&_e?.size&&!vt.required_filament_types.every(Bt=>_e.has(Bt.toUpperCase()))||vt.filament_overrides?.length&&Ae?.size&&!vt.filament_overrides.some(Nn=>{const Nt=(Nn.type||"").toUpperCase(),Wn=(Nn.color||"").replace("#","").toLowerCase().slice(0,6);return Ae.has(`${Nt}:${Wn}`)}))).length:0,[en,_e,Ae]),{data:_n}=Je({queryKey:["queue",t.id,"printing"],queryFn:()=>ge.getQueue(t.id,"printing"),enabled:de?.state==="RUNNING"}),{data:hn}=Je({queryKey:["currentPrintUser",t.id],queryFn:()=>ge.getCurrentPrintUser(t.id),enabled:de?.state==="RUNNING"}),gn=_n?.[0]?.created_by_username||hn?.username,{data:On}=Je({queryKey:["archives",t.id,"last"],queryFn:()=>ge.getArchives(t.id,1,0),enabled:de?.connected&&de?.state!=="RUNNING"}),Dn=On?.[0],zn=e&&Pe===!1,ze=ut({mutationFn:vt=>ge.deletePrinter(t.id,vt.deleteArchives),onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["archives"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:vt=>N(vt.message||g("printers.toast.failedToDelete"),"error")}),De=ut({mutationFn:()=>ge.connectPrinter(t.id),onSuccess:()=>{y.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Ze=ut({mutationFn:vt=>dt?ge.controlSmartPlug(dt.id,vt):Promise.reject("No plug"),onSuccess:()=>{y.invalidateQueries({queryKey:["smartPlugStatus",dt?.id]})}}),st=ut({mutationFn:vt=>dt?ge.updateSmartPlug(dt.id,{auto_off:vt}):Promise.reject("No plug"),onSuccess:()=>{y.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),y.invalidateQueries({queryKey:["smart-plugs"]})}}),Ye=ut({mutationFn:vt=>ge.controlSmartPlug(vt,"on"),onSuccess:()=>{N(g("printers.toast.scriptTriggered"))},onError:vt=>N(vt.message||g("printers.toast.failedToRunScript"),"error")}),It=ut({mutationFn:()=>ge.stopPrint(t.id),onSuccess:()=>{N(g("printers.toast.printStopped")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:vt=>N(vt.message||g("printers.toast.failedToStopPrint"),"error")}),Me=ut({mutationFn:()=>ge.pausePrint(t.id),onSuccess:()=>{N(g("printers.toast.printPaused")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:vt=>N(vt.message||g("printers.toast.failedToPausePrint"),"error")}),Ge=ut({mutationFn:()=>ge.resumePrint(t.id),onSuccess:()=>{N(g("printers.toast.printResumed")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:vt=>N(vt.message||g("printers.toast.failedToResumePrint"),"error")}),et=ut({mutationFn:vt=>ge.setChamberLight(t.id,vt),onMutate:async vt=>{await y.cancelQueries({queryKey:["printerStatus",t.id]});const Bt=y.getQueryData(["printerStatus",t.id]);return y.setQueryData(["printerStatus",t.id],Nn=>({...Nn,chamber_light:vt})),{previousStatus:Bt}},onSuccess:(vt,Bt)=>{N(`Chamber light ${Bt?"on":"off"}`)},onError:(vt,Bt,Nn)=>{Nn?.previousStatus&&y.setQueryData(["printerStatus",t.id],Nn.previousStatus),N(vt.message||g("printers.toast.failedToControlChamberLight"),"error")}}),Qe=ut({mutationFn:vt=>ge.updatePrinter(t.id,{plate_detection_enabled:vt}),onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),N(Qe.variables?g("printers.toast.plateCheckEnabled"):g("printers.toast.plateCheckDisabled"))},onError:vt=>N(vt.message||g("printers.toast.failedToUpdateSetting"),"error")}),Le=(de?.state==="RUNNING"||de?.state==="PAUSE")&&(de?.printable_objects_count??0)>=2,{data:ht}=Je({queryKey:["printableObjects",t.id],queryFn:()=>ge.getPrintableObjects(t.id),enabled:E||Le,refetchInterval:E?5e3:Le?3e4:!1}),[it,tt]=w.useState(null),_t=w.useRef(!1),jt=w.useRef(null),Dt=w.useRef(!1),Rt=ut({mutationFn:({amsId:vt,slotId:Bt})=>ge.refreshAmsSlot(t.id,vt,Bt),onMutate:({amsId:vt,slotId:Bt})=>{jt.current&&clearTimeout(jt.current),_t.current=!1,Dt.current=!1,tt({amsId:vt,slotId:Bt}),setTimeout(()=>{Dt.current=!0},2e3),jt.current=setTimeout(()=>{tt(null)},3e4)},onSuccess:vt=>{N(vt.message||g("printers.toast.rfidRereadInitiated"))},onError:vt=>{N(vt.message||g("printers.toast.failedToRereadRfid"),"error"),jt.current&&clearTimeout(jt.current),tt(null)}}),[tn,nn]=w.useState(null),[ln,vn]=w.useState(null),Rn=async()=>{try{const vt=await ge.getPlateReferences(t.id);nn(vt)}catch{}},Zt=()=>{Qe.mutate(!t.plate_detection_enabled)},xn=async()=>{F(!0),oe(null);const vt=de?.chamber_light===!1;He(vt),vt&&(await ge.setChamberLight(t.id,!0),await new Promise(Bt=>setTimeout(Bt,2500)));try{const Bt=await ge.checkPlateEmpty(t.id,{includeDebugImage:!0});oe(Bt),Rn()}catch(Bt){N(Bt instanceof Error?Bt.message:g("printers.toast.failedToCheckPlate"),"error"),vt&&(await ge.setChamberLight(t.id,!1),He(!1))}finally{F(!1)}},mn=w.useCallback(async()=>{oe(null),Ue&&(await ge.setChamberLight(t.id,!1),He(!1))},[Ue,t.id]),Gr=async vt=>{xe(!0);try{const Bt=await ge.calibratePlateDetection(t.id,{label:vt});if(Bt.success){N(Bt.message||g("printers.toast.calibrationSaved"),"success"),Rn();const Nn=await ge.checkPlateEmpty(t.id,{includeDebugImage:!0});oe(Nn)}else N(Bt.message||g("printers.toast.calibrationFailed"),"error")}catch(Bt){N(Bt instanceof Error?Bt.message:g("printers.toast.calibrationFailed"),"error")}finally{xe(!1)}},yn=async(vt,Bt)=>{try{await ge.updatePlateReferenceLabel(t.id,vt,Bt),vn(null),Rn()}catch(Nn){N(Nn instanceof Error?Nn.message:g("printers.toast.failedToUpdateLabel"),"error")}},dr=async vt=>{try{await ge.deletePlateReference(t.id,vt),N(g("printers.toast.referenceDeleted"),"success"),Rn();const Bt=await ge.checkPlateEmpty(t.id,{includeDebugImage:!0});oe(Bt)}catch(Bt){N(Bt instanceof Error?Bt.message:g("printers.toast.failedToDeleteReference"),"error")}},as=async()=>{if(he){Ne(!0);try{await ge.updatePrinter(t.id,{plate_detection_roi:he}),N(g("printers.toast.detectionAreaSaved"),"success"),le(null);const vt=await ge.checkPlateEmpty(t.id,{includeDebugImage:!0});oe(vt)}catch(vt){N(vt instanceof Error?vt.message:g("printers.toast.failedToSaveDetectionArea"),"error")}finally{Ne(!1)}}};w.useEffect(()=>{const vt=Bt=>{Bt.key==="Escape"&&fe&&mn()};return window.addEventListener("keydown",vt),()=>window.removeEventListener("keydown",vt)},[fe,mn]);const wn=w.useRef(null);w.useEffect(()=>{if(!it)return;const vt=de?.ams_status_main??0;return vt!==0&&(_t.current=!0,wn.current&&(clearTimeout(wn.current),wn.current=null)),_t.current&&vt===0&&(Dt.current?(jt.current&&clearTimeout(jt.current),tt(null)):wn.current||(wn.current=setTimeout(()=>{jt.current&&clearTimeout(jt.current),tt(null)},2e3))),()=>{wn.current&&clearTimeout(wn.current)}},[de?.ams_status_main,it]);const[Sr,ar]=w.useState(null);if(zn)return null;const ya=()=>{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"}},Ba=()=>{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"}},sa=()=>{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(Ct,{className:"relative",children:[a.jsxs(Tt,{className:i>=3?"p-5":"",children:[a.jsxs("div",{className:sa(),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:R$e(t.model),alt:t.model||g("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${ya()}`}),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 ${Ba()}`,children:t.name}),r==="compact"&&a.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${de?.connected?"bg-status-ok":"bg-status-error"}`,title:de?.connected?g("printers.connection.connected"):g("printers.connection.offline")})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&de?.nozzles&&de.nozzles[0]?.nozzle_diameter&&a.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:de.nozzles[0].nozzle_type||"Nozzle",children:["• ",de.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(Xn,{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(Oe,{variant:"ghost",size:"sm",onClick:()=>j(!C),children:a.jsx(Rh,{className:"w-4 h-4"})}),C&&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 ${A("printers:update")?"hover:bg-bambu-dark-tertiary":"opacity-50 cursor-not-allowed"}`,onClick:()=>{A("printers:update")&&(U(!0),j(!1))},title:A("printers:update")?void 0:g("printers.permission.noEdit"),children:[a.jsx(Ka,{className:"w-4 h-4"}),g("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:()=>{De.mutate(),j(!1)},children:[a.jsx(wr,{className:"w-4 h-4"}),g("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:()=>{ae(!0),j(!1)},children:[a.jsx(GY,{className:"w-4 h-4"}),g("printers.mqttDebug")]}),a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${A("printers:delete")?"text-red-400 hover:bg-bambu-dark-tertiary":"text-red-400/50 cursor-not-allowed"}`,onClick:()=>{A("printers:delete")&&(R(!0),j(!1))},title:A("printers:delete")?void 0:g("printers.permission.noDelete"),children:[a.jsx(Xt,{className:"w-4 h-4"}),g("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 ${de?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[de?.connected?a.jsx(ex,{className:"w-3 h-3"}):a.jsx(cC,{className:"w-3 h-3"}),de?.connected?g("printers.connection.connected"):g("printers.connection.offline")]}),de?.connected&&qe!=null&&a.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${qe>=-50||qe>=-60?"bg-status-ok/20 text-status-ok":qe>=-70?"bg-status-warning/20 text-status-warning":qe>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${qe} dBm - ${g(F$e(qe).labelKey)}`,children:[a.jsx(Bpe,{className:"w-3 h-3"}),qe,"dBm"]}),de?.connected&&(()=>{const vt=de.hms_errors?s2e(de.hms_errors):[];return a.jsxs("button",{onClick:()=>ue(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${vt.length>0?vt.some(Bt=>Bt.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:g("printers.clickToViewHmsErrors"),children:[a.jsx(Mn,{className:"w-3 h-3"}),vt.length>0?vt.length:"OK"]})})(),n&&a.jsxs("button",{onClick:()=>_("/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`:g("printers.maintenanceUpToDate"),children:[a.jsx(zf,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),pn>0&&a.jsxs("button",{onClick:()=>_("/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:g("printers.queue.inQueue",{count:pn}),children:[a.jsx(Ga,{className:"w-3 h-3"}),pn]}),v&&we?.current_version&&we?.latest_version?a.jsxs("button",{onClick:()=>me(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs hover:opacity-80 transition-opacity ${we.update_available?"bg-orange-500/20 text-orange-400":"bg-status-ok/20 text-status-ok"}`,title:we.update_available?g("printers.firmwareUpdateAvailable",{current:we.current_version,latest:we.latest_version}):g("printers.firmwareUpToDate",{version:we.current_version}),children:[we.update_available?a.jsx(ba,{className:"w-3 h-3"}):a.jsx(xr,{className:"w-3 h-3"}),we.current_version]}):de?.firmware_version?a.jsx("span",{className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-bambu-dark-tertiary/50 text-bambu-gray",children:de.firmware_version}):null]})]}),k&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(Ct,{className:"w-full max-w-md mx-4",children:a.jsxs(Tt,{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(Mn,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:g("printers.confirm.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:g("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:M,onChange:vt=>D(vt.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:g("printers.deleteArchives")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:g(M?"printers.confirm.deleteArchivesNote":"printers.confirm.keepArchivesNote")})]})]})}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Oe,{variant:"secondary",onClick:()=>{R(!1),D(!0)},children:g("common.cancel")}),a.jsx(Oe,{variant:"danger",onClick:()=>{ze.mutate({deleteArchives:M}),R(!1),D(!0)},children:"Delete"})]})]})})}),de?.connected&&a.jsxs(a.Fragment,{children:[r==="compact"?a.jsx("div",{className:"mt-2",children:de.state==="RUNNING"||de.state==="PAUSE"?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:`${de.progress||0}%`}})}),a.jsxs("span",{className:"text-xs text-white",children:[Math.round(de.progress||0),"%"]})]}):a.jsx("p",{className:"text-xs text-bambu-gray",children:aE(de.state,de.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:()=>O(!0),disabled:!(de.state==="RUNNING"||de.state==="PAUSE")||(de.printable_objects_count??0)<2||!A("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(de.state==="RUNNING"||de.state==="PAUSE")&&(de.printable_objects_count??0)>=2&&A("printers:control")?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:A("printers:control")?de.state==="RUNNING"||de.state==="PAUSE"?(de.printable_objects_count??0)>=2?g("printers.skipObjects.tooltip"):g("printers.skipObjects.requiresMultiple"):g("printers.skipObjects.onlyWhilePrinting"):g("printers.permission.noControl"),children:[a.jsx(wC,{className:"w-4 h-4"}),ht&&ht.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:ht.skipped_count})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(L$e,{url:de.state==="RUNNING"||de.state==="PAUSE"?de.cover_url:null,printName:(de.state==="RUNNING"||de.state==="PAUSE")&&(de.subtask_name||de.current_print)||void 0}),a.jsx("div",{className:"flex-1 min-w-0",children:de.current_print&&(de.state==="RUNNING"||de.state==="PAUSE")?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:aE(de.state,de.stg_cur_name)}),a.jsx("p",{className:"text-white text-sm mb-2 truncate",children:de.subtask_name||de.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:`${de.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(de.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[de.remaining_time!=null&&de.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Xn,{className:"w-3 h-3"}),js(de.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:g("printers.estimatedCompletion"),children:["ETA ",GF(de.remaining_time,f,g)]})]}),de.layer_num!=null&&de.total_layers!=null&&de.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ga,{className:"w-3 h-3"}),de.layer_num,"/",de.total_layers]}),gn&&a.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${gn}`,children:[a.jsx(id,{className:"w-3 h-3"}),gn]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:g("printers.sort.status")}),a.jsx("p",{className:"text-white text-sm mb-2",children:aE(de.state,de.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:"—"})]}),Dn?a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Dn.print_name||Dn.filename,children:["Last: ",Dn.print_name||Dn.filename,Dn.completed_at&&a.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",wb(Dn.completed_at,{month:"short",day:"numeric"})]})]}):a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:g("printers.readyToPrint")})]})})]})]}),a.jsx(c2e,{printerId:t.id,printerModel:t.model,printerState:de.state,plateCleared:de.plate_cleared,loadedFilamentTypes:_e,loadedFilaments:Ae})]}),de.temperatures&&r==="expanded"&&(()=>{const vt=de.temperatures.nozzle_heating||de.temperatures.nozzle_2_heating||!1,Bt=de.temperatures.bed_heating||!1,Nn=de.temperatures.chamber_heating||!1,Nt=t.nozzle_count===2||de.temperatures.nozzle_2!==void 0,Wn=de.active_extruder===1?"L":"R",ea=de.nozzle_rack?.find(ui=>ui.id===1),ir=de.nozzle_rack?.find(ui=>ui.id===0),mr=ir||ea;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(eE,{className:"w-3.5 h-3.5 mb-0.5",color:"text-orange-400",isHeating:vt}),de.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(de.temperatures.nozzle||0),"° / ",Math.round(de.temperatures.nozzle_2||0),"°"]})]}):mr?a.jsx(Une,{slot:mr,index:0,activeStatus:!0,filamentName:mr.filament_id?Ve?.[mr.filament_id]?.name:void 0,children:a.jsxs("div",{className:"cursor-default",children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:g("printers.temperatures.nozzle")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(de.temperatures.nozzle||0),"°C"]})]})}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:g("printers.temperatures.nozzle")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(de.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(eE,{className:"w-3.5 h-3.5 mb-0.5",color:"text-blue-400",isHeating:Bt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:g("printers.temperatures.bed")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(de.temperatures.bed||0),"°C"]})]}),de.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(eE,{className:"w-3.5 h-3.5 mb-0.5",color:"text-green-400",isHeating:Nn}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:g("printers.temperatures.chamber")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(de.temperatures.chamber||0),"°C"]})]}),Nt&&a.jsx(A$e,{leftSlot:ea,rightSlot:ir,activeNozzle:Wn,filamentInfo:Ve,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:g("printers.activeNozzle",{nozzle:g(Wn==="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 ${Wn==="L"?"text-amber-400":"text-gray-500"}`,children:["L",ea?.nozzle_diameter?` ${ea.nozzle_diameter}`:""]}),a.jsx("span",{className:"text-[9px] text-bambu-gray/40",children:"·"}),a.jsxs("span",{className:`text-[11px] font-bold ${Wn==="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:g("printers.temperatures.nozzle")})]})}),de.nozzle_rack&&de.nozzle_rack.some(ui=>ui.id>=2)&&a.jsx(T$e,{slots:de.nozzle_rack,filamentInfo:Ve})]})})(),r==="expanded"&&(()=>{const vt=de.state==="RUNNING",Bt=de.state==="PAUSE",Nn=vt||Bt,Nt=It.isPending||Me.isPending||Ge.isPending,Wn=de.cooling_fan_speed,ea=de.big_fan1_speed,ir=de.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:g("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 max-[550px]:items-start",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 max-[550px]:flex-wrap max-[550px]:items-start max-[550px]:gap-1.5",children:[a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Wn&&Wn>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:g("printers.fans.partCooling"),children:[a.jsx(OY,{className:`w-3.5 h-3.5 ${Wn&&Wn>0?"text-cyan-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Wn&&Wn>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Wn??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${ea&&ea>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:g("printers.fans.auxiliary"),children:[a.jsx(KY,{className:`w-3.5 h-3.5 ${ea&&ea>0?"text-blue-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${ea&&ea>0?"text-blue-400":"text-bambu-gray/50"}`,children:[ea??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:g("printers.fans.chamber"),children:[a.jsx(nhe,{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 flex-shrink-0 max-[550px]:self-start",children:[a.jsxs("button",{onClick:()=>be(!0),disabled:!Nn||Nt||!A("printers:control"),className:`
  8152. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  8153. transition-colors
  8154. ${Nn&&A("printers:control")?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  8155. `,title:A("printers:control")?g("printers.stop"):g("printers.permission.noControl"),children:[a.jsx(_l,{className:"w-3 h-3"}),g("printers.stop")]}),a.jsxs("button",{onClick:()=>Bt?T(!0):$(!0),disabled:!Nn||Nt||!A("printers:control"),className:`
  8156. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  8157. transition-colors
  8158. ${Nn&&A("printers:control")?Bt?"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"}
  8159. `,title:A("printers:control")?g(Bt?"printers.resume":"printers.pause"):g("printers.permission.noControl"),children:[Bt?a.jsx(lo,{className:"w-3 h-3"}):a.jsx(aC,{className:"w-3 h-3"}),g(Bt?"printers.resume":"printers.pause")]})]})]})]})})(),(St?.length>0||de.vt_tray.length>0)&&r==="expanded"&&(()=>{const vt=St.filter(Nt=>Nt.tray.length>1),Bt=St.filter(Nt=>Nt.tray.length===1),Nn=t.nozzle_count===2||de?.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:g("printers.filaments")}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"space-y-3",children:[vt.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:vt.map(Nt=>{const Wn=We[String(Nt.id)],ea=Nt.id>=128?Nt.id-128:Nt.id,ir=Wn!==void 0?Wn:ea,mr=ir===1,ui=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:ah(Nt.id,Nt.tray.length)}),Nn&&(mr||ui)&&a.jsx(yG,{side:mr?"L":"R"})]}),(Nt.humidity!=null||Nt.temp!=null)&&a.jsxs("div",{className:"flex items-center gap-1.5 max-[550px]:flex-col max-[550px]:items-start",children:[Nt.humidity!=null&&a.jsx(wG,{humidity:Nt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>B({amsId:Nt.id,amsLabel:ah(Nt.id,Nt.tray.length),mode:"humidity"}),compact:!0}),Nt.temp!=null&&a.jsx(SG,{temp:Nt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>B({amsId:Nt.id,amsLabel:ah(Nt.id,Nt.tray.length),mode:"temperature"}),compact:!0})]})]}),a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(an=>{const Fn=Nt.tray[an]||Nt.tray.find(Qn=>Qn.id===an),ki=Fn?.tray_type&&Fn.remain>=0,$s=!Fn?.tray_type,Uo=Nt.id*4+an,Bo=$e===Uo,zi=Fn?.tray_info_idx?Ve?.[Fn.tray_info_idx]:null,Fr=Te?.[Uo],Vs=Fn?.tray_uuid?.toUpperCase(),Ca=Vs?c?.[Vs]:void 0,ta=nE(Ca),is=d?.(t.id,Nt.id,an),fr=(()=>{const Qn=is?.spool;return Qn&&Qn.label_weight>0&&Qn.weight_used!=null?Math.round(Math.max(0,Qn.label_weight-Qn.weight_used)/Qn.label_weight*100):null})(),Ui=ta??fr??(ki?Fn.remain:null),Dl=ta!==null?"spoolman":fr!==null?"inventory":ki?"ams":void 0,kr=Fn?.tray_type?{vendor:rE(Fn)?"Bambu Lab":"Generic",profile:zi?.name||Fr?.preset_name||Fn.tray_sub_brands||Fn.tray_type,colorName:Qj(Fn.tray_id_name)||Zj(Fn.tray_color),colorHex:Fn.tray_color||null,kFactor:Jj(Fn.k),fillLevel:Ui,trayUuid:Fn.tray_uuid||null,tagUid:Fn.tag_uid||null,fillSource:Dl}:null,Yt=it?.amsId===Nt.id&&it?.slotId===an,va=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${$s?"opacity-50":""} ${Bo?"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:Fn?.tray_color?`#${Fn.tray_color}`:Fn?.tray_type?"#333":"transparent",borderColor:$s?"#666":"rgba(255,255,255,0.1)",borderStyle:$s?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Fn?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Ui!==null&&Ui>=0&&Fn&&a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Ui}%`,backgroundColor:tE(Ui)}})})]});return a.jsxs("div",{className:"relative group",children:[Yt&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(wr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),de?.state!=="RUNNING"&&a.jsx("button",{onClick:Qn=>{Qn.stopPropagation(),ar(Sr?.amsId===Nt.id&&Sr?.slotId===an?null:{amsId:Nt.id,slotId:an})},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:g("printers.slotOptions"),children:a.jsx(Rh,{className:"w-2.5 h-2.5 text-bambu-gray"})}),de?.state!=="RUNNING"&&Sr?.amsId===Nt.id&&Sr?.slotId===an&&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 ${A("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Qn=>{Qn.stopPropagation(),A("printers:ams_rfid")&&(Rt.mutate({amsId:Nt.id,slotId:an}),ar(null))},disabled:Yt||!A("printers:ams_rfid"),title:A("printers:ams_rfid")?void 0:g("printers.permission.noAmsRfid"),children:[a.jsx(wr,{className:`w-3 h-3 ${Yt?"animate-spin":""}`}),g("printers.rfid.reread")]})}),kr?a.jsx(Yj,{data:kr,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:kr.trayUuid?c?.[kr.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:u,onLinkSpool:o&&kr.trayUuid?Qn=>{z({tagUid:kr.tagUid||"",trayUuid:Qn,printerId:t.id,amsId:Nt.id,trayId:an})}:void 0},inventory:o?void 0:(()=>{const Qn=d?.(t.id,Nt.id,an);return{assignedSpool:Qn?.spool?{id:Qn.spool.id,material:Qn.spool.material,brand:Qn.spool.brand,color_name:Qn.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(Qn.spool.label_weight-Qn.spool.weight_used))}:null,onAssignSpool:kr.vendor!=="Bambu Lab"?()=>te({printerId:t.id,amsId:Nt.id,trayId:an,trayInfo:{type:kr.profile,color:kr.colorHex||"",location:`${ah(Nt.id,Nt.tray.length)} Slot ${an+1}`}}):void 0,onUnassignSpool:Qn&&kr.vendor!=="Bambu Lab"?()=>h?.(t.id,Nt.id,an):void 0}})(),configureSlot:{enabled:A("printers:control"),onConfigure:()=>ne({amsId:Nt.id,trayId:an,trayCount:Nt.tray.length,trayType:Fn?.tray_type||void 0,trayColor:Fn?.tray_color||void 0,traySubBrands:Fn?.tray_sub_brands||void 0,trayInfoIdx:Fn?.tray_info_idx||void 0,extruderId:Wn,caliIdx:Fn?.cali_idx,savedPresetId:Fr?.preset_id})},children:va}):a.jsx(Xj,{configureSlot:{enabled:A("printers:control"),onConfigure:()=>ne({amsId:Nt.id,trayId:an,trayCount:Nt.tray.length,extruderId:Wn})},children:va})]},an)})})]},Nt.id)})}),(Bt.length>0||de.vt_tray.length>0)&&a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Bt.map(Nt=>{const Wn=We[String(Nt.id)],ea=Nt.id>=128?Nt.id-128:Nt.id,ir=Wn!==void 0?Wn:ea,mr=ir===1,ui=ir===0,an=Nt.tray[0],Fn=an?.tray_type&&an.remain>=0,ki=!an?.tray_type,$s=YN(Nt.id,an?.id??0,!1),Uo=$e===$s,Bo=an?.tray_info_idx?Ve?.[an.tray_info_idx]:null,zi=Te?.[$s],Fr=an?.tray_uuid?.toUpperCase(),Vs=Fr?c?.[Fr]:void 0,Ca=nE(Vs),ta=an?.id??0,is=d?.(t.id,Nt.id,ta),fr=(()=>{const Cr=is?.spool;return Cr&&Cr.label_weight>0&&Cr.weight_used!=null?Math.round(Math.max(0,Cr.label_weight-Cr.weight_used)/Cr.label_weight*100):null})(),Ui=Ca??fr??(Fn?an.remain:null),Dl=Ca!==null?"spoolman":fr!==null?"inventory":Fn?"ams":void 0,kr=an?.tray_type?{vendor:rE(an)?"Bambu Lab":"Generic",profile:Bo?.name||zi?.preset_name||an.tray_sub_brands||an.tray_type,colorName:Qj(an.tray_id_name)||Zj(an.tray_color),colorHex:an.tray_color||null,kFactor:Jj(an.k),fillLevel:Ui,trayUuid:an.tray_uuid||null,tagUid:an.tag_uid||null,fillSource:Dl}:null,Yt=an?.id??0,va=it?.amsId===Nt.id&&it?.slotId===Yt,Qn=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${ki?"opacity-50":""} ${Uo?"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:an?.tray_color?`#${an.tray_color}`:an?.tray_type?"#333":"transparent",borderColor:ki?"#666":"rgba(255,255,255,0.1)",borderStyle:ki?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:an?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Ui!==null&&Ui>=0&&a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Ui}%`,backgroundColor:tE(Ui)}})})]});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:ah(Nt.id,Nt.tray.length)}),Nn&&(mr||ui)&&a.jsx(yG,{side:mr?"L":"R"})]}),a.jsxs("div",{className:"flex gap-1.5 max-[550px]:flex-col max-[550px]:items-start",children:[a.jsxs("div",{className:"relative group flex-1 max-[550px]:w-full",children:[va&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(wr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),de?.state!=="RUNNING"&&a.jsx("button",{onClick:Cr=>{Cr.stopPropagation(),ar(Sr?.amsId===Nt.id&&Sr?.slotId===Yt?null:{amsId:Nt.id,slotId:Yt})},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:g("printers.slotOptions"),children:a.jsx(Rh,{className:"w-2.5 h-2.5 text-bambu-gray"})}),de?.state!=="RUNNING"&&Sr?.amsId===Nt.id&&Sr?.slotId===Yt&&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 ${A("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Cr=>{Cr.stopPropagation(),A("printers:ams_rfid")&&(Rt.mutate({amsId:Nt.id,slotId:Yt}),ar(null))},disabled:va||!A("printers:ams_rfid"),title:A("printers:ams_rfid")?void 0:g("printers.permission.noAmsRfid"),children:[a.jsx(wr,{className:`w-3 h-3 ${va?"animate-spin":""}`}),g("printers.rfid.reread")]})}),kr?a.jsx(Yj,{data:kr,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:kr.trayUuid?c?.[kr.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:u,onLinkSpool:o&&kr.trayUuid?Cr=>{z({tagUid:kr.tagUid||"",trayUuid:Cr,printerId:t.id,amsId:Nt.id,trayId:Yt})}:void 0},inventory:o?void 0:(()=>{const Cr=d?.(t.id,Nt.id,Yt);return{assignedSpool:Cr?.spool?{id:Cr.spool.id,material:Cr.spool.material,brand:Cr.spool.brand,color_name:Cr.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(Cr.spool.label_weight-Cr.spool.weight_used))}:null,onAssignSpool:kr.vendor!=="Bambu Lab"?()=>te({printerId:t.id,amsId:Nt.id,trayId:Yt,trayInfo:{type:kr.profile,color:kr.colorHex||"",location:ah(Nt.id,Nt.tray.length)}}):void 0,onUnassignSpool:Cr&&kr.vendor!=="Bambu Lab"?()=>h?.(t.id,Nt.id,Yt):void 0}})(),configureSlot:{enabled:A("printers:control"),onConfigure:()=>ne({amsId:Nt.id,trayId:Yt,trayCount:Nt.tray.length,trayType:an?.tray_type||void 0,trayColor:an?.tray_color||void 0,traySubBrands:an?.tray_sub_brands||void 0,trayInfoIdx:an?.tray_info_idx||void 0,extruderId:Wn,caliIdx:an?.cali_idx,savedPresetId:zi?.preset_id})},children:Qn}):a.jsx(Xj,{configureSlot:{enabled:A("printers:control"),onConfigure:()=>ne({amsId:Nt.id,trayId:Yt,trayCount:Nt.tray.length,extruderId:Wn})},children:Qn})]}),(Nt.humidity!=null||Nt.temp!=null)&&a.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0 max-[550px]:w-full",children:[Nt.temp!=null&&a.jsx(SG,{temp:Nt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>B({amsId:Nt.id,amsLabel:ah(Nt.id,Nt.tray.length),mode:"temperature"}),compact:!0}),Nt.humidity!=null&&a.jsx(wG,{humidity:Nt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>B({amsId:Nt.id,amsLabel:ah(Nt.id,Nt.tray.length),mode:"humidity"}),compact:!0})]})]})]},Nt.id)}),de.vt_tray.length>0&&a.jsxs("div",{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30 ${de.vt_tray.length===1?"max-w-[50%]":""}`,children:[a.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.jsx("span",{className:"text-[10px] text-white font-medium",children:g("printers.external")})}),a.jsx("div",{className:`grid ${de.vt_tray.length>1?"grid-cols-2":"grid-cols-1"} gap-1.5`,children:[...de.vt_tray].sort((Nt,Wn)=>(Nt.id??254)-(Wn.id??254)).map(Nt=>{const Wn=Nt.id??254,ea=Nn&&$e===254?Wn===254&&de.active_extruder===1||Wn===255&&de.active_extruder===0:$e===Wn,ir=Wn-254,mr=Nn?g(Wn===254?"printers.extL":"printers.extR"):"",ui=Nt.tray_info_idx?Ve?.[Nt.tray_info_idx]:null,an=Te?.[1020+ir],Fn=Nt.tray_uuid?.toUpperCase(),ki=Fn?c?.[Fn]:void 0,$s=nE(ki),Uo=d?.(t.id,255,ir),Bo=(()=>{const fr=Uo?.spool;return fr&&fr.label_weight>0&&fr.weight_used!=null?Math.round(Math.max(0,fr.label_weight-fr.weight_used)/fr.label_weight*100):null})(),zi=Nt.tray_type&&Nt.remain>=0,Fr=$s??Bo??(zi?Nt.remain:null),Vs=$s!==null?"spoolman":Bo!==null?"inventory":zi?"ams":void 0,Ca={vendor:rE(Nt)?"Bambu Lab":"Generic",profile:ui?.name||an?.preset_name||Nt.tray_sub_brands||Nt.tray_type||"Unknown",colorName:Qj(Nt.tray_id_name)||Zj(Nt.tray_color),colorHex:Nt.tray_color||null,kFactor:Jj(Nt.k),fillLevel:Fr,trayUuid:Nt.tray_uuid||null,tagUid:Nt.tag_uid||null,fillSource:Vs},ta=!Nt.tray_type,is=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${ta?"opacity-50":""} ${ea?"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:Nt.tray_color?`#${Nt.tray_color}`:Nt.tray_type?"#333":"transparent",borderColor:ta?"#666":"rgba(255,255,255,0.1)",borderStyle:ta?"dashed":"solid"}}),a.jsx("div",{className:`text-[9px] font-bold truncate ${ta?"text-white/40":"text-white"}`,children:Nt.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Fr!==null&&Fr>=0&&!ta&&a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Fr}%`,backgroundColor:tE(Fr)}})}),mr&&a.jsx("div",{className:"text-[7px] text-white/40 mt-0.5 truncate",children:mr})]});return a.jsx("div",{className:"relative group",children:ta?a.jsx(Xj,{configureSlot:{enabled:A("printers:control"),onConfigure:()=>ne({amsId:255,trayId:ir,trayCount:1,extruderId:Nn?Wn===254?1:0:void 0})},children:is}):a.jsx(Yj,{data:Ca,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Ca.trayUuid?c?.[Ca.trayUuid.toUpperCase()]?.id:void 0,spoolmanUrl:u,onLinkSpool:o&&Ca.trayUuid?fr=>{z({tagUid:Ca.tagUid||"",trayUuid:fr,printerId:t.id,amsId:255,trayId:ir})}:void 0},inventory:o?void 0:(()=>{const fr=d?.(t.id,255,ir);return{assignedSpool:fr?.spool?{id:fr.spool.id,material:fr.spool.material,brand:fr.spool.brand,color_name:fr.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(fr.spool.label_weight-fr.spool.weight_used))}:null,onAssignSpool:()=>te({printerId:t.id,amsId:255,trayId:ir,trayInfo:{type:Ca.profile,color:Ca.colorHex||"",location:mr||g("printers.external")}}),onUnassignSpool:fr?()=>h?.(t.id,255,ir):void 0}})(),configureSlot:{enabled:A("printers:control"),onConfigure:()=>ne({amsId:255,trayId:ir,trayCount:1,trayType:Nt.tray_type||void 0,trayColor:Nt.tray_color||void 0,traySubBrands:Nt.tray_sub_brands||void 0,trayInfoIdx:Nt.tray_info_idx||void 0,extruderId:Nn?Wn===254?1:0:void 0,caliIdx:Nt.cali_idx,savedPresetId:an?.preset_id})},children:is})},Wn)})})]})]})]})]})})()]}),dt&&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(Ic,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-sm text-white truncate",children:dt.name}),Lt&&a.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Lt.state==="ON"?"bg-bambu-green/20 text-bambu-green":Lt.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[Lt.state||"?",Lt.state==="ON"&&Lt.energy?.power!=null&&a.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",Lt.energy.power,"W"]})]})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("button",{onClick:()=>se(!0),disabled:Ze.isPending||Lt?.state==="ON"||!A("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${A("smart_plugs:control")?Lt?.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:A("smart_plugs:control")?void 0:g("printers.permission.noSmartPlugControl"),children:[a.jsx(gd,{className:"w-3 h-3"}),"On"]}),a.jsxs("button",{onClick:()=>ye(!0),disabled:Ze.isPending||Lt?.state==="OFF"||!A("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${A("smart_plugs:control")?Lt?.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:A("smart_plugs:control")?void 0:g("printers.permission.noSmartPlugControl"),children:[a.jsx(iC,{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 ${dt.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:dt.auto_off_executed?"Auto-off done":"Auto-off"}),a.jsx("button",{onClick:()=>st.mutate(!dt.auto_off),disabled:st.isPending||dt.auto_off_executed||!A("smart_plugs:control"),title:A("smart_plugs:control")?dt.auto_off_executed?g("printers.autoOffExecuted"):g("printers.autoOffAfterPrint"):g("printers.permission.noSmartPlugControl"),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${A("smart_plugs:control")?dt.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":dt.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 ${dt.auto_off||dt.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]}),gt&&gt.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(vv,{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:gt.map(vt=>a.jsxs("button",{onClick:()=>Ye.mutate(vt.id),disabled:Ye.isPending,title:`Run ${vt.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(lo,{className:"w-2.5 h-2.5"}),vt.name]},vt.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(Oe,{variant:"secondary",size:"sm",onClick:()=>et.mutate(!de?.chamber_light),disabled:!de?.connected||et.isPending||!A("printers:control"),title:A("printers:control")?de?.chamber_light?g("printers.chamberLightOff"):g("printers.chamberLightOn"):g("printers.permission.noControl"),className:de?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:a.jsx(w4,{on:de?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>{if(p==="embedded"&&x)x(t.id,t.name);else{const vt=localStorage.getItem("cameraWindowState"),Bt=vt?JSON.parse(vt):{width:640,height:400},Nn=[`width=${Bt.width}`,`height=${Bt.height}`,Bt.left!==void 0?`left=${Bt.left}`:"",Bt.top!==void 0?`top=${Bt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,Nn)}},disabled:!de?.connected||!A("camera:view"),title:A("camera:view")?g(p==="embedded"?"printers.openCameraOverlay":"printers.openCameraWindow"):g("printers.permission.noCamera"),children:a.jsx($F,{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(Oe,{variant:"secondary",size:"sm",onClick:Zt,disabled:!de?.connected||Qe.isPending||!A("printers:update"),title:A("printers:update")?t.plate_detection_enabled?g("printers.plateDetection.enabledClick"):g("printers.plateDetection.disabledClick"):g("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:Qe.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(R1,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:xn,disabled:!de?.connected||I||!A("printers:update"),title:A("printers:update")?g("printers.plateDetection.manageCalibration"):g("printers.plateDetection.noPermission"),className:`!rounded-l-none !px-1.5 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:I?a.jsx(lt,{className:"w-3 h-3 animate-spin"}):a.jsx(En,{className:"w-3 h-3"})})]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>L(!0),disabled:!A("printers:files"),title:A("printers:files")?g("printers.browseFiles"):g("printers.permission.noFiles"),children:[a.jsx(Jb,{className:"w-4 h-4"}),"Files"]})]})]})]}),W&&a.jsx(ZTe,{printerId:t.id,printerName:t.name,onClose:()=>L(!1)}),ee&&a.jsx(a2e,{printerId:t.id,printerName:t.name,onClose:()=>ae(!1)}),fe&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>mn(),children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:vt=>vt.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:[fe.needs_calibration?a.jsx(R1,{className:"w-5 h-5 text-blue-500"}):fe.is_empty?a.jsx(xr,{className:"w-5 h-5 text-green-500"}):a.jsx(ii,{className:"w-5 h-5 text-yellow-500"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),fe.reference_count!==void 0&&fe.max_references&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[fe.reference_count,"/",fe.max_references," refs"]})]}),a.jsx("button",{onClick:()=>mn(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[fe.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:g("printers.plateDetection.calibrationRequired")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",dangerouslySetInnerHTML:{__html:g("printers.plateDetection.calibrationInstructions")}})]}),a.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[a.jsx("p",{children:g("printers.plateDetection.calibrationDescription")}),a.jsx("p",{dangerouslySetInnerHTML:{__html:g("printers.plateDetection.calibrationTip")}})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`p-3 rounded-lg ${fe.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 ${fe.is_empty?"text-green-400":"text-yellow-400"}`,children:fe.is_empty?g("printers.plateDetection.plateEmpty"):g("printers.plateDetection.objectsDetected")}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:[g("printers.plateDetection.confidence"),": ",Math.round(fe.confidence*100),"% | ",g("printers.plateDetection.difference"),": ",fe.difference_percent.toFixed(1),"%"]})]}),fe.debug_image_url&&a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:g("printers.plateDetection.analysisPreview")}),a.jsx("img",{src:fe.debug_image_url,alt:g("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:g("printers.plateDetection.analysisLegend")})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:fe.message})]}),tn&&tn.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:g("printers.plateDetection.savedReferences",{count:tn.references.length,max:tn.max_references})}),a.jsx("div",{className:"grid grid-cols-5 gap-2",children:tn.references.map(vt=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:ge.getPlateReferenceThumbnailUrl(t.id,vt.index),alt:vt.label||`Reference ${vt.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),a.jsx("button",{onClick:()=>dr(vt.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:g("printers.plateDetection.deleteReference"),children:a.jsx(Ut,{className:"w-3 h-3 text-white"})}),ln?.index===vt.index?a.jsx("input",{type:"text",value:ln.label,onChange:Bt=>vn({...ln,label:Bt.target.value}),onBlur:()=>yn(vt.index,ln.label),onKeyDown:Bt=>{Bt.key==="Enter"&&yn(vt.index,ln.label),Bt.key==="Escape"&&vn(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:g("printers.plateDetection.labelPlaceholder")}):a.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>vn({index:vt.index,label:vt.label}),title:vt.label?g("printers.plateDetection.clickToEdit",{label:vt.label}):g("printers.plateDetection.clickToAddLabel"),children:vt.label||a.jsx("span",{className:"italic opacity-50",children:g("printers.noLabel")})}),a.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:vt.timestamp?Jn(vt.timestamp)?.toLocaleDateString()??"":""})]},vt.index))})]}),!fe.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:g("printers.roi.title")}),he?a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>le(null),disabled:Ce,children:g("common.cancel")}),a.jsx(Oe,{size:"sm",onClick:as,disabled:Ce,children:Ce?a.jsx(lt,{className:"w-3 h-3 animate-spin"}):g("common.save")})]}):a.jsxs(Oe,{variant:"ghost",size:"sm",onClick:()=>le(fe.roi||{x:.15,y:.35,w:.7,h:.55}),children:[a.jsx(Ka,{className:"w-3 h-3 mr-1"}),g("common.edit")]})]}),he?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:g("printers.roi.xStart")}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:he.x,onChange:vt=>le({...he,x:parseFloat(vt.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(he.x*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:g("printers.roi.yStart")}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:he.y,onChange:vt=>le({...he,y:parseFloat(vt.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(he.y*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:g("printers.width")}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:he.w,onChange:vt=>le({...he,w:parseFloat(vt.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(he.w*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:g("printers.height")}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:he.h,onChange:vt=>le({...he,h:parseFloat(vt.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(he.h*100),"%"]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:g("printers.roi.instruction")})]}):a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((fe.roi?.x||.15)*100),"%, Y=",Math.round((fe.roi?.y||.35)*100),"%, W=",Math.round((fe.roi?.w||.7)*100),"%, H=",Math.round((fe.roi?.h||.55)*100),"%"]})]})]}),a.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:fe.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsx(Oe,{variant:"ghost",onClick:()=>mn(),children:g("common.cancel")}),a.jsx(Oe,{onClick:()=>Gr(),disabled:J,children:J?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(Oe,{variant:"ghost",onClick:()=>Gr(),disabled:J,children:J?"Adding...":`Add Reference (${tn?.references.length||0}/${tn?.max_references||5})`}),a.jsx(Oe,{onClick:()=>mn(),children:"Close"})]})})]})}),Y&&dt&&a.jsx(Sn,{title:g("printers.confirm.powerOnTitle"),message:g("printers.confirm.powerOnMessage",{name:t.name}),confirmText:g("printers.confirm.powerOnButton"),variant:"default",onConfirm:()=>{Ze.mutate("on"),se(!1)},onCancel:()=>se(!1)}),ce&&dt&&a.jsx(Sn,{title:g("printers.confirm.powerOffTitle"),message:de?.state==="RUNNING"?g("printers.confirm.powerOffWarning",{name:t.name}):g("printers.confirm.powerOffMessage",{name:t.name}),confirmText:g("printers.confirm.powerOffButton"),variant:"danger",onConfirm:()=>{Ze.mutate("off"),ye(!1)},onCancel:()=>ye(!1)}),pe&&a.jsx(Sn,{title:g("printers.confirm.stopTitle"),message:g("printers.confirm.stopMessage",{name:t.name}),confirmText:g("printers.confirm.stopButton"),variant:"danger",onConfirm:()=>{It.mutate(),be(!1)},onCancel:()=>be(!1)}),Ee&&a.jsx(Sn,{title:g("printers.confirm.pauseTitle"),message:g("printers.confirm.pauseMessage",{name:t.name}),confirmText:g("printers.confirm.pauseButton"),variant:"default",onConfirm:()=>{Me.mutate(),$(!1)},onCancel:()=>$(!1)}),K&&a.jsx(Sn,{title:g("printers.confirm.resumeTitle"),message:g("printers.confirm.resumeMessage",{name:t.name}),confirmText:g("printers.confirm.resumeButton"),variant:"default",onConfirm:()=>{Ge.mutate(),T(!1)},onCancel:()=>T(!1)}),a.jsx(S4,{printerId:t.id,isOpen:E,onClose:()=>O(!1)}),Z&&a.jsx(l2e,{printerName:t.name,errors:de?.hms_errors||[],onClose:()=>ue(!1),printerId:t.id,hasPermission:A}),q&&a.jsx(x$e,{isOpen:!!q,onClose:()=>B(null),printerId:t.id,printerName:t.name,amsId:q.amsId,amsLabel:q.amsLabel,initialMode:q.mode,thresholds:s}),re&&a.jsx(y$e,{isOpen:!!re,onClose:()=>z(null),tagUid:re.tagUid,trayUuid:re.trayUuid,printerId:re.printerId,amsId:re.amsId,trayId:re.trayId}),V&&a.jsx(v$e,{isOpen:!!V,onClose:()=>te(null),printerId:V.printerId,amsId:V.amsId,trayId:V.trayId,trayInfo:V.trayInfo}),Q&&a.jsx(One,{isOpen:!!Q,onClose:()=>ne(null),printerId:t.id,slotInfo:Q,printerModel:jR(t.model)||void 0,onSuccess:()=>{y.invalidateQueries({queryKey:["slotPresets",t.id]}),y.invalidateQueries({queryKey:["printerStatus",t.id]})}}),G&&a.jsx(U$e,{printer:t,onClose:()=>U(!1)}),ie&&we&&a.jsx(z$e,{printer:t,firmwareInfo:we,onClose:()=>me(!1)}),Sr&&a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>ar(null)})]})}function I$e({onClose:t,onAdd:e,existingSerials:n}){const{t:r}=Et(),[i,s]=w.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",location:"",auto_archive:!0}),[o,l]=w.useState(!1),[c,u]=w.useState([]),[d,h]=w.useState(""),[f,p]=w.useState(!1),[x,v]=w.useState(!1),[g,y]=w.useState([]),[_,N]=w.useState(""),[A,C]=w.useState({scanned:0,total:0});w.useEffect(()=>{mc.getInfo().then(M=>{v(M.is_docker),M.subnets.length>0&&(y(M.subnets),N(M.subnets[0]))}).catch(()=>{})},[]);const j=c.filter(M=>!n.includes(M.serial)),k=async()=>{h(""),u([]),l(!0),p(!1),C({scanned:0,total:0});try{if(x){await mc.startSubnetScan(_);const M=setInterval(async()=>{try{const D=await mc.getScanStatus();C({scanned:D.scanned,total:D.total});const G=await mc.getDiscoveredPrinters();u(G),D.running||(clearInterval(M),l(!1),p(!0))}catch(D){console.error("Failed to get scan status:",D)}},500)}else{await mc.startDiscovery(10);const M=setInterval(async()=>{try{const D=await mc.getDiscoveredPrinters();u(D)}catch(D){console.error("Failed to get discovered printers:",D)}},1e3);setTimeout(async()=>{clearInterval(M);try{await mc.stopDiscovery()}catch{}l(!1),p(!0);try{const D=await mc.getDiscoveredPrinters();u(D)}catch(D){console.error("Failed to get final discovered printers:",D)}},1e4)}}catch(M){console.error("Failed to start discovery:",M),h(M instanceof Error?M.message:r("printers.discovery.failedToStart")),l(!1),p(!0)}},R=M=>{const D=M.serial.startsWith("unknown-")?"":M.serial;s({...i,name:M.name||"",serial_number:D,ip_address:M.ip_address,model:jR(M.model)}),u([])};return w.useEffect(()=>()=>{mc.stopDiscovery().catch(()=>{}),mc.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const M=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:a.jsx(Ct,{className:"w-full max-w-md",onClick:M=>M.stopPropagation(),children:a.jsxs(Tt,{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:[x&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.discovery.subnetToScan")}),g.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:_,onChange:M=>N(M.target.value),disabled:o,children:g.map(M=>a.jsx("option",{value:M,children:M},M))}):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:_,onChange:M=>N(M.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(Oe,{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"}),x&&A.total>0?r("printers.discovery.scanProgress",{scanned:A.scanned,total:A.total}):r("printers.discovery.scanning")]}):a.jsxs(a.Fragment,{children:[a.jsx(Er,{className:"w-4 h-4"}),r(x?"printers.discovery.scanSubnet":"printers.discovery.discoverNetwork")]})}),d&&a.jsx("div",{className:"mt-2 text-sm text-red-400",children:d}),j.length>0&&a.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:j.map(M=>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:()=>R(M),children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-white text-sm truncate",children:M.name||M.serial}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[jR(M.model)||r("printers.discovery.unknown")," • ",M.ip_address,M.serial.startsWith("unknown-")&&a.jsxs("span",{className:"text-yellow-500",children:[" • ",r("printers.discovery.serialRequired")]})]})]}),a.jsx(En,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},M.serial))}),o&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.scanningSubnet":"printers.discovery.scanningNetwork")}),f&&!o&&c.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.noPrintersFoundSubnet":"printers.discovery.noPrintersFoundNetwork")}),f&&!o&&c.length>0&&j.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r("printers.discovery.allConfigured")})]}),a.jsxs("form",{onSubmit:M=>{M.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:M=>s({...i,name:M.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:M=>s({...i,ip_address:M.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:M=>s({...i,serial_number:M.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:M=>s({...i,access_code:M.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:M=>s({...i,model:M.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:M=>s({...i,location:M.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:M=>s({...i,auto_archive:M.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(Oe,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsx(Oe,{type:"submit",className:"flex-1",children:r("printers.addPrinter")})]})]})]})})})}function z$e({printer:t,firmwareInfo:e,onClose:n}){const{t:r}=Et(),i=Qt(),{showToast:s}=dn(),{hasPermission:o}=Rr(),l=o("firmware:update"),[c,u]=w.useState(null),[d,h]=w.useState(!1),[f,p]=w.useState(null),{data:x,isLoading:v}=Je({queryKey:["firmwarePrepare",t.id],queryFn:()=>Z_.prepareUpload(t.id),staleTime:3e4,enabled:e.update_available&&l}),g=ut({mutationFn:()=>Z_.startUpload(t.id),onSuccess:()=>{h(!0);const _=setInterval(async()=>{try{const N=await Z_.getUploadStatus(t.id);u(N),(N.status==="complete"||N.status==="error")&&(clearInterval(_),p(null),h(!1),N.status==="complete"&&(s(r("printers.firmwareModal.uploadedToast"),"success"),i.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);p(_)},onError:_=>{s(r("printers.firmwareModal.uploadFailed",{error:_.message}),"error"),h(!1)}});w.useEffect(()=>()=>{f&&clearInterval(f)},[f]);const y=()=>{u(null),g.mutate()};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(Ct,{className:"w-full max-w-md mx-4",children:a.jsxs(Tt,{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(ba,{className:"w-5 h-5 text-orange-400"}):a.jsx(xr,{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?v?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")]}):x&&!d&&!c?a.jsx("div",{className:"mb-4",children:x.can_proceed?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[a.jsx(ni,{className:"w-4 h-4"}),r("printers.firmwareModal.sdCardReady")]}):a.jsx("div",{className:"space-y-1",children:x.errors.map((_,N)=>a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(qa,{className:"w-4 h-4 flex-shrink-0"}),_]},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(Oe,{variant:"secondary",onClick:n,children:c?.status==="complete"?r("printers.firmwareModal.done"):r("common.cancel")}),x?.can_proceed&&!d&&c?.status!=="complete"&&l&&a.jsx(Oe,{onClick:y,disabled:g.isPending,children:g.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(ba,{className:"w-4 h-4 mr-2"}),r("printers.firmwareModal.uploadFirmware")]})})]})]})})})}function U$e({printer:t,onClose:e}){const{t:n}=Et(),r=Qt(),{showToast:i}=dn(),[s,o]=w.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),l=ut({mutationFn:u=>ge.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")});w.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(Ct,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:a.jsxs(Tt,{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(Oe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("common.cancel")}),a.jsx(Oe,{type:"submit",className:"flex-1",disabled:l.isPending,children:l.isPending?n("common.saving"):n("printers.modal.saveChanges")})]})]})]})})})}function B$e(t){const{data:e}=Je({queryKey:["printerStatus",t],queryFn:()=>ge.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function H$e({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=B$e(t.id),{data:s}=Je({queryKey:["smartPlugStatus",e.id],queryFn:()=>ge.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(gd,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function $$e(){const{t}=Et(),[e,n]=w.useState(!1),[r,i]=w.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[s,o]=w.useState(!1),[l,c]=w.useState(null),[u,d]=w.useState(()=>localStorage.getItem("printerSortBy")||"name"),[h,f]=w.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[p,x]=w.useState(()=>{const O=localStorage.getItem("printerCardSize");return O?parseInt(O,10):2}),v=p===1?"compact":"expanded",g=Qt(),{showToast:y}=dn(),{hasPermission:_}=Rr(),[N,A]=w.useState(()=>{const O=localStorage.getItem("openEmbeddedCameras");if(O)try{const q=JSON.parse(O);return new Map(q.map(B=>[B.id,B]))}catch{return new Map}return new Map});w.useEffect(()=>{const O=Array.from(N.values());O.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(O)):localStorage.removeItem("openEmbeddedCameras")},[N]);const{data:C,isLoading:j}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:k}=Je({queryKey:["settings"],queryFn:ge.getSettings});w.useEffect(()=>{k?.camera_view_mode==="window"&&N.size>0&&A(new Map)},[k?.camera_view_mode,N.size]);const{data:R}=Je({queryKey:["smart-plugs"],queryFn:ge.getSmartPlugs}),{data:M}=Je({queryKey:["maintenanceOverview"],queryFn:ge.getMaintenanceOverview,staleTime:60*1e3}),{data:D}=Je({queryKey:["spoolman-status"],queryFn:ge.getSpoolmanStatus,staleTime:60*1e3}),G=D?.enabled&&D?.connected,{data:U}=Je({queryKey:["unlinked-spools"],queryFn:ge.getUnlinkedSpools,enabled:!!G,staleTime:30*1e3}),W=U&&U.length>0,{data:L}=Je({queryKey:["linked-spools"],queryFn:ge.getLinkedSpools,enabled:!!G,staleTime:30*1e3}),ee=L?.linked,{data:ae}=Je({queryKey:["spool-assignments"],queryFn:()=>ge.getAssignments(),staleTime:30*1e3}),Y=ut({mutationFn:({printerId:O,amsId:q,trayId:B})=>ge.unassignSpool(O,q,B),onSuccess:()=>{g.invalidateQueries({queryKey:["spool-assignments"]})}}),se=(O,q,B)=>ae?.find(re=>re.printer_id===O&&re.ams_id===Number(q)&&re.tray_id===Number(B)),ce=M?.reduce((O,q)=>(O[q.printer_id]={due_count:q.due_count,warning_count:q.warning_count,total_print_hours:q.total_print_hours},O),{})||{},ye=R?.reduce((O,q)=>(q.printer_id&&(O[q.printer_id]=q),O),{})||{},Z=ut({mutationFn:ge.createPrinter,onSuccess:()=>{g.invalidateQueries({queryKey:["printers"]}),g.invalidateQueries({queryKey:["maintenanceOverview"]}),n(!1)},onError:O=>y(O.message||t("printers.toast.failedToAdd"),"error")}),ue=ut({mutationFn:O=>ge.controlSmartPlug(O,"on"),onSuccess:()=>{g.invalidateQueries({queryKey:["smart-plugs"]}),c(null)},onError:()=>{c(null)}}),pe=()=>{const O=!r;i(O),localStorage.setItem("hideDisconnectedPrinters",String(O))},be=O=>{d(O),localStorage.setItem("printerSortBy",O)},Ee=()=>{const O=!h;f(O),localStorage.setItem("printerSortAsc",String(O))},$=()=>{switch(p){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"}},K=["S","M","L","XL"],T=w.useMemo(()=>{if(!C)return[];const O=[...C];switch(u){case"name":O.sort((q,B)=>q.name.localeCompare(B.name));break;case"model":O.sort((q,B)=>(q.model||"").localeCompare(B.model||""));break;case"location":O.sort((q,B)=>{const re=q.location||"",z=B.location||"";return!re&&z?1:re&&!z?-1:re.localeCompare(z)||q.name.localeCompare(B.name)});break;case"status":O.sort((q,B)=>{const re=g.getQueryData(["printerStatus",q.id]),z=g.getQueryData(["printerStatus",B.id]),V=te=>te?.connected?te.state==="RUNNING"?0:1:2;return V(re)-V(z)});break}return h||O.reverse(),O},[C,u,h,g]),E=w.useMemo(()=>{if(u!=="location")return null;const O={};return T.forEach(q=>{const B=q.location||"Ungrouped";O[B]||(O[B]=[]),O[B].push(q)}),O},[u,T]);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(O$e,{printers:C})]}),a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("select",{value:u,onChange:O=>be(O.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:Ee,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(Lf,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(bb,{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:K.map((O,q)=>{const B=q+1,re=p===B;return a.jsx("button",{onClick:()=>{x(B),localStorage.setItem("printerCardSize",String(B))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${q===0?"rounded-l-lg":""} ${q===K.length-1?"rounded-r-lg":""} ${re?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:t(O==="S"?"printers.cardSize.small":O==="M"?"printers.cardSize.medium":O==="L"?"printers.cardSize.large":"printers.cardSize.extraLarge"),children:O},O)})}),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:pe,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),t("printers.hideOffline")]}),r&&Object.keys(ye).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(gd,{className:"w-4 h-4"}),t("printers.powerOn"),a.jsx(En,{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")}),C?.filter(O=>ye[O.id]).map(O=>a.jsx(H$e,{printer:O,plug:ye[O.id],onPowerOn:q=>{c(q),ue.mutate(q)},isPowering:l===ye[O.id]?.id},O.id)),C?.filter(O=>ye[O.id]).length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),a.jsxs(Oe,{onClick:()=>n(!0),disabled:!_("printers:create"),title:_("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(nr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})]}),j?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):C?.length===0?a.jsx(Ct,{children:a.jsxs(Tt,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("printers.noPrintersConfigured")}),a.jsxs(Oe,{onClick:()=>n(!0),disabled:!_("printers:create"),title:_("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(nr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})}):E?a.jsx("div",{className:"space-y-6",children:Object.entries(E).map(([O,q])=>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"}),O,a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",q.length,")"]})]}),a.jsx("div",{className:`grid gap-4 ${p>=3?"gap-6":""} ${$()}`,children:q.map(B=>a.jsx(_G,{printer:B,hideIfDisconnected:r,maintenanceInfo:ce[B.id],viewMode:v,cardSize:p,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:G,hasUnlinkedSpools:W,linkedSpools:ee,spoolmanUrl:D?.url,onGetAssignment:se,onUnassignSpool:(re,z,V)=>Y.mutate({printerId:re,amsId:z,trayId:V}),timeFormat:k?.time_format||"system",cameraViewMode:k?.camera_view_mode||"window",onOpenEmbeddedCamera:(re,z)=>A(V=>new Map(V).set(re,{id:re,name:z})),checkPrinterFirmware:k?.check_printer_firmware!==!1},B.id))})]},O))}):a.jsx("div",{className:`grid gap-4 ${p>=3?"gap-6":""} ${$()}`,children:T.map(O=>a.jsx(_G,{printer:O,hideIfDisconnected:r,maintenanceInfo:ce[O.id],viewMode:v,cardSize:p,spoolmanEnabled:G,hasUnlinkedSpools:W,linkedSpools:ee,spoolmanUrl:D?.url,onGetAssignment:se,onUnassignSpool:(q,B,re)=>Y.mutate({printerId:q,amsId:B,trayId:re}),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:(q,B)=>A(re=>new Map(re).set(q,{id:q,name:B})),checkPrinterFirmware:k?.check_printer_firmware!==!1},O.id))}),e&&a.jsx(I$e,{onClose:()=>n(!1),onAdd:O=>Z.mutate(O),existingSerials:C?.map(O=>O.serial_number)||[]}),Array.from(N.values()).map((O,q)=>a.jsx(r2e,{printerId:O.id,printerName:O.name,viewerIndex:q,onClose:()=>A(B=>{const re=new Map(B);return re.delete(O.id),re})},O.id))]})}function V$e(){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 ff(t,e="bambu_studio"){let n;e==="orcaslicer"?n=`orcaslicer://open?file=${t}`:V$e()==="macos"?n=`bambustudioopen://${encodeURIComponent(t)}`:n=`bambustudio://open?file=${t}`;const r=document.createElement("a");r.href=n,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}const q$e={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 sl(t){return q$e[t.toUpperCase()]||t}const G$e=[{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 (₽)"}],NG=768;function Bne(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<NG:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${NG-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}function AO({archiveId:t,libraryFileId:e,title:n,fileType:r,onClose:i}){const{t:s}=Et(),{data:o}=Je({queryKey:["settings"],queryFn:ge.getSettings}),l=o?.preferred_slicer||"bambu_studio",c=e!=null,[u,d]=w.useState(null),[h,f]=w.useState(null),[p,x]=w.useState(!0),[v,g]=w.useState(null),[y,_]=w.useState(!1),[N,A]=w.useState(null),[C,j]=w.useState(0),[k,R]=w.useState(!1),[M,D]=w.useState(null),[G,U]=w.useState(!1),[W,L]=w.useState(!1),ee=w.useRef(null),ae=w.useRef(null),Y=10,se=160,ce=240,ye=.35;w.useEffect(()=>{const fe=oe=>{oe.key==="Escape"&&i()};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},[i]),w.useEffect(()=>{if(x(!0),c){const fe=(r||"").toLowerCase(),oe=fe==="3mf"||fe==="stl",I=fe==="gcode"||fe==="3mf";f({has_model:oe,has_gcode:I,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d(oe?"3d":I?"gcode":null),x(!1);return}if(!t){f(null),d(null),x(!1);return}ge.getArchiveCapabilities(t).then(fe=>{f(fe),fe.has_model?d("3d"):fe.has_gcode&&d("gcode"),x(!1)}).catch(()=>{f({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d("3d"),x(!1)})},[t,r,c]),w.useEffect(()=>{if(_(!0),A(null),j(0),c){const fe=(r||"").toLowerCase();if(!e||fe!=="3mf"){g(null),_(!1);return}ge.getLibraryFilePlates(e).then(oe=>g(oe)).catch(()=>g(null)).finally(()=>_(!1));return}if(!t){g(null),_(!1);return}ge.getArchivePlates(t).then(fe=>g(fe)).catch(()=>g(null)).finally(()=>_(!1))},[t,r,c,e]);const Z=w.useMemo(()=>v?.plates??[],[v]),ue=(v?.is_multi_plate??!1)&&Z.length>1,pe=k&&ue,be=N==null?null:Z.find(fe=>fe.index===N)??null,Ee=fe=>fe.object_count??fe.objects?.length??0,$=Z.reduce((fe,oe)=>fe+Ee(oe),0),K=be?Ee(be):$,T=be?s("modelViewer.plateNumber",{number:be.index}):s("modelViewer.allPlates"),E=Z.length>0,O=w.useRef(null),q=w.useRef(null),[B,re]=w.useState(10),[z,V]=w.useState(3),te=Z.length>B,Q=Math.max(1,Math.ceil(Z.length/B)),ne=te?Z.slice(C*B,(C+1)*B):Z;w.useEffect(()=>{if(!pe){re(10),V(3);return}const fe=O.current,oe=q.current;if(!fe||!oe)return;let I=0;const F=()=>{const he=oe.clientWidth,Ce=Math.floor(he/210),Ne=Math.max(3,Math.min(5,Ce||3));V(Te=>Te===Ne?Te:Ne);const Ue=window.getComputedStyle(fe),He=Number.parseFloat(Ue.rowGap||"0"),we=fe.querySelector("button")?.getBoundingClientRect().height??44,ke=oe.clientHeight,Ae=Math.max(1,Math.floor((ke+He)/(we+He)))*Ne,Ve=Math.max(1,Ae-1);re(Te=>Te===Ve?Te:Ve)},J=()=>{I&&cancelAnimationFrame(I),I=requestAnimationFrame(F)};J();const xe=new ResizeObserver(J);return xe.observe(oe),xe.observe(fe),()=>{I&&cancelAnimationFrame(I),xe.disconnect()}},[pe,Z.length]),w.useEffect(()=>{if(!te){j(0);return}j(fe=>Math.min(fe,Q-1))},[Z.length,te,Q]),w.useEffect(()=>{if(!te||N==null)return;const fe=Z.findIndex(I=>I.index===N);if(fe<0)return;const oe=Math.floor(fe/B);j(I=>I===oe?I:oe)},[Z,B,N,te]),w.useEffect(()=>{if(!pe){D(null),L(!1);return}if(W)return;const fe=ee.current,oe=ae.current;if(!fe||!oe)return;const I=fe.clientHeight;if(!I)return;const F=Math.max(ce,I*ye),J=Math.max(se,I-Y-F),xe=Math.min(oe.scrollHeight,J);D(Math.max(se,xe))},[pe,W,Z.length,C,Y,se,ce,ye]),w.useEffect(()=>{if(!G)return;const fe=I=>{const F=ee.current;if(!F)return;const J=F.getBoundingClientRect(),xe=J.height;if(!xe)return;const he=Math.max(ce,xe*ye),le=Math.max(se,xe-Y-he),Ce=Math.min(le,Math.max(se,I.clientY-J.top));D(Ce)},oe=()=>{U(!1),L(!0)};return document.addEventListener("mousemove",fe),document.addEventListener("mouseup",oe),document.body.style.cursor="row-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",oe),document.body.style.cursor="",document.body.style.userSelect=""}},[G,Y,se,ce,ye]);const ie=c?(r||"").toLowerCase()==="3mf":!0,me=async()=>{if(!ie)return;const fe=n||"model";try{if(c){const{token:oe}=await ge.createLibrarySlicerToken(e),I=ge.getLibrarySlicerDownloadUrl(e,oe,fe);ff(`${window.location.origin}${I}`,l)}else{const{token:oe}=await ge.createArchiveSlicerToken(t),I=ge.getArchiveSlicerDownloadUrl(t,oe,fe);ff(`${window.location.origin}${I}`,l)}}catch{if(c){const oe=`${window.location.origin}${ge.getLibraryFileDownloadUrl(e)}`;ff(oe,l)}else{const oe=`${window.location.origin}${ge.getArchiveForSlicer(t,fe)}`;ff(oe,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:fe=>fe.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}),E&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary/70 px-2 py-1 rounded whitespace-nowrap",children:[T,": ",s("modelViewer.objectCount",{count:K})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:me,disabled:!ie,children:[a.jsx(aa,{className:"w-4 h-4"}),s("modelViewer.openInSlicer")]}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>R(fe=>!fe),title:k?"Exit fullscreen":"Enter fullscreen",children:k?a.jsx(zF,{className:"w-4 h-4"}):a.jsx(nC,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:i,children:a.jsx(Ut,{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(ni,{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(sme,{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:p?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:ee,className:`w-full h-full flex flex-col ${pe?"gap-0 min-h-0":"gap-3"}`,children:[ue&&a.jsxs("div",{ref:ae,style:pe&&M!=null?{height:M}:void 0,className:`rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3 ${pe?"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(Ga,{className:"w-4 h-4"}),s("modelViewer.plates"),y&&a.jsx(lt,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:pe?"flex flex-col min-h-0 flex-1":void 0,children:[a.jsx("div",{ref:q,className:pe?"min-h-0 overflow-hidden pr-1 flex-1":void 0,children:a.jsxs("div",{ref:O,className:pe?"grid gap-2":"grid grid-cols-2 md:grid-cols-3 gap-2",style:pe?{gridTemplateColumns:`repeat(${z}, minmax(0, 1fr))`}:void 0,children:[a.jsxs("button",{type:"button",onClick:()=>A(null),className:`flex items-center rounded-lg border text-left transition-colors ${pe?"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 ${pe?"w-8 h-8":"w-10 h-10"}`,children:a.jsx(Ga,{className:`${pe?"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:`${pe?"text-xs":"text-sm"} text-white font-medium truncate`,children:s("modelViewer.allPlates")}),a.jsx("p",{className:`${pe?"text-[10px]":"text-xs"} text-bambu-gray truncate`,children:s("modelViewer.plateCount",{count:Z.length})})]}),N==null&&a.jsx(Zr,{className:`${pe?"w-3.5 h-3.5":"w-4 h-4"} text-bambu-green flex-shrink-0`})]}),ne.map(fe=>a.jsxs("button",{type:"button",onClick:()=>A(fe.index),className:`flex items-center rounded-lg border text-left transition-colors ${pe?"gap-1.5 p-1.5 w-full":"gap-2 p-2"} ${N===fe.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[fe.has_thumbnail&&fe.thumbnail_url?a.jsx("img",{src:fe.thumbnail_url,alt:`Plate ${fe.index}`,className:`${pe?"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 ${pe?"w-8 h-8":"w-10 h-10"}`,children:a.jsx(Ga,{className:`${pe?"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:`${pe?"text-xs":"text-sm"} text-white font-medium truncate`,children:fe.name||s("modelViewer.plateNumber",{number:fe.index})}),a.jsx("p",{className:`${pe?"text-[10px]":"text-xs"} text-bambu-gray truncate`,children:s("modelViewer.objectCount",{count:fe.object_count??fe.objects?.length??0})})]}),N===fe.index&&a.jsx(Zr,{className:`${pe?"w-3.5 h-3.5":"w-4 h-4"} text-bambu-green flex-shrink-0`})]},fe.index))]})}),(be||te)&&a.jsxs("div",{className:"mt-auto pt-3 flex items-center gap-4 text-xs text-bambu-gray overflow-x-auto",children:[be&&a.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[a.jsx("span",{children:s("modelViewer.plateNumber",{number:be.index})}),be.print_time_seconds!=null&&a.jsx("span",{children:s("modelViewer.eta",{minutes:Math.round(be.print_time_seconds/60)})}),be.filament_used_grams!=null&&a.jsxs("span",{children:[be.filament_used_grams.toFixed(1)," g"]}),be.filaments.length>0&&a.jsx("span",{children:s("modelViewer.filamentCount",{count:be.filaments.length})})]}),te&&a.jsxs("div",{className:`flex items-center gap-2 whitespace-nowrap ${be?"ml-auto":""}`,children:[a.jsx("span",{children:s("modelViewer.pagination.pageOf",{current:C+1,total:Q})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>j(fe=>Math.max(fe-1,0)),disabled:C===0,className:`px-2 py-1 rounded border text-xs ${C===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 oe=Math.max(0,C-Math.floor(2.5));const I=Math.min(Q,oe+5);I-oe<5&&(oe=Math.max(0,I-5));const F=Array.from({length:I-oe},(J,xe)=>oe+xe);return a.jsxs(a.Fragment,{children:[oe>0&&a.jsx("button",{type:"button",onClick:()=>j(0),className:`px-2 py-1 rounded border text-xs ${C===0?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:"1"}),oe>1&&a.jsx("span",{className:"px-1",children:"…"}),F.map(J=>a.jsx("button",{type:"button",onClick:()=>j(J),className:`px-2 py-1 rounded border text-xs ${C===J?"border-bambu-green text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray"}`,children:J+1},J)),I<Q-1&&a.jsx("span",{className:"px-1",children:"…"}),I<Q&&a.jsx("button",{type:"button",onClick:()=>j(Q-1),className:`px-2 py-1 rounded border text-xs ${C===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:()=>j(fe=>Math.min(fe+1,Q-1)),disabled:C>=Q-1,className:`px-2 py-1 rounded border text-xs ${C>=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")})]})]})]})]})]}),pe&&a.jsx("div",{role:"separator","aria-orientation":"horizontal",onMouseDown:fe=>{fe.preventDefault(),U(!0),L(!0)},className:`h-2 cursor-row-resize flex items-center justify-center ${G?"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 ${pe?"min-h-0":""}`,children:a.jsx(BX,{url:c?ge.getLibraryFileDownloadUrl(e):h.has_source?ge.getSource3mfDownloadUrl(t):ge.getArchiveDownload(t),fileType:r,buildVolume:h.build_volume,filamentColors:h.filament_colors,selectedPlateId:N,className:"w-full h-full"})})]}):u==="gcode"&&h?a.jsx(_Q,{gcodeUrl:c?ge.getLibraryFileGcodeUrl(e):ge.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 XN={"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 W$e(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,f=r/255,p=i/255;s===h?c=((f-p)/d+(f<p?6:0))/6:s===f?c=((p-h)/d+2)/6:c=((h-f)/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 Af(t){const e=t.replace("#","").toLowerCase().substring(0,6);return XN[e]?XN[e]:W$e(t)}function TO(t,e){if(t&&!/^[A-Z]\d+-[A-Z]\d+$/.test(t))return t;if(e&&e.length>=6){const n=e.substring(0,6).toLowerCase();if(XN[n])return XN[n]}return null}function gA(t){const e=[],n=t?.ams_extruder_map,r=n&&Object.keys(n).length>0;t?.ams?.forEach(i=>{const s=i.tray.length===1;i.tray.forEach(o=>{if(o.tray_type){const l=gG(o.tray_color);e.push({type:o.tray_type,color:l,colorName:Af(l),amsId:i.id,trayId:o.id,isHt:s,isExternal:!1,label:kO(i.id,o.id,s,!1),globalTrayId:YN(i.id,o.id,!1),trayInfoIdx:o.tray_info_idx||"",extruderId:n?.[String(i.id)]})}})});for(const i of t?.vt_tray??[])if(i.tray_type){const s=gG(i.tray_color),o=i.id??254,l=(t?.vt_tray?.length??0)>1;e.push({type:i.tray_type,color:s,colorName:Af(s),amsId:-1,trayId:o-254,isHt:!1,isExternal:!0,label:l?o===254?"Ext-L":"Ext-R":"External",globalTrayId:o,trayInfoIdx:i.tray_info_idx||"",extruderId:r?255-o:void 0})}return e}function kG(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=gA(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=l.tray_info_idx||"";let u=n.filter(v=>!r.has(v.globalTrayId));l.nozzle_id!=null&&(u=u.filter(v=>v.extruderId===l.nozzle_id));let d,h,f,p;if(c){const v=u.filter(g=>g.trayInfoIdx===c);v.length===1?d=v[0]:v.length>1&&(h=v.find(g=>g.type?.toUpperCase()===l.type?.toUpperCase()&&La(g.color)===La(l.color)),h||(f=v.find(g=>g.type?.toUpperCase()===l.type?.toUpperCase()&&Oc(g.color,l.color))),!h&&!f&&(p=v.find(g=>g.type?.toUpperCase()===l.type?.toUpperCase())))}!d&&!h&&!f&&!p&&(h=u.find(v=>v.type?.toUpperCase()===l.type?.toUpperCase()&&La(v.color)===La(l.color)),h||(f=u.find(v=>v.type?.toUpperCase()===l.type?.toUpperCase()&&Oc(v.color,l.color))),!h&&!f&&(p=u.find(v=>v.type?.toUpperCase()===l.type?.toUpperCase())));const x=d||h||f||p||void 0;return x&&r.add(x.globalTrayId),{slot_id:l.slot_id,globalTrayId:x?.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 K$e(t){return w.useMemo(()=>gA(t),[t])}function Hne(t,e,n){const r=K$e(e),i=w.useMemo(()=>{if(!t?.filaments||t.filaments.length===0)return[];const c=new Set(Object.values(n));return t.filaments.map(u=>{const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const j=n[d],k=r.find(R=>R.globalTrayId===j);if(k){const R=k.type?.toUpperCase()===u.type?.toUpperCase(),M=La(k.color)===La(u.color)||Oc(k.color,u.color);let D;return R&&M?D="match":R?D="type_only":D="mismatch",{...u,loaded:k,hasFilament:!0,typeMatch:R,colorMatch:M,status:D,isManual:!0}}}const h=u.tray_info_idx||"";let f=r.filter(j=>!c.has(j.globalTrayId));u.nozzle_id!=null&&(f=f.filter(j=>j.extruderId===u.nozzle_id));let p,x,v,g;if(h){const j=f.filter(k=>k.trayInfoIdx===h);j.length===1?p=j[0]:j.length>1&&(x=j.find(k=>k.type?.toUpperCase()===u.type?.toUpperCase()&&La(k.color)===La(u.color)),x||(v=j.find(k=>k.type?.toUpperCase()===u.type?.toUpperCase()&&Oc(k.color,u.color))),!x&&!v&&(g=j.find(k=>k.type?.toUpperCase()===u.type?.toUpperCase())))}!p&&!x&&!v&&!g&&(x=f.find(j=>j.type?.toUpperCase()===u.type?.toUpperCase()&&La(j.color)===La(u.color)),x||(v=f.find(j=>j.type?.toUpperCase()===u.type?.toUpperCase()&&Oc(j.color,u.color))),!x&&!v&&(g=f.find(j=>j.type?.toUpperCase()===u.type?.toUpperCase())));const y=p||x||v||g||void 0;y&&c.add(y.globalTrayId);const _=!!y,N=_,A=!!p||!!x||!!v;let C;return p||x||v?C="match":g?C="type_only":C="mismatch",{...u,loaded:y,hasFilament:_,typeMatch:N,colorMatch:A,status:C,isManual:!1}})},[t,r,n]),s=w.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:s,hasTypeMismatch:o,hasColorMismatch:l}}function Y$e(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 g=n[d],y=e.find(_=>_.globalTrayId===g);if(y){const _=y.type?.toUpperCase()===u.type?.toUpperCase(),N=La(y.color)===La(u.color)||Oc(y.color,u.color);_&&N?r++:_?i++:s++;continue}}let h=e.filter(g=>!o.has(g.globalTrayId));if(u.nozzle_id!=null){const g=h.filter(y=>y.extruderId===u.nozzle_id);g.length>0&&(h=g)}const f=h.find(g=>g.type?.toUpperCase()===u.type?.toUpperCase()&&La(g.color)===La(u.color)),p=f?void 0:h.find(g=>g.type?.toUpperCase()===u.type?.toUpperCase()&&Oc(g.color,u.color)),x=f||p?void 0:h.find(g=>g.type?.toUpperCase()===u.type?.toUpperCase()),v=f??p??x;v&&o.add(v.globalTrayId),f||p?r++:x?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 X$e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=gA(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}let d=r.filter(v=>!i.has(v.globalTrayId));if(c.nozzle_id!=null){const v=d.filter(g=>g.extruderId===c.nozzle_id);v.length>0&&(d=v)}const h=d.find(v=>v.type?.toUpperCase()===c.type?.toUpperCase()&&La(v.color)===La(c.color)),f=h?void 0:d.find(v=>v.type?.toUpperCase()===c.type?.toUpperCase()&&Oc(v.color,c.color)),p=h||f?void 0:d.find(v=>v.type?.toUpperCase()===c.type?.toUpperCase()),x=h??f??p;x&&i.add(x.globalTrayId),s.push({slot_id:u,globalTrayId:x?.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 CG={useDefault:!0,manualMappings:{},autoConfigured:!1};function Q$e(t,e,n,r,i,s){const o=Qb({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>ge.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((x,v)=>{const g=o[v],y=g?.data,N=e?.find(D=>D.id===x)?.name||`Printer ${x}`,A=gA(y),C=i[x]||CG,j=kG(n,y),k=C.useDefault?r:C.manualMappings,R=X$e(n,y,k),M=Y$e(n?.filaments,A,k);return{printerId:x,printerName:N,status:y,isLoading:g?.isLoading??!1,loadedFilaments:A,autoMapping:j,finalMapping:R,matchStatus:M.status,exactMatches:M.exactMatches,typeOnlyMatches:M.typeOnlyMatches,missingTypes:M.missingTypes,totalSlots:M.totalSlots,config:C}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,v)=>{s(g=>({...g,[x]:{...g[x]||CG,...v}}))},d=x=>{const v=l.find(_=>_.printerId===x);if(!v||!v.status||!n?.filaments)return;const g=kG(n,v.status);if(!g)return;const y={};g.forEach((_,N)=>{_!==-1&&(y[N+1]=_)}),u(x,{useDefault:!1,manualMappings:y,autoConfigured:!0})},h=()=>{for(const x of t)d(x)},f=x=>l.find(g=>g.printerId===x)?.finalMapping,p=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:h,autoConfigurePrinter:d,getFinalMapping:f,allPrintersReady:p}}function Z$e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,currencySymbol:i,defaultCostPerKg:s,defaultExpanded:o=!1}){const{t:l}=Et(),c=Qt(),[u,d]=w.useState(!1),[h,f]=w.useState(o),{data:p}=Je({queryKey:["printer-status",t],queryFn:()=>ge.getPrinterStatus(t),enabled:!!t}),{data:x}=Je({queryKey:["spool-assignments",t],queryFn:()=>ge.getAssignments(t),enabled:!!t}),{loadedFilaments:v,filamentComparison:g,hasTypeMismatch:y,hasColorMismatch:_}=Hne(e,p,n),N=w.useMemo(()=>{const U=new Map;for(const W of x||[]){const L=W.ams_id===255,ee=YN(W.ams_id,W.tray_id,L);U.set(ee,W.spool?.cost_per_kg??null)}return U},[x]),A=w.useMemo(()=>{const U=new Map;for(const W of x||[]){const L=W.ams_id===255,ee=YN(W.ams_id,W.tray_id,L),ae=W.spool;if(!ae){U.set(ee,null);continue}U.set(ee,Math.max(0,Math.round((ae.label_weight??0)-(ae.weight_used??0))))}return U},[x]),C=w.useMemo(()=>{let U=0;for(const W of g){const L=W.loaded?.globalTrayId;if(L==null)continue;const ae=N.get(L)??null??s;ae>0&&(U+=W.used_grams/1e3*ae)}return U},[g,N,s]),j=w.useMemo(()=>Array.from(N.values()).some(U=>U!=null&&U>0),[N]),k=e?.filaments&&e.filaments.length>0,R=e?.filaments?.some(U=>U.nozzle_id!=null)??!1;if(!k||!p)return null;const M=y?"#f97316":_?"#facc15":"#00ae42",D=(U,W)=>{if(U>0)if(W===""){const L={...n};delete L[U],r(L)}else r({...n,[U]:parseInt(W,10)})},G=async()=>{d(!0);try{await ge.refreshPrinterStatus(t),await new Promise(U=>setTimeout(U,500)),await c.refetchQueries({queryKey:["printer-status",t]})}finally{d(!1)}};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>f(!h),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(T1,{className:"w-4 h-4",fill:M,stroke:"none"}),a.jsx("span",{children:l("printModal.filamentMapping")}),y?a.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):_?a.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):a.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),h?a.jsx(Sl,{className:"w-4 h-4 ml-auto"}):a.jsx(En,{className:"w-4 h-4 ml-auto"})]}),h&&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:G,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:u,children:[a.jsx(wr,{className:`w-3 h-3 ${u?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),g.map((U,W)=>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} - ${Af(U.color)}`,children:a.jsx(T1,{className:"w-3 h-3",fill:U.color,stroke:U.color})}),a.jsxs("span",{className:"text-white truncate flex items-center gap-1",children:[R&&U.nozzle_id!=null&&a.jsx("span",{className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded text-[9px] font-bold leading-none bg-bambu-gray/20 text-bambu-gray shrink-0",title:U.nozzle_id===1?l("printModal.leftNozzleTooltip"):l("printModal.rightNozzleTooltip"),children:U.nozzle_id===1?l("printModal.leftNozzle"):l("printModal.rightNozzle")}),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:U.loaded?.globalTrayId??"",onChange:L=>D(U.slot_id||0,L.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 ${U.status==="match"?"border-bambu-green/50 text-bambu-green":U.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${U.isManual?"ring-1 ring-blue-400/50":""}`,title:U.isManual?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),v.filter(L=>U.nozzle_id==null||L.extruderId===U.nozzle_id).map(L=>{const ee=A.get(L.globalTrayId),ae=ee!=null?l("printModal.slotRemainingShort",{grams:ee,defaultValue:` - ${ee}g left`}):"";return a.jsxs("option",{value:L.globalTrayId,className:"bg-bambu-dark text-white",children:[L.label,": ",L.type," (",L.colorName,")",ae]},L.globalTrayId)})]}),U.status==="match"?a.jsx(Zr,{className:"w-3 h-3 text-bambu-green"}):U.status==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(Mn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(Mn,{className:"w-3 h-3 text-orange-400"})})]},W)),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[l("printModal.totalCost")," ",a.jsx("span",{className:"text-white",children:C>0||j?`${i}${C.toFixed(2)}`:"N/A"})]}),y&&a.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}function J$e({filamentReqs:t,availableFilaments:e,overrides:n,onChange:r}){const{t:i}=Et(),s=w.useMemo(()=>{const c={};for(const u of e){const d=u.type.toUpperCase();c[d]||(c[d]=[]),c[d].push(u)}return c},[e]),o=t?.filaments;if(!o||o.length===0||e.length===0)return null;const l=(c,u)=>{if(u===""){const d={...n};delete d[c],r(d)}else{const[d,h]=u.split("|");r({...n,[c]:{type:d,color:h}})}};return a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"flex items-center gap-2 text-sm text-bambu-gray mb-2",children:a.jsx("span",{children:i("printModal.filamentOverride")})}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:i("printModal.filamentOverrideHint")}),a.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 space-y-2",children:o.map(c=>{const u=n[c.slot_id],d=!!u,h=s[c.type.toUpperCase()]||[],f=c.nozzle_id!=null?h.filter(p=>p.extruder_id==null||p.extruder_id===c.nozzle_id):h;return a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 20px"},children:[a.jsx("span",{title:`${i("printModal.originalFilament")}: ${c.type} - ${Af(c.color)}`,children:a.jsx(T1,{className:"w-3 h-3",fill:c.color,stroke:c.color})}),a.jsxs("span",{className:"text-white truncate",children:[c.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",c.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:d?`${u.type}|${u.color}`:"",onChange:p=>l(c.slot_id,p.target.value),disabled:f.length===0,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 ${d?"border-blue-400/50 text-blue-400":"border-bambu-gray/30 text-bambu-gray"}`,children:[a.jsxs("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:[i("printModal.originalFilament"),": ",c.type," (",Af(c.color),")"]}),f.map((p,x)=>a.jsxs("option",{value:`${p.type}|${p.color}`,className:"bg-bambu-dark text-white",children:[p.type," (",Af(p.color),")"]},`${p.type}-${p.color}-${x}`))]}),d?a.jsx("button",{type:"button",onClick:()=>l(c.slot_id,""),className:"text-bambu-gray hover:text-white transition-colors",title:i("printModal.resetToOriginal"),children:a.jsx(co,{className:"w-3 h-3"})}):a.jsx("span",{className:"w-3"})]},c.slot_id)})})]})}function e7e({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(Ga,{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(Mn,{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(Ga,{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?` • ${js(i.print_time_seconds)}`:""]})]}),n===i.index&&a.jsx(Zr,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function t7e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=Qt(),[i,s]=w.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 ge.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 f,p=!1;if(h!==void 0)f=t.loadedFilaments.find(v=>v.globalTrayId===h),p=!0;else{const v=new Set(Object.values(t.config.manualMappings)),g=t.loadedFilaments.find(N=>!v.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&La(N.color)===La(u.color)),y=g?void 0:t.loadedFilaments.find(N=>!v.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&Oc(N.color,u.color)),_=g||y?void 0:t.loadedFilaments.find(N=>!v.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase());f=g??y??_}let x="mismatch";if(f){const v=f.type?.toUpperCase()===u.type?.toUpperCase(),g=La(f.color)===La(u.color)||Oc(f.color,u.color);v&&g?x="match":v&&(x="type_only")}return{req:u,loaded:f,status:x,isManual:p}});return a.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom slot mapping"}),a.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:i,children:[a.jsx(wr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:h,isManual:f},p)=>a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[a.jsx("span",{title:`Required: ${u.type} - ${Af(u.color)}`,children:a.jsx(T1,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),a.jsxs("span",{className:"text-white truncate",children:[u.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:d?.globalTrayId??"",onChange:x=>o(u.slot_id||0,x.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${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"} ${f?"ring-1 ring-blue-400/50":""}`,title:f?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(x=>a.jsxs("option",{value:x.globalTrayId,className:"bg-bambu-dark text-white",children:[x.label,": ",x.type," (",x.colorName,")"]},x.globalTrayId))]}),h==="match"?a.jsx(Zr,{className:"w-3 h-3 text-bambu-green"}):h==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(Mn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(Mn,{className:"w-3 h-3 text-orange-400"})})]},p))]})}function n7e({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:f,onTargetModelChange:p,targetLocation:x,onTargetLocationChange:v,slicedForModel:g}){const[y,_]=w.useState(!1),N=s?t:t.filter(Y=>Y.is_active),A=w.useMemo(()=>{if(d!=="printer"||!g||y)return N;const Y=N.filter(se=>se.model===g);return Y.length>0?Y:N},[N,d,g,y]),C=N.length-A.length,j=w.useMemo(()=>{const Y=N.map(se=>se.model).filter(se=>!!se);return[...new Set(Y)].sort()},[N]),k=w.useMemo(()=>{if(!f)return[];const Y=N.filter(se=>se.model===f&&se.location).map(se=>se.location).filter(se=>!!se);return[...new Set(Y)].sort()},[N,f]),R=h&&p&&j.length>0,M=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(A.length===0)return a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[a.jsx(qa,{className:"w-4 h-4"}),"No ",s?"":"active ","printers available"]});const D=Y=>{i?e.includes(Y)?n(e.filter(se=>se!==Y)):n([...e,Y]):n([Y])},G=()=>{n(A.map(Y=>Y.id))},U=()=>{n([])},W=(Y,se,ce)=>{ce.stopPropagation(),!(!c||!u)&&(se?c(Y):u(Y,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},L=Y=>e.includes(Y),ee=e.length,ae=Y=>o?.find(se=>se.printerId===Y);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"),p(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="printer"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[a.jsx(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 Y=g&&j.includes(g)?g:j[0];p(Y)},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(gh,{className:"w-4 h-4"}),a.jsxs("span",{className:"text-sm",children:["Any ",g||"Model"]})]})]}),d==="model"&&R&&a.jsxs("div",{className:"space-y-3 mb-4",children:[!g&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Target Model"}),a.jsxs("select",{value:f||"",onChange:Y=>{p(Y.target.value||null),v&&v(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..."}),j.map(Y=>a.jsx("option",{value:Y,children:Y},Y))]})]}),f&&k.length>0&&v&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Location Filter (optional)"}),a.jsxs("select",{value:x||"",onChange:Y=>v(Y.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(Y=>a.jsx("option",{value:Y,children:Y},Y))]})]}),f&&a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Scheduler will assign to first available idle ",f," printer",x?` in ${x}`:""]})]}),d==="printer"&&i&&A.length>1&&a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[a.jsx("span",{children:ee===0?"Select printers":`${ee} printer${ee!==1?"s":""} selected`}),a.jsxs("div",{className:"flex gap-2",children:[ee<A.length&&a.jsx("button",{type:"button",onClick:G,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),ee>0&&a.jsx("button",{type:"button",onClick:U,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&A.map(Y=>{const se=L(Y.id),ce=ae(Y.id),ye=ce&&!ce.config.useDefault;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>D(Y.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${se?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${Y.is_active?"":"opacity-60"}`,children:[a.jsx("div",{className:`p-2 rounded-lg ${se?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:a.jsx(Dr,{className:`w-5 h-5 ${se?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{className:"text-left flex-1",children:[a.jsxs("p",{className:"text-white font-medium",children:[Y.name,!Y.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:[Y.model||"Unknown model"," • ",Y.ip_address]})]}),i&&a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${se?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:se&&a.jsx(Zr,{className:"w-3 h-3 text-white"})})]}),se&&M&&ce&&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:Z=>Z.stopPropagation(),children:[a.jsx("input",{type:"checkbox",checked:ye,onChange:Z=>W(Y.id,Z.target.checked,Z),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 ${ce.matchStatus==="full"?"text-bambu-green":ce.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",ce.exactMatches,"/",ce.totalSlots," matched)"]}),ce.isLoading&&a.jsx(wr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),ye&&a.jsxs("button",{type:"button",onClick:Z=>{Z.stopPropagation(),c(Y.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(Mge,{className:"w-3 h-3"}),"Auto"]})]}),ye&&a.jsx(t7e,{printerResult:ce,filamentReqs:l.filaments,onUpdateConfig:Z=>u(Y.id,Z)})]})]},Y.id)}),d==="printer"&&C>0&&!y&&a.jsxs("button",{type:"button",onClick:()=>_(!0),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1",children:[a.jsx(Mn,{className:"w-3 h-3 text-yellow-400"}),C," other printer",C>1?"s":""," hidden (different model) —",a.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&y&&g&&a.jsx("button",{type:"button",onClick:()=>_(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:a.jsxs("span",{className:"underline",children:["Show only ",g," printers"]})}),d==="printer"&&ee===0&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(qa,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!f&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(qa,{className:"w-3 h-3"}),"Select a target printer model"]})]})}const r7e=[{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 a7e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=w.useState(n),s=o=>{e({...t,[o]:!t[o]})};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(oC,{className:"w-4 h-4"}),a.jsx("span",{children:"Print Options"}),r?a.jsx(Sl,{className:"w-4 h-4 ml-auto"}):a.jsx(En,{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:r7e.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 i7e({options:t,onChange:e,dateFormat:n="system",timeFormat:r="system",canControlPrinter:i=!0}){const[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(!0),[h,f]=w.useState(!0),p=w.useRef(null),x=w.useRef(!1);w.useEffect(()=>{if(t.scheduleType!=="scheduled"){x.current=!1;return}if(!x.current){x.current=!0;let C;t.scheduledTime?(C=new Date(t.scheduledTime),isNaN(C.getTime())&&(C=new Date,C.setHours(C.getHours()+1,0,0,0))):(C=new Date,C.setHours(C.getHours()+1,0,0,0),e({...t,scheduledTime:_3(C)})),o(S3(C,n)),c(n8(C,r)),d(!0),f(!0)}},[t.scheduleType,t.scheduledTime,n,r,e,t]);const v=C=>{e({...t,scheduleType:C})},g=(C,j)=>{const k=Qge(C,n),R=Zge(j);d(!!k),f(!!R),k&&R&&(k.setHours(R.hours,R.minutes,0,0),k>new Date&&e({...t,scheduledTime:_3(k)}))},y=C=>{o(C),g(C,l)},_=C=>{c(C),g(s,C)},N=C=>{const j=C.target.value;if(j){const k=new Date(j);isNaN(k.getTime())||(o(S3(k,n)),c(n8(k,r)),d(!0),f(!0),e({...t,scheduledTime:j}))}},A=()=>{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:()=>v("asap"),children:[a.jsx(Xn,{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:()=>v("scheduled"),children:[a.jsx(Xr,{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:()=>v("manual"),children:[a.jsx(zY,{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 ${u?"border-bambu-dark-tertiary focus:border-bambu-green":"border-red-500"}`,value:s,onChange:C=>y(C.target.value),placeholder:Yge(n)}),a.jsx("button",{type:"button",onClick:A,className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",title:"Open calendar",children:a.jsx(Xr,{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 ${h?"border-bambu-dark-tertiary focus:border-bambu-green":"border-red-500"}`,value:l,onChange:C=>_(C.target.value),placeholder:Xge(r)})})]}),a.jsx("input",{ref:p,type:"datetime-local",className:"sr-only",value:t.scheduledTime,onChange:N,tabIndex:-1}),(!u||!h)&&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:C=>e({...t,requirePreviousSuccess:C.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:C=>e({...t,autoOffAfter:C.target.checked}),disabled:!i,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green disabled:opacity-50"}),a.jsxs("label",{htmlFor:"autoOffAfter",className:`text-sm flex items-center gap-1 ${i?"text-bambu-gray":"text-bambu-gray/50"}`,children:[a.jsx(gd,{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 Eg={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},s7e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function Zu({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:s,onSuccess:o}){const{t:l}=Et(),c=Qt(),{showToast:u}=dn(),{hasPermission:d}=Rr(),h=!!n&&!e,[f,p]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[x,v]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[g,y]=w.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??Eg.bed_levelling,flow_cali:i.flow_cali??Eg.flow_cali,vibration_cali:i.vibration_cali??Eg.vibration_cali,layer_inspect:i.layer_inspect??Eg.layer_inspect,timelapse:i.timelapse??Eg.timelapse}:Eg),[_,N]=w.useState(()=>{if(t==="edit-queue-item"&&i){let Pe="asap";i.manual_start?Pe="manual":i.scheduled_time&&!bG(i.scheduled_time)&&(Pe="scheduled");let Be="";if(i.scheduled_time&&!bG(i.scheduled_time)){const We=Jn(i.scheduled_time)??new Date;Be=_3(We)}return{scheduleType:Pe,scheduledTime:Be,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return s7e}),[A,C]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const Pe={};return i.ams_mapping.forEach((Be,We)=>{Be!==-1&&(Pe[We+1]=Be)}),Pe}return{}}),[j,k]=w.useState({}),[R,M]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[D,G]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?i.target_model:null),[U,W]=w.useState(()=>t==="edit-queue-item"&&i?.target_location?i.target_location:null),[L,ee]=w.useState(()=>{if(t==="edit-queue-item"&&i?.filament_overrides){const Pe={};for(const Be of i.filament_overrides)Pe[Be.slot_id]={type:Be.type,color:Be.color};return Pe}return{}}),[ae]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[Y]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[se,ce]=w.useState(!1),[ye,Z]=w.useState({current:0,total:0}),[ue,pe]=w.useState(new Set),be=f.length,Ee=f.length>0?f[0]:null,{data:$}=Je({queryKey:["settings"],queryFn:ge.getSettings}),K=sl($?.currency||"USD"),T=$?.default_filament_cost??0,{data:E,isLoading:O}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:q}=Je({queryKey:["archive",e],queryFn:()=>ge.getArchive(e),enabled:!!e&&!h}),{data:B}=Je({queryKey:["library-file",n],queryFn:()=>ge.getLibraryFile(n),enabled:h&&!!n}),re=q?.sliced_for_model||B?.sliced_for_model||null,{data:z,isError:V}=Je({queryKey:["archive-plates",e],queryFn:()=>ge.getArchivePlates(e),enabled:!!e&&!h,retry:!1}),{data:te}=Je({queryKey:["library-file-plates",n],queryFn:()=>ge.getLibraryFilePlates(n),enabled:h&&!!n}),Q=h?te:z,{data:ne,isError:ie}=Je({queryKey:["archive-filaments",e,x],queryFn:()=>ge.getArchiveFilamentRequirements(e,x??void 0),enabled:!!e&&!h&&(x!==null||!Q?.is_multi_plate),retry:!1}),{data:me}=Je({queryKey:["library-file-filaments",n,x],queryFn:()=>ge.getLibraryFileFilamentRequirements(n,x??void 0),enabled:h&&!!n&&(x!==null||!Q?.is_multi_plate)}),fe=!h&&(V||ie),oe=h?me:ne,I=w.useMemo(()=>{if(!(x===null||!Q?.plates?.length))return Q.plates.find(Pe=>Pe.index===x)?.name||void 0},[Q,x]),{data:F}=Je({queryKey:["available-filaments",D,U],queryFn:()=>ge.getAvailableFilaments(D,U??void 0),enabled:R==="model"&&!!D}),{data:J}=Je({queryKey:["printer-status",Ee],queryFn:()=>ge.getPrinterStatus(Ee),enabled:!!Ee}),{amsMapping:xe}=Hne(oe,J,A),he=Q$e(f,E,oe,A,j,k);w.useEffect(()=>{Q?.plates&&Q.plates.length>=1&&!x&&v(Q.plates[0].index)},[Q,x]),w.useEffect(()=>{if(t==="edit-queue-item")return;const Pe=E?.filter(Be=>Be.is_active)||[];Pe.length===1&&f.length===0&&p([Pe[0].id])},[t,E,f.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(f.sort())!==JSON.stringify(ae.sort())||x!==Y)&&(C({}),k({}),pe(new Set)):(C({}),k({}),pe(new Set))},[t,f,x,ae,Y]);const[le,Ce]=w.useState(D),[Ne,Ue]=w.useState(x);w.useEffect(()=>{(D!==le||x!==Ne)&&(Ce(D),Ue(x),(t!=="edit-queue-item"||le!==null)&&ee({}))},[D,x,le,Ne,t]),w.useEffect(()=>{if(!$?.per_printer_mapping_expanded||f.length<=1)return;const Pe=f.filter(Be=>{if(ue.has(Be))return!1;const We=he.printerResults.find(ct=>ct.printerId===Be);return We&&We.status&&!We.isLoading});Pe.length>0&&(pe(Be=>{const We=new Set(Be);return Pe.forEach(ct=>We.add(ct)),We}),Pe.forEach(Be=>{he.autoConfigurePrinter(Be)}))},[$?.per_printer_mapping_expanded,f,ue,he]),w.useEffect(()=>{const Pe=Be=>{Be.key==="Escape"&&!se&&s()};return window.addEventListener("keydown",Pe),()=>window.removeEventListener("keydown",Pe)},[s,se]);const He=Q?.is_multi_plate??!1,de=Q?.plates??[],we=ut({mutationFn:Pe=>ge.addToQueue(Pe)}),ke=ut({mutationFn:Pe=>ge.updateQueueItem(i.id,Pe),onSuccess:()=>{c.invalidateQueries({queryKey:["queue"]}),u("Queue item updated"),o?.(),s()},onError:Pe=>{u(Pe.message||"Failed to update queue item","error")}}),_e=async Pe=>{if(Pe?.preventDefault(),R==="printer"&&f.length===0){u("Please select at least one printer","error");return}if(R==="model"&&!D){u("Please select a target printer model","error");return}ce(!0);const Be=R==="model"?1:f.length;Z({current:0,total:Be});const We={success:0,failed:0,errors:[]},ct=yt=>{if(f.length>1){const $e=j[yt];if($e&&!$e.useDefault)return he.getFinalMapping(yt)}return xe},St=Object.keys(L).length>0?Object.entries(L).map(([yt,{type:$e,color:dt}])=>({slot_id:parseInt(yt,10),type:$e,color:dt})):void 0,Mt=yt=>({printer_id:R==="printer"?yt:null,target_model:R==="model"?D:null,target_location:R==="model"?U:null,filament_overrides:R==="model"?St:void 0,archive_id:h?void 0:e,library_file_id:h?n:void 0,require_previous_success:_.requirePreviousSuccess,auto_off_after:_.autoOffAfter,manual_start:_.scheduleType==="manual",ams_mapping:yt?ct(yt):void 0,plate_id:x,scheduled_time:_.scheduleType==="scheduled"&&_.scheduledTime?new Date(_.scheduledTime).toISOString():void 0,...g});if(R==="model"){Z({current:1,total:1});try{if(t==="reprint"){u("Model-based assignment only works with queue mode","error"),ce(!1);return}else if(t==="edit-queue-item"){const yt={printer_id:null,target_model:D,target_location:U,filament_overrides:St||null,require_previous_success:_.requirePreviousSuccess,auto_off_after:_.autoOffAfter,manual_start:_.scheduleType==="manual",ams_mapping:void 0,plate_id:x,scheduled_time:_.scheduleType==="scheduled"&&_.scheduledTime?new Date(_.scheduledTime).toISOString():null,...g};await ke.mutateAsync(yt)}else await we.mutateAsync(Mt(null));We.success++}catch(yt){We.failed++,We.errors.push(yt.message)}}else for(let yt=0;yt<f.length;yt++){const $e=f[yt];Z({current:yt+1,total:f.length});try{if(t==="reprint"){const dt=ct($e);h?await ge.printLibraryFile(n,$e,{plate_id:x??void 0,plate_name:I,ams_mapping:dt,...g}):await ge.reprintArchive(e,$e,{plate_id:x??void 0,plate_name:I,ams_mapping:dt,...g})}else if(t==="edit-queue-item"&&yt===0){const dt=ct($e),gt={printer_id:$e,target_model:null,target_location:null,require_previous_success:_.requirePreviousSuccess,auto_off_after:_.autoOffAfter,manual_start:_.scheduleType==="manual",ams_mapping:dt,plate_id:x,scheduled_time:_.scheduleType==="scheduled"&&_.scheduledTime?new Date(_.scheduledTime).toISOString():null,...g};await ke.mutateAsync(gt)}else await we.mutateAsync(Mt($e));We.success++}catch(dt){We.failed++;const gt=E?.find(Lt=>Lt.id===$e)?.name||`Printer ${$e}`;We.errors.push(`${gt}: ${dt.message}`)}}ce(!1),We.failed===0?(t!=="reprint"&&(R==="model"?u(t==="edit-queue-item"?"Queue item updated":`Queued for any ${D}`):t==="edit-queue-item"?u("Queue item updated"):We.success===1?u("Print queued for printer"):u(`Print queued for ${We.success} printers`)),c.invalidateQueries({queryKey:["queue"]}),o?.(),s()):We.success===0?u(`Failed: ${We.errors[0]}`,"error"):(u(`${We.success} succeeded, ${We.failed} failed`,"error"),c.invalidateQueries({queryKey:["queue"]}))},Ae=se||ke.isPending,Ve=w.useMemo(()=>!(Ae||R==="printer"&&f.length===0||R==="model"&&!D||R==="model"&&t==="reprint"||He&&!x),[f.length,R,D,t,He,x,Ae]),Ke=(()=>{const Pe=f.length;return t==="reprint"?{title:l(h?"queue.print":"queue.reprint"),icon:Dr,submitText:Pe>1?l("queue.printToPrinters",{count:Pe}):l("queue.print"),submitIcon:Dr,loadingText:ye.total>1?l("queue.sendingProgress",{current:ye.current,total:ye.total}):l("queue.sending")}:t==="add-to-queue"?{title:l("queue.schedulePrint"),icon:Xr,submitText:Pe>1?l("queue.queueToPrinters",{count:Pe}):l("queue.addToQueue"),submitIcon:Xr,loadingText:ye.total>1?l("queue.addingProgress",{current:ye.current,total:ye.total}):l("queue.adding")}:{title:l("queue.editQueueItem"),icon:Ka,submitText:l("common.save"),submitIcon:Ka,loadingText:ye.total>1?l("queue.savingProgress",{current:ye.current,total:ye.total}):l("common.saving")}})(),je=Ke.icon,qe=Ke.submitIcon,Re=Ee&&(h||(He?x!==null:!0));return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:se?void 0:s,children:a.jsx(Ct,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:Pe=>Pe.stopPropagation(),children:a.jsxs(Tt,{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(je,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:Ke.title})]}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:s,disabled:se,children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:_e,className:t==="reprint"?"":"p-4 space-y-4",children:[a.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?a.jsxs(a.Fragment,{children:["Send ",a.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),a.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),a.jsx(e7e,{plates:de,isMultiPlate:He,selectedPlate:x,onSelect:v}),a.jsx(n7e,{printers:E||[],selectedPrinterIds:f,onMultiSelect:p,isLoading:O,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:he.printerResults,filamentReqs:oe,onAutoConfigurePrinter:he.autoConfigurePrinter,onUpdatePrinterConfig:he.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":R,onAssignmentModeChange:t!=="reprint"?M:void 0,targetModel:D,onTargetModelChange:t!=="reprint"?G:void 0,targetLocation:U,onTargetLocationChange:t!=="reprint"?W:void 0,slicedForModel:re}),R==="model"&&D&&oe&&F&&F.length>0&&a.jsx(J$e,{filamentReqs:oe,availableFilaments:F,overrides:L,onChange:ee}),re&&R==="printer"&&f.length===1&&(()=>{const Pe=E?.find(Be=>Be.id===f[0]);return Pe&&Pe.model&&re!==Pe.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(Mn,{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 ",re,", but printing on ",Pe.model]})]}):null})(),fe&&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(qa,{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."})]}),Re&&!fe&&f.length===1&&a.jsx(Z$e,{printerId:Ee,filamentReqs:oe,manualMappings:A,onManualMappingChange:C,defaultExpanded:$?.per_printer_mapping_expanded??!1,currencySymbol:K,defaultCostPerKg:T}),(t==="reprint"||be>0||R==="model"&&D)&&a.jsx(a7e,{options:g,onChange:y}),t!=="reprint"&&a.jsx(i7e,{options:_,onChange:N,dateFormat:$?.date_format||"system",timeFormat:$?.time_format||"system",canControlPrinter:d("printers:control")}),ke.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:ke.error?.message||"Failed to complete operation"}),a.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[a.jsx(Oe,{type:"button",variant:"secondary",onClick:s,className:"flex-1",disabled:se,children:"Cancel"}),a.jsx(Oe,{type:"submit",disabled:!Ve,className:"flex-1",children:Ae?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),Ke.loadingText]}):a.jsxs(a.Fragment,{children:[a.jsx(qe,{className:"w-4 h-4"}),Ke.submitText]})})]})]})]})})})}function o7e({onClose:t,initialFiles:e}){const{t:n}=Et(),r=Qt(),{showToast:i}=dn(),s=w.useRef(null),[o,l]=w.useState(()=>e?.filter(C=>C.name.endsWith(".3mf")).map(C=>({file:C,status:"pending"}))||[]),[c,u]=w.useState(!1),[d,h]=w.useState(null);w.useEffect(()=>{const C=j=>{j.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]);const f=ut({mutationFn:C=>ge.uploadArchivesBulk(C),onSuccess:C=>{h(C),r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["archiveStats"]}),l(j=>j.map(k=>{const R=C.results.find(D=>D.filename===k.file.name),M=C.errors.find(D=>D.filename===k.file.name);return R?{...k,status:"success",archiveId:R.id}:M?{...k,status:"error",error:M.error}:k})),C.failed===0?i(`${C.uploaded} file${C.uploaded!==1?"s":""} uploaded`):C.uploaded===0?i(`Failed to upload ${C.failed} file${C.failed!==1?"s":""}`,"error"):i(`${C.uploaded} uploaded, ${C.failed} failed`,"warning")},onError:()=>{l(C=>C.map(j=>({...j,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),p=w.useCallback(C=>{C.preventDefault(),u(!0)},[]),x=w.useCallback(C=>{C.preventDefault(),u(!1)},[]),v=w.useCallback(C=>{C.preventDefault(),u(!1);const j=Array.from(C.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));j.length>0&&l(k=>[...k,...j.map(R=>({file:R,status:"pending"}))])},[]),g=w.useCallback(C=>{const j=Array.from(C.target.files||[]).filter(k=>k.name.endsWith(".3mf"));j.length>0&&l(k=>[...k,...j.map(R=>({file:R,status:"pending"}))]),s.current&&(s.current.value="")},[]),y=w.useCallback(C=>{l(j=>j.filter((k,R)=>R!==C))},[]),_=()=>{if(o.length===0)return;const C=o.filter(j=>j.status==="pending");C.length!==0&&(l(j=>j.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),f.mutate(C.map(j=>j.file)))},N=o.filter(C=>C.status==="pending").length,A=f.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(Ct,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:a.jsxs(Tt,{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(Ut,{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:p,onDragLeave:x,onDrop:v,children:[a.jsx(Ia,{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(Oe,{variant:"secondary",onClick:()=>s.current?.click(),disabled:A,children:n("uploadModal.browseFiles")}),a.jsx("input",{ref:s,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:g})]})}),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((C,j)=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(Zk,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"flex-1 text-white text-sm truncate",children:C.file.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[(C.file.size/(1024*1024)).toFixed(1)," MB"]}),C.status==="pending"&&a.jsx("button",{onClick:()=>y(j),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:A,children:a.jsx(Ut,{className:"w-4 h-4"})}),C.status==="uploading"&&a.jsx(lt,{className:"w-4 h-4 text-bambu-green animate-spin"}),C.status==="success"&&a.jsx(xr,{className:"w-4 h-4 text-bambu-green"}),C.status==="error"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-red-400",children:C.error}),a.jsx(qa,{className:"w-4 h-4 text-red-400"})]})]},`${C.file.name}-${j}`))})}),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(Oe,{variant:"secondary",onClick:t,className:"flex-1",children:n(d?"common.close":"common.cancel")}),!d&&a.jsx(Oe,{onClick:_,disabled:N===0||A,className:"flex-1",children:A?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(Ia,{className:"w-4 h-4"}),n("uploadModal.upload")," ",N>0&&`(${N})`]})})]})]})})})}const l7e=["adhesionFailure","spaghettiDetached","layerShift","cloggedNozzle","filamentRunout","warping","stringing","underExtrusion","powerFailure","userCancelled","other"],c7e=["completed","failed","aborted","printing"];function $ne({archive:t,onClose:e,existingTags:n=[]}){const{t:r}=Et();w.useEffect(()=>{const E=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const i=Qt(),[s,o]=w.useState(t.print_name||""),[l,c]=w.useState(t.printer_id),[u,d]=w.useState(t.project_id??null),[h,f]=w.useState(t.notes||""),[p,x]=w.useState(t.tags||""),[v,g]=w.useState(t.failure_reason||""),[y,_]=w.useState(t.status),[N,A]=w.useState(t.quantity??1),[C,j]=w.useState(t.photos||[]),[k,R]=w.useState(t.external_url||""),[M,D]=w.useState(!1),[G,U]=w.useState(!1),W=w.useRef(null),L=w.useRef(null),ee=w.useRef(null),{data:ae}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:Y}=Je({queryKey:["projects"],queryFn:()=>ge.getProjects()}),{data:se}=Je({queryKey:["tags"],queryFn:ge.getTags,enabled:n.length===0}),ce=n.length>0?n:se?.map(E=>E.name)||[],ye=p.split(",").map(E=>E.trim()).filter(Boolean),Z=p.includes(",")?p.substring(p.lastIndexOf(",")+1).trim().toLowerCase():p.trim().toLowerCase(),ue=ce.filter(E=>!ye.includes(E)&&(Z===""||E.toLowerCase().includes(Z))),pe=E=>{let O;if(Z&&!ce.includes(Z)?O=p.includes(",")?p.substring(0,p.lastIndexOf(",")).split(",").map(q=>q.trim()).filter(Boolean):[]:O=ye,!O.includes(E)){const q=[...O,E].join(", ");x(q)}ee.current!==null&&clearTimeout(ee.current),W.current?.focus()},be=E=>{const O=ye.filter(q=>q!==E).join(", ");x(O)},Ee=ut({mutationFn:E=>ge.updateArchive(t.id,E),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),i.invalidateQueries({queryKey:["projects"]}),e()}}),$=async E=>{const O=E.target.files?.[0];if(O){D(!0);try{const q=await ge.uploadArchivePhoto(t.id,O);j(q.photos),i.invalidateQueries({queryKey:["archives"]})}catch(q){console.error("Failed to upload photo:",q)}finally{D(!1),L.current&&(L.current.value="")}}},K=async E=>{try{const O=await ge.deleteArchivePhoto(t.id,E);j(O.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(O){console.error("Failed to delete photo:",O)}},T=E=>{E.preventDefault();const O={print_name:s||void 0,printer_id:l,project_id:u,notes:h||void 0,tags:p||void 0,quantity:N,external_url:k||null};y!==t.status&&(O.status=y),y==="failed"||y==="aborted"?O.failure_reason=v||void 0:(t.status==="failed"||t.status==="aborted")&&(O.failure_reason=null),Ee.mutate(O)};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:E=>E.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("editArchive.title")}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:T,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:E=>o(E.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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:E=>c(E.target.value?Number(E.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")}),ae?.map(E=>a.jsx("option",{value:E.id,children:E.name},E.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(xs,{className:"w-4 h-4 inline mr-1"}),r("editArchive.project")]}),a.jsxs("select",{value:u??"",onChange:E=>d(E.target.value?Number(E.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")}),Y?.map(E=>a.jsx("option",{value:E.id,children:E.name},E.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(mfe,{className:"w-4 h-4 inline mr-1"}),r("editArchive.itemsPrinted")]}),a.jsx("input",{type:"number",min:1,value:N,onChange:E=>A(Math.max(1,parseInt(E.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:E=>f(E.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(ex,{className:"w-4 h-4 inline mr-1"}),r("editArchive.externalLink")]}),a.jsx("input",{type:"url",value:k,onChange:E=>R(E.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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")}),ye.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ye.map(E=>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(ad,{className:"w-3 h-3"}),E,a.jsx("button",{type:"button",onClick:()=>be(E),className:"ml-0.5 text-bambu-gray hover:text-white",children:a.jsx(Ut,{className:"w-3 h-3"})})]},E))}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{ref:W,type:"text",value:p,onChange:E=>x(E.target.value),onFocus:()=>{ee.current!==null&&clearTimeout(ee.current),U(!0)},onBlur:()=>{ee.current=window.setTimeout(()=>U(!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:ye.length>0?r("editArchive.addMoreTags"):r("editArchive.tagsPlaceholder")}),G&&ue.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:[Z?r("editArchive.matchingTags",{query:Z}):r("editArchive.existingTags")," ",r("editArchive.clickToAdd")]}),a.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:ue.map(E=>a.jsx("button",{type:"button",onClick:()=>pe(E),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:E},E))})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.status")}),a.jsx("select",{value:y,onChange:E=>{_(E.target.value),E.target.value==="completed"&&g("")},className:"w-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:c7e.map(E=>a.jsx("option",{value:E,children:r(`editArchive.statuses.${E}`)},E))})]}),(y==="failed"||y==="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:v,onChange:E=>g(E.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:r("editArchive.selectReason")}),l7e.map(E=>a.jsx("option",{value:r(`editArchive.failureReasons.${E}`),children:r(`editArchive.failureReasons.${E}`)},E))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(xb,{className:"w-4 h-4 inline mr-1"}),r("editArchive.photos")]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[C.map(E=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:ge.getArchivePhotoUrl(t.id,E),alt:r("editArchive.printResult"),className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:()=>K(E),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(Xt,{className:"w-3 h-3 text-white"})})]},E)),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:L,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:$,className:"hidden",disabled:M}),M?a.jsx(lt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):a.jsx(nr,{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(Oe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:r("common.cancel")}),a.jsxs(Oe,{type:"submit",disabled:Ee.isPending,className:"flex-1",children:[a.jsx(bs,{className:"w-4 h-4"}),Ee.isPending?r("common.saving"):r("common.save")]})]})]})]})})}function Vne({x:t,y:e,items:n,onClose:r}){const i=w.useRef(null),[s,o]=w.useState(null),l=w.useRef(null),[c,u]=w.useState({x:t,y:e,visible:!1}),[d,h]=w.useState(!1),[f,p]=w.useState({});w.useEffect(()=>{const g=N=>{i.current&&!i.current.contains(N.target)&&r()},y=N=>{N.key==="Escape"&&r()},_=()=>{r()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),document.addEventListener("scroll",_,!0),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y),document.removeEventListener("scroll",_,!0),l.current&&clearTimeout(l.current)}},[r]),w.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const g=i.current.getBoundingClientRect(),y=window.innerWidth,_=window.innerHeight,N=8;let A=t,C=e;t+g.width>y-N&&(A=Math.max(N,y-g.width-N)),A<N&&(A=N),e+g.height>_-N&&(C=Math.max(N,_-g.height-N)),C<N&&(C=N);const j=180,k=y-A-g.width,R=A;h(k<j&&R>j),u({x:A,y:C,visible:!0})}},[t,e]);const x=(g,y)=>{l.current&&(clearTimeout(l.current),l.current=null);const _=y.getBoundingClientRect(),N=window.innerHeight,A=300,k=N-_.top-8<A&&_.top>A;p(R=>({...R,[g]:k?"bottom":"top"})),o(g)},v=()=>{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((g,y)=>{if(g.divider)return a.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},y);const _=g.submenu&&g.submenu.length>0;return a.jsxs("div",{className:"relative",onMouseEnter:N=>_&&x(y,N.currentTarget),onMouseLeave:()=>_&&v(),children:[a.jsxs("button",{onMouseEnter:N=>_&&x(y,N.currentTarget.parentElement),onClick:()=>{_?o(s===y?null:y):g.disabled||(g.onClick(),r())},disabled:g.disabled,title:g.title,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${g.disabled?"text-bambu-gray cursor-not-allowed":g.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${_&&s===y?"bg-bambu-dark-tertiary":""}`,children:[g.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:g.icon}),a.jsx("span",{className:"flex-1",children:g.label}),_&&a.jsx(pi,{className:"w-4 h-4 text-bambu-gray"})]}),_&&s===y&&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"} ${f[y]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>v(),children:g.submenu.map((N,A)=>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]},A))})]},y)})})}function u7e({selectedIds:t,existingTags:e,onClose:n}){const r=Qt(),{showToast:i}=dn(),[s,o]=w.useState(""),[l,c]=w.useState(new Set),[u,d]=w.useState("add");w.useEffect(()=>{const v=g=>{g.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const h=ut({mutationFn:async()=>{const v=Array.from(l);let g=0;for(const y of t)try{const _=await ge.getArchive(y),N=_.tags?_.tags.split(",").map(C=>C.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...N,...v])]:A=N.filter(C=>!l.has(C)),await ge.updateArchive(y,{tags:A.join(", ")}),g++}catch(_){throw console.error(`Failed to update archive ${y}:`,_),new Error(`Failed on archive ${y}: ${_ instanceof Error?_.message:"Unknown error"}`)}return{count:g,mode:u,tags:v}},onSuccess:({count:v,mode:g,tags:y})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${g==="add"?"Added":"Removed"} ${y.length} tag${y.length!==1?"s":""} ${g==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:v=>{i(v.message||"Failed to update tags","error")}}),f=v=>{c(g=>{const y=new Set(g);return y.has(v)?y.delete(v):y.add(v),y})},p=()=>{s.trim()&&!l.has(s.trim())&&(c(v=>new Set([...v,s.trim()])),o(""))},x=v=>{v.key==="Enter"&&(v.preventDefault(),p())};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(Ct,{className:"w-full max-w-md",children:a.jsxs(Tt,{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(ad,{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(Ut,{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(Oe,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),a.jsx(Oe,{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:v=>o(v.target.value),onKeyDown:x}),a.jsx(Oe,{size:"sm",variant:"secondary",onClick:p,disabled:!s.trim(),children:a.jsx(nr,{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(v=>a.jsx("button",{onClick:()=>f(v),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(v)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:v},v))})]}),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(v=>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:[v,a.jsx("button",{onClick:()=>f(v),className:"hover:opacity-70",children:a.jsx(Ut,{className:"w-3 h-3"})})]},v))})]})]}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Oe,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),a.jsx(Oe,{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(ad,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function d7e({selectedIds:t,onClose:e}){const n=Qt(),{showToast:r}=dn(),{data:i,isLoading:s}=Je({queryKey:["projects"],queryFn:()=>ge.getProjects()});w.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=ut({mutationFn:async d=>(await ge.addArchivesToProject(d,t),d),onSuccess:d=>{const h=i?.find(f=>f.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${h?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=ut({mutationFn:async()=>{for(const d of t)await ge.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(Ct,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:a.jsxs(Tt,{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(xs,{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(Ut,{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(ii,{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(xs,{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(Oe,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function h7e(t,e){return new Date(t,e+1,0).getDate()}function m7e(t,e){return new Date(t,e,1).getDay()}const f7e=["January","February","March","April","May","June","July","August","September","October","November","December"],p7e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function g7e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,s]=w.useState(r.getMonth()),[o,l]=w.useState(r.getFullYear()),[c,u]=w.useState(null),[d,h]=w.useState(null),f=w.useMemo(()=>{const C=new Map;return t.forEach(j=>{const k=Jn(j.completed_at||j.created_at)||new Date,R=`${k.getFullYear()}-${String(k.getMonth()+1).padStart(2,"0")}-${String(k.getDate()).padStart(2,"0")}`,M=C.get(R)||[];M.push(j),C.set(R,M)}),C},[t]),p=h7e(o,i),x=m7e(o,i),v=()=>{i===0?(s(11),l(o-1)):s(i-1)},g=()=>{i===11?(s(0),l(o+1)):s(i+1)},y=()=>{s(r.getMonth()),l(r.getFullYear())},_=[];for(let C=0;C<x;C++)_.push(null);for(let C=1;C<=p;C++)_.push(C);const N=c?f.get(c)||[]:[],A=C=>{C!==c&&h(null),u(C)};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:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Jl,{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:[f7e[i]," ",o]}),a.jsx("button",{onClick:y,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:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(pi,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:p7e.map(C=>a.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:C},C))}),a.jsx("div",{className:"grid grid-cols-7 gap-1",children:_.map((C,j)=>{if(C===null)return a.jsx("div",{className:"aspect-square"},`empty-${j}`);const k=`${o}-${String(i+1).padStart(2,"0")}-${String(C).padStart(2,"0")}`,R=f.get(k)||[],M=R.length>0,D=C===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),G=k===c,U=R.filter(L=>L.status==="completed").length,W=R.filter(L=>L.status==="failed").length;return a.jsxs("button",{onClick:()=>A(G?null:k),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${G?"bg-bambu-green text-white":D?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":M?"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 ${D&&!G?"text-bambu-green":""}`,children:C}),M&&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 ${W>0&&U===0?"bg-red-400":W>0?"bg-yellow-400":"bg-green-400"}`}),a.jsx("span",{className:"text-xs font-medium",children:R.length})]})]},C)})}),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(C=>{const j=Jn(C.completed_at||C.created_at)||new Date;return j.getMonth()===i&&j.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(C=>{const j=Jn(C.completed_at||C.created_at)||new Date;return j.getMonth()===i&&j.getFullYear()===o&&C.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(C=>{const j=Jn(C.completed_at||C.created_at)||new Date;return j.getMonth()===i&&j.getFullYear()===o&&C.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:"calendar-scroll space-y-2 max-h-96 overflow-y-auto",children:N.map(C=>{const j=C.id===d||C.id===n;return a.jsxs("button",{onClick:()=>{h(C.id),e?.(C)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${j?"":"hover:bg-bambu-dark-tertiary"}`,style:j?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[C.thumbnail_path?a.jsx("img",{src:ge.getArchiveThumbnail(C.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:C.print_name||C.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:C.status==="failed"?"text-red-400":"text-green-400",children:C.status==="failed"?"Failed":"Completed"}),C.filament_color&&a.jsx("div",{className:"flex gap-0.5",children:C.filament_color.split(",").map((k,R)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:k}},R))})]})]})]},C.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 qne({archiveId:t,archiveName:e,onClose:n}){const r=ge.getArchiveQRCodeUrl(t,300);w.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=()=>{const s=document.createElement("a");s.href=r,s.download=`${e}_qrcode.png`,s.click()};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ut,{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(Oe,{onClick:i,className:"w-full",children:[a.jsx(ba,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Gne({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,o]=w.useState(0),[l,c]=w.useState(!1);if(w.useEffect(()=>{const p=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&o(v=>Math.max(0,v-1)),x.key==="ArrowRight"&&o(v=>Math.min(n.length-1,v+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),w.useEffect(()=>{s>=n.length&&o(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return r(),null;const u=n[s],d=ge.getArchivePhotoUrl(t,u),h=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${s+1}.jpg`,p.click()},f=()=>{i&&c(!0)};return a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[a.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:p=>p.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:h,children:[a.jsx(ba,{className:"w-4 h-4"}),"Download"]}),i&&a.jsx(Oe,{variant:"secondary",size:"sm",onClick:f,className:"text-red-400 hover:text-red-300",children:a.jsx(Xt,{className:"w-4 h-4"})}),a.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ut,{className:"w-6 h-6"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&a.jsx("button",{onClick:()=>o(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(Jl,{className:"w-8 h-8 text-white"})}),a.jsx("img",{src:d,alt:`Photo ${s+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),s<n.length-1&&a.jsx("button",{onClick:()=>o(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(pi,{className:"w-8 h-8 text-white"})})]}),n.length>1&&a.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((p,x)=>a.jsx("button",{onClick:()=>o(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===s?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:a.jsx("img",{src:ge.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&a.jsx(Sn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Yi(t){this.content=t}Yi.prototype={constructor:Yi,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Yi(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 Yi(n)},addToStart:function(t,e){return new Yi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Yi(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new Yi(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Yi.from(t),t.size?new Yi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Yi.from(t),t.size?new Yi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Yi.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Yi.from=function(t){if(t instanceof Yi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Yi(e)};function Wne(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=Wne(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Kne(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=Kne(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class Ft{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 Ft(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 Ft(r,i)}cutByIndex(e,n){return e==n?Ft.empty:e==0&&n==this.content.length?this:new Ft(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 Ft(i,s)}addToStart(e){return new Ft([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ft(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 Wne(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Kne(this,e,n,r)}findIndex(e){if(e==0)return j_(0,e);if(e==this.size)return j_(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?j_(n+1,s):j_(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 Ft.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ft(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ft.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 Ft(n||e,r)}static from(e){if(!e)return Ft.empty;if(e instanceof Ft)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Ft([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Ft.empty=new Ft([],0);const iE={index:0,offset:0};function j_(t,e){return iE.index=t,iE.offset=e,iE}function QN(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(!QN(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!QN(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Yr=class ER{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&&QN(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 ER.none;if(e instanceof ER)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Yr.none=[];class ZN extends Error{}class qt{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=Xne(this.content,e+this.openStart,n);return r&&new qt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new qt(Yne(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 qt.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 qt(Ft.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 qt(e,r,i)}}qt.empty=new qt(Ft.empty,0,0);function Yne(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(Yne(s.content,e-i-1,n-i-1)))}function Xne(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=Xne(o.content,e-s-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function b7e(t,e,n){if(n.openStart>t.depth)throw new ZN("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ZN("Inconsistent open depths");return Qne(t,e,n,0)}function Qne(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=Qne(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 Mf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=x7e(n,t);return Mf(s,Jne(t,o,l,e,r))}else return Mf(s,JN(t,e,r))}function Zne(t,e){if(!e.type.compatibleContent(t.type))throw new ZN("Cannot join "+e.type.name+" onto "+t.type.name)}function DR(t,e,n){let r=t.node(n);return Zne(r,e.node(n)),r}function Tf(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 a0(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&&(Tf(t.nodeAfter,r),s++));for(let l=s;l<o;l++)Tf(i.child(l),r);e&&e.depth==n&&e.textOffset&&Tf(e.nodeBefore,r)}function Mf(t,e){return t.type.checkContent(e),t.copy(e)}function Jne(t,e,n,r,i){let s=t.depth>i&&DR(t,e,i+1),o=r.depth>i&&DR(n,r,i+1),l=[];return a0(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(Zne(s,o),Tf(Mf(s,Jne(t,e,n,r,i+1)),l)):(s&&Tf(Mf(s,JN(t,e,i+1)),l),a0(e,n,i,l),o&&Tf(Mf(o,JN(n,r,i+1)),l)),a0(r,null,i,l),new Ft(l)}function JN(t,e,n){let r=[];if(a0(null,t,n,r),t.depth>n){let i=DR(t,e,n+1);Tf(Mf(i,JN(t,e,n+1)),r)}return a0(e,null,n,r),new Ft(r)}function x7e(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(Ft.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class ev{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 Yr.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 ek(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 ev(n,r,s)}static resolveCached(e,n){let r=AG.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 AG.set(e,r=new y7e);let i=r.elts[r.i]=ev.resolve(e,n);return r.i=(r.i+1)%v7e,i}}class y7e{constructor(){this.elts=[],this.i=0}}const v7e=12,AG=new WeakMap;class ek{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 w7e=Object.create(null);let Gh=class RR{constructor(e,n,r,i=Yr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||Ft.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&&QN(this.attrs,n||e.defaultAttrs||w7e)&&Yr.sameSet(this.marks,r||Yr.none)}copy(e=null){return e==this.content?this:new RR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new RR(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 qt.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 qt(u,i.depth-o,s.depth-o)}replace(e,n,r){return b7e(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 ev.resolveCached(this,e)}resolveNoCache(e){return ev.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()+")"),ere(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=Ft.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=Yr.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(!Yr.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=Ft.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Gh.prototype.text=void 0;class tk extends Gh{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):ere(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 tk(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new tk(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 ere(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class tp{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new S7e(e,n);if(r.next==null)return tp.empty;let i=tre(r);r.next&&r.err("Unexpected trailing text");let s=M7e(T7e(i));return P7e(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 Ft.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 f=s(h,l.concat(d));if(f)return f}}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(`
  8160. `)}}tp.empty=new tp(!0);class S7e{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 tre(t){let e=[];do e.push(_7e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function _7e(t){let e=[];do e.push(N7e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function N7e(t){let e=A7e(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=k7e(t,e);else break;return e}function TG(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function k7e(t,e){let n=TG(t),r=n;return t.eat(",")&&(t.next!="}"?r=TG(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function C7e(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 A7e(t){if(t.eat("(")){let e=tre(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=C7e(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 T7e(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 nre(t,e){return e-t}function MG(t,e){let n=[];return r(e),n.sort(nre);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 M7e(t){let e=Object.create(null);return n(MG(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]);MG(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let s=e[r.join(",")]=new tp(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(nre);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function P7e(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 rre(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 are(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 ire(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 sre(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new E7e(t,r,e[r]);return n}let PG=class ore{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=sre(e,r.attrs),this.defaultAttrs=rre(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==tp.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:are(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Gh(this,this.computeAttrs(e),Ft.from(n),Yr.setFrom(r))}createChecked(e=null,n,r){return n=Ft.from(n),this.checkContent(n),new Gh(this,this.computeAttrs(e),n,Yr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Ft.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(Ft.empty,!0);return s?new Gh(this,e,n.append(s),Yr.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){ire(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:Yr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new ore(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 j7e(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 E7e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?j7e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class bA{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=sre(e,i.attrs),this.excluded=null;let s=rre(this.attrs);this.instance=s?new Yr(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Yr(this,are(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new bA(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){ire(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class lre{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Yi.from(e.nodes),n.marks=Yi.from(e.marks||{}),this.nodes=PG.compile(this.spec.nodes,this),this.marks=bA.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]=tp.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?jG(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==""?[]:jG(this,o.split(" "))}this.nodeFromJSON=i=>Gh.fromJSON(this,i),this.markFromJSON=i=>Yr.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 PG){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 tk(r,r.defaultAttrs,e,Yr.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 jG(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 D7e(t){return t.tag!=null}function R7e(t){return t.style!=null}let i0=class FR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(D7e(i))this.tags.push(i);else if(R7e(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 DG(this,n,!1);return r.addAll(e,Yr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new DG(this,n,!0);return r.addAll(e,Yr.none,n.from,n.to),qt.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(O7e(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=RG(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=RG(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new FR(e,FR.schemaRules(e)))}};const cre={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},F7e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ure={ol:!0,ul:!0},tv=1,LR=2,s0=4;function EG(t,e,n){return e!=null?(e?tv:0)|(e==="full"?LR:0):t&&t.whitespace=="pre"?tv|LR:n&~s0}class E_{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=Yr.none,this.match=s||(o&s0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ft.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&tv)){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=Ft.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ft.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&&!cre.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class DG{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=EG(null,n.preserveWhitespace,0)|(r?s0:0);i?s=new E_(i.type,i.attrs,Yr.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new E_(null,null,Yr.none,!0,null,o):s=new E_(e.schema.topNodeType,null,Yr.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&LR?"full":this.localPreserveWS||(i.options&tv)>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,`
  8161. `);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;ure.hasOwnProperty(o)&&this.parser.normalizeLists&&L7e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:F7e.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(cre.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(`
  8162. `),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=Yr.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):FG(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=EG(e,s,o.options);o.options&s0&&o.content.length==0&&(l|=s0);let c=Yr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):FG(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new E_(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|=tv)}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 L7e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ure.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function O7e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function RG(t){let e={};for(let n in t)e[n]=t[n];return e}function FG(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 mp{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=sE(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}=f1(sE(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&&f1(sE(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return f1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new mp(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=LG(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return LG(e.marks)}}function LG(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function sE(t){return t.document||window.document}const OG=new WeakMap;function I7e(t){let e=OG.get(t);return e===void 0&&OG.set(t,e=z7e(t)),e}function z7e(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 f1(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=I7e(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 f=h.indexOf(" ");f>0?c.setAttributeNS(h.slice(0,f),h.slice(f+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 f=e[h];if(f===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:p,contentDOM:x}=f1(t,f,n,r);if(c.appendChild(p),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const dre=65535,hre=Math.pow(2,16);function U7e(t,e){return t+e*hre}function IG(t){return t&dre}function B7e(t){return(t-(t&dre))/hre}const mre=1,fre=2,p1=4,pre=8;class OR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&pre)>0}get deletedBefore(){return(this.delInfo&(mre|p1))>0}get deletedAfter(){return(this.delInfo&(fre|p1))>0}get deletedAcross(){return(this.delInfo&p1)>0}}class Po{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Po.empty)return Po.empty}recover(e){let n=0,r=IG(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+B7e(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 f=u?e==c?-1:e==h?1:n:n,p=c+i+(f<0?0:d);if(r)return p;let x=e==(n<0?c:h)?null:U7e(l/3,e-c),v=e==c?fre:e==h?mre:p1;return(n<0?e!=c:e!=h)&&(v|=pre),new OR(p,v,x)}i+=d-u}return r?e+i:new OR(e+i,0,null)}touches(e,n){let r=0,i=IG(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 Po(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Po.empty:new Po(e<0?[0,-e,0]:[0,0,e])}}Po.empty=new Po([]);class nv{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 nv(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 nv;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 OR(e,i,null)}}const oE=Object.create(null);class Ns{getMap(){return Po.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=oE[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 oE)throw new RangeError("Duplicate use of step JSON ID "+e);return oE[e]=n,n.prototype.jsonID=e,n}}class ai{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ai(e,null)}static fail(e){return new ai(null,e)}static fromReplace(e,n,r,i){try{return ai.ok(e.replace(n,r,i))}catch(s){if(s instanceof ZN)return ai.fail(s.message);throw s}}}function MO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(MO(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return Ft.fromArray(r)}class Ph extends Ns{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 qt(MO(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 ai.fromReplace(e,this.from,this.to,s)}invert(){return new Ql(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 Ph(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ph&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ph(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 Ph(n.from,n.to,e.markFromJSON(n.mark))}}Ns.jsonID("addMark",Ph);class Ql extends Ns{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 qt(MO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ai.fromReplace(e,this.from,this.to,r)}invert(){return new Ph(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 Ql(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ql&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ql(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 Ql(n.from,n.to,e.markFromJSON(n.mark))}}Ns.jsonID("removeMark",Ql);class jh extends Ns{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ai.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ai.fromReplace(e,this.pos,this.pos+1,new qt(Ft.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 jh(this.pos,n.marks[i]);return new jh(this.pos,this.mark)}}return new np(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new jh(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 jh(n.pos,e.markFromJSON(n.mark))}}Ns.jsonID("addNodeMark",jh);class np extends Ns{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ai.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ai.fromReplace(e,this.pos,this.pos+1,new qt(Ft.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new jh(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new np(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 np(n.pos,e.markFromJSON(n.mark))}}Ns.jsonID("removeNodeMark",np);class Di extends Ns{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&IR(e,this.from,this.to)?ai.fail("Structure replace would overwrite content"):ai.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Po([this.from,this.to-this.from,this.slice.size])}invert(e){return new Di(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 Di(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Di)||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?qt.empty:new qt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Di(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?qt.empty:new qt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Di(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 Di(n.from,n.to,qt.fromJSON(e,n.slice),!!n.structure)}}Ns.jsonID("replace",Di);class Fi extends Ns{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&&(IR(e,this.from,this.gapFrom)||IR(e,this.gapTo,this.to)))return ai.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ai.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ai.fromReplace(e,this.from,this.to,r):ai.fail("Content does not fit in gap")}getMap(){return new Po([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 Fi(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 Fi(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 Fi(n.from,n.to,n.gapFrom,n.gapTo,qt.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ns.jsonID("replaceAround",Fi);function IR(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 H7e(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 f=Math.max(u,e),p=Math.min(u+c.nodeSize,n),x=r.addToSet(h);for(let v=0;v<h.length;v++)h[v].isInSet(x)||(o&&o.to==f&&o.mark.eq(h[v])?o.to=p:i.push(o=new Ql(f,p,h[v])));l&&l.to==f?l.to=p:s.push(l=new Ph(f,p,r))}}),i.forEach(c=>t.step(c)),s.forEach(c=>t.step(c))}function $7e(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 bA){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],f;for(let p=0;p<i.length;p++){let x=i[p];x.step==s-1&&h.eq(i[p].style)&&(f=x)}f?(f.to=u,f.step=s):i.push({style:h,from:Math.max(l,e),to:u,step:s})}}}),i.forEach(o=>t.step(new Ql(o.from,o.to,o.style)))}function PO(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 Di(l,d,qt.empty));else{r=h;for(let f=0;f<u.marks.length;f++)n.allowsMarkType(u.marks[f].type)||t.step(new Ql(l,d,u.marks[f]));if(i&&u.isText&&n.whitespace!="pre"){let f,p=/\r?\n|\r/g,x;for(;f=p.exec(u.text);)x||(x=new qt(Ft.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new Di(l+f.index,l+f.index+f[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(Ft.empty,!0);t.replace(l,l,new qt(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function V7e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function bx(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||!V7e(o,l,c))break;l&&(i=1),c<o.childCount&&(s=1)}return null}function q7e(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=Ft.empty,h=0;for(let x=s,v=!1;x>n;x--)v||r.index(x)>0?(v=!0,d=Ft.from(r.node(x).copy(d)),h++):c--;let f=Ft.empty,p=0;for(let x=s,v=!1;x>n;x--)v||i.after(x+1)<i.end(x)?(v=!0,f=Ft.from(i.node(x).copy(f)),p++):u++;t.step(new Fi(c,u,o,l,new qt(d.append(f),h,p),d.size-h,!0))}function jO(t,e,n=null,r=t){let i=G7e(t,e),s=i&&W7e(r,e);return s?i.map(zG).concat({type:e,attrs:n}).concat(s.map(zG)):null}function zG(t){return{type:t,attrs:null}}function G7e(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 W7e(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 K7e(t,e,n){let r=Ft.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=Ft.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new Fi(i,s,i,s,new qt(r,0,0),n.length,!0))}function Y7e(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)&&X7e(t.doc,t.mapping.slice(s).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?u=!1:!p&&x&&(u=!0)}u===!1&&bre(t,o,l,s),PO(t,t.mapping.slice(s).map(l,1),r,void 0,u===null);let d=t.mapping.slice(s),h=d.map(l,1),f=d.map(l+o.nodeSize,1);return t.step(new Fi(h,f,h+1,f-1,new qt(Ft.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&gre(t,o,l,s),!1}})}function gre(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 bre(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(`
  8163. `))}})}function X7e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Q7e(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 Fi(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new qt(Ft.from(o),0,0),1,!0))}function Ju(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),f=i.index(u);if(h.type.spec.isolating)return!1;let p=h.content.cutByIndex(f,h.childCount),x=r&&r[d+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let v=r&&r[d]||h;if(!h.canReplace(f+1,h.childCount)||!v.type.validContent(p))return!1}let l=i.indexAfter(s),c=r&&r[0];return i.node(s).canReplaceWith(l,l,c?c.type:i.node(s+1).type)}function Z7e(t,e,n=1,r){let i=t.doc.resolve(e),s=Ft.empty,o=Ft.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){s=Ft.from(i.node(l).copy(s));let d=r&&r[u];o=Ft.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new Di(e,e,new qt(s.append(o),n,n),!0))}function hm(t,e){let n=t.resolve(e),r=n.index();return xre(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function J7e(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 xre(t,e){return!!(t&&e&&!t.isLeaf&&J7e(t,e))}function xA(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&&xre(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 eVe(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);bre(t,d.node(),d.before(),l)}o.inlineContent&&PO(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 Di(u,c.map(e+n,-1),qt.empty,!0)),r===!0){let d=t.doc.resolve(u);gre(t,d.node(),d.before(),t.steps.length)}return t}function tVe(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 yre(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 yA(t,e,n=e,r=qt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return vre(i,s,r)?new Di(e,n,r):new nVe(i,s,r).fit()}function vre(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class nVe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Ft.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=Ft.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 qt(s,o,l);return e>-1?new Fi(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Di(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=lE(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(Ft.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=lE(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new qt(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=lE(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new qt($y(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new qt($y(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 v=0;v<s.length;v++)this.openFrontierNode(s[v]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:h,type:f}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));h=h.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let v=l.child(u),g=h.matchType(v.type);if(!g)break;u++,(u>1||c==0||v.content.size)&&(h=g,d.push(wre(v.mark(f.allowedMarks(v.marks)),u==1?c:0,u==l.childCount?p:-1)))}let x=u==l.childCount;x||(p=-1),this.placed=Vy(this.placed,n,Ft.from(d)),this.frontier[n].match=h,x&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,g=l;v<p;v++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=x?e==0?qt.empty:new qt($y(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new qt($y(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||!cE(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=cE(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=cE(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=Vy(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=Vy(this.placed,this.depth,Ft.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ft.empty,!0);n.childCount&&(this.placed=Vy(this.placed,this.frontier.length,n))}}function $y(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy($y(t.firstChild.content,e-1,n)))}function Vy(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Vy(t.lastChild.content,e-1,n)))}function lE(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function wre(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,wre(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(Ft.empty,!0)))),t.copy(r)}function cE(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&&!rVe(n,s.content,o)?l:null}function rVe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function aVe(t){return t.spec.defining||t.spec.definingForContent}function iVe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(vre(i,s,r))return t.step(new Di(e,n,r));let o=_re(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,p=i.pos-1;f>0;f--,p--){let x=i.node(f).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==p&&o.splice(1,0,-f)}let c=o.indexOf(l),u=[],d=r.openStart;for(let f=r.content,p=0;;p++){let x=f.firstChild;if(u.push(x),p==r.openStart)break;f=x.content}for(let f=d-1;f>=0;f--){let p=u[f],x=aVe(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=f;else if(x||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+d+1)%(r.openStart+1),x=u[p];if(x)for(let v=0;v<o.length;v++){let g=o[(v+c)%o.length],y=!0;g<0&&(y=!1,g=-g);let _=i.node(g-1),N=i.index(g-1);if(_.canReplaceWith(N,N,x.type,x.marks))return t.replace(i.before(g),y?s.after(g):n,new qt(Sre(r.content,0,r.openStart,p),p,r.openEnd))}}let h=t.steps.length;for(let f=o.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>h));f--){let p=o[f];p<0||(e=i.before(p),n=s.after(p))}}function Sre(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(Sre(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(Ft.empty,!0))}return t}function sVe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=tVe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new qt(Ft.from(r),0,0))}function oVe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=_re(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 _re(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 mb extends Ns{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 ai.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 ai.fromReplace(e,this.pos,this.pos+1,new qt(Ft.from(i),0,n.isLeaf?0:1))}getMap(){return Po.empty}invert(e){return new mb(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 mb(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 mb(n.pos,n.attr,n.value)}}Ns.jsonID("attr",mb);class rv extends Ns{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 ai.ok(r)}getMap(){return Po.empty}invert(e){return new rv(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 rv(n.attr,n.value)}}Ns.jsonID("docAttr",rv);let zb=class extends Error{};zb=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};zb.prototype=Object.create(Error.prototype);zb.prototype.constructor=zb;zb.prototype.name="TransformError";class Nre{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nv}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new zb(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}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((s,o,l,c)=>{e=Math.min(e,l),n=Math.max(n,c)})}return e==1e9?null:{from:e,to:n}}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=qt.empty){let i=yA(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new qt(Ft.from(r),0,0))}delete(e,n){return this.replace(e,n,qt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return iVe(this,e,n,r),this}replaceRangeWith(e,n,r){return sVe(this,e,n,r),this}deleteRange(e,n){return oVe(this,e,n),this}lift(e,n){return q7e(this,e,n),this}join(e,n=1){return eVe(this,e,n),this}wrap(e,n){return K7e(this,e,n),this}setBlockType(e,n=e,r,i=null){return Y7e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Q7e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new mb(e,n,r)),this}setDocAttribute(e,n){return this.step(new rv(e,n)),this}addNodeMark(e,n){return this.step(new jh(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 Yr)n.isInSet(r.marks)&&this.step(new np(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new np(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 Z7e(this,e,n,r),this}addMark(e,n,r){return H7e(this,e,n,r),this}removeMark(e,n,r){return $7e(this,e,n,r),this}clearIncompatible(e,n,r){return PO(this,e,n,r),this}}const uE=Object.create(null);class Gn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new lVe(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=qt.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?qt.empty:n),l==0&&HG(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),HG(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new An(e):$g(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?$g(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):$g(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 Lo(e.node(0))}static atStart(e){return $g(e,e,0,0,1)||new Lo(e)}static atEnd(e){return $g(e,e,e.content.size,e.childCount,-1)||new Lo(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=uE[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 uE)throw new RangeError("Duplicate use of selection JSON ID "+e);return uE[e]=n,n.prototype.jsonID=e,n}getBookmark(){return An.between(this.$anchor,this.$head).getBookmark()}}Gn.prototype.visible=!0;class lVe{constructor(e,n){this.$from=e,this.$to=n}}let UG=!1;function BG(t){!UG&&!t.parent.inlineContent&&(UG=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class An extends Gn{constructor(e,n=e){BG(e),BG(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 Gn.near(r);let i=e.resolve(n.map(this.anchor));return new An(i.parent.inlineContent?i:r,r)}replace(e,n=qt.empty){if(super.replace(e,n),n==qt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof An&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new vA(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 An(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=Gn.findFrom(n,r,!0)||Gn.findFrom(n,-r,!0);if(s)n=s.$head;else return Gn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Gn.findFrom(e,-r,!0)||Gn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new An(e,n)}}Gn.jsonID("text",An);class vA{constructor(e,n){this.anchor=e,this.head=n}map(e){return new vA(e.map(this.anchor),e.map(this.head))}resolve(e){return An.between(e.resolve(this.anchor),e.resolve(this.head))}}class un extends Gn{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?Gn.near(s):new un(s)}content(){return new qt(Ft.from(this.node),0,0)}eq(e){return e instanceof un&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new EO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new un(e.resolve(n.anchor))}static create(e,n){return new un(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}un.prototype.visible=!1;Gn.jsonID("node",un);class EO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new vA(r,r):new EO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&un.isSelectable(r)?new un(n):Gn.near(n)}}class Lo extends Gn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=qt.empty){if(n==qt.empty){e.delete(0,e.doc.content.size);let r=Gn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Lo(e)}map(e){return new Lo(e)}eq(e){return e instanceof Lo}getBookmark(){return cVe}}Gn.jsonID("all",Lo);const cVe={map(){return this},resolve(t){return new Lo(t)}};function $g(t,e,n,r,i,s=!1){if(e.inlineContent)return An.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&&un.isSelectable(l))return un.create(t,n-(i<0?l.nodeSize:0))}else{let c=$g(t,l,n+i,i<0?l.childCount:0,i,s);if(c)return c}n+=l.nodeSize*i}return null}function HG(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Di||i instanceof Fi))return;let s=t.mapping.maps[r],o;s.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(Gn.near(t.doc.resolve(o),n))}const $G=1,D_=2,VG=4;class uVe extends Nre{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|$G)&~D_,this.storedMarks=null,this}get selectionSet(){return(this.updated&$G)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=D_,this}ensureMarks(e){return Yr.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&D_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~D_,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)||Yr.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(Gn.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|=VG,this}get scrolledIntoView(){return(this.updated&VG)>0}}function qG(t,e){return!e||!t?t:t.bind(e)}class qy{constructor(e,n,r){this.name=e,this.init=qG(n.init,r),this.apply=qG(n.apply,r)}}const dVe=[new qy("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new qy("selection",{init(t,e){return t.selection||Gn.atStart(e.doc)},apply(t){return t.selection}}),new qy("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new qy("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class dE{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=dVe.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 qy(r.key,r.spec.state,r))})}}class Jg{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 Jg(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 uVe(this)}static create(e){let n=new dE(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Jg(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 dE(this.schema,e.plugins),r=n.fields,i=new Jg(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 dE(e.schema,e.plugins),s=new Jg(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Gh.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=Gn.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 kre(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=kre(i,e,{})),n[r]=i}return n}class ka{constructor(e){this.spec=e,this.props={},e.props&&kre(e.props,this,this.props),this.key=e.key?e.key.key:Cre("plugin")}getState(e){return e[this.key]}}const hE=Object.create(null);function Cre(t){return t in hE?t+"$"+ ++hE[t]:(hE[t]=0,t+"$")}class Ni{constructor(e="key"){this.key=Cre(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const DO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Are(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Tre=(t,e,n)=>{let r=Are(t,n);if(!r)return!1;let i=RO(r);if(!i){let o=r.blockRange(),l=o&&bx(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Ore(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Ub(s,"end")||un.isSelectable(s)))for(let o=r.depth;;o--){let l=yA(t.doc,r.before(o),r.after(o),qt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Ub(s,"end")?Gn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):un.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},hVe=(t,e,n)=>{let r=Are(t,n);if(!r)return!1;let i=RO(r);return i?Mre(t,i,e):!1},mVe=(t,e,n)=>{let r=jre(t,n);if(!r)return!1;let i=FO(r);return i?Mre(t,i,e):!1};function Mre(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=yA(t.doc,s,c,qt.empty);if(!u||u.from!=s||u instanceof Di&&u.slice.size>=c-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(An.create(d.doc,s)),n(d.scrollIntoView())}return!0}function Ub(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 Pre=(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=RO(r)}let o=s&&s.nodeBefore;return!o||!un.isSelectable(o)?!1:(e&&e(t.tr.setSelection(un.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function RO(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 jre(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Ere=(t,e,n)=>{let r=jre(t,n);if(!r)return!1;let i=FO(r);if(!i)return!1;let s=i.nodeAfter;if(Ore(t,i,e,1))return!0;if(r.parent.content.size==0&&(Ub(s,"start")||un.isSelectable(s))){let o=yA(t.doc,r.before(),r.after(),qt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ub(s,"start")?Gn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):un.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},Dre=(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=FO(r)}let o=s&&s.nodeAfter;return!o||!un.isSelectable(o)?!1:(e&&e(t.tr.setSelection(un.create(t.doc,s.pos)).scrollIntoView()),!0)};function FO(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 fVe=(t,e)=>{let n=t.selection,r=n instanceof un,i;if(r){if(n.node.isTextblock||!hm(t.doc,n.from))return!1;i=n.from}else if(i=xA(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(un.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},pVe=(t,e)=>{let n=t.selection,r;if(n instanceof un){if(n.node.isTextblock||!hm(t.doc,n.to))return!1;r=n.to}else if(r=xA(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},gVe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&bx(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},Rre=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8164. `).scrollIntoView()),!0)};function LO(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 bVe=(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=LO(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(Gn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},Fre=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Lo||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=LO(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(An.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Lre=(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(Ju(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&bx(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function xVe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof un&&e.selection.node.isBlock)return!r.parentOffset||!Ju(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,c=!1,u=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),l=LO(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),s.unshift(c&&l?{type:l}:null),o=p;break}else{if(p==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof An||e.selection instanceof Lo)&&d.deleteSelection();let h=d.mapping.map(r.pos),f=Ju(d.doc,h,s.length,s);if(f||(s[0]=l?{type:l}:null,f=Ju(d.doc,h,s.length,s)),!f)return!1;if(d.split(h,s.length,s),!c&&u&&r.node(o).type!=l){let p=d.mapping.map(r.before(o)),x=d.doc.resolve(p);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const yVe=xVe(),vVe=(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(un.create(t.doc,i))),!0)};function wVe(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||hm(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Ore(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,c=i.type.spec.isolating||s.type.spec.isolating;if(!c&&wVe(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(n){let p=e.pos+s.nodeSize,x=Ft.empty;for(let y=o.length-1;y>=0;y--)x=Ft.from(o[y].create(null,x));x=Ft.from(i.copy(x));let v=t.tr.step(new Fi(e.pos-1,p,e.pos,p,new qt(x,1,0),o.length,!0)),g=v.doc.resolve(p+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&hm(v.doc,g.pos)&&v.join(g.pos),n(v.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&c?null:Gn.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),f=h&&bx(h);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(h,f).scrollIntoView()),!0;if(u&&Ub(s,"start",!0)&&Ub(i,"end")){let p=i,x=[];for(;x.push(p),!p.isTextblock;)p=p.lastChild;let v=s,g=1;for(;!v.isTextblock;v=v.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(n){let y=Ft.empty;for(let N=x.length-1;N>=0;N--)y=Ft.from(x[N].copy(y));let _=t.tr.step(new Fi(e.pos-x.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new qt(y,x.length,0),0,!0));n(_.scrollIntoView())}return!0}}return!1}function Ire(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(An.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const SVe=Ire(-1),_Ve=Ire(1);function NVe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&jO(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function GG(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 OO(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}OO(DO,Tre,Pre);OO(DO,Ere,Dre);OO(Rre,Fre,Lre,yVe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function kVe(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 CVe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function CVe(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 ek(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new ek(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=jO(s,n,r,e);return l?(t&&AVe(t,e,l,i,n),!0):!1}function AVe(t,e,n,r,i){let s=Ft.empty;for(let d=n.length-1;d>=0;d--)s=Ft.from(n[d].type.create(n[d].attrs,s));t.step(new Fi(e.start-(r?2:0),e.end,e.start,e.end,new qt(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,f=!0;d<h;d++,f=!1)!f&&Ju(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function TVe(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?MVe(e,n,t,s):PVe(e,n,s):!0:!1}}function MVe(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Fi(s-1,o,s,o,new qt(Ft.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ek(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=bx(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(s,-1)-1);return hm(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function PVe(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,x=n.endIndex-1,v=n.startIndex;x>v;x--)p-=i.child(x).nodeSize,r.delete(p-1,p+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=s.node(-1),d=s.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?Ft.empty:Ft.from(i))))return!1;let h=s.pos,f=h+o.nodeSize;return r.step(new Fi(h-(l?1:0),f+(c?1:0),h+1,f-1,new qt((l?Ft.empty:Ft.from(i.copy(Ft.empty))).append(c?Ft.empty:Ft.from(i.copy(Ft.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function jVe(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=Ft.from(u?t.create():null),h=new qt(Ft.from(t.create(null,Ft.from(l.type.create(null,d)))),u?3:1,0),f=s.start,p=s.end;n(e.tr.step(new Fi(f-(u?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0}}const es=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 zR=null;const Ru=function(t,e,n){let r=zR||(zR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},EVe=function(){zR=null},rp=function(t,e,n,r){return n&&(WG(t,e,n,r,-1)||WG(t,e,n,r,1))},DVe=/^(img|br|input|textarea|hr)$/i;function WG(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:fl(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Yv(t)||DVe.test(t.nodeName)||t.contentEditable=="false")return!1;e=es(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?fl(t):0}else return!1}}function fl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function RVe(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=fl(t)}else if(t.parentNode&&!Yv(t))e=es(t),t=t.parentNode;else return null}}function FVe(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&&!Yv(t))e=es(t)+1,t=t.parentNode;else return null}}function LVe(t,e,n){for(let r=e==0,i=e==fl(t);r||i;){if(t==n)return!0;let s=es(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==fl(t)}}function Yv(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 wA=function(t){return t.focusNode&&rp(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function nf(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function OVe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function IVe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(fl(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(fl(r.startContainer),r.startOffset)}}}const Vc=typeof navigator<"u"?navigator:null,KG=typeof document<"u"?document:null,mm=Vc&&Vc.userAgent||"",UR=/Edge\/(\d+)/.exec(mm),zre=/MSIE \d/.exec(mm),BR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mm),oo=!!(zre||BR||UR),Wh=zre?document.documentMode:BR?+BR[1]:UR?+UR[1]:0,yl=!oo&&/gecko\/(\d+)/i.test(mm);yl&&+(/Firefox\/(\d+)/.exec(mm)||[0,0])[1];const HR=!oo&&/Chrome\/(\d+)/.exec(mm),ns=!!HR,Ure=HR?+HR[1]:0,ws=!oo&&!!Vc&&/Apple Computer/.test(Vc.vendor),Hb=ws&&(/Mobile\/\w+/.test(mm)||!!Vc&&Vc.maxTouchPoints>2),ol=Hb||(Vc?/Mac/.test(Vc.platform):!1),Bre=Vc?/Win/.test(Vc.platform):!1,qu=/Android \d/.test(mm),Xv=!!KG&&"webkitFontSmoothing"in KG.documentElement.style,zVe=Xv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function UVe(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 Au(t,e){return typeof t=="number"?t:t[e]}function BVe(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 YG(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?UVe(s):BVe(l),d=0,h=0;if(e.top<u.top+Au(r,"top")?h=-(u.top-e.top+Au(i,"top")):e.bottom>u.bottom-Au(r,"bottom")&&(h=e.bottom-e.top>u.bottom-u.top?e.top+Au(i,"top")-u.top:e.bottom-u.bottom+Au(i,"bottom")),e.left<u.left+Au(r,"left")?d=-(u.left-e.left+Au(i,"left")):e.right>u.right-Au(r,"right")&&(d=e.right-u.right+Au(i,"right")),d||h)if(c)s.defaultView.scrollBy(d,h);else{let p=l.scrollLeft,x=l.scrollTop;h&&(l.scrollTop+=h),d&&(l.scrollLeft+=d);let v=l.scrollLeft-p,g=l.scrollTop-x;e={left:e.left-v,top:e.top-g,right:e.right-v,bottom:e.bottom-g}}let f=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Bb(o)}}function HVe(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:Hre(t.dom)}}function Hre(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 $Ve({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;$re(n,r==0?0:r-e)}function $re(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 Dg=null;function VVe(t){if(t.setActive)return t.setActive();if(Dg)return t.focus(Dg);let e=Hre(t);t.focus(Dg==null?{get preventScroll(){return Dg={preventScroll:!0},!0}}:void 0),Dg||(Dg=!1,$re(e,0))}function Vre(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 f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=Ru(d).getClientRects();else continue;for(let p=0;p<f.length;p++){let x=f[p];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let v=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&v&&(s=h+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(s=h+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?qVe(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:Vre(n,i)}function qVe(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let o=oh(r,1);if(o.top!=o.bottom&&IO(e,o)){i={node:t,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function IO(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function GVe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function WVe(t,e,n){let{node:r,offset:i}=Vre(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 KVe(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 qre(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(IO(e,u))return qre(o,e,u)}}if((s=(s+1)%r)==i)break}return t}function YVe(t,e){let n=t.dom.ownerDocument,r,i=0,s=IVe(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(!IO(e,u)||(o=qre(t.dom,e,u),!o))return null}if(ws)for(let u=o;r&&u;u=Bb(u))u.draggable&&(r=void 0);if(o=GVe(o,e),r){if(yl&&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;Xv&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=KVe(t,r,i,e))}l==null&&(l=WVe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function XG(t){return t.top<t.bottom||t.left<t.right}function oh(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(XG(r))return r}return Array.prototype.find.call(n,XG)||t.getBoundingClientRect()}const XVe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Gre(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Xv||yl;if(r.nodeType==3)if(o&&(XVe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=oh(Ru(r,i,i),n);if(yl&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=oh(Ru(r,i-1,i-1),-1);if(u.top==c.top){let d=oh(Ru(r,i,i+1),-1);if(d.top!=c.top)return Ey(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++,Ey(oh(Ru(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==fl(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return mE(c.getBoundingClientRect(),!1)}if(s==null&&i<fl(r)){let c=r.childNodes[i];if(c.nodeType==1)return mE(c.getBoundingClientRect(),!0)}return mE(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==fl(r))){let c=r.childNodes[i-1],u=c.nodeType==3?Ru(c,fl(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Ey(oh(u,1),!1)}if(s==null&&i<fl(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?Ru(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return Ey(oh(u,-1),!0)}return Ey(oh(r.nodeType==3?Ru(r):r,-n),n>=0)}function Ey(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 mE(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 Wre(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 QVe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Wre(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=Gre(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=Ru(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 ZVe=/[\u0590-\u08ac]/;function JVe(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?!ZVe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:Wre(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:h}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:v}=t.domSelectionRange(),g=x&&!p.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==v;try{l.collapse(d,h),c&&(c!=d||u!=h)&&l.extend&&l.extend(c,u)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let QG=null,ZG=null,JG=!1;function eqe(t,e,n){return QG==e&&ZG==n?JG:(QG=e,ZG=n,JG=n=="up"||n=="down"?QVe(t,e,n):JVe(t,e,n))}const vl=0,eW=1,pf=2,qc=3;class Qv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=vl,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>es(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 Yre){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 Kre&&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?es(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?es(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 f=this.children[h-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=es(f.dom)+1;break}e-=f.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=es(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 p=0,x=0;p<this.children.length;p++){let v=this.children[p],g=x+v.size;if(s>x&&o<g)return v.setSelection(e-x-v.border,n-x-v.border,r,i);x=g}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((yl||ws)&&e==n){let{node:p,offset:x}=l;if(p.nodeType==3){if(h=!!(x&&p.nodeValue[x-1]==`
  8165. `),h&&x==p.nodeValue.length)for(let v=p,g;v;v=v.parentNode){if(g=v.nextSibling){g.nodeName=="BR"&&(l=c={node:g.parentNode,offset:es(g)+1});break}let y=v.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let v=p.childNodes[x-1];h=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(yl&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||h&&ws)&&rp(l.node,l.offset,d.anchorNode,d.anchorOffset)&&rp(c.node,c.offset,d.focusNode,d.focusOffset))return;let f=!1;if((u.extend||e==n)&&!(h&&yl)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),f=!0}catch{}}if(!f){if(e>n){let x=l;l=c,c=x}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,c=o-s.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?pf:eW,e==l&&n==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=qc:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?pf:qc}r=o}this.dirty=pf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?pf:eW;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Kre extends Qv{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==vl&&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 tqe extends Qv{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 ap extends Qv{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=mp.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new ap(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&qc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=qc&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=vl){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=vl}}slice(e,n,r){let i=ap.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=VR(s,n,o,r)),e>0&&(s=VR(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 Kh extends Qv{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}=mp.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 f=d;return d=Zre(d,r,n),u?c=new nqe(e,n,r,i,d,h||null,f,u,s,o+1):n.isText?new SA(e,n,r,i,d,f,s):new Kh(e,n,r,i,d,h||null,f,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=()=>Ft.empty)}return e}matchesNode(e,n,r){return this.dirty==vl&&e.eq(this.node)&&nk(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 aqe(this,o&&o.node,e);oqe(this.node,this.innerDeco,(u,d,h)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e,d):u.type.side>=0&&!h&&c.syncToMarks(d==this.node.childCount?Yr.none:this.node.child(d).marks,r,e,d),c.placeWidget(u,e,i)},(u,d,h,f)=>{c.syncToMarks(u.marks,r,e,f);let p;c.findNodeMatch(u,d,h,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(u,d,h,p,e)||c.updateNextNode(u,d,h,e,f,i)||c.addNode(u,d,h,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==pf)&&(o&&this.protectLocalComposition(e,o),Xre(this.contentDOM,this.children,e),Hb&&lqe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof An)||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=cqe(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 tqe(this,s,n,i);e.input.compositionNodes.push(o),this.children=VR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==qc||!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=vl}updateOuterDeco(e){if(nk(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Qre(this.dom,this.nodeDOM,$R(this.outerDeco,this.node,n),$R(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 tW(t,e,n,r,i){Zre(r,e,t);let s=new Kh(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class SA extends Kh{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==qc||this.dirty!=vl&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=vl||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=vl,!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 SA(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=qc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Yre extends Qv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==vl&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class nqe extends Kh{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==qc)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 Xre(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=nW(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof ap){let c=r?r.previousSibling:t.lastChild;Xre(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=nW(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const o0=function(t){t&&(this.nodeName=t)};o0.prototype=Object.create(null);const gf=[new o0];function $R(t,e,n){if(t.length==0)return gf;let r=n?gf[0]:new o0,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new o0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new o0(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 Qre(t,e,n,r){if(n==gf&&r==gf)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=gf[0]),i=c}rqe(i,l||gf[0],o)}return i}function rqe(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 Zre(t,e,n){return Qre(t,t,gf,$R(e,n,t.nodeType!=1))}function nk(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 nW(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class aqe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=iqe(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,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=vl,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let c=-1,u=this.top.children.length;i<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let d=this.index;d<u;d++){let h=this.top.children[d];if(h.matchesMark(e[o])&&!this.isLocked(h.dom)){c=d;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let d=ap.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}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==qc&&o.dom==o.contentDOM&&(o.dirty=pf),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 Kh){let u=this.preMatch.matched.get(c);if(u!=null&&u!=s)return!1;let d=c.dom,h,f=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=qc&&nk(n,c.outerDeco));if(!f&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(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=pf,h.updateChildren(i,o+1),h.dirty=vl),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)||!nk(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Kh.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=Kh.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 Kre(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 ap;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof SA)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ws||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 Yre(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 iqe(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 ap)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 sqe(t,e){return t.type.side-e.type.side}function oqe(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 g=i[o++];g.widget&&(d?(h||(h=[d])).push(g):d=g)}if(d)if(h){h.sort(sqe);for(let g=0;g<h.length;g++)n(h[g],u,!!c)}else n(d,u,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(u<t.childCount)p=u,f=t.child(u++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let x=s+f.nodeSize;if(f.isText){let g=x;o<i.length&&i[o].from<g&&(g=i[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<x&&(c=f.cut(g-s),f=f.cut(0,g-s),x=g,p=-1)}else for(;o<i.length&&i[o].to<x;)o++;let v=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,v,e.forChild(s,f),p),s=x}}function lqe(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 cqe(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 VR(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 zO(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(wA(n)){for(c=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&un.isSelectable(h)&&i.parent&&!(h.isInline&&LVe(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;u=new un(o==f?l:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=o,f=o;for(let p=0;p<n.rangeCount;p++){let x=n.getRangeAt(p);h=Math.min(h,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(h<0)return null;[c,o]=f==t.state.selection.anchor?[f,h]:[h,f],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=UO(t,d,l,h)}return u}function Jre(t){return t.editable?t.hasFocus():tae(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ed(t,e=!1){let n=t.state.selection;if(eae(t,n),!!Jre(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ns){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&rp(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)dqe(t);else{let{anchor:r,head:i}=n,s,o;rW&&!(n instanceof An)&&(n.$from.parent.inlineContent||(s=aW(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=aW(t,n.to))),t.docView.setSelection(r,i,t,e),rW&&(s&&iW(s),o&&iW(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&uqe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const rW=ws||ns&&Ure<63;function aW(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(ws&&i&&i.contentEditable=="false")return fE(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return fE(i);if(s)return fE(s)}}function fE(t){return t.contentEditable="true",ws&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function iW(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function uqe(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(()=>{(!Jre(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function dqe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,es(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&oo&&Wh<=11&&(n.disabled=!0,n.disabled=!1)}function eae(t,e){if(e instanceof un){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(sW(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else sW(t)}function sW(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function UO(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||An.between(e,n,r)}function oW(t){return t.editable&&!t.hasFocus()?!1:tae(t)}function tae(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 hqe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return rp(e.node,e.offset,n.anchorNode,n.anchorOffset)}function qR(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&&Gn.findFrom(s,e)}function hh(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function lW(t,e,n){let r=t.state.selection;if(r instanceof An)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 hh(t,new An(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=qR(t.state,e);return i&&i instanceof un?hh(t,i):!1}else if(!(ol&&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?un.isSelectable(s)?hh(t,new un(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Xv?hh(t,new An(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof un&&r.node.isInline)return hh(t,new An(e>0?r.$to:r.$from));{let i=qR(t.state,e);return i?hh(t,i):!1}}}function rk(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function l0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Rg(t,e){return e<0?mqe(t):fqe(t)}function mqe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(yl&&n.nodeType==1&&r<rk(n)&&l0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(l0(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(nae(n))break;{let l=n.previousSibling;for(;l&&l0(l,-1);)i=n.parentNode,s=es(l),l=l.previousSibling;if(l)n=l,r=rk(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?GR(t,n,r):i&&GR(t,i,s)}function fqe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=rk(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(l0(l,1))s=n,o=++r;else break}else{if(nae(n))break;{let l=n.nextSibling;for(;l&&l0(l,1);)s=l.parentNode,o=es(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=rk(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&GR(t,s,o)}function nae(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function pqe(t,e){for(;t&&e==t.childNodes.length&&!Yv(t);)e=es(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 gqe(t,e){for(;t&&!e&&!Yv(t);)e=es(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 GR(t,e,n){if(e.nodeType!=3){let s,o;(o=pqe(e,n))?(e=o,n=0):(s=gqe(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(wA(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&&ed(t)},50)}function cW(t,e){let n=t.state.doc.resolve(e);if(!(ns||Bre)&&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 uW(t,e,n){let r=t.state.selection;if(r instanceof An&&!r.empty||n.indexOf("s")>-1||ol&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=qR(t.state,e);if(o&&o instanceof un)return hh(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Lo?Gn.near(o,e):Gn.findFrom(o,e);return l?hh(t,l):!1}return!1}function dW(t,e){if(!(t.state.selection instanceof An))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 hW(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function bqe(t){if(!ws||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;hW(t,r,"true"),setTimeout(()=>hW(t,r,"false"),20)}return!1}function xqe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function yqe(t,e){let n=e.keyCode,r=xqe(e);if(n==8||ol&&n==72&&r=="c")return dW(t,-1)||Rg(t,-1);if(n==46&&!e.shiftKey||ol&&n==68&&r=="c")return dW(t,1)||Rg(t,1);if(n==13||n==27)return!0;if(n==37||ol&&n==66&&r=="c"){let i=n==37?cW(t,t.state.selection.from)=="ltr"?-1:1:-1;return lW(t,i,r)||Rg(t,i)}else if(n==39||ol&&n==70&&r=="c"){let i=n==39?cW(t,t.state.selection.from)=="ltr"?1:-1:1;return lW(t,i,r)||Rg(t,i)}else{if(n==38||ol&&n==80&&r=="c")return uW(t,-1,r)||Rg(t,-1);if(n==40||ol&&n==78&&r=="c")return bqe(t)||uW(t,1,r)||Rg(t,1);if(r==(ol?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function BO(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=t.someProp("clipboardSerializer")||mp.fromSchema(t.state.schema),l=lae(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,h=0;for(;u&&u.nodeType==1&&(d=oae[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let x=l.createElement(d[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),h++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
  8166. `);return{dom:c,text:f,slice:e}}function rae(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",f=>{e=f(e,s||r,t)}),s)return l=new qt(Ft.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8167. `))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let h=t.someProp("clipboardTextParser",f=>f(e,i,r,t));if(h)l=h;else{let f=i.marks(),{schema:p}=t.state,x=mp.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let g=o.appendChild(document.createElement("p"));v&&g.appendChild(x.serializeNode(p.text(v,f)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),o=_qe(n),Xv&&Nqe(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 f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||i0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!vqe.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=kqe(mW(l,+d[1],+d[2]),d[4]);else if(l=qt.maxOpen(wqe(l.content,i),!0),l.openStart||l.openEnd){let h=0,f=0;for(let p=l.content.firstChild;h<l.openStart&&!p.type.spec.isolating;h++,p=p.firstChild);for(let p=l.content.lastChild;f<l.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);l=mW(l,h,f)}return t.someProp("transformPasted",h=>{l=h(l,t,c)}),l}const vqe=/^(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 wqe(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&&iae(c,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=sae(o[o.length-1],s.length));let d=aae(l,c);o.push(d),i=i.matchType(d.type),s=c}}),o)return Ft.from(o)}return t}function aae(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ft.from(t));return t}function iae(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=iae(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(Ft.from(aae(n,t,i+1))))}}function sae(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,sae(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Ft.empty,!0);return t.copy(n.append(r))}function WR(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=WR(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(Ft.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function mW(t,e,n){return e<t.openStart&&(t=new qt(WR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new qt(WR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const oae={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 fW=null;function lae(){return fW||(fW=document.implementation.createHTMLDocument("title"))}let pE=null;function Sqe(t){let e=window.trustedTypes;return e?(pE||(pE=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),pE.createHTML(t)):t}function _qe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=lae().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&oae[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=Sqe(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function Nqe(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 kqe(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=Ft.from(c.create(r[l+1],i)),s++,o++}return new qt(i,s,o)}const Us={},Bs={},Cqe={touchstart:!0,touchmove:!0};class Aqe{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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Tqe(t){for(let e in Us){let n=Us[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Pqe(t,r)&&!HO(t,r)&&(t.editable||!(r.type in Bs))&&n(t,r)},Cqe[e]?{passive:!0}:void 0)}ws&&t.dom.addEventListener("input",()=>null),KR(t)}function Eh(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Mqe(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 KR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>HO(t,r))})}function HO(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Pqe(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 jqe(t,e){!HO(t,e)&&Us[e.type]&&(t.editable||!(e.type in Bs))&&Us[e.type](t,e)}Bs.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!uae(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(qu&&ns&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Hb&&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,nf(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||yqe(t,n)?n.preventDefault():Eh(t,"key")};Bs.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Bs.keypress=(t,e)=>{let n=e;if(uae(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ol&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof An)||!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 _A(t){return{left:t.clientX,top:t.clientY}}function Eqe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function $O(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 fb(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 Dqe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&un.isSelectable(r)?(fb(t,new un(n)),!0):!1}function Rqe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof un&&(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(un.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?(fb(t,un.create(t.state.doc,i)),!0):!1}function Fqe(t,e,n,r,i){return $O(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?Rqe(t,n):Dqe(t,n))}function Lqe(t,e,n,r){return $O(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function Oqe(t,e,n,r){return $O(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||Iqe(t,n,r)}function Iqe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(fb(t,An.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)fb(t,An.create(r,l+1,l+1+o.content.size));else if(un.isSelectable(o))fb(t,un.create(r,l));else continue;return!0}}function VO(t){return ak(t)}const cae=ol?"metaKey":"ctrlKey";Us.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=VO(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&Eqe(n,t.input.lastClick)&&!n[cae]&&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(_A(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new zqe(t,o,n,!!r)):(s=="doubleClick"?Lqe:Oqe)(t,o.pos,o.inside,n)?n.preventDefault():Eh(t,"pointer"))};class zqe{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[cae],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 un&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&yl&&!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)),Eh(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(()=>ed(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(_A(e))),this.updateAllowDefault(e),this.allowDefault||!n?Eh(this.view,"pointer"):Fqe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ws&&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)?(fb(this.view,Gn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Eh(this.view,"pointer")}move(e){this.updateAllowDefault(e),Eh(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)}}Us.touchstart=t=>{t.input.lastTouch=Date.now(),VO(t),Eh(t,"pointer")};Us.touchmove=t=>{t.input.lastTouch=Date.now(),Eh(t,"pointer")};Us.contextmenu=t=>VO(t);function uae(t,e){return t.composing?!0:ws&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Uqe=qu?5e3:-1;Bs.compositionstart=Bs.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof An&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ns&&Bre&&Bqe(t)))t.markCursor=t.state.storedMarks||n.marks(),ak(t,!0),t.markCursor=null;else if(ak(t,!e.selection.empty),yl&&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}dae(t,Uqe)};function Bqe(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Bs.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.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,dae(t,20))};function dae(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ak(t),e))}function hae(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=$qe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Hqe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=RVe(e.focusNode,e.focusOffset),r=FVe(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 $qe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ak(t,e=!1){if(!(qu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),hae(t),e||t.docView&&t.docView.dirty){let n=zO(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 Vqe(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 av=oo&&Wh<15||Hb&&zVe<604;Us.copy=Bs.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=av?null:n.clipboardData,o=r.content(),{dom:l,text:c}=BO(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):Vqe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function qqe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Gqe(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?iv(t,r.value,null,i,e):iv(t,r.textContent,r.innerHTML,i,e)},50)}function iv(t,e,n,r,i){let s=rae(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,s||qt.empty)))return!0;if(!s)return!1;let o=qqe(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 mae(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," "):""}Bs.paste=(t,e)=>{let n=e;if(t.composing&&!qu)return;let r=av?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&iv(t,mae(r),r.getData("text/html"),i,n)?n.preventDefault():Gqe(t,n)};class fae{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Wqe=ol?"altKey":"ctrlKey";function pae(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Wqe]}Us.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(_A(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof un?i.to-1:i.to))){if(r&&r.mightDrag)o=un.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=un.create(t.state.doc,h.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=BO(t,l);(!n.dataTransfer.files.length||!ns||Ure>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(av?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",av||n.dataTransfer.setData("text/plain",u),t.dragging=new fae(d,pae(t,n),o)};Us.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Bs.dragover=Bs.dragenter=(t,e)=>e.preventDefault();Bs.drop=(t,e)=>{try{Kqe(t,e,t.dragging)}finally{t.dragging=null}};function Kqe(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(_A(e));if(!r)return;let i=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",p=>{s=p(s,t,!1)}):s=rae(t,mae(e.dataTransfer),av?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&pae(t,e));if(t.someProp("handleDrop",p=>p(t,e,s||qt.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?yre(t.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let c=t.state.tr;if(o){let{node:p}=n;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(l),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(h))return;let f=c.doc.resolve(u);if(d&&un.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new un(f));else{let p=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((x,v,g,y)=>p=y),c.setSelection(UO(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}Us.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())&&ed(t)},20))};Us.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)};Us.beforeinput=(t,e)=>{if(ns&&qu&&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,nf(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 Bs)Us[t]=Bs[t];function sv(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 ik{constructor(e,n){this.toDOM=e,this.spec=n||Pf,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 Rs(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ik&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&sv(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Yh{constructor(e,n){this.attrs=e,this.spec=n||Pf}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 Rs(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Yh&&sv(this.attrs,e.attrs)&&sv(this.spec,e.spec)}static is(e){return e.type instanceof Yh}destroy(){}}class qO{constructor(e,n){this.attrs=e,this.spec=n||Pf}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 Rs(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 qO&&sv(this.attrs,e.attrs)&&sv(this.spec,e.spec)}destroy(){}}class Rs{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Rs(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 Rs(e,e,new ik(n,r))}static inline(e,n,r,i){return new Rs(e,n,new Yh(r,i))}static node(e,n,r,i){return new Rs(e,n,new qO(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Yh}get widget(){return this.type instanceof ik}}const Vg=[],Pf={};class wa{constructor(e,n){this.local=e.length?e:Vg,this.children=n.length?n:Vg}static create(e,n){return n.length?sk(n,e,0,Pf):fs}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==fs||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Pf)}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?Yqe(this.children,o||[],e,n,r,i,s):o?new wa(o.sort(jf),Vg):fs}add(e,n){return n.length?this==fs?wa.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=bae(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,sk(d,l,u+1,Pf)),s+=3}});let o=gae(s?xae(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new wa(o.length?this.local.concat(o).sort(jf):this.local,i||this.children)}remove(e){return e.length==0||this==fs?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!=fs?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 wa(i,r):fs}forChild(e,n){if(this==fs)return this;if(n.isLeaf)return wa.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 Yh){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 wa(i.sort(jf),Vg);return r?new yh([l,r]):l}return r||fs}eq(e){if(this==e)return!0;if(!(e instanceof wa)||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 GO(this.localsInner(e))}localsInner(e){if(this==fs)return Vg;if(e.inlineContent||!this.local.some(Yh.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Yh||n.push(this.local[r]);return n}forEachSet(e){e(this)}}wa.empty=new wa([],[]);wa.removeOverlap=GO;const fs=wa.empty;class yh{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Pf));return yh.from(r)}forChild(e,n){if(n.isLeaf)return wa.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=fs&&(s instanceof yh?r=r.concat(s.members):r.push(s))}return yh.from(r)}eq(e){if(!(e instanceof yh)||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?GO(r?n:n.sort(jf)):Vg}static from(e){switch(e.length){case 0:return fs;case 1:return e[0];default:return new yh(e.every(n=>n instanceof wa)?e:e.reduce((n,r)=>n.concat(r instanceof wa?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Yqe(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((f,p,x,v)=>{let g=v-x-(p-f);for(let y=0;y<l.length;y+=3){let _=l[y+1];if(_<0||f>_+d-h)continue;let N=l[y]+d-h;p>=N?l[y+1]=f<=N?-2:-1:f>=d&&g&&(l[y]+=g,l[y+1]+=g)}h+=g}),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 f=n.map(t[u+1]+s,-1),p=f-i,{index:x,offset:v}=r.content.findIndex(h),g=r.maybeChild(x);if(g&&v==h&&v+g.nodeSize==p){let y=l[u+2].mapInner(n,g,d+1,t[u]+s+1,o);y!=fs?(l[u]=h,l[u+1]=p,l[u+2]=y):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=Xqe(l,t,e,n,i,s,o),d=sk(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,f=0;h<d.children.length;h+=3){let p=d.children[h];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,d.children[h],d.children[h+1],d.children[h+2])}}return new wa(e.sort(jf),l)}function gae(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 Rs(i.from+e,i.to+e,i.type))}return n}function Xqe(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 bae(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 xae(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function sk(t,e,n,r){let i=[],s=!1;e.forEach((l,c)=>{let u=bae(t,l,c+n);if(u){s=!0;let d=sk(u,l,n+c+1,r);d!=fs&&i.push(c,c+l.nodeSize,d)}});let o=gae(s?xae(t):t,-n).sort(jf);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 wa(o,i):fs}function jf(t,e){return t.from-e.from||t.to-e.to}function GO(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),pW(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),pW(e,i,r.copy(s.from,r.to)));break}}}return e}function pW(t,e,n){for(;e<t.length&&jf(n,t[e])>0;)e++;t.splice(e,0,n)}function gE(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=fs&&e.push(r)}),t.cursorWrapper&&e.push(wa.create(t.state.doc,[t.cursorWrapper.deco])),yh.from(e)}const Qqe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Zqe=oo&&Wh<=11;class Jqe{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 e9e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jqe,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]);oo&&Wh<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ws&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Zqe&&(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,Qqe)),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(oW(this.view)){if(this.suppressingSelectionUpdates)return ed(this.view);if(oo&&Wh<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&rp(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)&&oW(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(c.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of c)if(d.nodeName=="BR"&&d.parentNode){let h=d.nextSibling;h&&h.nodeType==1&&h.contentEditable=="false"&&d.parentNode.removeChild(d)}}else if(yl&&c.length){let d=c.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,f]=d;h.parentNode&&h.parentNode.parentNode==f.parentNode?f.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let f of d){let p=f.parentNode;p&&p.nodeName=="LI"&&(!h||r9e(e,h)!=p)&&f.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&&wA(r)&&(u=zO(e))&&u.eq(Gn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ed(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),t9e(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,a9e(e,c)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ed(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(oo&&Wh<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:f}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?es(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?es(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 gW=new WeakMap,bW=!1;function t9e(t){if(!gW.has(t)&&(gW.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=yl,bW)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."),bW=!0}}function xW(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return rp(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function n9e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return xW(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?xW(t,n):null}function r9e(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 a9e(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let c=l.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(s,l.firstChild),r==s&&t.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function i9e(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}],wA(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ns&&t.input.lastKeyCode===8)for(let g=s;g>i;g--){let y=r.childNodes[g-1],_=y.pmViewDesc;if(y.nodeName=="BR"&&!_){s=g;break}if(!_||_.size)break}let h=t.state.doc,f=t.someProp("domParser")||i0.fromSchema(t.state.schema),p=h.resolve(o),x=null,v=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:s9e,context:p});if(u&&u[0].pos!=null){let g=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=g),x={anchor:g+o,head:y+o}}return{doc:v,sel:x,from:o,to:l}}function s9e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ws&&/^(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||ws&&/^(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 o9e=/^(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 l9e(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=zO(t,k);if(R&&!t.state.selection.eq(R)){if(ns&&qu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,nf(13,"Enter"))))return;let M=t.state.tr.setSelection(R);k=="pointer"?M.setMeta("pointer",!0):k=="key"&&M.scrollIntoView(),s&&M.setMeta("composition",s),t.dispatch(M)}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=i9e(t,e,n),d=t.state.doc,h=d.slice(u.from,u.to),f,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,p="end"):(f=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let x=d9e(h.content,u.doc.content,u.from,f,p);if(x&&t.input.domChangeCount++,(Hb&&t.input.lastIOSEnter>Date.now()-225||qu)&&i.some(k=>k.nodeType==1&&!o9e.test(k.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",k=>k(t,nf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof An&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let k=yW(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&&x.start==x.endB&&t.state.selection instanceof An&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),oo&&Wh<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)=="  "&&(x.start--,x.endA--,x.endB--);let v=u.doc.resolveNoCache(x.start-u.from),g=u.doc.resolveNoCache(x.endB-u.from),y=d.resolve(x.start),_=v.sameParent(g)&&v.parent.inlineContent&&y.end()>=x.endA;if((Hb&&t.input.lastIOSEnter>Date.now()-225&&(!_||i.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!_&&v.pos<u.doc.content.size&&(!v.sameParent(g)||!v.parent.inlineContent)&&v.pos<g.pos&&!/\S/.test(u.doc.textBetween(v.pos,g.pos,"","")))&&t.someProp("handleKeyDown",k=>k(t,nf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&u9e(d,x.start,x.endA,v,g)&&t.someProp("handleKeyDown",k=>k(t,nf(8,"Backspace")))){qu&&ns&&t.domObserver.suppressSelectionUpdates();return}ns&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),qu&&!_&&v.start()!=g.start()&&g.parentOffset==0&&v.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,g=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(k){return k(t,nf(13,"Enter"))})},20));let N=x.start,A=x.endA,C=k=>{let R=k||t.state.tr.replace(N,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let M=yW(t,R.doc,u.sel);M&&!(ns&&t.composing&&M.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(M.head==N||M.head==R.mapping.map(A)-1)||oo&&M.empty&&M.head==N)&&R.setSelection(M)}return s&&R.setMeta("composition",s),R.scrollIntoView()},j;if(_)if(v.pos==g.pos){oo&&Wh<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>ed(t),20));let k=C(t.state.tr.delete(N,A)),R=d.resolve(x.start).marksAcross(d.resolve(x.endA));R&&k.ensureMarks(R),t.dispatch(k)}else if(x.endA==x.endB&&(j=c9e(v.parent.content.cut(v.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,x.endA-y.start())))){let k=C(t.state.tr);j.type=="add"?k.addMark(N,A,j.mark):k.removeMark(N,A,j.mark),t.dispatch(k)}else if(v.parent.child(v.index()).isText&&v.index()==g.index()-(g.textOffset?0:1)){let k=v.parent.textBetween(v.parentOffset,g.parentOffset),R=()=>C(t.state.tr.insertText(k,N,A));t.someProp("handleTextInput",M=>M(t,N,A,k,R))||t.dispatch(R())}else t.dispatch(C());else t.dispatch(C())}function yW(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:UO(t,e.resolve(n.anchor),e.resolve(n.head))}function c9e(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(Ft.from(u).eq(t))return{mark:l,type:o}}function u9e(t,e,n,r,i){if(n-e<=i.pos-r.pos||bE(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(bE(s,!0,!0));return!o.parent.isTextblock||o.pos>n||bE(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function bE(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 d9e(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&&vW(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&&vW(t.textBetween(s-1,s+1))&&(s+=c?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function vW(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 yae{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 Aqe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(kW),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=_W(this),SW(this),this.nodeViews=NW(this),this.docView=tW(this.state.doc,wW(this),gE(this),this.dom,this),this.domObserver=new e9e(this,(r,i,s,o)=>l9e(this,r,i,s,o)),this.domObserver.start(),Tqe(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&&KR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(kW),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&&(hae(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=NW(this);m9e(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&KR(this),this.editable=_W(this),SW(this);let c=gE(this),u=wW(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 f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&HVe(this);if(o){this.domObserver.stop();let p=h&&(oo||ns)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&h9e(i.selection,e.selection);if(h){let x=ns?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Hqe(this)),(s||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=tW(e.doc,u,c,this.dom,this)),x&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&hqe(this))?ed(this,p):(eae(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():f&&$Ve(f)}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 un){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&YG(this,n.getBoundingClientRect(),e)}else YG(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 fae(e.slice,e.move,i<0?void 0:un.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(oo){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&&VVe(this.dom),ed(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 YVe(this,e)}coordsAtPos(e,n=1){return Gre(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 eqe(this,n||this.state,e)}pasteHTML(e,n){return iv(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return iv(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return BO(this,e)}destroy(){this.docView&&(Mqe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],gE(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,EVe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return jqe(this,e)}domSelectionRange(){let e=this.domSelection();return e?ws&&this.root.nodeType===11&&OVe(this.dom.ownerDocument)==this.dom&&n9e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}yae.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function wW(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"),[Rs.node(0,t.state.doc.content.size,e)]}function SW(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:Rs.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function _W(t){return!t.someProp("editable",e=>e(t.state)===!1)}function h9e(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 NW(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 m9e(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 kW(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 am={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:"'"},ok={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},f9e=typeof navigator<"u"&&/Mac/.test(navigator.platform),p9e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ts=0;ts<10;ts++)am[48+ts]=am[96+ts]=String(ts);for(var ts=1;ts<=24;ts++)am[ts+111]="F"+ts;for(var ts=65;ts<=90;ts++)am[ts]=String.fromCharCode(ts+32),ok[ts]=String.fromCharCode(ts);for(var xE in am)ok.hasOwnProperty(xE)||(ok[xE]=am[xE]);function g9e(t){var e=f9e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||p9e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ok:am)[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 b9e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),x9e=typeof navigator<"u"&&/Win/.test(navigator.platform);function y9e(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))b9e?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 v9e(t){let e=Object.create(null);for(let n in t)e[y9e(n)]=t[n];return e}function yE(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 w9e(t){return new ka({props:{handleKeyDown:vae(t)}})}function vae(t){let e=v9e(t);return function(n,r){let i=g9e(r),s,o=e[yE(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[yE(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(x9e&&r.ctrlKey&&r.altKey)&&(s=am[r.keyCode])&&s!=i){let l=e[yE(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var S9e=Object.defineProperty,WO=(t,e)=>{for(var n in e)S9e(t,n,{get:e[n],enumerable:!0})};function NA(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 kA=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,f])=>[h,(...x)=>{const v=this.buildProps(c,e),g=f(...x)(v);return o.push(g),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:NA({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}},wae={};WO(wae,{blur:()=>_9e,clearContent:()=>N9e,clearNodes:()=>k9e,command:()=>C9e,createParagraphNear:()=>A9e,cut:()=>T9e,deleteCurrentNode:()=>M9e,deleteNode:()=>P9e,deleteRange:()=>j9e,deleteSelection:()=>E9e,enter:()=>D9e,exitCode:()=>R9e,extendMarkRange:()=>F9e,first:()=>L9e,focus:()=>I9e,forEach:()=>z9e,insertContent:()=>U9e,insertContentAt:()=>$9e,joinBackward:()=>G9e,joinDown:()=>q9e,joinForward:()=>W9e,joinItemBackward:()=>K9e,joinItemForward:()=>Y9e,joinTextblockBackward:()=>X9e,joinTextblockForward:()=>Q9e,joinUp:()=>V9e,keyboardShortcut:()=>J9e,lift:()=>eGe,liftEmptyBlock:()=>tGe,liftListItem:()=>nGe,newlineInCode:()=>rGe,resetAttributes:()=>aGe,scrollIntoView:()=>iGe,selectAll:()=>sGe,selectNodeBackward:()=>oGe,selectNodeForward:()=>lGe,selectParentNode:()=>cGe,selectTextblockEnd:()=>uGe,selectTextblockStart:()=>dGe,setContent:()=>hGe,setMark:()=>EGe,setMeta:()=>DGe,setNode:()=>RGe,setNodeSelection:()=>FGe,setTextDirection:()=>LGe,setTextSelection:()=>OGe,sinkListItem:()=>IGe,splitBlock:()=>zGe,splitListItem:()=>UGe,toggleList:()=>BGe,toggleMark:()=>HGe,toggleNode:()=>$Ge,toggleWrap:()=>VGe,undoInputRule:()=>qGe,unsetAllMarks:()=>GGe,unsetMark:()=>WGe,unsetTextDirection:()=>KGe,updateAttributes:()=>YGe,wrapIn:()=>XGe,wrapInList:()=>QGe});var _9e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),N9e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),k9e=()=>({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)),f=u.resolve(d.map(c+l.nodeSize)),p=h.blockRange(f);if(!p)return;const x=bx(p);if(l.type.isTextblock){const{defaultType:v}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(p.start,v)}(x||x===0)&&e.lift(p,x)})}),!0},C9e=t=>e=>t(e),A9e=()=>({state:t,dispatch:e})=>Fre(t,e),T9e=(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 An(r.doc.resolve(Math.max(o-1,0)))),!0},M9e=()=>({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 ci(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 P9e=t=>({tr:e,state:n,dispatch:r})=>{const i=ci(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},j9e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},E9e=()=>({state:t,dispatch:e})=>DO(t,e),D9e=()=>({commands:t})=>t.keyboardShortcut("Enter"),R9e=()=>({state:t,dispatch:e})=>bVe(t,e);function KO(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function lk(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:KO(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Sae(t,e,n={}){return t.find(r=>r.type===e&&lk(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function CW(t,e,n={}){return!!Sae(t,e,n)}function YO(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),!Sae([...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&&CW([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&CW([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Sd(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 F9e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Sd(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const h=YO(c,s,e);if(h&&h.from<=u&&h.to>=d){const f=An.create(o,h.from,h.to);n.setSelection(f)}}return!0},L9e=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 _ae(t){return t instanceof An}function bf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Nae(t,e=null){if(!e)return null;const n=Gn.atStart(t),r=Gn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?An.create(t,bf(0,i,s),bf(t.content.size,i,s)):An.create(t,bf(e,i,s),bf(e,i,s))}function AW(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function ck(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function O9e(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var I9e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(ck()||AW())&&r.dom.focus(),O9e()&&!ck()&&!AW()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(s&&t===null&&!_ae(n.state.selection))return o(),!0;const l=Nae(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},z9e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),U9e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),kae=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&&kae(r)}return t};function R_(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return kae(n)}function ov(t,e,n){if(t instanceof Gh||t instanceof Ft)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 Ft.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),ov("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new lre({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?i0.fromSchema(c).parseSlice(R_(t),n.parseOptions):i0.fromSchema(c).parse(R_(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=i0.fromSchema(e);return n.slice?s.parseSlice(R_(t),n.parseOptions).content:s.parse(R_(t),n.parseOptions)}return ov("",e,n)}function B9e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Di||i instanceof Fi))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(Gn.near(t.doc.resolve(o),n))}var H9e=t=>!("type"in t),$9e=(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=g=>{s.emit("contentError",{editor:s,error:g,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{ov(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(g){c(g)}try{l=ov(e,s.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return c(g),!1}let{from:d,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,p=!0;if((H9e(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),d===h&&p){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,h+=1)}let v;if(f){if(Array.isArray(e))v=e.map(g=>g.text||"").join("");else if(e instanceof Ft){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),v=g}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,h)}else{v=l;const g=r.doc.resolve(d),y=g.node(),_=g.parentOffset===0,N=y.isText||y.isTextblock,A=y.content.size>0;_&&N&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,h,v)}n.updateSelection&&B9e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},V9e=()=>({state:t,dispatch:e})=>fVe(t,e),q9e=()=>({state:t,dispatch:e})=>pVe(t,e),G9e=()=>({state:t,dispatch:e})=>Tre(t,e),W9e=()=>({state:t,dispatch:e})=>Ere(t,e),K9e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=xA(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Y9e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=xA(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},X9e=()=>({state:t,dispatch:e})=>hVe(t,e),Q9e=()=>({state:t,dispatch:e})=>mVe(t,e);function Cae(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Z9e(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))ck()||Cae()?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 J9e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=Z9e(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 im(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?ci(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(h,f)=>{if(h.isText)return;const p=Math.max(r,f),x=Math.min(i,f+h.nodeSize);l.push({node:h,from:p,to:x})});const c=i-r,u=l.filter(h=>o?o.name===h.node.type.name:!0).filter(h=>lk(h.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((h,f)=>h+f.to-f.from,0)>=c}var eGe=(t,e={})=>({state:n,dispatch:r})=>{const i=ci(t,n.schema);return im(n,i,e)?gVe(n,r):!1},tGe=()=>({state:t,dispatch:e})=>Lre(t,e),nGe=t=>({state:e,dispatch:n})=>{const r=ci(t,e.schema);return TVe(r)(e,n)},rGe=()=>({state:t,dispatch:e})=>Rre(t,e);function CA(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function TW(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 aGe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=CA(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=ci(t,r.schema)),l==="mark"&&(o=Sd(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,TW(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(f=>{o===f.type&&(c=!0,i&&n.addMark(h,h+d.nodeSize,o.create(TW(f.attrs,e))))})})}),c},iGe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),sGe=()=>({tr:t,dispatch:e})=>{if(e){const n=new Lo(t.doc);t.setSelection(n)}return!0},oGe=()=>({state:t,dispatch:e})=>Pre(t,e),lGe=()=>({state:t,dispatch:e})=>Dre(t,e),cGe=()=>({state:t,dispatch:e})=>vVe(t,e),uGe=()=>({state:t,dispatch:e})=>_Ve(t,e),dGe=()=>({state:t,dispatch:e})=>SVe(t,e);function YR(t,e,n={},r={}){return ov(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var hGe=(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=YR(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 Aae(t,e){const n=Sd(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 Tae(t,e){const n=new Nre(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function mGe(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 fGe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function pGe(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 AA(t){return e=>pGe(e.$from,t)}function sn(t,e,n){return t.config[e]===void 0&&t.parent?sn(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?sn(t.parent,e,n):null}):t.config[e]}function XO(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=sn(e,"addExtensions",n);return r?[e,...XO(r())]:e}).flat(10)}function QO(t,e){const n=mp.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Mae(t){return typeof t=="function"}function Pr(t,e=void 0,...n){return Mae(t)?e?t.bind(e)(...n):t(...n):t}function gGe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function $b(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 Pae(t){const e=[],{nodeExtensions:n,markExtensions:r}=$b(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=sn(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(h=>{Object.entries(d.attributes).forEach(([f,p])=>{e.push({type:h,name:f,attribute:{...s,...p}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=sn(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,h])=>{const f={...s,...h};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:o.name,name:d,attribute:f})})}),e}function za(...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,f]=d.split(":").map(p=>p.trim());u.set(h,f)}),l.forEach(d=>{const[h,f]=d.split(":").map(p=>p.trim());u.set(h,f)}),r[i]=Array.from(u.entries()).map(([d,h])=>`${d}: ${h}`).join("; ")}else r[i]=s}),r},{})}function lv(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)=>za(n,r),{})}function bGe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function MW(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):bGe(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function PW(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&gGe(n)?!1:n!=null))}function jW(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 xGe(t,e){var n;const r=Pae(t),{nodeExtensions:i,markExtensions:s}=$b(t),o=(n=i.find(u=>sn(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(y=>y.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},f=t.reduce((y,_)=>{const N=sn(_,"extendNodeSchema",h);return{...y,...N?N(u):{}}},{}),p=PW({...f,content:Pr(sn(u,"content",h)),marks:Pr(sn(u,"marks",h)),group:Pr(sn(u,"group",h)),inline:Pr(sn(u,"inline",h)),atom:Pr(sn(u,"atom",h)),selectable:Pr(sn(u,"selectable",h)),draggable:Pr(sn(u,"draggable",h)),code:Pr(sn(u,"code",h)),whitespace:Pr(sn(u,"whitespace",h)),linebreakReplacement:Pr(sn(u,"linebreakReplacement",h)),defining:Pr(sn(u,"defining",h)),isolating:Pr(sn(u,"isolating",h)),attrs:Object.fromEntries(d.map(jW))}),x=Pr(sn(u,"parseHTML",h));x&&(p.parseDOM=x.map(y=>MW(y,d)));const v=sn(u,"renderHTML",h);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:lv(y,d)}));const g=sn(u,"renderText",h);return g&&(p.toText=g),[u.name,p]})),c=Object.fromEntries(s.map(u=>{const d=r.filter(g=>g.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},f=t.reduce((g,y)=>{const _=sn(y,"extendMarkSchema",h);return{...g,..._?_(u):{}}},{}),p=PW({...f,inclusive:Pr(sn(u,"inclusive",h)),excludes:Pr(sn(u,"excludes",h)),group:Pr(sn(u,"group",h)),spanning:Pr(sn(u,"spanning",h)),code:Pr(sn(u,"code",h)),attrs:Object.fromEntries(d.map(jW))}),x=Pr(sn(u,"parseHTML",h));x&&(p.parseDOM=x.map(g=>MW(g,d)));const v=sn(u,"renderHTML",h);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:lv(g,d)})),[u.name,p]}));return new lre({topNode:o,nodes:l,marks:c})}function yGe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function uk(t){return t.sort((n,r)=>{const i=sn(n,"priority")||100,s=sn(r,"priority")||100;return i>s?-1:i<s?1:0})}function jae(t){const e=uk(XO(t)),n=yGe(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 Eae(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
  8168. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,h)=>{var f;c.isBlock&&u>r&&(l+=s);const p=o?.[c.type.name];if(p)return d&&(l+=p({node:c,pos:u,parent:d,index:h,range:e})),!1;c.isText&&(l+=(f=c?.text)==null?void 0:f.slice(Math.max(r,u)-u,i-u))}),l}function vGe(t,e){const n={from:0,to:t.content.size};return Eae(t,n,e)}function Dae(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function wGe(t,e){const n=ci(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 Rae(t,e){const n=CA(typeof e=="string"?e:e.name,t.schema);return n==="node"?wGe(t,e):n==="mark"?Aae(t,e):{}}function SGe(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 _Ge(t){const e=SGe(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 Fae(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),f=e.invert().map(d);r.push({oldRange:{from:h,to:f},newRange:{from:u,to:d}})})}),_Ge(r)}function ZO(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=YO(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 NGe=(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 F_(t,e){return e.nodes[t]||e.marks[t]||null}function g1(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 kGe=(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 XR(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Sd(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>s?s.name===h.type.name:!0).find(h=>lk(h.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:h,$to:f})=>{const p=h.pos,x=f.pos;t.doc.nodesBetween(p,x,(v,g)=>{if(!v.isText&&!v.marks.length)return;const y=Math.max(p,g),_=Math.min(x,g+v.nodeSize),N=_-y;o+=N,l.push(...v.marks.map(A=>({mark:A,from:y,to:_})))})}),o===0)return!1;const c=l.filter(h=>s?s.name===h.mark.type.name:!0).filter(h=>lk(h.mark.attrs,n,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),u=l.filter(h=>s?h.mark.type!==s&&h.mark.type.excludes(s):!0).reduce((h,f)=>h+f.to-f.from,0);return(c>0?c+u:c)>=o}function CGe(t,e,n={}){if(!e)return im(t,null,n)||XR(t,null,n);const r=CA(e,t.schema);return r==="node"?im(t,e,n):r==="mark"?XR(t,e,n):!1}var AGe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=AA(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)},TGe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function EW(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function DW(t,e){const{nodeExtensions:n}=$b(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=Pr(sn(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function TA(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&&(TA(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Lae(t){return t instanceof un}var Oae=class Iae{constructor(e){this.position=e}static fromJSON(e){return new Iae(e.position)}toJSON(){return{position:this.position}}};function MGe(t,e){const n=e.mapping.mapResult(t.position);return{position:new Oae(n.pos),mapResult:n}}function PGe(t){return new Oae(t)}function jGe(t,e,n){var r;const{selection:i}=e;let s=null;if(_ae(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,f)=>{if(u)return!1;if(d.isInline){const p=!f||f.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));u=p&&x}return!u}),u})}var EGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,c=Sd(t,r.schema);if(i)if(o){const u=Aae(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,(f,p)=>{const x=Math.max(p,d),v=Math.min(p+f.nodeSize,h);f.marks.find(y=>y.type===c)?f.marks.forEach(y=>{c===y.type&&n.addMark(x,v,c.create({...y.attrs,...e}))}):n.addMark(x,v,c.create(e))})});return jGe(r,n,c)},DGe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),RGe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=ci(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})=>GG(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>GG(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},FGe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=bf(t,0,r.content.size),s=un.create(r,i);e.setSelection(s)}return!0},LGe=(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},OGe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=An.atStart(r).from,l=An.atEnd(r).to,c=bf(i,o,l),u=bf(s,o,l),d=An.create(r,c,u);e.setSelection(d)}return!0},IGe=t=>({state:e,dispatch:n})=>{const r=ci(t,e.schema);return jVe(r)(e,n)};function RW(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 zGe=({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=g1(u,l.node().type.name,l.node().attrs);if(s instanceof un&&s.node.isBlock)return!l.parentOffset||!Ju(o,l.pos)?!1:(r&&(t&&RW(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,f=l.depth===0?void 0:mGe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=h&&f?[{type:f,attrs:d}]:void 0,x=Ju(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!x&&Ju(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(x=!0,p=f?[{type:f,attrs:d}]:void 0),r){if(x&&(s instanceof An&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),f&&!h&&!l.parentOffset&&l.parent.type!==f)){const v=e.mapping.map(l.before()),g=e.doc.resolve(v);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&RW(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},UGe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=ci(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 f=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 y=Ft.empty;const _=c.index(-1)?1:c.index(-2)?2:3;for(let R=c.depth-_;R>=c.depth-3;R-=1)y=Ft.from(c.node(R).copy(y));const N=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...g1(f,c.node().type.name,c.node().attrs),...e},C=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(A))||void 0;y=y.append(Ft.from(l.createAndFill(null,C)||void 0));const j=c.before(c.depth-(_-1));n.replace(j,c.after(-N),new qt(y,4-_,0));let k=-1;n.doc.nodesBetween(j,n.doc.content.size,(R,M)=>{if(k>-1)return!1;R.isTextblock&&R.content.size===0&&(k=M+1)}),k>-1&&n.setSelection(An.near(n.doc.resolve(k))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?h.contentMatchAt(0).defaultType:null,x={...g1(f,h.type.name,h.attrs),...e},v={...g1(f,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const g=p?[{type:l,attrs:x},{type:p,attrs:v}]:[{type:l,attrs:x}];if(!Ju(n.doc,c.pos,2))return!1;if(i){const{selection:y,storedMarks:_}=r,{splittableMarks:N}=s.extensionManager,A=_||y.$to.parentOffset&&y.$from.marks();if(n.split(c.pos,2,g).scrollIntoView(),!A||!i)return!0;const C=A.filter(j=>N.includes(j.type.name));n.ensureMarks(C)}return!0},vE=(t,e)=>{const n=AA(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&&hm(t.doc,n.pos)&&t.join(n.pos),!0},wE=(t,e)=>{const n=AA(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&&hm(t.doc,r)&&t.join(r),!0},BGe=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:h,splittableMarks:f}=i.extensionManager,p=ci(t,o.schema),x=ci(e,o.schema),{selection:v,storedMarks:g}=o,{$from:y,$to:_}=v,N=y.blockRange(_),A=g||v.$to.parentOffset&&v.$from.marks();if(!N)return!1;const C=AA(j=>DW(j.type.name,h))(v);if(N.depth>=1&&C&&N.depth-C.depth<=1){if(C.node.type===p)return u.liftListItem(x);if(DW(C.node.type.name,h)&&p.validContent(C.node.content)&&l)return c().command(()=>(s.setNodeMarkup(C.pos,p),!0)).command(()=>vE(s,p)).command(()=>wE(s,p)).run()}return!n||!A||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>vE(s,p)).command(()=>wE(s,p)).run():c().command(()=>{const j=d().wrapInList(p,r),k=A.filter(R=>f.includes(R.type.name));return s.ensureMarks(k),j?!0:u.clearNodes()}).wrapInList(p,r).command(()=>vE(s,p)).command(()=>wE(s,p)).run()},HGe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Sd(t,r.schema);return XR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},$Ge=(t,e,n={})=>({state:r,commands:i})=>{const s=ci(t,r.schema),o=ci(e,r.schema),l=im(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})},VGe=(t,e={})=>({state:n,commands:r})=>{const i=ci(t,n.schema);return im(n,i,e)?r.lift(i):r.wrapIn(i,e)},qGe=()=>({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},GGe=()=>({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},WGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Sd(t,r.schema),{$from:u,empty:d,ranges:h}=l;if(!i)return!0;if(d&&o){let{from:f,to:p}=l;const x=(s=u.marks().find(g=>g.type===c))==null?void 0:s.attrs,v=YO(u,c,x);v&&(f=v.from,p=v.to),n.removeMark(f,p,c)}else h.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,c)});return n.removeStoredMark(c),!0},KGe=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},YGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=CA(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=ci(t,r.schema)),l==="mark"&&(o=Sd(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;let f,p,x,v;n.selection.empty?r.doc.nodesBetween(d,h,(g,y)=>{s&&s===g.type&&(c=!0,x=Math.max(y,d),v=Math.min(y+g.nodeSize,h),f=y,p=g)}):r.doc.nodesBetween(d,h,(g,y)=>{y<d&&s&&s===g.type&&(c=!0,x=Math.max(y,d),v=Math.min(y+g.nodeSize,h),f=y,p=g),y>=d&&y<=h&&(s&&s===g.type&&(c=!0,i&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(_=>{if(o===_.type&&(c=!0,i)){const N=Math.max(y,d),A=Math.min(y+g.nodeSize,h);n.addMark(N,A,o.create({..._.attrs,...e}))}}))}),p&&(f!==void 0&&i&&n.setNodeMarkup(f,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(g=>{o===g.type&&i&&n.addMark(x,v,o.create({...g.attrs,...e}))}))}),c},XGe=(t,e={})=>({state:n,dispatch:r})=>{const i=ci(t,n.schema);return NVe(i,e)(n,r)},QGe=(t,e={})=>({state:n,dispatch:r})=>{const i=ci(t,n.schema);return kVe(i,e)(n,r)},ZGe=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={}}},MA=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},JGe=(t,e)=>{if(KO(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 L_(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(f=>f.type.spec.code))return!1;let d=!1;const h=kGe(u)+s;return o.forEach(f=>{if(d)return;const p=JGe(h,f.find);if(!p)return;const x=c.state.tr,v=NA({state:c.state,transaction:x}),g={from:r-(p[0].length-s.length),to:i},{commands:y,chain:_,can:N}=new kA({editor:n,state:v});f.handler({state:v,range:g,match:p,commands:y,chain:_,can:N})===null||!x.steps.length||(f.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:s}),c.dispatch(x),d=!0)}),d}function eWe(t){const{editor:e,rules:n}=t,r=new ka({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=QO(Ft.from(d),o.schema);const{from:h}=c,f=h+d.length;L_({editor:e,from:h,to:f,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return L_({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&L_({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?L_({editor:e,from:o.pos,to:o.pos,text:`
  8169. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function tWe(t){return Object.prototype.toString.call(t).slice(8,-1)}function O_(t){return tWe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function zae(t,e){const n={...t};return O_(t)&&O_(e)&&Object.keys(e).forEach(r=>{O_(e[r])&&O_(t[r])?n[r]=zae(t[r],e[r]):n[r]=e[r]}),n}var JO=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{...Pr(sn(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Pr(sn(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>zae(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}},fm=class Uae extends JO{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Uae(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 nWe(t){return typeof t=="number"}var rWe=class{constructor(t){this.find=t.find,this.handler=t.handler}},aWe=(t,e,n)=>{if(KO(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 iWe(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new kA({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,i,(p,x)=>{var v,g,y,_,N;if((g=(v=p.type)==null?void 0:v.spec)!=null&&g.code||!(p.isText||p.isTextblock||p.isInline))return;const A=(N=(_=(y=p.content)==null?void 0:y.size)!=null?_:p.nodeSize)!=null?N:0,C=Math.max(r,x),j=Math.min(i,x+A);if(C>=j)return;const k=p.isText?p.text||"":p.textBetween(C-x,j-x,void 0,"");aWe(k,s.find,o).forEach(M=>{if(M.index===void 0)return;const D=C+M.index+1,G=D+M[0].length,U={from:n.tr.mapping.map(D),to:n.tr.mapping.map(G)},W=s.handler({state:n,range:U,match:M,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});h.push(W)})}),h.every(p=>p!==null)}var I_=null,sWe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function oWe(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:f,rule:p,pasteEvt:x})=>{const v=d.tr,g=NA({state:d,transaction:v});if(!(!iWe({editor:e,state:g,from:Math.max(h-1,0),to:f.b-1,rule:p,pasteEvent:x,dropEvent:l})||!v.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new ka({view(h){const f=x=>{var v;r=(v=h.dom.parentElement)!=null&&v.contains(x.target)?h.dom.parentElement:null,r&&(I_=e)},p=()=>{I_&&(I_=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(h,f)=>{if(s=r===h.dom.parentElement,l=f,!s){const p=I_;p?.isEditable&&setTimeout(()=>{const x=p.state.selection;x&&p.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(h,f)=>{var p;const x=(p=f.clipboardData)==null?void 0:p.getData("text/html");return o=f,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(h,f,p)=>{const x=h[0],v=x.getMeta("uiEvent")==="paste"&&!i,g=x.getMeta("uiEvent")==="drop"&&!s,y=x.getMeta("applyPasteRules"),_=!!y;if(!v&&!g&&!_)return;if(_){let{text:C}=y;typeof C=="string"?C=C:C=QO(Ft.from(C),p.schema);const{from:j}=y,k=j+C.length,R=sWe(C);return c({rule:d,state:p,from:j,to:{b:k},pasteEvt:R})}const N=f.doc.content.findDiffStart(p.doc.content),A=f.doc.content.findDiffEnd(p.doc.content);if(!(!nWe(N)||!A||N===A.b))return c({rule:d,state:p,from:N,to:A,pasteEvt:o})}}))}var PA=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=jae(t),this.schema=xGe(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:F_(e.name,this.schema)},r=sn(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return uk([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:F_(r.name,this.schema)},s=[],o=sn(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&sn(r,"exitable",i)&&(l.ArrowRight=()=>fm.handleExit({editor:t,mark:r})),o){const f=Object.fromEntries(Object.entries(o()).map(([p,x])=>[p,()=>x({editor:t})]));l={...l,...f}}const c=w9e(l);s.push(c);const u=sn(r,"addInputRules",i);if(EW(r,t.options.enableInputRules)&&u){const f=u();if(f&&f.length){const p=eWe({editor:t,rules:f}),x=Array.isArray(p)?p:[p];s.push(...x)}}const d=sn(r,"addPasteRules",i);if(EW(r,t.options.enablePasteRules)&&d){const f=d();if(f&&f.length){const p=oWe({editor:t,rules:f});s.push(...p)}}const h=sn(r,"addProseMirrorPlugins",i);if(h){const f=h();s.push(...f)}return s})}get attributes(){return Pae(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=$b(this.extensions);return Object.fromEntries(e.filter(n=>!!sn(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:ci(n.name,this.schema)},s=sn(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const l=(c,u,d,h,f)=>{const p=lv(c,r);return o({node:c,view:u,getPos:d,decorations:h,innerDecorations:f,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return uk([...this.extensions].reverse()).reduceRight((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:F_(i.name,this.schema)},o=sn(i,"dispatchTransaction",s);return o?l=>{o.call(s,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=$b(this.extensions);return Object.fromEntries(e.filter(n=>!!sn(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:Sd(n.name,this.schema)},s=sn(n,"addMarkView",i);if(!s)return[];const o=(l,c,u)=>{const d=lv(l,r);return s()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:h=>{SWe(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:F_(e.name,this.schema)};e.type==="mark"&&((n=Pr(sn(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=sn(e,"onBeforeCreate",r),s=sn(e,"onCreate",r),o=sn(e,"onUpdate",r),l=sn(e,"onSelectionUpdate",r),c=sn(e,"onTransaction",r),u=sn(e,"onFocus",r),d=sn(e,"onBlur",r),h=sn(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)})}};PA.resolve=jae;PA.sort=uk;PA.flatten=XO;var lWe={};WO(lWe,{ClipboardTextSerializer:()=>Hae,Commands:()=>$ae,Delete:()=>Vae,Drop:()=>qae,Editable:()=>Gae,FocusEvents:()=>Kae,Keymap:()=>Yae,Paste:()=>Xae,Tabindex:()=>Qae,TextDirection:()=>Zae,focusEventsPluginKey:()=>Wae});var qr=class Bae extends JO{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Bae(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Hae=qr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ka({key:new Ni("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=Dae(n);return Eae(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),$ae=qr.create({name:"commands",addCommands(){return{...wae}}}),Vae=qr.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=Tae(t.before,[t,...e]);Fae(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(x,v)=>{const g=v+x.nodeSize-2,y=p.oldRange.from<=v&&g<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:v,to:g,newFrom:d.mapping.map(v),newTo:d.mapping.map(g),deletedRange:p.oldRange,newRange:p.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});const f=d.mapping;d.steps.forEach((p,x)=>{var v,g;if(p instanceof Ql){const y=f.slice(x).map(p.from,-1),_=f.slice(x).map(p.to),N=f.invert().map(y,-1),A=f.invert().map(_),C=(v=d.doc.nodeAt(y-1))==null?void 0:v.marks.some(k=>k.eq(p.mark)),j=(g=d.doc.nodeAt(_))==null?void 0:g.marks.some(k=>k.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:N,to:A},newRange:{from:y,to:_},partial:!!(j||C),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()}}),qae=qr.create({name:"drop",addProseMirrorPlugins(){return[new ka({key:new Ni("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Gae=qr.create({name:"editable",addProseMirrorPlugins(){return[new ka({key:new Ni("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Wae=new Ni("focusEvents"),Kae=qr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ka({key:Wae,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}}}})]}}),Yae=qr.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:f,parent:p}=h,x=h.parent.isTextblock&&f>0?l.doc.resolve(f-1):h,v=x.parent.type.spec.isolating,g=h.pos-h.parentOffset,y=v&&x.parent.childCount===1?g===h.pos:Gn.atStart(u).from===f;return!d||!p.type.isTextblock||p.textContent.length||!y||y&&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 ck()||Cae()?s:i},addProseMirrorPlugins(){return[new ka({key:new Ni("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,c=Gn.atStart(e.doc).from,u=Gn.atEnd(e.doc).to;if(s||!(o===c&&l===u)||!TA(n.doc))return;const f=n.tr,p=NA({state:n,transaction:f}),{commands:x}=new kA({editor:this.editor,state:p});if(x.clearNodes(),!!f.steps.length)return f}})]}}),Xae=qr.create({name:"paste",addProseMirrorPlugins(){return[new ka({key:new Ni("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Qae=qr.create({name:"tabindex",addProseMirrorPlugins(){return[new ka({key:new Ni("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Zae=qr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=$b(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 ka({key:new Ni("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),cWe=class Gy{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 Gy(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 Gy(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 Gy(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=n.isInline,l=this.pos+r+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!i&&!o&&c.depth<=this.depth)return;const u=new Gy(c,this.editor,i,i||o?n:null);i&&(u.actualDepth=this.depth+1),e.push(u)}),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)}},uWe=`.ProseMirror {
  8170. position: relative;
  8171. }
  8172. .ProseMirror {
  8173. word-wrap: break-word;
  8174. white-space: pre-wrap;
  8175. white-space: break-spaces;
  8176. -webkit-font-variant-ligatures: none;
  8177. font-variant-ligatures: none;
  8178. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8179. }
  8180. .ProseMirror [contenteditable="false"] {
  8181. white-space: normal;
  8182. }
  8183. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8184. white-space: pre-wrap;
  8185. }
  8186. .ProseMirror pre {
  8187. white-space: pre-wrap;
  8188. }
  8189. img.ProseMirror-separator {
  8190. display: inline !important;
  8191. border: none !important;
  8192. margin: 0 !important;
  8193. width: 0 !important;
  8194. height: 0 !important;
  8195. }
  8196. .ProseMirror-gapcursor {
  8197. display: none;
  8198. pointer-events: none;
  8199. position: absolute;
  8200. margin: 0;
  8201. }
  8202. .ProseMirror-gapcursor:after {
  8203. content: "";
  8204. display: block;
  8205. position: absolute;
  8206. top: -2px;
  8207. width: 20px;
  8208. border-top: 1px solid black;
  8209. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8210. }
  8211. @keyframes ProseMirror-cursor-blink {
  8212. to {
  8213. visibility: hidden;
  8214. }
  8215. }
  8216. .ProseMirror-hideselection *::selection {
  8217. background: transparent;
  8218. }
  8219. .ProseMirror-hideselection *::-moz-selection {
  8220. background: transparent;
  8221. }
  8222. .ProseMirror-hideselection * {
  8223. caret-color: transparent;
  8224. }
  8225. .ProseMirror-focused .ProseMirror-gapcursor {
  8226. display: block;
  8227. }`;function dWe(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 hWe=class extends ZGe{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,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:MGe,createMappablePosition:PGe},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=Nae(e,this.options.autofocus);this.editorState=Jg.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=dWe(uWe,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=Mae(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?[Gae,Hae.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),$ae,Kae,Yae,Qae,qae,Xae,Vae,Zae.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 PA(r,this)}createCommandManager(){this.commandManager=new kA({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=YR(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=YR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new yae(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();const o=this.view.dom;o.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 Rae(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return CGe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return QO(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8228. `,textSerializers:n={}}=t||{};return vGe(this.state.doc,{blockSeparator:e,textSerializers:{...Dae(this.schema),...n}})}get isEmpty(){return TA(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 cWe(e,this)}get $doc(){return this.$pos(0)}};function Vb(t){return new MA({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Pr(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(ZO(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&s.delete(d,n.to),u>n.from&&s.delete(n.from+c,u);const f=n.from+c+o.length;s.addMark(n.from+c,f,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function Jae(t){return new MA({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Pr(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 QR(t){return new MA({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=Pr(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 qb(t){return new MA({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=Pr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&jO(c,t.type,s);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:h,storedMarks:f}=e,{splittableMarks:p}=t.editor.extensionManager,x=f||h.$to.parentOffset&&h.$from.marks();if(x){const v=x.filter(g=>p.includes(g.type.name));o.ensureMarks(v)}}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&&hm(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var mWe=t=>"touches"in t,fWe=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.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const c=l.touches[0];if(!c)return;const u=c.clientX-this.startX,d=c.clientY-this.startY;this.handleResize(u,d)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,c=this.element.offsetHeight;this.onCommit(l,c),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=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,s,o;this.node=t.node,this.editor=t.editor,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||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}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.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",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=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}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,mWe(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 pWe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof un){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 gWe={};WO(gWe,{createAtomBlockMarkdownSpec:()=>bWe,createBlockMarkdownSpec:()=>xWe,createInlineMarkdownSpec:()=>wWe,parseAttributes:()=>eI,parseIndentedBlocks:()=>ZR,renderNestedMarkdownContent:()=>nI,serializeAttributes:()=>tI});function eI(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 f=parseInt(((h=d.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),p=n[f];p&&(e[u]=p.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function tI(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 bWe(t){const{nodeName:e,name:n,parseAttributes:r=eI,serializeAttributes:i=tI,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const h={};return l.forEach(f=>{f in d&&(h[f]=d[f])}),h};return{parseMarkdown:(d,h)=>{const f={...s,...d.attributes};return h.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(d){var h;const f=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(h=d.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(d,h,f){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(p);if(!x)return;const v=x[1]||"",g=r(v);if(!o.find(_=>!(_ in g)))return{type:e,raw:x[0],attributes:g}}},renderMarkdown:d=>{const h=u(d.attrs||{}),f=i(h),p=f?` {${f}}`:"";return`:::${c}${p} :::`}}}function xWe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=eI,serializeAttributes:s=tI,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=h=>{if(!c)return h;const f={};return c.forEach(p=>{p in h&&(f[p]=h[p])}),f};return{parseMarkdown:(h,f)=>{let p;if(r){const v=r(h);p=typeof v=="string"?[{type:"text",text:v}]:v}else l==="block"?p=f.parseChildren(h.tokens||[]):p=f.parseInline(h.tokens||[]);const x={...o,...h.attributes};return f.createNode(e,x,p)},markdownTokenizer:{name:e,level:"block",start(h){var f;const p=new RegExp(`^:::${u}`,"m"),x=(f=h.match(p))==null?void 0:f.index;return x!==void 0?x:-1},tokenize(h,f,p){var x;const v=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=h.match(v);if(!g)return;const[y,_=""]=g,N=i(_);let A=1;const C=y.length;let j="";const k=/^:::([\w-]*)(\s.*)?/gm,R=h.slice(C);for(k.lastIndex=0;;){const M=k.exec(R);if(M===null)break;const D=M.index,G=M[1];if(!((x=M[2])!=null&&x.endsWith(":::"))){if(G)A+=1;else if(A-=1,A===0){const U=R.slice(0,D);j=U.trim();const W=h.slice(0,C+D+M[0].length);let L=[];if(j)if(l==="block")for(L=p.blockTokens(U),L.forEach(ee=>{ee.text&&(!ee.tokens||ee.tokens.length===0)&&(ee.tokens=p.inlineTokens(ee.text))});L.length>0;){const ee=L[L.length-1];if(ee.type==="paragraph"&&(!ee.text||ee.text.trim()===""))L.pop();else break}else L=p.inlineTokens(j);return{type:e,raw:W,attributes:N,content:j,tokens:L}}}}}},renderMarkdown:(h,f)=>{const p=d(h.attrs||{}),x=s(p),v=x?` {${x}}`:"",g=f.renderChildren(h.content||[],`
  8229. `);return`:::${u}${v}
  8230. ${g}
  8231. :::`}}}function yWe(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 vWe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function wWe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=yWe,serializeAttributes:s=vWe,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const p={};return c.forEach(x=>{const v=typeof x=="string"?x:x.name,g=typeof x=="string"?void 0:x.skipIfDefault;if(v in f){const y=f[v];if(g!==void 0&&y===g)return;p[v]=y}}),p},h=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,p)=>{const x={...o,...f.attributes};if(l)return p.createNode(e,x);const v=r?r(f):f.content||"";return v?p.createNode(e,x,[p.createTextNode(v)]):p.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(f){const p=l?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),x=f.match(p),v=x?.index;return v!==void 0?v:-1},tokenize(f,p,x){const v=l?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),g=f.match(v);if(!g)return;let y="",_="";if(l){const[,A]=g;_=A}else{const[,A,C]=g;_=A,y=C||""}const N=i(_.trim());return{type:e,raw:g[0],content:y.trim(),attributes:N}}},renderMarkdown:f=>{let p="";r?p=r(f):f.content&&f.content.length>0&&(p=f.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const x=d(f.attrs||{}),v=s(x),g=v?` ${v}`:"";return l?`[${u}${g}]`:`[${u}${g}]${p}[/${u}]`}}}function ZR(t,e,n){var r,i,s,o;const l=t.split(`
  8232. `),c=[];let u="",d=0;const h=e.baseIndentSize||2;for(;d<l.length;){const f=l[d],p=f.match(e.itemPattern);if(!p){if(c.length>0)break;if(f.trim()===""){d+=1,u=`${u}${f}
  8233. `;continue}else return}const x=e.extractItemData(p),{indentLevel:v,mainContent:g}=x;u=`${u}${f}
  8234. `;const y=[g];for(d+=1;d<l.length;){const C=l[d];if(C.trim()===""){const k=l.slice(d+1).findIndex(D=>D.trim()!=="");if(k===-1)break;if((((i=(r=l[d+1+k].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>v){y.push(C),u=`${u}${C}
  8235. `,d+=1;continue}else break}if((((o=(s=C.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>v)y.push(C),u=`${u}${C}
  8236. `,d+=1;else break}let _;const N=y.slice(1);if(N.length>0){const C=N.map(j=>j.slice(v+h)).join(`
  8237. `);C.trim()&&(e.customNestedParser?_=e.customNestedParser(C):_=n.blockTokens(C))}const A=e.createToken(x,_);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function nI(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(`
  8238. `).map(f=>f?e.indent(f):"").join(`
  8239. `);c.push(h)}}),c.join(`
  8240. `)}function SWe(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(p=>{if(p!==o)return!1;h=p}),!h)return;let f=!1;if(Object.keys(n).forEach(p=>{n[p]!==h.attrs[p]&&(f=!0)}),f){const p=t.type.create({...t.attrs,...n});s.removeMark(u,d,t.type),s.addMark(u,d,p)}}),s.docChanged&&e.view.dispatch(s)}var mo=class eie extends JO{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new eie(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function ip(t){return new rWe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=Pr(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),f=h+l.length;if(ZO(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(g=>g===t.type&&g!==x.mark.type)).filter(x=>x.to>h).length)return null;f<n.to&&o.delete(f,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)}}})}const{getOwnPropertyNames:_We,getOwnPropertySymbols:NWe}=Object,{hasOwnProperty:kWe}=Object.prototype;function SE(t,e){return function(r,i,s){return t(r,i,s)&&e(r,i,s)}}function z_(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:s}=i,o=s.get(n),l=s.get(r);if(o&&l)return o===r&&l===n;s.set(n,r),s.set(r,n);const c=t(n,r,i);return s.delete(n),s.delete(r),c}}function CWe(t){return t?.[Symbol.toStringTag]}function FW(t){return _We(t).concat(NWe(t))}const AWe=Object.hasOwn||((t,e)=>kWe.call(t,e));function fp(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const TWe="__v",MWe="__o",PWe="_owner",{getOwnPropertyDescriptor:LW,keys:OW}=Object;function jWe(t,e){return t.byteLength===e.byteLength&&dk(new Uint8Array(t),new Uint8Array(e))}function EWe(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function DWe(t,e){return t.byteLength===e.byteLength&&dk(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function RWe(t,e){return fp(t.getTime(),e.getTime())}function FWe(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function LWe(t,e){return t===e}function IW(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=t.entries();let o,l,c=0;for(;(o=s.next())&&!o.done;){const u=e.entries();let d=!1,h=0;for(;(l=u.next())&&!l.done;){if(i[h]){h++;continue}const f=o.value,p=l.value;if(n.equals(f[0],p[0],c,h,t,e,n)&&n.equals(f[1],p[1],f[0],p[0],t,e,n)){d=i[h]=!0;break}h++}if(!d)return!1;c++}return!0}const OWe=fp;function IWe(t,e,n){const r=OW(t);let i=r.length;if(OW(e).length!==i)return!1;for(;i-- >0;)if(!tie(t,e,n,r[i]))return!1;return!0}function Dy(t,e,n){const r=FW(t);let i=r.length;if(FW(e).length!==i)return!1;let s,o,l;for(;i-- >0;)if(s=r[i],!tie(t,e,n,s)||(o=LW(t,s),l=LW(e,s),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function zWe(t,e){return fp(t.valueOf(),e.valueOf())}function UWe(t,e){return t.source===e.source&&t.flags===e.flags}function zW(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=t.values();let o,l;for(;(o=s.next())&&!o.done;){const c=e.values();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(!i[d]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){u=i[d]=!0;break}d++}if(!u)return!1}return!0}function dk(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function BWe(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function tie(t,e,n,r){return(r===PWe||r===MWe||r===TWe)&&(t.$$typeof||e.$$typeof)?!0:AWe(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const HWe="[object ArrayBuffer]",$We="[object Arguments]",VWe="[object Boolean]",qWe="[object DataView]",GWe="[object Date]",WWe="[object Error]",KWe="[object Map]",YWe="[object Number]",XWe="[object Object]",QWe="[object RegExp]",ZWe="[object Set]",JWe="[object String]",eKe={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},tKe="[object URL]",nKe=Object.prototype.toString;function rKe({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:s,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:c,arePrimitiveWrappersEqual:u,areRegExpsEqual:d,areSetsEqual:h,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:x}){return function(g,y,_){if(g===y)return!0;if(g==null||y==null)return!1;const N=typeof g;if(N!==typeof y)return!1;if(N!=="object")return N==="number"?l(g,y,_):N==="function"?s(g,y,_):!1;const A=g.constructor;if(A!==y.constructor)return!1;if(A===Object)return c(g,y,_);if(Array.isArray(g))return e(g,y,_);if(A===Date)return r(g,y,_);if(A===RegExp)return d(g,y,_);if(A===Map)return o(g,y,_);if(A===Set)return h(g,y,_);const C=nKe.call(g);if(C===GWe)return r(g,y,_);if(C===QWe)return d(g,y,_);if(C===KWe)return o(g,y,_);if(C===ZWe)return h(g,y,_);if(C===XWe)return typeof g.then!="function"&&typeof y.then!="function"&&c(g,y,_);if(C===tKe)return p(g,y,_);if(C===WWe)return i(g,y,_);if(C===$We)return c(g,y,_);if(eKe[C])return f(g,y,_);if(C===HWe)return t(g,y,_);if(C===qWe)return n(g,y,_);if(C===VWe||C===YWe||C===JWe)return u(g,y,_);if(x){let j=x[C];if(!j){const k=CWe(g);k&&(j=x[k])}if(j)return j(g,y,_)}return!1}}function aKe({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:jWe,areArraysEqual:n?Dy:EWe,areDataViewsEqual:DWe,areDatesEqual:RWe,areErrorsEqual:FWe,areFunctionsEqual:LWe,areMapsEqual:n?SE(IW,Dy):IW,areNumbersEqual:OWe,areObjectsEqual:n?Dy:IWe,arePrimitiveWrappersEqual:zWe,areRegExpsEqual:UWe,areSetsEqual:n?SE(zW,Dy):zW,areTypedArraysEqual:n?SE(dk,Dy):dk,areUrlsEqual:BWe,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=z_(r.areArraysEqual),s=z_(r.areMapsEqual),o=z_(r.areObjectsEqual),l=z_(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:s,areObjectsEqual:o,areSetsEqual:l})}return r}function iKe(t){return function(e,n,r,i,s,o,l){return t(e,n,l)}}function sKe({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(l,c){const{cache:u=t?new WeakMap:void 0,meta:d}=n();return e(l,c,{cache:u,equals:r,meta:d,strict:i})};if(t)return function(l,c){return e(l,c,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const s={cache:void 0,equals:r,meta:void 0,strict:i};return function(l,c){return e(l,c,s)}}const oKe=pm();pm({strict:!0});pm({circular:!0});pm({circular:!0,strict:!0});pm({createInternalComparator:()=>fp});pm({strict:!0,createInternalComparator:()=>fp});pm({circular:!0,createInternalComparator:()=>fp});pm({circular:!0,createInternalComparator:()=>fp,strict:!0});function pm(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,s=aKe(t),o=rKe(s),l=n?n(o):iKe(o);return sKe({circular:e,comparator:o,createState:r,equals:l,strict:i})}var lKe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},cKe=({contentComponent:t})=>{const e=wF.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(e)})};function uKe(){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]:vde.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 dKe=class extends Kr.Component{constructor(t){var e;super(t),this.editorContentRef=Kr.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=uKe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.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.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:lKe(e,this.editorContentRef),...n}),t?.contentComponent&&a.jsx(cKe,{contentComponent:t.contentComponent})]})}},hKe=w.forwardRef((t,e)=>{const n=Kr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Kr.createElement(dKe,{key:n,innerRef:e,...t})}),nie=Kr.memo(hKe),mKe=typeof window<"u"?w.useLayoutEffect:w.useEffect,fKe=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 pKe(t){var e;const[n]=w.useState(()=>new fKe(t.editor)),r=aZ.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:oKe);return mKe(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var gKe=!1,JR=typeof window>"u",bKe=JR||!!(typeof window<"u"&&window.next),xKe=class rie{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?JR||bKe?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 hWe(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?rie.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 yKe(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new xKe(n)),i=wF.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),pKe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var aie=w.createContext({editor:null});aie.Consumer;var vKe=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),wKe=()=>w.useContext(vKe);Kr.forwardRef((t,e)=>{const{onDragStart:n}=wKe(),r=t.as||"div";return a.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Kr.createContext({markViewContentRef:()=>{}});var rI=w.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});rI.displayName="TiptapContext";var SKe=()=>w.useContext(rI);function iie({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=w.useMemo(()=>({editor:r}),[r]),s=w.useMemo(()=>({editor:r}),[r]);return a.jsx(aie.Provider,{value:s,children:a.jsx(rI.Provider,{value:i,children:n})})}iie.displayName="Tiptap";function sie({...t}){const{editor:e}=SKe();return a.jsx(nie,{editor:e,...t})}sie.displayName="Tiptap.Content";Object.assign(iie,{Content:sie});var hk=(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]},_Ke=/^\s*>\s$/,NKe=mo.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return hk("blockquote",{...za(this.options.HTMLAttributes,t),children:hk("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(`
  8241. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
  8242. `))}),r.join(`
  8243. ${n}
  8244. `)},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[qb({find:_Ke,type:this.type})]}}),kKe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,CKe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,AKe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,TKe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,MKe=fm.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 hk("strong",{...za(this.options.HTMLAttributes,t),children:hk("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:kKe,type:this.type}),Vb({find:AKe,type:this.type})]},addPasteRules(){return[ip({find:CKe,type:this.type}),ip({find:TKe,type:this.type})]}}),PKe=/(^|[^`])`([^`]+)`(?!`)$/,jKe=/(^|[^`])`([^`]+)`(?!`)/g,EKe=fm.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",za(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:PKe,type:this.type})]},addPasteRules(){return[ip({find:jKe,type:this.type})]}}),_E=4,DKe=/^```([a-z]+)?[\s\n]$/,RKe=/^~~~([a-z]+)?[\s\n]$/,FKe=mo.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:_E,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",za(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(`
  8245. `):r=`\`\`\`${i}
  8246. \`\`\``,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:_E,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,p=r.doc.textBetween(u,d,`
  8247. `,`
  8248. `).split(`
  8249. `).map(x=>l+x).join(`
  8250. `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:_E,{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(),p=r.doc.textBetween(d,h,`
  8251. `,`
  8252. `).split(`
  8253. `);let x=0,v=0;const g=u-d;for(let j=0;j<p.length;j+=1){if(v+p[j].length>=g){x=j;break}v+=p[j].length+1}const _=((c=p[x].match(/^ */))==null?void 0:c[0])||"",N=Math.min(_.length,n);if(N===0)return!0;let A=d;for(let j=0;j<x;j+=1)A+=p[j].length+1;return l.delete(A,A+N),u-A<=N&&l.setSelection(An.create(l.doc,A)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,f=r.doc.textBetween(c,u,`
  8254. `,`
  8255. `).split(`
  8256. `).map(p=>{var x;const v=((x=p.match(/^ */))==null?void 0:x[0])||"",g=Math.min(v.length,n);return p.slice(g)}).join(`
  8257. `);return l.replaceWith(c,u,r.schema.text(f)),!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(`
  8258. `);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(Gn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[QR({find:DKe,type:this.type,getAttributes:t=>({language:t[1]})}),QR({find:RKe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ka({key:new Ni("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,`
  8259. `));return o.replaceSelectionWith(this.type.create({language:s},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(An.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),LKe=mo.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8260. `):""}),OKe=mo.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",za(this.options.HTMLAttributes,t)]},renderText(){return`
  8261. `},renderMarkdown:()=>`
  8262. `,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(f=>l.includes(f.type.name));u.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),IKe=mo.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]}`,za(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>QR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),zKe=mo.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",za(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!pWe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Lae(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(An.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(un.create(o.doc,c.pos)):o.setSelection(An.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(An.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Jae({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),UKe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,BKe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,HKe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,$Ke=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,VKe=fm.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",za(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:UKe,type:this.type}),Vb({find:HKe,type:this.type})]},addPasteRules(){return[ip({find:BKe,type:this.type}),ip({find:$Ke,type:this.type})]}});const qKe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",GKe="ελ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",eF="numeric",tF="ascii",nF="alpha",c0="asciinumeric",Wy="alphanumeric",rF="domain",oie="emoji",WKe="scheme",KKe="slashscheme",NE="whitespace";function YKe(t,e){return t in e||(e[t]=[]),e[t]}function xf(t,e,n){e[eF]&&(e[c0]=!0,e[Wy]=!0),e[tF]&&(e[c0]=!0,e[nF]=!0),e[c0]&&(e[Wy]=!0),e[nF]&&(e[Wy]=!0),e[Wy]&&(e[rF]=!0),e[oie]&&(e[rF]=!0);for(const r in e){const i=YKe(r,n);i.indexOf(t)<0&&i.push(t)}}function XKe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function eo(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}eo.groups={};eo.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||eo.groups;let i;return e&&e.j?i=e:(i=new eo(e),n&&r&&xf(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||eo.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 eo,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new eo,s){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(XKe(o.t,r),n);xf(s,c,r)}else n&&xf(s,n,r);o.t=s}return i.j[t]=o,o}};const Un=(t,e,n,r,i)=>t.ta(e,n,r,i),Ma=(t,e,n,r,i)=>t.tr(e,n,r,i),UW=(t,e,n,r,i)=>t.ts(e,n,r,i),zt=(t,e,n,r,i)=>t.tt(e,n,r,i),Du="WORD",aF="UWORD",lie="ASCIINUMERICAL",cie="ALPHANUMERICAL",cv="LOCALHOST",iF="TLD",sF="UTLD",b1="SCHEME",qg="SLASH_SCHEME",aI="NUM",oF="WS",iI="NL",u0="OPENBRACE",d0="CLOSEBRACE",mk="OPENBRACKET",fk="CLOSEBRACKET",pk="OPENPAREN",gk="CLOSEPAREN",bk="OPENANGLEBRACKET",xk="CLOSEANGLEBRACKET",yk="FULLWIDTHLEFTPAREN",vk="FULLWIDTHRIGHTPAREN",wk="LEFTCORNERBRACKET",Sk="RIGHTCORNERBRACKET",_k="LEFTWHITECORNERBRACKET",Nk="RIGHTWHITECORNERBRACKET",kk="FULLWIDTHLESSTHAN",Ck="FULLWIDTHGREATERTHAN",Ak="AMPERSAND",Tk="APOSTROPHE",Mk="ASTERISK",mh="AT",Pk="BACKSLASH",jk="BACKTICK",Ek="CARET",vh="COLON",sI="COMMA",Dk="DOLLAR",vc="DOT",Rk="EQUALS",oI="EXCLAMATION",rl="HYPHEN",h0="PERCENT",Fk="PIPE",Lk="PLUS",Ok="POUND",m0="QUERY",lI="QUOTE",uie="FULLWIDTHMIDDLEDOT",cI="SEMI",wc="SLASH",f0="TILDE",Ik="UNDERSCORE",die="EMOJI",zk="SYM";var hie=Object.freeze({__proto__:null,ALPHANUMERICAL:cie,AMPERSAND:Ak,APOSTROPHE:Tk,ASCIINUMERICAL:lie,ASTERISK:Mk,AT:mh,BACKSLASH:Pk,BACKTICK:jk,CARET:Ek,CLOSEANGLEBRACKET:xk,CLOSEBRACE:d0,CLOSEBRACKET:fk,CLOSEPAREN:gk,COLON:vh,COMMA:sI,DOLLAR:Dk,DOT:vc,EMOJI:die,EQUALS:Rk,EXCLAMATION:oI,FULLWIDTHGREATERTHAN:Ck,FULLWIDTHLEFTPAREN:yk,FULLWIDTHLESSTHAN:kk,FULLWIDTHMIDDLEDOT:uie,FULLWIDTHRIGHTPAREN:vk,HYPHEN:rl,LEFTCORNERBRACKET:wk,LEFTWHITECORNERBRACKET:_k,LOCALHOST:cv,NL:iI,NUM:aI,OPENANGLEBRACKET:bk,OPENBRACE:u0,OPENBRACKET:mk,OPENPAREN:pk,PERCENT:h0,PIPE:Fk,PLUS:Lk,POUND:Ok,QUERY:m0,QUOTE:lI,RIGHTCORNERBRACKET:Sk,RIGHTWHITECORNERBRACKET:Nk,SCHEME:b1,SEMI:cI,SLASH:wc,SLASH_SCHEME:qg,SYM:zk,TILDE:f0,TLD:iF,UNDERSCORE:Ik,UTLD:sF,UWORD:aF,WORD:Du,WS:oF});const Tu=/[a-z]/,Ry=new RegExp("\\p{L}","u"),kE=new RegExp("\\p{Emoji}","u"),Mu=/\d/,CE=/\s/,BW="\r",AE=`
  8263. `,QKe="️",ZKe="‍",TE="";let U_=null,B_=null;function JKe(t=[]){const e={};eo.groups=e;const n=new eo;U_==null&&(U_=HW(qKe)),B_==null&&(B_=HW(GKe)),zt(n,"'",Tk),zt(n,"{",u0),zt(n,"}",d0),zt(n,"[",mk),zt(n,"]",fk),zt(n,"(",pk),zt(n,")",gk),zt(n,"<",bk),zt(n,">",xk),zt(n,"(",yk),zt(n,")",vk),zt(n,"「",wk),zt(n,"」",Sk),zt(n,"『",_k),zt(n,"』",Nk),zt(n,"<",kk),zt(n,">",Ck),zt(n,"&",Ak),zt(n,"*",Mk),zt(n,"@",mh),zt(n,"`",jk),zt(n,"^",Ek),zt(n,":",vh),zt(n,",",sI),zt(n,"$",Dk),zt(n,".",vc),zt(n,"=",Rk),zt(n,"!",oI),zt(n,"-",rl),zt(n,"%",h0),zt(n,"|",Fk),zt(n,"+",Lk),zt(n,"#",Ok),zt(n,"?",m0),zt(n,'"',lI),zt(n,"/",wc),zt(n,";",cI),zt(n,"~",f0),zt(n,"_",Ik),zt(n,"\\",Pk),zt(n,"・",uie);const r=Ma(n,Mu,aI,{[eF]:!0});Ma(r,Mu,r);const i=Ma(r,Tu,lie,{[c0]:!0}),s=Ma(r,Ry,cie,{[Wy]:!0}),o=Ma(n,Tu,Du,{[tF]:!0});Ma(o,Mu,i),Ma(o,Tu,o),Ma(i,Mu,i),Ma(i,Tu,i);const l=Ma(n,Ry,aF,{[nF]:!0});Ma(l,Tu),Ma(l,Mu,s),Ma(l,Ry,l),Ma(s,Mu,s),Ma(s,Tu),Ma(s,Ry,s);const c=zt(n,AE,iI,{[NE]:!0}),u=zt(n,BW,oF,{[NE]:!0}),d=Ma(n,CE,oF,{[NE]:!0});zt(n,TE,d),zt(u,AE,c),zt(u,TE,d),Ma(u,CE,d),zt(d,BW),zt(d,AE),Ma(d,CE,d),zt(d,TE,d);const h=Ma(n,kE,die,{[oie]:!0});zt(h,"#"),Ma(h,kE,h),zt(h,QKe,h);const f=zt(h,ZKe);zt(f,"#"),Ma(f,kE,h);const p=[[Tu,o],[Mu,i]],x=[[Tu,null],[Ry,l],[Mu,s]];for(let v=0;v<U_.length;v++)ih(n,U_[v],iF,Du,p);for(let v=0;v<B_.length;v++)ih(n,B_[v],sF,aF,x);xf(iF,{tld:!0,ascii:!0},e),xf(sF,{utld:!0,alpha:!0},e),ih(n,"file",b1,Du,p),ih(n,"mailto",b1,Du,p),ih(n,"http",qg,Du,p),ih(n,"https",qg,Du,p),ih(n,"ftp",qg,Du,p),ih(n,"ftps",qg,Du,p),xf(b1,{scheme:!0,ascii:!0},e),xf(qg,{slashscheme:!0,ascii:!0},e),t=t.sort((v,g)=>v[0]>g[0]?1:-1);for(let v=0;v<t.length;v++){const g=t[v][0],_=t[v][1]?{[WKe]:!0}:{[KKe]:!0};g.indexOf("-")>=0?_[rF]=!0:Tu.test(g)?Mu.test(g)?_[c0]=!0:_[tF]=!0:_[eF]=!0,UW(n,g,g,_)}return UW(n,"localhost",cv,{ascii:!0}),n.jd=new eo(zk),{start:n,tokens:Object.assign({groups:e},hie)}}function mie(t,e){const n=eYe(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,f=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(h=0,f=0,d=l):h>=0&&(h+=n[o].length,f++),u+=n[o].length,s+=n[o].length,o++;s-=h,o-=f,u-=h,i.push({t:d.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function eYe(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 ih(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 eo(r),s.jr=i.slice(),t.j[c]=s),t=s}return s=new eo(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function HW(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 uv={defaultProtocol:"http",events:null,format:$W,formatHref:$W,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function uI(t,e=null){let n=Object.assign({},uv);t&&(n=Object.assign(n,t instanceof uI?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}uI.prototype={o:uv,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]:uv[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 $W(t){return t}function fie(t,e){this.t="token",this.v=t,this.tk=e}fie.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=uv.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 jA(t,e){class n extends fie{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 VW=jA("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),qW=jA("text"),tYe=jA("nl"),H_=jA("url",{isLink:!0,toHref(t=uv.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==cv&&t[1].t===vh}}),el=t=>new eo(t);function nYe({groups:t}){const e=t.domain.concat([Ak,Mk,mh,Pk,jk,Ek,Dk,Rk,rl,aI,h0,Fk,Lk,Ok,wc,zk,f0,Ik]),n=[Tk,vh,sI,vc,oI,h0,m0,lI,cI,bk,xk,u0,d0,fk,mk,pk,gk,yk,vk,wk,Sk,_k,Nk,kk,Ck],r=[Ak,Tk,Mk,Pk,jk,Ek,Dk,Rk,rl,u0,d0,h0,Fk,Lk,Ok,m0,wc,zk,f0,Ik],i=el(),s=zt(i,f0);Un(s,r,s),Un(s,t.domain,s);const o=el(),l=el(),c=el();Un(i,t.domain,o),Un(i,t.scheme,l),Un(i,t.slashscheme,c),Un(o,r,s),Un(o,t.domain,o);const u=zt(o,mh);zt(s,mh,u),zt(l,mh,u),zt(c,mh,u);const d=zt(s,vc);Un(d,r,s),Un(d,t.domain,s);const h=el();Un(u,t.domain,h),Un(h,t.domain,h);const f=zt(h,vc);Un(f,t.domain,h);const p=el(VW);Un(f,t.tld,p),Un(f,t.utld,p),zt(u,cv,p);const x=zt(h,rl);zt(x,rl,x),Un(x,t.domain,h),Un(p,t.domain,h),zt(p,vc,f),zt(p,rl,x);const v=zt(p,vh);Un(v,t.numeric,VW);const g=zt(o,rl),y=zt(o,vc);zt(g,rl,g),Un(g,t.domain,o),Un(y,r,s),Un(y,t.domain,o);const _=el(H_);Un(y,t.tld,_),Un(y,t.utld,_),Un(_,t.domain,o),Un(_,r,s),zt(_,vc,y),zt(_,rl,g),zt(_,mh,u);const N=zt(_,vh),A=el(H_);Un(N,t.numeric,A);const C=el(H_),j=el();Un(C,e,C),Un(C,n,j),Un(j,e,C),Un(j,n,j),zt(_,wc,C),zt(A,wc,C);const k=zt(l,vh),R=zt(c,vh),M=zt(R,wc),D=zt(M,wc);Un(l,t.domain,o),zt(l,vc,y),zt(l,rl,g),Un(c,t.domain,o),zt(c,vc,y),zt(c,rl,g),Un(k,t.domain,C),zt(k,wc,C),zt(k,m0,C),Un(D,t.domain,C),Un(D,e,C),zt(D,wc,C);const G=[[u0,d0],[mk,fk],[pk,gk],[bk,xk],[yk,vk],[wk,Sk],[_k,Nk],[kk,Ck]];for(let U=0;U<G.length;U++){const[W,L]=G[U],ee=zt(C,W);zt(j,W,ee),zt(ee,L,C);const ae=el(H_);Un(ee,e,ae);const Y=el();Un(ee,n),Un(ae,e,ae),Un(ae,n,Y),Un(Y,e,ae),Un(Y,n,Y),zt(ae,L,C),zt(Y,L,C)}return zt(i,cv,_),zt(i,iI,tYe),{start:i,tokens:hie}}function rYe(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,f=-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()?(f=0,h=l):f>=0&&f++,i++,d++;if(f<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(ME(qW,e,o)),o=[]),i-=f,d-=f;const p=h.t,x=n.slice(i-d,i);s.push(ME(p,e,x))}}return o.length>0&&s.push(ME(qW,e,o)),s}function ME(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 aYe=typeof console<"u"&&console&&console.warn||(()=>{}),iYe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ua={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function sYe(){return eo.groups={},ua.scanner=null,ua.parser=null,ua.tokenQueue=[],ua.pluginQueue=[],ua.customSchemes=[],ua.initialized=!1,ua}function GW(t,e=!1){if(ua.initialized&&aYe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${iYe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8264. 1. Must only contain digits, lowercase ASCII letters or "-"
  8265. 2. Cannot start or end with "-"
  8266. 3. "-" cannot repeat`);ua.customSchemes.push([t,e])}function oYe(){ua.scanner=JKe(ua.customSchemes);for(let t=0;t<ua.tokenQueue.length;t++)ua.tokenQueue[t][1]({scanner:ua.scanner});ua.parser=nYe(ua.scanner.tokens);for(let t=0;t<ua.pluginQueue.length;t++)ua.pluginQueue[t][1]({scanner:ua.scanner,parser:ua.parser});return ua.initialized=!0,ua}function dI(t){return ua.initialized||oYe(),rYe(ua.parser.start,t,mie(ua.scanner.start,t))}dI.scan=mie;function pie(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 uI(n),i=dI(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 hI="[\0-   ᠎ -\u2029  ]",lYe=new RegExp(hI),cYe=new RegExp(`${hI}$`),uYe=new RegExp(hI,"g");function dYe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function hYe(t){return new ka({key:new Ni("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=Tae(n.doc,[...e]);if(Fae(l).forEach(({newRange:u})=>{const d=fGe(r.doc,u,p=>p.isTextblock);let h,f;if(d.length>1)h=d[0],f=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!cYe.test(p))return;h=d[0],f=r.doc.textBetween(h.pos,u.to,void 0," ")}if(h&&f){const p=f.split(lYe).filter(Boolean);if(p.length<=0)return!1;const x=p[p.length-1],v=h.pos+f.lastIndexOf(x);if(!x)return!1;const g=dI(x).map(y=>y.toObject(t.defaultProtocol));if(!dYe(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:v+y.start+1,to:v+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{ZO(y.from,y.to,r.doc).some(_=>_.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function mYe(t){return new ka({key:new Ni("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{const c=r.target;if(!c)return!1;const u=t.editor.view.dom;o=c.closest("a"),o&&!u.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const c=Rae(e.state,t.type.name),u=(i=o.href)!=null?i:c.href,d=(s=o.target)!=null?s:c.target;u&&(window.open(u,d),l=!0)}return l}}})}function fYe(t){return new ka({key:new Ni("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=pie(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.value)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function $m(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(uYe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var gie=fm.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"){GW(t);return}GW(t.scheme,t.optionalSlashes)})},onDestroy(){sYe()},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)=>!!$m(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},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},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!$m(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=>!!$m(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",za(this.options.HTMLAttributes,t),0]:["a",za(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,r,i,s;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",l=(s=(i=t.attrs)==null?void 0:i.title)!=null?s:"",c=e.renderChildren(t);return l?`[${c}](${o} "${l}")`:`[${c}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!$m(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=>!!$m(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[ip({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=pie(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!$m(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(hYe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!$m(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(mYe({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(fYe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),pYe=gie,gYe=Object.defineProperty,bYe=(t,e)=>{for(var n in e)gYe(t,n,{get:e[n],enumerable:!0})},xYe="listItem",WW="textStyle",KW=/^\s*([-+*])\s$/,bie=mo.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",za(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,`
  8267. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(xYe,this.editor.getAttributes(WW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=qb({find:KW,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=qb({find:KW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(WW),editor:this.editor})),[t]}}),xie=mo.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",za(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)=>nI(t,e,r=>{var i,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.start)||1)+r.index}. `:"- "},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)}}}),yYe={};bYe(yYe,{findListItemPos:()=>Zv,getNextListDepth:()=>mI,handleBackspace:()=>lF,handleDelete:()=>cF,hasListBefore:()=>yie,hasListItemAfter:()=>vYe,hasListItemBefore:()=>vie,listItemHasSubList:()=>wie,nextListIsDeeper:()=>Sie,nextListIsHigher:()=>_ie});var Zv=(t,e)=>{const{$from:n}=e.selection,r=ci(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}},mI=(t,e)=>{const n=Zv(t,e);if(!n)return!1;const[,r]=NGe(e,t,n.$pos.pos+4);return r},yie=(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))},vie=(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)},wie=(t,e,n)=>{if(!n)return!1;const r=ci(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},lF=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!im(t.state,e)&&yie(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((f,p)=>{f.type.name===e&&u.push({node:f,pos:p})});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(!im(t.state,e)||!TGe(t.state))return!1;const r=Zv(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=wie(e,t.state,s);return vie(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Sie=(t,e)=>{const n=mI(t,e),r=Zv(t,e);return!r||!n?!1:n>r.depth},_ie=(t,e)=>{const n=mI(t,e),r=Zv(t,e);return!r||!n?!1:n<r.depth},cF=(t,e)=>{if(!im(t.state,e)||!AGe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Sie(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():_ie(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},vYe=(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)},Nie=qr.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&&cF(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&&cF(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&&lF(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&&lF(t,n,r)&&(e=!0)}),e}}}}),YW=/^(\s*)(\d+)\.\s+(.*)$/,wYe=/^\s/;function SYe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(YW);if(!s)break;const[,o,l,c]=s,u=o.length;let d=c,h=n+1;const f=[i];for(;h<t.length;){const p=t[h];if(p.match(YW))break;if(p.trim()==="")f.push(p),d+=`
  8268. `,h+=1;else if(p.match(wYe))f.push(p),d+=`
  8269. ${p.slice(u+2)}`,h+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:f.join(`
  8270. `)}),r=h,n=h}return[e,r]}function kie(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(`
  8271. `),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(`
  8272. `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let h=s+1;const f=[];for(;h<t.length&&t[h].indent>e;)f.push(t[h]),h+=1;if(f.length>0){const p=Math.min(...f.map(v=>v.indent)),x=kie(f,p,n);u.push({type:"list",ordered:!0,start:f[0].number,items:x,raw:f.map(v=>v.raw).join(`
  8273. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),s=h}else s+=1}return i}function _Ye(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 NYe="listItem",XW="textStyle",QW=/^(\d+)\.\s$/,Cie=mo.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",za(this.options.HTMLAttributes,n),0]:["ol",za(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?_Ye(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,`
  8274. `):"",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(`
  8275. `),[s,o]=SYe(i);if(s.length===0)return;const l=kie(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(`
  8276. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(NYe,this.editor.getAttributes(XW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=qb({find:QW,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=qb({find:QW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(XW)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),kYe=/^\s*(\[([( |x])?\])\s$/,CYe=mo.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",za(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 nI(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=h=>{var f,p;l.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,h,l.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};u(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",h=>h.preventDefault()),l.addEventListener("change",h=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=h.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const x=n();if(typeof x!="number")return!1;const v=p.doc.nodeAt(x);return p.setNodeMarkup(x,void 0,{...v?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,f])=>{i.setAttribute(h,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,c),Object.entries(e).forEach(([h,f])=>{i.setAttribute(h,f)});let d=new Set(Object.keys(e));return{dom:i,contentDOM:c,update:h=>{if(h.type!==this.type)return!1;i.dataset.checked=h.attrs.checked,l.checked=h.attrs.checked,u(h);const f=r.extensionManager.attributes,p=lv(h,f),x=new Set(Object.keys(p)),v=this.options.HTMLAttributes;return d.forEach(g=>{x.has(g)||(g in v?i.setAttribute(g,v[g]):i.removeAttribute(g))}),Object.entries(p).forEach(([g,y])=>{y==null?g in v?i.setAttribute(g,v[g]):i.removeAttribute(g):i.setAttribute(g,y)}),d=x,!0}}}},addInputRules(){return[qb({find:kYe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),AYe=mo.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",za(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,`
  8277. `):"",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=ZR(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=ZR(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()}}});qr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(bie.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(xie.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Nie.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Cie.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(CYe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(AYe.configure(this.options.taskList)),t}});var ZW="&nbsp;",TYe=" ",MYe=mo.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",za(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===ZW||r[0].text===TYe)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?ZW:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),PYe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,jYe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,EYe=fm.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",za(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:PYe,type:this.type})]},addPasteRules(){return[ip({find:jYe,type:this.type})]}}),DYe=mo.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Aie=fm.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",za(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()}}}),RYe=Aie;function FYe(t={}){return new ka({view(e){return new LYe(e,t)}})}class LYe{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,f=e.nodeAfter;if(h||f){let p=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(p){let x=p.getBoundingClientRect(),v=h?x.bottom:x.top;h&&f&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:x.left,right:x.right,top:v-g,bottom:v+g}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:h.left-f,right:h.left+f,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(),f=h.width/c.offsetWidth,p=h.height/c.offsetHeight;u=h.left-c.scrollLeft*f,d=h.top-c.scrollTop*p}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=yre(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 Ra extends Gn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Ra.valid(r)?new Ra(r):Gn.near(r)}content(){return qt.empty}eq(e){return e instanceof Ra&&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 Ra(e.resolve(n.pos))}getBookmark(){return new fI(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!OYe(e)||!IYe(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&&Ra.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(Ra.valid(c))return c}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!un.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(Ra.valid(l))return l}return null}}}Ra.prototype.visible=!1;Ra.findFrom=Ra.findGapCursorFrom;Gn.jsonID("gapcursor",Ra);class fI{constructor(e){this.pos=e}map(e){return new fI(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Ra.valid(n)?new Ra(n):Gn.near(n)}}function Tie(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function OYe(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||Tie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function IYe(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||Tie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function zYe(){return new ka({props:{decorations:$Ye,createSelectionBetween(t,e,n){return e.pos==n.pos&&Ra.valid(n)?new Ra(n):null},handleClick:BYe,handleKeyDown:UYe,handleDOMEvents:{beforeinput:HYe}}})}const UYe=vae({ArrowLeft:$_("horiz",-1),ArrowRight:$_("horiz",1),ArrowUp:$_("vert",-1),ArrowDown:$_("vert",1)});function $_(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 An){if(!s.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=Ra.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new Ra(u))),!0):!1}}function BYe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Ra.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&un.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Ra(r))),!0)}function HYe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Ra))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=Ft.empty;for(let o=r.length-1;o>=0;o--)i=Ft.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new qt(i,0,0));return s.setSelection(An.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function $Ye(t){if(!(t.selection instanceof Ra))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",wa.create(t.doc,[Rs.widget(t.selection.head,e,{key:"gapcursor"})])}var Uk=200,Li=function(){};Li.prototype.append=function(e){return e.length?(e=Li.from(e),!this.length&&e||e.length<Uk&&this.leafAppend(e)||this.length<Uk&&e.leafPrepend(this)||this.appendInner(e)):this};Li.prototype.prepend=function(e){return e.length?Li.from(e).append(this):this};Li.prototype.appendInner=function(e){return new VYe(this,e)};Li.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Li.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Li.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Li.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)};Li.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};Li.from=function(e){return e instanceof Li?e:e&&e.length?new Mie(e):Li.empty};var Mie=(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<=Uk)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Uk)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})(Li);Li.empty=new Mie([]);var VYe=(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})(Li);const qYe=500;class Kl{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,f)=>{if(!h.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,d.push(h);return}if(i){d.push(new Sc(h.map));let p=h.step.map(i.slice(s)),x;p&&o.maybeStep(p).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new Sc(x,void 0,void 0,u.length+d.length))),s--,x&&i.appendMap(x,s)}else o.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(s)):h.selection,c=new Kl(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]),f=new Sc(e.mapping.maps[d],h,n),p;(p=c&&c.merge(f))&&(f=p,d?s.pop():l=l.slice(0,l.length-1)),s.push(f),n&&(o++,n=void 0),i||(c=f)}let u=o-r.depth;return u>WYe&&(l=GYe(l,u),o-=u),new Kl(l.append(s),o)}remapping(e,n){let r=new nv;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 Kl(this.items.append(e.map(n=>new Sc(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(f=>{f.selection&&l--},i);let c=n;this.items.forEach(f=>{let p=s.getMirror(--c);if(p==null)return;o=Math.min(o,p);let x=s.maps[p];if(f.step){let v=e.steps[p].invert(e.docs[p]),g=f.selection&&f.selection.map(s.slice(c+1,p));g&&l++,r.push(new Sc(x,v,g))}else r.push(new Sc(x))},i);let u=[];for(let f=n;f<o;f++)u.push(new Sc(s.maps[f]));let d=this.items.slice(0,i).append(u).append(r),h=new Kl(d,l);return h.emptyItemCount()>qYe&&(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 Sc(u.invert(),c,d),f,p=i.length-1;(f=i.length&&i[p].merge(h))?i[p]=f:i.push(h)}}else o.map&&r--},this.items.length,0),new Kl(Li.from(i.reverse()),s)}}Kl.empty=new Kl(Li.empty,0);function GYe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Sc{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 Sc(n.getMap().invert(),n,this.selection)}}}class fh{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const WYe=20;function KYe(t,e,n,r){let i=n.getMeta(Ef),s;if(i)return i.historyState;n.getMeta(QYe)&&(t=new fh(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Ef))return o.getMeta(Ef).redo?new fh(t.done.addTransform(n,void 0,r,x1(e)),t.undone,JW(n.mapping.maps),t.prevTime,t.prevComposition):new fh(t.done,t.undone.addTransform(n,void 0,r,x1(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||!YYe(n,t.prevRanges)),u=o?PE(t.prevRanges,n.mapping):JW(n.mapping.maps);return new fh(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,x1(e)),Kl.empty,u,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new fh(t.done.rebased(n,s),t.undone.rebased(n,s),PE(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new fh(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),PE(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function YYe(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 JW(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 PE(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 XYe(t,e,n){let r=x1(e),i=Ef.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 fh(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Ef,{redo:n,historyState:c})}let jE=!1,eK=null;function x1(t){let e=t.plugins;if(eK!=e){jE=!1,eK=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){jE=!0;break}}return jE}const Ef=new Ni("history"),QYe=new Ni("closeHistory");function ZYe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ka({key:Ef,state:{init(){return new fh(Kl.empty,Kl.empty,null,0,-1)},apply(e,n,r){return KYe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?jie:r=="historyRedo"?Eie:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Pie(t,e){return(n,r)=>{let i=Ef.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=XYe(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const jie=Pie(!1,!0),Eie=Pie(!0,!0);qr.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 ka({key:new Ni("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 JYe=qr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[FYe(this.options)]}});qr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ka({key:new Ni("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return wa.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(Rs.node(u,u+c.nodeSize,{class:this.options.className}))}),wa.create(t,s)}}})]}});var eXe=qr.create({name:"gapCursor",addProseMirrorPlugins(){return[zYe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Pr(sn(t,"allowGapCursor",n)))!=null?e:null}}}),tK="placeholder";function tXe(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}qr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:tK,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${tXe(this.options.dataAttribute)}`:`data-${tK}`;return[new ka({key:new Ni("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,s=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((l,c)=>{const u=i>=c&&i<=c+l.nodeSize,d=!l.isLeaf&&TA(l);if((u||!this.options.showOnlyCurrent)&&d){const h=[this.options.emptyNodeClass];o&&h.push(this.options.emptyEditorClass);const f=Rs.node(c,c+l.nodeSize,{class:h.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:c,hasAnchor:u}):this.options.placeholder});s.push(f)}return this.options.includeChildren}),wa.create(e,s)}}})]}});qr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ka({key:new Ni("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Lae(n.selection)||t.view.dragging?null:wa.create(n.doc,[Rs.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function nK({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var nXe=qr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ni(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 ka({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),h=l.content.size,f=u.nodes[n];if(d)return c.insert(h,f.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!nK({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!nK({node:o,types:r})}}})]}}),rXe=qr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>jie(t,e),redo:()=>({state:t,dispatch:e})=>Eie(t,e)}},addProseMirrorPlugins(){return[ZYe(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()}}}),aXe=qr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(MKe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(NKe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(bie.configure(this.options.bulletList)),this.options.code!==!1&&i.push(EKe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(FKe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(LKe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(JYe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(eXe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(OKe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(IKe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(rXe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(zKe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(VKe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(xie.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Nie.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(gie.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Cie.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(MYe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(EYe.configure(this.options.strike)),this.options.text!==!1&&i.push(DYe.configure(this.options.text)),this.options.underline!==!1&&i.push(Aie.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(nXe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),iXe=aXe,sXe=qr.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")}}}),oXe=sXe,lXe=20,Die=(t,e=0)=>{const n=[];return!t.children.length||e>lXe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Die(r,e+1))}),n},cXe=t=>{if(!t.children.length)return;const e=Die(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}`)})},Rie=fm.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&cXe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",za(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}}}}),uXe=qr.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()}}}),Fie=qr.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()}}}),dXe=qr.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()}}}),hXe=qr.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()}}}),mXe=qr.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()}}});qr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(uXe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Fie.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(dXe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(hXe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(mXe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Rie.configure(this.options.textStyle)),t}});var fXe=Fie,pXe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,gXe=mo.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",za(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,s,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return u?`![${c}](${l} "${u}")`:`![${c}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o,editor:l})=>{const c=document.createElement("img");Object.entries(o).forEach(([h,f])=>{if(f!=null)switch(h){case"width":case"height":break;default:c.setAttribute(h,f);break}}),c.src=o.src;const u=new fWe({element:c,editor:l,node:i,getPos:s,onResize:(h,f)=>{c.style.width=`${h}px`,c.style.height=`${f}px`},onCommit:(h,f)=>{const p=s();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:h,height:f}).run()},onUpdate:(h,f,p)=>h.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),d=u.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",c.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},u}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Jae({find:pXe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),bXe=gXe;function uF({content:t,onChange:e,placeholder:n}){const{t:r}=Et(),i=yKe({extensions:[iXe.configure({heading:!1,codeBlock:!1,code:!1}),RYe,pYe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),oXe.configure({types:["paragraph"]}),Rie,fXe,bXe.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(xhe,{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(_fe,{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(xge,{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(tC,{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(UY,{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(uge,{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(sge,{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(lge,{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(ex,{className:"w-4 h-4"})}),i.isActive("link")&&a.jsx(s,{onClick:()=>i.chain().focus().unsetLink().run(),title:r("richTextEditor.removeLink"),children:a.jsx(cC,{className:"w-4 h-4"})})]}),a.jsx(nie,{editor:i})]})}function Lie({archiveId:t,archiveName:e,onClose:n}){const r=Qt(),[i,s]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:h,error:f}=Je({queryKey:["archive-project-page",t],queryFn:()=>ge.getArchiveProjectPage(t)}),p=ut({mutationFn:C=>ge.updateArchiveProjectPage(t,C),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),u({})}});w.useEffect(()=>{const C=j=>{j.key==="Escape"&&(o!==null?l(null):i?y():n())};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[o,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],v=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),s(!0)},g=()=>{p.mutate(c)},y=()=>{s(!1),u({})},_=C=>{const j=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],k=new DOMParser().parseFromString(C,"text/html"),R=M=>{if(M.nodeType===Node.TEXT_NODE)return M.textContent||"";if(M.nodeType===Node.ELEMENT_NODE){const D=M,G=D.tagName.toLowerCase();if(!j.includes(G))return Array.from(D.childNodes).map(R).join("");let U="";if(G==="a"&&D.getAttribute("href")){const L=D.getAttribute("href");L?.toLowerCase().startsWith("http")&&(U=` href="${L}" target="_blank" rel="noopener noreferrer"`)}if(G==="img"){const L=D.getAttribute("src");if(!L?.toLowerCase().startsWith("http"))return"";U=` src="${L}" style="max-width: 100%; height: auto;"`}const W=Array.from(D.childNodes).map(R).join("");return["br","img"].includes(G)?`<${G}${U} />`:`<${G}${U}>${W}</${G}>`}return""};return Array.from(k.body.childNodes).map(R).join("")},N=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=C=>{C.target===C.currentTarget&&n()};return a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,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(Es,{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(Oe,{variant:"ghost",size:"sm",onClick:v,children:[a.jsx(Of,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&a.jsxs(a.Fragment,{children:[a.jsx(Oe,{variant:"ghost",size:"sm",onClick:y,children:"Cancel"}),a.jsxs(Oe,{variant:"primary",size:"sm",onClick:g,disabled:p.isPending,children:[a.jsx(bs,{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(Ut,{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"})}),f&&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(Es,{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:C=>u({...c,title:C.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(id,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.designer||"",onChange:C=>u({...c,designer:C.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(id,{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(aa,{className:"w-3 h-3"})})]}),d.creation_date&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(Xr,{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(Es,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.license||"",onChange:C=>u({...c,license:C.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(Es,{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(uF,{content:c.description||"",onChange:C=>u({...c,description:C}),placeholder:"Enter description..."}):a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:_(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:C=>u({...c,profile_title:C.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(uF,{content:c.profile_description||"",onChange:C=>u({...c,profile_description:C}),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:_(d.profile_description)}}),d.profile_user_name&&a.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[a.jsx(nd,{className:"w-4 h-4"}),"Images (",x.length,")"]}),a.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((C,j)=>a.jsx("button",{onClick:()=>l(j),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:a.jsx("img",{src:C.url,alt:C.name,className:"w-full h-full object-cover"})},C.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(aa,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[a.jsx("button",{onClick:C=>{C.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(Jl,{className:"w-6 h-6 text-white"})}),a.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:C=>C.stopPropagation()}),a.jsx("button",{onClick:C=>{C.stopPropagation(),l(Math.min(x.length-1,o+1))},disabled:o===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:a.jsx(pi,{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(Ut,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const xXe=[.25,.5,.75,1,1.5,2,3,4];function Fg(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function yXe({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=dn(),s=w.useRef(null),o=w.useRef(null),[l,c]=w.useState(!1),[u,d]=w.useState(0),[h,f]=w.useState(0),[p,x]=w.useState(0),[v,g]=w.useState(0),[y,_]=w.useState(1),[N,A]=w.useState(null),[C,j]=w.useState(null),[k,R]=w.useState(.8),[M,D]=w.useState(!1),{data:G,isLoading:U}=Je({queryKey:["timelapse-info",t],queryFn:()=>ge.getTimelapseInfo(t)}),{data:W}=Je({queryKey:["timelapse-thumbnails",t],queryFn:()=>ge.getTimelapseThumbnails(t,15)}),L=ut({mutationFn:()=>ge.processTimelapse(t,{trimStart:p,trimEnd:v,speed:y,saveMode:"replace"},N||void 0),onSuccess:Z=>{i(Z.message,"success"),r?.(),n()},onError:Z=>{i(Z.message||"Processing failed","error")}});w.useEffect(()=>{G?.duration&&v===0&&g(G.duration)},[G?.duration,v]),w.useEffect(()=>{const Z=ue=>{ue.key==="Escape"&&n()};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[n]),w.useEffect(()=>{const Z=s.current;if(!Z)return;const ue=()=>{const $=Z.currentTime;d($),$>=v&&(Z.currentTime=p)},pe=()=>{f(Z.duration),v===0&&g(Z.duration)},be=()=>c(!0),Ee=()=>c(!1);return Z.addEventListener("timeupdate",ue),Z.addEventListener("durationchange",pe),Z.addEventListener("play",be),Z.addEventListener("pause",Ee),()=>{Z.removeEventListener("timeupdate",ue),Z.removeEventListener("durationchange",pe),Z.removeEventListener("play",be),Z.removeEventListener("pause",Ee)}},[p,v]),w.useEffect(()=>{const Z=o.current,ue=s.current;!Z||!ue||!C||(Z.currentTime=ue.currentTime,Z.playbackRate=ue.playbackRate,l&&!M?Z.play().catch(()=>{}):Z.pause())},[l,C,M]),w.useEffect(()=>{o.current&&(o.current.volume=M?0:k)},[k,M]),w.useEffect(()=>{s.current&&(s.current.playbackRate=y),o.current&&(o.current.playbackRate=y)},[y]);const ee=w.useCallback(()=>{const Z=s.current;Z&&(l?Z.pause():(Z.currentTime<p&&(Z.currentTime=p),Z.play()))},[l,p]),ae=Z=>{const ue=s.current;ue&&(ue.currentTime=Math.max(p,Math.min(v,Z)))},Y=Z=>{const ue=Z.target.files?.[0];ue&&(C&&URL.revokeObjectURL(C),A(ue),j(URL.createObjectURL(ue)))},se=()=>{C&&URL.revokeObjectURL(C),A(null),j(null)};w.useEffect(()=>()=>{C&&URL.revokeObjectURL(C)},[C]);const ce=v-p,ye=ce/y;return U?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(Fh,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Oe,{variant:"primary",size:"sm",onClick:()=>L.mutate(),disabled:L.isPending,children:L.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{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(Ut,{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:ee,muted:!!C}),!l&&a.jsx("button",{onClick:ee,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(lo,{className:"w-8 h-8 text-white"})})}),C&&a.jsx("audio",{ref:o,src:C,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(Ppe,{className:"w-4 h-4"}),a.jsx("span",{children:"Trim"}),a.jsxs("span",{className:"ml-auto",children:[Fg(p)," - ",Fg(v)," (",Fg(ce),")"]})]}),a.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("div",{className:"absolute inset-0 flex",children:W?.thumbnails.map((Z,ue)=>a.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${Z})`}},ue))}),a.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/h*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(h-v)/h*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/h*100}%`,right:`${(h-v)/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:p,onChange:Z=>{const ue=parseFloat(Z.target.value);ue<v-1&&(x(ue),s.current&&s.current.currentTime<ue&&(s.current.currentTime=ue))},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:v,onChange:Z=>{const ue=parseFloat(Z.target.value);ue>p+1&&g(ue)},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:Z=>ae(parseFloat(Z.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8278. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8279. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8280. [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("div",{className:"flex items-center justify-center gap-2",children:a.jsx("button",{onClick:ee,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(aC,{className:"w-5 h-5 text-white"}):a.jsx(lo,{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(eC,{className:"w-4 h-4"}),a.jsx("span",{children:"Speed"}),a.jsxs("span",{className:"ml-auto",children:[y,"x (output: ",Fg(ye),")"]})]}),a.jsx("div",{className:"flex gap-1",children:xXe.map(Z=>a.jsxs("button",{onClick:()=>_(Z),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${y===Z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[Z,"x"]},Z))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(y3,{className:"w-4 h-4"}),a.jsx("span",{children:"Music Overlay"})]}),N?a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(y3,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:N.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(N.size/1024/1024).toFixed(1)," MB"]})]}),a.jsx("button",{onClick:()=>D(!M),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:M?a.jsx(Age,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(kge,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("input",{type:"range",min:0,max:1,step:.1,value:k,onChange:Z=>R(parseFloat(Z.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8281. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8282. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),a.jsx("button",{onClick:se,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:a.jsx(Xt,{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(Ia,{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:Y,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:"})," ",Fg(h)," @ ",G?.width,"x",G?.height]}),a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Output:"})," ",Fg(ye)," @ ",y,"x speed",N&&" + music overlay"]})]})]}),L.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 vXe=[.25,.5,.75,1,1.5,2,3,4];function Oie({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:s}){const o=w.useRef(null),[l,c]=w.useState(!0),[u,d]=w.useState(1),[h,f]=w.useState(0),[p,x]=w.useState(0),[v,g]=w.useState(!1);w.useEffect(()=>{const k=o.current;k&&(k.playbackRate=u)},[u]),w.useEffect(()=>{const k=R=>{R.key==="Escape"&&i()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[i]),w.useEffect(()=>{const k=o.current;if(!k)return;const R=()=>f(k.currentTime),M=()=>x(k.duration),D=()=>c(!0),G=()=>c(!1);return k.addEventListener("timeupdate",R),k.addEventListener("durationchange",M),k.addEventListener("play",D),k.addEventListener("pause",G),()=>{k.removeEventListener("timeupdate",R),k.removeEventListener("durationchange",M),k.removeEventListener("play",D),k.removeEventListener("pause",G)}},[]);const y=()=>{const k=o.current;k&&(l?k.pause():k.play())},_=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))},A=()=>{const k=o.current;k&&(k.currentTime=Math.min(p,k.currentTime+5))},C=k=>{const R=Math.floor(k/60),M=Math.floor(k%60);return`${R}:${M.toString().padStart(2,"0")}`},j=()=>{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(Fh,{className:"w-5 h-5 text-bambu-green"}),e]}),a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>g(!0),children:[a.jsx(Ka,{className:"w-4 h-4"}),"Edit"]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:j,children:[a.jsx(ba,{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(Ut,{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:y}),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:C(h)}),a.jsx("input",{type:"range",min:0,max:p||100,value:h,onChange:_,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8283. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8284. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8285. [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("span",{className:"text-xs text-bambu-gray w-12",children:C(p)})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:N,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:a.jsx($pe,{className:"w-5 h-5 text-bambu-gray"})}),a.jsx("button",{onClick:y,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(aC,{className:"w-5 h-5 text-white"}):a.jsx(lo,{className:"w-5 h-5 text-white"})}),a.jsx("button",{onClick:A,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:a.jsx(BF,{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:vXe.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))})]})]})]})]})]}),v&&r&&a.jsx(yXe,{archiveId:r,timelapseSrc:t,onClose:()=>g(!1),onSave:s})]})}function wXe({archiveIds:t,onClose:e}){w.useEffect(()=>{const s=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e]);const{data:n,isLoading:r,error:i}=Je({queryKey:["archive-comparison",t],queryFn:()=>ge.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(Ut,{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(Mn,{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(SXe,{comparison:n}):null}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx(Oe,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function SXe({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(Mn,{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(Mn,{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(Zr,{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 _Xe(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 NXe({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:s}){const[o,l]=w.useState(!1),[c,u]=w.useState(t.tags||""),[d,h]=w.useState(t.notes||""),[f,p]=w.useState(t.project_id),[x,v]=w.useState(!1);return a.jsx(Ct,{children:a.jsxs(Tt,{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(yf,{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:ml(t.file_size)}),a.jsx("span",{children:"·"}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Xn,{className:"w-3 h-3"}),_Xe(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(Sl,{className:"w-5 h-5"}):a.jsx(En,{className:"w-5 h-5"})}),a.jsx(Oe,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:f||void 0}),disabled:i,children:i?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Fs,{className:"w-4 h-4"}),"Archive"]})}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:s,children:s?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4 text-red-400"})})]})]}),x&&a.jsx(Sn,{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),v(!1)},onCancel:()=>v(!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:g=>u(g.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:g=>h(g.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:f||"",onChange:g=>p(g.target.value?Number(g.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(g=>a.jsx("option",{value:g.id,children:g.name},g.id))]})]})]})]})})}function kXe(){const t=Qt(),{showToast:e}=dn(),[n,r]=w.useState(!1),[i,s]=w.useState(!1),[o,l]=w.useState(new Set),[c,u]=w.useState(new Set),{data:d,isLoading:h}=Je({queryKey:["pending-uploads"],queryFn:zg.list,refetchInterval:1e4}),{data:f}=Je({queryKey:["projects"],queryFn:()=>ge.getProjects()}),p=ut({mutationFn:({id:y,data:_})=>zg.archive(y,_),onMutate:({id:y})=>{l(_=>new Set(_).add(y))},onSettled:(y,_,{id:N})=>{l(A=>{const C=new Set(A);return C.delete(N),C})},onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${y.print_name}`)},onError:y=>{e(y.message||"Failed to archive","error")}}),x=ut({mutationFn:y=>zg.discard(y),onMutate:y=>{u(_=>new Set(_).add(y))},onSettled:(y,_,N)=>{u(A=>{const C=new Set(A);return C.delete(N),C})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:y=>{e(y.message||"Failed to discard","error")}}),v=ut({mutationFn:zg.archiveAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${y.archived} files${y.failed>0?`, ${y.failed} failed`:""}`)},onError:y=>{e(y.message||"Failed to archive all","error")}}),g=ut({mutationFn:zg.discardAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${y.discarded} files`)},onError:y=>{e(y.message||"Failed to discard all","error")}});return h?a.jsx(Ct,{children:a.jsx(Tt,{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(Ct,{className:"border-l-4 border-l-yellow-500",children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ia,{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(Oe,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:v.isPending,children:v.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Fs,{className:"w-4 h-4"}),"Archive All"]})}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>s(!0),disabled:g.isPending,children:g.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Xt,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),a.jsxs(Tt,{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(y=>a.jsx(NXe,{upload:y,projects:f||[],onArchive:(_,N)=>p.mutate({id:_,data:N}),onDiscard:_=>x.mutate(_),isArchiving:o.has(y.id),isDiscarding:c.has(y.id)},y.id))})]})]}),n&&a.jsx(Sn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{v.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&a.jsx(Sn,{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:()=>{g.mutate(),s(!1)},onCancel:()=>s(!1)})]})}function CXe({onClose:t}){const e=Qt(),{showToast:n}=dn(),[r,i]=w.useState(""),[s,o]=w.useState(null),[l,c]=w.useState(""),[u,d]=w.useState(null),[h,f]=w.useState("count");w.useEffect(()=>{const M=D=>{D.key==="Escape"&&(s?o(null):u?d(null):t())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[t,s,u]);const{data:p,isLoading:x}=Je({queryKey:["tags"],queryFn:ge.getTags}),v=ut({mutationFn:({oldName:M,newName:D})=>ge.renameTag(M,D),onSuccess:(M,{oldName:D,newName:G})=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Renamed "${D}" to "${G}" in ${M.affected} archive${M.affected!==1?"s":""}`),o(null)},onError:M=>{n(M.message||"Failed to rename tag","error")}}),g=ut({mutationFn:M=>ge.deleteTag(M),onSuccess:(M,D)=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Deleted "${D}" from ${M.affected} archive${M.affected!==1?"s":""}`),d(null)},onError:M=>{n(M.message||"Failed to delete tag","error")}}),y=M=>{o(M.name),c(M.name),d(null)},_=()=>{o(null),c("")},N=()=>{if(!s||!l.trim())return;const M=l.trim();if(M===s){_();return}v.mutate({oldName:s,newName:M})},A=M=>{M.key==="Enter"?(M.preventDefault(),N()):M.key==="Escape"&&(M.preventDefault(),_())},C=M=>{d(M),o(null)},j=()=>{u&&g.mutate(u)},k=p?.filter(M=>M.name.toLowerCase().includes(r.toLowerCase())).sort((M,D)=>h==="count"&&D.count-M.count||M.name.localeCompare(D.name)),R=p?.reduce((M,D)=>M+D.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(Ct,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:a.jsxs(Tt,{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(ad,{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(Ut,{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(Er,{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:M=>i(M.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:M=>f(M.target.value),children:[a.jsx("option",{value:"count",children:"Sort by Count"}),a.jsx("option",{value:"name",children:"Sort by Name"})]})]}),p&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[p.length," tag",p.length!==1?"s":""," across ",R," usage",R!==1?"s":""]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 p-4",children:x?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):k?.length?a.jsx("div",{className:"space-y-2",children:k.map(M=>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===M.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:D=>c(D.target.value),onKeyDown:A,autoFocus:!0}),a.jsx(Oe,{size:"sm",variant:"primary",onClick:N,disabled:!l.trim()||v.isPending,className:"p-1.5",children:v.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Zr,{className:"w-4 h-4"})}),a.jsx(Oe,{size:"sm",variant:"ghost",onClick:_,className:"p-1.5",children:a.jsx(Ut,{className:"w-4 h-4"})})]}):u===M.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx(Mn,{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 "',M.name,'" from ',M.count," archive",M.count!==1?"s":"","?"]}),a.jsx(Oe,{size:"sm",variant:"danger",onClick:j,disabled:g.isPending,className:"p-1.5",children:g.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"})}),a.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>d(null),className:"p-1.5",children:a.jsx(Ut,{className:"w-4 h-4"})})]}):a.jsxs(a.Fragment,{children:[a.jsx(ad,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-white flex-1 truncate",children:M.name}),a.jsx("span",{className:"px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs",children:M.count}),a.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.jsx("button",{onClick:()=>y(M),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename tag",children:a.jsx(Ka,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>C(M.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(Xt,{className:"w-4 h-4"})})]})]})},M.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(Oe,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function wh(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function Iie(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()}async function Sh(t,e,n,r){try{if(n==="source"){const{token:i}=await ge.createSourceSlicerToken(t),s=ge.getSourceSlicerDownloadUrl(t,i,e);ff(`${window.location.origin}${s}`,r)}else{const{token:i}=await ge.createArchiveSlicerToken(t),s=ge.getArchiveSlicerDownloadUrl(t,i,e);ff(`${window.location.origin}${s}`,r)}}catch{const i=n==="source"?ge.getSource3mfForSlicer(t,e):ge.getArchiveForSlicer(t,e);ff(`${window.location.origin}${i}`,r)}}function AXe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,timeFormat:l="system",preferredSlicer:c="bambu_studio",currency:u,t:d}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const h=Qt(),{showToast:f}=dn(),{hasPermission:p,canModify:x}=Rr(),v=Bne(),[g,y]=w.useState(!1),[_,N]=w.useState(!1),[A,C]=w.useState(!1),[j,k]=w.useState(!1),[R,M]=w.useState(!1),[D,G]=w.useState(!1),[U,W]=w.useState([]),[L,ee]=w.useState(!1),[ae,Y]=w.useState(!1),[se,ce]=w.useState(!1),[ye,Z]=w.useState(!1),[ue,pe]=w.useState(!1),[be,Ee]=w.useState(!1),[$,K]=w.useState(!1),[T,E]=w.useState(null),[O,q]=w.useState(null),[B,re]=w.useState(!1),z=w.useRef(null),V=w.useRef(null),te=w.useRef(null),{data:Q}=Je({queryKey:["archive-plates",t.id],queryFn:()=>ge.getArchivePlates(t.id),enabled:B,staleTime:300*1e3}),ne=Q?.plates??[],ie=Q?.is_multi_plate??!1,me=O??0,fe=ut({mutationFn:()=>ge.deleteArchiveTimelapse(t.id),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.timelapseRemoved"))},onError:_e=>{f(_e.message||d("archives.toast.failedRemoveTimelapse"),"error")}}),oe=ut({mutationFn:_e=>ge.uploadArchiveTimelapse(t.id,_e),onSuccess:_e=>{h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.timelapseUploaded",{filename:_e.filename}))},onError:_e=>{f(_e.message||d("archives.toast.failedUploadTimelapse"),"error")}}),I=ut({mutationFn:_e=>ge.uploadSource3mf(t.id,_e),onSuccess:_e=>{h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.source3mfAttached",{filename:_e.filename}))},onError:_e=>{f(_e.message||d("archives.toast.failedUploadSource3mf"),"error")}}),F=ut({mutationFn:()=>ge.deleteSource3mf(t.id),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.source3mfRemoved"))},onError:_e=>{f(_e.message||d("archives.toast.failedRemoveSource3mf"),"error")}}),J=ut({mutationFn:_e=>ge.uploadF3d(t.id,_e),onSuccess:_e=>{h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.f3dAttached",{filename:_e.filename}))},onError:_e=>{f(_e.message||d("archives.toast.failedUploadF3d"),"error")}}),xe=ut({mutationFn:()=>ge.deleteF3d(t.id),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.f3dRemoved"))},onError:_e=>{f(_e.message||d("archives.toast.failedRemoveF3d"),"error")}}),he=ut({mutationFn:()=>ge.scanArchiveTimelapse(t.id),onSuccess:_e=>{_e.status==="attached"?(h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.timelapseAttached",{filename:_e.filename}))):_e.status==="exists"?f(d("archives.toast.timelapseAlreadyAttached")):_e.status==="not_found"&&_e.available_files&&_e.available_files.length>0?(W(_e.available_files),G(!0)):f(_e.message||d("archives.toast.noMatchingTimelapse"),"warning")},onError:_e=>{f(_e.message||d("archives.toast.failedScanTimelapse"),"error")}}),le=ut({mutationFn:_e=>ge.selectArchiveTimelapse(t.id,_e),onSuccess:_e=>{h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.timelapseAttached",{filename:_e.filename})),G(!1),W([])},onError:_e=>{f(_e.message||d("archives.toast.failedAttachTimelapse"),"error")}}),Ce=ut({mutationFn:()=>ge.deleteArchive(t.id),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.archiveDeleted"))},onError:()=>{f(d("archives.toast.failedDeleteArchive"),"error")}}),Ne=ut({mutationFn:()=>ge.toggleFavorite(t.id),onSuccess:_e=>{h.invalidateQueries({queryKey:["archives"]}),f(_e.is_favorite?d("archives.toast.addedToFavorites"):d("archives.toast.removedFromFavorites"))}}),{data:Ue}=Je({queryKey:["archive-folders",t.id],queryFn:()=>ge.getLibraryFoldersByArchive(t.id)}),He=ut({mutationFn:_e=>ge.updateArchive(t.id,{project_id:_e}),onSuccess:()=>{h.invalidateQueries({queryKey:["archives"]}),h.invalidateQueries({queryKey:["projects"]}),f(d("archives.toast.projectUpdated"))},onError:()=>{f(d("archives.toast.failedUpdateProject"),"error")}}),de=_e=>{_e.preventDefault(),E({x:_e.clientX,y:_e.clientY})},ke=[...wh(t.filename)?[{label:d("archives.menu.print"),icon:a.jsx(Dr,{className:"w-4 h-4"}),onClick:()=>N(!0),disabled:!t.file_path||!x("archives","reprint",t.created_by_id),title:t.file_path?x("archives","reprint",t.created_by_id)?void 0:d("archives.permission.noReprint"):d("archives.card.noFileForReprint")},{label:d("archives.menu.schedule"),icon:a.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>Z(!0),disabled:!t.file_path||!p("queue:create"),title:t.file_path?p("queue:create")?void 0:d("archives.permission.noAddToQueue"):d("archives.card.noFileForReprint")},{label:d("archives.menu.openInBambuStudio"),icon:a.jsx(aa,{className:"w-4 h-4"}),onClick:()=>{const _e=t.print_name||t.filename||"model";Sh(t.id,_e,"file",c)},disabled:!t.file_path,title:t.file_path?void 0:d("archives.card.noFileForReprint")}]:[{label:d("archives.menu.slice"),icon:a.jsx(aa,{className:"w-4 h-4"}),onClick:()=>{const _e=t.print_name||t.filename||"model";Sh(t.id,_e,"file",c)}}],{label:t.external_url?d("archives.menu.externalLink"):d("archives.menu.viewOnMakerWorld"),icon:a.jsx(Lh,{className:"w-4 h-4"}),onClick:()=>{const _e=t.external_url||t.makerworld_url;_e&&window.open(_e,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:d("archives.menu.preview3d"),icon:a.jsx(ni,{className:"w-4 h-4"}),onClick:()=>y(!0)},{label:d("archives.menu.viewTimelapse"),icon:a.jsx(Fh,{className:"w-4 h-4"}),onClick:()=>M(!0),disabled:!t.timelapse_path},{label:d("archives.menu.scanForTimelapse"),icon:a.jsx(R1,{className:"w-4 h-4"}),onClick:()=>he.mutate(),disabled:!t.printer_id||!!t.timelapse_path||he.isPending||!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives")},{label:d("archives.menu.uploadTimelapse"),icon:a.jsx(Ia,{className:"w-4 h-4"}),onClick:()=>te.current?.click(),disabled:!!t.timelapse_path||!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives")},...t.timelapse_path?[{label:d("archives.menu.removeTimelapse"),icon:a.jsx(Xt,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0,disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?d("archives.menu.downloadSource3mf"):d("archives.menu.uploadSource3mf"),icon:a.jsx(P1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?ge.downloadSource3mf(t.id).catch(_e=>{console.error("Source 3MF download failed:",_e)}):z.current?.click()},disabled:!t.source_3mf_path&&!x("archives","update",t.created_by_id),title:!t.source_3mf_path&&!x("archives","update",t.created_by_id)?d("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:d("archives.menu.replaceSource3mf"),icon:a.jsx(Ia,{className:"w-4 h-4"}),onClick:()=>z.current?.click(),disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives")},{label:d("archives.menu.removeSource3mf"),icon:a.jsx(Xt,{className:"w-4 h-4"}),onClick:()=>pe(!0),danger:!0,disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?d("archives.menu.replaceF3d"):d("archives.menu.uploadF3d"),icon:a.jsx(ni,{className:"w-4 h-4"}),onClick:()=>V.current?.click(),disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:d("archives.menu.downloadF3d"),icon:a.jsx(ba,{className:"w-4 h-4"}),onClick:()=>{ge.downloadF3d(t.id).catch(_e=>{console.error("F3D download failed:",_e)})}},{label:d("archives.menu.removeF3d"),icon:a.jsx(Xt,{className:"w-4 h-4"}),onClick:()=>Ee(!0),danger:!0,disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:d("archives.menu.download"),icon:a.jsx(ba,{className:"w-4 h-4"}),onClick:()=>{ge.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(_e=>{console.error("Archive download failed:",_e)})},disabled:!p("archives:read"),title:p("archives:read")?void 0:d("archives.permission.noDownload")},{label:d("archives.menu.copyDownloadLink"),icon:a.jsx(ec,{className:"w-4 h-4"}),onClick:()=>{const _e=`${window.location.origin}${ge.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(_e).then(()=>{f(d("archives.toast.linkCopied"))}).catch(()=>{f(d("archives.toast.failedCopyLink"),"error")})},disabled:!p("archives:read"),title:p("archives:read")?void 0:d("archives.permission.noCopyLink")},{label:d("archives.menu.qrCode"),icon:a.jsx(HY,{className:"w-4 h-4"}),onClick:()=>ee(!0)},{label:t.photos?.length?d("archives.menu.viewPhotosCount",{count:t.photos.length}):d("archives.menu.viewPhotos"),icon:a.jsx(xb,{className:"w-4 h-4"}),onClick:()=>Y(!0),disabled:!t.photos?.length},{label:d("archives.menu.projectPage"),icon:a.jsx(Es,{className:"w-4 h-4"}),onClick:()=>ce(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?d("archives.menu.removeFromFavorites"):d("archives.menu.addToFavorites"),icon:a.jsx(If,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ne.mutate(),disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives")},{label:d("archives.menu.edit"),icon:a.jsx(Ka,{className:"w-4 h-4"}),onClick:()=>k(!0),disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:d("archives.menu.goToProject",{name:t.project_name}),icon:a.jsx(xs,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:d("archives.menu.addToProject"),icon:a.jsx(xs,{className:"w-4 h-4"}),onClick:()=>{},disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?void 0:d("archives.permission.noUpdateArchives"),submenu:(()=>{const _e=[];if(t.project_id&&_e.push({label:d("archives.menu.removeFromProject"),icon:a.jsx(Ut,{className:"w-4 h-4"}),onClick:()=>He.mutate(null),disabled:!x("archives","update",t.created_by_id)}),!s)_e.push({label:d("archives.menu.loading"),icon:a.jsx(lt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Ae=s.filter(Ve=>Ve.status==="active");Ae.length===0?_e.push({label:d("archives.menu.noProjectsAvailable"),icon:a.jsx(xs,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Ae.forEach(Ve=>{_e.push({label:Ve.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Ve.color||"#888"}}),onClick:()=>He.mutate(Ve.id),disabled:t.project_id===Ve.id||!x("archives","update",t.created_by_id)})})}return _e})()},{label:d(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(uo,{className:"w-4 h-4"}):a.jsx(_l,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:d("archives.menu.delete"),icon:a.jsx(Xt,{className:"w-4 h-4"}),onClick:()=>C(!0),danger:!0,disabled:!x("archives","delete",t.created_by_id),title:x("archives","delete",t.created_by_id)?void 0:d("archives.permission.noDelete")}];return a.jsxs(Ct,{"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:de,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:_e=>{_e.stopPropagation(),r(t.id)},children:n?a.jsx(uo,{className:"w-5 h-5 text-bambu-green"}):a.jsx(_l,{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:()=>re(!0),onMouseLeave:()=>re(!1),children:[t.thumbnail_path?a.jsx("img",{src:O!==null&&ne.length>0?ge.getArchivePlateThumbnail(t.id,ne[me]?.index??0):ge.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(nd,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),ie&&ne.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 ${v?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:_e=>{_e.stopPropagation(),q(Ae=>{const Ve=Ae??0;return Ve>0?Ve-1:ne.length-1})},title:d("archives.card.previousPlate"),children:a.jsx(Jl,{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 ${v?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:_e=>{_e.stopPropagation(),q(Ae=>{const Ve=Ae??0;return Ve<ne.length-1?Ve+1:0})},title:d("archives.card.nextPlate"),children:a.jsx(pi,{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 ${v?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:ne.map((_e,Ae)=>a.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${Ae===me?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:Ve=>{Ve.stopPropagation(),q(Ae)},title:_e.name||d("archives.card.plateNumber",{index:_e.index})},_e.index))})]}),a.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${v?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:_e=>{_e.stopPropagation();const Ae=_e.currentTarget.getBoundingClientRect();E({x:Ae.left,y:Ae.bottom+4})},title:d("archives.card.moreOptions"),children:a.jsx(Rh,{className:"w-5 h-5 text-white"})}),a.jsx("button",{className:`absolute top-2 right-2 p-1 rounded transition-colors ${x("archives","update",t.created_by_id)?"bg-black/50 hover:bg-black/70":"bg-black/30 cursor-not-allowed"}`,onClick:_e=>{_e.stopPropagation(),x("archives","update",t.created_by_id)&&Ne.mutate()},disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?t.is_favorite?d("archives.card.removeFromFavorites"):d("archives.card.addToFavorites"):d("archives.permission.noUpdateArchives"),children:a.jsx(If,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"} ${x("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"?d("archives.card.cancelled"):d("archives.card.failed")}),t.duplicate_count>0&&a.jsxs("div",{className:"absolute top-2 right-12 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:d("archives.card.duplicateTitle"),children:[a.jsx(ec,{className:"w-3 h-3"}),d("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:_e=>{_e.stopPropagation();const Ae=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source";Sh(t.id,Ae,"source",c)},title:d("archives.card.openSource3mf"),children:a.jsx(P1,{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:_e=>{_e.stopPropagation(),ge.downloadF3d(t.id).catch(Ae=>{console.error("F3D download failed:",Ae)})},title:d("archives.card.downloadF3d"),children:a.jsx(ni,{className:"w-4 h-4 text-cyan-400"})}),a.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:_e=>{_e.stopPropagation(),y(!0)},title:d("archives.card.preview3d"),children:a.jsx(Ga,{className:"w-4 h-4 text-white"})}),t.timelapse_path&&a.jsx("button",{className:"absolute bottom-2 right-12 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:_e=>{_e.stopPropagation(),M(!0)},title:d("archives.card.viewTimelapse"),children:a.jsx(Fh,{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-[5.5rem]":"right-12"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:_e=>{_e.stopPropagation(),Y(!0)},title:t.photos.length===1?d("archives.card.viewPhoto"):d("archives.card.viewPhotos",{count:t.photos.length}),children:[a.jsx(xb,{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})]}),Ue&&Ue.length>0&&a.jsx(Zs,{to:`/files?folder=${Ue[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:_e=>_e.stopPropagation(),title:d("archives.card.openFolder",{name:Ue[0].name}),style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:a.jsx(nc,{className:"w-4 h-4 text-yellow-400"})})]}),a.jsxs(Tt,{className:"p-4 flex-1 flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[a.jsx("h3",{className:"min-w-0 font-medium text-white truncate",children:t.print_name||t.filename}),a.jsx(Oe,{variant:"ghost",size:"sm",className:"p-1 sm:p-1.5 shrink-0",onClick:()=>k(!0),disabled:!x("archives","update",t.created_by_id),title:x("archives","update",t.created_by_id)?d("archives.card.edit"):d("archives.card.noPermissionEdit"),children:a.jsx(Ka,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}),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 ${wh(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:wh(t.filename)?d("archives.card.slicedFile"):d("archives.card.sourceFile"),children:wh(t.filename)?d("archives.card.gcode"):d("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(_e=>_e.id===t.project_id)?.color||"#6b7280"}20`,color:s?.find(_e=>_e.id===t.project_id)?.color||"#6b7280"},title:d("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: ${js(t.print_time_seconds||0)}
  8286. Actual: ${js(t.actual_time_seconds||0)}
  8287. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${js(t.actual_time_seconds)}`:`Estimated: ${js(t.print_time_seconds||0)}`,children:[a.jsx(Xn,{className:"w-3 h-3"}),js(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(si,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),t.cost!=null&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(dme,{className:"w-3 h-3"}),u,t.cost.toFixed(2)]}),(t.layer_height||t.total_layers)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(Ga,{className:"w-3 h-3"}),t.total_layers&&a.jsx("span",{children:t.total_layers===1?d("archives.card.layer",{count:t.total_layers}):d("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?d("archives.card.object",{count:t.object_count}):d("archives.card.objects",{count:t.object_count}),children:[a.jsx(ni,{className:"w-3 h-3"}),t.object_count===1?d("archives.card.object",{count:t.object_count}):d("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:d("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((_e,Ae)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:_e},title:_e},Ae))})]})]}),(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(VY,{className:"w-3 h-3"})}),t.tags?.split(",").map((_e,Ae)=>a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:_e.trim()},Ae))]}),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:Uf(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:d("archives.card.uploadedBy",{name:t.created_by_username}),children:[a.jsx(id,{className:"w-3 h-3"}),t.created_by_username]}),a.jsx("span",{children:ml(t.file_size)})]})]}),a.jsxs("div",{className:"flex gap-1 mt-3",children:[wh(t.filename)?a.jsxs(a.Fragment,{children:[a.jsxs(Oe,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>N(!0),disabled:!t.file_path||!x("archives","reprint",t.created_by_id),title:t.file_path?x("archives","reprint",t.created_by_id)?void 0:d("archives.card.noPermissionReprint"):d("archives.card.noFileForReprint"),children:[a.jsx(Dr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:d("archives.card.reprint")})]}),a.jsxs(Oe,{variant:"secondary",size:"sm",className:"flex-1 min-w-0",onClick:()=>Z(!0),disabled:!t.file_path||!p("queue:create"),title:t.file_path?p("queue:create")?d("archives.card.schedulePrint"):d("archives.permission.noAddToQueue"):d("archives.card.noFileForReprint"),children:[a.jsx(Xr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:d("archives.card.schedule")})]}),a.jsx(Oe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const _e=t.print_name||t.filename||"model";Sh(t.id,_e,"file",c)},title:d("archives.card.openInBambuStudio"),children:a.jsx(aa,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):a.jsxs(Oe,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const _e=t.print_name||t.filename||"model";Sh(t.id,_e,"file",c)},title:d("archives.card.openInBambuStudioToSlice"),children:[a.jsx(aa,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:d("archives.card.slice")})]}),a.jsx(Oe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const _e=t.external_url||t.makerworld_url;_e&&window.open(_e,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?d("archives.card.externalLink"):t.makerworld_url?d("archives.card.makerWorld",{designer:t.designer||d("archives.card.viewProject")}):d("archives.card.noExternalLink"),children:a.jsx(Lh,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),a.jsx(Oe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{ge.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(_e=>{console.error("Archive download failed:",_e)})},title:d("archives.card.download"),children:a.jsx(ba,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Oe,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>C(!0),disabled:!x("archives","delete",t.created_by_id),title:x("archives","delete",t.created_by_id)?d("archives.card.delete"):d("archives.card.noPermissionDelete"),children:a.jsx(Xt,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),j&&a.jsx($ne,{archive:t,onClose:()=>k(!1)}),g&&a.jsx(AO,{archiveId:t.id,title:t.print_name||t.filename,fileType:Iie(t.filename),onClose:()=>y(!1)}),_&&a.jsx(Zu,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>N(!1)}),A&&a.jsx(Sn,{title:d("archives.modal.deleteArchive"),message:d("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:d("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{Ce.mutate(),C(!1)},onCancel:()=>C(!1)}),ue&&a.jsx(Sn,{title:d("archives.modal.removeSource3mf"),message:d("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:d("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{F.mutate(),pe(!1)},onCancel:()=>pe(!1)}),be&&a.jsx(Sn,{title:d("archives.modal.removeF3d"),message:d("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:d("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{xe.mutate(),Ee(!1)},onCancel:()=>Ee(!1)}),$&&a.jsx(Sn,{title:d("archives.modal.removeTimelapse"),message:d("archives.modal.removeTimelapseConfirm",{name:t.print_name||t.filename}),confirmText:d("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{fe.mutate(),K(!1)},onCancel:()=>K(!1)}),T&&a.jsx(Vne,{x:T.x,y:T.y,items:ke,onClose:()=>E(null)}),R&&t.timelapse_path&&a.jsx(Oie,{src:ge.getArchiveTimelapse(t.id),title:d("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>M(!1),onEdit:()=>{h.invalidateQueries({queryKey:["archives"]}),M(!1)}}),D&&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:d("archives.modal.selectTimelapse")}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:d("archives.modal.selectTimelapseDesc")})]}),a.jsx("button",{onClick:()=>{G(!1),W([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:U.map(_e=>a.jsxs("button",{onClick:()=>le.mutate(_e.name),disabled:le.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(Fh,{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:_e.name}),a.jsxs("p",{className:"text-sm text-gray-400",children:[ml(_e.size),_e.mtime&&` • ${Uf(_e.mtime,l)}`]})]})]},_e.name))}),a.jsx("div",{className:"p-4 border-t border-gray-700",children:a.jsx(Oe,{variant:"secondary",onClick:()=>{G(!1),W([])},className:"w-full",children:"Cancel"})})]})}),L&&a.jsx(qne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>ee(!1)}),ae&&t.photos&&t.photos.length>0&&a.jsx(Gne,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>Y(!1),onDelete:async _e=>{try{await ge.deleteArchivePhoto(t.id,_e),h.invalidateQueries({queryKey:["archives"]}),f(d("archives.toast.photoDeleted"))}catch{f(d("archives.toast.failedDeletePhoto"),"error")}}}),se&&a.jsx(Lie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>ce(!1)}),ye&&a.jsx(Zu,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Z(!1)}),a.jsx("input",{ref:z,type:"file",accept:".3mf",className:"hidden",onChange:_e=>{const Ae=_e.target.files?.[0];Ae&&I.mutate(Ae),_e.target.value=""}}),a.jsx("input",{ref:V,type:"file",accept:".f3d",className:"hidden",onChange:_e=>{const Ae=_e.target.files?.[0];Ae&&J.mutate(Ae),_e.target.value=""}}),a.jsx("input",{ref:te,type:"file",accept:".mp4,.avi,.mkv",className:"hidden",onChange:_e=>{const Ae=_e.target.files?.[0];Ae&&oe.mutate(Ae),_e.target.value=""}})]})}function TXe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,preferredSlicer:l="bambu_studio",t:c}){const u=Qt(),{showToast:d}=dn(),{hasPermission:h,canModify:f}=Rr(),[p,x]=w.useState(!1),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,A]=w.useState(!1),[C,j]=w.useState(!1),[k,R]=w.useState(!1),[M,D]=w.useState(!1),[G,U]=w.useState([]),[W,L]=w.useState(!1),[ee,ae]=w.useState(!1),[Y,se]=w.useState(!1),[ce,ye]=w.useState(!1),[Z,ue]=w.useState(!1),[pe,be]=w.useState(!1),[Ee,$]=w.useState(null),K=w.useRef(null),T=w.useRef(null),E=w.useRef(null),O=ut({mutationFn:()=>ge.deleteArchiveTimelapse(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseRemoved"))},onError:J=>{d(J.message||c("archives.toast.failedRemoveTimelapse"),"error")}}),q=ut({mutationFn:J=>ge.uploadArchiveTimelapse(t.id,J),onSuccess:J=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseUploaded",{filename:J.filename}))},onError:J=>{d(J.message||c("archives.toast.failedUploadTimelapse"),"error")}}),B=ut({mutationFn:J=>ge.uploadSource3mf(t.id,J),onSuccess:J=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfAttached",{filename:J.filename}))},onError:J=>{d(J.message||c("archives.toast.failedUploadSource3mf"),"error")}}),re=ut({mutationFn:()=>ge.deleteSource3mf(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfRemoved"))},onError:J=>{d(J.message||c("archives.toast.failedRemoveSource3mf"),"error")}}),z=ut({mutationFn:J=>ge.uploadF3d(t.id,J),onSuccess:J=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dAttached",{filename:J.filename}))},onError:J=>{d(J.message||c("archives.toast.failedUploadF3d"),"error")}}),V=ut({mutationFn:()=>ge.deleteF3d(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dRemoved"))},onError:J=>{d(J.message||c("archives.toast.failedRemoveF3d"),"error")}}),te=ut({mutationFn:()=>ge.scanArchiveTimelapse(t.id),onSuccess:J=>{J.status==="attached"?(u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:J.filename}))):J.status==="exists"?d(c("archives.toast.timelapseAlreadyAttached")):J.status==="not_found"&&J.available_files&&J.available_files.length>0?(U(J.available_files),D(!0)):d(J.message||c("archives.toast.noMatchingTimelapse"),"warning")},onError:J=>{d(J.message||c("archives.toast.failedScanTimelapse"),"error")}}),Q=ut({mutationFn:J=>ge.selectArchiveTimelapse(t.id,J),onSuccess:J=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:J.filename})),D(!1),U([])},onError:J=>{d(J.message||c("archives.toast.failedAttachTimelapse"),"error")}}),ne=ut({mutationFn:()=>ge.deleteArchive(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.archiveDeleted"))},onError:()=>{d(c("archives.toast.failedDeleteArchive"),"error")}}),ie=ut({mutationFn:()=>ge.toggleFavorite(t.id),onSuccess:J=>{u.invalidateQueries({queryKey:["archives"]}),d(J.is_favorite?c("archives.toast.addedToFavorites"):c("archives.toast.removedFromFavorites"))}}),{data:me}=Je({queryKey:["archive-folders",t.id],queryFn:()=>ge.getLibraryFoldersByArchive(t.id)}),fe=ut({mutationFn:J=>ge.updateArchive(t.id,{project_id:J}),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),u.invalidateQueries({queryKey:["projects"]}),d(c("archives.toast.projectUpdated"))},onError:()=>{d(c("archives.toast.failedUpdateProject"),"error")}}),oe=J=>{J.preventDefault(),$({x:J.clientX,y:J.clientY})},F=[...wh(t.filename)?[{label:c("archives.menu.print"),icon:a.jsx(Dr,{className:"w-4 h-4"}),onClick:()=>_(!0),disabled:!t.file_path||!f("archives","reprint",t.created_by_id),title:t.file_path?f("archives","reprint",t.created_by_id)?void 0:c("archives.permission.noReprint"):c("archives.card.noFileForReprint")},{label:c("archives.menu.schedule"),icon:a.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.file_path||!h("queue:create"),title:t.file_path?h("queue:create")?void 0:c("archives.permission.noAddToQueue"):c("archives.card.noFileForReprint")},{label:c("archives.menu.openInBambuStudio"),icon:a.jsx(aa,{className:"w-4 h-4"}),onClick:()=>{const J=t.print_name||t.filename||"model";Sh(t.id,J,"file",l)},disabled:!t.file_path,title:t.file_path?void 0:c("archives.card.noFileForReprint")}]:[{label:c("archives.menu.slice"),icon:a.jsx(aa,{className:"w-4 h-4"}),onClick:()=>{const J=t.print_name||t.filename||"model";Sh(t.id,J,"file",l)}}],{label:t.external_url?c("archives.menu.externalLink"):c("archives.menu.viewOnMakerWorld"),icon:a.jsx(Lh,{className:"w-4 h-4"}),onClick:()=>{const J=t.external_url||t.makerworld_url;J&&window.open(J,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.preview3d"),icon:a.jsx(ni,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:c("archives.menu.viewTimelapse"),icon:a.jsx(Fh,{className:"w-4 h-4"}),onClick:()=>R(!0),disabled:!t.timelapse_path},{label:c("archives.menu.scanForTimelapse"),icon:a.jsx(R1,{className:"w-4 h-4"}),onClick:()=>te.mutate(),disabled:!t.printer_id||!!t.timelapse_path||te.isPending||!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.uploadTimelapse"),icon:a.jsx(Ia,{className:"w-4 h-4"}),onClick:()=>E.current?.click(),disabled:!!t.timelapse_path||!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.timelapse_path?[{label:c("archives.menu.removeTimelapse"),icon:a.jsx(Xt,{className:"w-4 h-4"}),onClick:()=>be(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("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(P1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?ge.downloadSource3mf(t.id).catch(J=>{console.error("Source 3MF download failed:",J)}):K.current?.click()},disabled:!t.source_3mf_path&&!f("archives","update",t.created_by_id),title:!t.source_3mf_path&&!f("archives","update",t.created_by_id)?c("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:c("archives.menu.replaceSource3mf"),icon:a.jsx(Ia,{className:"w-4 h-4"}),onClick:()=>K.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.removeSource3mf"),icon:a.jsx(Xt,{className:"w-4 h-4"}),onClick:()=>ye(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("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(ni,{className:"w-4 h-4"}),onClick:()=>T.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:c("archives.menu.downloadF3d"),icon:a.jsx(ba,{className:"w-4 h-4"}),onClick:()=>{ge.downloadF3d(t.id).catch(J=>{console.error("F3D download failed:",J)})}},{label:c("archives.menu.removeF3d"),icon:a.jsx(Xt,{className:"w-4 h-4"}),onClick:()=>ue(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.download"),icon:a.jsx(ba,{className:"w-4 h-4"}),onClick:()=>{ge.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(J=>{console.error("Archive download failed:",J)})},disabled:!h("archives:read"),title:h("archives:read")?void 0:c("archives.permission.noDownload")},{label:c("archives.menu.copyDownloadLink"),icon:a.jsx(ec,{className:"w-4 h-4"}),onClick:()=>{const J=`${window.location.origin}${ge.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(J).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(HY,{className:"w-4 h-4"}),onClick:()=>L(!0)},{label:t.photos?.length?c("archives.menu.viewPhotosCount",{count:t.photos.length}):c("archives.menu.viewPhotos"),icon:a.jsx(xb,{className:"w-4 h-4"}),onClick:()=>ae(!0),disabled:!t.photos?.length},{label:c("archives.menu.projectPage"),icon:a.jsx(Es,{className:"w-4 h-4"}),onClick:()=>se(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?c("archives.menu.removeFromFavorites"):c("archives.menu.addToFavorites"),icon:a.jsx(If,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ie.mutate(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.edit"),icon:a.jsx(Ka,{className:"w-4 h-4"}),onClick:()=>x(!0),disabled:!f("archives","update",t.created_by_id),title:f("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(xs,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:c("archives.menu.addToProject"),icon:a.jsx(xs,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const J=[];if(t.project_id&&J.push({label:c("archives.menu.removeFromProject"),icon:a.jsx(Ut,{className:"w-4 h-4"}),onClick:()=>fe.mutate(null)}),!s)J.push({label:c("archives.menu.loading"),icon:a.jsx(lt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const xe=s.filter(he=>he.status==="active");xe.length===0?J.push({label:c("archives.menu.noProjectsAvailable"),icon:a.jsx(xs,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):xe.forEach(he=>{J.push({label:he.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:he.color||"#888"}}),onClick:()=>fe.mutate(he.id),disabled:t.project_id===he.id})})}return J})()},{label:c(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(uo,{className:"w-4 h-4"}):a.jsx(_l,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.delete"),icon:a.jsx(Xt,{className:"w-4 h-4"}),onClick:()=>g(!0),danger:!0,disabled:!f("archives","delete",t.created_by_id),title:f("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:oe,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(uo,{className:"w-4 h-4 text-bambu-green"}):a.jsx(_l,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?a.jsx("img",{src:ge.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(nd,{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.status==="failed"||t.status==="aborted")&&a.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] leading-tight bg-status-error/80 text-white flex-shrink-0",children:t.status==="aborted"?c("archives.card.cancelled"):c("archives.card.failed")}),t.timelapse_path&&a.jsx("span",{title:c("archives.list.hasTimelapse"),children:a.jsx(Fh,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),me&&me.length>0&&a.jsx(Zs,{to:`/files?folder=${me[0].id}`,className:"flex-shrink-0",title:c("archives.card.openFolder",{name:me[0].name}),onClick:J=>J.stopPropagation(),children:a.jsx(nc,{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((J,xe)=>a.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:J},title:J},xe))})]})]}),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:wb(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(id,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:ml(t.file_size)}),a.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[wh(t.filename)&&a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>_(!0),disabled:!f("archives","reprint",t.created_by_id),title:f("archives","reprint",t.created_by_id)?c("archives.card.reprint"):c("archives.card.noPermissionReprint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:a.jsx(lo,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{const J=t.print_name||t.filename||"model";Sh(t.id,J,"file",l)},title:c("archives.card.openInBambuStudio"),children:a.jsx(aa,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&a.jsx(Oe,{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(Lh,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{ge.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(J=>{console.error("Archive download failed:",J)})},title:c("archives.card.download"),children:a.jsx(ba,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>x(!0),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?c("archives.card.edit"):c("archives.card.noPermissionEdit"),children:a.jsx(Ka,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>g(!0),disabled:!f("archives","delete",t.created_by_id),title:f("archives","delete",t.created_by_id)?c("archives.card.delete"):c("archives.card.noPermissionDelete"),children:a.jsx(Xt,{className:"w-4 h-4 text-red-400"})}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:J=>{const xe=J.currentTarget.getBoundingClientRect();$({x:xe.left,y:xe.bottom+4})},title:c("archives.card.moreOptions"),children:a.jsx(Rh,{className:"w-4 h-4"})})]})]}),p&&a.jsx($ne,{archive:t,onClose:()=>x(!1)}),C&&a.jsx(AO,{archiveId:t.id,title:t.print_name||t.filename,fileType:Iie(t.filename),onClose:()=>j(!1)}),y&&a.jsx(Zu,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>_(!1)}),v&&a.jsx(Sn,{title:c("archives.modal.deleteArchive"),message:c("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{ne.mutate(),g(!1)},onCancel:()=>g(!1)}),ce&&a.jsx(Sn,{title:c("archives.modal.removeSource3mf"),message:c("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{re.mutate(),ye(!1)},onCancel:()=>ye(!1)}),Z&&a.jsx(Sn,{title:c("archives.modal.removeF3d"),message:c("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{V.mutate(),ue(!1)},onCancel:()=>ue(!1)}),pe&&a.jsx(Sn,{title:c("archives.modal.removeTimelapse"),message:c("archives.modal.removeTimelapseConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{O.mutate(),be(!1)},onCancel:()=>be(!1)}),Ee&&a.jsx(Vne,{x:Ee.x,y:Ee.y,items:F,onClose:()=>$(null)}),k&&t.timelapse_path&&a.jsx(Oie,{src:ge.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)}}),M&&G.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:c("archives.modal.selectTimelapse")}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:c("archives.modal.selectTimelapseDesc")})]}),a.jsx("button",{onClick:()=>{D(!1),U([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:G.map(J=>a.jsxs("button",{onClick:()=>Q.mutate(J.name),disabled:Q.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:J.name}),a.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[a.jsx("span",{children:ml(J.size)}),J.mtime&&a.jsx("span",{children:wb(J.mtime)})]})]},J.name))})]})}),W&&a.jsx(qne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>L(!1)}),ee&&t.photos&&a.jsx(Gne,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>ae(!1),onDelete:async J=>{try{await ge.deleteArchivePhoto(t.id,J),u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.photoDeleted"))}catch{d(c("archives.toast.failedDeletePhoto"),"error")}}}),Y&&a.jsx(Lie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>se(!1)}),N&&a.jsx(Zu,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>A(!1)}),a.jsx("input",{ref:K,type:"file",accept:".3mf",className:"hidden",onChange:J=>{const xe=J.target.files?.[0];xe&&B.mutate(xe),J.target.value=""}}),a.jsx("input",{ref:T,type:"file",accept:".f3d",className:"hidden",onChange:J=>{const xe=J.target.files?.[0];xe&&z.mutate(xe),J.target.value=""}}),a.jsx("input",{ref:E,type:"file",accept:".mp4,.avi,.mkv",className:"hidden",onChange:J=>{const xe=J.target.files?.[0];xe&&q.mutate(xe),J.target.value=""}})]})}const MXe=[{id:"all",label:"All Archives",icon:a.jsx(nc,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:a.jsx(Xn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:a.jsx(Xr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:a.jsx(Xr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:a.jsx(If,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:a.jsx(qa,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:a.jsx(ec,{className:"w-4 h-4"})}];function PXe(){const{t}=Et(),e=Qt(),{showToast:n}=dn(),{hasPermission:r,hasAnyPermission:i}=Rr(),s=w.useRef(null),[o,l]=w.useState(""),[c,u]=w.useState(()=>{const De=localStorage.getItem("archiveFilterPrinter");return De?Number(De):null}),[d,h]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[f,p]=w.useState(()=>{const De=localStorage.getItem("archiveFilterColors");return De?new Set(JSON.parse(De)):new Set}),[x,v]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[g,y]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[_,N]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[A,C]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[j,k]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[R,M]=w.useState(!1),[D,G]=w.useState([]),[U,W]=w.useState(!1),[L,ee]=w.useState(new Set),[ae,Y]=w.useState(!1),[se,ce]=w.useState(!1),[ye,Z]=w.useState(!1),[ue,pe]=w.useState(!1),[be,Ee]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[$,K]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[T,E]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[O,q]=w.useState(!1),[B,re]=w.useState(!1),[z,V]=w.useState(!1),[te,Q]=w.useState(!1),[ne,ie]=w.useState(null),[me,fe]=w.useState(()=>localStorage.getItem("logFilterUser")||null),[oe,I]=w.useState(()=>localStorage.getItem("logFilterStatus")),[F,J]=w.useState(()=>localStorage.getItem("logFilterDateFrom")||""),[xe,he]=w.useState(()=>localStorage.getItem("logFilterDateTo")||""),[le,Ce]=w.useState(()=>{const De=localStorage.getItem("logOffset");return De?Number(De):0}),[Ne,Ue]=w.useState(!1),[He,de]=w.useState(()=>{const De=localStorage.getItem("logPageSize");return De?Number(De):25});w.useEffect(()=>{if(ne){const De=setTimeout(()=>{const st=document.querySelector(`[data-archive-id="${ne}"]`);st&&st.scrollIntoView({behavior:"smooth",block:"center"})},100),Ze=setTimeout(()=>ie(null),5e3);return()=>{clearTimeout(De),clearTimeout(Ze)}}},[ne]);const{data:we,isLoading:ke}=Je({queryKey:["archives",c],queryFn:()=>ge.getArchives(c||void 0)}),{data:_e}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:Ae}=Je({queryKey:["projects"],queryFn:()=>ge.getProjects()}),{data:Ve}=Je({queryKey:["settings"],queryFn:ge.getSettings}),{data:Te}=Je({queryKey:["users"],queryFn:ge.getUsers,enabled:be==="log"}),{data:Ke,isLoading:je}=Je({queryKey:["print-log",c,me,oe,F,xe,o,le,He],queryFn:()=>ge.getPrintLog({search:o||void 0,printerId:c||void 0,username:me||void 0,status:oe||void 0,dateFrom:F||void 0,dateTo:xe||void 0,limit:He,offset:le}),enabled:be==="log"}),qe=Ve?.time_format||"system",Re=Ve?.preferred_slicer||"bambu_studio",Pe=sl(Ve?.currency||"USD"),Be=ut({mutationFn:async De=>(await Promise.all(De.map(Ze=>ge.deleteArchive(Ze))),De.length),onSuccess:De=>{e.invalidateQueries({queryKey:["archives"]}),ee(new Set),n(`${De} archive${De!==1?"s":""} deleted`)},onError:()=>{n(t("archives.toast.failedDeleteArchives"),"error")}}),We=ut({mutationFn:()=>ge.clearPrintLog(),onSuccess:De=>{e.invalidateQueries({queryKey:["print-log"]}),Ce(0),n(t("archives.log.cleared",{count:De.deleted}))},onError:()=>{n(t("archives.log.clearFailed"),"error")}});w.useEffect(()=>{c!==null?localStorage.setItem("archiveFilterPrinter",c.toString()):localStorage.removeItem("archiveFilterPrinter")},[c]),w.useEffect(()=>{d?localStorage.setItem("archiveFilterMaterial",d):localStorage.removeItem("archiveFilterMaterial")},[d]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...f]))},[f]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",x)},[x]),w.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",g.toString())},[g]),w.useEffect(()=>{localStorage.setItem("archiveHideFailed",_.toString())},[_]),w.useEffect(()=>{A?localStorage.setItem("archiveFilterTag",A):localStorage.removeItem("archiveFilterTag")},[A]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",j)},[j]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",be)},[be]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",$)},[$]),w.useEffect(()=>{localStorage.setItem("archiveCollection",T)},[T]),w.useEffect(()=>{me?localStorage.setItem("logFilterUser",me):localStorage.removeItem("logFilterUser")},[me]),w.useEffect(()=>{oe?localStorage.setItem("logFilterStatus",oe):localStorage.removeItem("logFilterStatus")},[oe]),w.useEffect(()=>{F?localStorage.setItem("logFilterDateFrom",F):localStorage.removeItem("logFilterDateFrom")},[F]),w.useEffect(()=>{xe?localStorage.setItem("logFilterDateTo",xe):localStorage.removeItem("logFilterDateTo")},[xe]),w.useEffect(()=>{localStorage.setItem("logOffset",le.toString())},[le]),w.useEffect(()=>{localStorage.setItem("logPageSize",He.toString())},[He]);const ct=new Map(_e?.map(De=>[De.id,De.name])||[]),St=[...new Set(we?.flatMap(De=>De.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),Mt=[...new Set(we?.flatMap(De=>De.filament_color?.split(",")||[]).filter(Boolean)||[])],yt=[...new Set(we?.flatMap(De=>De.tags?.split(",").map(Ze=>Ze.trim())||[]).filter(Boolean)||[])].sort(),$e=we?.filter(De=>{const Ze=new Date,st=Jn(De.created_at)||new Date(0);let Ye=!0;switch(T){case"recent":Ye=Ze.getTime()-st.getTime()<1440*60*1e3;break;case"this-week":Ye=Ze.getTime()-st.getTime()<10080*60*1e3;break;case"this-month":Ye=st.getMonth()===Ze.getMonth()&&st.getFullYear()===Ze.getFullYear();break;case"favorites":Ye=De.is_favorite===!0;break;case"failed":Ye=De.status==="failed"||De.status==="aborted";break;case"duplicates":Ye=De.duplicate_count>0;break}const It=(De.print_name||De.filename).toLowerCase().includes(o.toLowerCase()),Me=!d||De.filament_type?.split(", ").includes(d),Ge=De.filament_color?.split(",")||[],et=f.size===0||(x==="or"?Ge.some(jt=>f.has(jt)):[...f].every(jt=>Ge.includes(jt))),Qe=T==="favorites"||!g||De.is_favorite,Le=T==="failed"||!_||De.status!=="failed"&&De.status!=="aborted",ht=De.tags?.split(",").map(jt=>jt.trim())||[],it=!A||ht.includes(A),tt=wh(De.filename);return Ye&&It&&Me&&et&&Qe&&Le&&it&&(j==="all"||j==="gcode"&&tt||j==="source"&&!tt)}).sort((De,Ze)=>{switch($){case"date-desc":return(Jn(Ze.created_at)?.getTime()||0)-(Jn(De.created_at)?.getTime()||0);case"date-asc":return(Jn(De.created_at)?.getTime()||0)-(Jn(Ze.created_at)?.getTime()||0);case"name-asc":return(De.print_name||De.filename).localeCompare(Ze.print_name||Ze.filename);case"name-desc":return(Ze.print_name||Ze.filename).localeCompare(De.print_name||De.filename);case"size-desc":return Ze.file_size-De.file_size;case"size-asc":return De.file_size-Ze.file_size;default:return 0}}),dt=ae||L.size>0,gt=De=>{ee(Ze=>{const st=new Set(Ze);return st.has(De)?st.delete(De):st.add(De),st})},Lt=()=>{$e&&ee(new Set($e.map(De=>De.id)))},en=()=>{ee(new Set),Y(!1)},pn=De=>{p(Ze=>{const st=new Set(Ze);return st.has(De)?st.delete(De):st.add(De),st})},_n=()=>{p(new Set)},hn=()=>{l(""),u(null),h(null),y(!1),N(!1),C(null),k("all")},gn=o||c||d||g||_||A||j!=="all",On=w.useCallback(De=>{De.preventDefault(),De.dataTransfer.types.includes("Files")&&W(!0)},[]),Dn=w.useCallback(De=>{De.preventDefault(),De.currentTarget===De.target&&W(!1)},[]),zn=w.useCallback(De=>{De.preventDefault(),W(!1);const Ze=Array.from(De.dataTransfer.files).filter(st=>st.name.endsWith(".3mf"));Ze.length>0?(G(Ze),M(!0)):De.dataTransfer.files.length>0&&n(t("archives.page.only3mfSupported"),"warning")},[n,t]),ze=w.useCallback(De=>{const Ze=De.target;if(Ze.tagName==="INPUT"||Ze.tagName==="TEXTAREA"||Ze.isContentEditable){De.key==="Escape"&&Ze.blur();return}switch(De.key){case"/":De.preventDefault(),s.current?.focus();break;case"u":case"U":!De.metaKey&&!De.ctrlKey&&(De.preventDefault(),M(!0));break;case"Escape":dt&&en();break}},[dt]);return w.useEffect(()=>(document.addEventListener("keydown",ze),()=>document.removeEventListener("keydown",ze)),[ze]),a.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:On,onDragLeave:Dn,onDrop:zn,children:[U&&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(Ia,{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")})]})}),dt&&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(Oe,{variant:"secondary",size:"sm",onClick:en,children:[a.jsx(Ut,{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:[L.size," selected"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:Lt,children:"Select All"}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>Z(!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(ad,{className:"w-4 h-4"}),"Tags"]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>pe(!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(xs,{className:"w-4 h-4"}),"Project"]}),a.jsxs(Oe,{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 De=Array.from(L);Promise.all(De.map(Ze=>ge.toggleFavorite(Ze))).then(()=>{e.invalidateQueries({queryKey:["archives"]}),n(`Toggled favorites for ${De.length} archive${De.length!==1?"s":""}`)}).catch(()=>{n(t("archives.toast.failedUpdateFavorites"),"error")})},children:[a.jsx(If,{className:"w-4 h-4"}),"Favorite"]}),a.jsxs(Oe,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>ce(!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(Xt,{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:T,onChange:De=>E(De.target.value),children:MXe.map(De=>a.jsx("option",{value:De.id,children:De.label},De.id))})]}),a.jsxs("p",{className:"text-bambu-gray",children:[$e?.length||0," of ",we?.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(Oe,{variant:"secondary",onClick:()=>q(!O),disabled:B,children:[B?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(j1,{className:"w-4 h-4"}),"Export"]}),O&&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()=>{q(!1),re(!0);try{const{blob:De,filename:Ze}=await ge.exportArchives({format:"csv",printerId:c||void 0,status:T==="failed"?"failed":void 0,search:o||void 0}),st=URL.createObjectURL(De),Ye=document.createElement("a");Ye.href=st,Ye.download=Ze,Ye.click(),URL.revokeObjectURL(st),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{re(!1)}},children:[a.jsx(Es,{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()=>{q(!1),re(!0);try{const{blob:De,filename:Ze}=await ge.exportArchives({format:"xlsx",printerId:c||void 0,status:T==="failed"?"failed":void 0,search:o||void 0}),st=URL.createObjectURL(De),Ye=document.createElement("a");Ye.href=st,Ye.download=Ze,Ye.click(),URL.revokeObjectURL(st),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{re(!1)}},children:[a.jsx(j1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),L.size>=2&&L.size<=5&&a.jsxs(Oe,{variant:"secondary",onClick:()=>V(!0),children:[a.jsx(tb,{className:"w-4 h-4"}),"Compare (",L.size,")"]}),!dt&&a.jsxs(Oe,{variant:"secondary",onClick:()=>Y(!0),children:[a.jsx(uo,{className:"w-4 h-4"}),"Select"]}),a.jsxs(Oe,{onClick:()=>M(!0),disabled:!r("archives:create"),title:r("archives:create")?void 0:t("archives.permission.noCreate"),children:[a.jsx(Ia,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),a.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0 w-fit mb-4",children:[a.jsx("button",{className:`p-2 ${be==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Ee("grid"),title:t("archives.gridView"),children:a.jsx(wv,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${be==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Ee("list"),title:t("archives.listView"),children:a.jsx(tC,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${be==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Ee("calendar"),title:t("archives.calendarView"),children:a.jsx(jhe,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${be==="log"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Ee("log"),title:t("archives.logView"),children:a.jsx(eme,{className:"w-4 h-4"})})]}),be!=="log"&&a.jsx(Ct,{className:"mb-6",children:a.jsxs(Tt,{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(Er,{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:De=>l(De.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(Jk,{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:De=>u(De.target.value?Number(De.target.value):null),children:[a.jsx("option",{value:"",children:"All Printers"}),_e?.map(De=>a.jsx("option",{value:De.id,children:De.name},De.id))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(si,{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:De=>h(De.target.value||null),children:[a.jsx("option",{value:"",children:"All Materials"}),St.map(De=>a.jsx("option",{value:De,children:De},De))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(P1,{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:j,onChange:De=>k(De.target.value),children:[a.jsx("option",{value:"all",children:"All Files"}),a.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),a.jsx("option",{value:"source",children:"Source Only"})]})]}),a.jsxs("button",{onClick:()=>y(!g),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${g?"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(g?"archives.showAll":"archives.showFavoritesOnly"),children:[a.jsx(If,{className:`w-4 h-4 ${g?"fill-yellow-400":""}`}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),a.jsxs("button",{onClick:()=>N(!_),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${_?"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(_?"archives.showFailedPrints":"archives.hideFailedPrints"),children:[a.jsx(qa,{className:"w-4 h-4 "}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),yt.length>0&&a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(ad,{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:De=>C(De.target.value||null),children:[a.jsx("option",{value:"",children:"All Tags"}),yt.map(De=>a.jsx("option",{value:De,children:De},De))]}),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(oC,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(OF,{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:$,onChange:De=>K(De.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")})]})]})]}),gn&&a.jsxs(Oe,{variant:"ghost",size:"sm",onClick:hn,className:"text-bambu-gray hover:text-white",children:[a.jsx(Ut,{className:"w-4 h-4"}),"Reset"]})]}),Mt.length>0&&a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),f.size>1&&a.jsx("button",{onClick:()=>v(De=>De==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${x==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:x==="or"?"Match ANY selected color":"Match ALL selected colors",children:x.toUpperCase()}),a.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:Mt.map(De=>a.jsx("button",{onClick:()=>pn(De),className:`w-6 h-6 rounded-full border-2 transition-all ${f.has(De)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:De},title:De},De))}),f.size>0&&a.jsxs("button",{onClick:_n,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[a.jsx(Ut,{className:"w-3 h-3"}),"Clear"]})]})]})}),a.jsx(kXe,{}),ke?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("archives.loadingArchives")}):$e?.length===0?a.jsx(Ct,{children:a.jsxs(Tt,{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"})]})}):be==="calendar"?a.jsx(Ct,{className:"p-6",children:a.jsx(g7e,{archives:$e||[],onArchiveClick:De=>{l(""),Ee("grid"),ie(De.id)},highlightedArchiveId:ne})}):be==="grid"?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:$e?.map(De=>a.jsx(AXe,{archive:De,printerName:De.printer_id?ct.get(De.printer_id)||"Unknown":De.sliced_for_model?`Sliced for ${De.sliced_for_model}`:"No Printer",isSelected:L.has(De.id),onSelect:gt,selectionMode:dt,projects:Ae,isHighlighted:De.id===ne,timeFormat:qe,preferredSlicer:Re,currency:Pe,t},De.id))}):be==="list"?a.jsx(Ct,{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"})]}),$e?.map(De=>a.jsx(TXe,{archive:De,printerName:De.printer_id?ct.get(De.printer_id)||"Unknown":De.sliced_for_model?`Sliced for ${De.sliced_for_model}`:"No Printer",isSelected:L.has(De.id),onSelect:gt,selectionMode:dt,projects:Ae,isHighlighted:De.id===ne,preferredSlicer:Re,t},De.id))]})}):be==="log"?a.jsxs("div",{className:"space-y-4",children:[a.jsx(Ct,{children:a.jsx(Tt,{className:"py-3",children:a.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:items-center md:flex-wrap",children:[a.jsxs("div",{className:"flex-1 relative md:min-w-[200px]",children:[a.jsx(Er,{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("archives.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",value:o,onChange:De=>{l(De.target.value),Ce(0)}})]}),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 text-sm",value:c||"",onChange:De=>{u(De.target.value?Number(De.target.value):null),Ce(0)},children:[a.jsx("option",{value:"",children:t("archives.log.allPrinters")}),_e?.map(De=>a.jsx("option",{value:De.id,children:De.name},De.id))]}),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 text-sm",value:me||"",onChange:De=>{fe(De.target.value||null),Ce(0)},children:[a.jsx("option",{value:"",children:t("archives.log.allUsers")}),Te?.map(De=>a.jsx("option",{value:De.username,children:De.username},De.id))]}),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 text-sm",value:oe||"",onChange:De=>{I(De.target.value||null),Ce(0)},children:[a.jsx("option",{value:"",children:t("archives.log.allStatuses")}),a.jsx("option",{value:"completed",children:t("archives.status.completed")}),a.jsx("option",{value:"failed",children:t("archives.status.failed")}),a.jsx("option",{value:"stopped",children:t("archives.status.stopped")}),a.jsx("option",{value:"cancelled",children:t("archives.log.cancelled")}),a.jsx("option",{value:"skipped",children:t("archives.log.skipped")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"text-sm text-bambu-gray",children:t("archives.log.dateFrom")}),a.jsx("input",{type:"date",className:"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:F,onChange:De=>{J(De.target.value),Ce(0)}})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"text-sm text-bambu-gray",children:t("archives.log.dateTo")}),a.jsx("input",{type:"date",className:"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:xe,onChange:De=>{he(De.target.value),Ce(0)}})]}),a.jsx("div",{className:"ml-auto",children:a.jsxs(Oe,{variant:"danger",size:"sm",onClick:()=>Ue(!0),disabled:!r("archives:delete_all")||We.isPending,children:[a.jsx(Xt,{className:"w-4 h-4"}),t("archives.log.clearLog")]})})]})})}),a.jsx(Ct,{children:je?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):Ke?.items.length?a.jsxs(a.Fragment,{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:"border-b border-bambu-dark-tertiary text-bambu-gray text-left",children:[a.jsx("th",{className:"px-4 py-3 font-medium",children:t("archives.log.date")}),a.jsx("th",{className:"px-4 py-3 font-medium",children:t("archives.log.printName")}),a.jsx("th",{className:"px-4 py-3 font-medium",children:t("archives.log.printer")}),a.jsx("th",{className:"px-4 py-3 font-medium",children:t("archives.log.user")}),a.jsx("th",{className:"px-4 py-3 font-medium",children:t("archives.log.status")}),a.jsx("th",{className:"px-4 py-3 font-medium",children:t("archives.log.duration")}),a.jsx("th",{className:"px-4 py-3 font-medium",children:t("archives.log.filament")})]})}),a.jsx("tbody",{className:"divide-y divide-bambu-dark-tertiary",children:Ke.items.map(De=>a.jsxs("tr",{className:"hover:bg-bambu-dark-secondary/50",children:[a.jsx("td",{className:"px-4 py-3 text-white whitespace-nowrap",children:Uf(De.started_at||De.created_at,qe)}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[De.thumbnail_path&&a.jsx("img",{src:ge.getPrintLogThumbnail(De.id),alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0",onError:Ze=>{Ze.target.style.display="none"}}),a.jsx("span",{className:"text-white truncate max-w-[200px]",children:De.print_name||"—"})]})}),a.jsx("td",{className:"px-4 py-3 text-bambu-gray-light",children:De.printer_name||"—"}),a.jsx("td",{className:"px-4 py-3 text-bambu-gray-light",children:De.created_by_username||"—"}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${De.status==="completed"?"bg-green-500/20 text-green-400":De.status==="failed"?"bg-red-500/20 text-red-400":De.status==="stopped"?"bg-yellow-500/20 text-yellow-400":De.status==="cancelled"?"bg-orange-500/20 text-orange-400":De.status==="skipped"?"bg-blue-500/20 text-blue-400":"bg-gray-500/20 text-gray-400"}`,children:De.status})}),a.jsx("td",{className:"px-4 py-3 text-bambu-gray-light whitespace-nowrap",children:De.duration_seconds?js(De.duration_seconds):"—"}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-1.5",children:[De.filament_color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:De.filament_color.startsWith("#")?De.filament_color:void 0}}),a.jsx("span",{className:"text-bambu-gray-light text-xs",children:De.filament_type||"—"})]})})]},De.id))})]})}),a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-bambu-dark-tertiary flex-wrap gap-2",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t("archives.log.showing",{count:Math.min(le+He,Ke.total),total:Ke.total})}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:t("archives.log.rowsPerPage")}),a.jsxs("select",{className:"px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-xs focus:border-bambu-green focus:outline-none",value:He,onChange:De=>{de(Number(De.target.value)),Ce(0)},children:[a.jsx("option",{value:10,children:"10"}),a.jsx("option",{value:25,children:"25"}),a.jsx("option",{value:50,children:"50"}),a.jsx("option",{value:100,children:"100"})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("archives.log.page")," ",Math.floor(le/He)+1," / ",Math.max(1,Math.ceil(Ke.total/He))]}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>Ce(Math.max(0,le-He)),disabled:le===0,children:a.jsx(Jl,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>Ce(le+He),disabled:le+He>=Ke.total,children:a.jsx(pi,{className:"w-4 h-4"})})]})]})]}):a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("archives.log.noEntries")})})]}):null,R&&a.jsx(o7e,{onClose:()=>{M(!1),G([])},initialFiles:D}),se&&a.jsx(Sn,{title:t("archives.modal.deleteArchives"),message:t("archives.modal.deleteArchivesConfirm",{count:L.size}),confirmText:t("archives.modal.deleteCount",{count:L.size}),variant:"danger",onConfirm:()=>{Be.mutate(Array.from(L)),ce(!1)},onCancel:()=>ce(!1)}),ye&&a.jsx(u7e,{selectedIds:Array.from(L),existingTags:yt,onClose:()=>Z(!1)}),ue&&a.jsx(d7e,{selectedIds:Array.from(L),onClose:()=>pe(!1)}),z&&L.size>=2&&L.size<=5&&a.jsx(wXe,{archiveIds:Array.from(L),onClose:()=>{V(!1),ee(new Set),Y(!1)}}),te&&a.jsx(CXe,{onClose:()=>Q(!1)}),Ne&&a.jsx(Sn,{title:t("archives.log.clearLogTitle"),message:t("archives.log.clearLogConfirm"),confirmText:t("archives.log.clearLogButton"),variant:"danger",onConfirm:()=>{We.mutate(),Ue(!1)},onCancel:()=>Ue(!1)})]})}function jXe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const EA=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function xx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function pI(t){return"nodeType"in t}function fo(t){var e,n;return t?xx(t)?t:pI(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function gI(t){const{Document:e}=fo(t);return t instanceof e}function Jv(t){return xx(t)?!1:t instanceof fo(t).HTMLElement}function zie(t){return t instanceof fo(t).SVGElement}function yx(t){return t?xx(t)?t.document:pI(t)?gI(t)?t:Jv(t)||zie(t)?t.ownerDocument:document:document:document}const Gc=EA?w.useLayoutEffect:w.useEffect;function bI(t){const e=w.useRef(t);return Gc(()=>{e.current=t}),w.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function EXe(){const t=w.useRef(null),e=w.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=w.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function dv(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return Gc(()=>{n.current!==t&&(n.current=t)},e),n}function ew(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function Bk(t){const e=bI(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function dF(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let EE={};function tw(t,e){return w.useMemo(()=>{if(e)return e;const n=EE[t]==null?0:EE[t]+1;return EE[t]=n,t+"-"+n},[t,e])}function Uie(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 pb=Uie(1),hv=Uie(-1);function DXe(t){return"clientX"in t&&"clientY"in t}function xI(t){if(!t)return!1;const{KeyboardEvent:e}=fo(t.target);return e&&t instanceof e}function RXe(t){if(!t)return!1;const{TouchEvent:e}=fo(t.target);return e&&t instanceof e}function hF(t){if(RXe(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 DXe(t)?{x:t.clientX,y:t.clientY}:null}const Gb=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[Gb.Translate.toString(t),Gb.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),rK="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function FXe(t){return t.matches(rK)?t:t.querySelector(rK)}const LXe={display:"none"};function OXe(t){let{id:e,value:n}=t;return Kr.createElement("div",{id:e,style:LXe},n)}function IXe(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Kr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function zXe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Bie=w.createContext(null);function UXe(t){const e=w.useContext(Bie);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function BXe(){const[t]=w.useState(()=>new Set),e=w.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[w.useCallback(r=>{let{type:i,event:s}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,s)})},[t]),e]}const HXe={draggable:`
  8288. To pick up a draggable item, press the space bar.
  8289. While dragging, use the arrow keys to move the item.
  8290. Press space again to drop the item in its new position, or press escape to cancel.
  8291. `},$Xe={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 VXe(t){let{announcements:e=$Xe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=HXe}=t;const{announce:s,announcement:o}=zXe(),l=tw("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),UXe(w.useMemo(()=>({onDragStart(h){let{active:f}=h;s(e.onDragStart({active:f}))},onDragMove(h){let{active:f,over:p}=h;e.onDragMove&&s(e.onDragMove({active:f,over:p}))},onDragOver(h){let{active:f,over:p}=h;s(e.onDragOver({active:f,over:p}))},onDragEnd(h){let{active:f,over:p}=h;s(e.onDragEnd({active:f,over:p}))},onDragCancel(h){let{active:f,over:p}=h;s(e.onDragCancel({active:f,over:p}))}}),[s,e])),!c)return null;const d=Kr.createElement(Kr.Fragment,null,Kr.createElement(OXe,{id:r,value:i.draggable}),Kr.createElement(IXe,{id:l,announcement:o}));return n?Iu.createPortal(d,n):d}var fi;(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"})(fi||(fi={}));function Hk(){}function $k(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Hie(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const ic=Object.freeze({x:0,y:0});function $ie(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Vie(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function qXe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function aK(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 qie(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function iK(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 Gie=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=iK(e,e.left,e.top),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=$ie(iK(c),i);s.push({id:l,data:{droppableContainer:o,value:u}})}}return s.sort(Vie)},GXe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=aK(e),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=aK(c),d=i.reduce((f,p,x)=>f+$ie(u[x],p),0),h=Number((d/4).toFixed(4));s.push({id:l,data:{droppableContainer:o,value:h}})}}return s.sort(Vie)};function WXe(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 KXe=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=WXe(l,e);c>0&&i.push({id:o,data:{droppableContainer:s,value:c}})}}return i.sort(qXe)};function YXe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Wie(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:ic}function XXe(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 QXe=XXe(1);function ZXe(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 JXe(t,e,n){const r=ZXe(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 eQe={ignoreTransform:!1};function vx(t,e){e===void 0&&(e=eQe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=fo(t).getComputedStyle(t);u&&(n=JXe(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 sK(t){return vx(t,{ignoreTransform:!0})}function tQe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function nQe(t,e){return e===void 0&&(e=fo(t).getComputedStyle(t)),e.position==="fixed"}function rQe(t,e){e===void 0&&(e=fo(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 DA(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(gI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Jv(i)||zie(i)||n.includes(i))return n;const s=fo(t).getComputedStyle(i);return i!==t&&rQe(i,s)&&n.push(i),nQe(i,s)?n:r(i.parentNode)}return t?r(t):n}function Kie(t){const[e]=DA(t,1);return e??null}function DE(t){return!EA||!t?null:xx(t)?t:pI(t)?gI(t)||t===yx(t).scrollingElement?window:Jv(t)?t:null:null}function Yie(t){return xx(t)?t.scrollX:t.scrollLeft}function Xie(t){return xx(t)?t.scrollY:t.scrollTop}function mF(t){return{x:Yie(t),y:Xie(t)}}var Ei;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ei||(Ei={}));function Qie(t){return!EA||!t?!1:t===document.scrollingElement}function Zie(t){const e={x:0,y:0},n=Qie(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 aQe={x:.2,y:.2};function iQe(t,e,n,r,i){let{top:s,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=aQe);const{isTop:u,isBottom:d,isLeft:h,isRight:f}=Zie(t),p={x:0,y:0},x={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!u&&s<=e.top+v.height?(p.y=Ei.Backward,x.y=r*Math.abs((e.top+v.height-s)/v.height)):!d&&c>=e.bottom-v.height&&(p.y=Ei.Forward,x.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!f&&l>=e.right-v.width?(p.x=Ei.Forward,x.x=r*Math.abs((e.right-v.width-l)/v.width)):!h&&o<=e.left+v.width&&(p.x=Ei.Backward,x.x=r*Math.abs((e.left+v.width-o)/v.width)),{direction:p,speed:x}}function sQe(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 Jie(t){return t.reduce((e,n)=>pb(e,mF(n)),ic)}function oQe(t){return t.reduce((e,n)=>e+Yie(n),0)}function lQe(t){return t.reduce((e,n)=>e+Xie(n),0)}function cQe(t,e){if(e===void 0&&(e=vx),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);Kie(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const uQe=[["x",["left","right"],oQe],["y",["top","bottom"],lQe]];class yI{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=DA(n),i=Jie(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,o,l]of uQe)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 p0{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 dQe(t){const{EventTarget:e}=fo(t);return t instanceof e?t:yx(t)}function RE(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 ll;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ll||(ll={}));function oK(t){t.preventDefault()}function hQe(t){t.stopPropagation()}var cr;(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"})(cr||(cr={}));const ese={start:[cr.Space,cr.Enter],cancel:[cr.Esc],end:[cr.Space,cr.Enter,cr.Tab]},mQe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case cr.Right:return{...n,x:n.x+25};case cr.Left:return{...n,x:n.x-25};case cr.Down:return{...n,y:n.y+25};case cr.Up:return{...n,y:n.y-25}}};class RA{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 p0(yx(n)),this.windowListeners=new p0(fo(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ll.Resize,this.handleCancel),this.windowListeners.add(ll.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ll.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&cQe(r),n(ic)}handleKeyDown(e){if(xI(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=ese,coordinateGetter:o=mQe,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}:ic;this.referenceCoordinates||(this.referenceCoordinates=d);const h=o(e,{active:n,context:r.current,currentCoordinates:d});if(h){const f=hv(h,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const v of x){const g=e.code,{isTop:y,isRight:_,isLeft:N,isBottom:A,maxScroll:C,minScroll:j}=Zie(v),k=sQe(v),R={x:Math.min(g===cr.Right?k.right-k.width/2:k.right,Math.max(g===cr.Right?k.left:k.left+k.width/2,h.x)),y:Math.min(g===cr.Down?k.bottom-k.height/2:k.bottom,Math.max(g===cr.Down?k.top:k.top+k.height/2,h.y))},M=g===cr.Right&&!_||g===cr.Left&&!N,D=g===cr.Down&&!A||g===cr.Up&&!y;if(M&&R.x!==h.x){const G=v.scrollLeft+f.x,U=g===cr.Right&&G<=C.x||g===cr.Left&&G>=j.x;if(U&&!f.y){v.scrollTo({left:G,behavior:l});return}U?p.x=v.scrollLeft-G:p.x=g===cr.Right?v.scrollLeft-C.x:v.scrollLeft-j.x,p.x&&v.scrollBy({left:-p.x,behavior:l});break}else if(D&&R.y!==h.y){const G=v.scrollTop+f.y,U=g===cr.Down&&G<=C.y||g===cr.Up&&G>=j.y;if(U&&!f.x){v.scrollTo({top:G,behavior:l});return}U?p.y=v.scrollTop-G:p.y=g===cr.Down?v.scrollTop-C.y:v.scrollTop-j.y,p.y&&v.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,pb(hv(h,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}RA.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=ese,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 lK(t){return!!(t&&"distance"in t)}function cK(t){return!!(t&&"delay"in t)}class vI{constructor(e,n,r){var i;r===void 0&&(r=dQe(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=yx(o),this.documentListeners=new p0(this.document),this.listeners=new p0(r),this.windowListeners=new p0(fo(o)),this.initialCoordinates=(i=hF(s))!=null?i:ic,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(ll.Resize,this.handleCancel),this.windowListeners.add(ll.DragStart,oK),this.windowListeners.add(ll.VisibilityChange,this.handleCancel),this.windowListeners.add(ll.ContextMenu,oK),this.documentListeners.add(ll.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(cK(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(lK(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(ll.Click,hQe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ll.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=hF(e))!=null?n:ic,u=hv(i,c);if(!r&&l){if(lK(l)){if(l.tolerance!=null&&RE(u,l.tolerance))return this.handleCancel();if(RE(u,l.distance))return this.handleStart()}if(cK(l)&&RE(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===cr.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const fQe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class FA extends vI{constructor(e){const{event:n}=e,r=yx(n.target);super(e,fQe,r)}}FA.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 pQe={move:{name:"mousemove"},end:{name:"mouseup"}};var fF;(function(t){t[t.RightClick=2]="RightClick"})(fF||(fF={}));class gQe extends vI{constructor(e){super(e,pQe,yx(e.event.target))}}gQe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===fF.RightClick?!1:(r?.({event:n}),!0)}}];const FE={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class bQe extends vI{constructor(e){super(e,FE)}static setup(){return window.addEventListener(FE.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(FE.move.name,e)};function e(){}}}bQe.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 g0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(g0||(g0={}));var Vk;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Vk||(Vk={}));function xQe(t){let{acceleration:e,activator:n=g0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:o=5,order:l=Vk.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:h,threshold:f}=t;const p=vQe({delta:h,disabled:!s}),[x,v]=EXe(),g=w.useRef({x:0,y:0}),y=w.useRef({x:0,y:0}),_=w.useMemo(()=>{switch(n){case g0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case g0.DraggableRect:return i}},[n,i,c]),N=w.useRef(null),A=w.useCallback(()=>{const j=N.current;if(!j)return;const k=g.current.x*y.current.x,R=g.current.y*y.current.y;j.scrollBy(k,R)},[]),C=w.useMemo(()=>l===Vk.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!s||!u.length||!_){v();return}for(const j of C){if(r?.(j)===!1)continue;const k=u.indexOf(j),R=d[k];if(!R)continue;const{direction:M,speed:D}=iQe(j,R,_,e,f);for(const G of["x","y"])p[G][M[G]]||(D[G]=0,M[G]=0);if(D.x>0||D.y>0){v(),N.current=j,x(A,o),g.current=D,y.current=M;return}}g.current={x:0,y:0},y.current={x:0,y:0},v()},[e,A,r,v,s,o,JSON.stringify(_),JSON.stringify(p),x,u,C,d,JSON.stringify(f)])}const yQe={x:{[Ei.Backward]:!1,[Ei.Forward]:!1},y:{[Ei.Backward]:!1,[Ei.Forward]:!1}};function vQe(t){let{delta:e,disabled:n}=t;const r=dF(e);return ew(i=>{if(n||!r||!i)return yQe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ei.Backward]:i.x[Ei.Backward]||s.x===-1,[Ei.Forward]:i.x[Ei.Forward]||s.x===1},y:{[Ei.Backward]:i.y[Ei.Backward]||s.y===-1,[Ei.Forward]:i.y[Ei.Forward]||s.y===1}}},[n,e,r])}function wQe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return ew(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function SQe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...s]},[]),[t,e])}var mv;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(mv||(mv={}));var pF;(function(t){t.Optimized="optimized"})(pF||(pF={}));const uK=new Map;function _Qe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),h=g(),f=dv(h),p=w.useCallback(function(y){y===void 0&&(y=[]),!f.current&&o(_=>_===null?y:_.concat(y.filter(N=>!_.includes(N))))},[f]),x=w.useRef(null),v=ew(y=>{if(h&&!n)return uK;if(!y||y===uK||d.current!==t||s!=null){const _=new Map;for(let N of t){if(!N)continue;if(s&&s.length>0&&!s.includes(N.id)&&N.rect.current){_.set(N.id,N.rect.current);continue}const A=N.node.current,C=A?new yI(c(A),A):null;N.rect.current=C,C&&_.set(N.id,C)}return _}return y},[t,s,n,h,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{h||p()},[n,h]),w.useEffect(()=>{s&&s.length>0&&o(null)},[JSON.stringify(s)]),w.useEffect(()=>{h||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,h,p,...r]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:s!=null};function g(){switch(u){case mv.Always:return!1;case mv.BeforeDragging:return n;default:return!n}}}function tse(t,e){return ew(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function NQe(t,e){return tse(t,e)}function kQe(t){let{callback:e,disabled:n}=t;const r=bI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function LA(t){let{callback:e,disabled:n}=t;const r=bI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function CQe(t){return new yI(vx(t),t)}function dK(t,e,n){e===void 0&&(e=CQe);const[r,i]=w.useState(null);function s(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=kQe({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=LA({callback:s});return Gc(()=>{s(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function AQe(t){const e=tse(t);return Wie(t,e)}const hK=[];function TQe(t){const e=w.useRef(t),n=ew(r=>t?r&&r!==hK&&t&&e.current&&t.parentNode===e.current.parentNode?r:DA(t):hK,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function MQe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(s=>{const o=DE(s.target);o&&n(l=>l?(l.set(o,mF(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const s=r.current;if(t!==s){o(s);const l=t.map(c=>{const u=DE(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,mF(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=DE(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,o)=>pb(s,o),ic):Jie(t):ic,[t,e])}function mK(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==ic;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?hv(t,n.current):ic}function PQe(t){w.useEffect(()=>{if(!EA)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 jQe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=o=>{s(o,e)},n},{}),[t,e])}function nse(t){return w.useMemo(()=>t?tQe(t):null,[t])}const fK=[];function EQe(t,e){e===void 0&&(e=vx);const[n]=t,r=nse(n?fo(n):null),[i,s]=w.useState(fK);function o(){s(()=>t.length?t.map(c=>Qie(c)?r:new yI(e(c),c)):fK)}const l=LA({callback:o});return Gc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function DQe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Jv(e)?e:t}function RQe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(Jv(d)){r(h=>{const f=e(d);return h?{...h,width:f.width,height:f.height}:f});break}},[e]),s=LA({callback:i}),o=w.useCallback(u=>{const d=DQe(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[l,c]=Bk(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const FQe=[{sensor:FA,options:{}},{sensor:RA,options:{}}],LQe={current:{}},y1={draggable:{measure:sK},droppable:{measure:sK,strategy:mv.WhileDragging,frequency:pF.Optimized},dragOverlay:{measure:vx}};class b0 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 OQe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new b0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Hk},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:y1,measureDroppableContainers:Hk,windowRect:null,measuringScheduled:!1},IQe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Hk,draggableNodes:new Map,over:null,measureDroppableContainers:Hk},OA=w.createContext(IQe),rse=w.createContext(OQe);function zQe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new b0}}}function UQe(t,e){switch(e.type){case fi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case fi.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 fi.DragEnd:case fi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case fi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new b0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case fi.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 b0(t.droppable.containers);return o.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case fi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new b0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function BQe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(OA),s=dF(r),o=dF(n?.id);return w.useEffect(()=>{if(!e&&!r&&s&&o!=null){if(!xI(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=FXe(d);if(h){h.focus();break}}})}},[r,e,i,o,s]),null}function HQe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function $Qe(t){return w.useMemo(()=>({draggable:{...y1.draggable,...t?.draggable},droppable:{...y1.droppable,...t?.droppable},dragOverlay:{...y1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function VQe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Gc(()=>{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=Wie(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 f=Kie(u);f&&f.scrollBy({top:h.y,left:h.x})}},[e,o,l,r,n])}const ase=w.createContext({...ic,scaleX:1,scaleY:1});var ph;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(ph||(ph={}));const ise=w.memo(function(e){var n,r,i,s;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=FQe,collisionDetection:h=KXe,measuring:f,modifiers:p,...x}=e;const v=w.useReducer(UQe,void 0,zQe),[g,y]=v,[_,N]=BXe(),[A,C]=w.useState(ph.Uninitialized),j=A===ph.Initialized,{draggable:{active:k,nodes:R,translate:M},droppable:{containers:D}}=g,G=k!=null?R.get(k):null,U=w.useRef({initial:null,translated:null}),W=w.useMemo(()=>{var qe;return k!=null?{id:k,data:(qe=G?.data)!=null?qe:LQe,rect:U}:null},[k,G]),L=w.useRef(null),[ee,ae]=w.useState(null),[Y,se]=w.useState(null),ce=dv(x,Object.values(x)),ye=tw("DndDescribedBy",o),Z=w.useMemo(()=>D.getEnabled(),[D]),ue=$Qe(f),{droppableRects:pe,measureDroppableContainers:be,measuringScheduled:Ee}=_Qe(Z,{dragging:j,dependencies:[M.x,M.y],config:ue.droppable}),$=wQe(R,k),K=w.useMemo(()=>Y?hF(Y):null,[Y]),T=je(),E=NQe($,ue.draggable.measure);VQe({activeNode:k!=null?R.get(k):null,config:T.layoutShiftCompensation,initialRect:E,measure:ue.draggable.measure});const O=dK($,ue.draggable.measure,E),q=dK($?$.parentElement:null),B=w.useRef({activatorEvent:null,active:null,activeNode:$,collisionRect:null,collisions:null,droppableRects:pe,draggableNodes:R,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),re=D.getNodeFor((n=B.current.over)==null?void 0:n.id),z=RQe({measure:ue.dragOverlay.measure}),V=(r=z.nodeRef.current)!=null?r:$,te=j?(i=z.rect)!=null?i:O:null,Q=!!(z.nodeRef.current&&z.rect),ne=AQe(Q?null:O),ie=nse(V?fo(V):null),me=TQe(j?re??$:null),fe=EQe(me),oe=HQe(p,{transform:{x:M.x-ne.x,y:M.y-ne.y,scaleX:1,scaleY:1},activatorEvent:Y,active:W,activeNodeRect:O,containerNodeRect:q,draggingNodeRect:te,over:B.current.over,overlayNodeRect:z.rect,scrollableAncestors:me,scrollableAncestorRects:fe,windowRect:ie}),I=K?pb(K,M):null,F=MQe(me),J=mK(F),xe=mK(F,[O]),he=pb(oe,J),le=te?QXe(te,oe):null,Ce=W&&le?h({active:W,collisionRect:le,droppableRects:pe,droppableContainers:Z,pointerCoordinates:I}):null,Ne=qie(Ce,"id"),[Ue,He]=w.useState(null),de=Q?oe:pb(oe,xe),we=YXe(de,(s=Ue?.rect)!=null?s:null,O),ke=w.useRef(null),_e=w.useCallback((qe,Re)=>{let{sensor:Pe,options:Be}=Re;if(L.current==null)return;const We=R.get(L.current);if(!We)return;const ct=qe.nativeEvent,St=new Pe({active:L.current,activeNode:We,event:ct,options:Be,context:B,onAbort(yt){if(!R.get(yt))return;const{onDragAbort:dt}=ce.current,gt={id:yt};dt?.(gt),_({type:"onDragAbort",event:gt})},onPending(yt,$e,dt,gt){if(!R.get(yt))return;const{onDragPending:en}=ce.current,pn={id:yt,constraint:$e,initialCoordinates:dt,offset:gt};en?.(pn),_({type:"onDragPending",event:pn})},onStart(yt){const $e=L.current;if($e==null)return;const dt=R.get($e);if(!dt)return;const{onDragStart:gt}=ce.current,Lt={activatorEvent:ct,active:{id:$e,data:dt.data,rect:U}};Iu.unstable_batchedUpdates(()=>{gt?.(Lt),C(ph.Initializing),y({type:fi.DragStart,initialCoordinates:yt,active:$e}),_({type:"onDragStart",event:Lt}),ae(ke.current),se(ct)})},onMove(yt){y({type:fi.DragMove,coordinates:yt})},onEnd:Mt(fi.DragEnd),onCancel:Mt(fi.DragCancel)});ke.current=St;function Mt(yt){return async function(){const{active:dt,collisions:gt,over:Lt,scrollAdjustedTranslate:en}=B.current;let pn=null;if(dt&&en){const{cancelDrop:_n}=ce.current;pn={activatorEvent:ct,active:dt,collisions:gt,delta:en,over:Lt},yt===fi.DragEnd&&typeof _n=="function"&&await Promise.resolve(_n(pn))&&(yt=fi.DragCancel)}L.current=null,Iu.unstable_batchedUpdates(()=>{y({type:yt}),C(ph.Uninitialized),He(null),ae(null),se(null),ke.current=null;const _n=yt===fi.DragEnd?"onDragEnd":"onDragCancel";if(pn){const hn=ce.current[_n];hn?.(pn),_({type:_n,event:pn})}})}}},[R]),Ae=w.useCallback((qe,Re)=>(Pe,Be)=>{const We=Pe.nativeEvent,ct=R.get(Be);if(L.current!==null||!ct||We.dndKit||We.defaultPrevented)return;const St={active:ct};qe(Pe,Re.options,St)===!0&&(We.dndKit={capturedBy:Re.sensor},L.current=Be,_e(Pe,Re))},[R,_e]),Ve=SQe(d,Ae);PQe(d),Gc(()=>{O&&A===ph.Initializing&&C(ph.Initialized)},[O,A]),w.useEffect(()=>{const{onDragMove:qe}=ce.current,{active:Re,activatorEvent:Pe,collisions:Be,over:We}=B.current;if(!Re||!Pe)return;const ct={active:Re,activatorEvent:Pe,collisions:Be,delta:{x:he.x,y:he.y},over:We};Iu.unstable_batchedUpdates(()=>{qe?.(ct),_({type:"onDragMove",event:ct})})},[he.x,he.y]),w.useEffect(()=>{const{active:qe,activatorEvent:Re,collisions:Pe,droppableContainers:Be,scrollAdjustedTranslate:We}=B.current;if(!qe||L.current==null||!Re||!We)return;const{onDragOver:ct}=ce.current,St=Be.get(Ne),Mt=St&&St.rect.current?{id:St.id,rect:St.rect.current,data:St.data,disabled:St.disabled}:null,yt={active:qe,activatorEvent:Re,collisions:Pe,delta:{x:We.x,y:We.y},over:Mt};Iu.unstable_batchedUpdates(()=>{He(Mt),ct?.(yt),_({type:"onDragOver",event:yt})})},[Ne]),Gc(()=>{B.current={activatorEvent:Y,active:W,activeNode:$,collisionRect:le,collisions:Ce,droppableRects:pe,draggableNodes:R,draggingNode:V,draggingNodeRect:te,droppableContainers:D,over:Ue,scrollableAncestors:me,scrollAdjustedTranslate:he},U.current={initial:te,translated:le}},[W,$,Ce,le,R,V,te,pe,D,Ue,me,he]),xQe({...T,delta:M,draggingRect:le,pointerCoordinates:I,scrollableAncestors:me,scrollableAncestorRects:fe});const Te=w.useMemo(()=>({active:W,activeNode:$,activeNodeRect:O,activatorEvent:Y,collisions:Ce,containerNodeRect:q,dragOverlay:z,draggableNodes:R,droppableContainers:D,droppableRects:pe,over:Ue,measureDroppableContainers:be,scrollableAncestors:me,scrollableAncestorRects:fe,measuringConfiguration:ue,measuringScheduled:Ee,windowRect:ie}),[W,$,O,Y,Ce,q,z,R,D,pe,Ue,be,me,fe,ue,Ee,ie]),Ke=w.useMemo(()=>({activatorEvent:Y,activators:Ve,active:W,activeNodeRect:O,ariaDescribedById:{draggable:ye},dispatch:y,draggableNodes:R,over:Ue,measureDroppableContainers:be}),[Y,Ve,W,O,y,ye,R,Ue,be]);return Kr.createElement(Bie.Provider,{value:N},Kr.createElement(OA.Provider,{value:Ke},Kr.createElement(rse.Provider,{value:Te},Kr.createElement(ase.Provider,{value:we},u)),Kr.createElement(BQe,{disabled:l?.restoreFocus===!1})),Kr.createElement(VXe,{...l,hiddenTextDescribedById:ye}));function je(){const qe=ee?.autoScrollEnabled===!1,Re=typeof c=="object"?c.enabled===!1:c===!1,Pe=j&&!qe&&!Re;return typeof c=="object"?{...c,enabled:Pe}:{enabled:Pe}}}),qQe=w.createContext(null),pK="button",GQe="Draggable";function WQe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=tw(GQe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:h,over:f}=w.useContext(OA),{role:p=pK,roleDescription:x="draggable",tabIndex:v=0}=i??{},g=c?.id===e,y=w.useContext(g?ase:qQe),[_,N]=Bk(),[A,C]=Bk(),j=jQe(o,e),k=dv(n);Gc(()=>(h.set(e,{id:e,key:s,node:_,activatorNode:A,data:k}),()=>{const M=h.get(e);M&&M.key===s&&h.delete(e)}),[h,e]);const R=w.useMemo(()=>({role:p,tabIndex:v,"aria-disabled":r,"aria-pressed":g&&p===pK?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,v,g,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:R,isDragging:g,listeners:r?void 0:j,node:_,over:f,setNodeRef:N,setActivatorNodeRef:C,transform:y}}function KQe(){return w.useContext(rse)}const YQe="Droppable",XQe={timeout:25};function QQe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=tw(YQe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(OA),d=w.useRef({disabled:n}),h=w.useRef(!1),f=w.useRef(null),p=w.useRef(null),{disabled:x,updateMeasurementsFor:v,timeout:g}={...XQe,...i},y=dv(v??r),_=w.useCallback(()=>{if(!h.current){h.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),p.current=null},g)},[g]),N=LA({callback:_,disabled:x||!o}),A=w.useCallback((R,M)=>{N&&(M&&(N.unobserve(M),h.current=!1),R&&N.observe(R))},[N]),[C,j]=Bk(A),k=dv(e);return w.useEffect(()=>{!N||!C.current||(N.disconnect(),h.current=!1,N.observe(C.current))},[C,N]),w.useEffect(()=>(l({type:fi.RegisterDroppable,element:{id:r,key:s,disabled:n,node:C,rect:f,data:k}}),()=>l({type:fi.UnregisterDroppable,key:s,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:fi.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,l]),{active:o,rect:f,isOver:c?.id===r,node:C,over:c,setNodeRef:j}}function IA(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function ZQe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function V_(t){return t!==null&&t>=0}function JQe(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 eZe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const wI=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=IA(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}},q_={scaleX:1,scaleY:1},tZe=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,...q_}:null}const c=nZe(s,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...q_}:i<n&&i>=o?{x:0,y:l.height+c,...q_}:{x:0,y:0,...q_}};function nZe(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 sse="Sortable",ose=Kr.createContext({activeIndex:-1,containerId:sse,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:wI,disabled:{draggable:!1,droppable:!1}});function lse(t){let{children:e,id:n,items:r,strategy:i=wI,disabled:s=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=KQe(),h=tw(sse,n),f=l.rect!==null,p=w.useMemo(()=>r.map(j=>typeof j=="object"&&"id"in j?j.id:j),[r]),x=o!=null,v=o?p.indexOf(o.id):-1,g=u?p.indexOf(u.id):-1,y=w.useRef(p),_=!JQe(p,y.current),N=g!==-1&&v===-1||_,A=eZe(s);Gc(()=>{_&&x&&d(p)},[_,p,x,d]),w.useEffect(()=>{y.current=p},[p]);const C=w.useMemo(()=>({activeIndex:v,containerId:h,disabled:A,disableTransforms:N,items:p,overIndex:g,useDragOverlay:f,sortedRects:ZQe(p,c),strategy:i}),[v,h,A.draggable,A.droppable,N,p,g,c,f,i]);return Kr.createElement(ose.Provider,{value:C},e)}const rZe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return IA(n,r,i).indexOf(e)},aZe=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},iZe={duration:200,easing:"ease"},cse="transform",sZe=Gb.Transition.toString({property:cse,duration:0,easing:"linear"}),oZe={roleDescription:"sortable"};function lZe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,o]=w.useState(null),l=w.useRef(n);return Gc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=vx(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{s&&o(null)},[s]),s}function use(t){let{animateLayoutChanges:e=aZe,attributes:n,disabled:r,data:i,getNewIndex:s=rZe,id:o,strategy:l,resizeObserverConfig:c,transition:u=iZe}=t;const{items:d,containerId:h,activeIndex:f,disabled:p,disableTransforms:x,sortedRects:v,overIndex:g,useDragOverlay:y,strategy:_}=w.useContext(ose),N=cZe(r,p),A=d.indexOf(o),C=w.useMemo(()=>({sortable:{containerId:h,index:A,items:d},...i}),[h,i,A,d]),j=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:k,node:R,isOver:M,setNodeRef:D}=QQe({id:o,data:C,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:j,...c}}),{active:G,activatorEvent:U,activeNodeRect:W,attributes:L,setNodeRef:ee,listeners:ae,isDragging:Y,over:se,setActivatorNodeRef:ce,transform:ye}=WQe({id:o,data:C,attributes:{...oZe,...n},disabled:N.draggable}),Z=jXe(D,ee),ue=!!G,pe=ue&&!x&&V_(f)&&V_(g),be=!y&&Y,Ee=be&&pe?ye:null,K=pe?Ee??(l??_)({rects:v,activeNodeRect:W,activeIndex:f,overIndex:g,index:A}):null,T=V_(f)&&V_(g)?s({id:o,items:d,activeIndex:f,overIndex:g}):A,E=G?.id,O=w.useRef({activeId:E,items:d,newIndex:T,containerId:h}),q=d!==O.current.items,B=e({active:G,containerId:h,isDragging:Y,isSorting:ue,id:o,index:A,items:d,newIndex:O.current.newIndex,previousItems:O.current.items,previousContainerId:O.current.containerId,transition:u,wasDragging:O.current.activeId!=null}),re=lZe({disabled:!B,index:A,node:R,rect:k});return w.useEffect(()=>{ue&&O.current.newIndex!==T&&(O.current.newIndex=T),h!==O.current.containerId&&(O.current.containerId=h),d!==O.current.items&&(O.current.items=d)},[ue,T,h,d]),w.useEffect(()=>{if(E===O.current.activeId)return;if(E!=null&&O.current.activeId==null){O.current.activeId=E;return}const V=setTimeout(()=>{O.current.activeId=E},50);return()=>clearTimeout(V)},[E]),{active:G,activeIndex:f,attributes:L,data:C,rect:k,index:A,newIndex:T,items:d,isOver:M,isSorting:ue,isDragging:Y,listeners:ae,node:R,overIndex:g,over:se,setNodeRef:Z,setActivatorNodeRef:ce,setDroppableNodeRef:D,setDraggableNodeRef:ee,transform:re??K,transition:z()};function z(){if(re||q&&O.current.newIndex===A)return sZe;if(!(be&&!xI(U)||!u)&&(ue||B))return Gb.Transition.toString({...u,property:cse})}}function cZe(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 qk(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 uZe=[cr.Down,cr.Right,cr.Up,cr.Left],dse=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:o,scrollableAncestors:l}}=e;if(uZe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=i.get(h.id);if(f)switch(t.code){case cr.Down:r.top<f.top&&c.push(h);break;case cr.Up:r.top>f.top&&c.push(h);break;case cr.Left:r.left>f.left&&c.push(h);break;case cr.Right:r.left<f.left&&c.push(h);break}});const u=GXe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=qie(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const h=s.get(n.id),f=s.get(d),p=f?i.get(f.id):null,x=f?.node.current;if(x&&p&&h&&f){const g=DA(x).some((j,k)=>l[k]!==j),y=hse(h,f),_=dZe(h,f),N=g||!y?{x:0,y:0}:{x:_?r.width-p.width:0,y:_?r.height-p.height:0},A={x:p.left,y:p.top};return N.x&&N.y?A:hv(A,N)}}}};function hse(t,e){return!qk(t)||!qk(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function dZe(t,e){return!qk(t)||!qk(e)||!hse(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function mse(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}function hZe({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(Xn,{className:"w-3.5 h-3.5"}),r("queue.status.waiting")]});if(t==="printing"&&n==="PAUSE")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(aC,{className:"w-3.5 h-3.5"}),r("queue.status.paused")]});const i={pending:{icon:Xn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:r("queue.status.pending")},printing:{icon:lo,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:r("queue.status.printing")},completed:{icon:xr,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:r("queue.status.completed")},failed:{icon:ii,color:"text-status-error bg-status-error/10 border-status-error/20",label:r("queue.status.failed")},skipped:{icon:BF,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:r("queue.status.skipped")},cancelled:{icon:Ut,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 mZe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,canControlPrinter:s,t:o}){const[l,c]=w.useState("unchanged"),[u,d]=w.useState("unchanged"),[h,f]=w.useState("unchanged"),[p,x]=w.useState("unchanged"),[v,g]=w.useState("unchanged"),[y,_]=w.useState("unchanged"),[N,A]=w.useState("unchanged"),[C,j]=w.useState("unchanged"),[k,R]=w.useState("unchanged"),[M,D]=w.useState("unchanged"),G=()=>{const W={};l!=="unchanged"&&(W.printer_id=l),u!=="unchanged"&&(W.manual_start=u),h!=="unchanged"&&(W.auto_off_after=h),p!=="unchanged"&&(W.require_previous_success=p),v!=="unchanged"&&(W.bed_levelling=v),y!=="unchanged"&&(W.flow_cali=y),N!=="unchanged"&&(W.vibration_cali=N),C!=="unchanged"&&(W.layer_inspect=C),k!=="unchanged"&&(W.timelapse=k),M!=="unchanged"&&(W.use_ams=M),n(W)},U=l!=="unchanged"||u!=="unchanged"||h!=="unchanged"||p!=="unchanged"||v!=="unchanged"||y!=="unchanged"||N!=="unchanged"||C!=="unchanged"||k!=="unchanged"||M!=="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:o("queue.bulkEdit.title",{count:t})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ut,{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:o("queue.bulkEdit.description")}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:o("queue.bulkEdit.printer")}),a.jsxs("select",{value:l===null?"null":l==="unchanged"?"unchanged":String(l),onChange:W=>{const L=W.target.value;c(L==="unchanged"?"unchanged":L==="null"?null:Number(L))},className:"w-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:o("queue.bulkEdit.noChange")}),a.jsx("option",{value:"null",children:o("queue.filter.unassigned")}),e.map(W=>a.jsx("option",{value:W.id,children:W.name},W.id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:o("queue.bulkEdit.queueOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Pu,{label:o("queue.bulkEdit.staged"),value:u,onChange:d,t:o}),a.jsx(Pu,{label:o("queue.bulkEdit.autoPowerOff"),value:h,onChange:f,disabled:!s,t:o}),a.jsx(Pu,{label:o("queue.bulkEdit.requirePrevious"),value:p,onChange:x,t:o})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:o("queue.bulkEdit.printOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Pu,{label:o("queue.bulkEdit.bedLevelling"),value:v,onChange:g,t:o}),a.jsx(Pu,{label:o("queue.bulkEdit.flowCalibration"),value:y,onChange:_,t:o}),a.jsx(Pu,{label:o("queue.bulkEdit.vibrationCalibration"),value:N,onChange:A,t:o}),a.jsx(Pu,{label:o("queue.bulkEdit.layerInspection"),value:C,onChange:j,t:o}),a.jsx(Pu,{label:o("queue.bulkEdit.timelapse"),value:k,onChange:R,t:o}),a.jsx(Pu,{label:o("queue.bulkEdit.useAms"),value:M,onChange:D,t:o})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Oe,{variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Oe,{onClick:G,disabled:!U||i,children:o(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function Pu({label:t,value:e,onChange:n,disabled:r,t:i}){return a.jsxs("div",{className:`flex items-center justify-between py-1 ${r?"opacity-50":""}`,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"),disabled:r,className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"} disabled:cursor-not-allowed`,children:"—"}),a.jsx("button",{onClick:()=>n(!1),disabled:r,className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"} disabled:cursor-not-allowed`,children:i("common.off")}),a.jsx("button",{onClick:()=>n(!0),disabled:r,className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"} disabled:cursor-not-allowed`,children:i("common.on")})]})]})}function LE({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:f,printerState:p,t:x}){const{data:v}=Je({queryKey:["printerStatus",t.printer_id],queryFn:()=>ge.getPrinterStatus(t.printer_id),refetchInterval:3e4,enabled:t.printer_id!=null&&p==="printing"}),g=!!t.library_file_id&&!t.archive_id,{data:y}=Je({queryKey:["archive-plates",t.archive_id],queryFn:()=>ge.getArchivePlates(t.archive_id),enabled:!!t.archive_id&&!g}),{data:_}=Je({queryKey:["library-file-plates",t.library_file_id],queryFn:()=>ge.getLibraryFilePlates(t.library_file_id),enabled:g&&!!t.library_file_id}),N=g?_:y,A=N?.plates??[],C=h("queue:reorder"),{attributes:j,listeners:k,setNodeRef:R,transform:M,transition:D,isDragging:G}=use({id:t.id,disabled:t.status!=="pending"||!C}),U={transform:Gb.Transform.toString(M),transition:D},W=t.status==="printing",L=t.status==="pending",ee=["completed","failed","skipped","cancelled"].includes(t.status),ae=L&&d;return a.jsxs("div",{ref:R,style:U,className:`
  8292. group relative bg-bambu-dark-secondary rounded-xl border transition-all duration-200
  8293. ${G?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8294. ${W?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8295. ${u&&ae?"sm:border-bambu-dark-tertiary border-bambu-green/40":""}
  8296. ${!u&&!W?"border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80":""}
  8297. ${ae?"sm:cursor-default":""}
  8298. `,onClick:ae?()=>{window.innerWidth<640&&d()}:void 0,children:[ae&&u&&a.jsx("div",{className:"sm:hidden absolute left-0 top-3 bottom-3 w-1 rounded-full bg-bambu-green"}),a.jsxs("div",{className:"flex items-start sm:items-center gap-2 sm:gap-4 p-3 sm:p-4",children:[L&&d&&a.jsx("button",{onClick:Y=>{Y.stopPropagation(),d()},className:`hidden sm:flex items-center justify-center w-6 h-6 rounded border transition-colors shrink-0 ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&a.jsx(Zr,{className:"w-4 h-4"})}),L?a.jsx("div",{...j,...k,className:"hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation shrink-0",children:a.jsx(Oh,{className:"w-4 h-4 text-bambu-gray"})}):e!==void 0?a.jsxs("div",{className:"hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium shrink-0",children:["#",e]}):a.jsx("div",{className:"hidden sm:block w-8 shrink-0"}),a.jsx("div",{className:"w-10 h-10 sm:w-14 sm:h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?a.jsx("img",{src:t.plate_id!=null?ge.getArchivePlateThumbnail(t.archive_id,t.plate_id):ge.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?a.jsx("img",{src:t.plate_id!=null?ge.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):ge.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(Ga,{className:"w-5 h-5 sm:w-6 sm: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.jsxs("p",{className:"text-sm sm:text-base text-white font-medium truncate",children:[t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`,(N?.is_multi_plate??!1)&&t.plate_id!==void 0&&t.plate_id!==null&&` • ${A.find(Y=>Y.index===t.plate_id)?.name||x("queue.plateNumber",{index:t.plate_id})}`]}),t.archive_id?a.jsx(Zs,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:x("queue.viewArchive"),children:a.jsx(aa,{className:"w-3.5 h-3.5"})}):t.library_file_id?a.jsx(Zs,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:x("queue.viewInFileManager"),children:a.jsx(aa,{className:"w-3.5 h-3.5"})}):null]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs sm:text-sm text-bambu-gray",children:[a.jsxs("span",{className:`flex items-center gap-1 sm: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 h-3 sm:w-3.5 sm:h-3.5"}),a.jsx("span",{className:"truncate max-w-[120px] sm:max-w-none",children:t.target_model?`${x("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?x("queue.filter.unassigned"):t.printer_name||`${x("common.printer")} #${t.printer_id}`})]}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx(zu,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),js(t.print_time_seconds)]}),t.filament_used_grams&&a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx(WY,{className:"w-3 h-3 sm:w-3.5 sm:h-3.5"}),mse(t.filament_used_grams)]}),t.created_by_username&&a.jsxs("span",{className:"hidden sm:flex items-center gap-1.5",title:x("queue.addedBy",{name:t.created_by_username}),children:[a.jsx(id,{className:"w-3.5 h-3.5"}),t.created_by_username]}),L&&!t.manual_start&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Xn,{className:"w-3.5 h-3.5"}),t.scheduled_time?(Jn(t.scheduled_time)?.getTime()??0)-Date.now()<-6e4?x?.("queue.time.overdue")??"Overdue":C0(t.scheduled_time,c,x):x?.("queue.time.asap")??"ASAP"]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2 mt-1.5 sm:mt-2",children:[t.manual_start&&a.jsxs("span",{className:"text-[10px] sm:text-xs px-1.5 sm: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(zY,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3"}),x("queue.badges.staged")]}),t.require_previous_success&&a.jsx("span",{className:"text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:x("queue.badges.requiresPrevious")}),t.auto_off_after&&a.jsxs("span",{className:"text-[10px] sm:text-xs px-1.5 sm: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(gd,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3"}),x("queue.badges.autoPowerOff")]})]}),W&&v&&a.jsxs("div",{className:"mt-2 sm:mt-3",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs sm:text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5 sm:h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-green h-1.5 sm:h-2 rounded-full transition-all",style:{width:`${v.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(v.progress||0),"%"]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mt-1.5 sm:mt-2 text-[10px] sm:text-xs text-bambu-gray",children:[v.remaining_time!=null&&v.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Xn,{className:"w-3 h-3"}),js(v.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:x("printers.estimatedCompletion"),children:["ETA ",GF(v.remaining_time,c,x)]})]}),v.layer_num!=null&&v.total_layers!=null&&v.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ga,{className:"w-3 h-3"}),v.layer_num,"/",v.total_layers]})]})]}),t.waiting_reason&&t.status==="pending"&&a.jsxs("p",{className:"text-[10px] sm:text-xs text-purple-400 mt-1.5 sm:mt-2 flex items-start gap-1",children:[a.jsx(qa,{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-[10px] sm:text-xs text-red-400 mt-1.5 sm:mt-2 flex items-center gap-1",children:[a.jsx(qa,{className:"w-3 h-3"}),t.error_message]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row items-end sm:items-center gap-2 sm:gap-1 shrink-0",onClick:Y=>Y.stopPropagation(),children:[a.jsx(hZe,{status:t.status,waitingReason:t.waiting_reason,printerState:p,t:x}),a.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[W&&a.jsx(Oe,{variant:"ghost",size:"sm",onClick:s,disabled:!h("printers:control"),title:h("printers:control")?x("queue.actions.stopPrint"):x("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2",children:a.jsx(Xhe,{className:"w-4 h-4"})}),L&&a.jsxs(a.Fragment,{children:[t.manual_start&&a.jsx(Oe,{variant:"ghost",size:"sm",onClick:l,disabled:!h("printers:control"),title:h("printers:control")?x("queue.actions.startPrint"):x("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10 p-1.5 sm:p-2",children:a.jsx(lo,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:n,disabled:!f("queue","update",t.created_by_id),title:f("queue","update",t.created_by_id)?x("common.edit"):x("queue.permissions.noEdit"),className:"p-1.5 sm:p-2",children:a.jsx(Ka,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,disabled:!f("queue","delete",t.created_by_id),title:f("queue","delete",t.created_by_id)?x("common.cancel"):x("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2",children:a.jsx(Ut,{className:"w-4 h-4"})})]}),ee&&a.jsxs(a.Fragment,{children:[a.jsx(Oe,{variant:"ghost",size:"sm",onClick:o,disabled:!h("queue:create"),title:h("queue:create")?x("queue.actions.requeue"):x("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10 p-1.5 sm:p-2",children:a.jsx(wr,{className:"w-4 h-4"})}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:i,disabled:!f("queue","delete",t.created_by_id),title:f("queue","delete",t.created_by_id)?x("common.remove"):x("queue.permissions.noRemove"),className:"p-1.5 sm:p-2",children:a.jsx(Xt,{className:"w-4 h-4"})})]})]})]})]})]})}function fZe(){const{t}=Et(),e=Qt(),{showToast:n}=dn(),{hasPermission:r,hasAnyPermission:i,canModify:s}=Rr(),[o,l]=w.useState(null),[c,u]=w.useState(""),[d,h]=w.useState(""),[f,p]=w.useState(!1),[x,v]=w.useState(null),[g,y]=w.useState(null),[_,N]=w.useState(null),[A,C]=w.useState([]),[j,k]=w.useState(!1),[R,M]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[D,G]=w.useState(()=>{const I=localStorage.getItem("queue.historySortAsc");return I!==null?I==="true":!1}),[U,W]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[L,ee]=w.useState(()=>{const I=localStorage.getItem("queue.pendingSortAsc");return I!==null?I==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",R)},[R]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(D))},[D]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",U)},[U]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(L))},[L]);const ae=Hie($k(FA,{activationConstraint:{distance:8}}),$k(RA,{coordinateGetter:dse})),{data:Y}=Je({queryKey:["settings"],queryFn:ge.getSettings}),se=Y?.time_format||"system",{data:ce,isLoading:ye}=Je({queryKey:["queue",o,c],queryFn:()=>ge.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:Z}=Je({queryKey:["printers"],queryFn:()=>ge.getPrinters()}),ue=ut({mutationFn:I=>ge.cancelQueueItem(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),pe=ut({mutationFn:I=>ge.removeFromQueue(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),be=ut({mutationFn:I=>ge.stopQueueItem(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),Ee=ut({mutationFn:I=>ge.startQueueItem(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),$=ut({mutationFn:I=>ge.reorderQueue(I),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),K=ut({mutationFn:async()=>{const I=ce?.filter(F=>["completed","failed","skipped","cancelled"].includes(F.status))||[];for(const F of I)await ge.removeFromQueue(F.id);return I.length},onSuccess:I=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:I}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),T=ut({mutationFn:I=>ge.bulkUpdateQueue(I),onSuccess:I=>{e.invalidateQueries({queryKey:["queue"]}),C([]),k(!1),n(I.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),E=ut({mutationFn:async I=>{for(const F of I)await ge.cancelQueueItem(F);return I.length},onSuccess:I=>{e.invalidateQueries({queryKey:["queue"]}),C([]),n(t("queue.toast.bulkCancelled",{count:I}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),O=I=>{C(F=>F.includes(I)?F.filter(J=>J!==I):[...F,I])},q=w.useMemo(()=>{const I=new Set;return Z?.forEach(F=>{F.location&&I.add(F.location)}),ce?.forEach(F=>{F.target_location&&I.add(F.target_location)}),Array.from(I).sort()},[Z,ce]),B=w.useCallback(I=>d?I.target_location?I.target_location===d:I.printer_id?Z?.find(J=>J.id===I.printer_id)?.location===d:!1:!0,[d,Z]),re=w.useMemo(()=>{let I=ce?.filter(J=>J.status==="pending")||[];d&&(I=I.filter(B));const F=J=>{if(!J.scheduled_time)return 0;const xe=Jn(J.scheduled_time)?.getTime()??0,he=Date.now()+4320*60*60*1e3;return xe>he?0:xe};return[...I].sort((J,xe)=>{let he;if(U==="name"){const le=J.archive_name||J.library_file_name||"",Ce=xe.archive_name||xe.library_file_name||"";he=le.localeCompare(Ce)}else U==="printer"?he=(J.printer_name||"").localeCompare(xe.printer_name||""):U==="time"?he=F(J)-F(xe):he=J.position-xe.position;return L?he:-he})},[ce,U,L,B,d]),z=()=>{const I=re.map(F=>F.id);A.length===I.length?C([]):C(I)},V=w.useMemo(()=>{let I=ce?.filter(F=>F.status==="printing")||[];return d&&(I=I.filter(B)),I},[ce,d,B]),te=w.useMemo(()=>{const I=new Set;return V.forEach(F=>{F.printer_id&&I.add(F.printer_id)}),Array.from(I)},[V]),Q=Qb({queries:te.map(I=>({queryKey:["printerStatus",I],queryFn:()=>ge.getPrinterStatus(I),refetchInterval:5e3}))}),ne=w.useMemo(()=>{const I={};return te.forEach((F,J)=>{const xe=Q[J];xe?.data?.state&&(I[F]=xe.data.state)}),I},[te,Q]),ie=w.useMemo(()=>{let I=ce?.filter(F=>["completed","failed","skipped","cancelled"].includes(F.status))||[];return d&&(I=I.filter(B)),[...I].sort((F,J)=>{let xe;if(R==="name"){const he=F.archive_name||F.library_file_name||"",le=J.archive_name||J.library_file_name||"";xe=he.localeCompare(le)}else R==="printer"?xe=(F.printer_name||"").localeCompare(J.printer_name||""):xe=(Jn(J.completed_at||J.created_at)?.getTime()??0)-(Jn(F.completed_at||F.created_at)?.getTime()??0);return D?-xe:xe})},[ce,R,D,B,d]),me=w.useMemo(()=>re.reduce((I,F)=>I+(F.print_time_seconds||0),0),[re]),fe=w.useMemo(()=>re.reduce((I,F)=>I+(F.filament_used_grams||0),0),[re]),oe=I=>{const{active:F,over:J}=I;if(!J||F.id===J.id)return;const xe=re.findIndex(le=>le.id===F.id),he=re.findIndex(le=>le.id===J.id);if(xe!==-1&&he!==-1){const Ce=IA(re,xe,he).map((Ne,Ue)=>({id:Ne.id,position:Ue+1}));$.mutate(Ce)}};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(UY,{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-2 sm:grid-cols-3 lg:grid-cols-5 gap-2 sm:gap-3 lg:gap-4 mb-8",children:[a.jsx(Ct,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:a.jsx(Tt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-blue-500/20 flex items-center justify-center shrink-0",children:a.jsx(lo,{className:"w-4 h-4 sm:w-5 sm:h-5 text-blue-400"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:V.length}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.printing")})]})]})})}),a.jsx(Ct,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:a.jsx(Tt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center shrink-0",children:a.jsx(Xn,{className:"w-4 h-4 sm:w-5 sm:h-5 text-yellow-400"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:re.length}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.queued")})]})]})})}),a.jsx(Ct,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:a.jsx(Tt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center shrink-0",children:a.jsx(zu,{className:"w-4 h-4 sm:w-5 sm:h-5 text-bambu-green"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:js(me)}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalTime")})]})]})})}),a.jsx(Ct,{className:"bg-gradient-to-br from-purple-500/10 to-transparent border-purple-500/20",children:a.jsx(Tt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-purple-500/20 flex items-center justify-center shrink-0",children:a.jsx(WY,{className:"w-4 h-4 sm:w-5 sm:h-5 text-purple-500"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:mse(fe)}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.totalWeight")})]})]})})}),a.jsx(Ct,{className:"col-span-2 sm:col-span-1 bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:a.jsx(Tt,{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[a.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg bg-gray-500/20 flex items-center justify-center shrink-0",children:a.jsx(xr,{className:"w-4 h-4 sm:w-5 sm:h-5 text-gray-400"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-xl sm:text-2xl font-bold text-white truncate",children:ie.length}),a.jsx("p",{className:"text-xs sm:text-sm text-bambu-gray truncate",children:t("queue.summary.history")})]})]})})})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-4 mb-6",children:[a.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:o===-1?"unassigned":o||"",onChange:I=>{const F=I.target.value;l(F==="unassigned"?-1:F===""?null:Number(F))},children:[a.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),a.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),Z?.map(I=>a.jsx("option",{value:I.id,children:I.name},I.id))]}),a.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:c,onChange:I=>u(I.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")})]}),q.length>0&&a.jsxs("select",{className:"px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none",value:d,onChange:I=>h(I.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allLocations")}),q.map(I=>a.jsx("option",{value:I,children:I},I))]}),a.jsx("div",{className:"hidden sm:block flex-1"}),ie.length>0&&a.jsxs(Oe,{className:"w-full sm:w-auto",variant:"secondary",size:"sm",onClick:()=>p(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[a.jsx(Xt,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),ye?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):ce?.length===0?a.jsxs(Ct,{className:"p-12 text-center border-dashed",children:[a.jsx(Xr,{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-6 sm:space-y-8",children:[V.length>0&&a.jsxs("div",{children:[a.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white mb-3 sm: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-2 sm:space-y-3",children:V.map(I=>a.jsx(LE,{item:I,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>N({type:"stop",item:I}),onRequeue:()=>{},onStart:()=>{},timeFormat:se,hasPermission:r,canModify:s,printerState:I.printer_id?ne[I.printer_id]:null,t},I.id))})]}),re.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4",children:[a.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Xn,{className:"w-4 h-4 sm:w-5 sm:h-5 text-yellow-400"}),t("queue.sections.queued"),a.jsxs("span",{className:"text-xs sm:text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:re.length}),")"]}),a.jsx("span",{className:"hidden sm:inline 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-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:U,onChange:I=>W(I.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(Oe,{variant:"ghost",size:"sm",onClick:()=>ee(!L),title:t(L?"common.ascending":"common.descending"),className:"px-2",children:L?a.jsx(Lf,{className:"w-4 h-4"}):a.jsx(bb,{className:"w-4 h-4"})})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-3 sm:mb-4 p-2 sm:p-3 bg-bambu-dark rounded-lg",children:[a.jsxs(Oe,{variant:"ghost",size:"sm",onClick:z,className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm",children:[A.length===re.length&&re.length>0?a.jsx(uo,{className:"w-4 h-4 text-bambu-green"}):a.jsx(_l,{className:"w-4 h-4"}),A.length===re.length&&re.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),A.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-xs sm:text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:A.length})}),a.jsx("div",{className:"hidden sm:block h-4 w-px bg-bambu-dark-tertiary"}),a.jsxs(Oe,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-bambu-green hover:text-bambu-green-light",disabled:!i("queue:update_own","queue:update_all"),title:i("queue:update_own","queue:update_all")?t("queue.bulkEdit.editSelected"):t("queue.permissions.noEditItems"),children:[a.jsx(Ka,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("queue.bulkEdit.editSelected")})]}),a.jsxs(Oe,{variant:"ghost",size:"sm",onClick:()=>E.mutate(A),className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-red-400 hover:text-red-300",disabled:E.isPending||!i("queue:delete_own","queue:delete_all"),title:i("queue:delete_own","queue:delete_all")?t("queue.bulkEdit.cancelSelected"):t("queue.permissions.noCancelItems"),children:[a.jsx(Ut,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("queue.bulkEdit.cancelSelected")})]})]})]}),a.jsx(ise,{sensors:ae,collisionDetection:Gie,onDragEnd:oe,children:a.jsx(lse,{items:re.map(I=>I.id),strategy:tZe,children:a.jsx("div",{className:"space-y-2 sm:space-y-3",children:re.map((I,F)=>a.jsx(LE,{item:I,position:F+1,onEdit:()=>v(I),onCancel:()=>N({type:"cancel",item:I}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>Ee.mutate(I.id),timeFormat:se,isSelected:A.includes(I.id),onToggleSelect:()=>O(I.id),hasPermission:r,canModify:s,t},I.id))})})})]}),ie.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4",children:[a.jsxs("h2",{className:"text-base sm:text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(xr,{className:"w-4 h-4 sm:w-5 sm:h-5 text-bambu-gray"}),t("queue.sections.history"),a.jsxs("span",{className:"text-xs sm:text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:ie.length}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{className:"px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:R,onChange:I=>M(I.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(Oe,{variant:"ghost",size:"sm",onClick:()=>G(!D),title:t(D?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:D?a.jsx(Lf,{className:"w-4 h-4"}):a.jsx(bb,{className:"w-4 h-4"})})]})]}),a.jsx("div",{className:"space-y-2 sm:space-y-3",children:ie.slice(0,20).map((I,F)=>a.jsx(LE,{item:I,position:F+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>N({type:"remove",item:I}),onStop:()=>{},onRequeue:()=>y(I),onStart:()=>{},timeFormat:se,hasPermission:r,canModify:s,t},I.id))})]})]}),x&&a.jsx(Zu,{mode:"edit-queue-item",archiveId:x.archive_id??void 0,libraryFileId:x.library_file_id??void 0,archiveName:x.archive_name||x.library_file_name||`File #${x.archive_id||x.library_file_id}`,queueItem:x,onClose:()=>v(null)}),g&&a.jsx(Zu,{mode:"add-to-queue",archiveId:g.archive_id??void 0,libraryFileId:g.library_file_id??void 0,archiveName:g.archive_name||g.library_file_name||`File #${g.archive_id||g.library_file_id}`,onClose:()=>y(null)}),_&&a.jsx(Sn,{title:_.type==="cancel"?t("queue.confirm.cancelTitle"):_.type==="stop"?t("queue.confirm.stopTitle"):t("queue.confirm.removeTitle"),message:_.type==="cancel"?t("queue.confirm.cancelMessage",{name:_.item.archive_name||_.item.library_file_name||t("queue.confirm.thisPrint")}):_.type==="stop"?t("queue.confirm.stopMessage",{name:_.item.archive_name||_.item.library_file_name||t("queue.confirm.thisPrint")}):t("queue.confirm.removeMessage",{name:_.item.archive_name||_.item.library_file_name||t("queue.confirm.thisItem")}),confirmText:_.type==="cancel"?t("queue.confirm.cancelButton"):_.type==="stop"?t("queue.confirm.stopButton"):t("common.remove"),variant:"danger",onConfirm:()=>{_.type==="cancel"?ue.mutate(_.item.id):_.type==="stop"?be.mutate(_.item.id):pe.mutate(_.item.id),N(null)},onCancel:()=>N(null)}),f&&a.jsx(Sn,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:ie.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{K.mutate(),p(!1)},onCancel:()=>p(!1)}),j&&a.jsx(mZe,{selectedCount:A.length,printers:Z?.map(I=>({id:I.id,name:I.name}))||[],onSave:I=>{Object.keys(I).length>0&&T.mutate({item_ids:A,...I})},onClose:()=>k(!1),isSaving:T.isPending,canControlPrinter:r("printers:control"),t})]})}function pZe({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const _=n.current;if(!_)return;const N=new ResizeObserver(A=>{const C=A[0]?.contentRect.width||0;i(C)});return N.observe(_),()=>N.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=w.useMemo(()=>{const _={};t.forEach(G=>{const U=G.split("T")[0];_[U]=(_[U]||0)+1});const N=new Date,A=new Date(N);A.setMonth(A.getMonth()-e),A.setDate(A.getDate()-A.getDay());const C=[],j=[];let k=[],R=-1;const M=new Date(A);let D=0;for(;M<=N;)M.getDay()===0&&k.length>0&&(C.push(k),k=[],D++),M.getMonth()!==R&&(j.push({month:M.toLocaleDateString("en-US",{month:"short"}),weekIndex:D}),R=M.getMonth()),k.push(new Date(M)),M.setDate(M.getDate()+1);return k.length>0&&C.push(k),{weeks:C,monthLabels:j,printCounts:_}},[t,e]),c=Math.max(1,...Object.values(l)),u=_=>{if(_===0)return"bg-bambu-dark";const N=_/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,f=32,p=2,x=r-f-16,v=h>0?Math.floor((x-(h-1)*p)/h):12,g=Math.max(8,Math.min(20,v)),y=g<=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:f+4},children:o.map(({month:_,weekIndex:N},A)=>a.jsx("div",{className:"text-bambu-gray",style:{fontSize:y,marginLeft:A===0?0:`${(N-(o[A-1]?.weekIndex||0))*(g+p)-24}px`},children:_},A))}),a.jsxs("div",{className:"flex",style:{gap:p},children:[a.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:f},children:d.map((_,N)=>a.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:f,height:g,fontSize:y,visibility:N%2===1?"visible":"hidden"},children:_},_))}),s.map((_,N)=>a.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(A=>{const C=_.find(M=>M.getDay()===A);if(!C)return a.jsx("div",{style:{width:g,height:g}},A);const j=C.toISOString().split("T")[0],k=l[j]||0,R=j===new Date().toISOString().split("T")[0];return a.jsx("div",{className:`rounded-sm ${u(k)} ${R?"ring-1 ring-white":""}`,style:{width:g,height:g},title:`${C.toLocaleDateString()}: ${k} print${k!==1?"s":""}`},A)})},N))]}),a.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:y},children:[a.jsx("span",{children:"Less"}),a.jsxs("div",{className:"flex",style:{gap:p},children:[a.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:g,height:g}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:g,height:g}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:g,height:g}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:g,height:g}}),a.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:g,height:g}})]}),a.jsx("span",{children:"More"})]})]})})}const gK=["weight","prints","time"];function Gk({value:t,onChange:e,exclude:n}){const{t:r}=Et(),i={weight:r("stats.filamentByWeight"),prints:r("stats.filamentByPrints"),time:r("stats.filamentByTime")},s=n?gK.filter(o=>!n.includes(o)):gK;return a.jsx("div",{className:"flex gap-0.5 bg-bambu-dark rounded-lg p-0.5",children:s.map(o=>a.jsx("button",{onClick:()=>e(o),className:`px-2 py-0.5 text-xs rounded-md transition-colors ${t===o?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:i[o]},o))})}function _h(t){if(t>=1e6){const e=t/1e6;return`${e%1===0?e.toFixed(0):e.toFixed(1)}t`}if(t>=1e3){const e=t/1e3;return`${e%1===0?e.toFixed(0):e.toFixed(1)}kg`}return`${Math.round(t)}g`}const G_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"],gZe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],bK=["12am","1am","2am","3am","4am","5am","6am","7am","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm","6pm","7pm","8pm","9pm","10pm","11pm"];function bZe({archives:t,currency:e="$",dateFrom:n,dateTo:r}){const{t:i}=Et(),[s,o]=w.useState("weight"),[l,c]=w.useState("weight"),u=w.useMemo(()=>{const R=new Map;return t.forEach(M=>{const D=Jn(M.completed_at||M.created_at)||new Date,G=`${D.getFullYear()}-${String(D.getMonth()+1).padStart(2,"0")}-${String(D.getDate()).padStart(2,"0")}`,U=R.get(G)||{date:G,filament:0,cost:0,prints:0};U.filament+=M.filament_used_grams||0,U.cost+=M.cost||0,U.prints+=M.quantity||1,R.set(G,U)}),Array.from(R.values()).sort((M,D)=>M.date.localeCompare(D.date)).map(M=>({...M,dateLabel:new Date(M.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[t]),d=w.useMemo(()=>{if(n&&r)return Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1;if(n)return Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1;if(t.length<2)return 0;const R=t.map(M=>new Date(M.completed_at||M.created_at).getTime());return(Math.max(...R)-Math.min(...R))/864e5},[t,n,r]),h=w.useMemo(()=>{if(d>7)return[];const R=new Map,M=d>1;return t.forEach(D=>{const G=Jn(D.completed_at||D.created_at)||new Date,U=G.getHours(),W=`${G.getFullYear()}-${String(G.getMonth()+1).padStart(2,"0")}-${String(G.getDate()).padStart(2,"0")}T${String(U).padStart(2,"0")}`,L=R.get(W)||{date:W,filament:0,cost:0,prints:0};L.filament+=D.filament_used_grams||0,L.cost+=D.cost||0,L.prints+=D.quantity||1,R.set(W,L)}),Array.from(R.values()).sort((D,G)=>D.date.localeCompare(G.date)).map(D=>{const[G,U]=D.date.split("T"),W=new Date(G),L=parseInt(U,10),ee=M?`${gZe[W.getDay()]} ${bK[L]}`:bK[L];return{...D,dateLabel:ee}})},[t,d]),f=w.useMemo(()=>{if(u.length<=60)return u;const R=new Map;return u.forEach(M=>{const D=new Date(M.date),G=new Date(D);G.setDate(D.getDate()-D.getDay());const U=`${G.getFullYear()}-${String(G.getMonth()+1).padStart(2,"0")}-${String(G.getDate()).padStart(2,"0")}`,W=R.get(U)||{week:U,filament:0,cost:0,prints:0};W.filament+=M.filament,W.cost+=M.cost,W.prints+=M.prints,R.set(U,W)}),Array.from(R.values()).sort((M,D)=>M.week.localeCompare(D.week)).map(M=>({date:M.week,dateLabel:`Week of ${new Date(M.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...M}))},[u]),p=w.useMemo(()=>{const R=new Map;return t.forEach(M=>{const G=(M.filament_type||"Unknown").split(", ");G.forEach(U=>{const W=(M.filament_used_grams||0)/G.length;R.set(U,(R.get(U)||0)+W)})}),Array.from(R.entries()).map(([M,D])=>({name:M,value:Math.round(D)})).sort((M,D)=>D.value-M.value)},[t]),x=w.useMemo(()=>{const R=new Map;return t.forEach(M=>{(M.filament_type||"Unknown").split(", ").forEach(U=>{R.set(U,(R.get(U)||0)+1)})}),Array.from(R.entries()).map(([M,D])=>({name:M,value:D})).sort((M,D)=>D.value-M.value)},[t]),v=w.useMemo(()=>{const R=new Map;return t.forEach(M=>{const G=(M.filament_type||"Unknown").split(", "),U=(M.actual_time_seconds||M.print_time_seconds||0)/G.length;G.forEach(W=>{R.set(W,(R.get(W)||0)+U)})}),Array.from(R.entries()).map(([M,D])=>({name:M,value:Math.round(D/3600*10)/10})).sort((M,D)=>D.value-M.value)},[t]),g=w.useMemo(()=>{const R=new Map;return t.forEach(M=>{if(M.status!=="completed"&&M.status!=="failed")return;(M.filament_type||"Unknown").split(", ").forEach(G=>{const U=R.get(G)||{completed:0,failed:0};M.status==="completed"?U.completed++:U.failed++,R.set(G,U)})}),Array.from(R.entries()).filter(([,M])=>M.completed+M.failed>=2).map(([M,D])=>{const G=D.completed+D.failed,U=Math.round(D.completed/G*100);return{name:M,rate:U,total:G}}).sort((M,D)=>D.rate-M.rate)},[t]),y=w.useMemo(()=>{const R=new Map;return t.forEach(M=>{if(!M.filament_color)return;const D=M.filament_color.split(",").map(U=>U.trim()),G=(M.filament_used_grams||0)/D.length;D.forEach(U=>{const W=R.get(U)||{count:0,weight:0};W.count++,W.weight+=G,R.set(U,W)})}),Array.from(R.entries()).map(([M,D])=>({hex:M,value:l==="prints"?D.count:Math.round(D.weight)})).sort((M,D)=>D.value-M.value)},[t,l]),_=s==="weight"?p:s==="prints"?x:v,N=d<=7&&h.length>0?h:f,A=t.reduce((R,M)=>R+(M.filament_used_grams||0),0),C=t.reduce((R,M)=>R+(M.cost||0),0),j=t.reduce((R,M)=>R+(M.quantity||1),0),k=new Set(t.map(R=>R.printer_id).filter(Boolean)).size;return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-2 max-[640px]:grid-cols-1",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:i("stats.periodFilament")}),a.jsx("p",{className:"text-2xl font-bold text-white leading-none",children:_h(A)})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[k," ",i("nav.printers").toLowerCase()]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:i("stats.periodCost")}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[e,C.toFixed(2)]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[j," ",i("common.prints")]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("p",{className:"text-sm text-bambu-gray leading-none",children:i("stats.avgPerPrint")}),a.jsxs("p",{className:"text-2xl font-bold text-white leading-none",children:[j>0?(A/j).toFixed(0):0,"g"]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,j>0?(C/j).toFixed(2):"0.00"," avg"]})]})]}),N.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:i("stats.usageOverTime")}),a.jsx(Th,{width:"100%",height:250,children:a.jsxs(b$e,{data:N,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(df,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(hf,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),a.jsx(mf,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:R=>`${R}g`}),a.jsx(Mh,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:R=>[`${Number(R??0).toFixed(0)}g`,"Filament"]}),a.jsx(gne,{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:i("stats.noPrintDataInRange")}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:i("stats.byMaterial")}),a.jsx(Gk,{value:s,onChange:o})]}),_.length>0?a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(Th,{width:160,height:160,children:a.jsxs(cG,{children:[a.jsx(vR,{data:_,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:_.map((R,M)=>a.jsx(Ib,{fill:G_[M%G_.length]},`cell-${M}`))}),a.jsx(Mh,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:R=>[s==="weight"?_h(Number(R??0)):s==="time"?`${Number(R??0)}h`:`${R??0}`,s==="weight"?"Usage":s==="time"?"Time":"Prints"]})]})}),a.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:_.map((R,M)=>{const D=_.reduce((U,W)=>U+W.value,0),G=D>0?(R.value/D*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:G_[M%G_.length]}}),a.jsx("span",{className:"text-white truncate flex-1",children:R.name}),a.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[s==="weight"?_h(R.value):s==="time"?`${R.value}h`:R.value," · ",G,"%"]})]},R.name)})})]}):a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:i("stats.noFilamentData")})]}),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:i("stats.filamentSuccess")}),g.length>0?a.jsx("div",{className:"space-y-1.5",children:g.map(R=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"text-white truncate w-20 flex-shrink-0",children:R.name}),a.jsx("div",{className:"flex-1 h-1.5 bg-bambu-dark-secondary rounded-full",children:a.jsx("div",{className:`h-full rounded-full transition-all ${R.rate>=90?"bg-status-ok":R.rate>=70?"bg-status-warning":"bg-status-error"}`,style:{width:`${R.rate}%`}})}),a.jsxs("span",{className:`font-medium flex-shrink-0 tabular-nums ${R.rate>=90?"text-status-ok":R.rate>=70?"text-status-warning":"text-status-error"}`,children:[R.rate,"%"]}),a.jsxs("span",{className:"text-bambu-gray flex-shrink-0 text-xs",children:["(",R.total,")"]})]},R.name))}):a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:i("stats.noArchiveData")})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:i("stats.colorDistribution")}),a.jsx(Gk,{value:l,onChange:c,exclude:["time"]})]}),y.length>0?(()=>{const R=y.reduce((M,D)=>M+D.value,0);return a.jsxs("div",{children:[a.jsxs("div",{className:"relative mx-auto",style:{width:160,height:160},children:[a.jsx(Th,{width:"100%",height:"100%",children:a.jsxs(cG,{children:[a.jsx(vR,{data:y,cx:"50%",cy:"50%",innerRadius:45,outerRadius:70,paddingAngle:2,dataKey:"value",children:y.map((M,D)=>a.jsx(Ib,{fill:M.hex,stroke:"#1a1a1a",strokeWidth:1},`color-${D}`))}),a.jsx(Mh,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:M=>[l==="weight"?_h(Number(M??0)):`${M??0}`,i(l==="weight"?"stats.filamentByWeight":"stats.filamentByPrints")]})]})}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[a.jsx("span",{className:"text-lg font-bold text-white",children:l==="weight"?_h(R):R}),a.jsxs("span",{className:"text-[10px] text-bambu-gray",children:[y.length," ",y.length===1?"color":"colors"]})]})]}),a.jsx("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 mt-2",children:y.slice(0,8).map(M=>{const D=R>0?(M.value/R*100).toFixed(0):0;return a.jsxs("div",{className:"flex items-center gap-1.5 text-xs min-w-0",children:[a.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 border border-white/20",style:{backgroundColor:M.hex}}),a.jsxs("span",{className:"text-bambu-gray truncate",children:[D,"%"]})]},M.hex)})}),y.length>8&&a.jsxs("p",{className:"text-[10px] text-bambu-gray mt-1 text-center",children:["+",y.length-8," more"]})]})})():a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:i("stats.noColorData")})]})]})]})}function xZe({id:t,title:e,component:n,isHidden:r,size:i,columnSpan:s,onToggleVisibility:o,onToggleSize:l}){const{attributes:c,listeners:u,setNodeRef:d,transform:h,transition:f,isDragging:p}=use({id:t}),x={transform:Gb.Transform.toString(h),transition:f,opacity:p?.5:1};return r?null:a.jsxs("div",{ref:d,style:{...x,gridColumn:`span ${s}`},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",{...c,...u,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:a.jsx(Oh,{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:l,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(zF,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):a.jsx(nC,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),a.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:a.jsx(yv,{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 yZe({widgets:t,storageKey:e,columns:n=4,stackBelow:r,hideControls:i=!1,onResetLayout:s,renderControls:o}){const l=()=>{const R={};return t.forEach(M=>{R[M.id]=M.defaultSize||4}),R},[c,u]=w.useState(()=>{const R=localStorage.getItem(e);if(R)try{const M=JSON.parse(R);if(!M.sizes)M.sizes=l();else{const D=l();for(const G in D)G in M.sizes||(M.sizes[G]=D[G])}return M}catch{}return{order:t.map(M=>M.id),hidden:t.filter(M=>M.defaultVisible===!1).map(M=>M.id),sizes:l()}}),[d,h]=w.useState(!1),[f,p]=w.useState(!1);w.useEffect(()=>{if(!r)return;const R=window.matchMedia(`(max-width: ${r}px)`),M=G=>{p(G.matches)};M(R);const D=G=>M(G);return R.addEventListener?R.addEventListener("change",D):R.addListener(D),()=>{R.removeEventListener?R.removeEventListener("change",D):R.removeListener(D)}},[r]);const x=r&&f?1:n;w.useEffect(()=>{const R=()=>h(M=>!M);return window.addEventListener("toggle-hidden-panel",R),()=>window.removeEventListener("toggle-hidden-panel",R)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(c))},[c,e]),w.useEffect(()=>{const M=t.map(D=>D.id).filter(D=>!c.order.includes(D));M.length>0&&u(D=>({...D,order:[...D.order,...M]}))},[t,c.order]);const v=Hie($k(FA,{activationConstraint:{distance:8}}),$k(RA,{coordinateGetter:dse})),g=R=>{const{active:M,over:D}=R;D&&M.id!==D.id&&u(G=>{const U=G.order.indexOf(M.id),W=G.order.indexOf(D.id);return{...G,order:IA(G.order,U,W)}})},y=R=>{u(M=>({...M,hidden:M.hidden.includes(R)?M.hidden.filter(D=>D!==R):[...M.hidden,R]}))},_=R=>{u(M=>{const D=M.sizes[R]||4,G=D===1?2:D===2?4:1;return{...M,sizes:{...M.sizes,[R]:G}}})},N=()=>{const R={order:t.map(M=>M.id),hidden:t.filter(M=>M.defaultVisible===!1).map(M=>M.id),sizes:l()};u(R),s?.()},A=c.order.map(R=>t.find(M=>M.id===R)).filter(Boolean),C=A.filter(R=>!c.hidden.includes(R.id)),j=A.filter(R=>c.hidden.includes(R.id)),k=o?.({hiddenCount:j.length,showHiddenPanel:d,setShowHiddenPanel:h,resetLayout:N});return a.jsxs("div",{className:"space-y-4",children:[k,!i&&!o&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:N,children:[a.jsx(co,{className:"w-4 h-4"}),"Reset Layout"]}),j.length>0&&a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>h(!d),children:[a.jsx(tc,{className:"w-4 h-4"}),j.length," Hidden"]})]}),d&&j.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:j.map(R=>a.jsxs("button",{onClick:()=>y(R.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(tc,{className:"w-3 h-3"}),R.title]},R.id))})]}),a.jsx(ise,{sensors:v,collisionDetection:Gie,onDragEnd:g,children:a.jsx(lse,{items:C.map(R=>R.id),strategy:wI,children:a.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${x}, minmax(0, 1fr))`},children:C.map(R=>{const M=c.sizes[R.id]||2,D=Math.min(M,x);return a.jsx(xZe,{id:R.id,title:R.title,component:R.component,isHidden:c.hidden.includes(R.id),size:M,columnSpan:D,onToggleVisibility:()=>y(R.id),onToggleSize:()=>_(R.id)},R.id)})})})}),C.length===0&&a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx("p",{children:"All widgets are hidden."}),a.jsx(Oe,{className:"mt-4",onClick:N,children:"Reset Layout"})]})]})}function vZe(t){const e=new Date,n=e.getUTCFullYear(),r=e.getUTCMonth(),i=e.getUTCDate(),s=l=>l.toISOString().split("T")[0],o=s(e);switch(t){case"today":return{dateFrom:o,dateTo:o};case"this-week":{const l=e.getUTCDay(),c=new Date(Date.UTC(n,r,i-(l===0?6:l-1)));return{dateFrom:s(c),dateTo:o}}case"this-month":return{dateFrom:s(new Date(Date.UTC(n,r,1))),dateTo:o};case"last-7":return{dateFrom:s(new Date(Date.UTC(n,r,i-6))),dateTo:o};case"last-30":return{dateFrom:s(new Date(Date.UTC(n,r,i-29))),dateTo:o};case"last-90":return{dateFrom:s(new Date(Date.UTC(n,r,i-89))),dateTo:o};case"this-year":return{dateFrom:s(new Date(Date.UTC(n,0,1))),dateTo:o};case"all-time":return{dateFrom:void 0,dateTo:void 0};case"custom":return{}}}const wZe=["today","this-week","this-month","last-7","last-30","last-90","this-year","all-time"],SZe=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],gF=["12am","1am","2am","3am","4am","5am","6am","7am","8am","9am","10am","11am","12pm","1pm","2pm","3pm","4pm","5pm","6pm","7pm","8pm","9pm","10pm","11pm"],OE=[{key:"<30m",max:1800},{key:"30m-1h",max:3600},{key:"1-2h",max:7200},{key:"2-4h",max:14400},{key:"4-8h",max:28800},{key:"8-12h",max:43200},{key:"12-24h",max:86400},{key:"24h+",max:1/0}],W_={backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"};function _Ze({stats:t,currency:e}){const{t:n}=Et(),r=[{icon:si,color:"text-bambu-green",label:n("stats.totalPrints"),value:`${t?.total_prints||0}`},{icon:Xn,color:"text-blue-400",label:n("stats.printTime"),value:`${t?.total_print_time_hours?.toFixed(1)??"0"}h`},{icon:si,color:"text-orange-400",label:n("stats.filamentUsed"),value:_h(t?.total_filament_grams||0)},{icon:M1,color:"text-green-400",label:n("stats.filamentCost"),value:`${e} ${t?.total_cost?.toFixed(2)??"0.00"}`},{icon:Ic,color:"text-yellow-400",label:n("stats.energyUsed"),value:`${t?.total_energy_kwh?.toFixed(3)??"0.000"} kWh`},{icon:M1,color:"text-yellow-500",label:n("stats.energyCost"),value:`${e} ${t?.total_energy_cost?.toFixed(2)??"0.00"}`}];return a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:r.map(i=>a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${i.color}`,children:a.jsx(i.icon,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:i.label}),a.jsx("p",{className:"text-xl font-bold text-white",children:i.value})]})]},i.label))})}function NZe({stats:t,printerMap:e,size:n=1}){const{t:r}=Et(),i=(t?.successful_prints||0)+(t?.failed_prints||0),s=i?Math.round(t.successful_prints/i*100):0,o=n===1?112:n===2?128:144,l=o/2-8,c=l*2*Math.PI;return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:o,height:o},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:o/2,cy:o/2,r:l,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:o/2,cy:o/2,r:l,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${s/100*c} ${c}`})]}),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:[s,"%"]})})]}),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(xr,{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(ii,{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(([u,d])=>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(u)||`${r("common.printer")} ${u}`}),a.jsx("span",{className:"text-white font-medium",children:d})]},u))})]})]})]})}function kZe({stats:t,printerMap:e,size:n=1}){const{t:r}=Et(),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=(v=>v>=95&&v<=105?"#00ae42":v>105?"#3b82f6":"#f97316")(i),u=i-100,d=n===1?112:n===2?128:144,h=d/2-8,f=h*2*Math.PI,p=n===1?3:n===2?6:999,x=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,p):[];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*f} ${f}`})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[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(qY,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{children:r("stats.perfectEstimate")})]}),x.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:x.map(([v,g])=>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(v)||`${r("common.printer")} ${v}`}),a.jsxs("span",{className:`font-medium ${g>=95&&g<=105?"text-status-ok":g>105?"text-blue-400":"text-status-warning"}`,children:[g.toFixed(0),"%"]})]},v))})]})]})}function CZe({printDates:t,dateFrom:e,dateTo:n}){const{days:r,hourlyCounts:i,maxCount:s}=w.useMemo(()=>{const d=new Date(e+"T00:00:00"),h=new Date(n+"T00:00:00"),f=[],p=y=>`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,x=new Date(d);for(;x<=h;)f.push({key:p(x),label:x.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})}),x.setDate(x.getDate()+1);const v={};let g=0;return t.forEach(y=>{const _=Jn(y);if(!_)return;const A=`${`${_.getFullYear()}-${String(_.getMonth()+1).padStart(2,"0")}-${String(_.getDate()).padStart(2,"0")}`}-${_.getHours()}`;v[A]=(v[A]||0)+1,v[A]>g&&(g=v[A])}),{days:f,hourlyCounts:v,maxCount:Math.max(1,g)}},[t,e,n]),o=d=>{if(d===0)return"bg-bambu-dark";const h=d/s;return h<=.25?"bg-bambu-green/30":h<=.5?"bg-bambu-green/50":h<=.75?"bg-bambu-green/75":"bg-bambu-green"},l=20,c=2,u=80;return a.jsxs("div",{className:"w-full overflow-x-auto",children:[a.jsxs("div",{className:"inline-flex flex-col",style:{gap:c},children:[a.jsx("div",{className:"flex",style:{gap:c,marginLeft:u+4},children:gF.map((d,h)=>a.jsx("div",{className:"text-bambu-gray text-[10px] text-center",style:{width:l,visibility:h%2===0?"visible":"hidden"},children:d},h))}),r.map(d=>a.jsxs("div",{className:"flex items-center",style:{gap:c},children:[a.jsx("div",{className:"text-bambu-gray text-[10px] flex-shrink-0 truncate",style:{width:u},children:d.label}),Array.from({length:24},(h,f)=>{const p=i[`${d.key}-${f}`]||0;return a.jsx("div",{className:`rounded-sm ${o(p)}`,style:{width:l,height:l},title:`${d.label} ${gF[f]}: ${p} print${p!==1?"s":""}`},f)})]},d.key))]}),a.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray text-xs",children:[a.jsx("span",{children:"Less"}),a.jsxs("div",{className:"flex",style:{gap:c},children:[a.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:l,height:l}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:l,height:l}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:l,height:l}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:l,height:l}}),a.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:l,height:l}})]}),a.jsx("span",{children:"More"})]})]})}function AZe({printDates:t,size:e=2,dateFrom:n,dateTo:r}){const i=w.useMemo(()=>n&&r?Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1:n?Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1:1/0,[n,r]);if(i<=7&&n&&r)return a.jsx(CZe,{printDates:t,dateFrom:n,dateTo:r});const o=i===1/0?e===1?3:e===2?6:12:Math.max(1,Math.ceil(i/30));return a.jsx(pZe,{printDates:t,months:o})}function TZe({stats:t,archives:e,printerMap:n}){const{t:r}=Et(),[i,s]=w.useState("weight"),[o,l]=w.useState("weight"),c=w.useMemo(()=>{const y=new Map;return t?.prints_by_printer&&Object.entries(t.prints_by_printer).forEach(([_,N])=>{const A=y.get(_)||{prints:0,weight:0,time:0};A.prints=N,y.set(_,A)}),e.forEach(_=>{if(!_.printer_id)return;const N=String(_.printer_id),A=y.get(N)||{prints:0,weight:0,time:0};A.weight+=_.filament_used_grams||0,A.time+=_.actual_time_seconds||_.print_time_seconds||0,t?.prints_by_printer||A.prints++,y.set(N,A)}),Array.from(y.entries()).map(([_,N])=>({name:n.get(_)||`${r("common.printer")} ${_}`,value:i==="prints"?N.prints:i==="weight"?Math.round(N.weight):Math.round(N.time/3600*10)/10})).sort((_,N)=>N.value-_.value)},[t,e,n,i,r]),u=w.useMemo(()=>{const y=Array.from({length:24},(_,N)=>({hour:N,label:gF[N],total:0,failures:0}));return e.forEach(_=>{if(!_.started_at)return;const N=Jn(_.started_at);if(!N)return;const A=N.getHours();y[A].total++,_.status==="failed"&&y[A].failures++}),y},[e]),d=w.useMemo(()=>{const y=OE.map(_=>({name:_.key,count:0}));return e.forEach(_=>{const N=_.actual_time_seconds||_.print_time_seconds;if(!(!N||N<=0)){for(let A=0;A<OE.length;A++)if(N<=OE[A].max){y[A].count++;break}}}),y},[e]),h=w.useMemo(()=>{const y=[0,0,0,0,0,0,0],_=new Set;e.forEach(A=>{const C=Jn(A.created_at)||new Date(A.created_at);let j=C.getDay()-1;j<0&&(j=6),o==="prints"?y[j]++:o==="weight"?y[j]+=A.filament_used_grams||0:y[j]+=(A.actual_time_seconds||A.print_time_seconds||0)/3600;const k=new Date(C);k.setDate(C.getDate()-(C.getDay()+6)%7),_.add(`${k.getFullYear()}-${String(k.getMonth()+1).padStart(2,"0")}-${String(k.getDate()).padStart(2,"0")}`)});const N=Math.max(_.size,1);return SZe.map((A,C)=>({name:A,avg:Math.round(y[C]/N*10)/10}))},[e,o]),f=y=>({unit:y==="weight"?"g":y==="time"?"h":"",color:y==="weight"?"#00ae42":y==="time"?"#3b82f6":"#f59e0b"}),p=f(i),x=r(i==="weight"?"stats.filamentByWeight":i==="time"?"stats.hours":"common.prints"),v=f(o),g=r(o==="weight"?"stats.avgWeight":o==="time"?"stats.avgTime":"stats.avgPrints");return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:r("stats.printsByPrinter")}),a.jsx(Gk,{value:i,onChange:s})]}),c.length>0?a.jsx(Th,{width:"100%",height:Math.max(140,c.length*40),children:a.jsxs(M_,{data:c,layout:"vertical",margin:{left:10},children:[a.jsx(df,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(hf,{type:"number",stroke:"#9ca3af",tick:{fontSize:11},unit:p.unit}),a.jsx(mf,{type:"category",dataKey:"name",stroke:"#9ca3af",tick:{fontSize:11},width:100}),a.jsx(Mh,{contentStyle:W_,formatter:y=>[i==="weight"?_h(Number(y??0)):`${y??0}${p.unit}`,x]}),a.jsx(Hg,{dataKey:"value",fill:p.color,radius:[0,4,4,0]})]})}):a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noPrinterData")})]}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",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-3",children:r("stats.printDuration")}),e.length>0?a.jsx(Th,{width:"100%",height:160,children:a.jsxs(M_,{data:d,children:[a.jsx(df,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(hf,{dataKey:"name",stroke:"#9ca3af",tick:{fontSize:11}}),a.jsx(mf,{stroke:"#9ca3af",tick:{fontSize:11},allowDecimals:!1}),a.jsx(Mh,{contentStyle:W_}),a.jsx(Hg,{dataKey:"count",name:r("common.prints"),fill:"#00ae42",radius:[4,4,0,0]})]})}):a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noArchiveData")})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray",children:r("stats.printHabits")}),a.jsx(Gk,{value:o,onChange:l})]}),e.length>0?a.jsx(Th,{width:"100%",height:160,children:a.jsxs(M_,{data:h,children:[a.jsx(df,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(hf,{dataKey:"name",stroke:"#9ca3af",tick:{fontSize:11}}),a.jsx(mf,{stroke:"#9ca3af",tick:{fontSize:11},unit:v.unit}),a.jsx(Mh,{contentStyle:W_,formatter:y=>[`${y??0}${v.unit}`,g]}),a.jsx(Hg,{dataKey:"avg",fill:v.color,radius:[4,4,0,0]})]})}):a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noArchiveData")})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-3",children:r("stats.printTimeOfDay")}),e.length>0?a.jsx(Th,{width:"100%",height:160,children:a.jsxs(M_,{data:u,children:[a.jsx(df,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(hf,{dataKey:"label",stroke:"#9ca3af",tick:{fontSize:10},interval:5}),a.jsx(mf,{stroke:"#9ca3af",tick:{fontSize:11},allowDecimals:!1}),a.jsx(Mh,{contentStyle:W_}),a.jsx(Hg,{dataKey:"total",name:r("stats.totalPrints"),fill:"#00ae42",radius:[2,2,0,0]}),a.jsx(Hg,{dataKey:"failures",name:r("stats.failed"),fill:"#ef4444",radius:[2,2,0,0]})]})}):a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r("stats.noArchiveData")})]})]})]})}function MZe({archives:t,currency:e,dateFrom:n,dateTo:r}){const{t:i}=Et();return!t||t.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:i("stats.noPrintData")}):a.jsx(bZe,{archives:t,currency:e,dateFrom:n,dateTo:r})}function PZe({size:t=1,dateFrom:e,dateTo:n}){const{t:r}=Et(),i=!!(e||n),{data:s,isLoading:o}=Je({queryKey:["failureAnalysis",e,n],queryFn:()=>ge.getFailureAnalysis({...i?{dateFrom:e,dateTo:n}:{days:30}})});if(o)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(!s||s.total_prints===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:r(i?"stats.noPrintDataInRange":"stats.noPrintDataLast30Days")});const l=t===1?5:t===2?8:999,c=Object.entries(s.failures_by_reason).sort(([,h],[,f])=>f-h),u=c.slice(0,l),d=c.length>l;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(Mn,{className:`w-5 h-5 ${s.failure_rate>20?"text-status-error":s.failure_rate>10?"text-status-warning":"text-status-ok"}`}),a.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[s.failure_rate.toFixed(1),"%"]})]})}),a.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:r("stats.failedPrintsCount",{failed:s.failed_prints,total:s.total_prints})}),s.trend&&s.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(HF,{className:`w-4 h-4 ${s.trend[s.trend.length-1].failure_rate<s.trend[s.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),a.jsx("span",{className:"text-bambu-gray",children:r("stats.lastWeekRate",{rate:s.trend[s.trend.length-1].failure_rate.toFixed(1)})})]})})]}),u.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?r("stats.failureReasons"):r("stats.topFailureReasons")}),a.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:u.map(([h,f])=>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:h||r("common.unknown")}),a.jsx("span",{className:"text-bambu-gray ml-2",children:f})]},h))}),d&&a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:r("common.more",{count:c.length-l})})]})]})}function jZe({archives:t,currency:e}){const{t:n}=Et(),r=w.useMemo(()=>{const i=[];if(t.length===0)return i;const s=x=>{let v=null,g=0;return t.forEach(y=>{const _=x(y);_&&_>g&&(g=_,v=y)}),{archive:v,value:g}},o=s(x=>x.actual_time_seconds);o.archive&&i.push({icon:Xn,iconColor:"text-blue-400",label:n("stats.longestPrint"),value:js(o.value),detail:o.archive.print_name||null});const l=s(x=>x.filament_used_grams);l.archive&&i.push({icon:si,iconColor:"text-orange-400",label:n("stats.heaviestPrint"),value:_h(l.value),detail:l.archive.print_name||null});const c=s(x=>x.cost);c.archive&&i.push({icon:M1,iconColor:"text-green-400",label:n("stats.mostExpensivePrint"),value:`${e}${c.value.toFixed(2)}`,detail:c.archive.print_name||null});const u=new Map;t.forEach(x=>{const v=Jn(x.created_at)||new Date(x.created_at),g=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`;u.set(g,(u.get(g)||0)+1)});let d="",h=0;u.forEach((x,v)=>{x>h&&(h=x,d=v)}),h>1&&i.push({icon:Xr,iconColor:"text-purple-400",label:n("stats.busiestDay"),value:`${h} ${n("common.prints")}`,detail:(()=>{const[x,v,g]=d.split("-").map(Number);return new Date(x,v-1,g).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})})()});const f=[...t].filter(x=>x.status==="completed"||x.status==="failed").sort((x,v)=>new Date(v.completed_at||v.created_at).getTime()-new Date(x.completed_at||x.created_at).getTime());let p=0;for(const x of f)if(x.status==="completed")p++;else break;return p>0&&i.push({icon:Ic,iconColor:"text-yellow-400",label:n("stats.successStreak"),value:`${p}`,detail:p===1?n("stats.streakPrint"):n("stats.streakPrints",{count:p})}),i},[t,e,n]);return r.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noArchiveData")}):a.jsx("div",{className:"space-y-3",children:r.map((i,s)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-1.5 rounded-lg bg-bambu-dark ${i.iconColor}`,children:a.jsx(i.icon,{className:"w-4 h-4"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:i.label}),a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"text-sm font-bold text-white",children:i.value}),i.detail&&a.jsx("span",{className:"text-xs text-bambu-gray truncate",children:i.detail})]})]})]},s))})}function EZe(){const{t}=Et(),{showToast:e}=dn(),{hasPermission:n}=Rr(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(0),[u,d]=w.useState(0),[h,f]=w.useState(!1),[p,x]=w.useState(()=>{try{const ee=localStorage.getItem("bambusy-stats-timeframe");if(ee){const ae=JSON.parse(ee);if(ae.preset)return ae}}catch{}return{preset:"all-time",dateFrom:void 0,dateTo:void 0}}),[v,g]=w.useState(!1);w.useEffect(()=>{localStorage.setItem("bambusy-stats-timeframe",JSON.stringify(p))},[p]);const y=w.useMemo(()=>p.preset==="custom"?{dateFrom:p.dateFrom,dateTo:p.dateTo}:vZe(p.preset),[p]);w.useEffect(()=>{const ee=()=>{try{const Y=localStorage.getItem("bambusy-dashboard-layout-v2");if(Y){const se=JSON.parse(Y);d(se.hidden?.length||0)}}catch{d(0)}};ee(),window.addEventListener("storage",ee);const ae=setInterval(ee,2e3);return()=>{window.removeEventListener("storage",ee),clearInterval(ae)}},[l]);const{data:_,isLoading:N,refetch:A}=Je({queryKey:["archiveStats",y.dateFrom,y.dateTo],queryFn:()=>ge.getArchiveStats({dateFrom:y.dateFrom,dateTo:y.dateTo})}),{data:C}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:j,refetch:k}=Je({queryKey:["archivesSlim",y.dateFrom,y.dateTo],queryFn:()=>ge.getArchivesSlim(y.dateFrom,y.dateTo)}),{data:R}=Je({queryKey:["settings"],queryFn:ge.getSettings}),M=async ee=>{o(!1),i(!0);try{const{blob:ae,filename:Y}=await ge.exportStats({format:ee,days:90}),se=URL.createObjectURL(ae),ce=document.createElement("a");ce.href=se,ce.download=Y,ce.click(),URL.revokeObjectURL(se),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},D=async()=>{f(!0);try{const ee=await ge.recalculateCosts();await Promise.all([A(),k()]),e(t("stats.recalculatedCosts",{count:ee.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{f(!1)}},G=sl(R?.currency||"USD"),U=new Map(C?.map(ee=>[String(ee.id),ee.name])||[]),W=w.useMemo(()=>j?.map(ee=>ee.created_at)||[],[j]);if(N)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 L=[{id:"quick-stats",title:t("stats.quickStats"),component:a.jsx(_Ze,{stats:_,currency:G}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:ee=>a.jsx(NZe,{stats:_,printerMap:U,size:ee}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:ee=>a.jsx(kZe,{stats:_,printerMap:U,size:ee}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:ee=>a.jsx(PZe,{size:ee,dateFrom:y.dateFrom,dateTo:y.dateTo}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:ee=>a.jsx(AZe,{printDates:W,size:ee,dateFrom:y.dateFrom,dateTo:y.dateTo}),defaultSize:2},{id:"records",title:t("stats.records"),component:a.jsx(jZe,{archives:j||[],currency:G}),defaultSize:1},{id:"printer-stats",title:t("stats.printerStats"),component:a.jsx(TZe,{stats:_,archives:j||[],printerMap:U}),defaultSize:4},{id:"filament-trends",title:t("stats.filamentTrends"),component:a.jsx(MZe,{archives:j||[],currency:G,dateFrom:y.dateFrom,dateTo:y.dateTo}),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(Oe,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[a.jsx(tc,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),a.jsxs(Oe,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout-v2"),c(ee=>ee+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[a.jsx(co,{className:"w-4 h-4"}),t("stats.resetLayout")]}),a.jsxs(Oe,{variant:"secondary",onClick:D,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(Mhe,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),a.jsxs("div",{className:"relative",children:[a.jsxs(Oe,{variant:"secondary",onClick:()=>o(!s),disabled:r,children:[r?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(j1,{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:()=>M("csv"),children:[a.jsx(Es,{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:()=>M("xlsx"),children:[a.jsx(j1,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]}),a.jsxs("div",{className:"relative",children:[a.jsxs(Oe,{variant:"secondary",onClick:()=>g(!v),children:[a.jsx(Xr,{className:"w-4 h-4"}),t(`stats.timeframe.${p.preset}`),a.jsx(En,{className:"w-3 h-3"})]}),v&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>g(!1)}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 w-64 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 p-2",children:[wZe.map(ee=>a.jsx("button",{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${p.preset===ee?"bg-bambu-green text-white":"text-white hover:bg-bambu-dark-tertiary"}`,onClick:()=>{x({preset:ee,dateFrom:void 0,dateTo:void 0}),g(!1)},children:t(`stats.timeframe.${ee}`)},ee)),a.jsx("div",{className:"border-t border-bambu-dark-tertiary my-2"}),a.jsx("button",{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${p.preset==="custom"?"bg-bambu-green text-white":"text-white hover:bg-bambu-dark-tertiary"}`,onClick:()=>x(ee=>({...ee,preset:"custom"})),children:t("stats.timeframe.custom")}),p.preset==="custom"&&a.jsxs("div",{className:"mt-2 px-1 pb-1 space-y-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray block mb-1",children:t("stats.timeframe.from")}),a.jsx("input",{type:"date",value:p.dateFrom||"",max:p.dateTo||new Date().toISOString().split("T")[0],onChange:ee=>x(ae=>({...ae,dateFrom:ee.target.value||void 0})),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray block mb-1",children:t("stats.timeframe.to")}),a.jsx("input",{type:"date",value:p.dateTo||"",min:p.dateFrom,max:new Date().toISOString().split("T")[0],onChange:ee=>x(ae=>({...ae,dateTo:ee.target.value||void 0})),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]"})]}),a.jsx(Oe,{variant:"primary",onClick:()=>g(!1),className:"w-full",children:t("common.apply")})]})]})]})]})]})]}),a.jsx(yZe,{widgets:L,storageKey:"bambusy-dashboard-layout-v2",stackBelow:640,hideControls:!0},l)]})}function DZe({plug:t,onEdit:e}){const{t:n}=Et(),r=Qt(),{showToast:i}=dn(),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!1),[h,f]=w.useState(!1),{data:p,isLoading:x}=Je({queryKey:["smart-plug-status",t.id],queryFn:()=>ge.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:v}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),g=v?.find(D=>D.id===t.printer_id),y=ut({mutationFn:D=>ge.controlSmartPlug(t.id,D),onMutate:async D=>{await r.cancelQueries({queryKey:["smart-plug-status",t.id]});const G=r.getQueryData(["smart-plug-status",t.id]),U=D==="on"?"ON":D==="off"||p?.state==="ON"?"OFF":"ON";return r.setQueryData(["smart-plug-status",t.id],W=>({...W,state:U})),{previousStatus:G}},onError:(D,G,U)=>{U?.previousStatus&&r.setQueryData(["smart-plug-status",t.id],U.previousStatus),i(`Failed to turn ${G} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:["smart-plug-status",t.id]}),r.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),_=ut({mutationFn:D=>ge.updateSmartPlug(t.id,D),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&(r.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]}))}}),N=ut({mutationFn:()=>ge.deleteSmartPlug(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&r.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),A=p?.state==="ON",C=t.plug_type==="mqtt"&&p?.energy?.power!==null&&p?.energy?.power!==void 0,j=(p?.reachable??!1)||C,k=y.isPending,M=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const D=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${D}/`:`http://${D}/`})();return a.jsxs(a.Fragment,{children:[a.jsx(Ct,{className:"relative",children:a.jsxs(Tt,{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"?j?"bg-teal-500/20":"bg-red-500/20":j?A?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?a.jsx(UF,{className:`w-5 h-5 ${j?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?a.jsx(vv,{className:`w-5 h-5 ${j?A?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):a.jsx(bl,{className:`w-5 h-5 ${j?A?"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:[x?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"}),j&&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:j?A?"text-status-ok":"text-bambu-gray":"text-status-error",children:j?p?.state||"?":"Offline"})]}):j?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx(nb,{className:"w-4 h-4 text-status-ok"}),a.jsx("span",{className:A?"text-status-ok":"text-bambu-gray",children:p?.state||"Unknown"})]}):a.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[a.jsx(Xh,{className:"w-4 h-4"}),a.jsx("span",{children:n("smartPlugs.offline")})]}),M&&a.jsxs("a",{href:M,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(aa,{className:"w-3 h-3"}),n("smartPlugs.admin")]})]})]}),g&&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:g.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(tc,{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(eb,{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(Xr,{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(Oe,{size:"sm",variant:A?"primary":"secondary",disabled:!j||k,onClick:()=>c(!0),className:"flex-1",children:[k?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(gd,{className:"w-4 h-4"}),"On"]}),a.jsxs(Oe,{size:"sm",variant:A?"secondary":"primary",disabled:!j||k,onClick:()=>d(!0),className:"flex-1",children:[k?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(iC,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&p?.energy&&a.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[p.energy.power!==null&&p.energy.power!==void 0&&a.jsxs("div",{className:"flex-1 text-center",children:[a.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(p.energy.power),"W"]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),p.energy.today!==null&&p.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:p.energy.today.toFixed(3)}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),a.jsxs("button",{onClick:()=>f(!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(rd,{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(wv,{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:D=>_.mutate({show_in_switchbar:D.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:D=>_.mutate({enabled:D.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:D=>_.mutate({auto_on:D.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:D=>_.mutate({auto_off:D.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:()=>_.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(Xn,{className:"w-4 h-4"}),"Time"]}),a.jsxs("button",{onClick:()=>_.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(lC,{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:D=>_.mutate({off_delay_minutes:parseInt(D.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:D=>_.mutate({off_temp_threshold:parseInt(D.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(Oe,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(af,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Oe,{size:"sm",variant:"secondary",onClick:()=>o(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(Xt,{className:"w-4 h-4"})})]})]})]})}),s&&a.jsx(Sn,{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(Sn,{title:n("smartPlugs.turnOnSmartPlug"),message:`Are you sure you want to turn on "${t.name}"?`,confirmText:n("smartPlugs.turnOn"),variant:"default",onConfirm:()=>{y.mutate("on"),c(!1)},onCancel:()=>c(!1)}),u&&a.jsx(Sn,{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:()=>{y.mutate("off"),d(!1)},onCancel:()=>d(!1)})]})}function RZe({plug:t,onClose:e}){const{t:n}=Et(),r=Qt(),i=!!t,[s,o]=w.useState(t?.plug_type||"tasmota"),[l,c]=w.useState(t?.name||""),[u,d]=w.useState(t?.ip_address||""),[h,f]=w.useState(t?.username||""),[p,x]=w.useState(t?.password||""),[v,g]=w.useState(t?.ha_entity_id||""),[y,_]=w.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[N,A]=w.useState(t?.mqtt_power_path||""),[C,j]=w.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[k,R]=w.useState(t?.mqtt_energy_topic||""),[M,D]=w.useState(t?.mqtt_energy_path||""),[G,U]=w.useState((t?.mqtt_energy_multiplier??1).toString()),[W,L]=w.useState(t?.mqtt_state_topic||""),[ee,ae]=w.useState(t?.mqtt_state_path||""),[Y,se]=w.useState(t?.mqtt_state_on_value||""),[ce,ye]=w.useState(t?.ha_power_entity||""),[Z,ue]=w.useState(t?.ha_energy_today_entity||""),[pe,be]=w.useState(t?.ha_energy_total_entity||""),[Ee,$]=w.useState(""),[K,T]=w.useState(""),[E,O]=w.useState(!1),q=w.useRef(null),[B,re]=w.useState(""),[z,V]=w.useState(!1),te=w.useRef(null),[Q,ne]=w.useState(""),[ie,me]=w.useState(!1),fe=w.useRef(null),[oe,I]=w.useState(""),[F,J]=w.useState(!1),xe=w.useRef(null),[he,le]=w.useState(t?.printer_id||null),[Ce,Ne]=w.useState(null),[Ue,He]=w.useState(null),[de,we]=w.useState(t?.power_alert_enabled||!1),[ke,_e]=w.useState(t?.power_alert_high?.toString()||""),[Ae,Ve]=w.useState(t?.power_alert_low?.toString()||""),[Te,Ke]=w.useState(t?.schedule_enabled||!1),[je,qe]=w.useState(t?.schedule_on_time||""),[Re,Pe]=w.useState(t?.schedule_off_time||""),[Be,We]=w.useState(t?.show_in_switchbar||!1),[ct,St]=w.useState(t?.show_on_printer_card??!0),[Mt,yt]=w.useState(!1),[$e,dt]=w.useState({scanned:0,total:0}),[gt,Lt]=w.useState([]),en=w.useRef(null),{data:pn}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:_n}=Je({queryKey:["smart-plugs"],queryFn:ge.getSmartPlugs}),{data:hn}=Je({queryKey:["settings"],queryFn:ge.getSettings}),gn=!!(hn?.ha_enabled&&hn?.ha_url&&hn?.ha_token);w.useEffect(()=>{const Le=setTimeout(()=>{T(Ee)},300);return()=>clearTimeout(Le)},[Ee]),w.useEffect(()=>{const Le=ht=>{q.current&&!q.current.contains(ht.target)&&O(!1),te.current&&!te.current.contains(ht.target)&&V(!1),fe.current&&!fe.current.contains(ht.target)&&me(!1),xe.current&&!xe.current.contains(ht.target)&&J(!1)};return document.addEventListener("mousedown",Le),()=>document.removeEventListener("mousedown",Le)},[]);const{data:On,isLoading:Dn,error:zn}=Je({queryKey:["ha-entities",K],queryFn:()=>ge.getHAEntities(K||void 0),enabled:s==="homeassistant"&&gn,retry:!1,staleTime:0}),{data:ze}=Je({queryKey:["ha-sensor-entities"],queryFn:ge.getHASensorEntities,enabled:s==="homeassistant"&&gn,retry:!1,staleTime:0});w.useEffect(()=>{const Le=ht=>{ht.key==="Escape"&&e()};return window.addEventListener("keydown",Le),()=>{window.removeEventListener("keydown",Le),en.current&&clearInterval(en.current)}},[e]);const De=async()=>{yt(!0),Lt([]),dt({scanned:0,total:0}),He(null);try{await ge.startTasmotaScan();const Le=async()=>{try{const ht=await ge.getTasmotaScanStatus();dt({scanned:ht.scanned,total:ht.total});const it=await ge.getDiscoveredTasmotaDevices();Lt(it),ht.running||(yt(!1),en.current&&(clearInterval(en.current),en.current=null))}catch(ht){console.error("Polling error:",ht)}};await Le(),en.current=setInterval(Le,500)}catch(Le){yt(!1);const ht=Le instanceof Error?Le.message:typeof Le=="string"?Le:JSON.stringify(Le);He(ht||"Failed to start scan")}},Ze=async()=>{try{await ge.stopTasmotaScan()}catch{}yt(!1),en.current&&(clearInterval(en.current),en.current=null)},st=Le=>{d(Le.ip_address),c(Le.name),Ne(null)},Ye=ut({mutationFn:()=>ge.testSmartPlugConnection(u,h||null,p||null),onSuccess:Le=>{Ne(Le),He(null),!l&&Le.device_name&&c(Le.device_name)},onError:Le=>{Ne(null),He(Le.message)}}),It=ut({mutationFn:Le=>ge.createSmartPlug(Le),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Le=>{He(Le.message)}}),Me=ut({mutationFn:Le=>ge.updateSmartPlug(t.id,Le),onSuccess:()=>{r.invalidateQueries({queryKey:["smart-plugs"]}),r.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Le=>{He(Le.message)}}),Ge=pn?.filter(Le=>s==="tasmota"?!_n?.some(it=>it.printer_id===Le.id&&it.id!==t?.id&&it.plug_type==="tasmota"):!0),et=Le=>{if(Le.preventDefault(),He(null),!l.trim()){He("Name is required");return}if(s==="tasmota"&&!u.trim()){He("IP address is required for Tasmota plugs");return}if(s==="homeassistant"&&!v){He("Entity is required for Home Assistant plugs");return}if(s==="mqtt"){const it=y.trim(),tt=k.trim(),_t=W.trim();if(!it&&!tt&&!_t){He("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const ht={name:l.trim(),plug_type:s,ip_address:s==="tasmota"?u.trim():null,ha_entity_id:s==="homeassistant"?v:null,ha_power_entity:s==="homeassistant"&&ce||null,ha_energy_today_entity:s==="homeassistant"&&Z||null,ha_energy_total_entity:s==="homeassistant"&&pe||null,mqtt_power_topic:s==="mqtt"&&y.trim()||null,mqtt_power_path:s==="mqtt"&&N.trim()||null,mqtt_power_multiplier:s==="mqtt"&&parseFloat(C)||1,mqtt_energy_topic:s==="mqtt"&&k.trim()||null,mqtt_energy_path:s==="mqtt"&&M.trim()||null,mqtt_energy_multiplier:s==="mqtt"&&parseFloat(G)||1,mqtt_state_topic:s==="mqtt"&&W.trim()||null,mqtt_state_path:s==="mqtt"&&ee.trim()||null,mqtt_state_on_value:s==="mqtt"&&Y.trim()||null,username:s==="tasmota"&&h.trim()||null,password:s==="tasmota"&&p.trim()||null,printer_id:he,power_alert_enabled:de,power_alert_high:ke?parseFloat(ke):null,power_alert_low:Ae?parseFloat(Ae):null,schedule_enabled:Te,schedule_on_time:je||null,schedule_off_time:Re||null,show_in_switchbar:Be,show_on_printer_card:ct};i?Me.mutate(ht):It.mutate(ht)},Qe=It.isPending||Me.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:Le=>Le.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(Ut,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:et,className:"p-6 space-y-4 overflow-y-auto",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}),!i&&a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsxs("button",{type:"button",onClick:()=>{o("tasmota"),Ne(null),He(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(bl,{className:"w-4 h-4"}),"Tasmota"]}),a.jsxs("button",{type:"button",onClick:()=>{o("homeassistant"),Ne(null),He(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(vv,{className:"w-4 h-4"}),"HA"]}),a.jsxs("button",{type:"button",onClick:()=>{o("mqtt"),Ne(null),He(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(UF,{className:"w-4 h-4"}),"MQTT"]})]}),!i&&s==="tasmota"&&a.jsxs("div",{className:"space-y-3",children:[Mt?a.jsxs(Oe,{type:"button",variant:"secondary",onClick:Ze,className:"w-full",children:[a.jsx(Ut,{className:"w-4 h-4"}),"Stop Scanning"]}):a.jsxs(Oe,{type:"button",variant:"primary",onClick:De,className:"w-full",children:[a.jsx(Er,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),Mt&&$e.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:[$e.scanned," / ",$e.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:`${$e.scanned/$e.total*100}%`}})})]}),gt.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",gt.length," device(s) - click to select:"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:gt.map(Le=>a.jsxs("button",{type:"button",onClick:()=>st(Le),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(bl,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:Le.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:Le.ip_address})]})]}),Le.state&&a.jsxs("span",{className:`flex items-center gap-1 text-xs ${Le.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[a.jsx(gd,{className:"w-3 h-3"}),Le.state]})]},Le.ip_address))})]}),!Mt&&gt.length===0&&$e.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:[!gn&&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")})})]})]}),gn&&a.jsxs(a.Fragment,{children:[Dn&&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..."]}),zn&&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: ",zn.message]}),(()=>{const Le=_n?.filter(tt=>tt.ha_entity_id&&tt.id!==t?.id).map(tt=>tt.ha_entity_id)||[],ht=(On||[]).filter(tt=>!Le.includes(tt.entity_id)),it=On?.find(tt=>tt.entity_id===v);return a.jsxs("div",{ref:q,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(Er,{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:E?Ee:it?`${it.friendly_name} (${it.entity_id})`:"",onChange:tt=>{$(tt.target.value),E||O(!0)},onFocus:()=>{O(!0),$("")},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"}),v&&!E&&a.jsx("button",{type:"button",onClick:()=>{g(""),$("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ut,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),Dn&&a.jsx(lt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),E&&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:[Dn&&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..."]}),!Dn&&ht.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:K?`No entities found matching "${K}"`:"No entities available"}),!Dn&&ht.map(tt=>a.jsxs("button",{type:"button",onClick:()=>{g(tt.entity_id),O(!1),$(""),l||c(tt.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${tt.entity_id===v?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:tt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[a.jsx("span",{children:tt.entity_id}),a.jsx("span",{className:tt.state==="on"?"text-bambu-green":"",children:tt.state})]})]},tt.entity_id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:K?`Searching all entities (${ht.length} found)`:`Showing switch, light, input_boolean (${ht.length} available)`})]})})(),v&&ze&&ze.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 Le=ze.filter(tt=>tt.unit_of_measurement==="W"||tt.unit_of_measurement==="kW"||tt.unit_of_measurement==="mW"),ht=B?Le.filter(tt=>tt.entity_id.toLowerCase().includes(B.toLowerCase())||tt.friendly_name.toLowerCase().includes(B.toLowerCase())):Le,it=ze.find(tt=>tt.entity_id===ce);return a.jsxs("div",{ref:te,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(Er,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:z?B:it?`${it.friendly_name} (${it.state} ${it.unit_of_measurement})`:"",onChange:tt=>{re(tt.target.value),z||V(!0)},onFocus:()=>{V(!0),re("")},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"}),ce&&!z&&a.jsx("button",{type:"button",onClick:()=>{ye(""),re("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ut,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),z&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{ye(""),V(!1),re("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),ht.map(tt=>a.jsxs("button",{type:"button",onClick:()=>{ye(tt.entity_id),V(!1),re("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${tt.entity_id===ce?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:tt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[tt.entity_id," • ",tt.state," ",tt.unit_of_measurement]})]},tt.entity_id)),ht.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Le=ze.filter(tt=>tt.unit_of_measurement==="kWh"||tt.unit_of_measurement==="Wh"||tt.unit_of_measurement==="MWh"),ht=Q?Le.filter(tt=>tt.entity_id.toLowerCase().includes(Q.toLowerCase())||tt.friendly_name.toLowerCase().includes(Q.toLowerCase())):Le,it=ze.find(tt=>tt.entity_id===Z);return a.jsxs("div",{ref:fe,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(Er,{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:ie?Q:it?`${it.friendly_name} (${it.state} ${it.unit_of_measurement})`:"",onChange:tt=>{ne(tt.target.value),ie||me(!0)},onFocus:()=>{me(!0),ne("")},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"}),Z&&!ie&&a.jsx("button",{type:"button",onClick:()=>{ue(""),ne("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ut,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),ie&&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:()=>{ue(""),me(!1),ne("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),ht.map(tt=>a.jsxs("button",{type:"button",onClick:()=>{ue(tt.entity_id),me(!1),ne("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${tt.entity_id===Z?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:tt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[tt.entity_id," • ",tt.state," ",tt.unit_of_measurement]})]},tt.entity_id)),ht.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Le=ze.filter(tt=>tt.unit_of_measurement==="kWh"||tt.unit_of_measurement==="Wh"||tt.unit_of_measurement==="MWh"),ht=oe?Le.filter(tt=>tt.entity_id.toLowerCase().includes(oe.toLowerCase())||tt.friendly_name.toLowerCase().includes(oe.toLowerCase())):Le,it=ze.find(tt=>tt.entity_id===pe);return a.jsxs("div",{ref:xe,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(Er,{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:F?oe:it?`${it.friendly_name} (${it.state} ${it.unit_of_measurement})`:"",onChange:tt=>{I(tt.target.value),F||J(!0)},onFocus:()=>{J(!0),I("")},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"}),pe&&!F&&a.jsx("button",{type:"button",onClick:()=>{be(""),I("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ut,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),F&&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:()=>{be(""),J(!1),I("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),ht.map(tt=>a.jsxs("button",{type:"button",onClick:()=>{be(tt.entity_id),J(!1),I("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${tt.entity_id===pe?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:tt.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[tt.entity_id," • ",tt.state," ",tt.unit_of_measurement]})]},tt.entity_id)),ht.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:[!hn?.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)."]}),hn?.mqtt_broker&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),a.jsx("p",{className:"text-xs opacity-80",children:"MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system."})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:y,onChange:Le=>_(Le.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:Le=>A(Le.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:C,onChange:Le=>j(Le.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:Le=>R(Le.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:M,onChange:Le=>D(Le.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:G,onChange:Le=>U(Le.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:W,onChange:Le=>L(Le.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:ee,onChange:Le=>ae(Le.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:Y,onChange:Le=>se(Le.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:Le=>{d(Le.target.value),Ne(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(Oe,{type:"button",variant:"secondary",onClick:()=>Ye.mutate(),disabled:!u.trim()||Ye.isPending,children:[Ye.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(nb,{className:"w-4 h-4"}),"Test"]})]})]}),s==="tasmota"&&Ce&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${Ce.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:Ce.success?a.jsxs(a.Fragment,{children:[a.jsx(xr,{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:[Ce.device_name&&`Device: ${Ce.device_name} - `,"State: ",Ce.state]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(Xh,{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:Le=>c(Le.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:Le=>f(Le.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:p,onChange:Le=>x(Le.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:he??"",onChange:Le=>le(Le.target.value?Number(Le.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)"}),Ge?.map(Le=>a.jsx("option",{value:Le.id,children:Le.name},Le.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(eb,{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:de,onChange:Le=>we(Le.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),de&&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:ke,onChange:Le=>_e(Le.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:Ae,onChange:Le=>Ve(Le.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(Xn,{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:Te,onChange:Le=>Ke(Le.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),Te&&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:je,onChange:Le=>qe(Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),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:Re,onChange:Le=>Pe(Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),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(wv,{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:Be,onChange:Le=>We(Le.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),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(tc,{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:ct,onChange:Le=>St(Le.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Oe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Oe,{type:"submit",disabled:Qe,className:"flex-1",children:[Qe?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function $n({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 FZe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function LZe({provider:t,onEdit:e}){const n=Qt(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),d=u?.find(v=>v.id===t.printer_id),h=ut({mutationFn:v=>ge.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),f=ut({mutationFn:()=>ge.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=ut({mutationFn:()=>ge.testNotificationProvider(t.id),onSuccess:v=>{c(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{c({success:!1,message:v.message})}}),x=v=>v||"";return a.jsxs(a.Fragment,{children:[a.jsx(Ct,{className:"relative",children:a.jsxs(Tt,{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(eb,{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:FZe[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: ",wb(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Jn(t.last_error_at)?.getTime()||0)>(Jn(t.last_success)?.getTime()||0))&&a.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),a.jsx($n,{checked:t.enabled,onChange:v=>h.mutate({enabled:v})})]})]}),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.on_bed_cooled&&a.jsx("span",{className:"px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded",children:"Bed Cooled"}),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(D1,{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(Xr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),a.jsx("div",{className:"mb-3",children:a.jsxs(Oe,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(sC,{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(xr,{className:"w-4 h-4"}):a.jsx(ii,{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(rd,{className:"w-4 h-4"}),"Event Settings"]}),s?a.jsx(Sl,{className:"w-4 h-4"}):a.jsx(En,{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($n,{checked:t.enabled,onChange:v=>h.mutate({enabled:v})})]}),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($n,{checked:t.on_print_start,onChange:v=>h.mutate({on_print_start:v})})]}),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($n,{checked:t.on_plate_not_empty??!0,onChange:v=>h.mutate({on_plate_not_empty:v})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),a.jsx($n,{checked:t.on_print_complete,onChange:v=>h.mutate({on_print_complete:v})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Bed Cooled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed cooled below threshold after print"})]}),a.jsx($n,{checked:t.on_bed_cooled??!1,onChange:v=>h.mutate({on_bed_cooled:v})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),a.jsx($n,{checked:t.on_print_failed,onChange:v=>h.mutate({on_print_failed:v})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),a.jsx($n,{checked:t.on_print_stopped,onChange:v=>h.mutate({on_print_stopped:v})})]}),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($n,{checked:t.on_print_progress,onChange:v=>h.mutate({on_print_progress:v})})]})]}),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($n,{checked:t.on_printer_offline,onChange:v=>h.mutate({on_printer_offline:v})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),a.jsx($n,{checked:t.on_printer_error,onChange:v=>h.mutate({on_printer_error:v})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),a.jsx($n,{checked:t.on_filament_low,onChange:v=>h.mutate({on_filament_low:v})})]}),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($n,{checked:t.on_maintenance_due??!1,onChange:v=>h.mutate({on_maintenance_due:v})})]})]}),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($n,{checked:t.on_ams_humidity_high??!1,onChange:v=>h.mutate({on_ams_humidity_high:v})})]}),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($n,{checked:t.on_ams_temperature_high??!1,onChange:v=>h.mutate({on_ams_temperature_high:v})})]})]}),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($n,{checked:t.on_ams_ht_humidity_high??!1,onChange:v=>h.mutate({on_ams_ht_humidity_high:v})})]}),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($n,{checked:t.on_ams_ht_temperature_high??!1,onChange:v=>h.mutate({on_ams_ht_temperature_high:v})})]})]}),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($n,{checked:t.on_queue_job_added??!1,onChange:v=>h.mutate({on_queue_job_added:v})})]}),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($n,{checked:t.on_queue_job_assigned??!1,onChange:v=>h.mutate({on_queue_job_assigned:v})})]}),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($n,{checked:t.on_queue_job_started??!1,onChange:v=>h.mutate({on_queue_job_started:v})})]}),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($n,{checked:t.on_queue_job_waiting??!0,onChange:v=>h.mutate({on_queue_job_waiting:v})})]}),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($n,{checked:t.on_queue_job_skipped??!0,onChange:v=>h.mutate({on_queue_job_skipped:v})})]}),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($n,{checked:t.on_queue_job_failed??!0,onChange:v=>h.mutate({on_queue_job_failed:v})})]}),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($n,{checked:t.on_queue_completed??!1,onChange:v=>h.mutate({on_queue_completed:v})})]})]}),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(D1,{className:"w-4 h-4 text-purple-400"}),a.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),a.jsx($n,{checked:t.quiet_hours_enabled,onChange:v=>h.mutate({quiet_hours_enabled:v})})]}),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(Xn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xr,{className:"w-4 h-4 text-emerald-400"}),a.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),a.jsx($n,{checked:t.daily_digest_enabled,onChange:v=>h.mutate({daily_digest_enabled:v})})]}),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(Xn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Oe,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(af,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Oe,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(Xt,{className:"w-4 h-4"})})]})]})]})}),r&&a.jsx(Sn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{f.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const xK=[{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 OZe({provider:t,onClose:e}){const n=Qt(),r=!!t,[i,s]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,h]=w.useState(t?.quiet_hours_enabled||!1),[f,p]=w.useState(t?.quiet_hours_start||"22:00"),[x,v]=w.useState(t?.quiet_hours_end||"07:00"),[g,y]=w.useState(t?.daily_digest_enabled||!1),[_,N]=w.useState(t?.daily_digest_time||"08:00"),[A,C]=w.useState(t?.on_print_start??!1),[j,k]=w.useState(t?.on_print_complete??!0),[R,M]=w.useState(t?.on_print_failed??!0),[D,G]=w.useState(t?.on_print_stopped??!0),[U,W]=w.useState(t?.on_print_progress??!1),[L,ee]=w.useState(t?.on_printer_offline??!1),[ae,Y]=w.useState(t?.on_printer_error??!1),[se,ce]=w.useState(t?.on_filament_low??!1),[ye,Z]=w.useState(t?.on_maintenance_due??!1),[ue,pe]=w.useState(t?.on_bed_cooled??!1),[be,Ee]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([ie,me])=>[ie,String(me)])):{}),[$,K]=w.useState(null),[T,E]=w.useState(null),{data:O}=Je({queryKey:["printers"],queryFn:ge.getPrinters});w.useEffect(()=>{const ie=me=>{me.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[e]);const q=ut({mutationFn:()=>ge.testNotificationConfig({provider_type:o,config:be}),onSuccess:ie=>{K(ie),E(null)},onError:ie=>{K({success:!1,message:ie.message})}}),B=ut({mutationFn:ie=>ge.createNotificationProvider(ie),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:ie=>{E(ie.message)}}),re=ut({mutationFn:ie=>ge.updateNotificationProvider(t.id,ie),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:ie=>{E(ie.message)}}),z=ie=>{if(ie.preventDefault(),E(null),!i.trim()){E("Name is required");return}const me=Q(o);for(const oe of me)if(!be[oe.key]?.trim()){E(`${oe.label} is required`);return}const fe={name:i.trim(),provider_type:o,config:be,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?f:null,quiet_hours_end:d?x:null,daily_digest_enabled:g,daily_digest_time:g?_:null,on_print_start:A,on_print_complete:j,on_print_failed:R,on_print_stopped:D,on_print_progress:U,on_printer_offline:L,on_printer_error:ae,on_filament_low:se,on_maintenance_due:ye,on_bed_cooled:ue};r?re.mutate(fe):B.mutate(fe)},V=B.isPending||re.isPending,te=ie=>{switch(ie){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:me=>me.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:me=>me.payload_format!=="slack"}];default:return[]}},Q=ie=>te(ie).filter(me=>me.required),ne=te(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:ie=>ie.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(Ut,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:z,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:i,onChange:ie=>s(ie.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:ie=>{l(ie.target.value),Ee({}),K(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:xK.map(ie=>a.jsx("option",{value:ie.value,children:ie.label},ie.value))}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:xK.find(ie=>ie.value===o)?.description})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ne.filter(ie=>!("showIf"in ie)||ie.showIf?.(be)!==!1).map(ie=>a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[ie.label," ",ie.required&&"*"]}),ie.type==="select"&&"options"in ie&&ie.options?a.jsx("select",{value:be[ie.key]||ie.options[0]?.value||"",onChange:me=>{Ee({...be,[ie.key]:me.target.value}),K(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:ie.options.map(me=>a.jsx("option",{value:me.value,children:me.label},me.value))}):a.jsx("input",{type:ie.type,value:be[ie.key]||"",onChange:me=>{Ee({...be,[ie.key]:me.target.value}),K(null)},placeholder:ie.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"})]},ie.key))]}),a.jsx("div",{className:"flex gap-2",children:a.jsxs(Oe,{type:"button",variant:"secondary",onClick:()=>{K(null),q.mutate()},disabled:q.isPending||!be[Q(o)[0]?.key],className:"flex-1",children:[q.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(sC,{className:"w-4 h-4"}),"Test Configuration"]})}),$&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${$.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:$.success?a.jsxs(a.Fragment,{children:[a.jsx(xr,{className:"w-5 h-5"}),a.jsx("span",{children:$.message})]}):a.jsxs(a.Fragment,{children:[a.jsx(ii,{className:"w-5 h-5"}),a.jsx("span",{children:$.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:ie=>u(ie.target.value?Number(ie.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"All printers"}),O?.map(ie=>a.jsx("option",{value:ie.id,children:ie.name},ie.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($n,{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:f,onChange:ie=>p(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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),a.jsx("input",{type:"time",value:x,onChange:ie=>v(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"})]})]})]}),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($n,{checked:g,onChange:y})]}),g&&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:_,onChange:ie=>N(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"}),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($n,{checked:A,onChange:C})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Complete"}),a.jsx($n,{checked:j,onChange:k})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Failed"}),a.jsx($n,{checked:R,onChange:M})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Stopped"}),a.jsx($n,{checked:D,onChange:G})]}),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($n,{checked:U,onChange:W})]}),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:"Bed Cooled"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(after print completes)"})]}),a.jsx($n,{checked:ue,onChange:pe})]})]})]}),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($n,{checked:L,onChange:ee})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Error"}),a.jsx($n,{checked:ae,onChange:Y})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),a.jsx($n,{checked:se,onChange:ce})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),a.jsx($n,{checked:ye,onChange:Z})]})]})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Oe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Oe,{type:"submit",disabled:V,className:"flex-1",children:[V?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function IZe({template:t,onClose:e}){const n=Qt(),r=w.useRef(null),[i,s]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,h]=w.useState(!0),{data:f}=Je({queryKey:["template-variables"],queryFn:ge.getTemplateVariables}),p=f?.find(C=>C.event_type===t.event_type),{data:x,isLoading:v}=Je({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>ge.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const C=j=>{j.key==="Escape"&&e()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e]);const g=ut({mutationFn:C=>ge.updateNotificationTemplate(t.id,C),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:C=>{u(C.message)}}),y=ut({mutationFn:()=>ge.resetNotificationTemplate(t.id),onSuccess:C=>{s(C.title_template),l(C.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:C=>{u(C.message)}}),_=C=>{if(C.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}g.mutate({title_template:i,body_template:o})},N=C=>{const j=r.current;if(!j)return;const k=j.selectionStart,R=j.selectionEnd,M=o,D=M.substring(0,k),G=M.substring(R),U=D+`{${C}}`+G;l(U),setTimeout(()=>{j.focus();const W=k+C.length+2;j.setSelectionRange(W,W)},0)},A=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(Ut,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("form",{onSubmit:_,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:C=>s(C.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:C=>l(C.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),p&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:p.variables.map(C=>a.jsxs("button",{type:"button",onClick:()=>N(C),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(nr,{className:"w-3 h-3"}),C]},C))}),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(tc,{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:v?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..."]}):x?a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),a.jsx("div",{className:"text-white font-medium",children:x.title})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),a.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):a.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[a.jsxs(Oe,{type:"button",variant:"ghost",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-orange-400 hover:text-orange-300",children:[y.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(co,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Oe,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsxs(Oe,{onClick:_,disabled:g.isPending||!A,children:[g.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(bs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const zZe={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"},UZe={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 BZe({onClose:t}){const e=Qt(),{showToast:n}=dn(),[r,i]=w.useState(7),[s,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=Je({queryKey:["settings"],queryFn:ge.getSettings}),d=u?.time_format||"system",{data:h,isLoading:f,refetch:p,isRefetching:x}=Je({queryKey:["notification-logs",r,l],queryFn:()=>ge.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:v}=Je({queryKey:["notification-log-stats",r],queryFn:()=>ge.getNotificationLogStats(r)}),g=ut({mutationFn:()=>ge.clearNotificationLogs(30),onSuccess:_=>{n(_.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:_=>{n(`Failed to clear logs: ${_.message}`,"error")}}),y=_=>{const N=Jn(_);if(!N)return"";const C=new Date().getTime()-N.getTime();return C<6e4?"Just now":C<36e5?`${Math.floor(C/6e4)}m ago`:C<864e5?`${Math.floor(C/36e5)}h ago`:N.toLocaleDateString()+" "+JY(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(N0,{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:"×"})]}),v&&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:v.total})," notifications"]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(xr,{className:"w-4 h-4"}),v.success_count," sent"]}),v.failure_count>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(ii,{className:"w-4 h-4"}),v.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:_=>i(Number(_.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:_=>c(_.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(Oe,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:x,children:[x?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(wr,{className:"w-4 h-4"}),"Refresh"]}),a.jsxs(Oe,{size:"sm",variant:"secondary",onClick:()=>g.mutate(),disabled:g.isPending,className:"text-red-400 hover:text-red-300",children:[g.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"}),"Clear Old"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:f?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(_=>a.jsx(HZe,{log:_,isExpanded:s===_.id,onToggle:()=>o(s===_.id?null:_.id),formatDate:y,formatFullDate:N=>Uf(N,d)},_.id))}):a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(N0,{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 HZe({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(xr,{className:"w-4 h-4 text-bambu-green shrink-0"}):a.jsx(ii,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-xs font-medium ${UZe[t.event_type]||"text-bambu-gray"}`,children:zZe[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(Sl,{className:"w-4 h-4 text-bambu-gray shrink-0"}):a.jsx(En,{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 $Ze({formData:t,setFormData:e,groups:n,onClose:r,onCreate:i,isCreating:s,isCreateButtonDisabled:o}){const{t:l}=Et();w.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(Ct,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:[a.jsx(Vn,{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(gh,{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(Oe,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Ut,{className:"w-5 h-5"})})]})}),a.jsxs(Tt,{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(Oe,{variant:"secondary",onClick:r,children:l("users.modal.cancel")}),a.jsx(Oe,{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(nr,{className:"w-4 h-4"}),l("users.modal.createUser")]})})]})]})]})})}function VZe(){const{t}=Et(),e=Qt(),{showToast:n}=dn(),[r,i]=w.useState(!1),[s,o]=w.useState(""),[l,c]=w.useState("auto"),[u,d]=w.useState(!1),[h,f]=w.useState(!0),[p,x]=w.useState("all"),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,A]=w.useState(!1),{data:C,isLoading:j}=Je({queryKey:["spoolman-settings"],queryFn:ge.getSpoolmanSettings}),{data:k,isLoading:R,refetch:M}=Je({queryKey:["spoolman-status"],queryFn:ge.getSpoolmanStatus,refetchInterval:3e4}),{data:D}=Je({queryKey:["printers"],queryFn:ge.getPrinters});w.useEffect(()=>{C&&(i(C.spoolman_enabled==="true"),o(C.spoolman_url||""),c(C.spoolman_sync_mode||"auto"),d(C.spoolman_disable_weight_sync==="true"),f(C.spoolman_report_partial_usage!=="false"),g(!0))},[C]),w.useEffect(()=>{if(!v||!C)return;if(C.spoolman_enabled==="true"!==r||(C.spoolman_url||"")!==s||(C.spoolman_sync_mode||"auto")!==l||C.spoolman_disable_weight_sync==="true"!==u||C.spoolman_report_partial_usage!=="false"!==h){const ue=setTimeout(()=>{G.mutate()},500);return()=>clearTimeout(ue)}},[r,s,l,u,h,v]);const G=ut({mutationFn:()=>ge.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"]}),e.invalidateQueries({queryKey:["spool-assignments"]}),n(t("settings.toast.settingsSaved"))}}),U=ut({mutationFn:ge.connectSpoolman,onSuccess:()=>{M()}}),W=ut({mutationFn:ge.disconnectSpoolman,onSuccess:()=>{M()}}),L=ut({mutationFn:ge.syncAllPrintersAms,onSuccess:Z=>{Z.success}}),ee=ut({mutationFn:Z=>ge.syncPrinterAms(Z),onSuccess:Z=>{Z.success}}),ae=()=>{p==="all"?L.mutate():ee.mutate(p)},Y=ut({mutationFn:ge.syncWeightsFromAms,onSuccess:Z=>{e.invalidateQueries({queryKey:["spools"]}),e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("settings.amsSyncSuccess",{synced:Z.synced,skipped:Z.skipped}),"success"),A(!1)},onError:()=>{n(t("settings.amsSyncError"),"error"),A(!1)}}),se=L.isPending||ee.isPending,ce=p==="all"?L.data:ee.data,ye=p==="all"?L.isSuccess:ee.isSuccess;return j?a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Dc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]})}),a.jsx(Tt,{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(Ct,{children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Dc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.filamentTracking")})]}),G.isPending&&a.jsx(lt,{className:"w-4 h-4 text-bambu-green animate-spin"})]})}),a.jsxs(Tt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.filamentTrackingDesc")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("button",{type:"button",onClick:()=>i(!1),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50":"border-bambu-green bg-bambu-green/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx(si,{className:`w-4 h-4 ${r?"text-bambu-gray":"text-bambu-green"}`}),a.jsx("span",{className:`text-sm font-medium ${r?"text-bambu-gray":"text-white"}`,children:t("settings.trackingModeBuiltIn")})]}),a.jsx("p",{className:`text-xs ${r?"text-bambu-gray/60":"text-bambu-gray"}`,children:t("settings.trackingModeBuiltInDesc")}),!r&&a.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[a.jsx(Zr,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]}),a.jsxs("button",{type:"button",onClick:()=>i(!0),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx(aa,{className:`w-4 h-4 ${r?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:`text-sm font-medium ${r?"text-white":"text-bambu-gray"}`,children:"Spoolman"})]}),a.jsx("p",{className:`text-xs ${r?"text-bambu-gray":"text-bambu-gray/60"}`,children:t("settings.trackingModeSpoolmanDesc")}),r&&a.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[a.jsx(Zr,{className:"w-3 h-3 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-green",children:t("common.enabled")})]})]})]}),!r&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"p-3 bg-bambu-green/5 border border-bambu-green/20 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(to,{className:"w-4 h-4 text-bambu-green flex-shrink-0 mt-0.5"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[a.jsx("li",{children:t("settings.builtInFeatureRfid")}),a.jsx("li",{children:t("settings.builtInFeatureUsage")}),a.jsx("li",{children:t("settings.builtInFeatureCatalog")}),a.jsx("li",{children:t("settings.builtInFeatureThirdParty")})]})})]})}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>A(!0),disabled:Y.isPending,children:[Y.isPending?a.jsx(lt,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(wr,{className:"w-4 h-4 mr-2"}),t("settings.amsSyncButton")]})]}),r&&a.jsxs("div",{className:"space-y-4",children:[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(to,{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:t("settings.howSyncWorks")}),a.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[a.jsx("li",{children:t("settings.syncInfoRfidOnly")}),a.jsx("li",{children:t("settings.syncInfoAutoCreate")}),a.jsx("li",{children:t("settings.syncInfoThirdPartySkipped")})]}),a.jsx("p",{className:"font-medium mt-2 mb-1",children:t("settings.linkingExistingSpools")}),a.jsx("p",{className:"text-blue-300/80",children:t("settings.linkingExistingSpoolsDesc")})]})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.spoolmanUrl")}),a.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:s,onChange:Z=>o(Z.target.value),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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t("settings.spoolmanUrlHint")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("settings.syncMode")}),a.jsxs("select",{value:l,onChange:Z=>c(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"auto",children:t("settings.syncModeAuto")}),a.jsx("option",{value:"manual",children:t("settings.syncModeManual")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:t(l==="auto"?"settings.syncModeAutoDesc":"settings.syncModeManualDesc")})]}),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:Z=>d(Z.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"})]})]}),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:Z=>f(Z.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:"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.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("settings.status"),":"]}),R?a.jsx(lt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):k?.connected?a.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[a.jsx(Zr,{className:"w-4 h-4"}),t("settings.spoolmanConnected")]}):a.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[a.jsx(Ut,{className:"w-4 h-4"}),t("settings.spoolmanDisconnected")]})]}),a.jsx("div",{className:"flex gap-2",children:k?.connected?a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>W.mutate(),disabled:W.isPending,children:[W.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Mfe,{className:"w-4 h-4"}),t("settings.disconnect")]}):a.jsxs(Oe,{size:"sm",onClick:()=>U.mutate(),disabled:U.isPending||!s,children:[U.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ih,{className:"w-4 h-4"}),t("settings.connect")]})})]}),U.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:U.error.message}),k?.connected&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:t("settings.syncAmsData")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:t("settings.syncAmsDataDesc")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsxs("select",{value:p,onChange:Z=>x(Z.target.value==="all"?"all":Number(Z.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:t("settings.allPrinters")}),D?.map(Z=>a.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),a.jsx(En,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:ae,disabled:se,children:[se?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(wr,{className:"w-4 h-4"}),t("spoolman.sync")]})]})]}),ye&&ce&&a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsx("div",{className:`p-2 rounded text-sm ${ce.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:ce.success?`Synced ${ce.synced_count} spool${ce.synced_count!==1?"s":""} successfully`:`Synced ${ce.synced_count} spool${ce.synced_count!==1?"s":""} with ${ce.errors.length} error${ce.errors.length!==1?"s":""}`}),ce.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(Mn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{className:"font-medium",children:[ce.skipped_count," spool",ce.skipped_count!==1?"s":""," skipped"]})]}),ce.skipped_count>5&&a.jsx("button",{onClick:()=>_(!y),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:y?"Show less":"Show all"})]}),a.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(y?ce.skipped:ce.skipped.slice(0,5)).map((Z,ue)=>a.jsxs("li",{className:"flex items-center gap-2",children:[Z.color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${Z.color}`}}),a.jsx("span",{children:Z.location}),a.jsxs("span",{className:"text-amber-300/60",children:["- ",Z.reason]})]},ue)),!y&&ce.skipped_count>5&&a.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",ce.skipped_count-5," more"]})]})]}),ce.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:ce.errors.map((Z,ue)=>a.jsx("li",{children:Z},ue))})]})]})]})]})]}),N&&a.jsx(Sn,{title:t("settings.amsSyncTitle"),message:t("settings.amsSyncMessage"),confirmText:t("settings.amsSyncButton"),variant:"warning",isLoading:Y.isPending,loadingText:t("settings.amsSyncing"),onConfirm:()=>Y.mutate(),onCancel:()=>A(!1)})]})}function qZe(){const{t}=Et(),{showToast:e}=dn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),c=w.useRef(null),[u,d]=w.useState(!1),[h,f]=w.useState(null),[p,x]=w.useState(""),[v,g]=w.useState(""),[y,_]=w.useState(!1),[N,A]=w.useState(null),[C,j]=w.useState(!1),k=w.useCallback(async()=>{try{const Y=await ge.getSpoolCatalog();r(Y)}catch{e(t("settings.catalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{k()},[k]);const R=n.filter(Y=>Y.name.toLowerCase().includes(o.toLowerCase())),M=async()=>{if(!p.trim()||!v){e(t("settings.catalog.nameWeightRequired"),"error");return}_(!0);try{const Y=await ge.addCatalogEntry({name:p.trim(),weight:parseInt(v)});r(se=>[...se,Y].sort((ce,ye)=>ce.name.localeCompare(ye.name))),d(!1),x(""),g(""),e(t("settings.catalog.entryAdded"),"success")}catch{e(t("settings.catalog.addFailed"),"error")}finally{_(!1)}},D=Y=>{f(Y.id),x(Y.name),g(Y.weight.toString())},G=()=>{f(null),x(""),g("")},U=async Y=>{if(!p.trim()||!v){e(t("settings.catalog.nameWeightRequired"),"error");return}_(!0);try{const se=await ge.updateCatalogEntry(Y,{name:p.trim(),weight:parseInt(v)});r(ce=>ce.map(ye=>ye.id===Y?se:ye).sort((ye,Z)=>ye.name.localeCompare(Z.name))),f(null),x(""),g(""),e(t("settings.catalog.entryUpdated"),"success")}catch{e(t("settings.catalog.updateFailed"),"error")}finally{_(!1)}},W=async()=>{if(N)try{await ge.deleteCatalogEntry(N.id),r(Y=>Y.filter(se=>se.id!==N.id)),e(t("settings.catalog.entryDeleted"),"success")}catch{e(t("settings.catalog.deleteFailed"),"error")}finally{A(null)}},L=async()=>{j(!1),s(!0);try{await ge.resetSpoolCatalog(),await k(),e(t("settings.catalog.resetSuccess"),"success")}catch{e(t("settings.catalog.resetFailed"),"error"),s(!1)}},ee=()=>{const Y=n.map(({name:Z,weight:ue})=>({name:Z,weight:ue})),se=new Blob([JSON.stringify(Y,null,2)],{type:"application/json"}),ce=URL.createObjectURL(se),ye=document.createElement("a");ye.href=ce,ye.download="spool-catalog.json",document.body.appendChild(ye),ye.click(),document.body.removeChild(ye),URL.revokeObjectURL(ce),e(t("settings.catalog.exported",{count:n.length}),"success")},ae=async Y=>{const se=Y.target.files?.[0];if(se){try{const ce=await se.text(),ye=JSON.parse(ce);if(!Array.isArray(ye))throw new Error("Invalid format");let Z=0,ue=0;for(const pe of ye){if(!pe.name||typeof pe.weight!="number"){ue++;continue}if(n.some(Ee=>Ee.name.toLowerCase()===pe.name.toLowerCase())){ue++;continue}try{const Ee=await ge.addCatalogEntry({name:pe.name,weight:pe.weight});r($=>[...$,Ee].sort((K,T)=>K.name.localeCompare(T.name))),Z++}catch{ue++}}e(t("settings.catalog.imported",{added:Z,skipped:ue}),"success")}catch{e(t("settings.catalog.importFailed"),"error")}c.current&&(c.current.value="")}};return a.jsxs(Ct,{children:[a.jsxs(Vn,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Dc,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.catalog.spoolCatalog")}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("button",{onClick:ee,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.exportTooltip"),children:[a.jsx(ba,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),a.jsxs("button",{onClick:()=>c.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.importTooltip"),children:[a.jsx(Ia,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),a.jsx("input",{ref:c,type:"file",accept:".json",className:"hidden",onChange:ae}),a.jsxs("button",{onClick:()=>j(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.catalog.resetTooltip"),children:[a.jsx(co,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),a.jsxs("button",{onClick:()=>d(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[a.jsx(nr,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]})]}),a.jsxs(Tt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.catalog.spoolCatalogDescription")}),a.jsxs("div",{className:"relative",children:[a.jsx(Er,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",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",placeholder:t("settings.catalog.searchCatalog"),value:o,onChange:Y=>l(Y.target.value)})]}),u&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.catalog.addNewEntry")}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("input",{type:"text",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",placeholder:t("settings.catalog.namePlaceholder"),value:p,onChange:Y=>x(Y.target.value)})}),a.jsx("input",{type:"number",className:"w-20 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-center focus:border-bambu-green focus:outline-none",placeholder:"g",value:v,onChange:Y=>g(Y.target.value)}),a.jsx("span",{className:"text-bambu-gray shrink-0",children:"g"}),a.jsxs("button",{onClick:M,disabled:y,className:"px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center gap-1 shrink-0",children:[y?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Zr,{className:"w-4 h-4"}),t("common.add")]}),a.jsx("button",{onClick:()=>{d(!1),x(""),g("")},className:"p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:a.jsx(Ut,{className:"w-4 h-4"})})]})]}),i?a.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[a.jsx(lt,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):a.jsx("div",{className:"max-h-[600px] overflow-y-auto border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-4 py-2 text-left text-bambu-gray font-medium",children:t("common.name")}),a.jsx("th",{className:"px-4 py-2 text-right text-bambu-gray font-medium w-24",children:t("settings.catalog.weight")}),a.jsx("th",{className:"px-4 py-2 text-center text-bambu-gray font-medium w-20",children:t("settings.catalog.type")}),a.jsx("th",{className:"px-4 py-2 w-24"})]})}),a.jsx("tbody",{children:R.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-bambu-gray",children:t(o?"settings.catalog.noMatch":"settings.catalog.empty")})}):R.map(Y=>a.jsx("tr",{className:"border-t border-bambu-dark-tertiary hover:bg-bambu-dark",children:h===Y.id?a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-4 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white focus:border-bambu-green focus:outline-none",value:p,onChange:se=>x(se.target.value)})}),a.jsx("td",{className:"px-4 py-2",children:a.jsx("input",{type:"number",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-right focus:border-bambu-green focus:outline-none",value:v,onChange:se=>g(se.target.value)})}),a.jsx("td",{className:"px-4 py-2 text-center",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"-"})}),a.jsx("td",{className:"px-4 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>U(Y.id),disabled:y,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:y?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Zr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:G,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(Ut,{className:"w-4 h-4"})})]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-4 py-2 text-white",children:Y.name}),a.jsxs("td",{className:"px-4 py-2 text-right font-mono text-white",children:[Y.weight,"g"]}),a.jsx("td",{className:"px-4 py-2 text-center",children:Y.is_default?a.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray",children:t("settings.catalog.default")}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-bambu-green/20 text-bambu-green",children:t("settings.catalog.custom")})}),a.jsx("td",{className:"px-4 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>D(Y),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Ka,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>A(Y),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:a.jsx(Xt,{className:"w-4 h-4"})})]})})]})},Y.id))})]})})]}),N&&a.jsx(Sn,{title:t("settings.catalog.deleteEntry"),message:t("settings.catalog.deleteConfirm",{name:N.name}),confirmText:t("common.delete"),variant:"danger",onConfirm:W,onCancel:()=>A(null)}),C&&a.jsx(Sn,{title:t("settings.catalog.resetCatalog"),message:t("settings.catalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:L,onCancel:()=>j(!1)})]})}function GZe(){const{t}=Et(),{showToast:e}=dn(),[n,r]=w.useState([]),[i,s]=w.useState(!0),[o,l]=w.useState(""),[c,u]=w.useState("Bambu Lab"),d=w.useRef(null),[h,f]=w.useState(!1),[p,x]=w.useState(null),[v,g]=w.useState(""),[y,_]=w.useState(""),[N,A]=w.useState("#FFFFFF"),[C,j]=w.useState(""),[k,R]=w.useState(!1),[M,D]=w.useState(!1),[G,U]=w.useState(null),[W,L]=w.useState(null),[ee,ae]=w.useState(!1),Y=w.useCallback(async()=>{try{const O=await ge.getColorCatalog();r(O)}catch{e(t("settings.colorCatalog.loadFailed"),"error")}finally{s(!1)}},[e,t]);w.useEffect(()=>{Y()},[Y]);const se=[...new Set(n.map(O=>O.manufacturer))].sort(),ce=n.filter(O=>{const q=o===""||O.manufacturer.toLowerCase().includes(o.toLowerCase())||O.color_name.toLowerCase().includes(o.toLowerCase())||(O.material?.toLowerCase().includes(o.toLowerCase())??!1),B=c===""||O.manufacturer===c;return q&&B}),ye=()=>{g(""),_(""),A("#FFFFFF"),j("")},Z=async()=>{if(!v.trim()||!y.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}R(!0);try{const O=await ge.addColorEntry({manufacturer:v.trim(),color_name:y.trim(),hex_color:N,material:C.trim()||null});r(q=>[...q,O].sort((B,re)=>B.manufacturer.localeCompare(re.manufacturer)||(B.material||"").localeCompare(re.material||"")||B.color_name.localeCompare(re.color_name))),f(!1),ye(),e(t("settings.colorCatalog.colorAdded"),"success")}catch{e(t("settings.colorCatalog.addFailed"),"error")}finally{R(!1)}},ue=O=>{x(O.id),g(O.manufacturer),_(O.color_name),A(O.hex_color),j(O.material||"")},pe=()=>{x(null),ye()},be=async O=>{if(!v.trim()||!y.trim()||!N){e(t("settings.colorCatalog.fieldsRequired"),"error");return}R(!0);try{const q=await ge.updateColorEntry(O,{manufacturer:v.trim(),color_name:y.trim(),hex_color:N,material:C.trim()||null});r(B=>B.map(re=>re.id===O?q:re).sort((re,z)=>re.manufacturer.localeCompare(z.manufacturer)||(re.material||"").localeCompare(z.material||"")||re.color_name.localeCompare(z.color_name))),x(null),ye(),e(t("settings.colorCatalog.colorUpdated"),"success")}catch{e(t("settings.colorCatalog.updateFailed"),"error")}finally{R(!1)}},Ee=async()=>{if(W)try{await ge.deleteColorEntry(W.id),r(O=>O.filter(q=>q.id!==W.id)),e(t("settings.colorCatalog.colorDeleted"),"success")}catch{e(t("settings.colorCatalog.deleteFailed"),"error")}finally{L(null)}},$=async()=>{ae(!1),s(!0);try{await ge.resetColorCatalog(),await Y(),e(t("settings.colorCatalog.resetSuccess"),"success")}catch{e(t("settings.colorCatalog.resetFailed"),"error"),s(!1)}},K=async()=>{D(!0),U(null);try{const O={},q=sd();q&&(O.Authorization=`Bearer ${q}`);const B=await fetch("/api/v1/inventory/colors/sync",{method:"POST",headers:O});if(!B.ok)throw new Error("Failed to start sync");const re=B.body?.getReader();if(!re)throw new Error("No response body");const z=new TextDecoder;let V="";for(;;){const{done:te,value:Q}=await re.read();if(te)break;V+=z.decode(Q,{stream:!0});const ne=V.split(`
  8299. `);V=ne.pop()||"";for(const ie of ne)if(ie.startsWith("data: "))try{const me=JSON.parse(ie.slice(6));me.type==="progress"?U({fetched:me.total_fetched,total:me.total_available}):me.type==="complete"?me.added===0?e(t("settings.colorCatalog.syncUpToDate",{count:me.total_fetched}),"success"):e(t("settings.colorCatalog.syncComplete",{added:me.added,skipped:me.skipped}),"success"):me.type==="error"&&e(`${t("settings.colorCatalog.syncError")}: ${me.error}`,"error")}catch{}}await Y()}catch{e(t("settings.colorCatalog.syncFailed"),"error")}finally{D(!1),U(null)}},T=()=>{const O=n.map(({manufacturer:z,color_name:V,hex_color:te,material:Q})=>({manufacturer:z,color_name:V,hex_color:te,material:Q})),q=new Blob([JSON.stringify(O,null,2)],{type:"application/json"}),B=URL.createObjectURL(q),re=document.createElement("a");re.href=B,re.download="color-catalog.json",document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(B),e(t("settings.colorCatalog.exported",{count:n.length}),"success")},E=async O=>{const q=O.target.files?.[0];if(q){try{const B=await q.text(),re=JSON.parse(B);if(!Array.isArray(re))throw new Error("Invalid format");let z=0,V=0;for(const te of re){if(!te.manufacturer||!te.color_name||!te.hex_color){V++;continue}if(n.some(ne=>ne.manufacturer.toLowerCase()===te.manufacturer.toLowerCase()&&ne.color_name.toLowerCase()===te.color_name.toLowerCase()&&(ne.material||"").toLowerCase()===(te.material||"").toLowerCase())){V++;continue}try{const ne=await ge.addColorEntry({manufacturer:te.manufacturer,color_name:te.color_name,hex_color:te.hex_color,material:te.material||null});r(ie=>[...ie,ne].sort((me,fe)=>me.manufacturer.localeCompare(fe.manufacturer)||(me.material||"").localeCompare(fe.material||"")||me.color_name.localeCompare(fe.color_name))),z++}catch{V++}}e(t("settings.colorCatalog.imported",{added:z,skipped:V}),"success")}catch{e(t("settings.colorCatalog.importFailed"),"error")}d.current&&(d.current.value="")}};return a.jsxs(Ct,{children:[a.jsxs(Vn,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(rC,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.colorCatalog.title")}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",n.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs("button",{onClick:T,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[a.jsx(ba,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.export")})]}),a.jsxs("button",{onClick:()=>d.current?.click(),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[a.jsx(Ia,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.import")})]}),a.jsx("input",{ref:d,type:"file",accept:".json",className:"hidden",onChange:E}),a.jsxs("button",{onClick:K,disabled:M,className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",title:t("settings.colorCatalog.syncTooltip"),children:[M?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Zb,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:M?G?`${Math.min(G.fetched,G.total)} / ${G.total}`:t("settings.colorCatalog.starting"):t("settings.colorCatalog.sync")})]}),a.jsxs("button",{onClick:()=>ae(!0),className:"px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5",children:[a.jsx(co,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.reset")})]}),a.jsxs("button",{onClick:()=>f(!0),className:"px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5",children:[a.jsx(nr,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.add")})]})]})]}),a.jsxs(Tt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("settings.colorCatalog.description")}),a.jsxs("div",{className:"flex gap-2 flex-wrap",children:[a.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[a.jsx(Er,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",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",placeholder:t("settings.colorCatalog.searchColors"),value:o,onChange:O=>l(O.target.value)})]}),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:O=>u(O.target.value),children:[a.jsx("option",{value:"",children:t("settings.colorCatalog.allManufacturers")}),se.map(O=>a.jsx("option",{value:O,children:O},O))]})]}),h&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:t("settings.colorCatalog.addNewColor")}),a.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-2 items-end",children:[a.jsx("input",{type:"text",className:"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",placeholder:t("settings.colorCatalog.manufacturer"),value:v,onChange:O=>g(O.target.value)}),a.jsx("input",{type:"text",className:"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",placeholder:t("settings.colorCatalog.colorName"),value:y,onChange:O=>_(O.target.value)}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"color",className:"w-20 h-10 rounded cursor-pointer border border-bambu-dark-tertiary",value:N,onChange:O=>A(O.target.value)}),a.jsx("input",{type:"text",className:"w-32 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",placeholder:"#FFFFFF",value:N,onChange:O=>A(O.target.value)})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("input",{type:"text",className:"flex-1 max-w-lg min-w-[200px] 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",placeholder:t("settings.colorCatalog.materialOptional"),value:C,onChange:O=>j(O.target.value)}),a.jsxs("button",{onClick:Z,disabled:k,className:"w-24 px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center justify-center gap-3",children:[k?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Zr,{className:"w-4 h-4"}),t("common.add")]}),a.jsx("button",{onClick:()=>{f(!1),ye()},className:"p-2 ml-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary",children:a.jsx(Ut,{className:"w-4 h-4"})})]})]})]}),(o||c)&&a.jsx("div",{className:"text-xs text-bambu-gray",children:t("settings.colorCatalog.showing",{filtered:ce.length,total:n.length})}),i?a.jsxs("div",{className:"flex items-center justify-center py-8 text-bambu-gray",children:[a.jsx(lt,{className:"w-5 h-5 animate-spin mr-2"}),t("common.loading")]}):a.jsx("div",{className:"max-h-[600px] overflow-auto border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"bg-bambu-dark sticky top-0",children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium w-12"}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("settings.colorCatalog.manufacturer")}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("inventory.material")}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium",children:t("settings.colorCatalog.colorName")}),a.jsx("th",{className:"px-3 py-2 text-left text-bambu-gray font-medium w-24",children:t("settings.colorCatalog.hex")}),a.jsx("th",{className:"px-3 py-2 w-16"})]})}),a.jsx("tbody",{children:ce.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:6,className:"px-3 py-8 text-center text-bambu-gray",children:t(o||c?"settings.colorCatalog.noMatch":"settings.colorCatalog.empty")})}):ce.map(O=>a.jsx("tr",{className:"border-t border-bambu-dark-tertiary hover:bg-bambu-dark",children:p===O.id?a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"color",className:"w-8 h-8 rounded cursor-pointer border border-bambu-dark-tertiary",value:N,onChange:q=>A(q.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:v,onChange:q=>g(q.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:C,onChange:q=>j(q.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:y,onChange:q=>_(q.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsx("input",{type:"text",className:"w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",value:N,onChange:q=>A(q.target.value)})}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>be(O.id),disabled:k,className:"p-1.5 rounded hover:bg-green-500/20 text-green-500",children:k?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Zr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:pe,className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(Ut,{className:"w-4 h-4"})})]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("td",{className:"px-3 py-2",children:a.jsx("div",{className:"w-8 h-8 rounded border border-bambu-dark-tertiary",style:{backgroundColor:O.hex_color},title:O.hex_color})}),a.jsx("td",{className:"px-3 py-2 text-white",children:O.manufacturer}),a.jsx("td",{className:"px-3 py-2 text-bambu-gray",children:O.material||"-"}),a.jsx("td",{className:"px-3 py-2 text-white",children:O.color_name}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-bambu-gray",children:O.hex_color}),a.jsx("td",{className:"px-3 py-2",children:a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx("button",{onClick:()=>ue(O),className:"p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Ka,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>L(O),className:"p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500",children:a.jsx(Xt,{className:"w-4 h-4"})})]})})]})},O.id))})]})})]}),W&&a.jsx(Sn,{title:t("settings.colorCatalog.deleteColor"),message:t("settings.colorCatalog.deleteConfirm",{name:`${W.manufacturer} - ${W.color_name}`}),confirmText:t("common.delete"),variant:"danger",onConfirm:Ee,onCancel:()=>L(null)}),ee&&a.jsx(Sn,{title:t("settings.colorCatalog.resetCatalog"),message:t("settings.colorCatalog.resetConfirm"),confirmText:t("common.reset"),variant:"danger",onConfirm:$,onCancel:()=>ae(!1)})]})}function WZe({link:t,onClose:e}){const{t:n}=Et(),r=Qt(),i=!!t,s=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,h]=w.useState(t?.icon||"link"),[f,p]=w.useState(t?.open_in_new_tab||!1),[x,v]=w.useState(!!t?.custom_icon),[g,y]=w.useState(t?.custom_icon?ge.getExternalLinkIconUrl(t.id):null),[_,N]=w.useState(null),[A,C]=w.useState(null);w.useEffect(()=>{const W=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[e]);const j=ut({mutationFn:async W=>{const L=await ge.createExternalLink(W);return _?await ge.uploadExternalLinkIcon(L.id,_):L},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:W=>{C(W.message)}}),k=ut({mutationFn:async W=>{let L=await ge.updateExternalLink(t.id,W);return _?L=await ge.uploadExternalLinkIcon(t.id,_):!x&&t?.custom_icon&&(L=await ge.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{r.invalidateQueries({queryKey:["external-links"]}),e()},onError:W=>{C(W.message)}}),R=W=>{const L=W.target.files?.[0];if(L){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(L.type)){C("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(L.size>1024*1024){C("Image file must be less than 1MB");return}N(L),v(!0);const ae=new FileReader;ae.onload=Y=>{y(Y.target?.result)},ae.readAsDataURL(L)}},M=()=>{N(null),y(null),v(!1),s.current&&(s.current.value="")},D=W=>{if(W.preventDefault(),C(null),!o.trim()){C("Name is required");return}if(!c.trim()){C("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){C("URL must start with http:// or https://");return}const L={name:o.trim(),url:c.trim(),icon:d,open_in_new_tab:f};i?k.mutate(L):j.mutate(L)},G=j.isPending||k.isPending,U=uC(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:W=>W.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:x&&g?a.jsx("img",{src:g,alt:"",className:"w-5 h-5 rounded"}):a.jsx(U,{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(Ut,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:D,className:"p-6 space-y-4",children:[A&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:A}),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:W=>l(W.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:W=>u(W.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:()=>p(!f),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${f?"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 ${f?"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}),x&&g?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:g,alt:"Custom icon",className:"w-8 h-8 rounded border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:M,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:a.jsx(Xt,{className:"w-4 h-4"})})]}):a.jsxs(Oe,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[a.jsx(Ia,{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."})]}),!x&&a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),a.jsx(Vge,{value:d,onChange:h})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Oe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Oe,{type:"submit",disabled:G,className:"flex-1",children:[G?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function KZe(){const{t}=Et(),e=Qt(),[n,r]=w.useState(!1),[i,s]=w.useState(null),[o,l]=w.useState(null),[c,u]=w.useState(null),{data:d,isLoading:h}=Je({queryKey:["external-links"],queryFn:ge.getExternalLinks}),f=ut({mutationFn:N=>ge.deleteExternalLink(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),p=ut({mutationFn:N=>ge.reorderExternalLinks(N),onSuccess:()=>{e.invalidateQueries({queryKey:["external-links"]})}}),x=(N,A)=>{u(A),N.dataTransfer.effectAllowed="move"},v=N=>{N.preventDefault(),N.dataTransfer.dropEffect="move"},g=(N,A)=>{if(N.preventDefault(),c===null||c===A||!d)return;const C=d.map(M=>M.id),j=C.indexOf(c),k=C.indexOf(A);if(j===-1||k===-1)return;const R=[...C];R.splice(j,1),R.splice(k,0,c),p.mutate(R),u(null)},y=N=>{l(N)},_=()=>{o&&(f.mutate(o.id),l(null))};return a.jsxs(a.Fragment,{children:[a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ih,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),a.jsxs(Oe,{size:"sm",onClick:()=>r(!0),children:[a.jsx(nr,{className:"w-4 h-4"}),"Add Link"]})]})}),a.jsxs(Tt,{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 A=uC(N.icon);return a.jsxs("div",{draggable:!0,onDragStart:C=>x(C,N.id),onDragOver:v,onDrop:C=>g(C,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(Oh,{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(A,{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(aa,{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(Ka,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>y(N),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:t("externalLinks.deleteLink"),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]},N.id)})}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Ih,{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(WZe,{link:i,onClose:()=>{r(!1),s(null)}}),o&&a.jsx(Sn,{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:_,onCancel:()=>l(null)})]})}const IE={immediate:"archive",review:"review",print_queue:"queue",proxy:"proxy"};function YZe({printer:t,models:e}){const{t:n}=Et(),r=Qt(),{showToast:i}=dn(),[s,o]=w.useState(!0),[l,c]=w.useState(t.enabled),[u,d]=w.useState(t.name),[h,f]=w.useState(""),[p,x]=w.useState(t.mode==="queue"?"review":t.mode),[v,g]=w.useState(t.target_printer_id),[y,_]=w.useState(t.bind_ip||""),[N,A]=w.useState(t.remote_interface_ip||""),[C,j]=w.useState(t.model||""),[k,R]=w.useState(!1),[M,D]=w.useState(null),[G,U]=w.useState(!1);w.useEffect(()=>{M||(c(t.enabled),x(t.mode==="queue"?"review":t.mode),d(t.name),g(t.target_printer_id),_(t.bind_ip||""),A(t.remote_interface_ip||""),j(t.model||""))},[t,M]);const{data:W}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:L}=Je({queryKey:["network-interfaces"],queryFn:()=>ge.getNetworkInterfaces().then(K=>K.interfaces)}),ee=ut({mutationFn:K=>F1.update(t.id,K),onSuccess:()=>{r.invalidateQueries({queryKey:["virtual-printers"]}),i(n("virtualPrinter.toast.updated")),D(null)},onError:K=>{i(K.message||n("virtualPrinter.toast.failedToUpdate"),"error"),c(t.enabled),x(t.mode==="queue"?"review":t.mode),g(t.target_printer_id),_(t.bind_ip||""),D(null)}}),ae=ut({mutationFn:()=>F1.remove(t.id),onSuccess:()=>{r.invalidateQueries({queryKey:["virtual-printers"]}),i(n("virtualPrinter.toast.deleted")),U(!1)},onError:K=>{i(K.message||n("virtualPrinter.toast.failedToDelete"),"error"),U(!1)}}),Y=K=>{K.stopPropagation();const T=!l;if(T){if(!y){i(n("virtualPrinter.toast.bindIpRequired"),"error");return}if(p==="proxy"){if(!v){i(n("virtualPrinter.toast.targetPrinterRequired"),"error");return}}else if(!h&&!t.access_code_set){i(n("virtualPrinter.toast.accessCodeRequired"),"error");return}}c(T),D("toggle"),ee.mutate({enabled:T})},se=()=>{u.trim()&&(D("name"),ee.mutate({name:u.trim()}))},ce=()=>{if(!h){i(n("virtualPrinter.toast.accessCodeEmpty"),"error");return}if(h.length!==8){i(n("virtualPrinter.toast.accessCodeLength"),"error");return}D("accessCode"),ee.mutate({access_code:h}),f("")},ye=K=>{x(K),D("mode"),ee.mutate({mode:K})},Z=K=>{j(K),D("model"),ee.mutate({model:K})},ue=K=>{g(K),D("targetPrinter"),ee.mutate({target_printer_id:K})},pe=K=>{A(K),D("remoteInterface"),ee.mutate({remote_interface_ip:K})},be=t.status?.running||!1,Ee=n(`virtualPrinter.mode.${IE[p]||"archive"}`),$=W?.find(K=>K.id===v)?.name;return a.jsxs(a.Fragment,{children:[a.jsxs(Ct,{children:[a.jsxs("div",{className:"px-4 py-3 flex items-center gap-3 cursor-pointer select-none",onClick:()=>o(!s),children:[a.jsx("button",{className:"text-bambu-gray flex-shrink-0",children:s?a.jsx(En,{className:"w-4 h-4"}):a.jsx(pi,{className:"w-4 h-4"})}),a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${be?"bg-green-400 animate-pulse":"bg-gray-500"}`}),a.jsx("span",{className:"text-white font-medium truncate",children:t.name}),a.jsx("span",{className:"text-xs text-bambu-gray flex-shrink-0",children:Ee}),t.model_name&&a.jsx("span",{className:"text-xs text-bambu-gray flex-shrink-0",children:t.model_name}),$&&a.jsxs("span",{className:"text-xs text-bambu-gray flex-shrink-0 truncate",children:[p==="proxy"&&a.jsx(m3,{className:"w-3 h-3 inline mr-1"}),$]}),y&&a.jsx("span",{className:"text-[10px] text-bambu-gray flex-shrink-0 font-mono",children:y}),N&&a.jsx("span",{className:"text-[10px] text-bambu-gray flex-shrink-0 font-mono",children:N}),a.jsx("div",{className:"ml-auto flex items-center gap-2 flex-shrink-0",onClick:K=>K.stopPropagation(),children:a.jsx("button",{onClick:Y,disabled:M==="toggle",className:`relative w-10 h-5 rounded-full transition-colors ${l?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${M==="toggle"?"opacity-50":""}`,children:a.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${l?"translate-x-5":""}`})})})]}),s&&a.jsxs(Tt,{className:"pt-0 space-y-4",children:[a.jsx("div",{className:"border-t border-bambu-dark-tertiary"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"text",value:u,onChange:K=>d(K.target.value),onBlur:se,onKeyDown:K=>K.key==="Enter"&&se(),className:"flex-1 text-sm text-white bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-xs text-bambu-gray font-mono",children:t.serial}),a.jsx("button",{onClick:()=>U(!0),className:"p-1.5 text-bambu-gray hover:text-red-400 transition-colors",title:n("common.delete"),children:a.jsx(Xt,{className:"w-4 h-4"})})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-white text-sm font-medium mb-2",children:n("virtualPrinter.mode.title")}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:["immediate","review","print_queue","proxy"].map(K=>a.jsxs("button",{onClick:()=>ye(K),disabled:M==="mode",className:`p-2 rounded-lg border text-left transition-colors ${p===K?K==="proxy"?"border-blue-500 bg-blue-500/10":"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-white text-xs font-medium",children:[K==="proxy"&&a.jsx(m3,{className:"w-3 h-3"}),n(`virtualPrinter.mode.${IE[K]}`)]}),a.jsx("div",{className:"text-[10px] text-bambu-gray",children:n(`virtualPrinter.mode.${IE[K]}Desc`)})]},K))})]}),p!=="proxy"&&a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white text-sm font-medium mb-1",children:n("virtualPrinter.model.title")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:n("virtualPrinter.model.description")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:C,onChange:K=>Z(K.target.value),disabled:M==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10",children:Object.entries(e).map(([K,T])=>a.jsxs("option",{value:K,children:[T," (",K,")"]},K))}),a.jsx(En,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),p==="proxy"&&a.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-start gap-2 p-2 rounded bg-blue-500/10 border border-blue-500/30",children:[a.jsx(to,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("virtualPrinter.proxy.accessCodeHint")})]})}),p!=="proxy"&&a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("div",{className:"text-white text-sm font-medium",children:n("virtualPrinter.accessCode.title")}),t.access_code_set?a.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-400",children:[a.jsx(Zr,{className:"w-3 h-3"}),n("virtualPrinter.accessCode.isSet")]}):a.jsxs("span",{className:"flex items-center gap-1 text-xs text-yellow-400",children:[a.jsx(Mn,{className:"w-3 h-3"}),n("virtualPrinter.accessCode.notSet")]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:k?"text":"password",value:h,onChange:K=>f(K.target.value),placeholder:t.access_code_set?n("virtualPrinter.accessCode.placeholderChange"):n("virtualPrinter.accessCode.placeholder"),maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm placeholder-bambu-gray pr-10 font-mono"}),a.jsx("button",{onClick:()=>R(!k),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:k?a.jsx(yv,{className:"w-4 h-4"}):a.jsx(tc,{className:"w-4 h-4"})})]}),a.jsx(Oe,{onClick:ce,disabled:!h||M==="accessCode",variant:"primary",children:M==="accessCode"?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):n("common.save")})]}),h&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a.jsx("span",{className:h.length===8?"text-green-400":"text-yellow-400",children:n("virtualPrinter.accessCode.charCount",{count:h.length})})})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white text-sm font-medium mb-2",children:n("virtualPrinter.targetPrinter.title")}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:v??"",onChange:K=>{const T=parseInt(K.target.value,10);isNaN(T)||ue(T)},disabled:M==="targetPrinter",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10",children:[a.jsx("option",{value:"",children:n("virtualPrinter.targetPrinter.placeholder")}),W?.map(K=>a.jsxs("option",{value:K.id,children:[K.name," (",K.ip_address,")"]},K.id))]}),a.jsx(En,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white text-sm font-medium mb-1",children:n("virtualPrinter.bindIp.title")}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:y,onChange:K=>{_(K.target.value),D("bindIp"),ee.mutate({bind_ip:K.target.value})},disabled:M==="bindIp",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10",children:[a.jsx("option",{value:"",children:n("virtualPrinter.bindIp.placeholder")}),L?.map(K=>a.jsxs("option",{value:K.ip,children:[K.name," (",K.ip,")",K.is_alias?" [alias]":""," - ",K.subnet]},K.ip))]}),a.jsx(En,{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:n("virtualPrinter.bindIp.hint")})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("div",{className:"text-white text-sm font-medium",children:n("virtualPrinter.remoteInterface.title")}),N?a.jsx("span",{className:"flex items-center gap-1 text-xs text-green-400",children:a.jsx(Zr,{className:"w-3 h-3"})}):a.jsx("span",{className:"flex items-center gap-1 text-xs text-bambu-gray",title:n("virtualPrinter.remoteInterface.optional"),children:a.jsx(to,{className:"w-3 h-3"})})]}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:N,onChange:K=>pe(K.target.value),disabled:M==="remoteInterface",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10",children:[a.jsx("option",{value:"",children:n("virtualPrinter.remoteInterface.placeholder")}),L?.map(K=>a.jsxs("option",{value:K.ip,children:[K.name," (",K.ip,") - ",K.subnet]},K.ip))]}),a.jsx(En,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]})]}),G&&a.jsx(Sn,{title:n("virtualPrinter.deleteConfirm.title"),message:n("virtualPrinter.deleteConfirm.message",{name:t.name}),variant:"danger",confirmText:n("common.delete"),isLoading:ae.isPending,onConfirm:()=>ae.mutate(),onCancel:()=>U(!1)})]})}const yK={immediate:"archive",review:"review",print_queue:"queue",proxy:"proxy"};function XZe({onClose:t}){const{t:e}=Et(),n=Qt(),{showToast:r}=dn(),[i,s]=w.useState(""),[o,l]=w.useState("immediate"),[c,u]=w.useState(null),{data:d}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),h=ut({mutationFn:()=>F1.create({name:i.trim()||"Bambuddy",mode:o,target_printer_id:o==="proxy"?c??void 0:void 0}),onSuccess:()=>{n.invalidateQueries({queryKey:["virtual-printers"]}),r(e("virtualPrinter.toast.created")),t()},onError:f=>{r(f.message||e("virtualPrinter.toast.failedToCreate"),"error")}});return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:a.jsx(Ct,{className:"w-full max-w-md",onClick:f=>f.stopPropagation(),children:a.jsxs(Tt,{className:"p-6 space-y-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:e("virtualPrinter.addDialog.title")}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm text-white font-medium block mb-1",children:e("virtualPrinter.addDialog.name")}),a.jsx("input",{type:"text",value:i,onChange:f=>s(f.target.value),placeholder:"Bambuddy",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm placeholder-bambu-gray",autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm text-white font-medium block mb-1",children:e("virtualPrinter.mode.title")}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:["immediate","review","print_queue","proxy"].map(f=>a.jsxs("button",{onClick:()=>l(f),className:`p-2 rounded-lg border text-left transition-colors ${o===f?f==="proxy"?"border-blue-500 bg-blue-500/10":"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-white text-xs font-medium",children:[f==="proxy"&&a.jsx(m3,{className:"w-3 h-3"}),e(`virtualPrinter.mode.${yK[f]}`)]}),a.jsx("div",{className:"text-[10px] text-bambu-gray",children:e(`virtualPrinter.mode.${yK[f]}Desc`)})]},f))})]}),o==="proxy"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-sm text-white font-medium block mb-1",children:e("virtualPrinter.targetPrinter.title")}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:c??"",onChange:f=>{const p=parseInt(f.target.value,10);u(isNaN(p)?null:p)},className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm appearance-none cursor-pointer pr-10",children:[a.jsx("option",{value:"",children:e("virtualPrinter.targetPrinter.placeholder")}),d?.map(f=>a.jsxs("option",{value:f.id,children:[f.name," (",f.ip_address,")"]},f.id))]}),a.jsx(En,{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",children:e("virtualPrinter.addDialog.hint")}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Oe,{variant:"secondary",onClick:t,className:"flex-1",disabled:h.isPending,children:e("common.cancel")}),a.jsx(Oe,{variant:"primary",onClick:()=>h.mutate(),className:"flex-1",disabled:h.isPending,children:h.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):e("virtualPrinter.addDialog.create")})]})]})})})}function QZe(){const{t}=Et(),[e,n]=w.useState(!1),{data:r,isLoading:i}=Je({queryKey:["virtual-printers"],queryFn:F1.list,refetchInterval:1e4});if(i)return a.jsx(Ct,{children:a.jsx(Tt,{className:"py-8 flex justify-center",children:a.jsx(lt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const s=r?.printers||[],o=r?.models||{};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-4 items-stretch",children:[a.jsx(Ct,{className:"border-l-4 border-l-yellow-500",children:a.jsx(Tt,{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Mn,{className:"w-4 h-4 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-xs",children:[a.jsx("p",{className:"text-white font-medium",children:t("virtualPrinter.setupRequired.title")}),a.jsx("p",{className:"text-bambu-gray mt-1",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-1.5 mt-2 px-3 py-1.5 bg-yellow-500/20 border border-yellow-500/50 rounded text-yellow-400 hover:bg-yellow-500/30 transition-colors text-xs",children:[a.jsx(aa,{className:"w-3 h-3"}),t("virtualPrinter.setupRequired.readGuide")]})]})]})})}),a.jsx(Ct,{className:"lg:col-span-3",children:a.jsx(Tt,{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(to,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:t("virtualPrinter.howItWorks.title")}),a.jsxs("ul",{className:"space-y-1 list-disc list-inside",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.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.list.title")}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",s.length,")"]})]}),a.jsxs(Oe,{variant:"primary",onClick:()=>n(!0),children:[a.jsx(nr,{className:"w-4 h-4 mr-1"}),t("virtualPrinter.list.add")]})]}),s.length===0?a.jsx(Ct,{children:a.jsxs(Tt,{className:"py-8 text-center",children:[a.jsx(Dr,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("virtualPrinter.list.empty")}),a.jsxs(Oe,{variant:"primary",onClick:()=>n(!0),children:[a.jsx(nr,{className:"w-4 h-4 mr-1"}),t("virtualPrinter.list.addFirst")]})]})}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 items-start",children:s.map(l=>a.jsx(YZe,{printer:l,models:o},l.id))}),e&&a.jsx(XZe,{onClose:()=>n(!1)})]})}function vK({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(xr,{className:"w-3 h-3"}),failed:a.jsx(ii,{className:"w-3 h-3"}),skipped:a.jsx(BF,{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 ZZe(t){return t?new Date(t).toLocaleString():"-"}function JZe(){const t=Qt(),{showToast:e}=dn(),{t:n}=Et(),[r,i]=w.useState(""),[s,o]=w.useState(""),[l,c]=w.useState("main"),[u,d]=w.useState(!1),[h,f]=w.useState("daily"),[p,x]=w.useState(!0),[v,g]=w.useState(!0),[y,_]=w.useState(!1),[N,A]=w.useState(!0),[C,j]=w.useState(!1),[k,R]=w.useState(!1),[M,D]=w.useState(""),[G,U]=w.useState(!1),[W,L]=w.useState(null),[ee,ae]=w.useState(null),Y=w.useRef(null);w.useEffect(()=>{if(C||k){const I=F=>(F.preventDefault(),F.returnValue="A backup operation is in progress. Are you sure you want to leave?",F.returnValue);return window.addEventListener("beforeunload",I),()=>window.removeEventListener("beforeunload",I)}},[C,k]);const[se,ce]=w.useState(!1),[ye,Z]=w.useState(null),ue=w.useRef(null),pe=w.useRef(!1),{data:be,isLoading:Ee}=Je({queryKey:["github-backup-config"],queryFn:ge.getGitHubBackupConfig}),{data:$}=Je({queryKey:["github-backup-status"],queryFn:ge.getGitHubBackupStatus,refetchInterval:oe=>oe.state.data?.is_running?500:1e4}),{data:K}=Je({queryKey:["github-backup-logs"],queryFn:()=>ge.getGitHubBackupLogs(20)}),{data:T}=Je({queryKey:["cloud-status"],queryFn:ge.getCloudStatus}),{data:E}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),O=Qb({queries:(E??[]).map(oe=>({queryKey:["printerStatus",oe.id],queryFn:()=>ge.getPrinterStatus(oe.id),staleTime:1e4,refetchInterval:3e4}))}),q=(E??[]).map((oe,I)=>({printer:oe,connected:O[I]?.data?.connected??!1})),B=q.length,re=q.filter(oe=>oe.connected).length,z=B>0&&re===0,V=re>0&&re<B;w.useEffect(()=>{be&&(i(be.repository_url),c(be.branch),d(be.schedule_enabled),f(be.schedule_type),x(be.backup_kprofiles),g(be.backup_cloud_profiles),_(be.backup_settings),A(be.enabled),o(""),setTimeout(()=>{pe.current=!0},100))},[be]);const te=w.useCallback(async(oe=!1)=>{if(be?.has_token)try{oe&&s?(await ge.saveGitHubBackupConfig({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:p,backup_cloud_profiles:v,backup_settings:y,enabled:N}),o(""),e("Token updated")):(await ge.updateGitHubBackupConfig({repository_url:r,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:p,backup_cloud_profiles:v,backup_settings:y,enabled:N}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(I){e(`Failed to save: ${I.message}`,"error")}},[be?.has_token,r,s,l,u,h,p,v,y,N,t,e]);w.useEffect(()=>{if(!(!pe.current||!be?.has_token))return ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>{te(!1)},500),()=>{ue.current&&clearTimeout(ue.current)}},[r,l,u,h,p,v,y,N,te,be?.has_token]),w.useEffect(()=>{if(!(!pe.current||!be?.has_token||!s))return ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>{te(!0)},1e3),()=>{ue.current&&clearTimeout(ue.current)}},[s,te,be?.has_token]);const Q=ut({mutationFn:oe=>ge.saveGitHubBackupConfig(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),o(""),pe.current=!0},onError:oe=>{e(`Failed to save: ${oe.message}`,"error")}}),ne=ut({mutationFn:ge.triggerGitHubBackup,onSuccess:oe=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),oe.success?oe.files_changed>0?e(`Backup complete - ${oe.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${oe.message}`,"error")},onError:oe=>{e(`Backup failed: ${oe.message}`,"error")}}),ie=ut({mutationFn:()=>ge.clearGitHubBackupLogs(0),onSuccess:oe=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${oe.deleted} logs`)},onError:oe=>{e(`Failed to clear logs: ${oe.message}`,"error")}}),me=async()=>{ce(!0),Z(null);try{let oe;if(s){if(!r){e("Enter repository URL","error"),ce(!1);return}oe=await ge.testGitHubConnection(r,s)}else if(be?.has_token)oe=await ge.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),ce(!1);return}Z({success:oe.success,message:oe.message})}catch(oe){Z({success:!1,message:oe.message})}finally{ce(!1)}},fe=()=>{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:p,backup_cloud_profiles:v,backup_settings:y,enabled:N})};return Ee?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(Ct,{children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(p3,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),be&&T?.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($n,{checked:N,onChange:A})]})]})}),a.jsx(Tt,{className:"space-y-4",children:T?.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:oe=>{i(oe.target.value),Z(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 ",be?.has_token&&a.jsx("span",{className:"text-green-400",children:"(saved)"})]}),a.jsx("input",{type:"password",value:s,onChange:oe=>{o(oe.target.value),Z(null)},placeholder:be?.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:oe=>c(oe.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:oe=>{oe.target.value==="disabled"?d(!1):(d(!0),f(oe.target.value))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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 ${z?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[a.jsx("input",{type:"checkbox",checked:p,onChange:oe=>x(oe.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:z}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`text-sm ${z?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),z&&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(Mn,{className:"w-3 h-3"}),"No printers connected"]}),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(Mn,{className:"w-3 h-3"}),re,"/",B," 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:v,onChange:oe=>g(oe.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:!T?.is_authenticated}),a.jsxs("div",{children:[a.jsx("span",{className:`text-sm ${T?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:y,onChange:oe=>_(oe.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:[$?.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:$.last_backup_at?a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:["Last backup: ",C0($.last_backup_at,"system",n)]}),a.jsx(vK,{status:$.last_backup_status})]}):a.jsx("span",{children:"No backups yet"})}),$.next_scheduled_run&&a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx(Xn,{className:"w-3 h-3 inline mr-1"}),"Next: ",C0($.next_scheduled_run,"system",n)]})]}),ye&&a.jsxs("div",{className:`text-sm flex items-center gap-1 ${ye.success?"text-green-400":"text-red-400"}`,children:[ye.success?a.jsx(xr,{className:"w-4 h-4"}):a.jsx(ii,{className:"w-4 h-4"}),ye.message]}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:$?.configured?a.jsx(a.Fragment,{children:ne.isPending||$.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:$.progress||"Starting backup..."})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Oe,{variant:"primary",size:"sm",onClick:()=>ne.mutate(),disabled:!be?.enabled,children:[a.jsx(lo,{className:"w-4 h-4"}),"Backup Now"]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:me,disabled:se,children:[se?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(wr,{className:"w-4 h-4"}),"Test"]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(Oe,{variant:"primary",size:"sm",onClick:fe,disabled:Q.isPending||!r||!s,children:[Q.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(xr,{className:"w-4 h-4"}),"Enable Backup"]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:me,disabled:se||!r||!s,children:[se?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(wr,{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(Mn,{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."})]})})]}),K&&K.length>0&&a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(N0,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),a.jsxs(Oe,{variant:"ghost",size:"sm",onClick:()=>ie.mutate(),disabled:ie.isPending,children:[a.jsx(Xt,{className:"w-4 h-4"}),"Clear"]})]})}),a.jsx(Tt,{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:K.slice(0,10).map(oe=>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:ZZe(oe.started_at)}),a.jsx("td",{className:"py-2 px-2",children:a.jsx(vK,{status:oe.status})}),a.jsx("td",{className:"py-2 px-2",children:oe.commit_sha?a.jsxs("a",{href:`${be?.repository_url}/commit/${oe.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[oe.commit_sha.substring(0,7),a.jsx(aa,{className:"w-3 h-3"})]}):a.jsx("span",{className:"text-bambu-gray",children:"-"})})]},oe.id))})]})})})]})]}),a.jsx("div",{className:"space-y-6",children:a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Dc,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),a.jsxs(Tt,{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(Oe,{variant:"secondary",size:"sm",disabled:C||k,onClick:async()=>{j(!0),D("Preparing backup...");try{D("Creating backup archive... This may take a while for large archives.");const{blob:oe,filename:I}=await ge.exportBackup();D("Downloading backup file...");const F=URL.createObjectURL(oe),J=document.createElement("a");J.href=F,J.download=I,J.click(),URL.revokeObjectURL(F),e("Backup downloaded successfully")}catch(oe){e(`Failed to create backup: ${oe instanceof Error?oe.message:"Unknown error"}`,"error")}finally{j(!1),D("")}},children:[a.jsx(ba,{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:Y,type:"file",accept:".zip",className:"hidden",onChange:oe=>{const I=oe.target.files?.[0];I&&(L(I),U(!0)),oe.target.value=""}}),a.jsxs(Oe,{variant:"secondary",size:"sm",disabled:k||C,onClick:()=>Y.current?.click(),children:[a.jsx(Ia,{className:"w-4 h-4"}),"Restore"]})]}),ee&&a.jsx("div",{className:`p-3 rounded-lg ${ee.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:[ee.success?a.jsx(xr,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):a.jsx(ii,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:ee.success?"text-green-200":"text-red-200",children:[ee.message,ee.success&&a.jsx("div",{className:"mt-2",children:a.jsxs(Oe,{size:"sm",onClick:()=>window.location.reload(),children:[a.jsx(co,{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(Mn,{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."})]})]})})]})]})}),G&&W&&a.jsx(Sn,{title:"Restore Backup",message:`Are you sure you want to restore from "${W.name}"? This will completely replace your current database and all files. The application will need to be restarted after restore.`,confirmText:"Restore Backup",variant:"danger",onConfirm:async()=>{U(!1),R(!0),ae(null);try{D("Uploading backup file...");const oe=await ge.importBackup(W);ae(oe),oe.success?e("Backup restored. Please restart Bambuddy.","success"):e(oe.message,"error")}catch(oe){const I=oe instanceof Error?oe.message:"Failed to restore backup";ae({success:!1,message:I}),e(I,"error")}finally{R(!1),D(""),L(null)}},onCancel:()=>{U(!1),L(null)}}),(C||k)&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),a.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:C?"Creating Backup":"Restoring Backup"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:M||(C?"Preparing...":"Processing...")}),a.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(Mn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-yellow-200 text-left",children:"Please do not close this page or navigate away. This operation may take several minutes for large backups."})]})})]})})]})}const eJe={starttls:587,ssl:465,none:25},tJe={587:"starttls",465:"ssl",25:"none"};function nJe(){const{t}=Et(),{showToast:e}=dn(),n=Qt(),[r,i]=w.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]=w.useState(""),{data:l,isLoading:c}=Je({queryKey:["smtpSettings"],queryFn:()=>ge.getSMTPSettings()}),{data:u}=Je({queryKey:["advancedAuthStatus"],queryFn:()=>ge.getAdvancedAuthStatus()});w.useEffect(()=>{l&&i({...l,smtp_password:""})},[l]);const d=j=>{i({...r,smtp_security:j,smtp_port:eJe[j]})},h=j=>{const k=tJe[j];i({...r,smtp_port:j,...k?{smtp_security:k}:{}})},f=j=>{i({...r,smtp_auth_enabled:j,...j?{}:{smtp_username:"",smtp_password:""}})},p=ut({mutationFn:j=>ge.saveSMTPSettings(j),onSuccess:()=>{n.invalidateQueries({queryKey:["smtpSettings"]}),n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(t("settings.email.success.settingsSaved"),"success")},onError:j=>{e(j.message,"error")}}),x=ut({mutationFn:j=>ge.testSMTP(j),onSuccess:j=>{e(j.message,j.success?"success":"error")},onError:j=>{e(j.message,"error")}}),v=ut({mutationFn:j=>j?ge.enableAdvancedAuth():ge.disableAdvancedAuth(),onSuccess:j=>{n.invalidateQueries({queryKey:["advancedAuthStatus"]}),e(j.message,"success")},onError:j=>{e(j.message,"error")}}),g=()=>{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}p.mutate(r)},y=()=>{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}x.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})},_=()=>{if(!u?.advanced_auth_enabled&&!u?.smtp_configured){e(t("settings.email.errors.configureSmtpFirst"),"error");return}v.mutate(!u?.advanced_auth_enabled)};if(c)return 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"})});const N=u?.advanced_auth_enabled??!1,A="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",C="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white/40 placeholder-bambu-gray/40 cursor-not-allowed";return a.jsxs("div",{className:"space-y-6",children:[a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(k0,{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(Oe,{onClick:_,disabled:v.isPending,variant:N?"danger":"primary",children:N?a.jsxs(a.Fragment,{children:[a.jsx(Q_,{className:"w-4 h-4"}),t("settings.email.disable")||"Disable"]}):a.jsxs(a.Fragment,{children:[a.jsx(Vm,{className:"w-4 h-4"}),t("settings.email.enable")||"Enable"]})})]})}),a.jsx(Tt,{children:a.jsx("div",{className:"space-y-4",children:N?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(xr,{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(Mn,{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.jsx("div",{className:N?"":"opacity-50 pointer-events-none",children:a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.smtpSettings")||"SMTP Configuration"})}),a.jsx(Tt,{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.authentication")||"Authentication"}),a.jsxs("select",{value:r.smtp_auth_enabled?"true":"false",onChange:j=>f(j.target.value==="true"),className:A,children:[a.jsx("option",{value:"true",children:t("settings.email.authOptions.enabled")}),a.jsx("option",{value:"false",children:t("settings.email.authOptions.disabled")})]})]}),a.jsxs("div",{className:`grid grid-cols-1 md:grid-cols-2 gap-4 transition-opacity ${r.smtp_auth_enabled?"":"opacity-40 pointer-events-none"}`,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:j=>i({...r,smtp_username:j.target.value}),placeholder:"your.email@gmail.com",disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?A:C})]}),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:j=>i({...r,smtp_password:j.target.value}),placeholder:l?"••••••••":"App password",disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?A:C})]})]}),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:j=>i({...r,smtp_host:j.target.value}),placeholder:"smtp.gmail.com",className:A})]}),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:j=>h(parseInt(j.target.value)||587),placeholder:"587",className:A})]})]}),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:j=>d(j.target.value),className:A,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",{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:j=>i({...r,smtp_from_email:j.target.value}),placeholder:"your@email.com",className:A})]}),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:j=>i({...r,smtp_from_name:j.target.value}),placeholder:"BamBuddy",className:A})]})]}),a.jsx("div",{className:"flex gap-2",children:a.jsx(Oe,{onClick:g,disabled:p.isPending,className:"flex-1",children:p.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.jsx("div",{className:N?"":"opacity-50 pointer-events-none",children:a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("settings.email.testConnection")||"Test SMTP Connection"})}),a.jsx(Tt,{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:j=>o(j.target.value),placeholder:"test@example.com",className:A})]}),a.jsx(Oe,{onClick:y,disabled:x.isPending,variant:"secondary",children:x.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(sC,{className:"w-4 h-4"}),t("settings.email.sendTest")||"Send Test Email"]})})]})})]})})]})}const rJe={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 aJe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function Ky(t,e,n=0){if(n>5)return"...";if(e.$ref)return Ky(t,aJe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const s=Ky(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?[Ky(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,s]of Object.entries(e.properties))r[i]=Ky(t,s,n+1);return r}return{};default:return null}}function iJe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[s,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[h,f]=w.useState(null),[p,x]=w.useState(!1),[v,g]=w.useState(!1);w.useEffect(()=>{if(s&&n.parameters){const R={};for(const M of n.parameters)M.schema?.default!==void 0&&(R[M.name]=String(M.schema.default));c(M=>({...R,...M}))}},[s,n.parameters]),w.useEffect(()=>{if(s&&n.requestBody?.content?.["application/json"]?.schema&&!u){const R=n.requestBody.content["application/json"].schema,M=Ky(r,R);d(JSON.stringify(M,null,2))}},[s,n.requestBody,r,u]);const _=(()=>{const R=[];for(const M of n.parameters||[])if(M.in==="path"||M.required){const D=l[M.name];(D===void 0||D==="")&&R.push(M.name)}return R})(),N=async()=>{if(_.length>0){f({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${_.join(", ")}`,duration:0});return}x(!0),f(null);try{let R=t;const M=new URLSearchParams;for(const ye of n.parameters||[]){const Z=l[ye.name];Z!==void 0&&Z!==""&&(ye.in==="path"?R=R.replace(`{${ye.name}}`,encodeURIComponent(Z)):ye.in==="query"&&M.append(ye.name,Z))}const D=M.toString(),G=`${R}${D?`?${D}`:""}`,U={"Content-Type":"application/json"};i&&(U["X-API-Key"]=i);const W={method:e.toUpperCase(),headers:U};["post","put","patch"].includes(e)&&u&&(W.body=u);const L=performance.now(),ee=await fetch(G,W),ae=Math.round(performance.now()-L),Y={};ee.headers.forEach((ye,Z)=>{Y[Z]=ye});let se;ee.headers.get("content-type")?.includes("application/json")?se=await ee.json():se=await ee.text(),f({status:ee.status,statusText:ee.statusText,headers:Y,body:se,duration:ae})}catch(R){f({status:0,statusText:"Network Error",headers:{},body:R instanceof Error?R.message:"Unknown error",duration:0})}finally{x(!1)}},A=async()=>{if(h){const R=typeof h.body=="string"?h.body:JSON.stringify(h.body,null,2);try{await navigator.clipboard.writeText(R),g(!0),setTimeout(()=>g(!1),2e3)}catch{const M=document.createElement("textarea");M.value=R,M.style.position="fixed",M.style.left="-999999px",document.body.appendChild(M),M.select(),document.execCommand("copy"),document.body.removeChild(M),g(!0),setTimeout(()=>g(!1),2e3)}}},C=(n.parameters||[]).filter(R=>R.in==="path"),j=(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(En,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):a.jsx(pi,{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 ${rJe[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}),C.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:C.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:M=>c(D=>({...D,[R.name]:M.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))})]}),j.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:j.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:M=>c(D=>({...D,[R.name]:M.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(M=>a.jsx("option",{value:M,children:M},M))]}):a.jsx("input",{type:"text",value:l[R.name]||"",onChange:M=>c(D=>({...D,[R.name]:M.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(Oe,{onClick:N,disabled:p,children:[p?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(lo,{className:"w-4 h-4"}),"Execute"]}),_.length>0&&a.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[a.jsx(qa,{className:"w-3 h-3"}),"Fill in: ",_.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(Oe,{variant:"secondary",size:"sm",onClick:A,children:v?a.jsx(xr,{className:"w-3 h-3 text-green-400"}):a.jsx(ec,{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 sJe({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[s,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function g(){try{const y=await fetch("/openapi.json");if(!y.ok)throw new Error("Failed to fetch OpenAPI schema");const _=await y.json();n(_)}catch(y){o(y instanceof Error?y.message:"Unknown error")}finally{i(!1)}}g()},[]),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(Ct,{children:a.jsx(Tt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-red-400",children:[a.jsx(qa,{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[g,y]of Object.entries(e.paths))for(const[_,N]of Object.entries(y)){if(_==="parameters")continue;const A=N.tags||["Other"];for(const C of A)h[C]||(h[C]=[]),h[C].push({path:g,method:_,spec:N})}const f=Object.entries(h).map(([g,y])=>{if(!u)return{tag:g,endpoints:y};const _=y.filter(({path:N,method:A,spec:C})=>{const j=u.toLowerCase();return N.toLowerCase().includes(j)||A.toLowerCase().includes(j)||(C.summary?.toLowerCase()||"").includes(j)||(C.description?.toLowerCase()||"").includes(j)});return{tag:g,endpoints:_}}).filter(({endpoints:g})=>g.length>0).sort((g,y)=>g.tag.localeCompare(y.tag)),p=g=>{c(y=>{const _=new Set(y);return _.has(g)?_.delete(g):_.add(g),_})},x=()=>{c(new Set(f.map(g=>g.tag)))},v=()=>{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:g=>d(g.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(Oe,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:v,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(aa,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[f.reduce((g,y)=>g+y.endpoints.length,0)," endpoints in ",f.length," categories"]}),a.jsx("div",{className:"space-y-3",children:f.map(({tag:g,endpoints:y})=>a.jsxs(Ct,{children:[a.jsx("button",{onClick:()=>p(g),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(g)?a.jsx(En,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(pi,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:g.replace(/-/g," ")}),a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:y.length})]})}),l.has(g)&&a.jsx(Tt,{className:"pt-0 space-y-2",children:y.map(({path:_,method:N,spec:A})=>a.jsx(iJe,{path:_,method:N,spec:A,schema:e,apiKey:t},`${N}-${_}`))})]},g))})]})}const oJe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"],lJe={database:"bg-blue-600",library_files:"bg-green-500",library_thumbnails:"bg-teal-500",library_other:"bg-emerald-700",archive_timelapses:"bg-red-500",archive_thumbnails:"bg-amber-500",archive_files:"bg-sky-500",virtual_printer_uploads:"bg-purple-500",virtual_printer_upload_cache:"bg-fuchsia-500",virtual_printer_certs:"bg-violet-500",virtual_printer_other:"bg-purple-700",downloads:"bg-cyan-500",plate_calibration:"bg-lime-500",logs:"bg-orange-500",other_data:"bg-yellow-500"},wK=["bg-blue-500","bg-green-500","bg-yellow-500","bg-red-500","bg-orange-500","bg-teal-500","bg-cyan-500","bg-purple-500"],SK=(t,e)=>lJe[t]||wK[e%wK.length];function cJe(){const t=Qt(),e=jl(),[n,r]=MF(),{t:i,i18n:s}=Et(),{showToast:o}=dn(),{authEnabled:l,user:c,refreshAuth:u}=Rr(),{mode:d,darkStyle:h,darkBackground:f,darkAccent:p,lightStyle:x,lightBackground:v,lightAccent:g,setDarkStyle:y,setDarkBackground:_,setDarkAccent:N,setLightStyle:A,setLightBackground:C,setLightAccent:j}=lp(),[k,R]=w.useState(null),[M,D]=w.useState(!1),[G,U]=w.useState(null),[W,L]=w.useState(!1),[ee,ae]=w.useState(null),[Y,se]=w.useState(null),[ce,ye]=w.useState(!1),[Z,ue]=w.useState(eX()),pe=n.get("tab"),be=pe==="email",Ee=be?"users":pe&&oJe.includes(pe)?pe:"general",[$,K]=w.useState(Ee),[T,E]=w.useState(be?"email":"users"),O=Se=>{K(Se),Se==="users"&&E("users"),Se==="general"?n.delete("tab"):n.set("tab",Se),r(n,{replace:!0})},[q,B]=w.useState(!1),[re,z]=w.useState(""),[V,te]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[Q,ne]=w.useState(null),[ie,me]=w.useState(null),[fe,oe]=w.useState(""),[I,F]=w.useState(!1),[J,xe]=w.useState(!1),[he,le]=w.useState(null),[Ce,Ne]=w.useState(!1),[Ue,He]=w.useState(!1),[de,we]=w.useState(!1),[ke,_e]=w.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[Ae,Ve]=w.useState(!1),[Te,Ke]=w.useState(!1),[je,qe]=w.useState(!1),[Re,Pe]=w.useState(!1),[Be,We]=w.useState(null),[ct,St]=w.useState(null),[Mt,yt]=w.useState(null),[$e,dt]=w.useState(!1),[gt,Lt]=w.useState({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),[en,pn]=w.useState(null),[_n,hn]=w.useState(null),[gn,On]=w.useState(!1),[Dn,zn]=w.useState({}),[ze,De]=w.useState({}),Ze=Se=>{ue(Se),tbe(Se),o(i("settings.toast.settingsSaved"),"success")},st=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Ye,isLoading:It}=Je({queryKey:["settings"],queryFn:ge.getSettings}),{data:Me,isLoading:Ge,isFetching:et}=Je({queryKey:["storage-usage"],queryFn:()=>ge.getStorageUsage(),enabled:$==="general",staleTime:1/0,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),Qe=async()=>{Ke(!0);try{const Se=await ge.getStorageUsage({refresh:!0});t.setQueryData(["storage-usage"],Se)}catch(Se){const Ot=Se instanceof Error?Se.message:"Failed to refresh storage usage";o(Ot,"error")}finally{Ke(!1)}},{data:Le,isLoading:ht}=Je({queryKey:["smart-plugs"],queryFn:ge.getSmartPlugs}),{data:it,isLoading:tt}=Je({queryKey:["smart-plugs-energy",Le?.map(Se=>Se.id)],queryFn:async()=>{if(!Le||Le.length===0)return null;const Se=await Promise.all(Le.filter(po=>po.enabled).map(async po=>{try{const ks=await ge.getSmartPlugStatus(po.id);return{plug:po,status:ks}}catch{return{plug:po,status:null}}}));let Ot=0,ha=0,na=0,Jc=0,gp=0;for(const{plug:po,status:ks}of Se){const zA=po.plug_type==="mqtt"&&ks?.energy?.power!=null;(ks?.reachable||zA)&&ks?.energy&&(gp++,ks.energy?.power!=null&&(Ot+=ks.energy.power),ks.energy?.today!=null&&(ha+=ks.energy.today),ks.energy?.yesterday!=null&&(na+=ks.energy.yesterday),ks.energy?.total!=null&&(Jc+=ks.energy.total))}return{totalPower:Ot,totalToday:ha,totalYesterday:na,totalLifetime:Jc,reachableCount:gp,totalPlugs:Le.filter(po=>po.enabled).length}},enabled:$==="plugs"&&!!Le&&Le.length>0,refetchInterval:$==="plugs"?1e4:!1}),{data:_t,isLoading:jt}=Je({queryKey:["notification-providers"],queryFn:ge.getNotificationProviders}),{data:Dt,isLoading:Rt}=Je({queryKey:["api-keys"],queryFn:ge.getAPIKeys}),tn=ut({mutationFn:Se=>ge.createAPIKey(Se),onSuccess:Se=>{ne(Se.key||null),B(!1),z(""),t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyCreated"))},onError:Se=>{o(`Failed to create API key: ${Se.message}`,"error")}}),nn=ut({mutationFn:Se=>ge.deleteAPIKey(Se),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyDeleted"))},onError:Se=>{o(`Failed to delete API key: ${Se.message}`,"error")}}),{data:ln}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:vn,isLoading:Rn}=Je({queryKey:["notification-templates"],queryFn:ge.getNotificationTemplates}),{data:Zt}=Je({queryKey:["virtual-printer-settings"],queryFn:zge.getSettings,refetchInterval:1e4}),xn=Zt?.status?.running??!1,{data:mn}=Je({queryKey:["ffmpeg-status"],queryFn:ge.checkFfmpeg}),{data:Gr}=Je({queryKey:["version"],queryFn:ge.getVersion}),{data:yn,refetch:dr,isRefetching:as}=Je({queryKey:["updateCheck"],queryFn:ge.checkForUpdates,enabled:Ye?.check_updates!==!1,staleTime:300*1e3}),{data:wn,refetch:Sr}=Je({queryKey:["updateStatus"],queryFn:ge.getUpdateStatus,refetchInterval:Se=>{const Ot=Se.state.data;return Ot?.status==="downloading"||Ot?.status==="installing"?1e3:!1}}),{data:ar}=Je({queryKey:["mqtt-status"],queryFn:ge.getMQTTStatus,refetchInterval:$==="network"?5e3:!1}),{data:ya}=Je({queryKey:["github-backup-status"],queryFn:ge.getGitHubBackupStatus}),{data:Ba}=Je({queryKey:["cloud-status"],queryFn:ge.getCloudStatus}),{data:sa={advanced_auth_enabled:!1,smtp_configured:!1}}=Je({queryKey:["advancedAuthStatus"],queryFn:()=>ge.getAdvancedAuthStatus()}),{hasPermission:vt}=Rr(),{data:Bt=[],isLoading:Nn}=Je({queryKey:["users"],queryFn:()=>ge.getUsers(),enabled:l&&vt("users:read")}),{data:Nt=[],isLoading:Wn}=Je({queryKey:["groups"],queryFn:()=>ge.getGroups(),enabled:l&&vt("groups:read")}),ea=ut({mutationFn:Se=>ge.createUser(Se),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),qe(!1),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userCreated"))},onError:Se=>{o(Se.message,"error")}}),ir=ut({mutationFn:({id:Se,data:Ot})=>ge.updateUser(Se,Ot),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Pe(!1),We(null),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userUpdated"))},onError:Se=>{o(Se.message,"error")}}),mr=ut({mutationFn:({id:Se,deleteItems:Ot})=>ge.deleteUser(Se,Ot),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(i("settings.toast.userDeleted")),St(null),yt(null)},onError:Se=>{o(Se.message,"error")}}),ui=ut({mutationFn:Se=>ge.resetUserPassword({user_id:Se}),onSuccess:Se=>{o(Se.message,"success")},onError:Se=>{o(Se.message,"error")}}),an=async Se=>{St(Se),dt(!0);try{const Ot=await ge.getUserItemsCount(Se);yt(Ot)}catch{yt({archives:0,queue_items:0,library_files:0})}finally{dt(!1)}},Fn=ut({mutationFn:Se=>ge.deleteGroup(Se),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(i("settings.toast.groupDeleted"))},onError:Se=>{o(Se.message,"error")}}),ki=()=>{const Se=sa?.advanced_auth_enabled||!1;if(!gt.username){o(i("settings.toast.fillRequiredFields"),"error");return}if(Se&&!gt.email){o("Email is required when advanced authentication is enabled","error");return}if(!Se){if(!gt.password){o(i("settings.toast.fillRequiredFields"),"error");return}if(gt.password!==gt.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(gt.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}ea.mutate({username:gt.username,password:Se?void 0:gt.password,email:gt.email||void 0,role:gt.role,group_ids:gt.group_ids.length>0?gt.group_ids:void 0})},$s=Se=>{if(gt.password){if(gt.password!==gt.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(gt.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}const Ot={username:gt.username||void 0,password:gt.password||void 0,role:gt.role,group_ids:gt.group_ids};Ot.password||delete Ot.password,ir.mutate({id:Se,data:Ot})},Uo=Se=>{We(Se.id),Lt({username:Se.username,password:"",email:Se.email||"",confirmPassword:"",role:Se.role,group_ids:Se.groups?.map(Ot=>Ot.id)||[]}),Pe(!0)},Bo=Se=>{Lt(Ot=>({...Ot,group_ids:Ot.group_ids.includes(Se)?Ot.group_ids.filter(ha=>ha!==Se):[...Ot.group_ids,Se]}))},zi=ut({mutationFn:ge.applyUpdate,onSuccess:Se=>{Se.is_docker?o(Se.message,"error"):Sr()}}),[Fr,Vs]=w.useState(null),Ca=ut({mutationFn:ge.testAllNotificationProviders,onSuccess:Se=>{Vs(Se),t.invalidateQueries({queryKey:["notification-providers"]}),Se.failed===0?o(`All ${Se.tested} providers tested successfully!`,"success"):o(`${Se.success}/${Se.tested} providers succeeded`,Se.failed>0?"error":"success")},onError:Se=>{o(`Failed to test providers: ${Se.message}`,"error")}}),ta=ut({mutationFn:async Se=>{if(!Le)return{success:0,failed:0};const Ot=Le.filter(na=>na.enabled),ha=await Promise.all(Ot.map(async na=>{try{return await ge.controlSmartPlug(na.id,Se),{success:!0}}catch{return{success:!1}}}));return{success:ha.filter(na=>na.success).length,failed:ha.filter(na=>!na.success).length}},onSuccess:(Se,Ot)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),Se.failed===0?o(`All ${Se.success} plugs turned ${Ot}`,"success"):o(`${Se.success} plugs turned ${Ot}, ${Se.failed} failed`,"error")},onError:Se=>{o(`Failed: ${Se.message}`,"error")}}),is=w.useRef(null),fr=w.useRef(!1),Ui=w.useRef(!0);w.useEffect(()=>{if(Ye&&!k){const Se={...Ye,external_url:Ye.external_url||window.location.origin};R(Se),setTimeout(()=>{Ui.current=!1},100)}},[Ye,k]);const Dl=ut({mutationFn:ge.updateSettings,onSuccess:Se=>{t.setQueryData(["settings"],Se),t.invalidateQueries({queryKey:["archiveStats"]}),o(i("settings.toast.settingsSaved"),"success")},onError:Se=>{o(`Failed to save: ${Se.message}`,"error")},onSettled:()=>{fr.current=!1}}),kr=ut({mutationFn:({id:Se,data:Ot})=>ge.updatePrinter(Se,Ot),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(i("settings.toast.cameraSettingsSaved"),"success")},onError:Se=>{o(`Failed to update printer: ${Se.message}`,"error")}});w.useEffect(()=>{if(!(Ui.current||!k||!Ye||!(Ye.auto_archive!==k.auto_archive||Ye.save_thumbnails!==k.save_thumbnails||Ye.capture_finish_photo!==k.capture_finish_photo||Ye.default_filament_cost!==k.default_filament_cost||Ye.currency!==k.currency||Ye.energy_cost_per_kwh!==k.energy_cost_per_kwh||Ye.energy_tracking_mode!==k.energy_tracking_mode||Ye.check_updates!==k.check_updates||(Ye.check_printer_firmware??!0)!==(k.check_printer_firmware??!0)||(Ye.include_beta_updates??!1)!==(k.include_beta_updates??!1)||Ye.notification_language!==k.notification_language||(Ye.bed_cooled_threshold??35)!==(k.bed_cooled_threshold??35)||Ye.ams_humidity_good!==k.ams_humidity_good||Ye.ams_humidity_fair!==k.ams_humidity_fair||Ye.ams_temp_good!==k.ams_temp_good||Ye.ams_temp_fair!==k.ams_temp_fair||Ye.ams_history_retention_days!==k.ams_history_retention_days||Ye.per_printer_mapping_expanded!==k.per_printer_mapping_expanded||Ye.date_format!==k.date_format||Ye.time_format!==k.time_format||Ye.default_printer_id!==k.default_printer_id||Ye.ftp_retry_enabled!==k.ftp_retry_enabled||Ye.ftp_retry_count!==k.ftp_retry_count||Ye.ftp_retry_delay!==k.ftp_retry_delay||Ye.ftp_timeout!==k.ftp_timeout||Ye.mqtt_enabled!==k.mqtt_enabled||Ye.mqtt_broker!==k.mqtt_broker||Ye.mqtt_port!==k.mqtt_port||Ye.mqtt_username!==k.mqtt_username||Ye.mqtt_password!==k.mqtt_password||Ye.mqtt_topic_prefix!==k.mqtt_topic_prefix||Ye.mqtt_use_tls!==k.mqtt_use_tls||Ye.external_url!==k.external_url||Ye.ha_enabled!==k.ha_enabled||Ye.ha_url!==k.ha_url||Ye.ha_token!==k.ha_token||(Ye.library_archive_mode??"ask")!==(k.library_archive_mode??"ask")||Number(Ye.library_disk_warning_gb??5)!==Number(k.library_disk_warning_gb??5)||(Ye.camera_view_mode??"window")!==(k.camera_view_mode??"window")||(Ye.preferred_slicer??"bambu_studio")!==(k.preferred_slicer??"bambu_studio")||Ye.prometheus_enabled!==k.prometheus_enabled||Ye.prometheus_token!==k.prometheus_token))&&!fr.current)return is.current&&clearTimeout(is.current),is.current=setTimeout(()=>{if(fr.current)return;fr.current=!0;const Ot={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,include_beta_updates:k.include_beta_updates,notification_language:k.notification_language,bed_cooled_threshold:k.bed_cooled_threshold,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};Dl.mutate(Ot)},500),()=>{is.current&&clearTimeout(is.current)}},[k,Ye,Dl]);const Yt=w.useCallback((Se,Ot)=>{R(ha=>ha?{...ha,[Se]:Ot}:null)},[]),va=async(Se,Ot,ha)=>{if(!Ot){o(i("settings.toast.enterCameraUrl"),"error");return}De(na=>({...na,[Se]:!0})),zn(na=>({...na,[Se]:null}));try{const na=await ge.testExternalCamera(Se,Ot,ha);zn(Jc=>({...Jc,[Se]:na})),na.success?o(i("settings.toast.cameraConnected",{resolution:na.resolution||""}),"success"):o(na.error||i("settings.toast.connectionFailed"),"error")}catch(na){const Jc=na instanceof Error?na.message:i("settings.toast.testFailed");zn(gp=>({...gp,[Se]:{success:!1,error:Jc}})),o(Jc,"error")}finally{De(na=>({...na,[Se]:!1}))}},[Qn,Cr]=w.useState({}),Zc=w.useRef({}),nw=w.useRef(new Set);w.useEffect(()=>{if(ln){const Se={};ln.forEach(Ot=>{Ot.external_camera_url&&!nw.current.has(Ot.id)&&(Se[Ot.id]=Ot.external_camera_url,nw.current.add(Ot.id))}),Object.keys(Se).length>0&&Cr(Ot=>({...Ot,...Se}))}},[ln]);const wx=(Se,Ot)=>{Cr(ha=>({...ha,[Se]:Ot})),Zc.current[Se]&&clearTimeout(Zc.current[Se]),Zc.current[Se]=setTimeout(()=>{kr.mutate({id:Se,data:{external_camera_url:Ot||null}})},800)},pp=(Se,Ot)=>{const ha={};Ot.type!==void 0&&(ha.external_camera_type=Ot.type||null),Ot.enabled!==void 0&&(ha.external_camera_enabled=Ot.enabled),kr.mutate({id:Se,data:ha})};return It||!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:()=>O("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${$==="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:()=>O("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${$==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(bl,{className:"w-4 h-4"}),i("settings.tabs.smartPlugs"),Le&&Le.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Le.length})]}),a.jsxs("button",{onClick:()=>O("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${$==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(eb,{className:"w-4 h-4"}),i("settings.tabs.notifications"),_t&&_t.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:_t.length})]}),a.jsxs("button",{onClick:()=>O("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${$==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(wme,{className:"w-4 h-4"}),i("settings.tabs.filament")]}),a.jsxs("button",{onClick:()=>O("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${$==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(nb,{className:"w-4 h-4"}),i("settings.tabs.network"),a.jsx("span",{className:`w-2 h-2 rounded-full ${ar?.enabled?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>O("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${$==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(il,{className:"w-4 h-4"}),i("settings.tabs.apiKeys"),Dt&&Dt.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Dt.length})]}),a.jsxs("button",{onClick:()=>O("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${$==="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 ${xn?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>O("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${$==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(gh,{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:()=>O("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${$==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Dc,{className:"w-4 h-4"}),i("settings.tabs.backup"),a.jsx("span",{className:`w-2 h-2 rounded-full ${Ba?.is_authenticated&&ya?.configured&&ya?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),$==="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(Ct,{children:[a.jsx(Vn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),a.jsxs(Tt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Lh,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:s.language,onChange:Se=>{s.changeLanguage(Se.target.value),ge.updateSettings({language:Se.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:PB.map(Se=>a.jsxs("option",{value:Se.code,children:[Se.nativeName," (",Se.name,")"]},Se.code))}),a.jsx(En,{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:Z,onChange:Se=>Ze(Se.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:A0.map(Se=>a.jsx("option",{value:Se.to,children:i(Se.labelKey)},Se.id))}),a.jsx(En,{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:Se=>Yt("date_format",Se.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(En,{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:Se=>Yt("time_format",Se.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(En,{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:Se=>Yt("default_printer_id",Se.target.value?Number(Se.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")}),ln?.map(Se=>a.jsx("option",{value:Se.id,children:Se.name},Se.id))]}),a.jsx(En,{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:Se=>Yt("preferred_slicer",Se.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(En,{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(Oe,{variant:"secondary",size:"sm",onClick:st,children:[a.jsx(co,{className:"w-4 h-4"}),"Reset"]})]})]})]}),a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(rC,{className:"w-5 h-5"}),"Appearance"]})}),a.jsxs(Tt,{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:f,onChange:Se=>{_(Se.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:p,onChange:Se=>{N(Se.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:Se=>{y(Se.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:v,onChange:Se=>{C(Se.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:g,onChange:Se=>{j(Se.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:x,onChange:Se=>{A(Se.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(Ct,{children:[a.jsx(Vn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.archiveSettings")})}),a.jsxs(Tt,{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:Se=>Yt("auto_archive",Se.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:Se=>Yt("save_thumbnails",Se.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:Se=>Yt("capture_finish_photo",Se.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&&mn&&!mn.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(Mn,{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(Ct,{children:[a.jsx(Vn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx($F,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),a.jsxs(Tt,{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:Se=>Yt("camera_view_mode",Se.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."}),ln&&ln.length>0?a.jsx("div",{className:"space-y-3",children:ln.map(Se=>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:Se.name}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Se.external_camera_enabled,onChange:Ot=>pp(Se.id,{enabled:Ot.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"})]})]}),Se.external_camera_enabled&&a.jsxs("div",{className:"space-y-2 mt-2",children:[a.jsx("input",{type:"text",placeholder:Se.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:Qn[Se.id]??Se.external_camera_url??"",onChange:Ot=>wx(Se.id,Ot.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:Se.external_camera_type||"mjpeg",onChange:Ot=>pp(Se.id,{type:Ot.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(Oe,{size:"sm",variant:"secondary",onClick:()=>va(Se.id,Qn[Se.id]??Se.external_camera_url??"",Se.external_camera_type||"mjpeg"),disabled:ze[Se.id]||!(Qn[Se.id]??Se.external_camera_url),children:ze[Se.id]?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):"Test"})]}),Dn[Se.id]&&a.jsx("div",{className:`text-xs flex items-center gap-1 ${Dn[Se.id]?.success?"text-green-500":"text-red-500"}`,children:Dn[Se.id]?.success?a.jsxs(a.Fragment,{children:[a.jsx(xr,{className:"w-3 h-3"}),"Connected",Dn[Se.id]?.resolution&&` (${Dn[Se.id]?.resolution})`]}):a.jsxs(a.Fragment,{children:[a.jsx(ii,{className:"w-3 h-3"}),Dn[Se.id]?.error||i("settings.toast.connectionFailed")]})})]})]},Se.id))}):a.jsx("p",{className:"text-xs text-bambu-gray italic",children:i("settings.noPrintersConfigured")})]})]})]}),a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.costTracking")})}),a.jsxs(Tt,{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:Se=>Yt("currency",Se.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:G$e.map(Se=>a.jsx("option",{value:Se.code,children:Se.label},Se.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:sl(k.currency)}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:k.default_filament_cost,onChange:Se=>Yt("default_filament_cost",parseFloat(Se.target.value)||0),style:{paddingLeft:`${Math.max(2,sl(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:sl(k.currency)}),a.jsx("input",{type:"number",step:"0.001",min:"0",value:k.energy_cost_per_kwh,onChange:Se=>Yt("energy_cost_per_kwh",parseFloat(Se.target.value)||0),style:{paddingLeft:`${Math.max(2,sl(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:Se=>Yt("energy_tracking_mode",Se.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(Ct,{children:[a.jsx(Vn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Es,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),a.jsxs(Tt,{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:Se=>Yt("library_archive_mode",Se.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:Se=>Yt("library_disk_warning_gb",parseFloat(Se.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(KZe,{}),a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),a.jsxs(Tt,{className:"space-y-4",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Printer Firmware"}),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:Se=>Yt("check_printer_firmware",Se.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:"border-t border-bambu-dark-tertiary pt-4",children:a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wider mb-4",children:"Bambuddy Software"})}),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:Se=>Yt("check_updates",Se.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 ${k.check_updates?"":"opacity-50"}`,children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.includeBetaUpdates")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.includeBetaUpdatesDesc")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:k.include_beta_updates??!1,onChange:Se=>Yt("include_beta_updates",Se.target.checked),disabled:!k.check_updates,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.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",Gr?.version||"..."]})]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>dr(),disabled:as,children:[as?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(wr,{className:"w-4 h-4"}),"Check now"]})]}),yn?.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",yn.latest_version]}),yn.release_name&&yn.release_name!==yn.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:yn.release_name})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[yn.release_notes&&a.jsx("button",{onClick:()=>Ne(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),yn.release_url&&a.jsx("a",{href:yn.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:i("settings.viewReleaseOnGitHub"),children:a.jsx(aa,{className:"w-4 h-4"})})]})]}),wn?.status==="downloading"||wn?.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:wn.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:`${wn.progress}%`}})})]}):wn?.status==="complete"?a.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:wn.message}):wn?.status==="error"?a.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:wn.error||wn.message}):yn?.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(Oe,{className:"mt-3",onClick:()=>zi.mutate(),disabled:zi.isPending,children:[zi.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(ba,{className:"w-4 h-4"}),"Install Update"]})]}):yn?.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: ",yn.error]}):yn&&!yn.update_available?a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.dataManagement")})}),a.jsxs(Tt,{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(Oe,{variant:"secondary",size:"sm",onClick:()=>F(!0),children:[a.jsx(Xt,{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(Oe,{variant:"secondary",size:"sm",onClick:()=>xe(!0),children:[a.jsx(Xt,{className:"w-4 h-4"}),"Reset"]})]}),a.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.storageUsage","Storage Usage")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.storageUsageDescription","Breakdown of data usage by category")})]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:Qe,disabled:et||Te,children:[a.jsx(wr,{className:`w-4 h-4 ${et||Te?"animate-spin":""}`}),i("common.refresh","Refresh")]})]}),a.jsx("div",{className:"mt-3",children:Ge?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"}),i("common.loading","Loading")]}):Me?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-full h-3 bg-bambu-dark rounded-full overflow-hidden flex",children:Me.categories.filter(Se=>Se.bytes>0).map((Se,Ot)=>a.jsx("div",{className:`${SK(Se.key,Ot)} h-full`,style:{width:`${Se.percent_of_total}%`},title:`${Se.label}: ${Se.formatted}`},Se.key))}),a.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:Me.categories.filter(Se=>Se.bytes>0).map((Se,Ot)=>a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:`w-3 h-3 rounded-full ${SK(Se.key,Ot)}`}),a.jsx("span",{className:"text-bambu-gray",children:Se.label}),a.jsx("span",{className:"text-white",children:Se.formatted}),a.jsxs("span",{className:"text-bambu-gray",children:["(",Se.percent_of_total.toFixed(1),"%)"]})]},Se.key))}),a.jsxs("div",{className:"mt-2 text-xs text-bambu-gray",children:[i("settings.storageUsageTotal","Total"),": ",a.jsx("span",{className:"text-white",children:Me.total_formatted}),Me.scan_errors>0&&a.jsxs("span",{className:"ml-2 text-amber-400",children:[i("settings.storageUsageErrors","Scan errors"),": ",Me.scan_errors]})]}),Me.other_breakdown?.length>0&&a.jsxs("div",{className:"mt-4",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:i("settings.storageUsageOtherBreakdown","Other breakdown")}),a.jsx("div",{className:"space-y-2",children:Me.other_breakdown.map(Se=>a.jsxs("div",{className:"flex items-center justify-between text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-white",children:Se.label}),a.jsx("span",{className:`px-2 py-0.5 rounded-full border ${Se.kind==="system"?"border-slate-500 text-slate-300":"border-bambu-green text-bambu-green"}`,children:Se.kind==="system"?i("settings.storageUsageSystem","System"):i("settings.storageUsageData","Data")})]}),a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:Se.formatted}),a.jsxs("span",{children:["(",Se.percent_of_total.toFixed(1),"%)"]})]})]},`${Se.bucket}-${Se.kind}`))})]})]}):a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.storageUsageUnavailable","Storage usage data is unavailable")})})]}),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(Oe,{variant:"secondary",size:"sm",onClick:()=>O("backup"),children:[a.jsx(Dc,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),$==="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(Ct,{children:[a.jsx(Vn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Lh,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),a.jsxs(Tt,{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:Se=>Yt("external_url",Se.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(Ct,{children:[a.jsx(Vn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(wr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),a.jsxs(Tt,{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:Se=>Yt("ftp_retry_enabled",Se.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:Se=>Yt("ftp_retry_count",parseInt(Se.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(Se=>a.jsxs("option",{value:Se,children:[Se," ",Se===1?"time":"times"]},Se))}),a.jsx(En,{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:Se=>Yt("ftp_retry_delay",parseInt(Se.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(Se=>a.jsxs("option",{value:Se,children:[Se," ",Se===1?"second":"seconds"]},Se))}),a.jsx(En,{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:Se=>Yt("ftp_timeout",parseInt(Se.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(Se=>a.jsxs("option",{value:Se,children:[Se," seconds"]},Se))}),a.jsx(En,{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(Ct,{children:[a.jsx(Vn,{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(vv,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),k.ha_enabled&&_n&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${_n.success?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${_n.success?"text-green-400":"text-red-400"}`,children:_n.success?"Connected":"Disconnected"})]})]})}),a.jsxs(Tt,{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(Vm,{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:Se=>Yt("ha_enabled",Se.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:Se=>Yt("ha_url",Se.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(Vm,{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:Se=>Yt("ha_token",Se.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(Vm,{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(Oe,{variant:"secondary",size:"sm",disabled:gn,onClick:async()=>{On(!0),hn(null);try{const Se=await ge.testHAConnection(k.ha_url,k.ha_token);hn(Se)}catch(Se){hn({success:!1,message:null,error:Se instanceof Error?Se.message:i("common.unknownError")})}finally{On(!1)}},children:[gn?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(nb,{className:"w-4 h-4"}),i("settings.testConnection")]})})]})]})]}),a.jsxs(Ct,{children:[a.jsx(Vn,{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(nb,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),ar?.enabled&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${ar.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${ar.connected?"text-green-400":"text-red-400"}`,children:ar.connected?"Connected":"Disconnected"})]})]})}),a.jsxs(Tt,{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:Se=>Yt("mqtt_enabled",Se.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:Se=>Yt("mqtt_broker",Se.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:Se=>Yt("mqtt_port",Math.min(65535,Math.max(1,parseInt(Se.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:Se=>{const Ot=Se.target.checked;Yt("mqtt_use_tls",Ot);const ha=k.mqtt_port??1883;Ot&&ha===1883?Yt("mqtt_port",8883):!Ot&&ha===8883&&Yt("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:Se=>Yt("mqtt_username",Se.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:Se=>Yt("mqtt_password",Se.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:Se=>Yt("mqtt_topic_prefix",Se.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."]})]}),ar&&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 ${ar.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:"text-bambu-gray",children:ar.connected?a.jsxs(a.Fragment,{children:[i("settings.mqttConnectedTo")," ",a.jsxs("span",{className:"text-white",children:[ar.broker,":",ar.port]})]}):i("settings.spoolmanDisconnected")})]})})]})]})]})]}),a.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(w3,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),a.jsxs(Tt,{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:Se=>Yt("prometheus_enabled",Se.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:Se=>Yt("prometheus_token",Se.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)"})]})]})]})]})]})})]}),_n&&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:[_n.success?a.jsx(xr,{className:"w-8 h-8 text-green-400"}):a.jsx(ii,{className:"w-8 h-8 text-red-400"}),a.jsx("h3",{className:"text-lg font-medium text-white",children:_n.success?"Connection Successful":"Connection Failed"})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:_n.success?_n.message||"Successfully connected to Home Assistant.":_n.error||"Failed to connect to Home Assistant."}),a.jsx("div",{className:"flex justify-end",children:a.jsx(Oe,{variant:"primary",onClick:()=>hn(null),children:"OK"})})]})}),$==="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(bl,{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:[Le&&Le.filter(Se=>Se.enabled).length>1&&a.jsxs(a.Fragment,{children:[a.jsxs(Oe,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>le("on"),disabled:ta.isPending,title:i("settings.turnAllPlugsOn"),children:[ta.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(gd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),a.jsxs(Oe,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>le("off"),disabled:ta.isPending,title:i("settings.turnAllPlugsOff"),children:[ta.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(iC,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),a.jsxs(Oe,{className:"whitespace-nowrap",onClick:()=>{U(null),D(!0)},children:[a.jsx(nr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Le&&Le.length>0&&a.jsxs(Ct,{className:"mb-6",children:[a.jsx(Vn,{children:a.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[a.jsx(Ic,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",tt&&a.jsx(lt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),a.jsx(Tt,{children:it?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(Ic,{className:"w-3 h-3"}),"Current Power"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[it.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:[it.reachableCount,"/",it.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(Xr,{className:"w-3 h-3"}),"Today"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[it.totalToday.toFixed(3),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:["~",(it.totalToday*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",sl(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(w3,{className:"w-3 h-3"}),"Yesterday"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[it.totalYesterday.toFixed(3),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:["~",(it.totalYesterday*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",sl(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(M1,{className:"w-3 h-3"}),"Total"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[it.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:["~",(it.totalLifetime*(k?.energy_cost_per_kwh??0)).toFixed(2)," ",sl(k?.currency||"USD")]})]})]}):tt?null:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),ht?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Le&&Le.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Le.map(Se=>a.jsx(DZe,{plug:Se,onEdit:Ot=>{U(Ot),D(!0)}},Se.id))}):a.jsx(Ct,{children:a.jsx(Tt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(bl,{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(Oe,{onClick:()=>{U(null),D(!0)},children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.addFirstSmartPlug")]})]})})})]}),$==="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(eb,{className:"w-5 h-5 text-bambu-green"}),i("settings.providers")]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Oe,{size:"sm",variant:"secondary",onClick:()=>ye(!0),children:[a.jsx(N0,{className:"w-4 h-4"}),i("settings.log")]}),_t&&_t.length>0&&a.jsxs(Oe,{size:"sm",variant:"secondary",onClick:()=>{Vs(null),Ca.mutate()},disabled:Ca.isPending,children:[Ca.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(sC,{className:"w-4 h-4"}),i("settings.testAll")]}),a.jsxs(Oe,{size:"sm",onClick:()=>{ae(null),L(!0)},children:[a.jsx(nr,{className:"w-4 h-4"}),"Add"]})]})]}),a.jsx(Ct,{className:"mb-4",children:a.jsx(Tt,{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:Se=>Yt("notification_language",Se.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:PB.map(Se=>a.jsx("option",{value:Se.code,children:Se.nativeName},Se.code))})]})})}),a.jsx(Ct,{className:"mb-4",children:a.jsx(Tt,{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.bedCooledThreshold")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.bedCooledThresholdDescription")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("input",{type:"number",min:20,max:80,step:1,value:k.bed_cooled_threshold??35,onChange:Se=>Yt("bed_cooled_threshold",Number(Se.target.value)),className:"w-16 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm text-center focus:outline-none focus:ring-1 focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"°C"})]})]})})}),Fr&&a.jsx(Ct,{className:"mb-4",children:a.jsxs(Tt,{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:()=>Vs(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(xr,{className:"w-4 h-4"}),i("settings.testPassedCount",{count:Fr.success})]}),Fr.failed>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(ii,{className:"w-4 h-4"}),i("settings.testFailedCount",{count:Fr.failed})]})]}),Fr.results.filter(Se=>!Se.success).length>0&&a.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Fr.results.filter(Se=>!Se.success).map(Se=>a.jsxs("div",{className:"text-xs text-red-400",children:[a.jsxs("span",{className:"font-medium",children:[Se.provider_name,":"]})," ",Se.message]},Se.provider_id))})]})}),jt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):_t&&_t.length>0?a.jsx("div",{className:"space-y-3",children:_t.map(Se=>a.jsx(LZe,{provider:Se,onEdit:Ot=>{ae(Ot),L(!0)}},Se.id))}):a.jsx(Ct,{children:a.jsx(Tt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(eb,{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(Oe,{size:"sm",onClick:()=>{ae(null),L(!0)},children:[a.jsx(nr,{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(Es,{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")}),Rn?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(lt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):vn&&vn.length>0?a.jsx("div",{className:"space-y-2",children:[...vn].sort((Se,Ot)=>Se.name.localeCompare(Ot.name)).map(Se=>a.jsx(Ct,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>se(Se),children:a.jsx(Tt,{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:Se.name}),a.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Se.title_template})]}),a.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:Ot=>{Ot.stopPropagation(),se(Se)},children:a.jsx(af,{className:"w-4 h-4 text-bambu-gray"})})]})})},Se.id))}):a.jsx(Ct,{children:a.jsx(Tt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Es,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:i("settings.noTemplatesAvailable")})]})})})]})]}),$==="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(il,{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(Oe,{size:"sm",onClick:()=>B(!0),className:"flex-shrink-0",children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.createKey")]})]}),Q&&a.jsx(Ct,{className:"mb-6 border-bambu-green",children:a.jsx(Tt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(xr,{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(Oe,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(Q);else{const Se=document.createElement("textarea");Se.value=Q,Se.style.position="fixed",Se.style.left="-999999px",document.body.appendChild(Se),Se.select(),document.execCommand("copy"),document.body.removeChild(Se)}o(i("settings.toast.keyCopied"))}catch{o(i("settings.toast.copyFailed"),"error")}},children:a.jsx(ec,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>{oe(Q),o(i("settings.toast.keyAddedToBrowser"))},children:i("settings.useInApiBrowser")}),a.jsx(Oe,{variant:"secondary",size:"sm",onClick:()=>ne(null),children:i("common.dismiss")})]})]})]})})}),q&&a.jsxs(Ct,{className:"mb-6",children:[a.jsx(Vn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.createNewApiKey")})}),a.jsxs(Tt,{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:re,onChange:Se=>z(Se.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:V.can_read_status,onChange:Se=>te(Ot=>({...Ot,can_read_status:Se.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:V.can_queue,onChange:Se=>te(Ot=>({...Ot,can_queue:Se.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:V.can_control_printer,onChange:Se=>te(Ot=>({...Ot,can_control_printer:Se.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(Oe,{onClick:()=>tn.mutate({name:re||i("settings.unnamedKey"),...V}),disabled:tn.isPending,children:[tn.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(nr,{className:"w-4 h-4"}),i("settings.createKey")]}),a.jsx(Oe,{variant:"secondary",onClick:()=>B(!1),children:i("common.cancel")})]})]})]}),Rt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Dt&&Dt.length>0?a.jsx("div",{className:"space-y-3",children:Dt.map(Se=>a.jsx(Ct,{children:a.jsx(Tt,{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(il,{className:`w-5 h-5 ${Se.enabled?"text-bambu-green":"text-bambu-gray"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:Se.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[Se.key_prefix,"••••••••",Se.last_used&&` · ${i("settings.lastUsed")}: ${wb(Se.last_used)}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex gap-1 text-xs",children:[Se.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")}),Se.can_queue&&a.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:i("queue.title")}),Se.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(Oe,{variant:"secondary",size:"sm",onClick:()=>me(Se.id),children:a.jsx(Xt,{className:"w-4 h-4 text-red-400"})})]})]})})},Se.id))}):a.jsx(Ct,{children:a.jsx(Tt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(il,{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(Oe,{onClick:()=>B(!0),children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.createFirstKey")]})]})})}),a.jsxs(Ct,{className:"mt-6",children:[a.jsx(Vn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.webhookEndpoints")})}),a.jsxs(Tt,{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(Lh,{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(Ct,{className:"mb-4",children:a.jsxs(Tt,{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:fe,onChange:Se=>oe(Se.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(sJe,{apiKey:fe})]})]}),$==="virtual-printer"&&a.jsx(QZe,{}),$==="filament"&&k&&a.jsx(a.Fragment,{children:a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsxs("div",{className:"lg:w-1/3 space-y-6",children:[a.jsx(VZe,{}),a.jsxs(Ct,{children:[a.jsx(Vn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.amsDisplayThresholds")})}),a.jsxs(Tt,{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(IF,{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:Se=>Yt("ams_humidity_good",parseInt(Se.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:Se=>Yt("ams_humidity_fair",parseInt(Se.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(lC,{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:Se=>Yt("ams_temp_good",parseFloat(Se.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:Se=>Yt("ams_temp_fair",parseFloat(Se.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(Dc,{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:Se=>Yt("ams_history_retention_days",parseInt(Se.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:Se=>Yt("per_printer_mapping_expanded",Se.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:"lg:w-2/3 space-y-6",children:[a.jsx(qZe,{}),a.jsx(GZe,{})]})]})}),ie!==null&&a.jsx(Sn,{title:i("settings.deleteApiKeyTitle"),message:i("settings.deleteApiKeyMessage"),confirmText:i("settings.deleteKey"),variant:"danger",onConfirm:()=>{nn.mutate(ie),me(null)},onCancel:()=>me(null)}),M&&a.jsx(RZe,{plug:G,onClose:()=>{D(!1),U(null)}}),W&&a.jsx(OZe,{provider:ee,onClose:()=>{L(!1),ae(null)}}),Y&&a.jsx(IZe,{template:Y,onClose:()=>se(null)}),ce&&a.jsx(BZe,{onClose:()=>ye(!1)}),I&&a.jsx(Sn,{title:i("settings.clearNotificationLogs"),message:i("settings.clearLogsMessage"),confirmText:i("settings.clearLogs"),variant:"warning",onConfirm:async()=>{F(!1);try{const Se=await ge.clearNotificationLogs(30);o(Se.message,"success")}catch{o(i("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>F(!1)}),J&&a.jsx(Sn,{title:i("settings.resetUiPreferences"),message:i("settings.resetUiPreferencesMessage"),confirmText:i("settings.resetPreferences"),variant:"default",onConfirm:()=>{xe(!1),localStorage.clear(),o(i("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>xe(!1)}),he&&a.jsx(Sn,{title:`Turn All Plugs ${he==="on"?"On":"Off"}`,message:`This will turn ${he==="on"?"ON":"OFF"} all ${Le?.filter(Se=>Se.enabled).length||0} enabled smart plugs. ${he==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${he==="on"?"On":"Off"}`,variant:he==="off"?"danger":"warning",onConfirm:()=>{const Se=he;le(null),ta.mutate(Se)},onCancel:()=>le(null)}),Ce&&yn?.release_notes&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Ne(!1),children:a.jsxs(Ct,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:Se=>Se.stopPropagation(),children:[a.jsxs(Vn,{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",yn.latest_version]}),yn.release_name&&yn.release_name!==yn.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray",children:yn.release_name})]}),a.jsx("button",{onClick:()=>Ne(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsx(Tt,{className:"overflow-y-auto flex-1",children:a.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:yn.release_notes})}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[yn.release_url&&a.jsx("a",{href:yn.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:a.jsxs(Oe,{variant:"secondary",className:"w-full",children:[a.jsx(aa,{className:"w-4 h-4"}),"View on GitHub"]})}),a.jsx(Oe,{onClick:()=>Ne(!1),className:"flex-1",children:"Close"})]})]})}),$==="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:()=>E("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${T==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(gh,{className:"w-4 h-4"}),i("settings.tabs.users")]}),a.jsxs("button",{onClick:()=>E("email"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${T==="email"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(k0,{className:"w-4 h-4"}),i("settings.tabs.emailAuth")||"Email Authentication",sa?.advanced_auth_enabled&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"})]})]}),T==="users"&&a.jsxs(a.Fragment,{children:[a.jsx(Ct,{children:a.jsx(Tt,{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(Vm,{className:"w-5 h-5 text-green-400"}):a.jsx(Q_,{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(Oe,{variant:"secondary",onClick:()=>He(!0),children:[a.jsx(Q_,{className:"w-4 h-4"}),i("common.disable")]}):a.jsxs(Oe,{onClick:()=>e("/setup"),children:[a.jsx(Vm,{className:"w-4 h-4"}),i("common.enable")]})]})})}),sa?.advanced_auth_enabled&&a.jsx(Ct,{className:"border-blue-500/30 bg-blue-500/5",children:a.jsx(Tt,{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(k0,{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(Ct,{children:[a.jsx(Vn,{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(gh,{className:"w-5 h-5 text-bambu-green"}),i("settings.currentUser")]}),a.jsxs(Oe,{size:"sm",variant:"ghost",onClick:()=>we(!0),children:[a.jsx(il,{className:"w-4 h-4"}),i("settings.changePassword")]})]})}),a.jsx(Tt,{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(Se=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${Se.name==="Administrators"?"bg-purple-500/20 text-purple-300":Se.name==="Operators"?"bg-blue-500/20 text-blue-300":Se.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:Se.name},Se.id))]})]})})})]}),a.jsxs(Ct,{children:[a.jsx(Vn,{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(gh,{className:"w-5 h-5 text-bambu-green"}),i("settings.users")]}),vt("users:create")&&a.jsxs(Oe,{size:"sm",onClick:()=>{qe(!0),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.addUser")]})]})}),a.jsx(Tt,{children:Nn?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"})}):Bt.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:Bt.map(Se=>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:Se.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[Se.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")}),Se.groups?.map(Ot=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${Ot.name==="Administrators"?"bg-purple-500/20 text-purple-300":Ot.name==="Operators"?"bg-blue-500/20 text-blue-300":Ot.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:Ot.name},Ot.id))]})]}),a.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[vt("users:update")&&a.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>Uo(Se),children:a.jsx(af,{className:"w-4 h-4"})}),vt("users:delete")&&Se.id!==c?.id&&a.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>an(Se.id),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]},Se.id))})})]})]}),a.jsx("div",{children:a.jsxs(Ct,{children:[a.jsx(Vn,{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(v3,{className:"w-5 h-5 text-bambu-green"}),i("settings.groups")]}),vt("groups:create")&&a.jsxs(Oe,{size:"sm",onClick:()=>e("/groups/new"),children:[a.jsx(nr,{className:"w-4 h-4"}),i("settings.addGroup")]})]})}),a.jsx(Tt,{children:Wn?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"})}):Nt.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:Nt.map(Se=>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(v3,{className:`w-4 h-4 ${Se.name==="Administrators"?"text-purple-400":Se.name==="Operators"?"text-blue-400":Se.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),a.jsx("span",{className:"text-white font-medium",children:Se.name}),Se.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:[vt("groups:update")&&a.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>e(`/groups/${Se.id}/edit`),children:a.jsx(af,{className:"w-4 h-4"})}),vt("groups:delete")&&!Se.is_system&&a.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>pn(Se.id),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:Se.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:Se.user_count})}),a.jsx("span",{children:i("settings.permissionCount",{count:Se.permissions.length})})]})]},Se.id))})})]})})]}),!l&&a.jsx(Ct,{children:a.jsx(Tt,{className:"py-6",children:a.jsxs("div",{className:"text-center",children:[a.jsx(Q_,{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(xr,{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(xr,{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(xr,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature3")})]})]}),a.jsxs(Oe,{onClick:()=>e("/setup"),children:[a.jsx(Vm,{className:"w-4 h-4"}),i("settings.enableAuthentication")]})]})})})]}),T==="email"&&a.jsx("div",{className:"max-w-2xl",children:a.jsx(nJe,{})})]}),je&&!sa?.advanced_auth_enabled&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{qe(!1),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(Ct,{className:"w-full max-w-md",onClick:Se=>Se.stopPropagation(),children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gh,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.createUser")})]}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{qe(!1),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Ut,{className:"w-5 h-5"})})]})}),a.jsxs(Tt,{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:gt.username,onChange:Se=>Lt({...gt,username:Se.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:gt.password,onChange:Se=>Lt({...gt,password:Se.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:gt.confirmPassword,onChange:Se=>Lt({...gt,confirmPassword:Se.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 ${gt.confirmPassword&&gt.password!==gt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),gt.confirmPassword&&gt.password!==gt.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:[Nt.map(Se=>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:gt.group_ids.includes(Se.id),onChange:()=>Bo(Se.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:Se.name}),Se.is_system&&a.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},Se.id)),Nt.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(Oe,{variant:"secondary",onClick:()=>{qe(!1),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),a.jsx(Oe,{onClick:ki,disabled:ea.isPending||!gt.username||!gt.password||gt.password!==gt.confirmPassword||gt.password.length<6,children:ea.isPending?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(nr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),je&&sa?.advanced_auth_enabled&&a.jsx($Ze,{formData:gt,setFormData:Lt,groups:Nt,onClose:()=>{qe(!1),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},onCreate:ki,isCreating:ea.isPending,isCreateButtonDisabled:ea.isPending||!gt.username||!gt.email}),Re&&Be!==null&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Pe(!1),We(null),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(Ct,{className:"w-full max-w-md",onClick:Se=>Se.stopPropagation(),children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(af,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.editUser")})]}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{Pe(!1),We(null),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Ut,{className:"w-5 h-5"})})]})}),a.jsxs(Tt,{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")," ",sa?.advanced_auth_enabled&&a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsx("input",{type:"text",value:gt.username,onChange:Se=>Lt({...gt,username:Se.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"," ",sa?.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:gt.email,onChange:Se=>Lt({...gt,email:Se.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:sa?.advanced_auth_enabled})]}),!sa?.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:gt.password,onChange:Se=>Lt({...gt,password:Se.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})]}),gt.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:gt.confirmPassword,onChange:Se=>Lt({...gt,confirmPassword:Se.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 ${gt.confirmPassword&&gt.password!==gt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),gt.confirmPassword&&gt.password!==gt.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),sa?.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(Oe,{variant:"secondary",size:"sm",onClick:()=>Be&&ui.mutate(Be),disabled:ui.isPending||!gt.email,className:"w-full",children:ui.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(co,{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:Nt.map(Se=>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:gt.group_ids.includes(Se.id),onChange:()=>Bo(Se.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:Se.name}),Se.is_system&&a.jsxs("span",{className:"text-xs text-yellow-400",children:["(",i("users.system")||"System",")"]})]},Se.id))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Oe,{variant:"secondary",onClick:()=>{Pe(!1),We(null),Lt({username:"",password:"",email:"",confirmPassword:"",role:"user",group_ids:[]})},children:i("users.modal.cancel")||"Cancel"}),a.jsx(Oe,{onClick:()=>$s(Be),disabled:ir.isPending||!gt.username||sa?.advanced_auth_enabled&&!gt.email||!!(!sa?.advanced_auth_enabled&&gt.password&&(gt.password!==gt.confirmPassword||gt.password.length<6)),children:ir.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(bs,{className:"w-4 h-4"}),i("users.modal.saveChanges")||"Save Changes"]})})]})]})]})}),ct!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{St(null),yt(null)},children:a.jsxs(Ct,{className:"w-full max-w-md",onClick:Se=>Se.stopPropagation(),children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[a.jsx(Xt,{className:"w-5 h-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:i("settings.deleteUserTitle")})]})}),a.jsx(Tt,{className:"space-y-4",children:$e?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"})}):Mt&&Mt.archives+Mt.queue_items+Mt.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:[Mt.archives>0&&a.jsxs("li",{children:[Mt.archives," archive",Mt.archives!==1?"s":""]}),Mt.queue_items>0&&a.jsxs("li",{children:[Mt.queue_items," queue item",Mt.queue_items!==1?"s":""]}),Mt.library_files>0&&a.jsxs("li",{children:[Mt.library_files," library file",Mt.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(Oe,{variant:"danger",onClick:()=>mr.mutate({id:ct,deleteItems:!0}),disabled:mr.isPending,className:"justify-center",children:"Delete user AND their items"}),a.jsx(Oe,{variant:"secondary",onClick:()=>mr.mutate({id:ct,deleteItems:!1}),disabled:mr.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),a.jsx(Oe,{variant:"ghost",onClick:()=>{St(null),yt(null)},disabled:mr.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(Oe,{variant:"ghost",onClick:()=>{St(null),yt(null)},disabled:mr.isPending,children:"Cancel"}),a.jsx(Oe,{variant:"danger",onClick:()=>mr.mutate({id:ct,deleteItems:!1}),disabled:mr.isPending,children:"Delete User"})]})]})})]})}),en!==null&&a.jsx(Sn,{title:i("settings.deleteGroupTitle"),message:i("settings.deleteGroupMessage"),confirmText:i("settings.deleteGroup"),variant:"danger",onConfirm:()=>{Fn.mutate(en),pn(null)},onCancel:()=>pn(null)}),$==="backup"&&a.jsx(JZe,{}),Ue&&a.jsx(Sn,{title:i("settings.disableAuthenticationTitle"),message:i("settings.disableAuthenticationMessage"),confirmText:i("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await ge.disableAuth(),o(i("settings.toast.authDisabled"),"success"),await u(),He(!1),window.location.href="/"}catch(Se){const Ot=Se instanceof Error?Se.message:i("settings.toast.authDisableFailed");o(Ot,"error")}},onCancel:()=>He(!1)}),de&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{we(!1),_e({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(Ct,{className:"w-full max-w-md",onClick:Se=>Se.stopPropagation(),children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(il,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.changePassword")})]}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{we(!1),_e({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Ut,{className:"w-5 h-5"})})]})}),a.jsxs(Tt,{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:ke.currentPassword,onChange:Se=>_e({...ke,currentPassword:Se.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:ke.newPassword,onChange:Se=>_e({...ke,newPassword:Se.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:ke.confirmPassword,onChange:Se=>_e({...ke,confirmPassword:Se.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 ${ke.confirmPassword&&ke.newPassword!==ke.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),ke.confirmPassword&&ke.newPassword!==ke.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(Oe,{variant:"secondary",onClick:()=>{we(!1),_e({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),a.jsx(Oe,{onClick:async()=>{if(ke.newPassword!==ke.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(ke.newPassword.length<6){o(i("settings.toast.passwordTooShort"),"error");return}Ve(!0);try{await ge.changePassword(ke.currentPassword,ke.newPassword),o(i("settings.toast.passwordChanged"),"success"),we(!1),_e({currentPassword:"",newPassword:"",confirmPassword:""})}catch(Se){const Ot=Se instanceof Error?Se.message:"Failed to change password";o(Ot,"error")}finally{Ve(!1)}},disabled:Ae||!ke.currentPassword||!ke.newPassword||ke.newPassword!==ke.confirmPassword||ke.newPassword.length<6,children:Ae?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(il,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const fse=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},uJe=t=>t.startsWith("HH")?"HF":"S",dJe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},pse=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 zE({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:o}){const l=uJe(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(uo,{className:"w-4 h-4 text-bambu-green"}):a.jsx(_l,{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:fse(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(VY,{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(ec,{className:"w-4 h-4"})})]})}function UE({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],builtinFilaments:i=[],isDualNozzle:s=!1,initialNote:o="",initialNoteKey:l=null,onClose:c,onSave:u,onSaveNote:d,hasPermission:h}){const{t:f}=Et(),{showToast:p}=dn(),[x,v]=w.useState(t?.name||""),[g,y]=w.useState(t?.k_value?fse(t.k_value):"0.020"),[_,N]=w.useState(t?.filament_id||""),[A,C]=w.useState(t?.nozzle_id?dJe(t.nozzle_id):"HH00"),[j,k]=w.useState(t?.nozzle_diameter||n),[R,M]=w.useState(t?[t.extruder_id]:s?[0,1]:[0]),[D,G]=w.useState(!1),[U,W]=w.useState({current:0,total:0}),[L,ee]=w.useState(o),ae=Kr.useMemo(()=>{const pe=new Map;for(const Ee of i)pe.set(Ee.filament_id,Ee.name);const be=new Map;for(const Ee of r)if(Ee.filament_id&&!be.has(Ee.filament_id)){const K=pe.get(Ee.filament_id)||pse(Ee.name||"");be.set(Ee.filament_id,{id:Ee.filament_id,name:K||Ee.filament_id})}return Array.from(be.values()).sort((Ee,$)=>Ee.name.localeCompare($.name))},[r,i]),Y=ut({mutationFn:pe=>(console.log("[KProfile] Calling API..."),ge.setKProfile(e,pe)),onSuccess:pe=>{if(console.log("[KProfile] Save success:",pe),p(f("kProfiles.toast.profileSaved")),d&&L!==o){let be;L===""&&l?be=l:t&&t.slot_id>0?be=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:be=`name_${x}_${_}`,d(be,L)}G(!0),setTimeout(()=>{G(!1),u()},2500)},onError:pe=>{console.error("[KProfile] Save error:",pe),p(pe.message,"error"),G(!1)}}),se=ut({mutationFn:pe=>(console.log("[KProfile] Deleting profile..."),ge.deleteKProfile(e,pe)),onSuccess:pe=>{console.log("[KProfile] Delete success:",pe),p(f("kProfiles.toast.profileDeleted")),G(!0),setTimeout(()=>{G(!1),c()},4e3)},onError:pe=>{console.error("[KProfile] Delete error:",pe),p(pe.message,"error"),G(!1)}}),[ce,ye]=w.useState(!1),Z=()=>{t&&se.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})},ue=async pe=>{if(pe.preventDefault(),s&&!t&&R.length===0){p(f("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const be=parseFloat(g).toFixed(6),Ee=`${A}-${j}`;if(t||R.length===1){const K={name:x,k_value:be,filament_id:_,nozzle_id:Ee,nozzle_diameter:j,extruder_id:t?t.extruder_id:R[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",K),Y.mutate(K);return}G(!0),W({current:1,total:R.length});const $=R.map(K=>({name:x,k_value:be,filament_id:_,nozzle_id:Ee,nozzle_diameter:j,extruder_id:K,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${$.length} profiles in batch:`,$);try{if(await ge.setKProfilesBatch(e,$),p(f("kProfiles.toast.profilesSaved",{count:R.length})),d&&L){const K=`name_${x}_${_}`;d(K,L)}}catch(K){console.error("[KProfile] Failed to save batch:",K),p(f("kProfiles.toast.failedToSaveBatch"),"error"),G(!1),W({current:0,total:0});return}W({current:R.length,total:R.length}),setTimeout(()=>{G(!1),W({current:0,total:0}),u()},3e3)};return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[a.jsxs(Ct,{className:"w-full max-w-md relative",children:[D&&a.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[a.jsx(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?f("kProfiles.modal.savingExtruder",{current:U.current,total:U.total}):f("kProfiles.modal.syncing")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:f("kProfiles.modal.pleaseWait")})]}),a.jsxs(Tt,{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:f(t?"kProfiles.modal.editTitle":"kProfiles.modal.addTitle")}),a.jsx("button",{onClick:c,className:"text-bambu-gray hover:text-white transition-colors",disabled:D,children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:ue,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.profileName")}),a.jsx("input",{type:"text",value:x,onChange:pe=>v(pe.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:f("kProfiles.modal.profileNamePlaceholder"),required:!t})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.kValue")}),a.jsx("input",{type:"text",inputMode:"decimal",value:g,onChange:pe=>{const be=pe.target.value;(be===""||/^\d*\.?\d*$/.test(be))&&y(be)},onBlur:pe=>{const be=parseFloat(pe.target.value);isNaN(be)||y((Math.trunc(be*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:f("kProfiles.modal.kValuePlaceholder"),required:!0}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.kValueHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.filament")}),a.jsxs("select",{value:_,onChange:pe=>{const be=pe.target.value;if(N(be),!t&&be&&!x){const Ee=ae.find($=>$.id===be);Ee&&v(`${A==="HH00"?"HF":"S"} ${Ee.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:f("kProfiles.modal.selectFilament")}),t?.filament_id&&a.jsx("option",{value:t.filament_id,children:ae.find(pe=>pe.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&ae.map(pe=>a.jsx("option",{value:pe.id,children:pe.name},pe.id))]}),!t&&ae.length===0&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("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:f("kProfiles.modal.flowType")}),a.jsxs("select",{value:A,onChange:pe=>{const be=pe.target.value;if(C(be),!t&&_&&!x){const Ee=ae.find($=>$.id===_);Ee&&v(`${be==="HS00"?"HF":"S"} ${Ee.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:f("kProfiles.modal.highFlow")}),a.jsx("option",{value:"HS00",children:f("kProfiles.modal.standard")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.nozzleSize")}),a.jsxs("select",{value:j,onChange:pe=>k(pe.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"})]})]})]}),s&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f(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?f("kProfiles.modal.left"):f("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:R.includes(1),onChange:pe=>{pe.target.checked?M([...R,1]):M(R.filter(be=>be!==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:f("kProfiles.modal.left")})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:R.includes(0),onChange:pe=>{pe.target.checked?M([...R,0]):M(R.filter(be=>be!==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:f("kProfiles.modal.right")})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.notes")}),a.jsx("textarea",{value:L,onChange:pe=>ee(pe.target.value),placeholder:f("kProfiles.modal.notesPlaceholder"),rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.notesHelp")})]}),a.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&a.jsx(Oe,{type:"button",variant:"secondary",onClick:()=>ye(!0),disabled:se.isPending||D||!h("kprofiles:delete"),title:h("kprofiles:delete")?void 0:f("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:se.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"})}),a.jsx(Oe,{type:"button",variant:"secondary",onClick:c,disabled:D,className:"flex-1",children:f("common.cancel")}),a.jsxs(Oe,{type:"submit",disabled:Y.isPending||D||!h(t?"kprofiles:update":"kprofiles:create"),title:h(t?"kprofiles:update":"kprofiles:create")?void 0:f(t?"kProfiles.permission.noUpdate":"kProfiles.permission.noCreate"),className:"flex-1",children:[Y.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(eC,{className:"w-4 h-4"}),f("common.save")]})]})]})]})]}),ce&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.jsx(Ct,{className:"w-full max-w-sm",children:a.jsxs(Tt,{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(Xt,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:f("kProfiles.deleteConfirm.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:f("kProfiles.deleteConfirm.cannotUndo")})]})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:f("kProfiles.deleteConfirm.message",{name:t?.name})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Oe,{variant:"secondary",onClick:()=>ye(!1),className:"flex-1",children:f("common.cancel")}),a.jsxs(Oe,{onClick:()=>{ye(!1),Z()},disabled:se.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[se.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"}),f("common.delete")]})]})]})})})]})}const K_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function hJe(){const{t}=Et(),{showToast:e}=dn(),{hasPermission:n}=Rr(),[r,i]=w.useState(null),[s,o]=w.useState(()=>localStorage.getItem(K_.NOZZLE_DIAMETER)||"0.4"),[l,c]=w.useState(null),[u,d]=w.useState(!1),[h,f]=w.useState(null),[p,x]=w.useState(""),[v,g]=w.useState("all"),[y,_]=w.useState("all"),[N,A]=w.useState(()=>localStorage.getItem(K_.SORT_OPTION)||"name"),[C,j]=w.useState(!1),[k,R]=w.useState(new Set),[M,D]=w.useState(!1),[G,U]=w.useState(!1),W=w.useCallback(F=>`${F.slot_id}_${F.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(K_.NOZZLE_DIAMETER,s)},[s]),w.useEffect(()=>{localStorage.setItem(K_.SORT_OPTION,N)},[N]);const{data:L,isLoading:ee}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:ae,isLoading:Y,isFetching:se,error:ce,refetch:ye}=Je({queryKey:["kprofiles",r,s],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",s);const F=await ge.getKProfiles(r,s);return console.log("[KProfiles] Received profiles:",F?.profiles?.length||0,"profiles"),F},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Z}=Je({queryKey:["kprofiles",r,"0.4"],queryFn:()=>ge.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:ue}=Je({queryKey:["builtinFilaments"],queryFn:()=>ge.getBuiltinFilaments(),staleTime:3e5}),{data:pe}=Je({queryKey:["filamentIdMap"],queryFn:()=>ge.getFilamentIdMap(),staleTime:3e5}),{data:be,refetch:Ee}=Je({queryKey:["kprofile-notes",r],queryFn:()=>ge.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),$=ce?.message?.includes("not connected");w.useEffect(()=>{if(!r&&L&&L.length>0){const F=L.find(J=>J.is_active);F&&i(F.id)}},[r,L]),w.useEffect(()=>{if(r){const F=setTimeout(()=>{ye()},150);return()=>clearTimeout(F)}},[r,s]);const K=L?.filter(F=>F.is_active)||[],T=Kr.useMemo(()=>{const F=new Map;if(ue)for(const J of ue)F.set(J.filament_id,J.name);if(pe)for(const[J,xe]of Object.entries(pe))F.has(J)||F.set(J,xe);return F},[ue,pe]),E=Kr.useMemo(()=>Array.from(T.entries()).map(([F,J])=>({filament_id:F,name:J})),[T]),O=Kr.useCallback(F=>T.get(F.filament_id)||pse(F.name),[T]),q=Kr.useMemo(()=>ae?.profiles?ae.profiles.filter(J=>{const xe=p.toLowerCase(),he=!xe||J.name.toLowerCase().includes(xe)||J.filament_id.toLowerCase().includes(xe),le=v==="all"||v==="left"&&J.extruder_id===1||v==="right"&&J.extruder_id===0,Ce=y==="all"||y==="hf"&&J.nozzle_id.startsWith("HH")||y==="s"&&J.nozzle_id.startsWith("HS");return he&&le&&Ce}).sort((J,xe)=>{switch(N){case"k_value":return parseFloat(J.k_value)-parseFloat(xe.k_value);case"filament":return O(J).localeCompare(O(xe));default:return J.name.localeCompare(xe.name)}}):[],[ae?.profiles,p,v,y,N,O]),B=L?.find(F=>F.id===r),re=B?.nozzle_count===2;w.useEffect(()=>{const F=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||l||u||h||(J.key==="r"||J.key==="R"?(J.preventDefault(),ye()):J.key==="n"||J.key==="N"?(J.preventDefault(),d(!0)):J.key==="Escape"&&C&&(J.preventDefault(),j(!1),R(new Set)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[l,u,h,C,ye]);const z=w.useCallback(()=>{if(!ae?.profiles||ae.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const F={version:1,exported_at:new Date().toISOString(),printer:B?.name||"Unknown",nozzle_diameter:s,profiles:ae.profiles.map(le=>({name:le.name,k_value:le.k_value,filament_id:le.filament_id,nozzle_id:le.nozzle_id,nozzle_diameter:le.nozzle_diameter,extruder_id:le.extruder_id}))},J=new Blob([JSON.stringify(F,null,2)],{type:"application/json"}),xe=URL.createObjectURL(J),he=document.createElement("a");he.href=xe,he.download=`kprofiles_${B?.name||"printer"}_${s}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(he),he.click(),document.body.removeChild(he),URL.revokeObjectURL(xe),e(t("kProfiles.toast.exportedProfiles",{count:ae.profiles.length}))},[ae?.profiles,B,s,e,t]),V=w.useCallback(()=>{const F=document.createElement("input");F.type="file",F.accept=".json",F.onchange=async J=>{const xe=J.target.files?.[0];if(xe)try{const he=await xe.text(),le=JSON.parse(he);if(!le.profiles||!Array.isArray(le.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let Ce=0;for(const Ne of le.profiles)if(!(!Ne.name||!Ne.k_value||!Ne.filament_id))try{await ge.setKProfile(r,{name:Ne.name,k_value:parseFloat(Ne.k_value).toFixed(6),filament_id:Ne.filament_id,nozzle_id:Ne.nozzle_id||`HH00-${s}`,nozzle_diameter:Ne.nozzle_diameter||s,extruder_id:Ne.extruder_id??0,slot_id:0}),Ce++,await new Promise(Ue=>setTimeout(Ue,500))}catch(Ue){console.error("Failed to import profile:",Ne.name,Ue)}e(t("kProfiles.toast.importedProfiles",{count:Ce,total:le.profiles.length})),ye()}catch(he){console.error("Import error:",he),e(t("kProfiles.toast.failedToParseImport"),"error")}},F.click()},[r,s,e,ye,t]),te=w.useCallback(F=>{R(J=>{const xe=new Set(J);return xe.has(F)?xe.delete(F):xe.add(F),xe})},[]),Q=w.useCallback(()=>{R(new Set(q.map(F=>W(F))))},[q,W]),ne=w.useCallback(()=>{k.size!==0&&D(!0)},[k.size]),ie=w.useCallback(async()=>{const F=q.filter(xe=>k.has(W(xe)));U(!0);let J=0;for(const xe of F)try{await ge.deleteKProfile(r,{slot_id:xe.slot_id,extruder_id:xe.extruder_id,nozzle_id:xe.nozzle_id,nozzle_diameter:xe.nozzle_diameter,filament_id:xe.filament_id,setting_id:xe.setting_id}),J++,await new Promise(he=>setTimeout(he,300))}catch(he){console.error("Failed to delete profile:",xe.name,he)}e(t("kProfiles.toast.profilesDeleted",{count:J})),U(!1),D(!1),j(!1),R(new Set),ye()},[r,k,q,e,ye,W,t]),me=w.useCallback(F=>{const J=[];return F.setting_id&&J.push(F.setting_id),J.push(`slot_${F.slot_id}_${F.filament_id}_${F.extruder_id}`),J.push(`name_${F.name}_${F.filament_id}`),J},[]),fe=w.useCallback(async(F,J)=>{if(r)try{await ge.setKProfileNote(r,F,J),Ee()}catch(xe){console.error("Failed to save note:",xe),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,Ee,e,t]),oe=w.useCallback(F=>{if(!be?.notes)return{note:"",key:null};const J=me(F);for(const xe of J)if(be.notes[xe])return{note:be.notes[xe],key:xe};return{note:"",key:null}},[be,me]),I=w.useCallback(F=>oe(F).note,[oe]);return ee?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!L||L.length===0?a.jsx(Ct,{children:a.jsxs(Tt,{className:"py-12 text-center",children:[a.jsx(qa,{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")})]})}):K.length===0?a.jsx(Ct,{children:a.jsxs(Tt,{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:[se&&!Y&&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:F=>i(parseInt(F.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:K.map(F=>a.jsx("option",{value:F.id,children:F.name},F.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:F=>o(F.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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(Oe,{variant:"secondary",onClick:()=>ye(),disabled:se||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[a.jsx(wr,{className:`w-4 h-4 ${se?"animate-spin":""}`}),t("kProfiles.refresh")]}),a.jsxs(Oe,{onClick:()=>d(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[a.jsx(nr,{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(Er,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:p,onChange:F=>x(F.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"})]}),re&&a.jsx("div",{className:"w-36",children:a.jsxs("select",{value:v,onChange:F=>g(F.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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:y,onChange:F=>_(F.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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:F=>A(F.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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(Oe,{variant:"secondary",onClick:z,disabled:!ae?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[a.jsx(ba,{className:"w-4 h-4"}),t("kProfiles.export")]}),a.jsxs(Oe,{variant:"secondary",onClick:V,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[a.jsx(Ia,{className:"w-4 h-4"}),t("kProfiles.import")]}),a.jsx("div",{className:"flex-1"}),C?a.jsxs(a.Fragment,{children:[a.jsxs(Oe,{variant:"secondary",onClick:Q,children:[a.jsx(uo,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),a.jsxs(Oe,{variant:"secondary",onClick:ne,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(Xt,{className:"w-4 h-4"}),t("kProfiles.delete")," (",k.size,")"]}),a.jsxs(Oe,{variant:"secondary",onClick:()=>{j(!1),R(new Set)},children:[a.jsx(Ut,{className:"w-4 h-4"}),t("common.cancel")]})]}):a.jsxs(Oe,{variant:"secondary",onClick:()=>j(!0),disabled:!q.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[a.jsx(uo,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),Y?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):$?a.jsx(Ct,{children:a.jsxs(Tt,{className:"py-12 text-center",children:[a.jsx(Xh,{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(Oe,{variant:"secondary",onClick:()=>ye(),children:[a.jsx(wr,{className:"w-4 h-4"}),t("common.refresh")]})]})}):q.length>0?re?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:q.filter(F=>F.extruder_id===1).map(F=>a.jsx(zE,{profile:F,onEdit:()=>c(F),onCopy:()=>f(F),selectionMode:C,isSelected:k.has(W(F)),onToggleSelect:()=>te(W(F)),note:I(F)},W(F)))})]}),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:q.filter(F=>F.extruder_id===0).map(F=>a.jsx(zE,{profile:F,onEdit:()=>c(F),onCopy:()=>f(F),selectionMode:C,isSelected:k.has(W(F)),onToggleSelect:()=>te(W(F)),note:I(F)},W(F)))})]})]}):a.jsx("div",{className:"space-y-1",children:q.map(F=>a.jsx(zE,{profile:F,onEdit:()=>c(F),onCopy:()=>f(F),selectionMode:C,isSelected:k.has(W(F)),onToggleSelect:()=>te(W(F)),note:I(F)},W(F)))}):p||v!=="all"||y!=="all"?a.jsx(Ct,{children:a.jsxs(Tt,{className:"py-12 text-center",children:[a.jsx(Er,{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(Ct,{children:a.jsxs(Tt,{className:"py-12 text-center",children:[a.jsx(eC,{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(Oe,{onClick:()=>d(!0),children:[a.jsx(nr,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:F,key:J}=oe(l);return a.jsx(UE,{profile:l,printerId:r,nozzleDiameter:s,existingProfiles:Z?.profiles||ae?.profiles,builtinFilaments:E,isDualNozzle:re,initialNote:F,initialNoteKey:J,onSaveNote:fe,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),ye()},onSave:()=>{c(null),ye()}})})(),u&&r&&a.jsx(UE,{printerId:r,nozzleDiameter:s,existingProfiles:Z?.profiles||ae?.profiles,builtinFilaments:E,isDualNozzle:re,onSaveNote:fe,hasPermission:n,onClose:()=>{d(!1),ye()},onSave:()=>{d(!1),ye()}}),h&&r&&a.jsx(UE,{printerId:r,nozzleDiameter:s,existingProfiles:Z?.profiles||ae?.profiles,builtinFilaments:E,isDualNozzle:re,onSaveNote:fe,hasPermission:n,profile:{...h,slot_id:0,name:`${h.name} (Copy)`},onClose:()=>{f(null),ye()},onSave:()=>{f(null),ye()}}),M&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(Ct,{className:"w-full max-w-sm",children:a.jsxs(Tt,{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(Xt,{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(Oe,{variant:"secondary",onClick:()=>D(!1),disabled:G,className:"flex-1",children:t("common.cancel")}),a.jsxs(Oe,{onClick:ie,disabled:G,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[G?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}const gse=["PLA","PETG","PCTG","ABS","ASA","TPU","PC","PA","PVA","HIPS","PP","PET","NYLON"],mJe={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 fJe(t){const e=t.toUpperCase();for(const n of gse)if(new RegExp(`\\b${n}\\b`).test(e))return n;return null}function pJe(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const r of gse){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 BE({preset:t,onDelete:e,onExpand:n,isExpanded:r}){const{t:i}=Et(),{hasPermission:s}=Rr(),o=t.filament_type||fJe(t.name),l=t.filament_vendor||pJe(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=mJe[o.toUpperCase()]||null),a.jsx(Ct,{className:"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors",children:a.jsxs(Tt,{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(Xt,{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(Sl,{className:"w-3.5 h-3.5"}):a.jsx(En,{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 gJe(){const{t}=Et(),{hasPermission:e}=Rr(),n=Qt(),{showToast:r}=dn(),[i,s]=w.useState(""),[o,l]=w.useState(null),[c,u]=w.useState(!1),[d,h]=w.useState(null),{data:f,isLoading:p}=Je({queryKey:["localPresets"],queryFn:()=>ge.getLocalPresets()}),x=ut({mutationFn:async k=>{const R=[];for(const M of Array.from(k)){const D=new FormData;D.append("file",M),R.push(await ge.importLocalPresets(D))}return R},onSuccess:k=>{n.invalidateQueries({queryKey:["localPresets"]});let R=0,M=0,D=0;for(const G of k)R+=G.imported,M+=G.skipped,D+=G.errors.length;R>0&&r(t("profiles.localProfiles.toast.importSuccess",{count:R})),M>0&&r(t("profiles.localProfiles.toast.importSkipped",{count:M}),"warning"),D>0&&r(t("profiles.localProfiles.toast.importError",{count:D}),"error")},onError:k=>{r(k.message,"error")}}),v=ut({mutationFn:k=>ge.deleteLocalPreset(k),onSuccess:()=>{n.invalidateQueries({queryKey:["localPresets"]}),h(null),r(t("profiles.localProfiles.toast.deleted"))}}),g=w.useCallback(k=>{!k||k.length===0||x.mutate(k)},[x]),y=w.useCallback(k=>{k.preventDefault(),u(!1),g(k.dataTransfer.files)},[g]),_=w.useCallback(k=>{if(!i)return k;const R=i.toLowerCase();return k.filter(M=>M.name.toLowerCase().includes(R)||M.filament_type?.toLowerCase().includes(R)||M.filament_vendor?.toLowerCase().includes(R))},[i]),N=w.useMemo(()=>_(f?.filament||[]),[f?.filament,_]),A=w.useMemo(()=>_(f?.printer||[]),[f?.printer,_]),C=w.useMemo(()=>_(f?.process||[]),[f?.process,_]),j=N.length+A.length+C.length;return 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"})}):a.jsxs("div",{className:"space-y-6",children:[e("settings:update")&&a.jsxs("div",{onDragOver:k=>{k.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:y,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=>g(k.target.files)}),x.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(Ia,{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")})]})]}),j>0&&a.jsxs("div",{className:"relative",children:[a.jsx(Er,{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"})]}),j===0&&!p&&a.jsxs("div",{className:"text-center py-12",children:[a.jsx(Jb,{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")})]}),j>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(Qk,{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(BE,{preset:k,onDelete:R=>h(R),onExpand:l,isExpanded:o===k.id},k.id))})]}),C.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(Ga,{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:["(",C.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:C.map(k=>a.jsx(BE,{preset:k,onDelete:R=>h(R),onExpand:l,isExpanded:o===k.id},k.id))})]}),A.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx(rd,{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:["(",A.length,")"]})]}),a.jsx("div",{className:"space-y-2",children:A.map(k=>a.jsx(BE,{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(qa,{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(Oe,{variant:"secondary",size:"sm",onClick:()=>h(null),children:t("profiles.localProfiles.cancel")}),a.jsxs(Oe,{variant:"danger",size:"sm",onClick:()=>v.mutate(d),disabled:v.isPending,children:[v.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{className:"w-4 h-4"}),t("profiles.localProfiles.delete")]})]})]})})]})}function SI(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 fv(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function bJe({onSuccess:t,t:e}){const{showToast:n}=dn(),[r,i]=w.useState("email"),[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(""),[h,f]=w.useState(""),[p,x]=w.useState("global"),[v,g]=w.useState(null),[y,_]=w.useState(null),N=ut({mutationFn:()=>ge.cloudLogin(s,l,p),onSuccess:R=>{R.success?(n(e("profiles.login.toast.loggedIn")),t()):R.needs_verification?(g(R.verification_type||"email"),_(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")}),A=ut({mutationFn:()=>ge.cloudVerify(s,u,y||void 0),onSuccess:R=>{R.success?(n(e("profiles.login.toast.loggedIn")),t()):n(R.message,"error")},onError:R=>n(R.message,"error")}),C=ut({mutationFn:()=>ge.cloudSetToken(h),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:R=>n(R.message,"error")}),j=R=>{R.preventDefault(),r==="email"?N.mutate():r==="code"?A.mutate():r==="token"&&C.mutate()},k=N.isPending||A.isPending||C.isPending;return a.jsx(Ct,{className:"max-w-md mx-auto",children:a.jsxs(Tt,{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(Zb,{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:j,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:p,onChange:R=>x(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(v==="totp"?"profiles.login.totpCode":"profiles.login.verificationCode")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:v==="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=>f(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 max-[550px]:flex-wrap max-[550px]:items-center",children:[r==="code"&&a.jsx(Oe,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:e("profiles.login.back")}),a.jsxs(Oe,{type:"submit",disabled:k,className:"flex-1",children:[k?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(YB,{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(il,{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(YB,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function Lg({label:t,value:e,options:n,onChange:r}){const[i,s]=w.useState(!1),o=n.find(l=>l.value===e);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),a.jsx("span",{children:o?.label||"All"}),a.jsx(En,{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 xJe(){const[t,e]=w.useState(!1);w.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?a.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:a.jsx(Lf,{className:"w-5 h-5"})}):null}function HE({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:o,t:l}){const c=SI(t.name),u=fv(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(ec,{className:"w-4 h-4"})})]})}function bF(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(`
  8300. `)){const i=t.replace(/\\n/g,`
  8301. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8302. `);if(i.length>1)return`"""
  8303. `+i.map(s=>n+" "+s).join(`
  8304. `)+`
  8305. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8306. `+t.map(i=>n+" "+bF(i,e+1)).join(`,
  8307. `)+`
  8308. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8309. `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+bF(o,e+1)).join(`,
  8310. `)+`
  8311. `+n+"}"}return String(t)}function yJe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s,t:o}){const{showToast:l}=dn(),c=Qt(),[u,d]=w.useState(!1),{data:h,isLoading:f}=Je({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ge.getCloudSettingDetail(t.setting_id)}),p=ut({mutationFn:()=>ge.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:g=>l(g.message,"error")}),x=fv(t.setting_id),v=SI(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(Ct,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(Tt,{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}),x&&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}`)}),v.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:v.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(Ut,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:f?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(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:bF(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(Mn,{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(Oe,{variant:"secondary",onClick:()=>d(!1),disabled:p.isPending,className:"flex-1",children:o("common.cancel")}),a.jsxs(Oe,{variant:"danger",onClick:()=>p.mutate(),disabled:p.isPending,className:"flex-1",children:[p.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):a.jsx(Xt,{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(Oe,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),a.jsxs(Oe,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[a.jsx(ec,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&a.jsxs(a.Fragment,{children:[a.jsxs(Oe,{variant:"secondary",onClick:i,disabled:f||!h||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[a.jsx(Ka,{className:"w-4 h-4"}),o("common.edit")]}),a.jsx(Oe,{variant:"danger",onClick:()=>d(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]})})]})})})}function bse(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function xse(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function vJe({onClose:t,onApply:e,t:n}){const{showToast:r}=dn(),[i,s]=w.useState(bse),[o,l]=w.useState("all"),[c,u]=w.useState(null),[d,h]=w.useState(""),[f,p]=w.useState(""),[x,v]=w.useState("{}"),[g,y]=w.useState(null),[_,N]=w.useState(null),A=o==="all"?i:i.filter(W=>W.type===o),C=W=>{s(W),xse(W)},j=W=>{const L=i.filter(ee=>ee.id!==W);C(L),N(null),r(n("profiles.templates.toast.deleted"))},k=W=>{u(W.id),h(W.name),p(W.description),v(JSON.stringify(W.settings,null,2)),y(null)},R=()=>{if(!(!c||!d.trim()))try{const W=JSON.parse(x),L=i.map(ee=>ee.id===c?{...ee,name:d.trim(),description:f.trim(),settings:W}:ee);C(L),u(null),r(n("profiles.templates.toast.updated"))}catch(W){y(W.message)}},M=()=>{u(null),h(""),p(""),v("{}"),y(null)},D=W=>{const L=i.map(ee=>ee.id===W?{...ee,showInModal:!ee.showInModal}:ee);C(L)},G={filament:{label:n("profiles.presets.types.filament"),icon:Qk,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:rd,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Dr,color:"text-purple-400"}},U=_?i.find(W=>W.id===_):null;return w.useEffect(()=>{const W=L=>{L.key==="Escape"&&(_?N(null):c?M():t())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[_,c,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[U&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(Ct,{className:"w-full max-w-md",children:a.jsxs(Tt,{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(Mn,{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:U.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Oe,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),a.jsxs(Oe,{onClick:()=>j(_),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(Xt,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),a.jsx(Ct,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(Tt,{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(vb,{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(Ut,{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(W=>a.jsx("button",{onClick:()=>l(W),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===W?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:W==="all"?n("common.all"):G[W].label},W))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:A.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(vb,{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:A.map(W=>{const L=G[W.type],ee=L.icon;return c===W.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:ae=>h(ae.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:f,onChange:ae=>p(ae.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:x,onChange:ae=>{v(ae.target.value),y(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${g?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),g&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:g})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Oe,{size:"sm",onClick:R,disabled:!d.trim(),children:[a.jsx(bs,{className:"w-4 h-4"}),"Save"]}),a.jsx(Oe,{size:"sm",variant:"secondary",onClick:M,children:"Cancel"})]})]},W.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(ee,{className:`w-5 h-5 ${L.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:W.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:W.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(W.settings).length})}),a.jsx("button",{onClick:()=>D(W.id),className:`p-1 transition-colors ${W.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:W.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:W.showInModal?a.jsx(tc,{className:"w-4 h-4"}):a.jsx(yv,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(W),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(W),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:a.jsx(Ka,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(W.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:a.jsx(Xt,{className:"w-4 h-4"})})]},W.id)})})})]})})]})}function yse({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:s}){const[o,l]=w.useState("changes"),[c,u]=w.useState(""),d=w.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),v=[];for(const g of x){if(g==="inherits"||g==="version")continue;const y=e[g],_=n[g],N=g in e,A=g in n;let C;!N&&A?C="added":N&&!A?C="removed":JSON.stringify(y)!==JSON.stringify(_)?C="changed":C="same",v.push({key:g,left:y,right:_,status:C})}return v.sort((g,y)=>{const _={changed:0,added:1,removed:2,same:3};return _[g.status]!==_[y.status]?_[g.status]-_[y.status]:g.key.localeCompare(y.key)})},[e,n]),h=w.useMemo(()=>{let x=[...d];if(o==="changes"&&(x=x.filter(v=>v.status!=="same")),c){const v=c.toLowerCase();x=x.filter(g=>g.key.toLowerCase().includes(v)||String(g.left).toLowerCase().includes(v)||String(g.right).toLowerCase().includes(v))}return x},[d,o,c]),f=w.useMemo(()=>({added:d.filter(x=>x.status==="added").length,removed:d.filter(x=>x.status==="removed").length,changed:d.filter(x=>x.status==="changed").length,same:d.filter(x=>x.status==="same").length}),[d]),p=x=>{if(x===void 0)return"—";if(x===null)return"null";if(Array.isArray(x))return x.length===0?"[]":x.length===1?String(x[0]):x.join(", ");if(typeof x=="object")return JSON.stringify(x);const v=String(x);if(v.includes("\\n")||v.length>100){const g=v.split("\\n").length;if(g>1)return`[${g} lines of G-code/script]`;if(v.length>100)return v.substring(0,100)+"…"}return v};return w.useEffect(()=>{const x=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(Ct,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(Tt,{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(tb,{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(Ut,{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(nr,{className:"w-3.5 h-3.5"}),f.added," ",s("profiles.diff.added")]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(E1,{className:"w-3.5 h-3.5"}),f.removed," ",s("profiles.diff.removed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(f3,{className:"w-3.5 h-3.5"}),f.changed," ",s("profiles.diff.changed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(Y2,{className:"w-3.5 h-3.5"}),f.same," ",s("profiles.diff.same")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(Er,{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:x=>u(x.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"})]}),f.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(Y2,{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(x=>{const v={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],g={added:a.jsx(nr,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(E1,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(f3,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(Y2,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${v}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[g,a.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="removed"?"text-red-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="added"?"text-green-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(x.right)})})]},x.key)})})]})})]})})})}function wJe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=dn(),s=Qt(),o=!!e?.setting_id,[l,c]=w.useState("common"),[u,d]=w.useState(e?.type||"filament"),[h,f]=w.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[p,x]=w.useState(e?.base_id||""),[v,g]=w.useState(""),[y,_]=w.useState(e?.setting||{inherits:""}),[N,A]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[C,j]=w.useState(null),[k,R]=w.useState(""),[M,D]=w.useState(!1),[G,U]=w.useState(""),[W,L]=w.useState(!1),[ee,ae]=w.useState(bse),[Y,se]=w.useState(!1),[ce,ye]=w.useState(""),[Z,ue]=w.useState(""),[pe,be]=w.useState(!0),[Ee,$]=w.useState(null),[K,T]=w.useState(!1),E=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),O=w.useMemo(()=>E.filter(ke=>fv(ke.setting_id)),[E]),{data:q}=Je({queryKey:["cloudFields",u],queryFn:()=>ge.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:B}=Je({queryKey:["allPresetDetails",u,O.map(ke=>ke.setting_id).join(",")],queryFn:async()=>{const ke={};for(let Ae=0;Ae<O.length;Ae+=5){const Ve=O.slice(Ae,Ae+5);(await Promise.all(Ve.map(async Ke=>{try{const je=await ge.getCloudSettingDetail(Ke.setting_id);return{id:Ke.setting_id,detail:je}}catch{return null}}))).forEach(Ke=>{Ke&&(ke[Ke.id]=Ke.detail)})}return ke},enabled:O.length>0,staleTime:1e3*60*10}),{data:re,isLoading:z}=Je({queryKey:["cloudSettingDetail",p],queryFn:()=>ge.getCloudSettingDetail(p),enabled:!!p});w.useEffect(()=>{l!=="json"&&A(JSON.stringify(y,null,2))},[y,l]);const V=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(_e=>!fv(_e.setting_id)).sort((_e,Ae)=>_e.name.localeCompare(Ae.name)),[n,u]);w.useEffect(()=>{if(!p)return;const ke=V.find(_e=>_e.setting_id===p);ke&&(g(ke.name),o||(_({inherits:ke.name}),A(JSON.stringify({inherits:ke.name},null,2))))},[p,V,o]);const te=w.useMemo(()=>{const ke=q?.fields||[],_e=new Set(ke.map(Ke=>Ke.key)),Ae=new Set,Ve=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);B&&Object.values(B).forEach(Ke=>{Ke?.setting&&Object.keys(Ke.setting).forEach(je=>{!_e.has(je)&&!Ve.has(je)&&Ae.add(je)})}),Object.keys(y).forEach(Ke=>{!_e.has(Ke)&&!Ve.has(Ke)&&Ae.add(Ke)});const Te=Array.from(Ae).sort().map(Ke=>({key:Ke,label:Ke.replace(/_/g," ").replace(/\b\w/g,je=>je.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...ke,...Te]},[q,B,y,r]),Q=te.filter(ke=>ke.label.toLowerCase().includes(k.toLowerCase())||ke.key.toLowerCase().includes(k.toLowerCase())),ne=()=>{if(G.trim()){const ke=G.trim().toLowerCase().replace(/\s+/g,"_");ie(ke,""),U(""),L(!1),i(r("profiles.presets.toast.fieldAdded",{key:ke}))}},ie=(ke,_e)=>{_(Ae=>{const Ve={...Ae};return _e===""||_e===void 0?delete Ve[ke]:Ve[ke]=_e,Ve})},me=ke=>{_(_e=>({..._e,...ke.settings})),$(ke.name),i(r("profiles.templates.toast.applied"))},fe=()=>{if(!ce.trim())return;const ke={...y};if(delete ke.inherits,Object.keys(ke).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const _e={id:Date.now().toString(),name:ce.trim(),description:Z.trim()||r("profiles.presets.customTemplate"),type:u,settings:ke,showInModal:pe},Ae=[...ee,_e];ae(Ae),xse(Ae),se(!1),ye(""),ue(""),be(!0),i(r("profiles.templates.toast.created"))},oe=w.useMemo(()=>ee.filter(ke=>ke.type===u&&ke.showInModal),[u,ee]),I=ke=>{A(ke);try{const _e=JSON.parse(ke);_(_e),j(null)}catch(_e){j(_e.message)}},F=ke=>{ke.preventDefault(),D(!1);const _e=ke.dataTransfer.files[0];if(_e&&_e.name.endsWith(".json")){const Ae=new FileReader;Ae.onload=Ve=>{try{const Te=Ve.target?.result,Ke=JSON.parse(Te),je=Ke.setting||Ke;_(qe=>({...qe,...je})),A(JSON.stringify({...y,...je},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},Ae.readAsText(_e)}},J=ut({mutationFn:()=>{const ke={...y},_e=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";ke[_e]=`"${h}"`;const Ae={type:u,name:h,base_id:p,setting:ke};return ge.createCloudSetting(Ae)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ke=>i(ke.message,"error")}),xe=ut({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return ge.updateCloudSetting(e.setting_id,{name:h,setting:y})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ke=>i(ke.message,"error")}),he=o?xe:J,le=re?.setting?.inherits,Ce=le?V.find(ke=>ke.name===le):void 0,{data:Ne}=Je({queryKey:["cloudSettingDetail",Ce?.setting_id],queryFn:()=>ge.getCloudSettingDetail(Ce.setting_id),enabled:!!Ce?.setting_id}),Ue=w.useMemo(()=>{const ke=Ne?.setting||{},_e=re?.setting||{},Ae=p&&B?.[p]?.setting?B[p].setting:{};return{...ke,..._e,...Ae}},[p,re,Ne,B]),He=ke=>{if(ke==null)return"";if(Array.isArray(ke)){const _e=[...new Set(ke.map(Ae=>String(Ae)))];return _e.length===1?_e[0]:ke.join(", ")}return String(ke)},de=ke=>{const _e=y[ke.key],Ae=Ue[ke.key],Ve=He(Ae),Te=z?r("common.loading"):Ve||"",Ke="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(ke.type==="boolean"){const je=_e==="1"||_e===void 0&&Ae==="1";return a.jsx("button",{type:"button",onClick:()=>ie(ke.key,_e==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${je?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${je?"translate-x-3.5":"translate-x-0.5"}`})})}return ke.type==="select"?a.jsxs("select",{value:_e||"",onChange:je=>ie(ke.key,je.target.value),className:Ke,children:[a.jsx("option",{value:"",children:Te}),ke.options?.map(je=>a.jsx("option",{value:je.value,children:je.label},je.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:ke.type==="number"?"number":"text",value:_e!==void 0?String(_e):"",onChange:je=>ie(ke.key,je.target.value),step:ke.step,min:ke.min,max:ke.max,placeholder:Te,className:Ke}),ke.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ke.unit})]})},we=w.useMemo(()=>re?.setting?re.setting:{},[re]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ke=>{ke.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:F,children:[K&&p&&a.jsx(yse,{onClose:()=>T(!1),leftPreset:we,rightPreset:y,leftLabel:r("profiles.presets.baseLabel",{name:v||p}),rightLabel:r("profiles.presets.currentLabel",{name:h||r("profiles.presets.newPreset")}),t:r}),a.jsx(Ct,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto",children:a.jsxs(Tt,{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:[p&&a.jsxs("button",{onClick:()=>T(!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(tb,{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(Ut,{className:"w-5 h-5"})})]})]}),M&&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(Ia,{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 max-[640px]:grid-cols-1",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:ke=>{d(ke.target.value),x("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[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:p,onChange:ke=>x(ke.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")}),V.map(ke=>a.jsx("option",{value:ke.setting_id,children:ke.name},ke.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:ke=>f(ke.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")})]})]}),v&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Zr,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",a.jsx("span",{className:"text-white",children:v}),z&&a.jsx(lt,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary max-[640px]:flex-wrap max-[640px]:items-center",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(XB,{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(tC,{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(LY,{className:"w-4 h-4"}),"JSON",C&&a.jsx(qa,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1 max-[640px]:hidden"}),a.jsxs("button",{onClick:()=>{const ke={name:h,type:u,base_id:p,setting:y},_e=new Blob([JSON.stringify(ke,null,2)],{type:"application/json"}),Ae=URL.createObjectURL(_e),Ve=document.createElement("a");Ve.href=Ae,Ve.download=`${h||"preset"}.json`,document.body.appendChild(Ve),Ve.click(),document.body.removeChild(Ve),URL.revokeObjectURL(Ae),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(ba,{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(Ia,{className:"w-4 h-4"}),r("common.upload")]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ke=>{const _e=ke.target.files?.[0];if(_e){const Ae=new FileReader;Ae.onload=Ve=>{try{const Te=JSON.parse(Ve.target?.result),Ke=Te.setting||Te;_(je=>({...je,...Ke})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},Ae.readAsText(_e)}}})]}),a.jsxs("div",{className:"flex-1 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(vb,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(y).filter(ke=>ke!=="inherits").length>0&&a.jsxs("button",{onClick:()=>se(!Y),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(bs,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),Y&&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:ce,onChange:ke=>ye(ke.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:Z,onChange:ke=>ue(ke.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(Oe,{size:"sm",onClick:fe,disabled:!ce.trim(),children:[a.jsx(bs,{className:"w-3 h-3"}),r("common.save")]}),a.jsx(Oe,{size:"sm",variant:"secondary",onClick:()=>se(!1),children:r("common.cancel")})]}),a.jsxs("button",{onClick:()=>be(!pe),className:`flex items-center gap-1.5 text-xs transition-colors ${pe?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[pe?a.jsx(tc,{className:"w-3.5 h-3.5"}):a.jsx(yv,{className:"w-3.5 h-3.5"}),r(pe?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),Ee&&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(Zr,{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:Ee})]}),a.jsx("button",{onClick:()=>$(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Ut,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[oe.map(ke=>a.jsxs("button",{onClick:()=>me(ke),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:ke.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ke.description})]},ke.id)),oe.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:te.slice(0,10).map(ke=>a.jsxs("div",{className:"flex items-center justify-between gap-4 max-[640px]:flex-col max-[640px]:items-start",children:[a.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:ke.label}),a.jsx("div",{className:"w-48 max-[640px]:w-full",children:de(ke)})]},ke.key))})]}),Object.keys(y).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(y).filter(([ke])=>ke!=="inherits").map(([ke,_e])=>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:[ke,": ",String(_e).slice(0,20),a.jsx("button",{onClick:()=>ie(ke,void 0),className:"hover:text-white",children:a.jsx(Ut,{className:"w-3 h-3"})})]},ke))})]})]}),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:B?r("profiles.templates.fieldsCount",{count:te.length}):r("common.loading")})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(Er,{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:ke=>R(ke.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(ke=>!(ke.key in y)).map(ke=>{const _e=Ue[ke.key],Ae=He(_e);return a.jsxs("div",{onClick:()=>{_(Ve=>({...Ve,[ke.key]:Ae||""}))},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:ke.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ke.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Ae&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Ae,children:[Ae.slice(0,20),Ae.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(nr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ke.key)}),Q.filter(ke=>!(ke.key in y)).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:W?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:G,onChange:ke=>U(ke.target.value),onKeyDown:ke=>ke.key==="Enter"&&ne(),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(Oe,{size:"sm",onClick:ne,disabled:!G.trim(),children:a.jsx(nr,{className:"w-4 h-4"})}),a.jsx(Oe,{size:"sm",variant:"secondary",onClick:()=>{L(!1),U("")},children:a.jsx(Ut,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>L(!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(nr,{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(y).filter(ke=>ke!=="inherits").length})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([ke])=>ke!=="inherits").map(([ke,_e])=>{const Ae=te.find(Ve=>Ve.key===ke);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:Ae?.label||ke}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ke})]}),a.jsx("button",{onClick:()=>ie(ke,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Ut,{className:"w-4 h-4"})})]}),Ae?de(Ae):a.jsx("input",{type:"text",value:String(_e),onChange:Ve=>ie(ke,Ve.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"})]},ke)}),Object.keys(y).filter(ke=>ke!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(XB,{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(y).filter(ke=>ke!=="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:()=>{se(!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(bs,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&a.jsxs("div",{className:"space-y-2",children:[C&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(qa,{className:"w-4 h-4"}),C]}),a.jsx("textarea",{value:N,onChange:ke=>I(ke.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${C?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Oe,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsxs(Oe,{onClick:()=>he.mutate(),disabled:he.isPending||!h.trim()||!o&&!p||!!C,className:"flex-1",children:[he.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):o?a.jsx(bs,{className:"w-4 h-4"}):a.jsx(nr,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function SJe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s,t:o}){const[l,c]=w.useState(""),[u,d]=w.useState("all"),[h,f]=w.useState("all"),[p,x]=w.useState("all"),[v,g]=w.useState("all"),[y,_]=w.useState("all"),[N,A]=w.useState("all"),[C,j]=w.useState(null),[k,R]=w.useState(!1),[M,D]=w.useState(!1),[G,U]=w.useState(null),[W,L]=w.useState(null),[ee,ae]=w.useState(null),[Y,se]=w.useState(!1),[ce,ye]=w.useState([null,null]),[Z,ue]=w.useState(!1),[pe,be]=w.useState(null),Ee=Qt(),$=w.useMemo(()=>[...t.filament.map(ne=>({...ne,type:"filament"})),...t.printer.map(ne=>({...ne,type:"printer"})),...t.process.map(ne=>({...ne,type:"process"}))].map(ne=>({...ne,meta:SI(ne.name)})),[t]),K=w.useMemo(()=>{const Q=new Set,ne=new Set,ie=new Set;return $.forEach(me=>{me.meta.nozzle&&Q.add(me.meta.nozzle),me.meta.filamentType&&ne.add(me.meta.filamentType),me.meta.layerHeight&&ie.add(me.meta.layerHeight)}),{printers:i.map(me=>({id:me.id.toString(),name:me.name})),nozzles:Array.from(Q).sort((me,fe)=>parseFloat(me)-parseFloat(fe)),filaments:Array.from(ne).sort(),layerHeights:Array.from(ie).sort((me,fe)=>parseFloat(me)-parseFloat(fe))}},[$,i]),T=w.useMemo(()=>p==="all"?null:i.find(ne=>ne.id.toString()===p)?.model||null,[p,i]),E=w.useMemo(()=>$.filter(Q=>u==="all"||Q.type===u).filter(Q=>{if(h==="all")return!0;const ne=fv(Q.setting_id);return h==="custom"?ne:!ne}).filter(Q=>{if(p==="all"||!T)return!0;const ne=Q.meta.printer?.toLowerCase()||"",ie=T.toLowerCase();return ne.includes(ie)||ie.includes(ne)}).filter(Q=>v==="all"||Q.meta.nozzle===v).filter(Q=>y==="all"||Q.meta.filamentType===y).filter(Q=>N==="all"||Q.meta.layerHeight===N).filter(Q=>l===""||Q.name.toLowerCase().includes(l.toLowerCase())).sort((Q,ne)=>Q.name.localeCompare(ne.name)),[$,u,h,p,T,v,y,N,l]),O=Q=>{if(Y){const ne=ce[0]?.setting_id===Q.setting_id,ie=ce[1]?.setting_id===Q.setting_id;if(ne)ye([ce[1],null]);else if(ie)ye([ce[0],null]);else if(!ce[0])ye([Q,null]);else if(ce[1]){if(ce[0].type!==Q.type)return;ye([ce[0],Q])}else{if(ce[0].type!==Q.type)return;ye([ce[0],Q])}}else j(Q)},q=Q=>{if(ce[0]?.setting_id===Q.setting_id)return 0;if(ce[1]?.setting_id===Q.setting_id)return 1},B=async Q=>{try{const ne=await ge.getCloudSettingDetail(Q.setting_id),ie=Q.type==="process"?"print":Q.type;U({type:ie,name:Q.name,base_id:ne.base_id||"GFSA00",setting:ne.setting||{}}),j(null)}catch(ne){console.error("Failed to fetch preset details for duplication:",ne)}},re=async Q=>{try{Ee.removeQueries({queryKey:["cloudSettingDetail",Q.setting_id]});const ne=await ge.getCloudSettingDetail(Q.setting_id),ie=Q.type==="process"?"print":Q.type;L({type:ie,name:Q.name,base_id:ne.base_id||"GFSA00",setting:ne.setting||{},setting_id:Q.setting_id}),j(null)}catch(ne){console.error("Failed to fetch preset details for editing:",ne)}},z=()=>{d("all"),f("all"),x("all"),g("all"),_("all"),A("all"),c("")},V=u!=="all"||h!=="all"||p!=="all"||v!=="all"||y!=="all"||N!=="all"||l!=="",te=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(Er,{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 max-[550px]:flex-wrap max-[550px]:items-center",children:[a.jsxs(Oe,{variant:Y?"primary":"secondary",onClick:()=>{Y?(se(!1),ye([null,null])):se(!0)},children:[a.jsx(tb,{className:"w-4 h-4"}),o(Y?"common.cancel":"profiles.presets.compare")]}),a.jsxs(Oe,{variant:"secondary",onClick:()=>D(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[a.jsx(vb,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),a.jsxs(Oe,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[a.jsx(wr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),a.jsxs(Oe,{onClick:()=>R(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[a.jsx(nr,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(Jk,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(Lg,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:te},{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(Lg,{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=>f(Q)}),K.printers.length>0&&a.jsx(Lg,{label:o("profiles.cloudView.filters.printer"),value:p,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...K.printers.map(Q=>({value:Q.id,label:Q.name}))],onChange:x}),K.nozzles.length>0&&a.jsx(Lg,{label:o("profiles.cloudView.filters.nozzle"),value:v,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...K.nozzles.map(Q=>({value:Q,label:Q}))],onChange:g}),K.filaments.length>0&&(u==="all"||u==="filament")&&a.jsx(Lg,{label:o("profiles.cloudView.filters.filament"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...K.filaments.map(Q=>({value:Q,label:Q}))],onChange:_}),K.layerHeights.length>0&&(u==="all"||u==="process")&&a.jsx(Lg,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...K.layerHeights.map(Q=>({value:Q,label:Q}))],onChange:A}),V&&a.jsx("button",{onClick:z,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),Y&&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(tb,{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:ce[0]?o("profiles.cloudView.selectAnotherPreset",{type:ce[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] ${ce[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:ce[0]?ce[0].name:o("profiles.cloudView.selectFirst")}),a.jsx(f3,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${ce[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:ce[1]?ce[1].name:o("profiles.cloudView.selectSecond")})]}),ce[0]&&ce[1]&&a.jsxs(Oe,{size:"sm",onClick:async()=>{try{const[Q,ne]=await Promise.all([ge.getCloudSettingDetail(ce[0].setting_id),ge.getCloudSettingDetail(ce[1].setting_id)]);be([Q.setting||{},ne.setting||{}]),ue(!0)}catch{}},children:[a.jsx(tb,{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(Xn,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",C0(e.toISOString(),"system",o)]}),a.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:E.length,total:te})}),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")]})]})]}),E.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(Ga,{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")}),V&&a.jsx("button",{onClick:z,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(Qk,{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:["(",E.filter(Q=>Q.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[E.filter(Q=>Q.type==="filament").map(Q=>a.jsx(HE,{setting:Q,onClick:()=>O(Q),onDuplicate:()=>B(Q),compareMode:Y,isCompareSelected:q(Q)!==void 0,compareIndex:q(Q),compareDisabled:Y&&!!ce[0]&&ce[0].type!==Q.type,t:o},Q.setting_id)),E.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(rd,{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:["(",E.filter(Q=>Q.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[E.filter(Q=>Q.type==="process").map(Q=>a.jsx(HE,{setting:Q,onClick:()=>O(Q),onDuplicate:()=>B(Q),compareMode:Y,isCompareSelected:q(Q)!==void 0,compareIndex:q(Q),compareDisabled:Y&&!!ce[0]&&ce[0].type!==Q.type,t:o},Q.setting_id)),E.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:["(",E.filter(Q=>Q.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[E.filter(Q=>Q.type==="printer").map(Q=>a.jsx(HE,{setting:Q,onClick:()=>O(Q),onDuplicate:()=>B(Q),compareMode:Y,isCompareSelected:q(Q)!==void 0,compareIndex:q(Q),compareDisabled:Y&&!!ce[0]&&ce[0].type!==Q.type,t:o},Q.setting_id)),E.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")})]})]})]}),C&&a.jsx(yJe,{setting:C,onClose:()=>j(null),onDeleted:()=>j(null),onDuplicate:()=>B(C),onEdit:()=>re(C),hasPermission:s,t:o}),(k||G||W||ee)&&a.jsx(wJe,{onClose:()=>{R(!1),U(null),L(null),ae(null)},initialData:W||G||(ee?{type:ee.type,name:"",base_id:"",setting:ee.setting}:void 0),allPresets:t,t:o}),M&&a.jsx(vJe,{onClose:()=>D(!1),onApply:Q=>{ae({type:Q.type,setting:Q.settings}),D(!1)},t:o}),Z&&pe&&ce[0]&&ce[1]&&a.jsx(yse,{onClose:()=>{ue(!1),be(null)},leftPreset:pe[0],rightPreset:pe[1],leftLabel:ce[0].name,rightLabel:ce[1].name,t:o})]})}function _Je(){const{t}=Et(),e=Qt(),{showToast:n}=dn(),{hasPermission:r}=Rr(),[i,s]=w.useState("cloud"),[o,l]=w.useState(),{data:c,isLoading:u}=Je({queryKey:["cloudStatus"],queryFn:ge.getCloudStatus}),{data:d=[]}=Je({queryKey:["printers"],queryFn:ge.getPrinters}),{data:h,isLoading:f,refetch:p,dataUpdatedAt:x}=Je({queryKey:["cloudSettings"],queryFn:()=>ge.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{x&&l(new Date(x))},[x]);const v=ut({mutationFn:ge.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),g=()=>{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(Zb,{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(Jb,{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(eC,{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(Oe,{variant:"secondary",size:"sm",onClick:()=>v.mutate(),disabled:v.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[a.jsx(x3,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?f?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(SJe,{settings:h,lastSyncTime:o,onRefresh:()=>p(),isRefreshing:f,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(Oe,{onClick:()=>p(),children:t("profiles.retry")})]}):a.jsx(bJe,{onSuccess:g,t})]}),i==="local"&&a.jsx(gJe,{}),i==="kprofiles"&&a.jsx(hJe,{}),a.jsx(xJe,{})]})}const Yy={Droplet:Qk,Flame:Vme,Ruler:Npe,Sparkles:vb,Square:_l,Cable:Ahe,Wrench:zf,Calendar:Xr,Timer:zu,Cog:mme,Fan:OY,Zap:Ic,Wind:KY,Thermometer:lC,Layers:Ga,Box:ni,Target:qY,RefreshCw:wr,Settings:oC,Filter:Jk,CircleDot:Khe};function x0(t){return t&&Yy[t]||zf}function Og(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 $E(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 NJe(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 Carbon Rods":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":h?"https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis":null;case"Lubricate Linear Rails":return 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":null;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||h?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":null;case"Clean Linear Rails":return 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":null;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 kJe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const s=x0(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const p=t.days_since_maintenance??0;return Math.max(0,Math.min(100,p/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",f=()=>{if(!t.enabled)return i("common.disabled");if(o==="days"){const p=t.days_until_due??0;return t.is_due?i("maintenance.overdueBy",{duration:Og(Math.abs(p),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:Og(p,"days",i)}):i("maintenance.timeLeft",{duration:Og(p,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:Og(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:Og(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:Og(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 max-[550px]:flex-wrap",children:[a.jsxs("div",{className:`relative p-2.5 rounded-lg shrink-0 ${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(Xr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const p=t.maintenance_type_wiki_url||NJe(t.maintenance_type_name,t.printer_model);return p?a.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:x=>x.stopPropagation(),children:a.jsx(aa,{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(Mn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(Xn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Zr,{className:"w-3 h-3"}),f()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0 max-[550px]:w-full max-[550px]:justify-end max-[550px]:mt-1",children:[a.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:a.jsx($n,{checked:t.enabled,onChange:p=>n(t.id,p),disabled:!r("maintenance:update")})}),a.jsxs(Oe,{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(co,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function CJe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:s}){const[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(t.total_print_hours.toFixed(1)),f=[...t.maintenance_items].sort((v,g)=>v.is_due&&!g.is_due?-1:!v.is_due&&g.is_due?1:v.is_warning&&!g.is_warning?-1:!v.is_warning&&g.is_warning?1:v.maintenance_type_id-g.maintenance_type_id),p=f.find(v=>v.enabled&&(v.is_due||v.is_warning)),x=()=>{const v=parseFloat(d);!isNaN(v)&&v>=0&&(r(t.printer_id,v),u(!1))};return a.jsxs(Ct,{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(Mn,{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(Xn,{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(Zr,{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(Sl,{className:"w-4 h-4"}):a.jsx(En,{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(zu,{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:v=>h(v.target.value),onKeyDown:v=>{v.key==="Enter"&&x(),v.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(Oe,{size:"sm",onClick:x,children:s("common.save")}),a.jsx(Oe,{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(Of,{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"}),p&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${p.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const v=x0(p.maintenance_type_icon);return a.jsx(v,{className:`w-4 h-4 ${p.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${p.is_due?"text-red-400":"text-amber-400"}`,children:p.maintenance_type_name}),a.jsx("div",{className:`text-xs ${p.is_due?"text-red-400/70":"text-amber-400/70"}`,children:p.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&a.jsx(Tt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:a.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:f.map(v=>a.jsx(kJe,{item:v,onPerform:e,onToggle:n,hasPermission:i,t:s},v.id))})})]})}function AJe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onRestoreDefaults:o,isRestoringDefaults:l,onAssignType:c,onRemoveItem:u,hasPermission:d,t:h}){const[f,p]=w.useState(null),[x,v]=w.useState(""),[g,y]=w.useState("hours"),[_,N]=w.useState(!1),[A,C]=w.useState(""),[j,k]=w.useState("100"),[R,M]=w.useState("hours"),[D,G]=w.useState("Wrench"),[U,W]=w.useState(""),[L,ee]=w.useState(new Set),[ae,Y]=w.useState(null),[se,ce]=w.useState(null),ye=w.useMemo(()=>t?t.map(I=>({id:I.printer_id,name:I.printer_name})):[],[t]),Z=I=>t?t.filter(F=>F.maintenance_items.some(J=>J.maintenance_type_id===I)).map(F=>({printerId:F.printer_id,printerName:F.printer_name,itemId:F.maintenance_items.find(J=>J.maintenance_type_id===I)?.id})):[],ue=I=>{if(!t)return[];const F=new Set(Z(I).map(J=>J.printerId));return ye.filter(J=>!F.has(J.id))},[pe,be]=w.useState(null),[Ee,$]=w.useState(""),[K,T]=w.useState(""),[E,O]=w.useState("hours"),[q,B]=w.useState("Wrench"),[re,z]=w.useState(""),V=I=>{be(I),$(I.name),T(I.default_interval_hours.toString()),O(I.interval_type||"hours"),B(I.icon||"Wrench"),z(I.wiki_url||"")},te=()=>{pe&&Ee.trim()&&parseFloat(K)>0&&(i(pe.id,{name:Ee.trim(),default_interval_hours:parseFloat(K),interval_type:E,icon:q,wiki_url:re.trim()||null}),be(null))},Q=(I,F,J)=>{const xe=parseFloat(x);if(!isNaN(xe)&&xe>0){const he=Math.abs(xe-F)<.01?null:xe;n(I,{custom_interval_hours:he,custom_interval_type:g!==J?g:null})}p(null)},ne=I=>{I.preventDefault(),A.trim()&&parseFloat(j)>0&&L.size>0&&(r({name:A.trim(),default_interval_hours:parseFloat(j),interval_type:R,icon:D,wiki_url:U.trim()||null},Array.from(L)),C(""),k("100"),M("hours"),W(""),ee(new Set),N(!1))},ie=I=>{ee(F=>{const J=new Set(F);return J.has(I)?J.delete(I):J.add(I),J})},me=t?.map(I=>({printerId:I.printer_id,printerName:I.printer_name,items:I.maintenance_items.sort((F,J)=>F.maintenance_type_id-J.maintenance_type_id)})).sort((I,F)=>I.printerName.localeCompare(F.printerName))||[],fe=e.filter(I=>I.is_system),oe=e.filter(I=>!I.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:h("maintenance.maintenanceTypes")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.maintenanceTypesDescription")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Oe,{variant:"secondary",onClick:o,disabled:!d("maintenance:delete")||l,title:d("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),children:h("maintenance.restoreDefaults")}),a.jsxs(Oe,{onClick:()=>N(!_),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:h("maintenance.noPermissionEditTypes"),children:[a.jsx(nr,{className:"w-4 h-4"}),h("maintenance.addCustomType")]})]})]}),_&&a.jsx(Ct,{className:"mb-6",children:a.jsx(Tt,{className:"py-4",children:a.jsxs("form",{onSubmit:ne,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:h("common.name")}),a.jsx("input",{type:"text",value:A,onChange:I=>C(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:h("maintenance.exampleName"),autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalType")}),a.jsxs("select",{value:R,onChange:I=>{M(I.target.value),I.target.value==="days"?k("30"):k("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:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.intervalValue",{type:R==="days"?h("maintenance.calendarDays").toLowerCase():h("common.hours")})}),a.jsx("input",{type:"number",value:j,onChange:I=>k(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),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:h("maintenance.icon")}),a.jsx("div",{className:"flex gap-1",children:Object.keys(Yy).map(I=>{const F=Yy[I];return a.jsx("button",{type:"button",onClick:()=>G(I),className:`p-2 rounded-lg transition-colors ${D===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(F,{className:"w-4 h-4"})},I)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.documentationLink")}),a.jsx("input",{type:"url",value:U,onChange:I=>W(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:h("maintenance.assignToPrinters")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:ye.map(I=>a.jsx("button",{type:"button",onClick:()=>ie(I.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${L.has(I.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:I.name},I.id))}),L.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:h("maintenance.selectAtLeastOnePrinter")})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Oe,{type:"button",variant:"secondary",onClick:()=>{N(!1),ee(new Set)},children:h("common.cancel")}),a.jsx(Oe,{type:"submit",disabled:!A.trim()||L.size===0,children:h("maintenance.addType")})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[fe.map(I=>{const F=x0(I.icon),J=I.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(F,{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:I.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[J==="days"?a.jsx(Xr,{className:"w-3 h-3"}):a.jsx(zu,{className:"w-3 h-3"}),$E(I.default_interval_hours,J,h)]})]}),a.jsx("button",{onClick:()=>{d("maintenance:delete")&&ce(I)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Xt,{className:"w-4 h-4"})})]})},I.id)}),oe.map(I=>{const F=x0(I.icon),J=I.interval_type||"hours";if(pe?.id===I.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:Ee,onChange:Ne=>$(Ne.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:h("common.name"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:E,onChange:Ne=>O(Ne.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:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:K,onChange:Ne=>T(Ne.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(Yy).map(Ne=>{const Ue=Yy[Ne];return a.jsx("button",{type:"button",onClick:()=>B(Ne),className:`p-1.5 rounded transition-colors ${q===Ne?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx(Ue,{className:"w-3.5 h-3.5"})},Ne)})}),a.jsx("input",{type:"url",value:re,onChange:Ne=>z(Ne.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:h("maintenance.documentationLink")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Oe,{size:"sm",onClick:te,disabled:!Ee.trim(),children:h("common.save")}),a.jsx(Oe,{size:"sm",variant:"secondary",onClick:()=>be(null),children:h("common.cancel")})]})]})},I.id);const he=Z(I.id),le=ue(I.id),Ce=ae===I.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(F,{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:I.name}),a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:h("maintenance.custom")})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[J==="days"?a.jsx(Xr,{className:"w-3 h-3"}):a.jsx(zu,{className:"w-3 h-3"}),$E(I.default_interval_hours,J,h)]})]}),a.jsxs("button",{onClick:()=>Y(Ce?null:I.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${he.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:h("maintenance.printersAssignedClick",{count:he.length}),children:[a.jsx(Dr,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:he.length}),a.jsx(En,{className:`w-3 h-3 transition-transform ${Ce?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>V(I),disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:h("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${d("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Of,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(h("maintenance.deleteTypeConfirm",{name:I.name}))&&s(I.id)},disabled:!d("maintenance:delete"),title:d("maintenance:delete")?void 0:h("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${d("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(Xt,{className:"w-4 h-4"})})]}),Ce&&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:h("maintenance.assignedToPrinters")}),he.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:h("maintenance.noPrintersAssigned")}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:he.map(Ne=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[Ne.printerName,a.jsx("button",{onClick:()=>Ne.itemId&&u(Ne.itemId),disabled:!d("maintenance:delete"),title:d("maintenance:delete")?h("maintenance.removeFromPrinter"):h("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${d("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},Ne.printerId))}),le.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:h("maintenance.addPrinterShort")}),le.map(Ne=>a.jsxs("button",{onClick:()=>c(Ne.id,I.id),disabled:!d("maintenance:create"),title:d("maintenance:create")?void 0:h("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${d("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",Ne.name]},Ne.id))]})]})]},I.id)})]})]}),me.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:h("maintenance.intervalOverrides")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:h("maintenance.intervalOverridesDescription")})]}),a.jsx("div",{className:"space-y-4",children:me.map(I=>a.jsx(Ct,{children:a.jsxs(Tt,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:I.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:I.items.map(F=>{const J=x0(F.maintenance_type_icon),xe=e.find(Ue=>Ue.id===F.maintenance_type_id),he=xe?.default_interval_hours||F.interval_hours,le=xe?.interval_type||"hours",Ce=F.interval_type||"hours",Ne=f===F.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(J,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:F.maintenance_type_name}),Ne?a.jsxs("div",{className:"flex items-center gap-1",children:[g==="days"?a.jsx(Xr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(zu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:g,onChange:Ue=>y(Ue.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:h("maintenance.printHours")}),a.jsx("option",{value:"days",children:h("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:x,onChange:Ue=>v(Ue.target.value),onKeyDown:Ue=>{Ue.key==="Enter"&&Q(F.id,he,le),Ue.key==="Escape"&&p(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(Oe,{size:"sm",onClick:()=>Q(F.id,he,le),children:"OK"})]}):a.jsxs("button",{onClick:()=>{d("maintenance:update")&&(p(F.id),v(F.interval_hours.toString()),y(Ce))},disabled:!d("maintenance:update"),title:d("maintenance:update")?void 0:h("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 ${d("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[Ce==="days"?a.jsx(Xr,{className:"w-3 h-3"}):a.jsx(zu,{className:"w-3 h-3"}),$E(F.interval_hours,Ce,h),a.jsx(Of,{className:"w-3 h-3 text-bambu-gray"})]})]},F.id)})})]})},I.printerId))})]}),me.length===0&&a.jsx(Ct,{children:a.jsxs(Tt,{className:"text-center py-12",children:[a.jsx(Xn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:h("common.noPrinters")}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:h("maintenance.intervalOverridesDescription")})]})}),se&&a.jsx(Sn,{title:h("maintenance.deleteSystemTypeTitle"),message:h("maintenance.deleteSystemTypeMessage",{name:se.name}),confirmText:h("common.delete"),cancelText:h("common.cancel"),variant:"danger",cancelVariant:"primary",cardClassName:"bg-red-950/70 border border-red-800/70",onConfirm:()=>{s(se.id),ce(null)},onCancel:()=>ce(null)})]})}function TJe(){const{t}=Et(),e=Qt(),{showToast:n}=dn(),{hasPermission:r}=Rr(),[i,s]=w.useState("status"),{data:o,isLoading:l}=Je({queryKey:["maintenanceOverview"],queryFn:ge.getMaintenanceOverview}),{data:c}=Je({queryKey:["maintenanceTypes"],queryFn:ge.getMaintenanceTypes}),u=ut({mutationFn:({id:j,notes:k})=>ge.performMaintenance(j,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:j=>{n(j.message,"error")}}),d=ut({mutationFn:({id:j,data:k})=>ge.updateMaintenanceItem(j,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:j=>{n(j.message,"error")}}),h=ut({mutationFn:({id:j,data:k})=>ge.updateMaintenanceType(j,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:j=>{n(j.message,"error")}}),f=ut({mutationFn:ge.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:j=>{n(j.message,"error")}}),p=ut({mutationFn:ge.restoreDefaultMaintenanceTypes,onSuccess:j=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.defaultsRestored",{count:j.restored}))},onError:j=>{n(j.message,"error")}}),x=ut({mutationFn:({printerId:j,hours:k})=>ge.setPrinterHours(j,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:j=>{n(j.message,"error")}}),v=ut({mutationFn:({printerId:j,typeId:k})=>ge.assignMaintenanceType(j,k),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:j=>{n(j.message,"error")}}),g=ut({mutationFn:ge.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:j=>{n(j.message,"error")}}),y=j=>{u.mutate({id:j})},_=(j,k)=>{d.mutate({id:j,data:{enabled:k}})},N=(j,k)=>{x.mutate({printerId:j,hours:k})};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 A=o?.reduce((j,k)=>j+k.due_count,0)||0,C=o?.reduce((j,k)=>j+k.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:[A>0&&a.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:A})}),A>0&&C>0&&" · ",C>0&&a.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:C})}),A===0&&C===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((j,k)=>{const R=j.due_count*10+j.warning_count,M=k.due_count*10+k.warning_count;return R!==M?M-R:j.printer_name.localeCompare(k.printer_name)}).map(j=>a.jsx(CJe,{overview:j,onPerform:y,onToggle:_,onSetHours:N,hasPermission:r,t},j.printer_id)):a.jsx(Ct,{children:a.jsxs(Tt,{className:"text-center py-16",children:[a.jsx(zf,{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(AJe,{overview:o,types:c||[],onUpdateInterval:(j,k)=>d.mutate({id:j,data:k}),onAddType:async(j,k)=>{const R=await ge.createMaintenanceType(j);for(const M of k)await ge.assignMaintenanceType(M,R.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(j,k)=>h.mutate({id:j,data:k}),onDeleteType:j=>f.mutate(j),onRestoreDefaults:()=>p.mutate(),isRestoringDefaults:p.isPending,onAssignType:(j,k)=>v.mutate({printerId:j,typeId:k}),onRemoveItem:j=>g.mutate(j),hasPermission:r,t})]})}const _K=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function vse({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.useState(t?.name||""),[l,c]=w.useState(t?.description||""),[u,d]=w.useState(t?.color||_K[0]),[h,f]=w.useState(t?.target_count?.toString()||""),[p,x]=w.useState(t?.target_parts_count?.toString()||""),[v,g]=w.useState(t?.status||"active"),[y,_]=w.useState(t?.tags||""),[N,A]=w.useState(t?.due_date?.split("T")[0]||""),[C,j]=w.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:p?parseInt(p,10):void 0,tags:y.trim()||void 0,due_date:N||void 0,priority:C,...t&&{status:v}})};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:_K.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=>f(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:p,onChange:R=>x(R.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:i("projects.targetPartsPlaceholder"),min:"1"}),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:y,onChange:R=>_(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=>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"})]}),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:C,onChange:R=>j(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:v,onChange:R=>g(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(Oe,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Oe,{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 MJe({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]=w.useState(!1),p=c?{icon:yb,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:Fs,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Xn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:xs,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 ${p.bg} flex-shrink-0`,children:a.jsx(p.icon,{className:`w-5 h-5 ${p.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 x=t.archives.map(_=>_.filament_type).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(Boolean),v=[...new Set(x)],g=t.archives.map(_=>_.filament_color).filter(Boolean).flatMap(_=>_.split(",").map(N=>N.trim())).filter(_=>_.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(_)),y=[...new Set(g)];return v.length===0&&y.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[v.slice(0,3).map(_=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:_},_)),y.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[y.slice(0,5).map(_=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:_.startsWith("#")?_:`#${_}`},title:_},_)),y.length>5&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",y.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:x=>x.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(Rh,{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(Of,{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(Xt,{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(Fs,{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(Mn,{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(Xn,{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(x=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:x.print_name||"Unknown",children:[x.thumbnail_path?a.jsx("img",{src:ge.getArchiveThumbnail(x.id),alt:x.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(si,{className:"w-6 h-6"})}),x.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(Mn,{className:"w-4 h-4 text-white"})})]},x.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(Ga,{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(si,{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(Mn,{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(b3,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(pi,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function PJe(){const{t}=Et(),e=jl(),n=Qt(),{showToast:r}=dn(),{hasPermission:i}=Rr(),[s,o]=w.useState(!1),[l,c]=w.useState(),[u,d]=w.useState("active"),[h,f]=w.useState(null),{data:p,isLoading:x}=Je({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>ge.getProjects(u==="all"?void 0:u)}),v=ut({mutationFn:W=>ge.createProject(W),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:W=>{r(W.message,"error")}}),g=ut({mutationFn:({id:W,data:L})=>ge.updateProject(W,L),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:W=>{r(W.message,"error")}}),y=ut({mutationFn:W=>ge.deleteProject(W),onSuccess:()=>{f(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:W=>{f(null),r(W.message,"error")}}),_=ut({mutationFn:W=>ge.importProject(W),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:W=>{r(W.message,"error")}}),N=w.useRef(null),A=async()=>{try{const W=await ge.getProjects(),L=await Promise.all(W.map(async se=>await ge.exportProjectJson(se.id))),ee=new Blob([JSON.stringify(L,null,2)],{type:"application/json"}),ae=URL.createObjectURL(ee),Y=document.createElement("a");Y.href=ae,Y.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,Y.click(),URL.revokeObjectURL(ae),r(t("projects.toast.exported"),"success")}catch(W){r(W.message,"error")}},C=()=>{N.current?.click()},j=async W=>{const L=W.target.files?.[0];if(L){try{if(L.name.toLowerCase().endsWith(".zip"))await ge.importProjectFile(L),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const ae=await L.text(),Y=JSON.parse(ae),se=Array.isArray(Y)?Y:[Y];for(const ce of se)await _.mutateAsync(ce);se.length>1&&r(t("projects.toast.multipleImported",{count:se.length}),"success")}}catch(ee){r(`${t("projects.toast.importFailed")}: ${ee.message}`,"error")}W.target.value=""}},k=W=>{l?g.mutate({id:l.id,data:W}):v.mutate(W)},R=W=>{c(W),o(!0)},M=W=>{e(`/projects/${W.id}`)},D=W=>{f(W)},G=()=>{h!==null&&y.mutate(h)},U=p?.reduce((W,L)=>(W[L.status]=(W[L.status]||0)+1,W.all=(W.all||0)+1,W),{})||{};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:j,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(xs,{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(Oe,{variant:"secondary",onClick:C,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[a.jsx(Ia,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),a.jsxs(Oe,{variant:"secondary",onClick:A,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[a.jsx(ba,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),a.jsxs(Oe,{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(nr,{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:Xn},{key:"completed",label:t("projects.statusCompleted"),icon:yb},{key:"archived",label:t("projects.statusArchived"),icon:Fs},{key:"all",label:t("common.all"),icon:xs}].map(({key:W,label:L,icon:ee})=>a.jsxs("button",{onClick:()=>d(W),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===W?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx(ee,{className:"w-4 h-4"}),a.jsx("span",{children:L}),U[W]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===W?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:U[W]})]},W))}),x?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")})]})}):p?.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(xs,{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(Oe,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(nr,{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:p?.map(W=>a.jsx(MJe,{project:W,onClick:()=>M(W),onEdit:()=>R(W),onDelete:()=>D(W.id),hasPermission:i,t},W.id))}),h!==null&&a.jsx(Sn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:G,onCancel:()=>f(null)}),s&&a.jsx(vse,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:k,isLoading:v.isPending||g.isPending,t})]})}function jJe(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 EJe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function DJe({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 NK({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(Ct,{children:a.jsx(Tt,{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 RJe({archives:t,t:e}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(si,{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(Zs,{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:ge.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(si,{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(ii,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(xr,{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 FJe({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(Mn,{className:"w-3 h-3"}),i]})}function LJe(t){return t?wb(t,{year:"numeric",month:"short",day:"numeric"}):""}function VE(t,e){if(!t)return null;const n=Jn(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 OJe(){const{id:t}=bv(),e=jl(),{t:n}=Et(),r=Qt(),{showToast:i}=dn(),{hasPermission:s}=Rr(),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(""),f=parseInt(t||"0",10),{data:p,isLoading:x,error:v}=Je({queryKey:["project",f],queryFn:()=>ge.getProject(f),enabled:f>0}),{data:g,isLoading:y}=Je({queryKey:["project-archives",f],queryFn:()=>ge.getProjectArchives(f),enabled:f>0}),{data:_,isLoading:N}=Je({queryKey:["project-bom",f],queryFn:()=>ge.getProjectBOM(f),enabled:f>0}),{data:A,isLoading:C}=Je({queryKey:["project-timeline",f],queryFn:()=>ge.getProjectTimeline(f,20),enabled:f>0}),{data:j}=Je({queryKey:["settings"],queryFn:ge.getSettings}),{data:k}=Je({queryKey:["project-folders",f],queryFn:()=>ge.getLibraryFoldersByProject(f),enabled:f>0}),R=sl(j?.currency||"USD"),M=j?.time_format||"system",D=ut({mutationFn:Ae=>ge.updateProject(f,Ae),onSuccess:()=>{r.invalidateQueries({queryKey:["project",f]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:Ae=>{i(Ae.message,"error")}}),G=()=>{h(p?.notes||""),u(!0)},U=()=>{D.mutate({notes:d})},W=()=>{u(!1),h("")},[L,ee]=w.useState(""),[ae,Y]=w.useState(1),[se,ce]=w.useState(""),[ye,Z]=w.useState(""),[ue,pe]=w.useState(""),[be,Ee]=w.useState(!1),[$,K]=w.useState(!1),[T,E]=w.useState(null),[O,q]=w.useState(""),[B,re]=w.useState(1),[z,V]=w.useState(""),[te,Q]=w.useState(""),[ne,ie]=w.useState(""),[me,fe]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),oe=ut({mutationFn:Ae=>ge.createBOMItem(f,Ae),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),ee(""),Y(1),ce(""),Z(""),pe(""),Ee(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:Ae=>i(Ae.message,"error")}),I=ut({mutationFn:({itemId:Ae,data:Ve})=>ge.updateBOMItem(f,Ae,Ve),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),E(null)},onError:Ae=>i(Ae.message,"error")}),F=ut({mutationFn:Ae=>ge.deleteBOMItem(f,Ae),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",f]}),r.invalidateQueries({queryKey:["project",f]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:Ae=>i(Ae.message,"error")}),J=Ae=>{Ae.preventDefault(),L.trim()&&oe.mutate({name:L.trim(),quantity_needed:ae,unit_price:se?parseFloat(se):void 0,sourcing_url:ye.trim()||void 0,remarks:ue.trim()||void 0})},xe=Ae=>{const Ve=Ae.is_complete?0:Ae.quantity_needed;I.mutate({itemId:Ae.id,data:{quantity_acquired:Ve}})},he=(Ae,Ve)=>{fe({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Ve}),onConfirm:()=>{fe(Te=>({...Te,isOpen:!1})),F.mutate(Ae)}})},le=Ae=>{E(Ae),q(Ae.name),re(Ae.quantity_needed),V(Ae.unit_price?.toString()||""),Q(Ae.sourcing_url||""),ie(Ae.remarks||"")},Ce=Ae=>{Ae.preventDefault(),!(!T||!O.trim())&&I.mutate({itemId:T.id,data:{name:O.trim(),quantity_needed:B,unit_price:z?parseFloat(z):void 0,sourcing_url:te.trim()||void 0,remarks:ne.trim()||void 0}})},Ne=()=>{E(null)},Ue=async()=>{try{const{blob:Ae,filename:Ve}=await ge.exportProjectZip(Number(f)),Te=URL.createObjectURL(Ae),Ke=document.createElement("a");Ke.href=Te,Ke.download=Ve||`${p?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,Ke.click(),URL.revokeObjectURL(Te),i(n("projectDetail.toast.projectExported"),"success")}catch(Ae){i(Ae.message,"error")}},He=ut({mutationFn:()=>ge.createTemplateFromProject(f),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:Ae=>i(Ae.message,"error")}),de=Ae=>Uf(Ae,M,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)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(v||!p)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:v?`${n("common.error")}: ${v.message}`:n("projectDetail.notFound")}),a.jsx(Oe,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const we=p.stats,ke=we?.progress_percent??0,_e=we?.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(Zs,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),a.jsx(pi,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:p.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(EY,{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:p.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:p.name}),p.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:p.description})]})]}),a.jsx(DJe,{status:p.status,t:n})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Oe,{variant:"secondary",onClick:Ue,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[a.jsx(ba,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),a.jsxs(Oe,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[a.jsx(Of,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(p.target_count||p.target_parts_count)&&a.jsx(Ct,{children:a.jsxs(Tt,{className:"p-4 space-y-4",children:[p.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:[we?.total_archives||0," / ",p.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(ke,100)}%`,backgroundColor:ke>=100?"#22c55e":p.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:ke.toFixed(0)})}),we?.remaining_prints!=null&&we.remaining_prints>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:we.remaining_prints})})]})]}),p.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:[we?.completed_prints||0," / ",p.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(_e,100)}%`,backgroundColor:_e>=100?"#22c55e":p.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:_e.toFixed(0)})}),we?.remaining_parts!=null&&we.remaining_parts>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:we.remaining_parts})})]})]})]})}),we&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(Ct,{children:a.jsx(Tt,{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(si,{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:[we.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),we.failed_prints>0&&a.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:we.failed_prints})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:we.completed_prints})})]})]})})}),a.jsx(NK,{icon:Xn,label:n("projectDetail.stats.printTime"),value:jJe(we.total_print_time_hours),color:"text-yellow-400"}),a.jsx(NK,{icon:Dr,label:n("projectDetail.stats.filamentUsed"),value:EJe(we.total_filament_grams),color:"text-purple-400"})]}),we&&(we.estimated_cost>0||p.budget)&&a.jsx(Ct,{children:a.jsxs(Tt,{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,we.estimated_cost.toFixed(2)]})]}),we.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:[we.total_energy_kwh.toFixed(3)," kWh",we.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",R,we.total_energy_cost.toFixed(2),")"]})]})]}),p.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,p.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 ${p.budget-we.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[R,(p.budget-we.estimated_cost).toFixed(2)]})]})]})]})]})}),p.children&&p.children.length>0&&a.jsx(Ct,{children:a.jsxs(Tt,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(Xme,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:p.children.length})]}),a.jsx("div",{className:"space-y-2",children:p.children.map(Ae=>a.jsxs(Zs,{to:`/projects/${Ae.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:Ae.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:Ae.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Ae.status==="completed"?"bg-status-ok/20 text-status-ok":Ae.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Ae.status})]}),Ae.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[Ae.progress_percent.toFixed(0),"%"]})]},Ae.id))})]})}),p.parent_id&&p.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Ga,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),a.jsx(Zs,{to:`/projects/${p.parent_id}`,className:"text-bambu-green hover:underline",children:p.parent_name})]}),(p.tags||p.due_date||p.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[p.priority&&p.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(FJe,{priority:p.priority,t:n})]}),p.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xr,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:LJe(p.due_date)}),VE(p.due_date,n)&&a.jsxs("span",{className:`text-xs ${VE(p.due_date,n).color}`,children:["(",VE(p.due_date,n).label,")"]})]}),p.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ad,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:p.tags.split(",").map((Ae,Ve)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Ae.trim()},Ve))})]})]}),a.jsx(Ct,{children:a.jsxs(Tt,{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(Es,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:W,disabled:D.isPending,children:[a.jsx(Ut,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),a.jsxs(Oe,{size:"sm",onClick:U,disabled:D.isPending,children:[D.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(bs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:G,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[a.jsx(Of,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?a.jsx(uF,{content:d,onChange:h,placeholder:n("projectDetail.notes.placeholder")}):p.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:p.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),a.jsx(Ct,{children:a.jsxs(Tt,{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(nc,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(Zs,{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(Ae=>a.jsxs(Zs,{to:`/files?folder=${Ae.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(nc,{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:Ae.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:Ae.file_count})})]})]}),a.jsx(pi,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Ae.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),a.jsx(Ct,{children:a.jsxs(Tt,{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($Y,{className:"w-5 h-5"}),n("projectDetail.bom.title"),we&&we.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:we.bom_completed_items,total:we.bom_total_items}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[_&&_.some(Ae=>Ae.is_complete)&&a.jsx("button",{onClick:()=>K(!$),className:`text-xs px-2 py-1 rounded transition-colors ${$?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n($?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!be&&a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>Ee(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[a.jsx(nr,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),be&&a.jsxs("form",{onSubmit:J,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:L,onChange:Ae=>ee(Ae.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:ae,onChange:Ae=>Y(parseInt(Ae.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:se,onChange:Ae=>ce(Ae.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:ye,onChange:Ae=>Z(Ae.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:ue,onChange:Ae=>pe(Ae.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(Oe,{type:"button",variant:"secondary",size:"sm",onClick:()=>Ee(!1),children:n("common.cancel")}),a.jsx(Oe,{type:"submit",size:"sm",disabled:!L.trim()||oe.isPending,children:oe.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"})}):_&&_.length>0?a.jsxs("div",{className:"space-y-2",children:[_.filter(Ae=>!$||!Ae.is_complete).map(Ae=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${Ae.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:T?.id===Ae.id?a.jsxs("form",{onSubmit:Ce,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:O,onChange:Ve=>q(Ve.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:B,onChange:Ve=>re(parseInt(Ve.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:z,onChange:Ve=>V(Ve.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:te,onChange:Ve=>Q(Ve.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:ne,onChange:Ve=>ie(Ve.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(Oe,{type:"button",variant:"secondary",size:"sm",onClick:Ne,children:n("common.cancel")}),a.jsx(Oe,{type:"submit",size:"sm",disabled:!O.trim()||I.isPending,children:I.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")&&xe(Ae),disabled:I.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 ${Ae.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:Ae.is_complete&&a.jsx(xr,{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 ${Ae.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Ae.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Ae.quantity_needed]})]}),Ae.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[R,(Ae.unit_price*Ae.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s("projects:update")&&le(Ae),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(Ka,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("projects:update")&&he(Ae.id,Ae.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(Xt,{className:"w-4 h-4"})})]})]}),Ae.sourcing_url&&a.jsxs("a",{href:Ae.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:Ve=>Ve.stopPropagation(),children:[a.jsx(aa,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Ae.sourcing_url).hostname.replace("www.","")}catch{return Ae.sourcing_url}})()})]}),Ae.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Ae.remarks})]})]})},Ae.id)),_.some(Ae=>Ae.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,_.reduce((Ae,Ve)=>Ae+(Ve.unit_price||0)*Ve.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),a.jsx(Ct,{children:a.jsxs(Tt,{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(N0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),C?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"})}):A&&A.length>0?a.jsx("div",{className:"space-y-3",children:A.slice(0,10).map((Ae,Ve)=>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 ${Ae.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":Ae.event_type==="print_failed"?"bg-status-error/20 text-status-error":Ae.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Ae.event_type==="print_completed"&&a.jsx(xr,{className:"w-4 h-4"}),Ae.event_type==="print_failed"&&a.jsx(ii,{className:"w-4 h-4"}),Ae.event_type==="print_started"&&a.jsx(Dr,{className:"w-4 h-4"}),Ae.event_type==="queued"&&a.jsx(b3,{className:"w-4 h-4"}),Ae.event_type==="project_created"&&a.jsx(nr,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:Ae.title}),Ae.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Ae.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:de(Ae.timestamp)})]})]},Ve))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!p.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>He.mutate(),disabled:He.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[He.isPending?a.jsx(lt,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(ec,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),we&&(we.queued_prints>0||we.in_progress_prints>0)&&a.jsx(Ct,{children:a.jsxs(Tt,{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(b3,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),a.jsx(Zs,{to:`/queue?project=${f}`,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:[we.in_progress_prints>0&&a.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:we.in_progress_prints})}),we.queued_prints>0&&a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:we.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(si,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:g?.length||0})]})}),y?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(RJe,{archives:g||[],t:n})]}),o&&a.jsx(vse,{t:n,project:{...p,archive_count:we?.total_archives||0,total_items:we?.total_items||0,completed_count:we?.completed_prints||0,failed_count:we?.failed_prints||0,queue_count:we?.queued_prints||0,progress_percent:we?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:Ae=>D.mutate(Ae),isLoading:D.isPending}),me.isOpen&&a.jsx(Sn,{title:me.title,message:me.message,confirmText:n("common.delete"),variant:"danger",onConfirm:me.onConfirm,onCancel:()=>fe(Ae=>({...Ae,isOpen:!1}))})]})}function IJe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=w.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(Oe,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Oe,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function zJe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:s}){const[o,l]=w.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(Oe,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),a.jsx(Oe,{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 UJe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s,t:o}){const[l,c]=w.useState(null),u=(h,f=0)=>{const p=[];for(const x of h)p.push({id:x.id,name:x.name,depth:f}),x.children.length>0&&p.push(...u(x.children,f+1));return p},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(nc,{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(Oe,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Oe,{onClick:()=>i(l),disabled:s,children:s?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function BJe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[s,o]=w.useState("project"),[l,c]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&o("archive")});const{data:u}=Je({queryKey:["projects"],queryFn:()=>ge.getProjects()}),{data:d}=Je({queryKey:["archives-for-link"],queryFn:()=>ge.getArchives(void 0,void 0,100)}),h=()=>{n(s==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},f=()=>{n({project_id:0,archive_id:0})},p=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(Ih,{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(Ut,{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(DY,{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(Fs,{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(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:x.name})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):d&&d.length>0?d.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(yf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.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:[p&&a.jsxs(Oe,{variant:"danger",onClick:f,disabled:r,children:[a.jsx(cC,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),a.jsxs("div",{className:`flex gap-2 ${p?"":"ml-auto"}`,children:[a.jsx(Oe,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Oe,{onClick:h,disabled:!l||r,children:r?a.jsx(lt,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function HJe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,s]=w.useState([]),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,h]=w.useState(!0),[f,p]=w.useState(!1),[x,v]=w.useState(!0),g=w.useRef(null),y=ee=>{ee.preventDefault(),l(!0)},_=ee=>{ee.preventDefault(),l(!1)},N=ee=>{ee.preventDefault(),l(!1);const ae=Array.from(ee.dataTransfer.files);C(ae)},A=ee=>{ee.target.files&&C(Array.from(ee.target.files))},C=ee=>{const ae=ee.map(Y=>({file:Y,status:"pending",isZip:Y.name.toLowerCase().endsWith(".zip"),is3mf:Y.name.toLowerCase().endsWith(".3mf")}));s(Y=>[...Y,...ae])},j=ee=>{s(ae=>ae.filter((Y,se)=>se!==ee))},k=i.some(ee=>ee.isZip&&ee.status==="pending"),R=i.some(ee=>ee.file.name.toLowerCase().endsWith(".stl")&&ee.status==="pending"),M=i.some(ee=>ee.is3mf&&ee.status==="pending"),D=async()=>{if(i.length!==0){u(!0);for(let ee=0;ee<i.length;ee++)if(i[ee].status==="pending"){s(ae=>ae.map((Y,se)=>se===ee?{...Y,status:"uploading"}:Y));try{if(i[ee].isZip){const ae=await ge.extractZipFile(i[ee].file,t,d,f,x);s(Y=>Y.map((se,ce)=>ce===ee?{...se,status:ae.errors.length>0&&ae.extracted===0?"error":"success",extractedCount:ae.extracted,error:ae.errors.length>0?`${ae.errors.length} files failed`:void 0}:se))}else await ge.uploadLibraryFile(i[ee].file,t,x),s(ae=>ae.map((Y,se)=>se===ee?{...Y,status:"success"}:Y))}catch(ae){s(Y=>Y.map((se,ce)=>ce===ee?{...se,status:"error",error:ae instanceof Error?ae.message:"Upload failed"}:se))}}u(!1),n(),e()}},G=i.filter(ee=>ee.status==="pending").length,U=i.filter(ee=>ee.status==="success").length,W=i.filter(ee=>ee.status==="error").length,L=i.length>0&&G===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(Ut,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:y,onDragLeave:_,onDrop:N,onClick:()=>g.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(Ia,{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:g,type:"file",multiple:!0,className:"hidden",onChange:A}),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(Fs,{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:ee=>h(ee.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:f,onChange:ee=>p(ee.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")})]})]})]})}),M&&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(nd,{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:x,onChange:ee=>v(ee.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((ee,ae)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[ee.isZip?a.jsx(Fs,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(Zk,{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:ee.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(ee.file.size/1024/1024).toFixed(2)," MB",ee.isZip&&ee.status==="pending"&&a.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),ee.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:ee.extractedCount})]})]})]}),ee.status==="pending"&&a.jsx("button",{onClick:()=>j(ae),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ut,{className:"w-4 h-4 text-bambu-gray"})}),ee.status==="uploading"&&a.jsx(lt,{className:"w-4 h-4 text-bambu-green animate-spin"}),ee.status==="success"&&a.jsx(xr,{className:"w-4 h-4 text-green-500"}),ee.status==="error"&&a.jsx("span",{title:ee.error,children:a.jsx(ii,{className:"w-4 h-4 text-red-500"})})]},ae))}),L&&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:U}),W>0&&a.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:W})]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Oe,{variant:"secondary",onClick:e,children:r(L?"common.close":"common.cancel")}),!L&&a.jsx(Oe,{onClick:D,disabled:G===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(Ia,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",G>0?`(${G})`:""]})})]})]})})}function wse({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]=w.useState(!0),[f,p]=w.useState(!1),x=t.children.length>0,v=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:[x?a.jsx("button",{onClick:g=>{g.stopPropagation(),h(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(pi,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(nc,{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}),v&&a.jsxs("button",{onClick:g=>{g.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(Ih,{className:"w-3 h-3"}),t.project_name?a.jsx(DY,{className:"w-3 h-3"}):a.jsx(Fs,{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}),!v&&a.jsx("button",{onClick:g=>{g.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:a.jsx(Ih,{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:g=>g.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>p(!f),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(Rh,{className:"w-3.5 h-3.5 text-bambu-gray"})}),f&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>p(!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),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[a.jsx(Ka,{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),p(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionLinkFolder"),children:[a.jsx(Ih,{className:"w-3.5 h-3.5"}),u(v?"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),p(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:u("fileManager.noPermissionDeleteFolder"),children:[a.jsx(Xt,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),x&&d&&a.jsx("div",{children:t.children.map(g=>a.jsx(wse,{folder:g,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:u},g.id))})]})}function xF(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function $Je({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:f,canModify:p,authEnabled:x,t:v}){const[g,y]=w.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:`${ge.getLibraryFileThumbnailUrl(t.id)}${h?`?v=${h}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(yf,{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:ml(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Xn,{className:"w-3 h-3"}),js(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:v("fileManager.printedCount",{count:t.print_count})}),x&&t.created_by_username&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(id,{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:_=>_.stopPropagation(),children:[a.jsx("button",{onClick:()=>y(!g),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(Rh,{className:"w-4 h-4 text-bambu-gray"})}),g&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>y(!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&&xF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("printers:control")&&(l(t),y(!1))},disabled:!f("printers:control"),title:f("printers:control")?void 0:v("fileManager.noPermissionPrint"),children:[a.jsx(Dr,{className:"w-3.5 h-3.5"}),v("common.print")]}),o&&xF(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("queue:create")&&(o(t.id),y(!1))},disabled:!f("queue:create"),title:f("queue:create")?void 0:v("fileManager.noPermissionAddToQueue"),children:[a.jsx(Xn,{className:"w-3.5 h-3.5"}),v("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 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(c(t),y(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:"You do not have permission to preview files",children:[a.jsx(ni,{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 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(s(t.id),y(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:v("fileManager.noPermissionDownload"),children:[a.jsx(ba,{className:"w-3.5 h-3.5"}),v("common.download")]}),u&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(u(t),y(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionRenameFile"),children:[a.jsx(Ka,{className:"w-3.5 h-3.5"}),v("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 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(d(t),y(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:v("fileManager.noPermissionGenerateThumbnail"),children:[a.jsx(nd,{className:"w-3.5 h-3.5"}),v("fileManager.generateThumbnail")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","delete",t.created_by_id)&&(i(t.id),y(!1))},disabled:!p("library","delete",t.created_by_id),title:p("library","delete",t.created_by_id)?void 0:v("fileManager.noPermissionDeleteFile"),children:[a.jsx(Xt,{className:"w-3.5 h-3.5"}),v("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 VJe(){const{t}=Et(),e=Qt(),{showToast:n}=dn(),{hasPermission:r,hasAnyPermission:i,canModify:s,authEnabled:o}=Rr(),[l]=MF(),c=l.get("folder"),u=c?parseInt(c,10):null,[d,h]=w.useState(u),[f,p]=w.useState([]),[x,v]=w.useState(!1),[g,y]=w.useState(!1),[_,N]=w.useState(!1),[A,C]=w.useState(null),[j,k]=w.useState(null),[R,M]=w.useState(null),[D,G]=w.useState(null),[U,W]=w.useState(null),[L,ee]=w.useState(null),[ae,Y]=w.useState({}),[se,ce]=w.useState(null),[ye,Z]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[ue,pe]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[be,Ee]=w.useState(()=>{const $e=localStorage.getItem("library-sidebar-width");return $e?parseInt($e,10):256}),[$,K]=w.useState(!1),T=w.useRef(null);w.useEffect(()=>{if(!$)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const $e=gt=>{if(!T.current)return;const Lt=T.current.parentElement?.getBoundingClientRect();if(!Lt)return;const en=gt.clientX-Lt.left,pn=Math.min(500,Math.max(200,en));Ee(pn)},dt=()=>{K(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(be))};return document.addEventListener("mousemove",$e),document.addEventListener("mouseup",dt),()=>{document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",dt),document.body.style.userSelect="",document.body.style.cursor=""}},[$,be]);const[E,O]=w.useState(""),[q,B]=w.useState("all"),[re,z]=w.useState(""),[V,te]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[Q,ne]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),ie=Bne();w.useEffect(()=>{const $e=l.get("folder");if($e){const dt=parseInt($e,10);h(dt)}},[l]);const{data:me}=Je({queryKey:["settings"],queryFn:()=>ge.getSettings()}),{data:fe,isLoading:oe}=Je({queryKey:["library-folders"],queryFn:()=>ge.getLibraryFolders()}),{data:I,isLoading:F}=Je({queryKey:["library-files",d],queryFn:()=>ge.getLibraryFiles(d,d===null)}),{data:J}=Je({queryKey:["library-stats"],queryFn:()=>ge.getLibraryStats()}),{data:xe}=Je({queryKey:["users"],queryFn:()=>ge.getUsers()}),he=w.useMemo(()=>{if(!I)return[];const $e=new Set(I.map(dt=>dt.file_type));return Array.from($e).sort()},[I]),le=w.useMemo(()=>{if(!I)return[];let $e=[...I];if(E.trim()){const dt=E.toLowerCase();$e=$e.filter(gt=>gt.filename.toLowerCase().includes(dt)||gt.print_name&&gt.print_name.toLowerCase().includes(dt))}if(q!=="all"&&($e=$e.filter(dt=>dt.file_type===q)),re.trim()){const dt=re.toLowerCase();$e=$e.filter(gt=>gt.created_by_username&&gt.created_by_username.toLowerCase().includes(dt))}return $e.sort((dt,gt)=>{let Lt=0;switch(V){case"name":Lt=(dt.print_name||dt.filename).localeCompare(gt.print_name||gt.filename);break;case"date":Lt=(Jn(dt.created_at)?.getTime()??0)-(Jn(gt.created_at)?.getTime()??0);break;case"size":Lt=dt.file_size-gt.file_size;break;case"type":Lt=dt.file_type.localeCompare(gt.file_type);break;case"prints":Lt=dt.print_count-gt.print_count;break}return Q==="asc"?Lt:-Lt}),$e},[I,E,q,re,V,Q]),Ce=w.useMemo(()=>{if(!J||!me)return!1;const $e=(me.library_disk_warning_gb||5)*1024*1024*1024;return J.disk_free_bytes<$e},[J,me]),Ne=ut({mutationFn:$e=>ge.createLibraryFolder($e),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),v(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:$e=>n($e.message,"error")}),Ue=ut({mutationFn:$e=>ge.deleteLibraryFolder($e),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),d===j?.id&&h(null),k(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:$e=>{k(null),n($e.message,"error")}}),He=ut({mutationFn:$e=>ge.deleteLibraryFile($e),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p($e=>$e.filter(dt=>dt!==j?.id)),k(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:$e=>{k(null),n($e.message,"error")}}),de=ut({mutationFn:$e=>ge.bulkDeleteLibrary($e,[]),onSuccess:($e,dt)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:dt.length}),"success"),p([]),k(null)},onError:$e=>{k(null),n($e.message,"error")}}),we=ut({mutationFn:({fileIds:$e,folderId:dt})=>ge.moveLibraryFiles($e,dt),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),y(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:$e=>n($e.message,"error")}),ke=ut({mutationFn:({id:$e,data:dt})=>ge.updateLibraryFolder($e,dt),onSuccess:($e,dt)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),C(null);const gt=dt.data.project_id===0&&dt.data.archive_id===0;n(t(gt?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:$e=>n($e.message,"error")}),_e=ut({mutationFn:({id:$e,filename:dt})=>ge.updateLibraryFile($e,{filename:dt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),ee(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:$e=>{ee(null),n($e.message,"error")}}),Ae=ut({mutationFn:({id:$e,name:dt})=>ge.updateLibraryFolder($e,{name:dt}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),ee(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:$e=>{ee(null),n($e.message,"error")}}),Ve=ut({mutationFn:()=>ge.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:$e=>{if(e.invalidateQueries({queryKey:["library-files"]}),$e.succeeded>0){const dt=Date.now(),gt={};$e.results.forEach(Lt=>{Lt.success&&(gt[Lt.file_id]=dt)}),Y(Lt=>({...Lt,...gt}))}$e.succeeded>0&&$e.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:$e.succeeded}),"success"):$e.succeeded>0&&$e.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:$e.succeeded,failed:$e.failed}),"success"):$e.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:$e.results[0]?.error||"Unknown error"}),"error")},onError:$e=>n($e.message,"error")}),Te=ut({mutationFn:$e=>ge.batchGenerateStlThumbnails({file_ids:[$e]}),onSuccess:$e=>{if(e.invalidateQueries({queryKey:["library-files"]}),$e.succeeded>0){const dt=$e.results[0]?.file_id;dt&&Y(gt=>({...gt,[dt]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:$e.results[0]?.error||"Unknown error"}),"error")},onError:$e=>n($e.message,"error")}),Ke=w.useCallback($e=>{const dt=$e.toLowerCase();return dt.endsWith(".gcode")||dt.includes(".gcode.")},[]),je=w.useMemo(()=>I?I.filter($e=>f.includes($e.id)&&Ke($e.filename)):[],[I,f,Ke]),qe=w.useCallback($e=>{p(dt=>dt.includes($e)?dt.filter(gt=>gt!==$e):[...dt,$e])},[]),Re=w.useCallback(()=>{le.length>0&&p(le.map($e=>$e.id))},[le]),Pe=w.useCallback(()=>{p([])},[]),Be=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},We=$e=>{ge.downloadLibraryFile($e).catch(dt=>{console.error("Library file download failed:",dt)})},ct=()=>{j&&(j.type==="file"?He.mutate(j.id):j.type==="folder"?Ue.mutate(j.id):j.type==="bulk"&&de.mutate(f))},St=Ue.isPending||He.isPending||de.isPending,Mt=$e=>{Z($e),localStorage.setItem("library-view-mode",$e)},yt=oe||F;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(nc,{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:()=>Mt("grid"),className:`p-1.5 rounded transition-colors ${ye==="grid"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:a.jsx(wv,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>Mt("list"),className:`p-1.5 rounded transition-colors ${ye==="list"?"bg-bambu-dark-secondary text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:a.jsx(tC,{className:"w-4 h-4"})})]}),a.jsxs(Oe,{variant:"secondary",onClick:()=>Ve.mutate(),disabled:Ve.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[Ve.isPending?a.jsx(lt,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(nd,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),a.jsxs(Oe,{variant:"secondary",onClick:()=>v(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[a.jsx(Kme,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),a.jsxs(Oe,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(Ia,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),Ce&&J&&me&&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(Mn,{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:ml(J.disk_free_bytes),total:ml(J.disk_total_bytes),threshold:me.library_disk_warning_gb})})]})]}),J&&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(Zk,{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:J.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(nc,{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:J.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Jb,{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:ml(J.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 ${Ce?"text-amber-500":"text-white"}`,children:ml(J.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:$e=>h($e.target.value?parseInt($e.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")]}),fe&&(()=>{const $e=(dt,gt=0)=>{const Lt=[];for(const en of dt)Lt.push({id:en.id,name:en.name,fileCount:en.file_count,depth:gt}),en.children.length>0&&Lt.push(...$e(en.children,gt+1));return Lt};return $e(fe).map(dt=>a.jsxs("option",{value:dt.id,children:["│ ".repeat(dt.depth),"📂 ",dt.name," ",dt.fileCount>0?`(${dt.fileCount})`:""]},dt.id))})()]})}),a.jsxs("div",{ref:T,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:`${be}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 ${$?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:$e=>{$e.preventDefault(),K(!0)},onDoubleClick:()=>{Ee(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 ${$?"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 $e=!ue;pe($e),localStorage.setItem("library-wrap-folders",String($e))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${ue?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(ue?"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(yf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),fe?.map($e=>a.jsx(wse,{folder:$e,selectedFolderId:d,onSelect:h,onDelete:dt=>k({type:"folder",id:dt}),onLink:C,onRename:dt=>ee({type:"folder",id:dt.id,name:dt.name}),wrapNames:ue,hasPermission:r,t},$e.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[I&&I.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(Er,{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:E,onChange:$e=>O($e.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(Jk,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:q,onChange:$e=>B($e.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")}),he.map($e=>a.jsx("option",{value:$e,children:$e.toUpperCase()},$e))]})]}),o&&a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:t("fileManager.filterByUser",{defaultValue:"Filter by user"}),value:re,onChange:$e=>z($e.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 ${re?"pr-7":""}`,style:re?{WebkitAppearance:"none",MozAppearance:"textfield"}:void 0}),re&&a.jsx("button",{onClick:()=>z(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10",children:a.jsx(Ut,{className:"w-3 h-3"})}),a.jsx("datalist",{id:"usernames-list",children:xe?.map($e=>a.jsx("option",{value:$e.username},$e.id))})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:V,onChange:$e=>{const dt=$e.target.value;te(dt),localStorage.setItem("library-sort-field",dt)},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:()=>ne($e=>{const dt=$e==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",dt),dt}),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(hhe,{className:"w-4 h-4 text-white"}):a.jsx(ihe,{className:"w-4 h-4 text-white"})})]}),(E||q!=="all"||re)&&a.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:le.length,total:I.length})})]}),le.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:[f.length===le.length&&f.length>0?a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:Pe,children:[a.jsx(_l,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:Re,children:[a.jsx(uo,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),f.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:f.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:[je.length===1&&a.jsxs(Oe,{variant:"primary",size:"sm",onClick:()=>G(je[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[a.jsx(lo,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),je.length===1&&a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>W(je[0]),disabled:!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[a.jsx(Xn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.schedulePrint")})]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[a.jsx(rpe,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),a.jsxs(Oe,{variant:"danger",size:"sm",onClick:()=>{f.length===1?k({type:"file",id:f[0]}):k({type:"bulk",id:0,count:f.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[a.jsx(Xt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),a.jsxs(Oe,{variant:"secondary",size:"sm",onClick:Pe,children:[a.jsx(Ut,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),yt?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")})]})}):I?.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(yf,{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(Oe,{onClick:()=>N(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(nr,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):le.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(Er,{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(Oe,{variant:"secondary",onClick:()=>{O(""),B("all")},children:t("fileManager.clearFilters")})]}):ye==="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:le.map($e=>a.jsx($Je,{file:$e,isSelected:f.includes($e.id),isMobile:ie,t,onSelect:qe,onDelete:dt=>k({type:"file",id:dt}),onDownload:We,onAddToQueue:dt=>{const gt=I?.find(Lt=>Lt.id===dt);gt&&W(gt)},onPrint:M,onPreview3d:ce,onRename:dt=>ee({type:"file",id:dt.id,name:dt.filename}),onGenerateThumbnail:dt=>Te.mutate(dt.id),thumbnailVersion:ae[$e.id],hasPermission:r,canModify:s,authEnabled:o},$e.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",{})]}),le.map($e=>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 ${f.includes($e.id)?"bg-bambu-green/10":""}`,onClick:()=>qe($e.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${f.includes($e.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:f.includes($e.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:$e.thumbnail_path?a.jsx("img",{src:`${ge.getLibraryFileThumbnailUrl($e.id)}${ae[$e.id]?`?v=${ae[$e.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(yf,{className:"w-5 h-5 text-bambu-gray/50"})})}),$e.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:`${ge.getLibraryFileThumbnailUrl($e.id)}${ae[$e.id]?`?v=${ae[$e.id]}`:""}`,alt:$e.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:$e.print_name||$e.filename})})]}),o&&a.jsx("div",{className:"text-sm text-bambu-gray flex items-center gap-1",children:$e.created_by_username?a.jsxs(a.Fragment,{children:[a.jsx(id,{className:"w-3 h-3"}),a.jsx("span",{className:"truncate",children:$e.created_by_username})]}):"-"}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${$e.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":$e.file_type==="gcode"?"bg-blue-500/20 text-blue-400":$e.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:$e.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:ml($e.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:$e.print_count>0?`${$e.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:dt=>dt.stopPropagation(),children:[xF($e.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>r("printers:control")&&M($e),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")&&W($e)},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(Xn,{className:"w-4 h-4"})})]}),($e.file_type==="3mf"||$e.file_type==="gcode"||$e.file_type==="stl")&&a.jsx("button",{onClick:()=>r("library:read")&&ce($e),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(ni,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("library:read")&&We($e.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(ba,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","update",$e.created_by_id)&&ee({type:"file",id:$e.id,name:$e.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",$e.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",$e.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",$e.created_by_id),children:a.jsx(Ka,{className:"w-4 h-4"})}),$e.file_type==="stl"&&a.jsx("button",{onClick:()=>s("library","update",$e.created_by_id)&&Te.mutate($e.id),className:`p-1.5 rounded transition-colors ${s("library","update",$e.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",$e.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:Te.isPending||!s("library","update",$e.created_by_id),children:a.jsx(nd,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","delete",$e.created_by_id)&&k({type:"file",id:$e.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",$e.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",$e.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",$e.created_by_id),children:a.jsx(Xt,{className:"w-4 h-4"})})]})]},$e.id))]})})]})]}),x&&a.jsx(IJe,{parentId:d,onClose:()=>v(!1),onSave:$e=>Ne.mutate($e),isLoading:Ne.isPending,t}),g&&fe&&a.jsx(UJe,{folders:fe,selectedFiles:f,currentFolderId:d,onClose:()=>y(!1),onMove:$e=>we.mutate({fileIds:f,folderId:$e}),isLoading:we.isPending,t}),_&&a.jsx(HJe,{folderId:d,onClose:()=>N(!1),onUploadComplete:Be,t}),A&&a.jsx(BJe,{folder:A,onClose:()=>C(null),onLink:$e=>ke.mutate({id:A.id,data:$e}),isLoading:ke.isPending,t}),j&&a.jsx(Sn,{title:j.type==="folder"?t("fileManager.deleteFolder"):j.type==="bulk"?t("fileManager.deleteFilesCount",{count:j.count}):t("fileManager.deleteFile"),message:j.type==="folder"?t("fileManager.deleteFolderConfirm"):j.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:j.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:St,loadingText:t("fileManager.deleting"),onConfirm:ct,onCancel:()=>k(null)}),R&&a.jsx(Zu,{mode:"reprint",libraryFileId:R.id,archiveName:R.print_name||R.filename,onClose:()=>M(null),onSuccess:()=>{M(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),D&&a.jsx(Zu,{mode:"reprint",libraryFileId:D.id,archiveName:D.print_name||D.filename,onClose:()=>G(null),onSuccess:()=>{G(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),U&&a.jsx(Zu,{mode:"add-to-queue",libraryFileId:U.id,archiveName:U.print_name||U.filename,onClose:()=>W(null),onSuccess:()=>{W(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]})}}),se&&a.jsx(AO,{libraryFileId:se.id,title:se.print_name||se.filename,fileType:se.file_type,onClose:()=>ce(null)}),L&&a.jsx(zJe,{type:L.type,currentName:L.name,onClose:()=>ee(null),onSave:$e=>{L.type==="file"?_e.mutate({id:L.id,filename:$e}):Ae.mutate({id:L.id,name:$e})},isLoading:_e.isPending||Ae.isPending,t})]})}const qE=5,qJe=2e3,GJe=3e4,WJe=5e3;function KJe(){const{t}=Et(),e=Qt(),{showToast:n}=dn(),{hasPermission:r}=Rr(),{printerId:i}=bv(),s=parseInt(i||"0",10),[o,l]=w.useState("stream"),[c,u]=w.useState(!1),[d,h]=w.useState(!1),[f,p]=w.useState(!0),[x,v]=w.useState(Date.now()),[g,y]=w.useState(!1),[_,N]=w.useState(!1),[A,C]=w.useState(0),[j,k]=w.useState(!1),[R,M]=w.useState(0),[D,G]=w.useState(1),[U,W]=w.useState({x:0,y:0}),[L,ee]=w.useState(!1),[ae,Y]=w.useState({x:0,y:0}),[se,ce]=w.useState(null),[ye,Z]=w.useState(null),ue=w.useRef(null),pe=w.useRef(null),be=w.useRef(null),Ee=w.useRef(null),$=w.useRef(null),{data:K}=Je({queryKey:["printer",s],queryFn:()=>ge.getPrinter(s),enabled:s>0}),{data:T}=Je({queryKey:["printerStatus",s],queryFn:()=>ge.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),E=ut({mutationFn:we=>ge.setChamberLight(s,we),onMutate:async we=>{await e.cancelQueries({queryKey:["printerStatus",s]});const ke=e.getQueryData(["printerStatus",s]);return e.setQueryData(["printerStatus",s],_e=>({..._e,chamber_light:we})),{previousStatus:ke}},onSuccess:(we,ke)=>{n(`Chamber light ${ke?"on":"off"}`)},onError:(we,ke,_e)=>{_e?.previousStatus&&e.setQueryData(["printerStatus",s],_e.previousStatus),n(we.message||t("printers.toast.failedToControlChamberLight"),"error")}}),O=(T?.state==="RUNNING"||T?.state==="PAUSE")&&(T?.printable_objects_count??0)>=2;w.useEffect(()=>(K&&(document.title=`${K.name} - Camera`),()=>{document.title="Bambuddy"}),[K]);const q=w.useRef(!1);w.useEffect(()=>{const we=`/api/v1/printers/${s}/camera/stop`;q.current=!1;const ke=()=>{if(s>0&&!q.current){q.current=!0;const Ve={},Te=sd();Te&&(Ve.Authorization=`Bearer ${Te}`),fetch(we,{method:"POST",keepalive:!0,headers:Ve}).catch(()=>{})}},_e=()=>{ke()};window.addEventListener("beforeunload",_e);const Ae=ue.current;return()=>{window.removeEventListener("beforeunload",_e),Ae&&(Ae.src=""),ke()}},[s]),w.useEffect(()=>{if(f&&!g){const ke=setTimeout(()=>{p(!1)},o==="stream"?3e3:2e4);return()=>clearTimeout(ke)}},[o,f,x,g]),w.useEffect(()=>{const we=()=>{const ke=!!document.fullscreenElement;N(ke),G(1),W({x:0,y:0}),o==="stream"&&!g&&(ue.current&&(ue.current.src=""),setTimeout(()=>{p(!0),v(Date.now())},200))};return document.addEventListener("fullscreenchange",we),()=>document.removeEventListener("fullscreenchange",we)},[o,g]),w.useEffect(()=>{let we;const ke=()=>{clearTimeout(we),we=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",ke),()=>{clearTimeout(we),window.removeEventListener("resize",ke)}},[]),w.useEffect(()=>()=>{be.current&&clearTimeout(be.current),Ee.current&&clearInterval(Ee.current),$.current&&clearInterval($.current)},[]);const B=w.useCallback(()=>{if(A>=qE){k(!1),h(!0);return}const we=Math.min(qJe*Math.pow(2,A),GJe);k(!0),M(Math.ceil(we/1e3)),Ee.current=setInterval(()=>{M(ke=>ke<=1?(Ee.current&&clearInterval(Ee.current),0):ke-1)},1e3),be.current=setTimeout(()=>{C(ke=>ke+1),k(!1),p(!0),h(!1),ue.current&&(ue.current.src=""),v(Date.now())},we)},[A]);w.useEffect(()=>{if(o!=="stream"||f||j||g){$.current&&(clearInterval($.current),$.current=null);return}return $.current=setInterval(async()=>{try{const we=await ge.getCameraStatus(s);(we.stalled||!we.active&&!d)&&(console.log(`Stream issue detected: stalled=${we.stalled}, active=${we.active}, reconnecting...`),$.current&&(clearInterval($.current),$.current=null),p(!1),B())}catch{}},WJe),()=>{$.current&&(clearInterval($.current),$.current=null)}},[o,f,d,j,g,s,B]);const re=()=>{p(!1),o==="stream"&&A<qE?B():h(!0)},z=()=>{if(p(!1),h(!1),C(0),k(!1),be.current&&clearTimeout(be.current),Ee.current&&clearInterval(Ee.current),ue.current&&!localStorage.getItem("cameraWindowState")){const we=ue.current,ke=we.naturalWidth,_e=we.naturalHeight;if(ke>0&&_e>0){const Te=window.outerWidth-window.innerWidth,Ke=window.outerHeight-window.innerHeight,je=ke+16+Te,qe=_e+45+16+Ke;try{window.resizeTo(je,qe)}catch{}}}},V=()=>{if(s>0){const we={},ke=sd();ke&&(we.Authorization=`Bearer ${ke}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:"POST",headers:we}).catch(()=>{})}},te=we=>{o===we||g||(y(!0),p(!0),h(!1),C(0),k(!1),G(1),W({x:0,y:0}),be.current&&clearTimeout(be.current),Ee.current&&clearInterval(Ee.current),ue.current&&(ue.current.src=""),o==="stream"&&V(),setTimeout(()=>{l(we),v(Date.now()),y(!1)},100))},Q=()=>{g||(y(!0),p(!0),h(!1),C(0),k(!1),be.current&&clearTimeout(be.current),Ee.current&&clearInterval(Ee.current),ue.current&&(ue.current.src=""),o==="stream"&&V(),setTimeout(()=>{v(Date.now()),y(!1)},100))},ne=()=>{pe.current&&(document.fullscreenElement?document.exitFullscreen():pe.current.requestFullscreen())},ie=()=>{G(we=>Math.min(we+.5,4))},me=()=>{G(we=>{const ke=Math.max(we-.5,1);return ke===1&&W({x:0,y:0}),ke})},fe=we=>{we.preventDefault(),we.deltaY<0?ie():me()},oe=we=>{D>1&&(we.preventDefault(),ee(!0),Y({x:we.clientX-U.x,y:we.clientY-U.y}))},I=w.useCallback(()=>{if(!pe.current)return{x:300,y:200};const we=pe.current.getBoundingClientRect(),ke=we.width*(D-1)/2,_e=we.height*(D-1)/2;return{x:Math.max(50,ke),y:Math.max(50,_e)}},[D]),F=we=>{if(L&&D>1){const ke=we.clientX-ae.x,_e=we.clientY-ae.y,Ae=I();W({x:Math.max(-Ae.x,Math.min(Ae.x,ke)),y:Math.max(-Ae.y,Math.min(Ae.y,_e))})}},J=()=>{ee(!1)},xe=we=>{if(we.length<2)return 0;const ke=we[0].clientX-we[1].clientX,_e=we[0].clientY-we[1].clientY;return Math.sqrt(ke*ke+_e*_e)},he=we=>we.length<2?{x:we[0].clientX,y:we[0].clientY}:{x:(we[0].clientX+we[1].clientX)/2,y:(we[0].clientY+we[1].clientY)/2},le=we=>{we.touches.length===2?(we.preventDefault(),ce(xe(we.touches)),Z(he(we.touches))):we.touches.length===1&&D>1&&(we.preventDefault(),ee(!0),Y({x:we.touches[0].clientX-U.x,y:we.touches[0].clientY-U.y}))},Ce=we=>{if(we.touches.length===2&&se!==null){we.preventDefault();const ke=xe(we.touches),_e=ke/se;G(Ve=>{const Te=Math.max(1,Math.min(4,Ve*_e));return Te===1&&W({x:0,y:0}),Te}),ce(ke);const Ae=he(we.touches);if(ye){const Ve=I();W(Te=>({x:Math.max(-Ve.x,Math.min(Ve.x,Te.x+(Ae.x-ye.x))),y:Math.max(-Ve.y,Math.min(Ve.y,Te.y+(Ae.y-ye.y)))}))}Z(Ae)}else if(we.touches.length===1&&L&&D>1){we.preventDefault();const ke=we.touches[0].clientX-ae.x,_e=we.touches[0].clientY-ae.y,Ae=I();W({x:Math.max(-Ae.x,Math.min(Ae.x,ke)),y:Math.max(-Ae.y,Math.min(Ae.y,_e))})}},Ne=we=>{we.touches.length<2&&(ce(null),Z(null)),we.touches.length===0&&ee(!1)},Ue=()=>{G(1),W({x:0,y:0})},He=g?"":o==="stream"?`/api/v1/printers/${s}/camera/stream?fps=15&t=${x}`:`/api/v1/printers/${s}/camera/snapshot?t=${x}`,de=f||g||j;return s?a.jsxs("div",{ref:pe,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(xb,{className:"w-4 h-4"}),K?.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:()=>te("stream"),disabled:de,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:()=>te("snapshot"),disabled:de,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:()=>E.mutate(!T?.chamber_light),disabled:!T?.connected||E.isPending||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${T?.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(w4,{on:T?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>u(!0),disabled:!O||!r("printers:control"),className:`p-1.5 rounded disabled:opacity-50 ${O&&r("printers:control")?"hover:bg-bambu-dark-tertiary":""}`,title:r("printers:control")?t(O?"printers.skipObjects.tooltip":"printers.skipObjects.onlyWhilePrinting"):t("printers.permission.noControl"),children:a.jsx(wC,{className:"w-4 h-4 text-bambu-gray"})}),a.jsx("button",{onClick:Q,disabled:de,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(o==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:a.jsx(wr,{className:`w-4 h-4 text-bambu-gray ${de?"animate-spin":""}`})}),a.jsx("button",{onClick:ne,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(_?"camera.exitFullscreen":"camera.fullscreen"),children:_?a.jsx(BY,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(qfe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:fe,onMouseMove:F,onMouseUp:J,onMouseLeave:J,onTouchStart:le,onTouchMove:Ce,onTouchEnd:Ne,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(f||g)&&!j&&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(wr,{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")})]})}),j&&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(Xh,{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:A+1,max:qE})}),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&&!j&&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(Mn,{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:ue,src:He,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${D}) translate(${U.x/D}px, ${U.y/D}px)`,cursor:D>1?L?"grabbing":"grab":"default"},onError:He?re:void 0,onLoad:He?z:void 0,onMouseDown:oe,draggable:!1},x),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:me,disabled:D<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:a.jsx(qF,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:Ue,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(D*100),"%"]}),a.jsx("button",{onClick:ie,disabled:D>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:a.jsx(VF,{className:"w-4 h-4 text-white"})})]})]})}),a.jsx(S4,{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 YJe(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 XJe(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 QJe(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"};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 ZJe(){const{printerId:t}=bv(),[e]=MF(),{t:n}=Et(),r=Qt(),i=parseInt(t||"0",10),[s,o]=w.useState(Date.now()),l=w.useMemo(()=>YJe(e),[e]),c=QJe(l.size),{data:u}=Je({queryKey:["printer",i],queryFn:()=>ge.getPrinter(i),enabled:i>0}),{data:d}=Je({queryKey:["printerStatus",i],queryFn:()=>ge.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3}),{data:h}=Je({queryKey:["settings"],queryFn:ge.getSettings}),f=h?.time_format||"system";w.useEffect(()=>{if(!i)return;const _=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,N=new WebSocket(_);return N.onmessage=A=>{try{const C=JSON.parse(A.data);C.type==="printer_status"&&C.printer_id===i&&r.setQueryData(["printerStatus",i],C.status)}catch{}},N.onerror=()=>{},()=>{N.close()}},[i,r]),w.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const p=()=>{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 x=d.state==="RUNNING"||d.state==="PAUSE",v=d.progress||0,g=`/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:g,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:p},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:XJe(d,n)}),l.showProgress&&x&&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(v),"%"]})]}),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:`${v}%`}})})]}),x&&(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(Ga,{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(zu,{className:c.icon}),a.jsx("span",{className:`${c.text} text-white`,children:js(d.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(Xn,{className:c.icon}),a.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",GF(d.remaining_time,f,n)]})]})]})]}),!x&&a.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function JJe(){const{t}=Et(),{id:e}=bv(),{mode:n}=lp(),{data:r,isLoading:i,error:s}=Je({queryKey:["external-link",e],queryFn:()=>ge.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(Mn,{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"})}function kK(){const{id:t}=bv(),e=jl(),n=Qt(),{t:r}=Et(),{showToast:i}=dn(),s=!!t,[o,l]=w.useState(""),[c,u]=w.useState(""),[d,h]=w.useState([]),[f,p]=w.useState(""),[x,v]=w.useState(!1),{data:g,isLoading:y}=Je({queryKey:["group",t],queryFn:()=>ge.getGroup(Number(t)),enabled:s}),{data:_,isLoading:N}=Je({queryKey:["permissions"],queryFn:()=>ge.getPermissions()});s&&g&&!x&&(l(g.name),u(g.description||""),h(g.permissions),v(!0));const A=ut({mutationFn:Y=>ge.createGroup(Y),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),i(r("groups.toast.created")),e("/settings?tab=users")},onError:Y=>{i(Y.message,"error")}}),C=ut({mutationFn:Y=>ge.updateGroup(Number(t),Y),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),i(r("groups.toast.updated")),e("/settings?tab=users")},onError:Y=>{i(Y.message,"error")}}),j=A.isPending||C.isPending,k=()=>{if(!o.trim()){i(r("groups.toast.enterGroupName"),"error");return}s?C.mutate({name:o!==g?.name?o:void 0,description:c,permissions:d}):A.mutate({name:o,description:c||void 0,permissions:d})},R=Y=>{h(se=>se.includes(Y)?se.filter(ce=>ce!==Y):[...se,Y])},M=(Y,se)=>{const ce=Y.permissions.map(ye=>ye.value);h(ye=>{const Z=ye.filter(ue=>!ce.includes(ue));return se?[...Z,...ce]:Z})},D=Y=>Y.permissions.every(se=>d.includes(se.value)),G=Y=>{const se=Y.permissions.filter(ce=>d.includes(ce.value)).length;return se>0&&se<Y.permissions.length},U=()=>{_&&h(_.all_permissions)},W=()=>{h([])},L=f.toLowerCase(),ee=w.useMemo(()=>_?L?_.categories.map(Y=>({...Y,permissions:Y.permissions.filter(se=>se.label.toLowerCase().includes(L))})).filter(Y=>Y.permissions.length>0):_.categories:[],[_,L]),ae=_?.all_permissions.length??0;return y||N?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 max-w-5xl mx-auto",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>e("/settings?tab=users"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:a.jsx(EY,{className:"w-5 h-5"})}),a.jsx("h1",{className:"text-xl font-bold text-white",children:r(s?"groups.editor.title":"groups.editor.createTitle")})]}),s&&g?.is_system&&a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20 text-yellow-400 text-sm",children:[a.jsx(Mn,{className:"w-4 h-4 shrink-0"}),r("groups.form.systemGroupWarning")]}),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:r("groups.form.groupName")}),a.jsx("input",{type:"text",value:o,onChange:Y=>l(Y.target.value),disabled:s&&g?.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:r("groups.form.groupNamePlaceholder")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:r("groups.form.description")}),a.jsx("input",{type:"text",value:c,onChange:Y=>u(Y.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:r("groups.form.descriptionPlaceholder")})]})]}),a.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:[r("groups.editor.permissionsSelected",{count:d.length})," / ",ae]}),a.jsx(Oe,{size:"sm",variant:"ghost",onClick:U,children:r("groups.editor.selectAll")}),a.jsx(Oe,{size:"sm",variant:"ghost",onClick:W,children:r("groups.editor.clearAll")})]}),a.jsxs("div",{className:"relative",children:[a.jsx(Er,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray"}),a.jsx("input",{type:"text",value:f,onChange:Y=>p(Y.target.value),placeholder:r("groups.editor.search"),className:"pl-9 pr-4 py-2 text-sm 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 w-64"})]})]}),ee.length===0?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:r("groups.editor.noResults")}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:ee.map(Y=>{const se=_.categories.find(pe=>pe.name===Y.name),ce=se.permissions.filter(pe=>d.includes(pe.value)).length,ye=se.permissions.length,Z=D(se),ue=G(se);return a.jsxs(Ct,{children:[a.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 py-3 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary rounded-t-xl",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("button",{type:"button",onClick:()=>M(se,!Z),className:`w-5 h-5 rounded border flex items-center justify-center transition-colors shrink-0 ${Z?"bg-bambu-green border-bambu-green":ue?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:[Z&&a.jsx(Zr,{className:"w-3 h-3 text-white"}),ue&&!Z&&a.jsx(E1,{className:"w-3 h-3 text-white"})]}),a.jsx(v3,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-white font-medium text-sm",children:Y.name})]}),a.jsxs("span",{className:"text-xs text-bambu-gray tabular-nums",children:[ce,"/",ye]})]}),a.jsx("div",{className:"p-3 space-y-1",children:Y.permissions.map(pe=>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:d.includes(pe.value),onChange:()=>R(pe.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:pe.label})]},pe.value))})]},Y.name)})}),a.jsx("div",{className:"h-16"}),a.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-20 px-6 py-3 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-center justify-center gap-3",children:[a.jsx(Oe,{variant:"secondary",onClick:()=>e("/settings?tab=users"),children:r("common.cancel")}),a.jsx(Oe,{onClick:k,disabled:j||!o.trim(),children:j?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),r("common.saving")]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),r("common.save")]})})]})]})}const CK={material:"",subtype:"",brand:"",color_name:"",rgba:"808080FF",label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:"",note:"",cost_per_kg:null};function eet(t,e=!1){const n={};return e?(t.material||(n.material="Material is required"),{isValid:Object.keys(n).length===0,errors:n}):(t.slicer_filament||(n.slicer_filament="Slicer preset is required"),t.material||(n.material="Material is required"),t.brand||(n.brand="Brand is required"),t.subtype||(n.subtype="Subtype is required"),{isValid:Object.keys(n).length===0,errors:n})}const tet=["PLA","PETG","ABS","TPU","ASA","PC","PA","PVA","HIPS","PA-CF","PETG-CF","PLA-CF"],net=["Bambu","PolyLite","PolyTerra","eSUN","Overture","Fiberon","SUNLU","Inland","Hatchbox","Generic"],y0=["Basic","Matte","Silk","Tough","HF","High Flow","Engineering","Galaxy","Glow","Marble","Metal","Rainbow","Sparkle","Wood","Translucent","Transparent","Clear","Lite","Pro","Plus","Max","Super","Ultra","Flex","Soft","Hard","Strong","Impact","Heat Resistant","UV Resistant","ESD","Conductive","Magnetic","Gradient","Dual Color","Tri Color","Multicolor"],Sse=[{name:"Black",hex:"000000"},{name:"White",hex:"FFFFFF"},{name:"Gray",hex:"808080"},{name:"Red",hex:"FF0000"},{name:"Orange",hex:"FFA500"},{name:"Yellow",hex:"FFFF00"},{name:"Green",hex:"00AE42"},{name:"Blue",hex:"0066FF"},{name:"Purple",hex:"8B00FF"},{name:"Pink",hex:"FF69B4"},{name:"Brown",hex:"8B4513"},{name:"Silver",hex:"C0C0C0"}],ret=[{name:"Dark Red",hex:"8B0000"},{name:"Crimson",hex:"DC143C"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Dark Orange",hex:"FF8C00"},{name:"Peach",hex:"FFDAB9"},{name:"Gold",hex:"FFD700"},{name:"Khaki",hex:"F0E68C"},{name:"Lemon",hex:"FFF44F"},{name:"Lime",hex:"32CD32"},{name:"Forest Green",hex:"228B22"},{name:"Olive",hex:"808000"},{name:"Mint",hex:"98FF98"},{name:"Teal",hex:"008080"},{name:"Navy",hex:"000080"},{name:"Sky Blue",hex:"87CEEB"},{name:"Royal Blue",hex:"4169E1"},{name:"Cyan",hex:"00FFFF"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Magenta",hex:"FF00FF"},{name:"Indigo",hex:"4B0082"},{name:"Lavender",hex:"E6E6FA"},{name:"Plum",hex:"DDA0DD"},{name:"Hot Pink",hex:"FF69B4"},{name:"Rose",hex:"FF007F"},{name:"Blush",hex:"FFB6C1"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Beige",hex:"F5F5DC"},{name:"Maroon",hex:"800000"},{name:"Dark Gray",hex:"404040"},{name:"Light Gray",hex:"D3D3D3"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Bambu Green",hex:"00AE42"},{name:"Jade White",hex:"E8E8E8"},{name:"Titan Gray",hex:"5A5A5A"}],AK=[...Sse,...ret],_se="bambuddy-recent-colors",aet=8,iet=[{code:"GFL00",name:"Bambu PLA Basic",displayName:"Bambu PLA Basic",isCustom:!1,allCodes:["GFL00"]},{code:"GFL01",name:"Bambu PLA Matte",displayName:"Bambu PLA Matte",isCustom:!1,allCodes:["GFL01"]},{code:"GFL05",name:"Generic PLA",displayName:"Generic PLA",isCustom:!1,allCodes:["GFL05"]},{code:"GFG00",name:"Bambu PETG Basic",displayName:"Bambu PETG Basic",isCustom:!1,allCodes:["GFG00"]},{code:"GFG05",name:"Generic PETG",displayName:"Generic PETG",isCustom:!1,allCodes:["GFG05"]},{code:"GFB00",name:"Bambu ABS Basic",displayName:"Bambu ABS Basic",isCustom:!1,allCodes:["GFB00"]},{code:"GFB05",name:"Generic ABS",displayName:"Generic ABS",isCustom:!1,allCodes:["GFB05"]},{code:"GFA00",name:"Bambu ASA Basic",displayName:"Bambu ASA Basic",isCustom:!1,allCodes:["GFA00"]},{code:"GFU00",name:"Bambu TPU 95A",displayName:"Bambu TPU 95A",isCustom:!1,allCodes:["GFU00"]},{code:"GFU05",name:"Generic TPU",displayName:"Generic TPU",isCustom:!1,allCodes:["GFU05"]},{code:"GFC00",name:"Bambu PC Basic",displayName:"Bambu PC Basic",isCustom:!1,allCodes:["GFC00"]},{code:"GFN00",name:"Bambu PA Basic",displayName:"Bambu PA Basic",isCustom:!1,allCodes:["GFN00"]},{code:"GFN05",name:"Generic PA",displayName:"Generic PA",isCustom:!1,allCodes:["GFN05"]},{code:"GFS00",name:"Bambu PLA-CF",displayName:"Bambu PLA-CF",isCustom:!1,allCodes:["GFS00"]},{code:"GFT00",name:"Bambu PETG-CF",displayName:"Bambu PETG-CF",isCustom:!1,allCodes:["GFT00"]},{code:"GFNC0",name:"Bambu PA-CF",displayName:"Bambu PA-CF",isCustom:!1,allCodes:["GFNC0"]},{code:"GFV00",name:"Bambu PVA",displayName:"Bambu PVA",isCustom:!1,allCodes:["GFV00"]}];function Wb(t){let e=t.replace(/@.*$/,"").trim();e=e.replace(/\(Custom\)/i,"").trim(),e=e.replace(/^[#*]+\s*/,"").trim();const n=["PLA-CF","PETG-CF","ABS-GF","ASA-CF","PA-CF","PAHT-CF","PA6-CF","PA6-GF","PPA-CF","PPA-GF","PET-CF","PPS-CF","PC-CF","PC-ABS","ABS-GF","PCTG","PETG","PLA","ABS","ASA","PC","PA","TPU","PVA","HIPS","BVOH","PPS","PEEK","PEI"];let r="",i=-1;for(const c of n){const u=e.toUpperCase().indexOf(c.toUpperCase());if(u!==-1){r=c,i=u;break}}let s="";i>0&&(s=e.substring(0,i).trim(),s=s.replace(/[-_\s]+$/,""));let o="";i!==-1&&r&&(o=e.substring(i+r.length).trim(),o=o.replace(/^[-_\s]+/,""));let l="";for(const c of y0)if(o.toLowerCase().includes(c.toLowerCase())){l=c;break}if(!l&&s)for(const c of y0){const u=new RegExp(`\\s+${c}$`,"i");if(u.test(s)){l=c,s=s.replace(u,"").trim();break}}return{brand:s,material:r,variant:l}}function set(t,e){const n=new Set(net);for(const r of t){const{brand:i}=Wb(r.name);i&&i.length>1&&n.add(i)}if(e)for(const r of e)if(r.filament_vendor&&r.filament_vendor.length>1)n.add(r.filament_vendor);else{const{brand:i}=Wb(r.name);i&&i.length>1&&n.add(i)}return Array.from(n).sort((r,i)=>r.localeCompare(i))}function oet(t){const e=t.filter(r=>r.preset_type==="filament");if(e.length===0)return[];const n=new Map;for(const r of e){const i=r.name.replace(/@.*$/,"").trim(),s=n.get(i);if(s)s.allCodes.push(String(r.id));else{const o=r.filament_type||String(r.id);n.set(i,{code:o,name:i,displayName:i,isCustom:!1,allCodes:[o]})}}return Array.from(n.values()).sort((r,i)=>r.displayName.localeCompare(i.displayName))}function cet(t,e,n){if(t.length>0){const r=[],i=new Map;for(const s of t)if(s.is_custom){const o=s.name.toUpperCase();(e.size===0||Array.from(e).some(c=>o.includes(c))||!o.includes("@"))&&r.push({code:s.setting_id,name:s.name,displayName:`${s.name} (Custom)`,isCustom:!0,allCodes:[s.setting_id]})}else{const o=s.name.replace(/@.*$/,"").trim(),l=i.get(o);l?l.allCodes.push(s.setting_id):i.set(o,{code:s.setting_id,name:o,displayName:o,isCustom:!1,allCodes:[s.setting_id]})}return[...r,...Array.from(i.values())].sort((s,o)=>s.displayName.localeCompare(o.displayName))}if(n&&n.length>0){const r=oet(n);if(r.length>0)return r}return iet}function uet(t,e){if(!t)return;let n=e.find(r=>r.code===t);if(n||(n=e.find(r=>r.allCodes.includes(t))),!n){const r=t.toLowerCase();n=e.find(i=>i.code.toLowerCase()===r||i.allCodes.some(s=>s.toLowerCase()===r))}return n}function det(){try{const t=localStorage.getItem(_se);if(t)return JSON.parse(t)}catch{}return[]}function het(t,e){const n=e.filter(i=>i.hex.toUpperCase()!==t.hex.toUpperCase()),r=[t,...n].slice(0,aet);try{localStorage.setItem(_se,JSON.stringify(r))}catch{}return r}function GE(t,e){if(!e.material)return!1;const r=(t.name||"").replace(/^High Flow[_\s]+/i,"").replace(/^Standard[_\s]+/i,"").replace(/^HF[_\s]+/i,"").replace(/^S[_\s]+/i,"").trim(),i=Wb(r);return!(!(i.material.toUpperCase()===e.material.toUpperCase())||e.brand&&!(i.brand.toLowerCase().includes(e.brand.toLowerCase())||e.brand.toLowerCase().includes(i.brand.toLowerCase()))||e.subtype&&!(i.variant.toLowerCase().includes(e.subtype.toLowerCase())||e.subtype.toLowerCase().includes(i.variant.toLowerCase())||r.toLowerCase().includes(e.subtype.toLowerCase())))}function met({formData:t,updateField:e,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:i,setPresetInputValue:s,selectedPresetOption:o,filamentOptions:l,availableBrands:c,availableMaterials:u,quickAdd:d,quantity:h,onQuantityChange:f,errors:p}){const{t:x}=Et(),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,A]=w.useState(!1),[C,j]=w.useState(!1),[k,R]=w.useState(""),[M,D]=w.useState(""),[G,U]=w.useState(""),[W,L]=w.useState(String(t.label_weight)),[ee,ae]=w.useState(!1),Y=w.useRef(null),se=w.useRef(null),ce=w.useRef(null),ye=w.useRef(null);w.useEffect(()=>{const $=K=>{Y.current&&!Y.current.contains(K.target)&&g(!1),ye.current&&!ye.current.contains(K.target)&&j(!1),se.current&&!se.current.contains(K.target)&&_(!1),ce.current&&!ce.current.contains(K.target)&&A(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const Z=w.useMemo(()=>{if(!i)return l;const $=i.toLowerCase();return l.filter(K=>K.displayName.toLowerCase().includes($)||K.code.toLowerCase().includes($))},[l,i]),ue=w.useMemo(()=>{if(!k)return c;const $=k.toLowerCase();return c.filter(T=>T.toLowerCase().includes($)).sort((T,E)=>{const O=T.toLowerCase()===$,q=E.toLowerCase()===$;return O&&!q?-1:!O&&q?1:T.localeCompare(E)})},[c,k]),pe=w.useMemo(()=>{if(!M)return y0;const $=M.toLowerCase();return y0.filter(K=>K.toLowerCase().includes($))},[M]),be=w.useMemo(()=>{if(!G)return u;const $=G.toLowerCase();return u.filter(T=>T.toLowerCase().includes($)).sort((T,E)=>{const O=T.toLowerCase()===$,q=E.toLowerCase()===$;return O&&!q?-1:!O&&q?1:T.localeCompare(E)})},[G,u]);w.useEffect(()=>{ee||L(String(t.label_weight))},[t.label_weight,ee]);const Ee=$=>{e("slicer_filament",$.code),s($.displayName),g(!1);const K=Wb($.name);K.material&&e("material",K.material),K.brand&&e("brand",K.brand),K.variant&&e("subtype",K.variant)};return a.jsxs("div",{className:"space-y-4",children:[!d&&a.jsx("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:r?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-3 h-3 animate-spin"})," ",x("inventory.loadingPresets")]}):n?a.jsxs(a.Fragment,{children:[a.jsx(Zb,{className:"w-3 h-3 text-bambu-green"})," ",x("inventory.cloudConnected")]}):a.jsxs(a.Fragment,{children:[a.jsx(rme,{className:"w-3 h-3"})," ",x("inventory.cloudNotConnected")]})}),!d&&a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.slicerPreset")," *"]}),a.jsxs("div",{className:"relative",ref:Y,children:[a.jsx(Er,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:x("inventory.searchPresets"),value:i,onChange:$=>{s($.target.value),g(!0)},onFocus:()=>{g(!0),s("")}}),v&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:Z.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noPresetsFound")}):Z.map($=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary truncate ${o?.code===$.code?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>Ee($),children:$.displayName},$.code))})]}),o&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-gray",children:[x("inventory.selectedPreset"),": ",a.jsx("span",{className:"font-mono text-bambu-green",children:o.code})]}),p?.slicer_filament&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.slicer_filament})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.material")," *"]}),a.jsxs("div",{className:"relative",ref:ye,children:[a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:x("inventory.selectMaterial"),value:C?G:t.material,onChange:$=>{U($.target.value),j(!0)},onFocus:()=>{j(!0),U("")}}),a.jsx(En,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),C&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[be.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):be.map($=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.material===$?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("material",$),j(!1),U("")},children:$},$)),G&&!be.includes(G)&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("material",G),j(!1),U("")},children:x("inventory.useCustomMaterial",{material:G})})]})]}),p?.material&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.material})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.brand"),!d&&" *"]}),a.jsxs("div",{className:"relative",ref:se,children:[a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:x("inventory.searchBrand"),value:y?k:t.brand,onChange:$=>{R($.target.value),_(!0)},onFocus:()=>{_(!0),R("")}}),a.jsx(En,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),y&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[ue.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):ue.map($=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.brand===$?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("brand",$),_(!1),R("")},children:$},$)),k&&!ue.includes(k)&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("brand",k),_(!1),R("")},children:x("inventory.useCustomBrand",{brand:k})})]})]}),p?.brand&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.brand})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:[x("inventory.subtype"),!d&&" *"]}),a.jsxs("div",{className:"relative",ref:ce,children:[a.jsx("input",{type:"text",value:N?M:t.subtype,onChange:$=>{D($.target.value),A(!0)},onFocus:()=>{A(!0),D("")},placeholder:"Basic, Matte, Silk...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),a.jsx(En,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),N&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[pe.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:x("inventory.noResults")}):pe.map($=>a.jsx("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${t.subtype===$?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{e("subtype",$),A(!1),D("")},children:$},$)),M&&!y0.some($=>$.toLowerCase()===M.toLowerCase().trim())&&a.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary",onClick:()=>{e("subtype",M),A(!1),D("")},children:x("inventory.useCustomBrand",{brand:M})})]})]}),p?.subtype&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:p.subtype})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:x("inventory.labelWeight")}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"number",className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green",value:W,min:0,onFocus:()=>ae(!0),onChange:$=>L($.target.value),onBlur:()=>{ae(!1);const $=W.trim(),K=Number($);if(!$||!Number.isFinite(K)||K<0){L(String(t.label_weight));return}const T=Math.round(K);e("label_weight",T),L(String(T))}}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]})]}),d&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:x("inventory.quantity")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green",value:h,min:1,max:100,onChange:$=>{const K=Math.max(1,Math.min(100,parseInt($.target.value)||1));f(K)}})]})]})}function fet({formData:t,updateField:e,recentColors:n,onColorUsed:r,catalogColors:i}){const{t:s}=Et(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=t.rgba.replace("#","").substring(0,6),h=y=>d.toUpperCase()===y.toUpperCase(),f=(y,_)=>{e("rgba",y.toUpperCase()+"FF"),e("color_name",_),r({name:_,hex:y})},p=w.useMemo(()=>{if(i.length===0)return[];const y=t.brand?.trim(),_=t.material?.toLowerCase().trim(),N=t.subtype?.toLowerCase().trim();if(!y&&!_)return[];const A=y?y.toLowerCase().split(/[\s\-_]+/).filter(k=>k.length>=2):[],C=k=>{if(A.length===0)return!0;const R=k.toLowerCase();return A.some(M=>R.includes(M))};if(y&&!_){const k=i.filter(R=>C(R.manufacturer));if(k.length>0)return k.map(R=>({name:R.color_name,hex:R.hex_color.replace("#","").substring(0,6),manufacturer:R.manufacturer,material:typeof R.material=="string"?R.material:void 0}))}const j=_&&N?`${_} ${N}`:"";if(j){const k=i.filter(M=>C(M.manufacturer)&&M.material?.toLowerCase()===j);if(k.length>0)return k.map(M=>({name:M.color_name,hex:M.hex_color.replace("#","").substring(0,6),manufacturer:M.manufacturer,material:typeof M.material=="string"?M.material:void 0}));const R=j.replace(/\+$/,"");if(R!==j){const M=i.filter(D=>C(D.manufacturer)&&D.material?.toLowerCase()===R);if(M.length>0)return M.map(D=>({name:D.color_name,hex:D.hex_color.replace("#","").substring(0,6),manufacturer:D.manufacturer,material:typeof D.material=="string"?D.material:void 0}))}}if(_){const k=i.filter(R=>C(R.manufacturer)&&(!R.material||R.material.toLowerCase().startsWith(_)));if(k.length>0)return k.map(R=>({name:R.color_name,hex:R.hex_color.replace("#","").substring(0,6),manufacturer:R.manufacturer,material:typeof R.material=="string"?R.material:void 0}))}return[]},[i,t.brand,t.material,t.subtype]),x=w.useMemo(()=>{if(!c)return p;if(p.length===0)return[];const y=c.toLowerCase();return p.filter(N=>N.name.toLowerCase().includes(y)||(N.manufacturer?.toLowerCase().includes(y)??!1)||(N.material?.toLowerCase().includes(y)??!1))},[c,p]),v=p.length>0,g=w.useMemo(()=>c?AK.filter(y=>y.name.toLowerCase().includes(c.toLowerCase())):o?AK:Sse,[c,o]);return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"h-10 rounded-lg border border-bambu-dark-tertiary",style:{backgroundColor:`#${d}`}}),n.length>0&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-bambu-gray shrink-0",children:[a.jsx(Xn,{className:"w-3 h-3"}),a.jsx("span",{children:s("inventory.recentColors")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(y=>a.jsx("button",{type:"button",onClick:()=>f(y.hex,y.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${h(y.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${y.hex}`},title:y.name},y.hex))})]}),a.jsxs("div",{className:"relative",children:[a.jsx(Er,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none"}),a.jsx("input",{type:"text",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchColors"),value:c,onChange:y=>u(y.target.value)})]}),v?a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:c?s("inventory.searchResults"):`${t.brand}${t.material?` ${t.material}`:""}`}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.map(y=>a.jsx("button",{type:"button",onClick:()=>f(y.hex,y.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(y.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${y.hex}`},title:y.manufacturer&&y.material?`${y.name} (${y.manufacturer} — ${y.material})`:y.manufacturer?`${y.name} (${y.manufacturer})`:y.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:y.manufacturer&&y.material?`${y.name} (${y.manufacturer} — ${y.material})`:y.manufacturer?`${y.name} (${y.manufacturer})`:y.name})},`${y.hex}-${y.name}-${y.manufacturer??""}`)),x.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:s(c?"inventory.searchResults":o?"inventory.allColors":"inventory.commonColors")}),!c&&a.jsx("button",{type:"button",onClick:()=>l(!o),className:"flex items-center gap-1 hover:text-white transition-colors",children:o?a.jsxs(a.Fragment,{children:[s("inventory.showLess")," ",a.jsx(Sl,{className:"w-3 h-3"})]}):a.jsxs(a.Fragment,{children:[s("inventory.showAll")," ",a.jsx(En,{className:"w-3 h-3"})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g.map(y=>a.jsx("button",{type:"button",onClick:()=>f(y.hex,y.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(y.hex)?"border-bambu-green ring-1 ring-bambu-green/30 scale-110":"border-bambu-dark-tertiary"}`,style:{backgroundColor:`#${y.hex}`},title:y.name,children:a.jsx("span",{className:"absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white",children:y.name})},y.hex)),g.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray py-1",children:s("inventory.noColorsFound")})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.colorName")}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.colorNamePlaceholder"),value:t.color_name,onChange:y=>e("color_name",y.target.value)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:s("inventory.hexColor")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray",children:"#"}),a.jsx("input",{type:"text",className:"w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green",placeholder:"RRGGBB",value:d.toUpperCase(),onChange:y=>{const _=y.target.value.replace("#","").replace(/[^0-9A-Fa-f]/g,"");_.length<=8&&e("rgba",_.toUpperCase()+(_.length<=6?"FF":""))}})]}),a.jsx("input",{type:"color",className:"w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent",value:`#${d}`,onChange:y=>{const _=y.target.value.replace("#","").toUpperCase();e("rgba",_+"FF")},title:s("inventory.pickColor")})]})]})]})]})}function pet({catalog:t,value:e,onChange:n,catalogId:r,onCatalogIdChange:i}){const{t:s}=Et(),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=w.useRef(null),h=w.useRef(null);w.useEffect(()=>{const v=g=>{d.current&&!d.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]),w.useEffect(()=>{if(t.length===0)return;const v=t.filter(g=>g.weight===e);if(r){const g=t.find(y=>y.id===r);if(g&&g.weight===e)return}v.length===1?i(v[0].id):v.length===0&&r!==null&&i(null)},[e,t,r,i]);const f=w.useMemo(()=>{if(!c)return t;const v=c.toLowerCase();return t.filter(g=>g.name.toLowerCase().includes(v)||g.weight.toString().includes(v))},[t,c]),p=w.useMemo(()=>t.filter(v=>v.weight===e),[t,e]),x=w.useMemo(()=>{if(o)return c;if(r){const v=t.find(g=>g.id===r);if(v)return v.name}return p.length>0?p[0].name:""},[o,c,r,t,p]);return a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(Ape,{className:"w-3.5 h-3.5 text-bambu-gray"}),s("inventory.coreWeight")]})}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("div",{className:"flex-1 min-w-0 relative",ref:d,children:[a.jsx("input",{ref:h,type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green",placeholder:s("inventory.searchSpoolWeight"),value:x,onFocus:()=>{l(!0),u("")},onChange:v=>{u(v.target.value),l(!0)}}),o&&a.jsx("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto",children:f.length===0?a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:s("inventory.noResults")}):f.map(v=>a.jsxs("button",{type:"button",className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(r?v.id===r:v.weight===e)?"bg-bambu-green/10 text-bambu-green":"text-white"}`,onClick:()=>{i(v.id),n(v.weight),l(!1),u("")},children:[a.jsx("span",{className:"truncate",children:v.name}),a.jsxs("span",{className:"font-mono text-xs text-bambu-gray ml-2 shrink-0",children:[v.weight,"g"]})]},v.id))})]}),a.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[a.jsx("input",{type:"number",className:"w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green",value:e,min:0,max:2e3,onChange:v=>{const g=parseInt(v.target.value);!isNaN(g)&&g>=0&&n(g)}}),a.jsx("span",{className:"text-bambu-gray text-sm",children:"g"})]})]})]})}function get({formData:t,updateField:e,spoolCatalog:n,currencySymbol:r}){const{t:i}=Et(),{showToast:s}=dn(),[o,l]=w.useState(""),[c,u]=w.useState(!1),[d,h]=w.useState(""),[f,p]=w.useState(!1),x=Math.max(0,t.label_weight-t.weight_used),v=t.core_weight+x;return w.useEffect(()=>{c||l(String(v))},[c,v]),w.useEffect(()=>{f||h(String(x))},[f,x]),a.jsxs("div",{className:"space-y-4",children:[a.jsx(pet,{catalog:n,value:t.core_weight,onChange:g=>e("core_weight",g),catalogId:t.core_weight_catalog_id,onCatalogIdChange:g=>e("core_weight_catalog_id",g)}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.currentWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:d,min:0,max:t.label_weight,onFocus:()=>p(!0),onChange:g=>{h(g.target.value)},onBlur:()=>{p(!1);const g=d.trim(),y=Number(g);if(!g||!Number.isFinite(y)||y<0||y>t.label_weight){h(String(x));return}const _=Math.round(y);e("weight_used",Math.max(0,t.label_weight-_)),h(String(_))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.measuredWeight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"number",value:o,min:0,onFocus:()=>u(!0),onChange:g=>{l(g.target.value)},onBlur:()=>{u(!1);const g=o.trim(),y=Number(g),_=t.core_weight,N=t.core_weight+t.label_weight;if(!g||!Number.isFinite(y)||y<_||y>N){s(i("inventory.measuredWeightError",{min:_,max:N}),"error"),l(String(v));return}const A=Math.round(y),C=Math.max(0,Math.min(t.label_weight,A-t.core_weight));e("weight_used",Math.max(0,t.label_weight-C)),l(String(A))},className:"w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"}),a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray",children:"g"})]}),a.jsxs("span",{className:"text-xs text-bambu-gray shrink-0",children:["/ ",t.core_weight+t.label_weight,"g"]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.costPerKg","Cost per kg")}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none",children:r}),a.jsx("input",{type:"number",value:t.cost_per_kg??"",min:0,step:.01,placeholder:"0.00",onChange:g=>{const y=g.target.value===""?null:parseFloat(g.target.value);e("cost_per_kg",y)},style:{paddingLeft:`${Math.max(2,r.length*.6+1)}rem`},className:"w-full py-2 pr-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green"})]})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:i("inventory.note")}),a.jsx("textarea",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]",placeholder:i("inventory.notePlaceholder"),value:t.note,onChange:g=>e("note",g.target.value)})]})]})}function bet({formData:t,printersWithCalibrations:e,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:i,setExpandedPrinters:s}){const{t:o}=Et(),l=f=>{s(p=>{const x=new Set(p);return x.has(f)?x.delete(f):x.add(f),x})},c=(f,p,x)=>{const v=`${f}:${p}:${x??"null"}`,g=`${f}:${x??"null"}`;r(y=>{const _=new Set(y);if(_.has(v))_.delete(v);else{for(const N of Array.from(_)){const A=N.split(":");`${A[0]}:${A[2]}`===g&&_.delete(N)}_.add(v)}return _})},u=()=>{const f=new Set;for(const{printer:p,calibrations:x}of e){if(!p.connected)continue;const v=x.filter(y=>GE(y,t)),g=new Map;for(const y of v){const _=`${y.extruder_id??"null"}`;g.has(_)||g.set(_,[]),g.get(_).push(y)}for(const[y,_]of g)if(_.length>0){const A=[..._].sort((C,j)=>j.k_value-C.k_value)[0];f.add(`${p.id}:${A.cali_idx}:${y}`)}}r(f)};if(!t.material)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.selectMaterialFirst")})});if(e.length===0)return a.jsx("div",{className:"p-6 bg-bambu-dark rounded-lg text-center",children:a.jsx("p",{className:"text-bambu-gray",children:o("inventory.noPrintersConfigured")})});const d=e.reduce((f,{printer:p,calibrations:x})=>p.connected?f+x.filter(v=>GE(v,t)).length:f,0),h=(f,p)=>{const x=`${f.id}:${p.cali_idx}:${p.extruder_id??"null"}`,v=n.has(x);return a.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${v?"bg-bambu-green/10 border-bambu-green/30":"bg-bambu-dark border-transparent hover:bg-bambu-dark/80"}`,children:[a.jsx("input",{type:"checkbox",checked:v,onChange:()=>c(String(f.id),p.cali_idx,p.extruder_id),className:"w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green"}),a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("span",{className:`text-sm font-medium ${v?"text-bambu-green":"text-white"}`,children:p.name||p.filament_id})}),a.jsx("div",{className:"flex items-center gap-2 shrink-0",children:a.jsxs("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray",children:["K=",p.k_value.toFixed(3)]})})]},`${p.cali_idx}-${p.extruder_id}`)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:[o("inventory.matchingFilter"),": ",t.brand||o("inventory.anyBrand")," / ",t.material," / ",t.subtype||o("inventory.anyVariant")]}),d>0&&a.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",children:[a.jsx(vb,{className:"w-3.5 h-3.5"}),o("inventory.autoSelect")," (",d,")"]})]}),a.jsx("div",{className:"space-y-3",children:e.map(({printer:f,calibrations:p})=>{const x=i.has(String(f.id)),v=p.filter(A=>GE(A,t)),g=v.length,y=v.some(A=>A.extruder_id!==void 0&&A.extruder_id!==null&&A.extruder_id>0),_=v.filter(A=>A.extruder_id===1),N=v.filter(A=>A.extruder_id===0||A.extruder_id===void 0||A.extruder_id===null);return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>l(String(f.id)),className:"w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[x?a.jsx(En,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(pi,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"font-medium text-white",children:f.name}),g>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:[g," ",o(g!==1?"inventory.matches":"inventory.match")]}):a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray",children:o("inventory.noMatches")})]}),a.jsx("span",{className:`text-xs px-2 py-1 rounded-full ${f.connected?"bg-green-500/20 text-green-500":"bg-bambu-gray/20 text-bambu-gray"}`,children:f.connected?o("inventory.connected"):o("inventory.offline")})]}),x&&a.jsx("div",{className:"px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary",children:f.connected?g===0?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.noKProfilesMatch")}):y?a.jsxs(a.Fragment,{children:[_.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.leftNozzle")}),a.jsx("div",{className:"space-y-2",children:_.map(A=>h(f,A))})]}),N.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-bambu-gray uppercase tracking-wide",children:o("inventory.rightNozzle")}),a.jsx("div",{className:"space-y-2",children:N.map(A=>h(f,A))})]})]}):a.jsx("div",{className:"space-y-2",children:v.map(A=>h(f,A))}):a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:o("inventory.printerOffline")})})]},f.id)})}),n.size>0&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"font-semibold",children:n.size})," ",o("inventory.profilesSelected")]})})]})}function xet(t){const e=new Date(t);return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})}const yet={completed:"text-bambu-green",failed:"text-red-400",aborted:"text-yellow-400"};function vet({spoolId:t}){const{t:e}=Et(),n=Qt(),{showToast:r}=dn(),{data:i,isLoading:s}=Je({queryKey:["spool-usage",t],queryFn:()=>ge.getSpoolUsageHistory(t)}),o=ut({mutationFn:()=>ge.clearSpoolUsageHistory(t),onSuccess:()=>{n.invalidateQueries({queryKey:["spool-usage",t]}),r(e("inventory.historyCleared"),"success")}});return s?a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(lt,{className:"w-5 h-5 animate-spin text-bambu-green"})}):!i||i.length===0?a.jsxs("div",{className:"text-center py-4 text-bambu-gray text-sm",children:[a.jsx(Xn,{className:"w-5 h-5 mx-auto mb-2 opacity-50"}),e("inventory.noUsageHistory")]}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:e("inventory.usageHistory")}),a.jsxs(Oe,{variant:"ghost",size:"sm",onClick:()=>o.mutate(),disabled:o.isPending,className:"text-xs text-bambu-gray hover:text-red-400",children:[a.jsx(Xt,{className:"w-3 h-3 mr-1"}),e("inventory.clearHistory")]})]}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:i.map(l=>a.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:"text-bambu-gray",children:xet(l.created_at)}),l.print_name&&a.jsx("span",{className:"text-white ml-2 truncate",title:l.print_name,children:l.print_name})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[a.jsxs("span",{className:"text-white font-medium",children:[l.weight_used.toFixed(1),"g"]}),a.jsxs("span",{className:"text-bambu-gray",children:["(",l.percent_used,"%)"]}),a.jsx("span",{className:yet[l.status]||"text-bambu-gray",children:l.status})]})]},l.id))})]})}function wet({isOpen:t,onClose:e,spool:n,printersWithCalibrations:r=[],currencySymbol:i}){const{t:s}=Et(),o=Qt(),{showToast:l}=dn(),c=!!n,[u,d]=w.useState(CK),[h,f]=w.useState({}),[p,x]=w.useState("filament"),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,A]=w.useState(1),[C,j]=w.useState(!1),[k,R]=w.useState(!1),[M,D]=w.useState([]),[G,U]=w.useState(""),[W,L]=w.useState([]),[ee,ae]=w.useState([]),[Y,se]=w.useState([]),[ce,ye]=w.useState([]),[Z,ue]=w.useState([]),[pe,be]=w.useState(new Set),[Ee,$]=w.useState(new Set),K=r.length>0?r:Z,T=w.useMemo(()=>pe.size,[pe]);w.useEffect(()=>{ye(det())},[]),w.useEffect(()=>{t&&((async()=>{R(!0);try{const le=await ge.getCloudStatus();if(j(le.is_authenticated),le.is_authenticated){const Ce=await ge.getFilamentPresets();D(Ce)}}catch(le){console.error("Failed to fetch cloud presets:",le),j(!1)}finally{R(!1)}})(),ge.getSpoolCatalog().then(L).catch(console.error),ge.getColorCatalog().then(se).catch(console.error),ge.getLocalPresets().then(le=>ae(le.filament)).catch(console.error),r.length===0&&(async()=>{try{const le=await ge.getPrinters(),Ce=await Promise.all(le.map(Ue=>ge.getPrinterStatus(Ue.id).catch(()=>null))),Ne=[];for(let Ue=0;Ue<le.length;Ue++){const He=le[Ue],we=Ce[Ue]?.connected??!1;let ke=[];if(we)try{ke=(await ge.getKProfiles(He.id)).profiles.map(Ae=>({cali_idx:Ae.slot_id,filament_id:Ae.filament_id,setting_id:Ae.setting_id||"",name:Ae.name,k_value:parseFloat(Ae.k_value)||0,n_coef:parseFloat(Ae.n_coef)||0,extruder_id:Ae.extruder_id,nozzle_diameter:Ae.nozzle_diameter}))}catch{}Ne.push({printer:{...He,connected:we},calibrations:ke})}ue(Ne)}catch(le){console.error("Failed to fetch printer calibrations:",le)}})())},[t,r.length]);const E=w.useMemo(()=>cet(M,new Set,ee),[M,ee]),O=w.useMemo(()=>{const he=set(M,ee),le=Y.map(Ne=>Ne.manufacturer?.trim()).filter(Ne=>!!Ne),Ce=new Set([...he,...le]);return Array.from(Ce).sort((Ne,Ue)=>Ne.localeCompare(Ue))},[M,ee,Y]),q=w.useMemo(()=>{const he=Y.map(Ce=>Ce.material?.trim()).filter(Ce=>!!Ce),le=new Set([...tet,...he]);return Array.from(le).sort((Ce,Ne)=>Ce.localeCompare(Ne))},[Y]),B=w.useMemo(()=>{const he=[];for(const le of Y){const Ce=le.manufacturer?.trim(),Ne=le.material?.trim();Ce&&Ne&&he.push({brand:Ce,material:Ne})}for(const le of M){const Ce=Wb(le.name);Ce.brand&&Ce.material&&he.push({brand:Ce.brand,material:Ce.material})}for(const le of ee){const Ce=Wb(le.name),Ne=le.filament_vendor?.trim()||Ce.brand,Ue=Ce.material;Ne&&Ue&&he.push({brand:Ne,material:Ue})}return he},[M,Y,ee]),re=w.useMemo(()=>{const he=new Map;for(const le of B){const Ce=le.brand.toLowerCase(),Ne=le.material.toLowerCase();he.has(Ce)||he.set(Ce,new Set),he.get(Ce).add(Ne)}return he},[B]),z=w.useMemo(()=>{const he=new Map;for(const le of B){const Ce=le.brand.toLowerCase(),Ne=le.material.toLowerCase();he.has(Ne)||he.set(Ne,new Set),he.get(Ne).add(Ce)}return he},[B]),V=w.useMemo(()=>{if(!u.material)return O;const he=u.material.toLowerCase(),le=z.get(he);return!le||le.size===0?O:O.filter(Ce=>le.has(Ce.toLowerCase()))},[O,u.material,z]),te=w.useMemo(()=>{if(!u.brand)return q;const he=u.brand.toLowerCase(),le=re.get(he);return!le||le.size===0?q:q.filter(Ce=>le.has(Ce.toLowerCase()))},[q,u.brand,re]),Q=w.useMemo(()=>uet(u.slicer_filament,E),[u.slicer_filament,E]);w.useEffect(()=>{if(t){if(n)if(d({material:n.material||"",subtype:n.subtype||"",brand:n.brand||"",color_name:n.color_name||"",rgba:n.rgba||"808080FF",label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,core_weight_catalog_id:n.core_weight_catalog_id??null,weight_used:n.weight_used||0,slicer_filament:n.slicer_filament||"",note:n.note||"",cost_per_kg:n.cost_per_kg??null}),U(n.slicer_filament_name||n.slicer_filament||""),n.k_profiles&&n.k_profiles.length>0){const he=new Set;for(const le of n.k_profiles)le.cali_idx!==null&&le.cali_idx!==void 0&&he.add(`${le.printer_id}:${le.cali_idx}:${le.extruder??"null"}`);be(he)}else be(new Set);else d(CK),U(""),be(new Set),_(!1),A(1);f({}),x("filament"),g(!1)}},[t,n]),w.useEffect(()=>{t&&K.length>0&&$(new Set(K.map(he=>String(he.printer.id))))},[t,K]);const ne=(he,le)=>{d(Ce=>({...Ce,[he]:le})),he==="weight_used"&&g(!0),h[he]&&f(Ce=>({...Ce,[he]:void 0}))},ie=he=>{ye(le=>het(he,le))},me=ut({mutationFn:he=>ge.createSpool(he),onSuccess:async he=>{pe.size>0&&he?.id&&await F(he.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolCreated"),"success"),e()},onError:he=>{l(he.message,"error")}}),fe=ut({mutationFn:({data:he,qty:le})=>ge.bulkCreateSpools(he,le),onSuccess:async he=>{if(pe.size>0)for(const le of he)await F(le.id);await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolsCreated",{count:he.length}),"success"),e()},onError:he=>{l(he.message,"error")}}),oe=ut({mutationFn:he=>ge.updateSpool(n.id,he),onSuccess:async()=>{n?.id&&await F(n.id),await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.spoolUpdated"),"success"),e()},onError:he=>{l(he.message,"error")}}),I=ut({mutationFn:()=>ge.updateSpool(n.id,{tag_uid:null}),onSuccess:async()=>{await o.invalidateQueries({queryKey:["inventory-spools"]}),l(s("inventory.tagDeleted","Tag removed"),"success"),e()},onError:he=>{l(he.message,"error")}}),F=async he=>{if(pe.size===0){try{await ge.saveSpoolKProfiles(he,[])}catch{}return}const le=[];for(const Ce of pe){const[Ne,Ue,He]=Ce.split(":"),de=parseInt(Ne),we=parseInt(Ue),ke=He==="null"?0:parseInt(He),_e=K.find(Ae=>Ae.printer.id===de);if(_e){const Ae=_e.calibrations.find(Ve=>Ve.cali_idx===we);Ae&&le.push({printer_id:de,extruder:ke,nozzle_diameter:Ae.nozzle_diameter||"0.4",k_value:Ae.k_value,name:Ae.name||null,cali_idx:Ae.cali_idx,setting_id:Ae.setting_id||null})}}if(le.length>0)try{await ge.saveSpoolKProfiles(he,le)}catch(Ce){console.error("Failed to save K-profiles:",Ce)}};if(w.useEffect(()=>{if(!t)return;const he=le=>{le.key==="Escape"&&e()};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[t,e]),!t)return null;const J=()=>{const he=eet(u,y);if(!he.isValid){f(he.errors),(he.errors.slicer_filament||he.errors.material||he.errors.brand||he.errors.subtype)&&x("filament");return}const le=Q?.displayName||G||null,Ce={material:u.material,subtype:u.subtype||null,brand:u.brand||null,color_name:u.color_name||null,rgba:u.rgba||null,label_weight:u.label_weight,core_weight:u.core_weight,core_weight_catalog_id:u.core_weight_catalog_id,slicer_filament:u.slicer_filament||null,slicer_filament_name:le,nozzle_temp_min:null,nozzle_temp_max:null,note:u.note||null,cost_per_kg:u.cost_per_kg};(!c||v)&&(Ce.weight_used=u.weight_used),c?oe.mutate(Ce):N>1?fe.mutate({data:Ce,qty:N}):me.mutate(Ce)},xe=me.isPending||fe.isPending||oe.isPending||I.isPending;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-xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-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 flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:s(c?"inventory.editSpool":"inventory.addSpool")}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),!c&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ic,{className:"w-4 h-4 text-amber-400"}),a.jsx("span",{className:"text-sm text-white",children:s("inventory.quickAdd")})]}),a.jsx("button",{type:"button",onClick:()=>{_(!y),y||x("filament")},className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${y?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${y?"translate-x-4":"translate-x-0.5"}`})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("button",{onClick:()=>x("filament"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${p==="filament"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(rC,{className:"w-4 h-4"}),s("inventory.filamentInfoTab")]}),!y&&a.jsxs("button",{onClick:()=>x("pa-profile"),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${p==="pa-profile"?"text-bambu-green border-b-2 border-bambu-green":"text-bambu-gray hover:text-white"}`,children:[a.jsx(phe,{className:"w-4 h-4"}),s("inventory.paProfileTab"),T>0&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green",children:T})]})]}),a.jsx("div",{className:"p-4 overflow-y-auto flex-1",style:{scrollbarGutter:"stable"},children:p==="filament"?a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.filamentInfo")}),a.jsx(met,{formData:u,updateField:ne,cloudAuthenticated:C,loadingCloudPresets:k,presetInputValue:G,setPresetInputValue:U,selectedPresetOption:Q,filamentOptions:E,availableBrands:V,availableMaterials:te,quickAdd:y,quantity:N,onQuantityChange:A,errors:h})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.color")}),a.jsx(fet,{formData:u,updateField:ne,recentColors:ce,onColorUsed:ie,catalogColors:Y})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3",children:s("inventory.additional")}),a.jsx(get,{formData:u,updateField:ne,spoolCatalog:W,currencySymbol:i})]}),c&&n&&a.jsx("div",{children:a.jsx(vet,{spoolId:n.id})})]}):a.jsx(bet,{formData:u,updateField:ne,printersWithCalibrations:K,selectedProfiles:pe,setSelectedProfiles:be,expandedPrinters:Ee,setExpandedPrinters:$})}),a.jsxs("div",{className:"flex gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:[c&&a.jsxs(Oe,{variant:"secondary",onClick:()=>I.mutate(),disabled:xe||!n?.tag_uid,className:"mr-auto",children:[a.jsx(ad,{className:"w-4 h-4"}),s("inventory.deleteTag","Delete Tag")]}),a.jsxs("div",{className:"flex gap-2 ml-auto",children:[a.jsx(Oe,{variant:"secondary",onClick:e,children:s("common.cancel")}),a.jsx(Oe,{onClick:J,disabled:xe,children:xe?a.jsxs(a.Fragment,{children:[a.jsx(lt,{className:"w-4 h-4 animate-spin"}),s("common.saving")]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),s(c?"common.save":"inventory.addSpool")]})})]})]})]})]})}function _et({isOpen:t,onClose:e,columns:n,defaultColumns:r,onSave:i}){const{t:s}=Et(),[o,l]=w.useState(n),[c,u]=w.useState(null),d=w.useRef(null);if(w.useEffect(()=>{t&&l(n.map(A=>({...A})))},[t,n]),w.useEffect(()=>{if(!t)return;const A=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,e]),!t)return null;const h=A=>{l(C=>C.map((j,k)=>k===A?{...j,visible:!j.visible}:j))},f=(A,C)=>{C<0||C>=o.length||l(j=>{const k=[...j],[R]=k.splice(A,1);return k.splice(C,0,R),k})},p=(A,C)=>{d.current=C,u(C),A.dataTransfer.effectAllowed="move"},x=(A,C)=>{A.preventDefault(),A.dataTransfer.dropEffect="move";const j=d.current;j!==null&&j!==C&&(f(j,C),d.current=C,u(C))},v=A=>{A.preventDefault()},g=()=>{d.current=null,u(null)},y=()=>{l(r.map(A=>({...A})))},_=()=>{i(o),e()},N=o.filter(A=>A.visible).length;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsx(Ct,{className:"w-full max-w-md max-h-[80vh] flex flex-col",onClick:A=>A.stopPropagation(),children:a.jsxs(Tt,{className:"p-6 flex flex-col min-h-0",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:s("inventory.configureColumns")}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:[s("inventory.configureColumnsDesc"),a.jsxs("span",{className:"ml-2 text-bambu-gray/60",children:["(",N," ",s("inventory.of")," ",o.length," ",s("inventory.visible"),")"]})]}),a.jsx("div",{className:"space-y-1 overflow-y-auto flex-1 min-h-0 pr-1",children:o.map((A,C)=>a.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===C?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-tertiary/50"} ${A.visible?"":"opacity-50"}`,draggable:!0,onDragStart:j=>p(j,C),onDragOver:j=>x(j,C),onDrop:v,onDragEnd:g,children:[a.jsx("div",{className:"cursor-grab text-bambu-gray/50 hover:text-bambu-gray",children:a.jsx(Oh,{className:"w-4 h-4"})}),a.jsx("span",{className:"flex-1 font-medium text-sm text-white",children:A.label}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("button",{onClick:()=>f(C,C-1),disabled:C===0,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveUp"),children:a.jsx(Sl,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>f(C,C+1),disabled:C===o.length-1,className:"p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed",title:s("inventory.moveDown"),children:a.jsx(En,{className:"w-4 h-4"})})]}),a.jsx("button",{onClick:()=>h(C),className:`p-1.5 rounded transition-colors ${A.visible?"text-bambu-green hover:bg-bambu-green/10":"text-bambu-gray/50 hover:bg-bambu-dark-secondary"}`,title:A.visible?s("inventory.hideColumn"):s("inventory.showColumn"),children:A.visible?a.jsx(tc,{className:"w-4 h-4"}):a.jsx(yv,{className:"w-4 h-4"})})]},A.id))}),a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs(Oe,{variant:"secondary",onClick:y,className:"mr-auto",children:[a.jsx(co,{className:"w-4 h-4"}),s("inventory.reset")]}),a.jsx(Oe,{variant:"secondary",onClick:e,children:s("inventory.cancel")}),a.jsx(Oe,{onClick:_,children:s("inventory.applyChanges")})]})]})})})}function TK(t){return`${t.material}|${t.subtype||""}|${t.brand||""}|${t.color_name||""}|${t.rgba||""}|${t.label_weight}`}const Nse="bambuddy-inventory-columns",v1=[{id:"id",label:"#",visible:!0},{id:"added_time",label:"Added",visible:!0},{id:"encode_time",label:"Encoded",visible:!1},{id:"last_used_time",label:"Last Used",visible:!1},{id:"rgba",label:"Color",visible:!0},{id:"material",label:"Material",visible:!0},{id:"subtype",label:"Subtype",visible:!0},{id:"color_name",label:"Color Name",visible:!1},{id:"brand",label:"Brand",visible:!0},{id:"slicer_filament",label:"Slicer Filament",visible:!1},{id:"location",label:"Location",visible:!0},{id:"label_weight",label:"Label",visible:!0},{id:"net",label:"Net",visible:!0},{id:"gross",label:"Gross",visible:!1},{id:"added_full",label:"Full",visible:!1},{id:"used",label:"Used",visible:!1},{id:"printed_total",label:"Printed Total",visible:!1},{id:"printed_since_weight",label:"Printed Since Weight",visible:!1},{id:"note",label:"Note",visible:!1},{id:"pa_k",label:"PA(K)",visible:!0},{id:"tag_id",label:"Tag ID",visible:!1},{id:"data_origin",label:"Data Origin",visible:!1},{id:"tag_type",label:"Linked Tag Type",visible:!1},{id:"stock",label:"Stock",visible:!1},{id:"remaining",label:"Remaining",visible:!0},{id:"cost_per_kg",label:"Cost/kg",visible:!1},{id:"weight_check",label:"Weight Check",visible:!1}];function Net(){try{const t=localStorage.getItem(Nse);if(t){const e=JSON.parse(t),n=new Set(v1.map(o=>o.id)),r=new Set(e.map(o=>o.id)),i=e.filter(o=>n.has(o.id)),s=v1.filter(o=>!r.has(o.id));return[...i,...s]}}catch{}return v1.map(t=>({...t}))}function ket(t){try{localStorage.setItem(Nse,JSON.stringify(t))}catch{}}function Ec(t,e=!1){return e&&t>=1e3?`${(t/1e3).toFixed(1)}kg`:`${Math.round(t)}g`}const Cet={PLA:"bg-green-500/20 text-green-400",ABS:"bg-red-500/20 text-red-400",PETG:"bg-blue-500/20 text-blue-400",TPU:"bg-purple-500/20 text-purple-400",ASA:"bg-orange-500/20 text-orange-400",PA:"bg-yellow-500/20 text-yellow-400",PC:"bg-cyan-500/20 text-cyan-400",PET:"bg-sky-500/20 text-sky-400"};function WE(t,e="system"){if(!t)return"-";const n=Jn(t);return n?S3(n,e):"-"}const Aet={id:()=>"#",added_time:()=>"Added",encode_time:()=>"Encoded",last_used_time:()=>"Last Used",rgba:t=>t("inventory.color"),material:t=>t("inventory.material"),subtype:t=>t("inventory.subtype"),color_name:t=>t("inventory.colorName"),brand:t=>t("inventory.brand"),slicer_filament:t=>t("inventory.slicerFilament"),location:()=>"Location",label_weight:t=>t("inventory.labelWeight"),net:t=>t("inventory.net"),gross:()=>"Gross",added_full:()=>"Full",used:t=>t("inventory.weightUsed"),printed_total:()=>"Printed Total",printed_since_weight:()=>"Printed Since Weight",note:t=>t("inventory.note"),pa_k:()=>"PA(K)",tag_id:()=>"Tag ID",data_origin:()=>"Data Origin",tag_type:()=>"Linked Tag Type",stock:t=>t("inventory.stock"),remaining:t=>t("inventory.remaining"),cost_per_kg:t=>t("inventory.costPerKg"),weight_check:t=>t("inventory.weightCheck")},yF={id:({spool:t})=>a.jsx("span",{className:"text-sm font-medium text-white",children:t.id}),added_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:WE(t.created_at,e)}),encode_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:WE(t.encode_time,e)}),last_used_time:({spool:t,dateFormat:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.last_used?WE(t.last_used,e):"Never"}),rgba:({spool:t})=>a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("span",{className:"w-5 h-5 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:t.rgba?`#${t.rgba.substring(0,6)}`:"#808080"},title:t.rgba?`#${t.rgba.substring(0,6)}`:void 0})}),material:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:t.material}),subtype:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.subtype||"-"}),color_name:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:TO(t.color_name,t.rgba)||"-"}),brand:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.brand||"-"}),slicer_filament:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",title:t.slicer_filament||void 0,children:t.slicer_filament_name||t.slicer_filament||"-"}),location:({spool:t,assignmentMap:e})=>{const n=e[t.id];if(!n)return a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"});const r=n.printer_name||`Printer ${n.printer_id}`,i=n.ams_id===254||n.ams_id===255,s=!i&&n.ams_id>=128,o=kO(n.ams_id,n.tray_id,s,i);return a.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400",children:[r," ",o]})},label_weight:({spool:t})=>a.jsx("span",{className:"text-sm text-white",children:Ec(t.label_weight)}),net:({remaining:t})=>a.jsx("span",{className:"text-sm text-white",children:Ec(t)}),gross:({spool:t,remaining:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:Ec(e+t.core_weight)}),added_full:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.added_full==null?"-":t.added_full?"Yes":"No"}),used:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.weight_used>0?Ec(t.weight_used):"-"}),printed_total:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),printed_since_weight:()=>a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"}),note:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray max-w-[150px] truncate block",title:t.note||void 0,children:t.note||"-"}),pa_k:({spool:t})=>(t.k_profiles?.length??0)===0?a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):a.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green",children:"K"}),tag_id:({spool:t})=>{const e=t.tag_uid||t.tray_uuid;return e?a.jsx("span",{className:"text-sm text-bambu-gray font-mono",title:e,children:e.length>12?`${e.slice(0,6)}...${e.slice(-4)}`:e}):a.jsx("span",{className:"text-sm text-bambu-gray/50",children:"-"})},data_origin:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.data_origin||"-"}),tag_type:({spool:t})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.tag_type||"-"}),stock:({spool:t,t:e})=>t.slicer_filament?a.jsx("span",{className:"text-sm text-bambu-gray",children:"-"}):a.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-amber-500/20 text-amber-400",children:e("inventory.stock")}),remaining:({remaining:t,pct:e})=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${e>50?"bg-bambu-green":e>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(e,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(t),"g"]})]}),cost_per_kg:({spool:t,currencySymbol:e})=>a.jsx("span",{className:"text-sm text-bambu-gray",children:t.cost_per_kg!=null?`${e}${t.cost_per_kg.toFixed(2)}`:"-"}),weight_check:({spool:t,onSyncWeight:e})=>{const n=t.last_scale_weight;if(n==null)return a.jsx("span",{className:"text-sm text-bambu-gray/50",title:"No scale measurement",children:"-"});const r=t.core_weight||0,i=Math.max(0,t.label_weight-t.weight_used)+r;let s,o;n<r?(s=n-r,o=!0):(s=n-i,o=Math.abs(s)<=50);const l=s>0?`+${Math.round(s)}`:`${Math.round(s)}`,c=o?`Scale: ${Math.round(n)}g
  8312. Calculated: ${Math.round(i)}g
  8313. Difference: ${l}g (within tolerance)`:`Scale: ${Math.round(n)}g
  8314. Calculated: ${Math.round(i)}g
  8315. Difference: ${l}g (mismatch!)`;return a.jsxs("div",{className:`flex items-center gap-1 text-sm font-medium ${o?"text-green-400":"text-yellow-400"}`,title:c,children:[a.jsxs("span",{children:[Math.round(n),"g"]}),o?a.jsx(Zr,{className:"w-3 h-3"}):a.jsxs(a.Fragment,{children:[a.jsx(Mn,{className:"w-3 h-3"}),e&&a.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),u.preventDefault(),e(t)},className:"p-1 hover:bg-bambu-green/20 rounded transition-colors text-bambu-green",title:"Sync: trust scale weight and reset tracking",children:a.jsx(wr,{className:"w-3.5 h-3.5"})})]})]})}},KE={id:t=>t.id,added_time:t=>t.created_at||"",encode_time:t=>t.encode_time||"",last_used_time:t=>t.last_used||"",material:t=>(t.material||"").toLowerCase(),subtype:t=>(t.subtype||"").toLowerCase(),color_name:t=>(t.color_name||"").toLowerCase(),brand:t=>(t.brand||"").toLowerCase(),slicer_filament:t=>(t.slicer_filament_name||t.slicer_filament||"").toLowerCase(),location:(t,e)=>{const n=e[t.id];if(!n)return"";const r=n.ams_id===254||n.ams_id===255,i=!r&&n.ams_id>=128;return`${n.printer_name||""} ${kO(n.ams_id,n.tray_id,i,r)}`},label_weight:t=>t.label_weight,net:t=>Math.max(0,t.label_weight-t.weight_used),gross:t=>Math.max(0,t.label_weight-t.weight_used)+t.core_weight,used:t=>t.weight_used,remaining:t=>t.label_weight>0?Math.max(0,t.label_weight-t.weight_used)/t.label_weight:0,note:t=>(t.note||"").toLowerCase(),data_origin:t=>(t.data_origin||"").toLowerCase(),tag_type:t=>(t.tag_type||"").toLowerCase(),stock:t=>t.slicer_filament?1:0,cost_per_kg:t=>t.cost_per_kg??0,weight_check:t=>{if(t.last_scale_weight==null)return-1;const e=Math.max(0,t.label_weight-t.weight_used)+t.core_weight;return Math.abs(t.last_scale_weight-e)}},vF="bambuddy-inventory-sort";function Tet(){try{const t=localStorage.getItem(vF);if(t)return JSON.parse(t)}catch{}return null}function Met(t){try{t?localStorage.setItem(vF,JSON.stringify(t)):localStorage.removeItem(vF)}catch{}}function Pet(){const{data:t}=Je({queryKey:["spoolman-settings"],queryFn:ge.getSpoolmanSettings,staleTime:3e5});return t?.spoolman_enabled==="true"&&t?.spoolman_url?a.jsx("iframe",{src:t.spoolman_url,className:"h-full w-full border-0",title:"Spoolman",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"}):a.jsx(jet,{})}function jet(){const{t}=Et(),e=Qt(),{showToast:n}=dn(),[r,i]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState("active"),[u,d]=w.useState("all"),[h,f]=w.useState(""),[p,x]=w.useState(""),[v,g]=w.useState("all"),[y,_]=w.useState(""),[N,A]=w.useState("table"),[C,j]=w.useState(Tet),[k,R]=w.useState(Net),[M,D]=w.useState(!1),[G,U]=w.useState(()=>{try{return localStorage.getItem("bambuddy-inventory-group")==="true"}catch{return!1}}),[W,L]=w.useState(new Set),[ee,ae]=w.useState(0),[Y,se]=w.useState(()=>{try{const de=localStorage.getItem("bambuddy-inventory-pageSize");if(de){const we=Number(de);if([15,30,50,100,-1].includes(we))return we}}catch{}return 15}),{data:ce}=Je({queryKey:["settings"],queryFn:ge.getSettings}),ye=ce?.date_format||"system",{data:Z,isLoading:ue}=Je({queryKey:["inventory-spools"],queryFn:()=>ge.getSpools(!0),refetchInterval:3e4}),{data:pe}=Je({queryKey:["spool-assignments"],queryFn:()=>ge.getAssignments(),refetchInterval:3e4}),be=ut({mutationFn:de=>ge.deleteSpool(de),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolDeleted"),"success")}}),Ee=ut({mutationFn:de=>ge.archiveSpool(de),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolArchived"),"success")}}),$=ut({mutationFn:de=>ge.restoreSpool(de),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolRestored"),"success")}}),K=async de=>{if(de.last_scale_weight!=null)try{await ys.updateSpoolWeight(de.id,de.last_scale_weight),e.invalidateQueries({queryKey:["inventory-spools"]});const we=[de.brand,de.material,de.color_name].filter(Boolean).join(" ");n(`Synced "${we}" to scale weight`,"success")}catch{n("Failed to sync weight","error")}},T=w.useMemo(()=>{if(!Z)return null;let de=0,we=0,ke=0,_e=0;const Ae={};for(const Ve of Z){if(Ve.archived_at)continue;_e++;const Te=Math.max(0,Ve.label_weight-Ve.weight_used);de+=Te,we+=Ve.weight_used,(Ve.label_weight>0?Te/Ve.label_weight*100:0)<20&&ke++;const je=Ve.material||"Unknown";Ae[je]||(Ae[je]={count:0,weight:0}),Ae[je].count++,Ae[je].weight+=Te}return{totalWeight:de,totalConsumed:we,lowStock:ke,byMaterial:Ae,totalSpools:_e}},[Z]),E=pe?.length??0,O=sl(ce?.currency||"USD"),q=w.useMemo(()=>{const de={};for(const we of pe||[])de[we.spool_id]=we;return de},[pe]),B=w.useMemo(()=>T?Object.entries(T.byMaterial).sort((de,we)=>we[1].weight-de[1].weight).slice(0,4):[],[T]),re=w.useMemo(()=>{let de=Z||[];if(l==="active"?de=de.filter(we=>!we.archived_at):de=de.filter(we=>!!we.archived_at),u==="used"?de=de.filter(we=>we.weight_used>0):u==="new"&&(de=de.filter(we=>we.weight_used===0)),h&&(de=de.filter(we=>we.material===h)),p&&(de=de.filter(we=>we.brand===p)),v==="stock"?de=de.filter(we=>!we.slicer_filament):v==="configured"&&(de=de.filter(we=>!!we.slicer_filament)),y){const we=y.toLowerCase();de=de.filter(ke=>ke.brand?.toLowerCase().includes(we)||ke.material.toLowerCase().includes(we)||ke.color_name?.toLowerCase().includes(we)||ke.subtype?.toLowerCase().includes(we)||ke.note?.toLowerCase().includes(we)||ke.slicer_filament_name?.toLowerCase().includes(we))}return de},[Z,l,u,h,p,v,y]),z=()=>ae(0),V=[...new Set(Z?.map(de=>de.material)||[])].sort(),te=[...new Set(Z?.map(de=>de.brand).filter(Boolean)||[])].sort(),Q=l!=="active"||u!=="all"||!!h||!!p||v!=="all"||!!y,ne=de=>{R(de),ket(de)},ie=w.useMemo(()=>k.filter(de=>de.visible).map(de=>de.id),[k]),me=de=>{KE[de]&&(j(we=>{let ke;return we?.column===de?ke=we.direction==="asc"?{column:de,direction:"desc"}:null:ke={column:de,direction:"asc"},Met(ke),ke}),z())},fe=w.useMemo(()=>{if(!C)return re;const de=KE[C.column];return de?[...re].sort((ke,_e)=>{const Ae=de(ke,q),Ve=de(_e,q);return Ae<Ve?C.direction==="asc"?-1:1:Ae>Ve?C.direction==="asc"?1:-1:0}):re},[re,C,q]),oe=w.useMemo(()=>{if(!G)return fe.map(_e=>({type:"single",spool:_e}));const de=new Map;for(const _e of fe)if(!(_e.weight_used>0||q[_e.id])){const Ae=TK(_e),Ve=de.get(Ae);Ve?Ve.push(_e):de.set(Ae,[_e])}const we=[],ke=new Set;for(const _e of fe){if(_e.weight_used>0||q[_e.id]){we.push({type:"single",spool:_e});continue}const Ae=TK(_e);if(ke.has(Ae))continue;ke.add(Ae);const Ve=de.get(Ae);Ve.length===1?we.push({type:"single",spool:Ve[0]}):we.push({type:"group",key:Ae,spools:Ve,representative:Ve[0]})}return we},[fe,G,q]),I=Y===-1,F=oe.length,J=I?F||1:Y,xe=Math.max(1,Math.ceil(F/J)),he=I?0:Math.min(ee,xe-1),le=I?oe:oe.slice(he*J,(he+1)*J),Ce=()=>{const de=!G;U(de),L(new Set),z();try{localStorage.setItem("bambuddy-inventory-group",String(de))}catch{}},Ne=de=>{L(we=>{const ke=new Set(we);return ke.has(de)?ke.delete(de):ke.add(de),ke})},Ue=de=>{se(de),ae(0);try{localStorage.setItem("bambuddy-inventory-pageSize",String(de))}catch{}},He=()=>{c("active"),d("all"),f(""),x(""),g("all"),_(""),z()};return a.jsxs("div",{className:"p-4 md:p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(si,{className:"w-6 h-6 text-bambu-green"}),a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("inventory.title")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-9",children:(t("inventory.noSpools").split(".")[0],"")})]}),a.jsxs(Oe,{onClick:()=>i({spool:null}),children:[a.jsx(nr,{className:"w-4 h-4"}),t("inventory.addSpool")]})]}),T&&!ue&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(si,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalInventory")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Ec(T.totalWeight,!0)}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[T.totalSpools," ",T.totalSpools!==1?t("inventory.spools"):t("inventory.spool")]})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(HF,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalConsumed")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:Ec(T.totalConsumed,!0)}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.sinceTracking")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Ga,{className:"w-4 h-4 text-green-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.byMaterial")})]}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:B.map(([de,we])=>a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${Cet[de]||"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[de," ",a.jsx("span",{className:"opacity-70",children:Ec(we.weight,!0)})]},de))})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Dr,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.inPrinter")})]}),a.jsx("div",{className:"text-xl font-bold text-white",children:E}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.loadedInAms")})]}),a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(Mn,{className:"w-4 h-4 text-yellow-400"}),a.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.lowStock")})]}),a.jsx("div",{className:`text-xl font-bold ${T.lowStock>0?"text-yellow-400":"text-white"}`,children:T.lowStock}),a.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.lowStockThreshold")})]})]}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between",children:[a.jsxs("div",{className:"relative flex-1 max-w-md",children:[a.jsx(Er,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50"}),a.jsx("input",{type:"text",value:y,onChange:de=>{_(de.target.value),z()},placeholder:t("inventory.search"),className:"w-full pl-10 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),y&&a.jsx("button",{onClick:()=>{_(""),z()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Ut,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[N==="table"&&a.jsxs("button",{onClick:()=>D(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-bambu-gray border border-bambu-dark-tertiary rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t("inventory.configureColumns"),children:[a.jsx(pme,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.columns")})]}),a.jsxs("button",{onClick:Ce,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium border rounded-lg transition-colors ${G?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,title:t("inventory.groupSimilar"),children:[a.jsx(cfe,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.groupSimilar")})]}),a.jsxs("div",{className:"flex bg-bambu-dark-primary border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>A("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${N==="table"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(tge,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.table")})]}),a.jsxs("button",{onClick:()=>A("cards"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${N==="cards"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(wv,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden sm:inline",children:t("inventory.cards")})]})]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("button",{onClick:()=>{c("active"),z()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="active"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(si,{className:"w-3.5 h-3.5"}),t("inventory.active")]}),a.jsxs("button",{onClick:()=>{c("archived"),z()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="archived"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Fs,{className:"w-3.5 h-3.5"}),t("inventory.archived")]})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsx("button",{onClick:()=>{d("all"),z()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${u==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsxs("button",{onClick:()=>{d("used"),z()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${u==="used"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(Xn,{className:"w-3.5 h-3.5"}),t("inventory.used")]}),a.jsx("button",{onClick:()=>{d("new"),z()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${u==="new"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.new")})]}),a.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsx("button",{onClick:()=>{g("all"),z()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${v==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),a.jsx("button",{onClick:()=>{g("stock"),z()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${v==="stock"?"bg-amber-500/20 text-amber-400":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.stock")}),a.jsx("button",{onClick:()=>{g("configured"),z()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${v==="configured"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.configured")})]}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("select",{value:h,onChange:de=>{f(de.target.value),z()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${h?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.material")}),V.map(de=>a.jsx("option",{value:de,children:de},de))]}),a.jsxs("select",{value:p,onChange:de=>{x(de.target.value),z()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${p?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[a.jsx("option",{value:"",children:t("inventory.brand")}),te.map(de=>a.jsx("option",{value:de,children:de},de))]}),Q&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),a.jsxs("button",{onClick:He,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:[a.jsx(Ut,{className:"w-3.5 h-3.5"}),t("inventory.clearFilters")]})]}),a.jsxs("span",{className:"ml-auto text-xs text-bambu-gray",children:[fe.length," ",fe.length!==1?t("inventory.spools"):t("inventory.spool"),G&&F<fe.length&&` (${F} ${t("inventory.groupedRows")})`]})]}),ue?a.jsx("div",{className:"flex justify-center py-16",children:a.jsx(lt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):N==="cards"?le.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:le.map(de=>{if(de.type==="group"){const{key:Ve,spools:Te,representative:Ke}=de,je=Ke.rgba?`#${Ke.rgba.substring(0,6)}`:"#808080",qe=W.has(Ve);return a.jsxs("div",{className:"col-span-full",children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-green/30 hover:border-bambu-green transition-colors cursor-pointer",onClick:()=>Ne(Ve),children:[a.jsx("div",{className:"h-10 flex items-center px-4 gap-3",style:{backgroundColor:je},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:TO(Ke.color_name,Ke.rgba)||"-"})}),a.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(En,{className:`w-4 h-4 text-bambu-gray transition-transform ${qe?"":"-rotate-90"}`}),a.jsxs("div",{children:[a.jsxs("h3",{className:"font-semibold text-white",children:[Ke.material,Ke.subtype?` ${Ke.subtype}`:""]}),a.jsx("p",{className:"text-sm text-bambu-gray",children:Ke.brand||"-"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:Ec(Ke.label_weight)}),a.jsx("span",{className:"text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full",children:t("inventory.groupedSpools",{count:Te.length})})]})]})]}),qe&&a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mt-2 ml-4",children:Te.map(Re=>{const Pe=Math.max(0,Re.label_weight-Re.weight_used),Be=Re.label_weight>0?Pe/Re.label_weight*100:0,We=Re.rgba?`#${Re.rgba.substring(0,6)}`:"#808080";return a.jsx(MK,{spool:Re,remaining:Pe,pct:Be,colorStyle:We,onClick:()=>i({spool:Re}),t},Re.id)})})]},`group-${Ve}`)}const we=de.spool,ke=Math.max(0,we.label_weight-we.weight_used),_e=we.label_weight>0?ke/we.label_weight*100:0,Ae=we.rgba?`#${we.rgba.substring(0,6)}`:"#808080";return a.jsx(MK,{spool:we,remaining:ke,pct:_e,colorStyle:Ae,onClick:()=>i({spool:we}),t},we.id)})}),a.jsx(Eet,{pageIndex:he,pageSize:Y,totalRows:F,totalPages:xe,onPageChange:ae,onPageSizeChange:Ue,t})]}):a.jsx(PK,{hasFilters:Q,onAddSpool:()=>i({spool:null}),t}):le.length>0?a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30",children:[ie.map(de=>{const we=!!KE[de],ke=C?.column===de;return a.jsx("th",{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${de==="remaining"?"min-w-[150px]":""} ${we?"cursor-pointer hover:text-bambu-green transition-colors":""} ${ke?"text-bambu-green":"text-bambu-gray"}`,onClick:we?()=>me(de):void 0,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[Aet[de]?.(t)??de,we&&(ke?C.direction==="asc"?a.jsx(Lf,{className:"w-3 h-3"}):a.jsx(bb,{className:"w-3 h-3"}):a.jsx(OF,{className:"w-3 h-3 opacity-30"}))]})},de)}),a.jsx("th",{className:"text-right py-3 px-4 text-xs font-medium text-bambu-gray uppercase tracking-wide",children:t("common.actions")})]})}),a.jsx("tbody",{children:le.map(de=>{if(de.type==="group"){const{key:Ae,spools:Ve,representative:Te}=de,Ke=W.has(Ae),je=Math.max(0,Te.label_weight-Te.weight_used),qe=Te.label_weight>0?je/Te.label_weight*100:0;return a.jsx(Det,{spools:Ve,representative:Te,remaining:je,pct:qe,isExpanded:Ke,onToggle:()=>Ne(Ae),onEdit:Re=>i({spool:Re}),onArchive:Re=>o({type:"archive",spoolId:Re}),onDelete:Re=>o({type:"delete",spoolId:Re}),visibleColumns:ie,assignmentMap:q,currencySymbol:O,dateFormat:ye,t,onSyncWeight:K},`group-${Ae}`)}const we=de.spool,ke=Math.max(0,we.label_weight-we.weight_used),_e=we.label_weight>0?ke/we.label_weight*100:0;return a.jsx(kse,{spool:we,remaining:ke,pct:_e,onEdit:()=>i({spool:we}),onRestore:()=>$.mutate(we.id),onArchive:()=>o({type:"archive",spoolId:we.id}),onDelete:()=>o({type:"delete",spoolId:we.id}),visibleColumns:ie,assignmentMap:q,currencySymbol:O,dateFormat:ye,t,onSyncWeight:K},we.id)})})]})}),a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-bambu-dark-tertiary/50 border-t border-bambu-dark-tertiary text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:I?`${F} ${t(F!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[t("inventory.showing")," ",he*J+1," ",t("inventory.to")," ",Math.min((he+1)*J,F)," ",t("inventory.of")," ",F," ",t("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:t("inventory.show")}),a.jsxs("select",{value:Y,onChange:de=>Ue(Number(de.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(de=>a.jsx("option",{value:de,children:de},de)),a.jsx("option",{value:-1,children:t("inventory.all")})]}),!I&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>ae(0),disabled:he===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"First page",children:a.jsx(RY,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>ae(de=>Math.max(0,de-1)),disabled:he===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(Jl,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[t("inventory.page")," ",he+1," ",t("inventory.of")," ",xe]}),a.jsx("button",{onClick:()=>ae(de=>Math.min(xe-1,de+1)),disabled:he>=xe-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(pi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>ae(xe-1),disabled:he>=xe-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Last page",children:a.jsx(FY,{className:"w-4 h-4"})})]})]})]})]}):a.jsx(PK,{hasFilters:Q,onAddSpool:()=>i({spool:null}),t}),r!==null&&a.jsx(wet,{isOpen:!0,onClose:()=>i(null),spool:r.spool,currencySymbol:O}),s&&a.jsx(Sn,{title:s.type==="delete"?t("common.delete"):t("inventory.archive"),message:s.type==="delete"?t("inventory.deleteConfirm"):t("inventory.archiveConfirm"),confirmText:s.type==="delete"?t("common.delete"):t("inventory.archive"),variant:s.type==="delete"?"danger":"warning",onConfirm:()=>{s.type==="delete"?be.mutate(s.spoolId):Ee.mutate(s.spoolId),o(null)},onCancel:()=>o(null)}),a.jsx(_et,{isOpen:M,onClose:()=>D(!1),columns:k,defaultColumns:v1,onSave:ne})]})}function Eet({pageIndex:t,pageSize:e,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:s,t:o}){const l=e===-1;if(r<=1&&!l)return null;const c=l?n||1:e;return a.jsxs("div",{className:"flex items-center justify-between pt-2 text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:l?`${n} ${o(n!==1?"inventory.spools":"inventory.spool")}`:a.jsxs(a.Fragment,{children:[o("inventory.showing")," ",t*c+1," ",o("inventory.to")," ",Math.min((t+1)*c,n)," ",o("inventory.of")," ",n," ",o("inventory.spools")]})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-gray",children:o("inventory.show")}),a.jsxs("select",{value:e,onChange:u=>s(Number(u.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(u=>a.jsx("option",{value:u,children:u},u)),a.jsx("option",{value:-1,children:o("inventory.all")})]}),!l&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>i(0),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(RY,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(Math.max(0,t-1)),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(Jl,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[o("inventory.page")," ",t+1," ",o("inventory.of")," ",r]}),a.jsx("button",{onClick:()=>i(Math.min(r-1,t+1)),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(pi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>i(r-1),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a.jsx(FY,{className:"w-4 h-4"})})]})]})]})}function MK({spool:t,remaining:e,pct:n,colorStyle:r,onClick:i,t:s}){return a.jsxs("div",{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors cursor-pointer ${t.archived_at?"opacity-50":""}`,onClick:i,children:[a.jsx("div",{className:"h-14 flex items-center justify-center",style:{backgroundColor:r},children:a.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:TO(t.color_name,t.rgba)||"-"})}),a.jsxs("div",{className:"p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{children:[a.jsxs("h3",{className:"font-semibold text-white",children:[t.material,t.subtype?` ${t.subtype}`:""]}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t.brand||"-"})]}),a.jsxs("span",{className:"text-xs font-mono text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:["#",t.id]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[a.jsx("span",{children:s("inventory.remaining")}),a.jsxs("span",{children:[Math.round(n),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full ${n>50?"bg-bambu-green":n>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(n,100)}%`}})}),a.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(e),"g"]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[s("inventory.labelWeight"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:Ec(t.label_weight)})]}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-bambu-gray/60",children:[s("inventory.weightUsed"),": "]}),a.jsx("span",{className:"text-bambu-gray",children:t.weight_used>0?Ec(t.weight_used):"-"})]})]}),t.note&&a.jsx("div",{className:"text-xs text-bambu-gray/60 pt-2 border-t border-bambu-dark-tertiary truncate",title:t.note,children:t.note})]})]})}function kse({spool:t,remaining:e,pct:n,onEdit:r,onRestore:i,onArchive:s,onDelete:o,visibleColumns:l,assignmentMap:c,currencySymbol:u,dateFormat:d,t:h,onSyncWeight:f}){return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer ${t.archived_at?"opacity-50":""}`,onClick:r,children:[l.map(p=>a.jsx("td",{className:"py-3 px-4",children:yF[p]?.({spool:t,remaining:e,pct:n,assignmentMap:c,currencySymbol:u,dateFormat:d,t:h,onSyncWeight:f})},p)),a.jsx("td",{className:"py-3 px-4",children:a.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:p=>p.stopPropagation(),children:[a.jsx("button",{onClick:r,className:"p-1.5 text-bambu-gray hover:text-white rounded transition-colors",title:h("inventory.editSpool"),children:a.jsx(af,{className:"w-4 h-4"})}),t.archived_at?a.jsx("button",{onClick:i,className:"p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors",title:h("inventory.restore"),children:a.jsx(co,{className:"w-4 h-4"})}):a.jsx("button",{onClick:s,className:"p-1.5 text-bambu-gray hover:text-yellow-400 rounded transition-colors",title:h("inventory.archive"),children:a.jsx(Fs,{className:"w-4 h-4"})}),a.jsx("button",{onClick:o,className:"p-1.5 text-bambu-gray hover:text-red-400 rounded transition-colors",title:h("common.delete"),children:a.jsx(Xt,{className:"w-4 h-4"})})]})})]})}function Det({spools:t,representative:e,remaining:n,pct:r,isExpanded:i,onToggle:s,onEdit:o,onArchive:l,onDelete:c,visibleColumns:u,assignmentMap:d,currencySymbol:h,dateFormat:f,t:p,onSyncWeight:x}){return a.jsxs(a.Fragment,{children:[a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer bg-bambu-green/5",onClick:s,children:[u.map((v,g)=>a.jsx("td",{className:"py-3 px-4",children:g===0?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(En,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"":"-rotate-90"}`}),yF[v]?.({spool:e,remaining:n,pct:r,assignmentMap:d,currencySymbol:h,dateFormat:f,t:p,onSyncWeight:x})]}):v==="id"?a.jsx("span",{className:"text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full",children:p("inventory.groupedSpools",{count:t.length})}):yF[v]?.({spool:e,remaining:n,pct:r,assignmentMap:d,currencySymbol:h,dateFormat:f,t:p,onSyncWeight:x})},v)),a.jsx("td",{className:"py-3 px-4",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:t.map(v=>`#${v.id}`).join(", ")})})]}),i&&t.map(v=>{const g=Math.max(0,v.label_weight-v.weight_used),y=v.label_weight>0?g/v.label_weight*100:0;return a.jsx(kse,{spool:v,remaining:g,pct:y,onEdit:()=>o(v),onRestore:()=>{},onArchive:()=>l(v.id),onDelete:()=>c(v.id),visibleColumns:u,assignmentMap:d,currencySymbol:h,dateFormat:f,t:p,onSyncWeight:x},v.id)})]})}function PK({hasFilters:t,onAddSpool:e,t:n}){return a.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[a.jsxs("div",{className:"relative mb-6",children:[a.jsx("div",{className:"absolute inset-0 -m-4 bg-bambu-green/5 rounded-full blur-2xl"}),a.jsxs("div",{className:"relative flex items-center justify-center w-24 h-24 rounded-2xl bg-gradient-to-br from-bambu-dark-secondary to-bambu-dark-tertiary border border-bambu-dark-tertiary shadow-lg",children:[a.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 rounded-full bg-bambu-green/30"}),a.jsx("div",{className:"absolute -bottom-2 -left-2 w-2 h-2 rounded-full bg-bambu-green/20"}),t?a.jsx(Er,{className:"w-10 h-10 text-bambu-gray/40",strokeWidth:1.5}):a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-14 h-14 rounded-full border-4 border-bambu-gray/20 flex items-center justify-center",children:a.jsx("div",{className:"w-6 h-6 rounded-full bg-bambu-gray/10 border-2 border-bambu-gray/20"})}),a.jsx("div",{className:"absolute -bottom-1 -right-1 w-6 h-6 rounded-full bg-bambu-green flex items-center justify-center shadow-md",children:a.jsx("span",{className:"text-white text-lg font-bold leading-none",children:"+"})})]})]})]}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2 text-center",children:t?n("inventory.noSpoolsMatch"):n("inventory.noSpools").split(".")[0]}),a.jsx("p",{className:"text-sm text-bambu-gray text-center max-w-sm mb-6",children:n(t?"inventory.noSpoolsMatchDesc":"inventory.noSpools")}),!t&&a.jsxs(Oe,{onClick:e,children:[a.jsx(si,{className:"w-4 h-4"}),n("inventory.addSpool")]})]})}const jK=["DEBUG","INFO","WARNING","ERROR"],YE={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},Ret={DEBUG:Xk,INFO:to,WARNING:Mn,ERROR:qa};function Fet(){const t=Qt(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[h,f]=w.useState(!1),p=w.useRef(null),{data:x,isLoading:v,refetch:g}=Je({queryKey:["application-logs",l,s],queryFn:()=>rb.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:h?2e3:!1,enabled:u});w.useEffect(()=>{u||f(!1)},[u]);const y=ut({mutationFn:()=>rb.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&p.current&&x?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[x?.entries,e]);const _=k=>{i(R=>{const M=new Set(R);return M.has(k)?M.delete(k):M.add(k),M})},N=k=>{const R=k.split(" ");return R.length>=2?R[1]:k},A=w.useMemo(()=>x?.entries??[],[x?.entries]),C=w.useMemo(()=>[...A].reverse(),[A]),j=({level:k})=>{const R=Ret[k]||to;return a.jsx(R,{className:`w-3.5 h-3.5 ${YE[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(Xk,{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 - ${x?.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(Sl,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(En,{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(),f(!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(_l,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:k=>{k.stopPropagation(),f(!0),g()},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(lo,{className:"w-4 h-4"}),"Start"]}),a.jsxs("button",{onClick:()=>y.mutate(),disabled:y.isPending||A.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(Xt,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>g(),disabled:v,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(wr,{className:`w-4 h-4 ${v?"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:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Er,{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(Ut,{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"}),jK.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===jK.length-1?"rounded-r":""} ${l===k?`${YE[k]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:k},k))]})]})]}),a.jsx("div",{ref:p,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:A.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:C.map((k,R)=>{const M=r.has(R),D=k.message.includes(`
  8316. `);return a.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${M?"bg-bambu-dark-secondary/30":""}`,onClick:()=>D&&_(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(j,{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 ${YE[k.level]||"text-white/80"} ${!M&&D?"truncate":""}`,children:M?a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:k.message}):k.message.split(`
  8317. `)[0]}),D&&a.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:M?a.jsx(Sl,{className:"w-3.5 h-3.5"}):a.jsx(En,{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 Let(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 Pa({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 EK({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 sh({title:t,icon:e,children:n}){return a.jsxs(Ct,{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 Oet(){const{t}=Et(),e=Qt(),[n,r]=w.useState(null),[i,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:h}=Je({queryKey:["systemInfo"],queryFn:ge.getSystemInfo,refetchInterval:3e4}),{data:f}=Je({queryKey:["debugLogging"],queryFn:rb.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=Je({queryKey:["settings"],queryFn:ge.getSettings}),{data:x}=Je({queryKey:["library-stats"],queryFn:ge.getLibraryStats}),v=p?.time_format||"system",g=async()=>{l(!0);try{const A=await rb.setDebugLogging(!f?.enabled);e.setQueryData(["debugLogging"],A)}catch(A){console.error("Failed to toggle debug logging:",A)}finally{l(!1)}},y=async()=>{r(null),s(!0);try{await rb.downloadSupportBundle()}catch(A){r(A instanceof Error?A.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 _=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(wr,{className:`w-4 h-4 ${h?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),a.jsx(sh,{title:t("system.application","Application"),icon:qm,children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(Pa,{icon:qm,label:t("system.version","Version"),value:`v${c.app.version}`}),a.jsx(Pa,{icon:Xn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),a.jsx(Pa,{icon:qm,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),a.jsx(sh,{title:t("support.title","Support & Troubleshooting"),icon:pfe,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 ${f?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(Xk,{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:[f?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),f?.enabled&&f.duration_seconds!==null&&a.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(f.duration_seconds/60),"m ",f.duration_seconds%60,"s)"]})]})]})]}),a.jsxs("button",{onClick:g,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${f?.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"}),f?.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(ba,{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:y,disabled:i||!f?.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:f?.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}),!f?.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 and 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.jsxs("li",{children:["• ",t("support.notItem7","IP addresses")]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","Email addresses in logs are replaced with [EMAIL], printer names with [PRINTER], serial numbers with [SERIAL], and IP addresses with [IP].")})]}),a.jsx(Fet,{})]})}),a.jsxs(sh,{title:t("system.database","Database"),icon:Dc,children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[a.jsx(Pa,{icon:Fs,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),a.jsx(Pa,{icon:yb,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),a.jsx(Pa,{icon:ii,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),a.jsx(Pa,{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(Pa,{icon:Dr,label:t("system.printers","Printers"),value:c.database.printers}),a.jsx(Pa,{icon:rC,label:t("system.filaments","Filaments"),value:c.database.filaments}),a.jsx(Pa,{icon:xs,label:t("system.projects","Projects"),value:c.database.projects}),a.jsx(Pa,{icon:bl,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(Pa,{icon:Xn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),a.jsx(Pa,{icon:Fs,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),a.jsxs(sh,{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(A=>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:A.name})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[a.jsx("span",{children:A.model}),a.jsx("span",{className:`px-2 py-0.5 rounded ${A.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":A.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:A.state})]})]},A.id))}):a.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),a.jsx(sh,{title:t("system.storage","Storage"),icon:Jb,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(EK,{percent:c.storage.disk_percent_used,color:_}),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(Pa,{icon:Fs,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),a.jsx(Pa,{icon:Dc,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&a.jsx(Pa,{icon:nc,label:t("system.fileManagerStorage","File Manager"),value:Let(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.jsx(sh,{title:t("system.memory","Memory"),icon:Wfe,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(EK,{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(sh,{title:t("system.cpu","CPU"),icon:uS,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Pa,{icon:uS,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),a.jsx(Pa,{icon:uS,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),a.jsx(sh,{title:t("system.systemDetails","System Details"),icon:qm,children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(Pa,{icon:qm,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),a.jsx(Pa,{icon:uS,label:t("system.architecture","Architecture"),value:c.system.architecture}),a.jsx(Pa,{icon:qm,label:t("system.python","Python"),value:c.system.python_version}),a.jsx(Pa,{icon:Xn,label:t("system.bootTime","Boot Time"),value:Uf(c.system.boot_time,v)})]})})]})}function Iet(){const t=jl(),{t:e}=Et(),{login:n}=Rr(),{showToast:r}=dn(),{mode:i}=lp(),[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(!1),[h,f]=w.useState(""),{data:p}=Je({queryKey:["advancedAuthStatus"],queryFn:()=>ge.getAdvancedAuthStatus()}),x=ut({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:_=>{r(_.message||e("login.loginFailed"),"error")}}),v=ut({mutationFn:_=>ge.forgotPassword({email:_}),onSuccess:_=>{r(_.message,"success"),d(!1),f("")},onError:_=>{r(_.message,"error")}}),g=_=>{if(_.preventDefault(),!s||!l){r(e("login.enterCredentials"),"error");return}x.mutate()},y=_=>{if(_.preventDefault(),!h){r("Please enter your email address","error");return}v.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:g,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:p?.advanced_auth_enabled?e("login.usernameOrEmail")||"Username or Email":e("login.username")}),a.jsx("input",{id:"username",type:"text",required:!0,value:s,onChange:_=>o(_.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:p?.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:_=>c(_.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:x.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:x.isPending?e("login.signingIn"):e("login.signIn")})}),p?.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(Ct,{className:"w-full max-w-md",onClick:_=>_.stopPropagation(),children:[a.jsx(Vn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(k0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),a.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{d(!1),f("")},children:a.jsx(Ut,{className:"w-5 h-5"})})]})}),a.jsx(Tt,{children:p?.advanced_auth_enabled?a.jsxs("form",{onSubmit:y,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:_=>f(_.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(Oe,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{d(!1),f("")},children:e("login.cancel")||"Cancel"}),a.jsx(Oe,{type:"submit",className:"flex-1",disabled:v.isPending,children:v.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(Oe,{variant:"secondary",className:"w-full",onClick:()=>d(!1),children:e("login.gotIt")})]})})]})})]})}function zet(){const t=jl(),{t:e}=Et(),{showToast:n}=dn(),{mode:r}=lp(),{refreshAuth:i}=Rr(),[s,o]=w.useState(!1),[l,c]=w.useState(""),[u,d]=w.useState(""),[h,f]=w.useState(""),p=ut({mutationFn:()=>ge.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?u:void 0}),onSuccess:async v=>{await i(),v.auth_enabled?v.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:v=>{n(v.message,"error")}}),x=v=>{if(v.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}}p.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:x,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:v=>o(v.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(to,{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:v=>c(v.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:v=>d(v.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:v=>f(v.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:p.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:p.isPending?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function Uet(){const t=w.useRef(null),e=w.useRef(null),n=Qt(),[r,i]=w.useState(!1),s=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),h=w.useRef(()=>{}),f=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const _=()=>{const N=u.current.shift();N?requestAnimationFrame(()=>{h.current(N),u.current.length>0?setTimeout(_,16):d.current=!1}):d.current=!1};_()},[]),p=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,A=new WebSocket(N);let C=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),C=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=j=>{try{const k=JSON.parse(j.data);k.type==="printer_status"&&k.printer_id!==void 0&&k.data?h.current(k):(u.current.push(k),f())}catch{}},A.onclose=j=>{console.log("[WebSocket] Closed",j.code,j.reason),C&&(clearInterval(C),C=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},A.onerror=j=>{console.error("[WebSocket] Error",j),A.close()},t.current=A},[f]),x=w.useCallback((_,N)=>{const A=l.current.get(_)||{};l.current.set(_,{...A,...N}),c.current||(c.current=window.setTimeout(()=>{const C=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{C.forEach((j,k)=>{n.setQueryData(["printerStatus",k],R=>{const M={...R,...j};return M.wifi_signal==null&&R?.wifi_signal!=null&&(M.wifi_signal=R.wifi_signal),M})})})},100))},[n]),v=w.useCallback(_=>{s.current.add(_),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const N=Array.from(s.current);s.current.clear(),o.current=null;let A=0;N.forEach(C=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[C]})})},A),A+=500})},3e3)},[n]),g=w.useCallback(_=>{switch(_.type){case"printer_status":_.printer_id!==void 0&&_.data&&x(_.printer_id,_.data);break;case"print_start":_.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",_.printer_id]});break;case"print_complete":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:_.printer_id,printer_name:_.printer_name,message:_.message}}));break;case"spool_auto_assigned":v("inventory-spools"),v("spool-assignments");break;case"spool_usage_logged":v("inventory-spools");break;case"unknown_tag":window.dispatchEvent(new CustomEvent("unknown-tag",{detail:{printer_id:_.printer_id,ams_id:_.ams_id,tray_id:_.tray_id,tag_uid:_.tag_uid,tray_uuid:_.tray_uuid}}));break;case"background_dispatch":window.dispatchEvent(new CustomEvent("background-dispatch",{detail:_.data||{}}));break;case"spoolbuddy_weight":window.dispatchEvent(new CustomEvent("spoolbuddy-weight",{detail:_}));break;case"spoolbuddy_tag_matched":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-matched",{detail:_})),v("inventory-spools");break;case"spoolbuddy_unknown_tag":window.dispatchEvent(new CustomEvent("spoolbuddy-unknown-tag",{detail:_}));break;case"spoolbuddy_tag_removed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-removed",{detail:_}));break;case"spoolbuddy_tag_written":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-written",{detail:_})),v("inventory-spools");break;case"spoolbuddy_tag_write_failed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-write-failed",{detail:_}));break;case"spoolbuddy_online":window.dispatchEvent(new CustomEvent("spoolbuddy-online",{detail:_}));break;case"spoolbuddy_offline":window.dispatchEvent(new CustomEvent("spoolbuddy-offline",{detail:_}));break}},[n,v,x]);w.useEffect(()=>{h.current=g},[g]),w.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const y=w.useCallback(_=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(_))},[]);return{isConnected:r,sendMessage:y}}function Bet({selectedPrinterId:t,onPrinterChange:e,deviceOnline:n}){const{t:r}=Et(),[i,s]=w.useState(new Date),{data:o=[]}=Je({queryKey:["printers"],queryFn:()=>ge.getPrinters()}),l=Qb({queries:o.map(d=>({queryKey:["printerStatus",d.id],queryFn:()=>ge.getPrinterStatus(d.id),refetchInterval:1e4}))}),c=w.useMemo(()=>o.filter((d,h)=>l[h]?.data?.connected),[o,l]);w.useEffect(()=>{const d=c.some(h=>h.id===t);(!t||!d)&&c.length>0&&e(c[0].id)},[c,t,e]);const{data:u}=Je({queryKey:["settings"],queryFn:ge.getSettings});return w.useEffect(()=>{const d=setInterval(()=>s(new Date),1e3);return()=>clearInterval(d)},[]),a.jsxs("div",{className:"h-12 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-3 gap-4 shrink-0",children:[a.jsx("div",{className:"flex items-center shrink-0",children:a.jsx("img",{src:"/img/spoolbuddy_logo_dark_small.png",alt:"SpoolBuddy",width:113,height:28,className:"h-7 w-auto"})}),a.jsx("div",{className:"flex-1 flex justify-center",children:a.jsx("select",{value:t??"",onChange:d=>e(Number(d.target.value)),className:"bg-bambu-dark text-white text-base px-4 py-2 rounded border border-bambu-dark-tertiary focus:outline-none focus:border-bambu-green min-w-[180px]",children:c.length===0?a.jsx("option",{value:"",children:r("spoolbuddy.status.noPrinters","No printers online")}):c.map(d=>a.jsx("option",{value:d.id,children:d.name},d.id))})}),a.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[a.jsx("div",{className:"flex items-center",title:n?r("spoolbuddy.status.backend","Backend"):r("spoolbuddy.status.offline","Offline"),children:n?a.jsx("div",{className:"flex items-end gap-0.5 h-4",children:[1,2,3,4].map(d=>a.jsx("div",{className:`w-1 rounded-sm ${d<=4?"bg-white":"bg-bambu-dark-tertiary"}`,style:{height:`${d*4}px`}},d))}):a.jsx(Xh,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:`w-3 h-3 rounded-full ${n?"bg-bambu-green shadow-[0_0_6px_rgba(34,197,94,0.5)]":"bg-bambu-gray"}`}),a.jsx("span",{className:"text-sm text-white/50",children:n?r("spoolbuddy.status.backend","Backend"):r("spoolbuddy.status.offline","Offline")})]}),a.jsx("span",{className:"text-white/50 text-base font-mono min-w-[50px] text-right",children:JY(i,u?.time_format||"system")})]})]})}const Het=[{to:"/spoolbuddy",labelKey:"spoolbuddy.nav.dashboard",fallback:"Dashboard",icon:a.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})})},{to:"/spoolbuddy/ams",labelKey:"spoolbuddy.nav.ams",fallback:"AMS",icon:a.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})},{to:"/spoolbuddy/write-tag",labelKey:"spoolbuddy.nav.writeTag",fallback:"Write",icon:a.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.288 15.038a5.25 5.25 0 017.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0"}),a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12.53 18.22l-.53.53-.53-.53a.75.75 0 011.06 0z"})]})},{to:"/spoolbuddy/settings",labelKey:"spoolbuddy.nav.settings",fallback:"Settings",icon:a.jsxs("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}];function $et(){const{t}=Et();return a.jsx("nav",{className:"h-14 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-stretch shrink-0",children:Het.map(e=>a.jsxs(Gg,{to:e.to,end:e.to==="/spoolbuddy",className:({isActive:n})=>`flex-1 flex flex-col items-center justify-center gap-1 transition-colors ${n?"text-bambu-green bg-bambu-dark":"text-white/50 hover:text-white/70 hover:bg-bambu-dark-tertiary"}`,children:[e.icon,a.jsx("span",{className:"text-xs font-medium",children:t(e.labelKey,e.fallback)})]},e.to))})}function Vet({alert:t}){const{t:e}=Et(),n=t?t.type==="error"?"bg-red-500":t.type==="warning"?"bg-amber-500":"bg-bambu-green":"bg-bambu-green",r=t?t.type==="error"?"border-red-500":t.type==="warning"?"border-amber-500":"border-bambu-dark-tertiary":"border-bambu-dark-tertiary";return a.jsxs("div",{className:`h-9 bg-bambu-dark-secondary border-t-2 ${r} flex items-center px-3 gap-3 shrink-0`,children:[a.jsx("div",{className:`w-3.5 h-3.5 rounded-full ${n} animate-pulse`}),a.jsx("div",{className:"flex-1 text-sm text-white/50 truncate",children:t?a.jsx("span",{children:t.message}):a.jsx("span",{className:"text-bambu-green",children:e("spoolbuddy.status.systemReady","System Ready")})})]})}const qet={weight:null,weightStable:!1,rawAdc:null,matchedSpool:null,unknownTagUid:null,deviceOnline:!1,deviceId:null};function Get(t,e){switch(e.type){case"WEIGHT_UPDATE":return{...t,weight:e.weight,weightStable:e.stable,rawAdc:e.rawAdc,deviceId:e.deviceId,deviceOnline:!0};case"TAG_MATCHED":return{...t,matchedSpool:e.spool,unknownTagUid:null,deviceId:e.deviceId};case"UNKNOWN_TAG":return{...t,matchedSpool:null,unknownTagUid:e.tagUid,deviceId:e.deviceId};case"TAG_REMOVED":return{...t,matchedSpool:null,unknownTagUid:null};case"DEVICE_ONLINE":return{...t,deviceOnline:!0,deviceId:e.deviceId};case"DEVICE_OFFLINE":return{...t,deviceOnline:!1,weight:null,weightStable:!1,rawAdc:null};default:return t}}function Wet(){const[t,e]=w.useReducer(Get,qet),n=w.useCallback(d=>{const h=d.detail;e({type:"WEIGHT_UPDATE",weight:h.weight_grams??h.data?.weight_grams,stable:h.stable??h.data?.stable??!1,rawAdc:h.raw_adc??h.data?.raw_adc??null,deviceId:h.device_id??h.data?.device_id??""})},[]),r=w.useCallback(d=>{const h=d.detail,f=h.spool??h.data?.spool;f&&e({type:"TAG_MATCHED",spool:{id:f.id,tag_uid:h.tag_uid??h.data?.tag_uid??"",material:f.material??"",subtype:f.subtype??null,color_name:f.color_name??null,rgba:f.rgba??null,brand:f.brand??null,label_weight:f.label_weight??0,core_weight:f.core_weight??0,weight_used:f.weight_used??0},deviceId:h.device_id??h.data?.device_id??""})},[]),i=w.useCallback(d=>{const h=d.detail;e({type:"UNKNOWN_TAG",tagUid:h.tag_uid??h.data?.tag_uid??"",deviceId:h.device_id??h.data?.device_id??""})},[]),s=w.useCallback(d=>{const h=d.detail;e({type:"TAG_REMOVED",deviceId:h.device_id??h.data?.device_id??""})},[]),o=w.useCallback(d=>{const h=d.detail;e({type:"DEVICE_ONLINE",deviceId:h.device_id??h.data?.device_id??""})},[]),l=w.useCallback(d=>{const h=d.detail;e({type:"DEVICE_OFFLINE",deviceId:h.device_id??h.data?.device_id??""})},[]);w.useEffect(()=>(window.addEventListener("spoolbuddy-weight",n),window.addEventListener("spoolbuddy-tag-matched",r),window.addEventListener("spoolbuddy-unknown-tag",i),window.addEventListener("spoolbuddy-tag-removed",s),window.addEventListener("spoolbuddy-online",o),window.addEventListener("spoolbuddy-offline",l),()=>{window.removeEventListener("spoolbuddy-weight",n),window.removeEventListener("spoolbuddy-tag-matched",r),window.removeEventListener("spoolbuddy-unknown-tag",i),window.removeEventListener("spoolbuddy-tag-removed",s),window.removeEventListener("spoolbuddy-online",o),window.removeEventListener("spoolbuddy-offline",l)}),[n,r,i,s,o,l]);const c=t.matchedSpool?Math.max(0,t.matchedSpool.label_weight-t.matchedSpool.weight_used):null,u=t.weight!==null&&t.matchedSpool?Math.max(0,t.weight-t.matchedSpool.core_weight):null;return{...t,remainingWeight:c,netWeight:u}}var w1={exports:{}};var Ket=w1.exports,DK;function Yet(){return DK||(DK=1,(function(t,e){(function(n,r){t.exports=r(sp())})(Ket,(function(n){return(function(){var r={981:function(){typeof Element>"u"||"remove"in Element.prototype||(Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)}),typeof self<"u"&&"document"in self&&((!("classList"in document.createElement("_"))||document.createElementNS&&!("classList"in document.createElementNS("http://www.w3.org/2000/svg","g")))&&(function(l){if("Element"in l){var c="classList",u="prototype",d=l.Element[u],h=Object,f=String[u].trim||function(){return this.replace(/^\s+|\s+$/g,"")},p=Array[u].indexOf||function(A){for(var C=0,j=this.length;C<j;C++)if(C in this&&this[C]===A)return C;return-1},x=function(A,C){this.name=A,this.code=DOMException[A],this.message=C},v=function(A,C){if(C==="")throw new x("SYNTAX_ERR","The token must not be empty.");if(/\s/.test(C))throw new x("INVALID_CHARACTER_ERR","The token must not contain space characters.");return p.call(A,C)},g=function(A){for(var C=f.call(A.getAttribute("class")||""),j=C?C.split(/\s+/):[],k=0,R=j.length;k<R;k++)this.push(j[k]);this._updateClassName=function(){A.setAttribute("class",this.toString())}},y=g[u]=[],_=function(){return new g(this)};if(x[u]=Error[u],y.item=function(A){return this[A]||null},y.contains=function(A){return~v(this,A+"")},y.add=function(){var A,C=arguments,j=0,k=C.length,R=!1;do~v(this,A=C[j]+"")||(this.push(A),R=!0);while(++j<k);R&&this._updateClassName()},y.remove=function(){var A,C,j=arguments,k=0,R=j.length,M=!1;do for(C=v(this,A=j[k]+"");~C;)this.splice(C,1),M=!0,C=v(this,A);while(++k<R);M&&this._updateClassName()},y.toggle=function(A,C){var j=this.contains(A),k=j?C!==!0&&"remove":C!==!1&&"add";return k&&this[k](A),C===!0||C===!1?C:!j},y.replace=function(A,C){var j=v(A+"");~j&&(this.splice(j,1,C),this._updateClassName())},y.toString=function(){return this.join(" ")},h.defineProperty){var N={get:_,enumerable:!0,configurable:!0};try{h.defineProperty(d,c,N)}catch(A){A.number!==void 0&&A.number!==-2146823252||(N.enumerable=!1,h.defineProperty(d,c,N))}}else h[u].__defineGetter__&&d.__defineGetter__(c,_)}})(self),(function(){var l=document.createElement("_");if(l.classList.add("c1","c2"),!l.classList.contains("c2")){var c=function(d){var h=DOMTokenList.prototype[d];DOMTokenList.prototype[d]=function(f){var p,x=arguments.length;for(p=0;p<x;p++)f=arguments[p],h.call(this,f)}};c("add"),c("remove")}if(l.classList.toggle("c3",!1),l.classList.contains("c3")){var u=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(d,h){return 1 in arguments&&!this.contains(d)==!h?h:u.call(this,d)}}"replace"in document.createElement("_").classList||(DOMTokenList.prototype.replace=function(d,h){var f=this.toString().split(" "),p=f.indexOf(d+"");~p&&(f=f.slice(p),this.remove.apply(this,f),this.add(h),this.add.apply(this,f.slice(1)))}),l=null})())},548:function(l){l.exports=(function(){var c={9306:function($,K,T){var E=T(4901),O=T(6823),q=TypeError;$.exports=function(B){if(E(B))return B;throw new q(O(B)+" is not a function")}},5548:function($,K,T){var E=T(3517),O=T(6823),q=TypeError;$.exports=function(B){if(E(B))return B;throw new q(O(B)+" is not a constructor")}},3506:function($,K,T){var E=T(3925),O=String,q=TypeError;$.exports=function(B){if(E(B))return B;throw new q("Can't set "+O(B)+" as a prototype")}},6469:function($,K,T){var E=T(8227),O=T(2360),q=T(4913).f,B=E("unscopables"),re=Array.prototype;re[B]===void 0&&q(re,B,{configurable:!0,value:O(null)}),$.exports=function(z){re[B][z]=!0}},7829:function($,K,T){var E=T(8183).charAt;$.exports=function(O,q,B){return q+(B?E(O,q).length:1)}},8551:function($,K,T){var E=T(34),O=String,q=TypeError;$.exports=function(B){if(E(B))return B;throw new q(O(B)+" is not an object")}},235:function($,K,T){var E=T(9213).forEach,O=T(4598)("forEach");$.exports=O?[].forEach:function(q){return E(this,q,arguments.length>1?arguments[1]:void 0)}},7916:function($,K,T){var E=T(6080),O=T(9565),q=T(8981),B=T(6319),re=T(4209),z=T(3517),V=T(6198),te=T(4659),Q=T(4527),ne=T(81),ie=T(851),me=Array;$.exports=function(fe){var oe=q(fe),I=z(this),F=arguments.length,J=F>1?arguments[1]:void 0,xe=J!==void 0;xe&&(J=E(J,F>2?arguments[2]:void 0));var he,le,Ce,Ne,Ue,He,de=ie(oe),we=0;if(!de||this===me&&re(de))for(he=V(oe),le=I?new this(he):me(he);he>we;we++)He=xe?J(oe[we],we):oe[we],te(le,we,He);else for(le=I?new this:[],Ue=(Ne=ne(oe,de)).next;!(Ce=O(Ue,Ne)).done;we++)He=xe?B(Ne,J,[Ce.value,we],!0):Ce.value,te(le,we,He);return Q(le,we),le}},9617:function($,K,T){var E=T(5397),O=T(5610),q=T(6198),B=function(re){return function(z,V,te){var Q=E(z),ne=q(Q);if(ne===0)return!re&&-1;var ie,me=O(te,ne);if(re&&V!=V){for(;ne>me;)if((ie=Q[me++])!=ie)return!0}else for(;ne>me;me++)if((re||me in Q)&&Q[me]===V)return re||me||0;return!re&&-1}};$.exports={includes:B(!0),indexOf:B(!1)}},9213:function($,K,T){var E=T(6080),O=T(7055),q=T(8981),B=T(6198),re=T(1469),z=T(4659),V=function(te){var Q=te===1,ne=te===2,ie=te===3,me=te===4,fe=te===6,oe=te===7,I=te===5||fe;return function(F,J,xe){for(var he,le,Ce=q(F),Ne=O(Ce),Ue=B(Ne),He=E(J,xe),de=0,we=0,ke=Q?re(F,Ue):ne||oe?re(F,0):void 0;Ue>de;de++)if((I||de in Ne)&&(le=He(he=Ne[de],de,Ce),te))if(Q)z(ke,de,le);else if(le)switch(te){case 3:return!0;case 5:return he;case 6:return de;case 2:z(ke,we++,he)}else switch(te){case 4:return!1;case 7:z(ke,we++,he)}return fe?-1:ie||me?me:ke}};$.exports={forEach:V(0),map:V(1),filter:V(2),some:V(3),every:V(4),find:V(5),findIndex:V(6),filterReject:V(7)}},597:function($,K,T){var E=T(9039),O=T(8227),q=T(9519),B=O("species");$.exports=function(re){return q>=51||!E((function(){var z=[];return(z.constructor={})[B]=function(){return{foo:1}},z[re](Boolean).foo!==1}))}},4598:function($,K,T){var E=T(9039);$.exports=function(O,q){var B=[][O];return!!B&&E((function(){B.call(null,q||function(){return 1},1)}))}},926:function($,K,T){var E=T(9306),O=T(8981),q=T(7055),B=T(6198),re=TypeError,z="Reduce of empty array with no initial value",V=function(te){return function(Q,ne,ie,me){var fe=O(Q),oe=q(fe),I=B(fe);if(E(ne),I===0&&ie<2)throw new re(z);var F=te?I-1:0,J=te?-1:1;if(ie<2)for(;;){if(F in oe){me=oe[F],F+=J;break}if(F+=J,te?F<0:I<=F)throw new re(z)}for(;te?F>=0:I>F;F+=J)F in oe&&(me=ne(me,oe[F],F,fe));return me}};$.exports={left:V(!1),right:V(!0)}},4527:function($,K,T){var E=T(3724),O=T(4376),q=TypeError,B=Object.getOwnPropertyDescriptor,re=E&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(z){return z instanceof TypeError}})();$.exports=re?function(z,V){if(O(z)&&!B(z,"length").writable)throw new q("Cannot set read only .length");return z.length=V}:function(z,V){return z.length=V}},7680:function($,K,T){var E=T(9504);$.exports=E([].slice)},4488:function($,K,T){var E=T(7680),O=Math.floor,q=function(B,re){var z=B.length;if(z<8)for(var V,te,Q=1;Q<z;){for(te=Q,V=B[Q];te&&re(B[te-1],V)>0;)B[te]=B[--te];te!==Q++&&(B[te]=V)}else for(var ne=O(z/2),ie=q(E(B,0,ne),re),me=q(E(B,ne),re),fe=ie.length,oe=me.length,I=0,F=0;I<fe||F<oe;)B[I+F]=I<fe&&F<oe?re(ie[I],me[F])<=0?ie[I++]:me[F++]:I<fe?ie[I++]:me[F++];return B};$.exports=q},7433:function($,K,T){var E=T(4376),O=T(3517),q=T(34),B=T(8227)("species"),re=Array;$.exports=function(z){var V;return E(z)&&(V=z.constructor,(O(V)&&(V===re||E(V.prototype))||q(V)&&(V=V[B])===null)&&(V=void 0)),V===void 0?re:V}},1469:function($,K,T){var E=T(7433);$.exports=function(O,q){return new(E(O))(q===0?0:q)}},6319:function($,K,T){var E=T(8551),O=T(9539);$.exports=function(q,B,re,z){try{return z?B(E(re)[0],re[1]):B(re)}catch(V){O(q,"throw",V)}}},4428:function($,K,T){var E=T(8227)("iterator"),O=!1;try{var q=0,B={next:function(){return{done:!!q++}},return:function(){O=!0}};B[E]=function(){return this},Array.from(B,(function(){throw 2}))}catch{}$.exports=function(re,z){try{if(!z&&!O)return!1}catch{return!1}var V=!1;try{var te={};te[E]=function(){return{next:function(){return{done:V=!0}}}},re(te)}catch{}return V}},2195:function($,K,T){var E=T(9504),O=E({}.toString),q=E("".slice);$.exports=function(B){return q(O(B),8,-1)}},6955:function($,K,T){var E=T(2140),O=T(4901),q=T(2195),B=T(8227)("toStringTag"),re=Object,z=q((function(){return arguments})())==="Arguments";$.exports=E?q:function(V){var te,Q,ne;return V===void 0?"Undefined":V===null?"Null":typeof(Q=(function(ie,me){try{return ie[me]}catch{}})(te=re(V),B))=="string"?Q:z?q(te):(ne=q(te))==="Object"&&O(te.callee)?"Arguments":ne}},7740:function($,K,T){var E=T(9297),O=T(5031),q=T(7347),B=T(4913);$.exports=function(re,z,V){for(var te=O(z),Q=B.f,ne=q.f,ie=0;ie<te.length;ie++){var me=te[ie];E(re,me)||V&&E(V,me)||Q(re,me,ne(z,me))}}},1436:function($,K,T){var E=T(8227)("match");$.exports=function(O){var q=/./;try{"/./"[O](q)}catch{try{return q[E]=!1,"/./"[O](q)}catch{}}return!1}},2211:function($,K,T){var E=T(9039);$.exports=!E((function(){function O(){}return O.prototype.constructor=null,Object.getPrototypeOf(new O)!==O.prototype}))},2529:function($){$.exports=function(K,T){return{value:K,done:T}}},6699:function($,K,T){var E=T(3724),O=T(4913),q=T(6980);$.exports=E?function(B,re,z){return O.f(B,re,q(1,z))}:function(B,re,z){return B[re]=z,B}},6980:function($){$.exports=function(K,T){return{enumerable:!(1&K),configurable:!(2&K),writable:!(4&K),value:T}}},4659:function($,K,T){var E=T(3724),O=T(4913),q=T(6980);$.exports=function(B,re,z){E?O.f(B,re,q(0,z)):B[re]=z}},3640:function($,K,T){var E=T(8551),O=T(4270),q=TypeError;$.exports=function(B){if(E(this),B==="string"||B==="default")B="string";else if(B!=="number")throw new q("Incorrect hint");return O(this,B)}},2106:function($,K,T){var E=T(283),O=T(4913);$.exports=function(q,B,re){return re.get&&E(re.get,B,{getter:!0}),re.set&&E(re.set,B,{setter:!0}),O.f(q,B,re)}},6840:function($,K,T){var E=T(4901),O=T(4913),q=T(283),B=T(9433);$.exports=function(re,z,V,te){te||(te={});var Q=te.enumerable,ne=te.name!==void 0?te.name:z;if(E(V)&&q(V,ne,te),te.global)Q?re[z]=V:B(z,V);else{try{te.unsafe?re[z]&&(Q=!0):delete re[z]}catch{}Q?re[z]=V:O.f(re,z,{value:V,enumerable:!1,configurable:!te.nonConfigurable,writable:!te.nonWritable})}return re}},9433:function($,K,T){var E=T(4576),O=Object.defineProperty;$.exports=function(q,B){try{O(E,q,{value:B,configurable:!0,writable:!0})}catch{E[q]=B}return B}},4606:function($,K,T){var E=T(6823),O=TypeError;$.exports=function(q,B){if(!delete q[B])throw new O("Cannot delete property "+E(B)+" of "+E(q))}},3724:function($,K,T){var E=T(9039);$.exports=!E((function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}))},4055:function($,K,T){var E=T(4576),O=T(34),q=E.document,B=O(q)&&O(q.createElement);$.exports=function(re){return B?q.createElement(re):{}}},6837:function($){var K=TypeError;$.exports=function(T){if(T>9007199254740991)throw K("Maximum allowed index exceeded");return T}},7400:function($){$.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},9296:function($,K,T){var E=T(4055)("span").classList,O=E&&E.constructor&&E.constructor.prototype;$.exports=O===Object.prototype?void 0:O},8727:function($){$.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},3709:function($,K,T){var E=T(2839).match(/firefox\/(\d+)/i);$.exports=!!E&&+E[1]},3763:function($,K,T){var E=T(2839);$.exports=/MSIE|Trident/.test(E)},6193:function($,K,T){var E=T(4215);$.exports=E==="NODE"},2839:function($,K,T){var E=T(4576).navigator,O=E&&E.userAgent;$.exports=O?String(O):""},9519:function($,K,T){var E,O,q=T(4576),B=T(2839),re=q.process,z=q.Deno,V=re&&re.versions||z&&z.version,te=V&&V.v8;te&&(O=(E=te.split("."))[0]>0&&E[0]<4?1:+(E[0]+E[1])),!O&&B&&(!(E=B.match(/Edge\/(\d+)/))||E[1]>=74)&&(E=B.match(/Chrome\/(\d+)/))&&(O=+E[1]),$.exports=O},3607:function($,K,T){var E=T(2839).match(/AppleWebKit\/(\d+)\./);$.exports=!!E&&+E[1]},4215:function($,K,T){var E=T(4576),O=T(2839),q=T(2195),B=function(re){return O.slice(0,re.length)===re};$.exports=B("Bun/")?"BUN":B("Cloudflare-Workers")?"CLOUDFLARE":B("Deno/")?"DENO":B("Node.js/")?"NODE":E.Bun&&typeof Bun.version=="string"?"BUN":E.Deno&&typeof Deno.version=="object"?"DENO":q(E.process)==="process"?"NODE":E.window&&E.document?"BROWSER":"REST"},6518:function($,K,T){var E=T(4576),O=T(7347).f,q=T(6699),B=T(6840),re=T(9433),z=T(7740),V=T(2796);$.exports=function(te,Q){var ne,ie,me,fe,oe,I=te.target,F=te.global,J=te.stat;if(ne=F?E:J?E[I]||re(I,{}):E[I]&&E[I].prototype)for(ie in Q){if(fe=Q[ie],me=te.dontCallGetSet?(oe=O(ne,ie))&&oe.value:ne[ie],!V(F?ie:I+(J?".":"#")+ie,te.forced)&&me!==void 0){if(typeof fe==typeof me)continue;z(fe,me)}(te.sham||me&&me.sham)&&q(fe,"sham",!0),B(ne,ie,fe,te)}}},9039:function($){$.exports=function(K){try{return!!K()}catch{return!0}}},9228:function($,K,T){T(7495);var E=T(9565),O=T(6840),q=T(7323),B=T(9039),re=T(8227),z=T(6699),V=re("species"),te=RegExp.prototype;$.exports=function(Q,ne,ie,me){var fe=re(Q),oe=!B((function(){var xe={};return xe[fe]=function(){return 7},""[Q](xe)!==7})),I=oe&&!B((function(){var xe=!1,he=/a/;if(Q==="split"){var le={};le[V]=function(){return he},(he={constructor:le,flags:""})[fe]=/./[fe]}return he.exec=function(){return xe=!0,null},he[fe](""),!xe}));if(!oe||!I||ie){var F=/./[fe],J=ne(fe,""[Q],(function(xe,he,le,Ce,Ne){var Ue=he.exec;return Ue===q||Ue===te.exec?oe&&!Ne?{done:!0,value:E(F,he,le,Ce)}:{done:!0,value:E(xe,le,he,Ce)}:{done:!1}}));O(String.prototype,Q,J[0]),O(te,fe,J[1])}me&&z(te[fe],"sham",!0)}},8745:function($,K,T){var E=T(616),O=Function.prototype,q=O.apply,B=O.call;$.exports=typeof Reflect=="object"&&Reflect.apply||(E?B.bind(q):function(){return B.apply(q,arguments)})},6080:function($,K,T){var E=T(7476),O=T(9306),q=T(616),B=E(E.bind);$.exports=function(re,z){return O(re),z===void 0?re:q?B(re,z):function(){return re.apply(z,arguments)}}},616:function($,K,T){var E=T(9039);$.exports=!E((function(){var O=(function(){}).bind();return typeof O!="function"||O.hasOwnProperty("prototype")}))},566:function($,K,T){var E=T(9504),O=T(9306),q=T(34),B=T(9297),re=T(7680),z=T(616),V=Function,te=E([].concat),Q=E([].join),ne={};$.exports=z?V.bind:function(ie){var me=O(this),fe=me.prototype,oe=re(arguments,1),I=function(){var F=te(oe,re(arguments));return this instanceof I?(function(J,xe,he){if(!B(ne,xe)){for(var le=[],Ce=0;Ce<xe;Ce++)le[Ce]="a["+Ce+"]";ne[xe]=V("C,a","return new C("+Q(le,",")+")")}return ne[xe](J,he)})(me,F.length,F):me.apply(ie,F)};return q(fe)&&(I.prototype=fe),I}},9565:function($,K,T){var E=T(616),O=Function.prototype.call;$.exports=E?O.bind(O):function(){return O.apply(O,arguments)}},350:function($,K,T){var E=T(3724),O=T(9297),q=Function.prototype,B=E&&Object.getOwnPropertyDescriptor,re=O(q,"name"),z=re&&(function(){}).name==="something",V=re&&(!E||E&&B(q,"name").configurable);$.exports={EXISTS:re,PROPER:z,CONFIGURABLE:V}},6706:function($,K,T){var E=T(9504),O=T(9306);$.exports=function(q,B,re){try{return E(O(Object.getOwnPropertyDescriptor(q,B)[re]))}catch{}}},7476:function($,K,T){var E=T(2195),O=T(9504);$.exports=function(q){if(E(q)==="Function")return O(q)}},9504:function($,K,T){var E=T(616),O=Function.prototype,q=O.call,B=E&&O.bind.bind(q,q);$.exports=E?B:function(re){return function(){return q.apply(re,arguments)}}},7751:function($,K,T){var E=T(4576),O=T(4901);$.exports=function(q,B){return arguments.length<2?(re=E[q],O(re)?re:void 0):E[q]&&E[q][B];var re}},851:function($,K,T){var E=T(6955),O=T(5966),q=T(4117),B=T(6269),re=T(8227)("iterator");$.exports=function(z){if(!q(z))return O(z,re)||O(z,"@@iterator")||B[E(z)]}},81:function($,K,T){var E=T(9565),O=T(9306),q=T(8551),B=T(6823),re=T(851),z=TypeError;$.exports=function(V,te){var Q=arguments.length<2?re(V):te;if(O(Q))return q(E(Q,V));throw new z(B(V)+" is not iterable")}},5966:function($,K,T){var E=T(9306),O=T(4117);$.exports=function(q,B){var re=q[B];return O(re)?void 0:E(re)}},2478:function($,K,T){var E=T(9504),O=T(8981),q=Math.floor,B=E("".charAt),re=E("".replace),z=E("".slice),V=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,te=/\$([$&'`]|\d{1,2})/g;$.exports=function(Q,ne,ie,me,fe,oe){var I=ie+Q.length,F=me.length,J=te;return fe!==void 0&&(fe=O(fe),J=V),re(oe,J,(function(xe,he){var le;switch(B(he,0)){case"$":return"$";case"&":return Q;case"`":return z(ne,0,ie);case"'":return z(ne,I);case"<":le=fe[z(he,1,-1)];break;default:var Ce=+he;if(Ce===0)return xe;if(Ce>F){var Ne=q(Ce/10);return Ne===0?xe:Ne<=F?me[Ne-1]===void 0?B(he,1):me[Ne-1]+B(he,1):xe}le=me[Ce-1]}return le===void 0?"":le}))}},4576:function($,K,T){var E=function(O){return O&&O.Math===Math&&O};$.exports=E(typeof globalThis=="object"&&globalThis)||E(typeof window=="object"&&window)||E(typeof self=="object"&&self)||E(typeof T.g=="object"&&T.g)||E(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()},9297:function($,K,T){var E=T(9504),O=T(8981),q=E({}.hasOwnProperty);$.exports=Object.hasOwn||function(B,re){return q(O(B),re)}},421:function($){$.exports={}},397:function($,K,T){var E=T(7751);$.exports=E("document","documentElement")},5917:function($,K,T){var E=T(3724),O=T(9039),q=T(4055);$.exports=!E&&!O((function(){return Object.defineProperty(q("div"),"a",{get:function(){return 7}}).a!==7}))},7055:function($,K,T){var E=T(9504),O=T(9039),q=T(2195),B=Object,re=E("".split);$.exports=O((function(){return!B("z").propertyIsEnumerable(0)}))?function(z){return q(z)==="String"?re(z,""):B(z)}:B},3167:function($,K,T){var E=T(4901),O=T(34),q=T(2967);$.exports=function(B,re,z){var V,te;return q&&E(V=re.constructor)&&V!==z&&O(te=V.prototype)&&te!==z.prototype&&q(B,te),B}},3706:function($,K,T){var E=T(9504),O=T(4901),q=T(7629),B=E(Function.toString);O(q.inspectSource)||(q.inspectSource=function(re){return B(re)}),$.exports=q.inspectSource},1181:function($,K,T){var E,O,q,B=T(8622),re=T(4576),z=T(34),V=T(6699),te=T(9297),Q=T(7629),ne=T(6119),ie=T(421),me="Object already initialized",fe=re.TypeError,oe=re.WeakMap;if(B||Q.state){var I=Q.state||(Q.state=new oe);I.get=I.get,I.has=I.has,I.set=I.set,E=function(J,xe){if(I.has(J))throw new fe(me);return xe.facade=J,I.set(J,xe),xe},O=function(J){return I.get(J)||{}},q=function(J){return I.has(J)}}else{var F=ne("state");ie[F]=!0,E=function(J,xe){if(te(J,F))throw new fe(me);return xe.facade=J,V(J,F,xe),xe},O=function(J){return te(J,F)?J[F]:{}},q=function(J){return te(J,F)}}$.exports={set:E,get:O,has:q,enforce:function(J){return q(J)?O(J):E(J,{})},getterFor:function(J){return function(xe){var he;if(!z(xe)||(he=O(xe)).type!==J)throw new fe("Incompatible receiver, "+J+" required");return he}}}},4209:function($,K,T){var E=T(8227),O=T(6269),q=E("iterator"),B=Array.prototype;$.exports=function(re){return re!==void 0&&(O.Array===re||B[q]===re)}},4376:function($,K,T){var E=T(2195);$.exports=Array.isArray||function(O){return E(O)==="Array"}},4901:function($){var K=typeof document=="object"&&document.all;$.exports=K===void 0&&K!==void 0?function(T){return typeof T=="function"||T===K}:function(T){return typeof T=="function"}},3517:function($,K,T){var E=T(9504),O=T(9039),q=T(4901),B=T(6955),re=T(7751),z=T(3706),V=function(){},te=re("Reflect","construct"),Q=/^\s*(?:class|function)\b/,ne=E(Q.exec),ie=!Q.test(V),me=function(oe){if(!q(oe))return!1;try{return te(V,[],oe),!0}catch{return!1}},fe=function(oe){if(!q(oe))return!1;switch(B(oe)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ie||!!ne(Q,z(oe))}catch{return!0}};fe.sham=!0,$.exports=!te||O((function(){var oe;return me(me.call)||!me(Object)||!me((function(){oe=!0}))||oe}))?fe:me},2796:function($,K,T){var E=T(9039),O=T(4901),q=/#|\.prototype\./,B=function(Q,ne){var ie=z[re(Q)];return ie===te||ie!==V&&(O(ne)?E(ne):!!ne)},re=B.normalize=function(Q){return String(Q).replace(q,".").toLowerCase()},z=B.data={},V=B.NATIVE="N",te=B.POLYFILL="P";$.exports=B},2087:function($,K,T){var E=T(34),O=Math.floor;$.exports=Number.isInteger||function(q){return!E(q)&&isFinite(q)&&O(q)===q}},4117:function($){$.exports=function(K){return K==null}},34:function($,K,T){var E=T(4901);$.exports=function(O){return typeof O=="object"?O!==null:E(O)}},3925:function($,K,T){var E=T(34);$.exports=function(O){return E(O)||O===null}},6395:function($){$.exports=!1},5810:function($,K,T){var E=T(34),O=T(1181).get;$.exports=function(q){if(!E(q))return!1;var B=O(q);return!!B&&B.type==="RawJSON"}},788:function($,K,T){var E=T(34),O=T(2195),q=T(8227)("match");$.exports=function(B){var re;return E(B)&&((re=B[q])!==void 0?!!re:O(B)==="RegExp")}},757:function($,K,T){var E=T(7751),O=T(4901),q=T(1625),B=T(7040),re=Object;$.exports=B?function(z){return typeof z=="symbol"}:function(z){var V=E("Symbol");return O(V)&&q(V.prototype,re(z))}},9539:function($,K,T){var E=T(9565),O=T(8551),q=T(5966);$.exports=function(B,re,z){var V,te;O(B);try{if(!(V=q(B,"return"))){if(re==="throw")throw z;return z}V=E(V,B)}catch(Q){te=!0,V=Q}if(re==="throw")throw z;if(te)throw V;return O(V),z}},3994:function($,K,T){var E=T(7657).IteratorPrototype,O=T(2360),q=T(6980),B=T(687),re=T(6269),z=function(){return this};$.exports=function(V,te,Q,ne){var ie=te+" Iterator";return V.prototype=O(E,{next:q(+!ne,Q)}),B(V,ie,!1,!0),re[ie]=z,V}},1088:function($,K,T){var E=T(6518),O=T(9565),q=T(6395),B=T(350),re=T(4901),z=T(3994),V=T(2787),te=T(2967),Q=T(687),ne=T(6699),ie=T(6840),me=T(8227),fe=T(6269),oe=T(7657),I=B.PROPER,F=B.CONFIGURABLE,J=oe.IteratorPrototype,xe=oe.BUGGY_SAFARI_ITERATORS,he=me("iterator"),le="keys",Ce="values",Ne="entries",Ue=function(){return this};$.exports=function(He,de,we,ke,_e,Ae,Ve){z(we,de,ke);var Te,Ke,je,qe=function(Mt){if(Mt===_e&&ct)return ct;if(!xe&&Mt&&Mt in Be)return Be[Mt];switch(Mt){case le:case Ce:case Ne:return function(){return new we(this,Mt)}}return function(){return new we(this)}},Re=de+" Iterator",Pe=!1,Be=He.prototype,We=Be[he]||Be["@@iterator"]||_e&&Be[_e],ct=!xe&&We||qe(_e),St=de==="Array"&&Be.entries||We;if(St&&(Te=V(St.call(new He)))!==Object.prototype&&Te.next&&(q||V(Te)===J||(te?te(Te,J):re(Te[he])||ie(Te,he,Ue)),Q(Te,Re,!0,!0),q&&(fe[Re]=Ue)),I&&_e===Ce&&We&&We.name!==Ce&&(!q&&F?ne(Be,"name",Ce):(Pe=!0,ct=function(){return O(We,this)})),_e)if(Ke={values:qe(Ce),keys:Ae?ct:qe(le),entries:qe(Ne)},Ve)for(je in Ke)(xe||Pe||!(je in Be))&&ie(Be,je,Ke[je]);else E({target:de,proto:!0,forced:xe||Pe},Ke);return q&&!Ve||Be[he]===ct||ie(Be,he,ct,{name:_e}),fe[de]=ct,Ke}},7657:function($,K,T){var E,O,q,B=T(9039),re=T(4901),z=T(34),V=T(2360),te=T(2787),Q=T(6840),ne=T(8227),ie=T(6395),me=ne("iterator"),fe=!1;[].keys&&("next"in(q=[].keys())?(O=te(te(q)))!==Object.prototype&&(E=O):fe=!0),!z(E)||B((function(){var oe={};return E[me].call(oe)!==oe}))?E={}:ie&&(E=V(E)),re(E[me])||Q(E,me,(function(){return this})),$.exports={IteratorPrototype:E,BUGGY_SAFARI_ITERATORS:fe}},6269:function($){$.exports={}},6198:function($,K,T){var E=T(8014);$.exports=function(O){return E(O.length)}},283:function($,K,T){var E=T(9504),O=T(9039),q=T(4901),B=T(9297),re=T(3724),z=T(350).CONFIGURABLE,V=T(3706),te=T(1181),Q=te.enforce,ne=te.get,ie=String,me=Object.defineProperty,fe=E("".slice),oe=E("".replace),I=E([].join),F=re&&!O((function(){return me((function(){}),"length",{value:8}).length!==8})),J=String(String).split("String"),xe=$.exports=function(he,le,Ce){fe(ie(le),0,7)==="Symbol("&&(le="["+oe(ie(le),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),Ce&&Ce.getter&&(le="get "+le),Ce&&Ce.setter&&(le="set "+le),(!B(he,"name")||z&&he.name!==le)&&(re?me(he,"name",{value:le,configurable:!0}):he.name=le),F&&Ce&&B(Ce,"arity")&&he.length!==Ce.arity&&me(he,"length",{value:Ce.arity});try{Ce&&B(Ce,"constructor")&&Ce.constructor?re&&me(he,"prototype",{writable:!1}):he.prototype&&(he.prototype=void 0)}catch{}var Ne=Q(he);return B(Ne,"source")||(Ne.source=I(J,typeof le=="string"?le:"")),he};Function.prototype.toString=xe((function(){return q(this)&&ne(this).source||V(this)}),"toString")},741:function($){var K=Math.ceil,T=Math.floor;$.exports=Math.trunc||function(E){var O=+E;return(O>0?T:K)(O)}},7819:function($,K,T){var E=T(9039);$.exports=!E((function(){var O="9007199254740993",q=JSON.rawJSON(O);return!JSON.isRawJSON(q)||JSON.stringify(q)!==O}))},5749:function($,K,T){var E=T(788),O=TypeError;$.exports=function(q){if(E(q))throw new O("The method doesn't accept regular expressions");return q}},4213:function($,K,T){var E=T(3724),O=T(9504),q=T(9565),B=T(9039),re=T(1072),z=T(3717),V=T(8773),te=T(8981),Q=T(7055),ne=Object.assign,ie=Object.defineProperty,me=O([].concat);$.exports=!ne||B((function(){if(E&&ne({b:1},ne(ie({},"a",{enumerable:!0,get:function(){ie(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var fe={},oe={},I=Symbol("assign detection"),F="abcdefghijklmnopqrst";return fe[I]=7,F.split("").forEach((function(J){oe[J]=J})),ne({},fe)[I]!==7||re(ne({},oe)).join("")!==F}))?function(fe,oe){for(var I=te(fe),F=arguments.length,J=1,xe=z.f,he=V.f;F>J;)for(var le,Ce=Q(arguments[J++]),Ne=xe?me(re(Ce),xe(Ce)):re(Ce),Ue=Ne.length,He=0;Ue>He;)le=Ne[He++],E&&!q(he,Ce,le)||(I[le]=Ce[le]);return I}:ne},2360:function($,K,T){var E,O=T(8551),q=T(6801),B=T(8727),re=T(421),z=T(397),V=T(4055),te=T(6119),Q="prototype",ne="script",ie=te("IE_PROTO"),me=function(){},fe=function(F){return"<"+ne+">"+F+"</"+ne+">"},oe=function(F){F.write(fe("")),F.close();var J=F.parentWindow.Object;return F=null,J},I=function(){try{E=new ActiveXObject("htmlfile")}catch{}var F,J,xe;I=typeof document<"u"?document.domain&&E?oe(E):(J=V("iframe"),xe="java"+ne+":",J.style.display="none",z.appendChild(J),J.src=String(xe),(F=J.contentWindow.document).open(),F.write(fe("document.F=Object")),F.close(),F.F):oe(E);for(var he=B.length;he--;)delete I[Q][B[he]];return I()};re[ie]=!0,$.exports=Object.create||function(F,J){var xe;return F!==null?(me[Q]=O(F),xe=new me,me[Q]=null,xe[ie]=F):xe=I(),J===void 0?xe:q.f(xe,J)}},6801:function($,K,T){var E=T(3724),O=T(8686),q=T(4913),B=T(8551),re=T(5397),z=T(1072);K.f=E&&!O?Object.defineProperties:function(V,te){B(V);for(var Q,ne=re(te),ie=z(te),me=ie.length,fe=0;me>fe;)q.f(V,Q=ie[fe++],ne[Q]);return V}},4913:function($,K,T){var E=T(3724),O=T(5917),q=T(8686),B=T(8551),re=T(6969),z=TypeError,V=Object.defineProperty,te=Object.getOwnPropertyDescriptor,Q="enumerable",ne="configurable",ie="writable";K.f=E?q?function(me,fe,oe){if(B(me),fe=re(fe),B(oe),typeof me=="function"&&fe==="prototype"&&"value"in oe&&ie in oe&&!oe[ie]){var I=te(me,fe);I&&I[ie]&&(me[fe]=oe.value,oe={configurable:ne in oe?oe[ne]:I[ne],enumerable:Q in oe?oe[Q]:I[Q],writable:!1})}return V(me,fe,oe)}:V:function(me,fe,oe){if(B(me),fe=re(fe),B(oe),O)try{return V(me,fe,oe)}catch{}if("get"in oe||"set"in oe)throw new z("Accessors not supported");return"value"in oe&&(me[fe]=oe.value),me}},7347:function($,K,T){var E=T(3724),O=T(9565),q=T(8773),B=T(6980),re=T(5397),z=T(6969),V=T(9297),te=T(5917),Q=Object.getOwnPropertyDescriptor;K.f=E?Q:function(ne,ie){if(ne=re(ne),ie=z(ie),te)try{return Q(ne,ie)}catch{}if(V(ne,ie))return B(!O(q.f,ne,ie),ne[ie])}},298:function($,K,T){var E=T(2195),O=T(5397),q=T(8480).f,B=T(7680),re=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];$.exports.f=function(z){return re&&E(z)==="Window"?(function(V){try{return q(V)}catch{return B(re)}})(z):q(O(z))}},8480:function($,K,T){var E=T(1828),O=T(8727).concat("length","prototype");K.f=Object.getOwnPropertyNames||function(q){return E(q,O)}},3717:function($,K){K.f=Object.getOwnPropertySymbols},2787:function($,K,T){var E=T(9297),O=T(4901),q=T(8981),B=T(6119),re=T(2211),z=B("IE_PROTO"),V=Object,te=V.prototype;$.exports=re?V.getPrototypeOf:function(Q){var ne=q(Q);if(E(ne,z))return ne[z];var ie=ne.constructor;return O(ie)&&ne instanceof ie?ie.prototype:ne instanceof V?te:null}},1625:function($,K,T){var E=T(9504);$.exports=E({}.isPrototypeOf)},1828:function($,K,T){var E=T(9504),O=T(9297),q=T(5397),B=T(9617).indexOf,re=T(421),z=E([].push);$.exports=function(V,te){var Q,ne=q(V),ie=0,me=[];for(Q in ne)!O(re,Q)&&O(ne,Q)&&z(me,Q);for(;te.length>ie;)O(ne,Q=te[ie++])&&(~B(me,Q)||z(me,Q));return me}},1072:function($,K,T){var E=T(1828),O=T(8727);$.exports=Object.keys||function(q){return E(q,O)}},8773:function($,K){var T={}.propertyIsEnumerable,E=Object.getOwnPropertyDescriptor,O=E&&!T.call({1:2},1);K.f=O?function(q){var B=E(this,q);return!!B&&B.enumerable}:T},2551:function($,K,T){var E=T(6395),O=T(4576),q=T(9039),B=T(3607);$.exports=E||!q((function(){if(!(B&&B<535)){var re=Math.random();__defineSetter__.call(null,re,(function(){})),delete O[re]}}))},2967:function($,K,T){var E=T(6706),O=T(34),q=T(7750),B=T(3506);$.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var re,z=!1,V={};try{(re=E(Object.prototype,"__proto__","set"))(V,[]),z=V instanceof Array}catch{}return function(te,Q){return q(te),B(Q),O(te)&&(z?re(te,Q):te.__proto__=Q),te}})():void 0)},3179:function($,K,T){var E=T(2140),O=T(6955);$.exports=E?{}.toString:function(){return"[object "+O(this)+"]"}},4270:function($,K,T){var E=T(9565),O=T(4901),q=T(34),B=TypeError;$.exports=function(re,z){var V,te;if(z==="string"&&O(V=re.toString)&&!q(te=E(V,re))||O(V=re.valueOf)&&!q(te=E(V,re))||z!=="string"&&O(V=re.toString)&&!q(te=E(V,re)))return te;throw new B("Can't convert object to primitive value")}},5031:function($,K,T){var E=T(7751),O=T(9504),q=T(8480),B=T(3717),re=T(8551),z=O([].concat);$.exports=E("Reflect","ownKeys")||function(V){var te=q.f(re(V)),Q=B.f;return Q?z(te,Q(V)):te}},8235:function($,K,T){var E=T(9504),O=T(9297),q=SyntaxError,B=parseInt,re=String.fromCharCode,z=E("".charAt),V=E("".slice),te=E(/./.exec),Q={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
  8318. `,"\\r":"\r","\\t":" "},ne=/^[\da-f]{4}$/i,ie=/^[\u0000-\u001F]$/;$.exports=function(me,fe){for(var oe=!0,I="";fe<me.length;){var F=z(me,fe);if(F==="\\"){var J=V(me,fe,fe+2);if(O(Q,J))I+=Q[J],fe+=2;else{if(J!=="\\u")throw new q('Unknown escape sequence: "'+J+'"');var xe=V(me,fe+=2,fe+4);if(!te(ne,xe))throw new q("Bad Unicode escape at: "+fe);I+=re(B(xe,16)),fe+=4}}else{if(F==='"'){oe=!1,fe++;break}if(te(ie,F))throw new q("Bad control character in string literal at: "+fe);I+=F,fe++}}if(oe)throw new q("Unterminated string at: "+fe);return{value:I,end:fe}}},9167:function($,K,T){var E=T(4576);$.exports=E},1056:function($,K,T){var E=T(4913).f;$.exports=function(O,q,B){B in O||E(O,B,{configurable:!0,get:function(){return q[B]},set:function(re){q[B]=re}})}},6682:function($,K,T){var E=T(9565),O=T(8551),q=T(4901),B=T(2195),re=T(7323),z=TypeError;$.exports=function(V,te){var Q=V.exec;if(q(Q)){var ne=E(Q,V,te);return ne!==null&&O(ne),ne}if(B(V)==="RegExp")return E(re,V,te);throw new z("RegExp#exec called on incompatible receiver")}},7323:function($,K,T){var E,O,q=T(9565),B=T(9504),re=T(655),z=T(7979),V=T(8429),te=T(5745),Q=T(2360),ne=T(1181).get,ie=T(3635),me=T(8814),fe=te("native-string-replace",String.prototype.replace),oe=RegExp.prototype.exec,I=oe,F=B("".charAt),J=B("".indexOf),xe=B("".replace),he=B("".slice),le=(O=/b*/g,q(oe,E=/a/,"a"),q(oe,O,"a"),E.lastIndex!==0||O.lastIndex!==0),Ce=V.BROKEN_CARET,Ne=/()??/.exec("")[1]!==void 0;(le||Ne||Ce||ie||me)&&(I=function(Ue){var He,de,we,ke,_e,Ae,Ve,Te=this,Ke=ne(Te),je=re(Ue),qe=Ke.raw;if(qe)return qe.lastIndex=Te.lastIndex,He=q(I,qe,je),Te.lastIndex=qe.lastIndex,He;var Re=Ke.groups,Pe=Ce&&Te.sticky,Be=q(z,Te),We=Te.source,ct=0,St=je;if(Pe&&(Be=xe(Be,"y",""),J(Be,"g")===-1&&(Be+="g"),St=he(je,Te.lastIndex),Te.lastIndex>0&&(!Te.multiline||Te.multiline&&F(je,Te.lastIndex-1)!==`
  8319. `)&&(We="(?: "+We+")",St=" "+St,ct++),de=new RegExp("^(?:"+We+")",Be)),Ne&&(de=new RegExp("^"+We+"$(?!\\s)",Be)),le&&(we=Te.lastIndex),ke=q(oe,Pe?de:Te,St),Pe?ke?(ke.input=he(ke.input,ct),ke[0]=he(ke[0],ct),ke.index=Te.lastIndex,Te.lastIndex+=ke[0].length):Te.lastIndex=0:le&&ke&&(Te.lastIndex=Te.global?ke.index+ke[0].length:we),Ne&&ke&&ke.length>1&&q(fe,ke[0],de,(function(){for(_e=1;_e<arguments.length-2;_e++)arguments[_e]===void 0&&(ke[_e]=void 0)})),ke&&Re)for(ke.groups=Ae=Q(null),_e=0;_e<Re.length;_e++)Ae[(Ve=Re[_e])[0]]=ke[Ve[1]];return ke}),$.exports=I},5213:function($,K,T){var E=T(4576),O=T(9039),q=E.RegExp,B=!O((function(){var re=!0;try{q(".","d")}catch{re=!1}var z={},V="",te=re?"dgimsy":"gimsy",Q=function(me,fe){Object.defineProperty(z,me,{get:function(){return V+=fe,!0}})},ne={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var ie in re&&(ne.hasIndices="d"),ne)Q(ie,ne[ie]);return Object.getOwnPropertyDescriptor(q.prototype,"flags").get.call(z)!==te||V!==te}));$.exports={correct:B}},7979:function($,K,T){var E=T(8551);$.exports=function(){var O=E(this),q="";return O.hasIndices&&(q+="d"),O.global&&(q+="g"),O.ignoreCase&&(q+="i"),O.multiline&&(q+="m"),O.dotAll&&(q+="s"),O.unicode&&(q+="u"),O.unicodeSets&&(q+="v"),O.sticky&&(q+="y"),q}},1034:function($,K,T){var E=T(9565),O=T(9297),q=T(1625),B=T(5213),re=T(7979),z=RegExp.prototype;$.exports=B.correct?function(V){return V.flags}:function(V){return B.correct||!q(z,V)||O(V,"flags")?V.flags:E(re,V)}},8429:function($,K,T){var E=T(9039),O=T(4576).RegExp,q=E((function(){var z=O("a","y");return z.lastIndex=2,z.exec("abcd")!==null})),B=q||E((function(){return!O("a","y").sticky})),re=q||E((function(){var z=O("^r","gy");return z.lastIndex=2,z.exec("str")!==null}));$.exports={BROKEN_CARET:re,MISSED_STICKY:B,UNSUPPORTED_Y:q}},3635:function($,K,T){var E=T(9039),O=T(4576).RegExp;$.exports=E((function(){var q=O(".","s");return!(q.dotAll&&q.test(`
  8320. `)&&q.flags==="s")}))},8814:function($,K,T){var E=T(9039),O=T(4576).RegExp;$.exports=E((function(){var q=O("(?<a>b)","g");return q.exec("b").groups.a!=="b"||"b".replace(q,"$<a>c")!=="bc"}))},7750:function($,K,T){var E=T(4117),O=TypeError;$.exports=function(q){if(E(q))throw new O("Can't call method on "+q);return q}},7633:function($,K,T){var E=T(7751),O=T(2106),q=T(8227),B=T(3724),re=q("species");$.exports=function(z){var V=E(z);B&&V&&!V[re]&&O(V,re,{configurable:!0,get:function(){return this}})}},687:function($,K,T){var E=T(4913).f,O=T(9297),q=T(8227)("toStringTag");$.exports=function(B,re,z){B&&!z&&(B=B.prototype),B&&!O(B,q)&&E(B,q,{configurable:!0,value:re})}},6119:function($,K,T){var E=T(5745),O=T(3392),q=E("keys");$.exports=function(B){return q[B]||(q[B]=O(B))}},7629:function($,K,T){var E=T(6395),O=T(4576),q=T(9433),B="__core-js_shared__",re=$.exports=O[B]||q(B,{});(re.versions||(re.versions=[])).push({version:"3.48.0",mode:E?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.48.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745:function($,K,T){var E=T(7629);$.exports=function(O,q){return E[O]||(E[O]=q||{})}},2293:function($,K,T){var E=T(8551),O=T(5548),q=T(4117),B=T(8227)("species");$.exports=function(re,z){var V,te=E(re).constructor;return te===void 0||q(V=E(te)[B])?z:O(V)}},8183:function($,K,T){var E=T(9504),O=T(1291),q=T(655),B=T(7750),re=E("".charAt),z=E("".charCodeAt),V=E("".slice),te=function(Q){return function(ne,ie){var me,fe,oe=q(B(ne)),I=O(ie),F=oe.length;return I<0||I>=F?Q?"":void 0:(me=z(oe,I))<55296||me>56319||I+1===F||(fe=z(oe,I+1))<56320||fe>57343?Q?re(oe,I):me:Q?V(oe,I,I+2):fe-56320+(me-55296<<10)+65536}};$.exports={codeAt:te(!1),charAt:te(!0)}},706:function($,K,T){var E=T(350).PROPER,O=T(9039),q=T(7452);$.exports=function(B){return O((function(){return!!q[B]()||"​…᠎"[B]()!=="​…᠎"||E&&q[B].name!==B}))}},3802:function($,K,T){var E=T(9504),O=T(7750),q=T(655),B=T(7452),re=E("".replace),z=RegExp("^["+B+"]+"),V=RegExp("(^|[^"+B+"])["+B+"]+$"),te=function(Q){return function(ne){var ie=q(O(ne));return 1&Q&&(ie=re(ie,z,"")),2&Q&&(ie=re(ie,V,"$1")),ie}};$.exports={start:te(1),end:te(2),trim:te(3)}},4495:function($,K,T){var E=T(9519),O=T(9039),q=T(4576).String;$.exports=!!Object.getOwnPropertySymbols&&!O((function(){var B=Symbol("symbol detection");return!q(B)||!(Object(B)instanceof Symbol)||!Symbol.sham&&E&&E<41}))},8242:function($,K,T){var E=T(9565),O=T(7751),q=T(8227),B=T(6840);$.exports=function(){var re=O("Symbol"),z=re&&re.prototype,V=z&&z.valueOf,te=q("toPrimitive");z&&!z[te]&&B(z,te,(function(Q){return E(V,this)}),{arity:1})}},1296:function($,K,T){var E=T(4495);$.exports=E&&!!Symbol.for&&!!Symbol.keyFor},1240:function($,K,T){var E=T(9504);$.exports=E(1.1.valueOf)},5610:function($,K,T){var E=T(1291),O=Math.max,q=Math.min;$.exports=function(B,re){var z=E(B);return z<0?O(z+re,0):q(z,re)}},5397:function($,K,T){var E=T(7055),O=T(7750);$.exports=function(q){return E(O(q))}},1291:function($,K,T){var E=T(741);$.exports=function(O){var q=+O;return q!=q||q===0?0:E(q)}},8014:function($,K,T){var E=T(1291),O=Math.min;$.exports=function(q){var B=E(q);return B>0?O(B,9007199254740991):0}},8981:function($,K,T){var E=T(7750),O=Object;$.exports=function(q){return O(E(q))}},2777:function($,K,T){var E=T(9565),O=T(34),q=T(757),B=T(5966),re=T(4270),z=T(8227),V=TypeError,te=z("toPrimitive");$.exports=function(Q,ne){if(!O(Q)||q(Q))return Q;var ie,me=B(Q,te);if(me){if(ne===void 0&&(ne="default"),ie=E(me,Q,ne),!O(ie)||q(ie))return ie;throw new V("Can't convert object to primitive value")}return ne===void 0&&(ne="number"),re(Q,ne)}},6969:function($,K,T){var E=T(2777),O=T(757);$.exports=function(q){var B=E(q,"string");return O(B)?B:B+""}},2140:function($,K,T){var E={};E[T(8227)("toStringTag")]="z",$.exports=String(E)==="[object z]"},655:function($,K,T){var E=T(6955),O=String;$.exports=function(q){if(E(q)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return O(q)}},6823:function($){var K=String;$.exports=function(T){try{return K(T)}catch{return"Object"}}},3392:function($,K,T){var E=T(9504),O=0,q=Math.random(),B=E(1.1.toString);$.exports=function(re){return"Symbol("+(re===void 0?"":re)+")_"+B(++O+q,36)}},7040:function($,K,T){var E=T(4495);$.exports=E&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},8686:function($,K,T){var E=T(3724),O=T(9039);$.exports=E&&O((function(){return Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype!==42}))},8622:function($,K,T){var E=T(4576),O=T(4901),q=E.WeakMap;$.exports=O(q)&&/native code/.test(String(q))},511:function($,K,T){var E=T(9167),O=T(9297),q=T(1951),B=T(4913).f;$.exports=function(re){var z=E.Symbol||(E.Symbol={});O(z,re)||B(z,re,{value:q.f(re)})}},1951:function($,K,T){var E=T(8227);K.f=E},8227:function($,K,T){var E=T(4576),O=T(5745),q=T(9297),B=T(3392),re=T(4495),z=T(7040),V=E.Symbol,te=O("wks"),Q=z?V.for||V:V&&V.withoutSetter||B;$.exports=function(ne){return q(te,ne)||(te[ne]=re&&q(V,ne)?V[ne]:Q("Symbol."+ne)),te[ne]}},7452:function($){$.exports=`
  8321. \v\f\r                 \u2028\u2029\uFEFF`},8706:function($,K,T){var E=T(6518),O=T(9039),q=T(4376),B=T(34),re=T(8981),z=T(6198),V=T(6837),te=T(4659),Q=T(4527),ne=T(1469),ie=T(597),me=T(8227),fe=T(9519),oe=me("isConcatSpreadable"),I=fe>=51||!O((function(){var J=[];return J[oe]=!1,J.concat()[0]!==J})),F=function(J){if(!B(J))return!1;var xe=J[oe];return xe!==void 0?!!xe:q(J)};E({target:"Array",proto:!0,arity:1,forced:!I||!ie("concat")},{concat:function(J){var xe,he,le,Ce,Ne,Ue=re(this),He=ne(Ue,0),de=0;for(xe=-1,le=arguments.length;xe<le;xe++)if(F(Ne=xe===-1?Ue:arguments[xe]))for(Ce=z(Ne),V(de+Ce),he=0;he<Ce;he++,de++)he in Ne&&te(He,de,Ne[he]);else V(de+1),te(He,de++,Ne);return Q(He,de),He}})},2008:function($,K,T){var E=T(6518),O=T(9213).filter;E({target:"Array",proto:!0,forced:!T(597)("filter")},{filter:function(q){return O(this,q,arguments.length>1?arguments[1]:void 0)}})},3418:function($,K,T){var E=T(6518),O=T(7916);E({target:"Array",stat:!0,forced:!T(4428)((function(q){Array.from(q)}))},{from:O})},4423:function($,K,T){var E=T(6518),O=T(9617).includes,q=T(9039),B=T(6469);E({target:"Array",proto:!0,forced:q((function(){return!Array(1).includes()}))},{includes:function(re){return O(this,re,arguments.length>1?arguments[1]:void 0)}}),B("includes")},5276:function($,K,T){var E=T(6518),O=T(7476),q=T(9617).indexOf,B=T(4598),re=O([].indexOf),z=!!re&&1/re([1],1,-0)<0;E({target:"Array",proto:!0,forced:z||!B("indexOf")},{indexOf:function(V){var te=arguments.length>1?arguments[1]:void 0;return z?re(this,V,te)||0:q(this,V,te)}})},3792:function($,K,T){var E=T(5397),O=T(6469),q=T(6269),B=T(1181),re=T(4913).f,z=T(1088),V=T(2529),te=T(6395),Q=T(3724),ne="Array Iterator",ie=B.set,me=B.getterFor(ne);$.exports=z(Array,"Array",(function(oe,I){ie(this,{type:ne,target:E(oe),index:0,kind:I})}),(function(){var oe=me(this),I=oe.target,F=oe.index++;if(!I||F>=I.length)return oe.target=null,V(void 0,!0);switch(oe.kind){case"keys":return V(F,!1);case"values":return V(I[F],!1)}return V([F,I[F]],!1)}),"values");var fe=q.Arguments=q.Array;if(O("keys"),O("values"),O("entries"),!te&&Q&&fe.name!=="values")try{re(fe,"name",{value:"values"})}catch{}},8598:function($,K,T){var E=T(6518),O=T(9504),q=T(7055),B=T(5397),re=T(4598),z=O([].join);E({target:"Array",proto:!0,forced:q!==Object||!re("join",",")},{join:function(V){return z(B(this),V===void 0?",":V)}})},2062:function($,K,T){var E=T(6518),O=T(9213).map;E({target:"Array",proto:!0,forced:!T(597)("map")},{map:function(q){return O(this,q,arguments.length>1?arguments[1]:void 0)}})},2712:function($,K,T){var E=T(6518),O=T(926).left,q=T(4598),B=T(9519);E({target:"Array",proto:!0,forced:!T(6193)&&B>79&&B<83||!q("reduce")},{reduce:function(re){var z=arguments.length;return O(this,re,z,z>1?arguments[1]:void 0)}})},4782:function($,K,T){var E=T(6518),O=T(4376),q=T(3517),B=T(34),re=T(5610),z=T(6198),V=T(5397),te=T(4659),Q=T(4527),ne=T(8227),ie=T(597),me=T(7680),fe=ie("slice"),oe=ne("species"),I=Array,F=Math.max;E({target:"Array",proto:!0,forced:!fe},{slice:function(J,xe){var he,le,Ce,Ne=V(this),Ue=z(Ne),He=re(J,Ue),de=re(xe===void 0?Ue:xe,Ue);if(O(Ne)&&(he=Ne.constructor,(q(he)&&(he===I||O(he.prototype))||B(he)&&(he=he[oe])===null)&&(he=void 0),he===I||he===void 0))return me(Ne,He,de);for(le=new(he===void 0?I:he)(F(de-He,0)),Ce=0;He<de;He++,Ce++)He in Ne&&te(le,Ce,Ne[He]);return Q(le,Ce),le}})},6910:function($,K,T){var E=T(6518),O=T(9504),q=T(9306),B=T(8981),re=T(6198),z=T(4606),V=T(655),te=T(9039),Q=T(4488),ne=T(4598),ie=T(3709),me=T(3763),fe=T(9519),oe=T(3607),I=[],F=O(I.sort),J=O(I.push),xe=te((function(){I.sort(void 0)})),he=te((function(){I.sort(null)})),le=ne("sort"),Ce=!te((function(){if(fe)return fe<70;if(!(ie&&ie>3)){if(me)return!0;if(oe)return oe<603;var Ne,Ue,He,de,we="";for(Ne=65;Ne<76;Ne++){switch(Ue=String.fromCharCode(Ne),Ne){case 66:case 69:case 70:case 72:He=3;break;case 68:case 71:He=4;break;default:He=2}for(de=0;de<47;de++)I.push({k:Ue+de,v:He})}for(I.sort((function(ke,_e){return _e.v-ke.v})),de=0;de<I.length;de++)Ue=I[de].k.charAt(0),we.charAt(we.length-1)!==Ue&&(we+=Ue);return we!=="DGBEFHACIJK"}}));E({target:"Array",proto:!0,forced:xe||!he||!le||!Ce},{sort:function(Ne){Ne!==void 0&&q(Ne);var Ue=B(this);if(Ce)return Ne===void 0?F(Ue):F(Ue,Ne);var He,de,we=[],ke=re(Ue);for(de=0;de<ke;de++)de in Ue&&J(we,Ue[de]);for(Q(we,(function(_e){return function(Ae,Ve){return Ve===void 0?-1:Ae===void 0?1:_e!==void 0?+_e(Ae,Ve)||0:V(Ae)>V(Ve)?1:-1}})(Ne)),He=re(we),de=0;de<He;)Ue[de]=we[de++];for(;de<ke;)z(Ue,de++);return Ue}})},4554:function($,K,T){var E=T(6518),O=T(8981),q=T(5610),B=T(1291),re=T(6198),z=T(4527),V=T(6837),te=T(1469),Q=T(4659),ne=T(4606),ie=T(597)("splice"),me=Math.max,fe=Math.min;E({target:"Array",proto:!0,forced:!ie},{splice:function(oe,I){var F,J,xe,he,le,Ce,Ne=O(this),Ue=re(Ne),He=q(oe,Ue),de=arguments.length;for(de===0?F=J=0:de===1?(F=0,J=Ue-He):(F=de-2,J=fe(me(B(I),0),Ue-He)),V(Ue+F-J),xe=te(Ne,J),he=0;he<J;he++)(le=He+he)in Ne&&Q(xe,he,Ne[le]);if(z(xe,J),F<J){for(he=He;he<Ue-J;he++)Ce=he+F,(le=he+J)in Ne?Ne[Ce]=Ne[le]:ne(Ne,Ce);for(he=Ue;he>Ue-J+F;he--)ne(Ne,he-1)}else if(F>J)for(he=Ue-J;he>He;he--)Ce=he+F-1,(le=he+J-1)in Ne?Ne[Ce]=Ne[le]:ne(Ne,Ce);for(he=0;he<F;he++)Ne[he+He]=arguments[he+2];return z(Ne,Ue-J+F),xe}})},739:function($,K,T){var E=T(6518),O=T(9039),q=T(8981),B=T(2777);E({target:"Date",proto:!0,arity:1,forced:O((function(){return new Date(NaN).toJSON()!==null||Date.prototype.toJSON.call({toISOString:function(){return 1}})!==1}))},{toJSON:function(re){var z=q(this),V=B(z,"number");return typeof V!="number"||isFinite(V)?z.toISOString():null}})},9572:function($,K,T){var E=T(9297),O=T(6840),q=T(3640),B=T(8227)("toPrimitive"),re=Date.prototype;E(re,B)||O(re,B,q)},2010:function($,K,T){var E=T(3724),O=T(350).EXISTS,q=T(9504),B=T(2106),re=Function.prototype,z=q(re.toString),V=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,te=q(V.exec);E&&!O&&B(re,"name",{configurable:!0,get:function(){try{return te(V,z(this))[1]}catch{return""}}})},3110:function($,K,T){var E=T(6518),O=T(7751),q=T(8745),B=T(9565),re=T(9504),z=T(9039),V=T(4376),te=T(4901),Q=T(5810),ne=T(757),ie=T(2195),me=T(655),fe=T(7680),oe=T(8235),I=T(3392),F=T(4495),J=T(7819),xe=String,he=O("JSON","stringify"),le=re(/./.exec),Ce=re("".charAt),Ne=re("".charCodeAt),Ue=re("".replace),He=re("".slice),de=re([].push),we=re(1.1.toString),ke=/[\uD800-\uDFFF]/g,_e=/^[\uD800-\uDBFF]$/,Ae=/^[\uDC00-\uDFFF]$/,Ve=I(),Te=Ve.length,Ke=!F||z((function(){var Be=O("Symbol")("stringify detection");return he([Be])!=="[null]"||he({a:Be})!=="{}"||he(Object(Be))!=="{}"})),je=z((function(){return he("\uDF06\uD834")!=='"\\udf06\\ud834"'||he("\uDEAD")!=='"\\udead"'})),qe=Ke?function(Be,We){var ct=fe(arguments),St=Pe(We);if(te(St)||Be!==void 0&&!ne(Be))return ct[1]=function(Mt,yt){if(te(St)&&(yt=B(St,this,xe(Mt),yt)),!ne(yt))return yt},q(he,null,ct)}:he,Re=function(Be,We,ct){var St=Ce(ct,We-1),Mt=Ce(ct,We+1);return le(_e,Be)&&!le(Ae,Mt)||le(Ae,Be)&&!le(_e,St)?"\\u"+we(Ne(Be,0),16):Be},Pe=function(Be){if(te(Be))return Be;if(V(Be)){for(var We=Be.length,ct=[],St=0;St<We;St++){var Mt=Be[St];typeof Mt=="string"?de(ct,Mt):typeof Mt!="number"&&ie(Mt)!=="Number"&&ie(Mt)!=="String"||de(ct,me(Mt))}var yt=ct.length,$e=!0;return function(dt,gt){if($e)return $e=!1,gt;if(V(this))return gt;for(var Lt=0;Lt<yt;Lt++)if(ct[Lt]===dt)return gt}}};he&&E({target:"JSON",stat:!0,arity:3,forced:Ke||je||!J},{stringify:function(Be,We,ct){var St=Pe(We),Mt=[],yt=qe(Be,(function(_n,hn){var gn=te(St)?B(St,this,xe(_n),hn):hn;return!J&&Q(gn)?Ve+(de(Mt,gn.rawJSON)-1):gn}),ct);if(typeof yt!="string"||(je&&(yt=Ue(yt,ke,Re)),J))return yt;for(var $e="",dt=yt.length,gt=0;gt<dt;gt++){var Lt=Ce(yt,gt);if(Lt==='"'){var en=oe(yt,++gt).end-1,pn=He(yt,gt,en);$e+=He(pn,0,Te)===Ve?Mt[He(pn,Te)]:'"'+pn+'"',gt=en}else $e+=Lt}return $e}})},2892:function($,K,T){var E=T(6518),O=T(6395),q=T(3724),B=T(4576),re=T(9167),z=T(9504),V=T(2796),te=T(9297),Q=T(3167),ne=T(1625),ie=T(757),me=T(2777),fe=T(9039),oe=T(8480).f,I=T(7347).f,F=T(4913).f,J=T(1240),xe=T(3802).trim,he="Number",le=B[he],Ce=re[he],Ne=le.prototype,Ue=B.TypeError,He=z("".slice),de=z("".charCodeAt),we=function(Ve){var Te,Ke,je,qe,Re,Pe,Be,We,ct=me(Ve,"number");if(ie(ct))throw new Ue("Cannot convert a Symbol value to a number");if(typeof ct=="string"&&ct.length>2){if(ct=xe(ct),(Te=de(ct,0))===43||Te===45){if((Ke=de(ct,2))===88||Ke===120)return NaN}else if(Te===48){switch(de(ct,1)){case 66:case 98:je=2,qe=49;break;case 79:case 111:je=8,qe=55;break;default:return+ct}for(Pe=(Re=He(ct,2)).length,Be=0;Be<Pe;Be++)if((We=de(Re,Be))<48||We>qe)return NaN;return parseInt(Re,je)}}return+ct},ke=V(he,!le(" 0o1")||!le("0b1")||le("+0x1")),_e=function(Ve){var Te,Ke=arguments.length<1?0:le((function(je){var qe=me(je,"number");return typeof qe=="bigint"?qe:we(qe)})(Ve));return ne(Ne,Te=this)&&fe((function(){J(Te)}))?Q(Object(Ke),this,_e):Ke};_e.prototype=Ne,ke&&!O&&(Ne.constructor=_e),E({global:!0,constructor:!0,wrap:!0,forced:ke},{Number:_e});var Ae=function(Ve,Te){for(var Ke,je=q?oe(Te):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),qe=0;je.length>qe;qe++)te(Te,Ke=je[qe])&&!te(Ve,Ke)&&F(Ve,Ke,I(Te,Ke))};O&&Ce&&Ae(re[he],Ce),(ke||O)&&Ae(re[he],le)},2637:function($,K,T){T(6518)({target:"Number",stat:!0},{isInteger:T(2087)})},9085:function($,K,T){var E=T(6518),O=T(4213);E({target:"Object",stat:!0,arity:2,forced:Object.assign!==O},{assign:O})},7427:function($,K,T){var E=T(6518),O=T(3724),q=T(2551),B=T(9306),re=T(8981),z=T(4913);O&&E({target:"Object",proto:!0,forced:q},{__defineGetter__:function(V,te){z.f(re(this),V,{get:B(te),enumerable:!0,configurable:!0})}})},3851:function($,K,T){var E=T(6518),O=T(9039),q=T(5397),B=T(7347).f,re=T(3724);E({target:"Object",stat:!0,forced:!re||O((function(){B(1)})),sham:!re},{getOwnPropertyDescriptor:function(z,V){return B(q(z),V)}})},1278:function($,K,T){var E=T(6518),O=T(3724),q=T(5031),B=T(5397),re=T(7347),z=T(4659);E({target:"Object",stat:!0,sham:!O},{getOwnPropertyDescriptors:function(V){for(var te,Q,ne=B(V),ie=re.f,me=q(ne),fe={},oe=0;me.length>oe;)(Q=ie(ne,te=me[oe++]))!==void 0&&z(fe,te,Q);return fe}})},1480:function($,K,T){var E=T(6518),O=T(9039),q=T(298).f;E({target:"Object",stat:!0,forced:O((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:q})},9773:function($,K,T){var E=T(6518),O=T(4495),q=T(9039),B=T(3717),re=T(8981);E({target:"Object",stat:!0,forced:!O||q((function(){B.f(1)}))},{getOwnPropertySymbols:function(z){var V=B.f;return V?V(re(z)):[]}})},9432:function($,K,T){var E=T(6518),O=T(8981),q=T(1072);E({target:"Object",stat:!0,forced:T(9039)((function(){q(1)}))},{keys:function(B){return q(O(B))}})},6099:function($,K,T){var E=T(2140),O=T(6840),q=T(3179);E||O(Object.prototype,"toString",q,{unsafe:!0})},825:function($,K,T){var E=T(6518),O=T(7751),q=T(8745),B=T(566),re=T(5548),z=T(8551),V=T(34),te=T(2360),Q=T(9039),ne=O("Reflect","construct"),ie=Object.prototype,me=[].push,fe=Q((function(){function F(){}return!(ne((function(){}),[],F)instanceof F)})),oe=!Q((function(){ne((function(){}))})),I=fe||oe;E({target:"Reflect",stat:!0,forced:I,sham:I},{construct:function(F,J){re(F),z(J);var xe=arguments.length<3?F:re(arguments[2]);if(oe&&!fe)return ne(F,J,xe);if(F===xe){switch(J.length){case 0:return new F;case 1:return new F(J[0]);case 2:return new F(J[0],J[1]);case 3:return new F(J[0],J[1],J[2]);case 4:return new F(J[0],J[1],J[2],J[3])}var he=[null];return q(me,he,J),new(q(B,F,he))}var le=xe.prototype,Ce=te(V(le)?le:ie),Ne=q(F,Ce,J);return V(Ne)?Ne:Ce}})},4864:function($,K,T){var E=T(3724),O=T(4576),q=T(9504),B=T(2796),re=T(3167),z=T(6699),V=T(2360),te=T(8480).f,Q=T(1625),ne=T(788),ie=T(655),me=T(1034),fe=T(8429),oe=T(1056),I=T(6840),F=T(9039),J=T(9297),xe=T(1181).enforce,he=T(7633),le=T(8227),Ce=T(3635),Ne=T(8814),Ue=le("match"),He=O.RegExp,de=He.prototype,we=O.SyntaxError,ke=q(de.exec),_e=q("".charAt),Ae=q("".replace),Ve=q("".indexOf),Te=q("".slice),Ke=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,je=/a/g,qe=/a/g,Re=new He(je)!==je,Pe=fe.MISSED_STICKY,Be=fe.UNSUPPORTED_Y;if(B("RegExp",E&&(!Re||Pe||Ce||Ne||F((function(){return qe[Ue]=!1,He(je)!==je||He(qe)===qe||String(He(je,"i"))!=="/a/i"}))))){for(var We=function(Mt,yt){var $e,dt,gt,Lt,en,pn,_n=Q(de,this),hn=ne(Mt),gn=yt===void 0,On=[],Dn=Mt;if(!_n&&hn&&gn&&Mt.constructor===We)return Mt;if((hn||Q(de,Mt))&&(Mt=Mt.source,gn&&(yt=me(Dn))),Mt=Mt===void 0?"":ie(Mt),yt=yt===void 0?"":ie(yt),Dn=Mt,Ce&&"dotAll"in je&&(dt=!!yt&&Ve(yt,"s")>-1)&&(yt=Ae(yt,/s/g,"")),$e=yt,Pe&&"sticky"in je&&(gt=!!yt&&Ve(yt,"y")>-1)&&Be&&(yt=Ae(yt,/y/g,"")),Ne&&(Lt=(function(zn){for(var ze,De=zn.length,Ze=0,st="",Ye=[],It=V(null),Me=!1,Ge=!1,et=0,Qe="";Ze<De;Ze++){if((ze=_e(zn,Ze))==="\\")ze+=_e(zn,++Ze);else if(ze==="]")Me=!1;else if(!Me)switch(!0){case ze==="[":Me=!0;break;case ze==="(":if(st+=ze,Te(zn,Ze+1,Ze+3)==="?:")continue;ke(Ke,Te(zn,Ze+1))&&(Ze+=2,Ge=!0),et++;continue;case(ze===">"&&Ge):if(Qe===""||J(It,Qe))throw new we("Invalid capture group name");It[Qe]=!0,Ye[Ye.length]=[Qe,et],Ge=!1,Qe="";continue}Ge?Qe+=ze:st+=ze}return[st,Ye]})(Mt),Mt=Lt[0],On=Lt[1]),en=re(He(Mt,yt),_n?this:de,We),(dt||gt||On.length)&&(pn=xe(en),dt&&(pn.dotAll=!0,pn.raw=We((function(zn){for(var ze,De=zn.length,Ze=0,st="",Ye=!1;Ze<De;Ze++)(ze=_e(zn,Ze))!=="\\"?Ye||ze!=="."?(ze==="["?Ye=!0:ze==="]"&&(Ye=!1),st+=ze):st+="[\\s\\S]":st+=ze+_e(zn,++Ze);return st})(Mt),$e)),gt&&(pn.sticky=!0),On.length&&(pn.groups=On)),Mt!==Dn)try{z(en,"source",Dn===""?"(?:)":Dn)}catch{}return en},ct=te(He),St=0;ct.length>St;)oe(We,He,ct[St++]);de.constructor=We,We.prototype=de,I(O,"RegExp",We,{constructor:!0})}he("RegExp")},7495:function($,K,T){var E=T(6518),O=T(7323);E({target:"RegExp",proto:!0,forced:/./.exec!==O},{exec:O})},8781:function($,K,T){var E=T(350).PROPER,O=T(6840),q=T(8551),B=T(655),re=T(9039),z=T(1034),V="toString",te=RegExp.prototype,Q=te[V],ne=re((function(){return Q.call({source:"a",flags:"b"})!=="/a/b"})),ie=E&&Q.name!==V;(ne||ie)&&O(te,V,(function(){var me=q(this);return"/"+B(me.source)+"/"+B(z(me))}),{unsafe:!0})},1699:function($,K,T){var E=T(6518),O=T(9504),q=T(5749),B=T(7750),re=T(655),z=T(1436),V=O("".indexOf);E({target:"String",proto:!0,forced:!z("includes")},{includes:function(te){return!!~V(re(B(this)),re(q(te)),arguments.length>1?arguments[1]:void 0)}})},7764:function($,K,T){var E=T(8183).charAt,O=T(655),q=T(1181),B=T(1088),re=T(2529),z="String Iterator",V=q.set,te=q.getterFor(z);B(String,"String",(function(Q){V(this,{type:z,string:O(Q),index:0})}),(function(){var Q,ne=te(this),ie=ne.string,me=ne.index;return me>=ie.length?re(void 0,!0):(Q=E(ie,me),ne.index+=Q.length,re(Q,!1))}))},8543:function($,K,T){var E=T(6518),O=T(9565),q=T(7476),B=T(3994),re=T(2529),z=T(7750),V=T(8014),te=T(655),Q=T(8551),ne=T(34),ie=T(2195),me=T(788),fe=T(1034),oe=T(5966),I=T(6840),F=T(9039),J=T(8227),xe=T(2293),he=T(7829),le=T(6682),Ce=T(1181),Ne=T(6395),Ue=J("matchAll"),He="RegExp String",de=He+" Iterator",we=Ce.set,ke=Ce.getterFor(de),_e=RegExp.prototype,Ae=TypeError,Ve=q("".indexOf),Te=q("".matchAll),Ke=!!Te&&!F((function(){Te("a",/./)})),je=B((function(Re,Pe,Be,We){we(this,{type:de,regexp:Re,string:Pe,global:Be,unicode:We,done:!1})}),He,(function(){var Re=ke(this);if(Re.done)return re(void 0,!0);var Pe=Re.regexp,Be=Re.string,We=le(Pe,Be);return We===null?(Re.done=!0,re(void 0,!0)):Re.global?(te(We[0])===""&&(Pe.lastIndex=he(Be,V(Pe.lastIndex),Re.unicode)),re(We,!1)):(Re.done=!0,re(We,!1))})),qe=function(Re){var Pe,Be,We,ct=Q(this),St=te(Re),Mt=xe(ct,RegExp),yt=te(fe(ct));return Pe=new Mt(Mt===RegExp?ct.source:ct,yt),Be=!!~Ve(yt,"g"),We=!!~Ve(yt,"u"),Pe.lastIndex=V(ct.lastIndex),new je(Pe,St,Be,We)};E({target:"String",proto:!0,forced:Ke},{matchAll:function(Re){var Pe,Be,We,ct,St=z(this);if(ne(Re)){if(me(Re)&&(Pe=te(z(fe(Re))),!~Ve(Pe,"g")))throw new Ae("`.matchAll` does not allow non-global regexes");if(Ke)return Te(St,Re);if((We=oe(Re,Ue))===void 0&&Ne&&ie(Re)==="RegExp"&&(We=qe),We)return O(We,Re,St)}else if(Ke)return Te(St,Re);return Be=te(St),ct=new RegExp(Re,"g"),Ne?O(qe,ct,Be):ct[Ue](Be)}}),Ne||Ue in _e||I(_e,Ue,qe)},1761:function($,K,T){var E=T(9565),O=T(9504),q=T(9228),B=T(8551),re=T(34),z=T(8014),V=T(655),te=T(7750),Q=T(5966),ne=T(7829),ie=T(1034),me=T(6682),fe=O("".indexOf);q("match",(function(oe,I,F){return[function(J){var xe=te(this),he=re(J)?Q(J,oe):void 0;return he?E(he,J,xe):new RegExp(J)[oe](V(xe))},function(J){var xe=B(this),he=V(J),le=F(I,xe,he);if(le.done)return le.value;var Ce=V(ie(xe));if(fe(Ce,"g")===-1)return me(xe,he);var Ne=fe(Ce,"u")!==-1;xe.lastIndex=0;for(var Ue,He=[],de=0;(Ue=me(xe,he))!==null;){var we=V(Ue[0]);He[de]=we,we===""&&(xe.lastIndex=ne(he,z(xe.lastIndex),Ne)),de++}return de===0?null:He}]}))},5440:function($,K,T){var E=T(8745),O=T(9565),q=T(9504),B=T(9228),re=T(9039),z=T(8551),V=T(4901),te=T(34),Q=T(1291),ne=T(8014),ie=T(655),me=T(7750),fe=T(7829),oe=T(5966),I=T(2478),F=T(1034),J=T(6682),xe=T(8227)("replace"),he=Math.max,le=Math.min,Ce=q([].concat),Ne=q([].push),Ue=q("".indexOf),He=q("".slice),de="a".replace(/./,"$0")==="$0",we=!!/./[xe]&&/./[xe]("a","$0")==="";B("replace",(function(ke,_e,Ae){var Ve=we?"$":"$0";return[function(Te,Ke){var je=me(this),qe=te(Te)?oe(Te,xe):void 0;return qe?O(qe,Te,je,Ke):O(_e,ie(je),Te,Ke)},function(Te,Ke){var je=z(this),qe=ie(Te);if(typeof Ke=="string"&&Ue(Ke,Ve)===-1&&Ue(Ke,"$<")===-1){var Re=Ae(_e,je,qe,Ke);if(Re.done)return Re.value}var Pe=V(Ke);Pe||(Ke=ie(Ke));var Be,We=ie(F(je)),ct=Ue(We,"g")!==-1;ct&&(Be=Ue(We,"u")!==-1,je.lastIndex=0);for(var St,Mt=[];(St=J(je,qe))!==null&&(Ne(Mt,St),ct);)ie(St[0])===""&&(je.lastIndex=fe(qe,ne(je.lastIndex),Be));for(var yt,$e="",dt=0,gt=0;gt<Mt.length;gt++){for(var Lt,en=ie((St=Mt[gt])[0]),pn=he(le(Q(St.index),qe.length),0),_n=[],hn=1;hn<St.length;hn++)Ne(_n,(yt=St[hn])===void 0?yt:String(yt));var gn=St.groups;if(Pe){var On=Ce([en],_n,pn,qe);gn!==void 0&&Ne(On,gn),Lt=ie(E(Ke,void 0,On))}else Lt=I(en,qe,pn,_n,gn,Ke);pn>=dt&&($e+=He(qe,dt,pn)+Lt,dt=pn+en.length)}return $e+He(qe,dt)}]}),!!re((function(){var ke=/./;return ke.exec=function(){var _e=[];return _e.groups={a:"7"},_e},"".replace(ke,"$<a>")!=="7"}))||!de||we)},744:function($,K,T){var E=T(9565),O=T(9504),q=T(9228),B=T(8551),re=T(34),z=T(7750),V=T(2293),te=T(7829),Q=T(8014),ne=T(655),ie=T(5966),me=T(6682),fe=T(8429),oe=T(9039),I=fe.UNSUPPORTED_Y,F=Math.min,J=O([].push),xe=O("".slice),he=!oe((function(){var Ce=/(?:)/,Ne=Ce.exec;Ce.exec=function(){return Ne.apply(this,arguments)};var Ue="ab".split(Ce);return Ue.length!==2||Ue[0]!=="a"||Ue[1]!=="b"})),le="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;q("split",(function(Ce,Ne,Ue){var He="0".split(void 0,0).length?function(de,we){return de===void 0&&we===0?[]:E(Ne,this,de,we)}:Ne;return[function(de,we){var ke=z(this),_e=re(de)?ie(de,Ce):void 0;return _e?E(_e,de,ke,we):E(He,ne(ke),de,we)},function(de,we){var ke=B(this),_e=ne(de);if(!le){var Ae=Ue(He,ke,_e,we,He!==Ne);if(Ae.done)return Ae.value}var Ve=V(ke,RegExp),Te=ke.unicode,Ke=(ke.ignoreCase?"i":"")+(ke.multiline?"m":"")+(ke.unicode?"u":"")+(I?"g":"y"),je=new Ve(I?"^(?:"+ke.source+")":ke,Ke),qe=we===void 0?4294967295:we>>>0;if(qe===0)return[];if(_e.length===0)return me(je,_e)===null?[_e]:[];for(var Re=0,Pe=0,Be=[];Pe<_e.length;){je.lastIndex=I?0:Pe;var We,ct=me(je,I?xe(_e,Pe):_e);if(ct===null||(We=F(Q(je.lastIndex+(I?Pe:0)),_e.length))===Re)Pe=te(_e,Pe,Te);else{if(J(Be,xe(_e,Re,Pe)),Be.length===qe)return Be;for(var St=1;St<=ct.length-1;St++)if(J(Be,ct[St]),Be.length===qe)return Be;Pe=Re=We}}return J(Be,xe(_e,Re)),Be}]}),le||!he,I)},2762:function($,K,T){var E=T(6518),O=T(3802).trim;E({target:"String",proto:!0,forced:T(706)("trim")},{trim:function(){return O(this)}})},6761:function($,K,T){var E=T(6518),O=T(4576),q=T(9565),B=T(9504),re=T(6395),z=T(3724),V=T(4495),te=T(9039),Q=T(9297),ne=T(1625),ie=T(8551),me=T(5397),fe=T(6969),oe=T(655),I=T(6980),F=T(2360),J=T(1072),xe=T(8480),he=T(298),le=T(3717),Ce=T(7347),Ne=T(4913),Ue=T(6801),He=T(8773),de=T(6840),we=T(2106),ke=T(5745),_e=T(6119),Ae=T(421),Ve=T(3392),Te=T(8227),Ke=T(1951),je=T(511),qe=T(8242),Re=T(687),Pe=T(1181),Be=T(9213).forEach,We=_e("hidden"),ct="Symbol",St="prototype",Mt=Pe.set,yt=Pe.getterFor(ct),$e=Object[St],dt=O.Symbol,gt=dt&&dt[St],Lt=O.RangeError,en=O.TypeError,pn=O.QObject,_n=Ce.f,hn=Ne.f,gn=he.f,On=He.f,Dn=B([].push),zn=ke("symbols"),ze=ke("op-symbols"),De=ke("wks"),Ze=!pn||!pn[St]||!pn[St].findChild,st=function(it,tt,_t){var jt=_n($e,tt);jt&&delete $e[tt],hn(it,tt,_t),jt&&it!==$e&&hn($e,tt,jt)},Ye=z&&te((function(){return F(hn({},"a",{get:function(){return hn(this,"a",{value:7}).a}})).a!==7}))?st:hn,It=function(it,tt){var _t=zn[it]=F(gt);return Mt(_t,{type:ct,tag:it,description:tt}),z||(_t.description=tt),_t},Me=function(it,tt,_t){it===$e&&Me(ze,tt,_t),ie(it);var jt=fe(tt);return ie(_t),Q(zn,jt)?(_t.enumerable?(Q(it,We)&&it[We][jt]&&(it[We][jt]=!1),_t=F(_t,{enumerable:I(0,!1)})):(Q(it,We)||hn(it,We,I(1,F(null))),it[We][jt]=!0),Ye(it,jt,_t)):hn(it,jt,_t)},Ge=function(it,tt){ie(it);var _t=me(tt),jt=J(_t).concat(ht(_t));return Be(jt,(function(Dt){z&&!q(et,_t,Dt)||Me(it,Dt,_t[Dt])})),it},et=function(it){var tt=fe(it),_t=q(On,this,tt);return!(this===$e&&Q(zn,tt)&&!Q(ze,tt))&&(!(_t||!Q(this,tt)||!Q(zn,tt)||Q(this,We)&&this[We][tt])||_t)},Qe=function(it,tt){var _t=me(it),jt=fe(tt);if(_t!==$e||!Q(zn,jt)||Q(ze,jt)){var Dt=_n(_t,jt);return!Dt||!Q(zn,jt)||Q(_t,We)&&_t[We][jt]||(Dt.enumerable=!0),Dt}},Le=function(it){var tt=gn(me(it)),_t=[];return Be(tt,(function(jt){Q(zn,jt)||Q(Ae,jt)||Dn(_t,jt)})),_t},ht=function(it){var tt=it===$e,_t=gn(tt?ze:me(it)),jt=[];return Be(_t,(function(Dt){!Q(zn,Dt)||tt&&!Q($e,Dt)||Dn(jt,zn[Dt])})),jt};V||(dt=function(){if(ne(gt,this))throw new en("Symbol is not a constructor");var it=arguments.length&&arguments[0]!==void 0?oe(arguments[0]):void 0,tt=Ve(it),_t=function(jt){var Dt=this===void 0?O:this;Dt===$e&&q(_t,ze,jt),Q(Dt,We)&&Q(Dt[We],tt)&&(Dt[We][tt]=!1);var Rt=I(1,jt);try{Ye(Dt,tt,Rt)}catch(tn){if(!(tn instanceof Lt))throw tn;st(Dt,tt,Rt)}};return z&&Ze&&Ye($e,tt,{configurable:!0,set:_t}),It(tt,it)},de(gt=dt[St],"toString",(function(){return yt(this).tag})),de(dt,"withoutSetter",(function(it){return It(Ve(it),it)})),He.f=et,Ne.f=Me,Ue.f=Ge,Ce.f=Qe,xe.f=he.f=Le,le.f=ht,Ke.f=function(it){return It(Te(it),it)},z&&(we(gt,"description",{configurable:!0,get:function(){return yt(this).description}}),re||de($e,"propertyIsEnumerable",et,{unsafe:!0}))),E({global:!0,constructor:!0,wrap:!0,forced:!V,sham:!V},{Symbol:dt}),Be(J(De),(function(it){je(it)})),E({target:ct,stat:!0,forced:!V},{useSetter:function(){Ze=!0},useSimple:function(){Ze=!1}}),E({target:"Object",stat:!0,forced:!V,sham:!z},{create:function(it,tt){return tt===void 0?F(it):Ge(F(it),tt)},defineProperty:Me,defineProperties:Ge,getOwnPropertyDescriptor:Qe}),E({target:"Object",stat:!0,forced:!V},{getOwnPropertyNames:Le}),qe(),Re(dt,ct),Ae[We]=!0},9463:function($,K,T){var E=T(6518),O=T(3724),q=T(4576),B=T(9504),re=T(9297),z=T(4901),V=T(1625),te=T(655),Q=T(2106),ne=T(7740),ie=q.Symbol,me=ie&&ie.prototype;if(O&&z(ie)&&(!("description"in me)||ie().description!==void 0)){var fe={},oe=function(){var Ce=arguments.length<1||arguments[0]===void 0?void 0:te(arguments[0]),Ne=V(me,this)?new ie(Ce):Ce===void 0?ie():ie(Ce);return Ce===""&&(fe[Ne]=!0),Ne};ne(oe,ie),oe.prototype=me,me.constructor=oe;var I=String(ie("description detection"))==="Symbol(description detection)",F=B(me.valueOf),J=B(me.toString),xe=/^Symbol\((.*)\)[^)]+$/,he=B("".replace),le=B("".slice);Q(me,"description",{configurable:!0,get:function(){var Ce=F(this);if(re(fe,Ce))return"";var Ne=J(Ce),Ue=I?le(Ne,7,-1):he(Ne,xe,"$1");return Ue===""?void 0:Ue}}),E({global:!0,constructor:!0,forced:!0},{Symbol:oe})}},1510:function($,K,T){var E=T(6518),O=T(7751),q=T(9297),B=T(655),re=T(5745),z=T(1296),V=re("string-to-symbol-registry"),te=re("symbol-to-string-registry");E({target:"Symbol",stat:!0,forced:!z},{for:function(Q){var ne=B(Q);if(q(V,ne))return V[ne];var ie=O("Symbol")(ne);return V[ne]=ie,te[ie]=ne,ie}})},2259:function($,K,T){T(511)("iterator")},2675:function($,K,T){T(6761),T(1510),T(7812),T(3110),T(9773)},7812:function($,K,T){var E=T(6518),O=T(9297),q=T(757),B=T(6823),re=T(5745),z=T(1296),V=re("symbol-to-string-registry");E({target:"Symbol",stat:!0,forced:!z},{keyFor:function(te){if(!q(te))throw new TypeError(B(te)+" is not a symbol");if(O(V,te))return V[te]}})},5700:function($,K,T){var E=T(511),O=T(8242);E("toPrimitive"),O()},8344:function($,K,T){T(8543)},3500:function($,K,T){var E=T(4576),O=T(7400),q=T(9296),B=T(235),re=T(6699),z=function(te){if(te&&te.forEach!==B)try{re(te,"forEach",B)}catch{te.forEach=B}};for(var V in O)O[V]&&z(E[V]&&E[V].prototype);z(q)},2953:function($,K,T){var E=T(4576),O=T(7400),q=T(9296),B=T(3792),re=T(6699),z=T(687),V=T(8227)("iterator"),te=B.values,Q=function(ie,me){if(ie){if(ie[V]!==te)try{re(ie,V,te)}catch{ie[V]=te}if(z(ie,me,!0),O[me]){for(var fe in B)if(ie[fe]!==B[fe])try{re(ie,fe,B[fe])}catch{ie[fe]=B[fe]}}}};for(var ne in O)Q(E[ne]&&E[ne].prototype,ne);Q(q,"DOMTokenList")}},u={};function d($){var K=u[$];if(K!==void 0)return K.exports;var T=u[$]={exports:{}};return c[$].call(T.exports,T,T.exports,d),T.exports}d.d=function($,K){for(var T in K)d.o(K,T)&&!d.o($,T)&&Object.defineProperty($,T,{enumerable:!0,get:K[T]})},d.g=(function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}})(),d.o=function($,K){return Object.prototype.hasOwnProperty.call($,K)},d.r=function($){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty($,Symbol.toStringTag,{value:"Module"}),Object.defineProperty($,"__esModule",{value:!0})};var h={};function f($){return(function(K){if(Array.isArray(K))return x(K)})($)||(function(K){if(typeof Symbol<"u"&&K[Symbol.iterator]!=null||K["@@iterator"]!=null)return Array.from(K)})($)||p($)||(function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
  8322. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function p($,K){if($){if(typeof $=="string")return x($,K);var T={}.toString.call($).slice(8,-1);return T==="Object"&&$.constructor&&(T=$.constructor.name),T==="Map"||T==="Set"?Array.from($):T==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(T)?x($,K):void 0}}function x($,K){(K==null||K>$.length)&&(K=$.length);for(var T=0,E=Array(K);T<K;T++)E[T]=$[T];return E}function v($){return v=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(K){return typeof K}:function(K){return K&&typeof Symbol=="function"&&K.constructor===Symbol&&K!==Symbol.prototype?"symbol":typeof K},v($)}function g($,K){for(var T=0;T<K.length;T++){var E=K[T];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty($,_(E.key),E)}}function y($,K,T){return(K=_(K))in $?Object.defineProperty($,K,{value:T,enumerable:!0,configurable:!0,writable:!0}):$[K]=T,$}function _($){var K=(function(T,E){if(v(T)!="object"||!T)return T;var O=T[Symbol.toPrimitive];if(O!==void 0){var q=O.call(T,E);if(v(q)!="object")return q;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(T)})($,"string");return v(K)=="symbol"?K:K+""}d.r(h),d.d(h,{SimpleKeyboard:function(){return be},default:function(){return Ee}}),d(5276),d(8598),d(4782),d(4554),d(2010),d(7427),d(6099),d(7495),d(8781),d(5440),d(744),d(2762),typeof Element>"u"||"remove"in Element.prototype||(Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)}),typeof self<"u"&&"document"in self&&((!("classList"in document.createElement("_"))||document.createElementNS&&!("classList"in document.createElementNS("http://www.w3.org/2000/svg","g")))&&(function($){if("Element"in $){var K="classList",T="prototype",E=$.Element[T],O=Object,q=String[T].trim||function(){return this.replace(/^\s+|\s+$/g,"")},B=Array[T].indexOf||function(ie){for(var me=0,fe=this.length;me<fe;me++)if(me in this&&this[me]===ie)return me;return-1},re=function(ie,me){this.name=ie,this.code=DOMException[ie],this.message=me},z=function(ie,me){if(me==="")throw new re("SYNTAX_ERR","The token must not be empty.");if(/\s/.test(me))throw new re("INVALID_CHARACTER_ERR","The token must not contain space characters.");return B.call(ie,me)},V=function(ie){for(var me=q.call(ie.getAttribute("class")||""),fe=me?me.split(/\s+/):[],oe=0,I=fe.length;oe<I;oe++)this.push(fe[oe]);this._updateClassName=function(){ie.setAttribute("class",this.toString())}},te=V[T]=[],Q=function(){return new V(this)};if(re[T]=Error[T],te.item=function(ie){return this[ie]||null},te.contains=function(ie){return~z(this,ie+"")},te.add=function(){var ie,me=arguments,fe=0,oe=me.length,I=!1;do~z(this,ie=me[fe]+"")||(this.push(ie),I=!0);while(++fe<oe);I&&this._updateClassName()},te.remove=function(){var ie,me,fe=arguments,oe=0,I=fe.length,F=!1;do for(me=z(this,ie=fe[oe]+"");~me;)this.splice(me,1),F=!0,me=z(this,ie);while(++oe<I);F&&this._updateClassName()},te.toggle=function(ie,me){var fe=this.contains(ie),oe=fe?me!==!0&&"remove":me!==!1&&"add";return oe&&this[oe](ie),me===!0||me===!1?me:!fe},te.replace=function(ie,me){var fe=z(ie+"");~fe&&(this.splice(fe,1,me),this._updateClassName())},te.toString=function(){return this.join(" ")},O.defineProperty){var ne={get:Q,enumerable:!0,configurable:!0};try{O.defineProperty(E,K,ne)}catch(ie){ie.number!==void 0&&ie.number!==-2146823252||(ne.enumerable=!1,O.defineProperty(E,K,ne))}}else O[T].__defineGetter__&&E.__defineGetter__(K,Q)}})(self),(function(){var $=document.createElement("_");if($.classList.add("c1","c2"),!$.classList.contains("c2")){var K=function(E){var O=DOMTokenList.prototype[E];DOMTokenList.prototype[E]=function(q){var B,re=arguments.length;for(B=0;B<re;B++)q=arguments[B],O.call(this,q)}};K("add"),K("remove")}if($.classList.toggle("c3",!1),$.classList.contains("c3")){var T=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(E,O){return 1 in arguments&&!this.contains(E)==!O?O:T.call(this,E)}}"replace"in document.createElement("_").classList||(DOMTokenList.prototype.replace=function(E,O){var q=this.toString().split(" "),B=q.indexOf(E+"");~B&&(q=q.slice(B),this.remove.apply(this,q),this.add(O),this.add.apply(this,q.slice(1)))}),$=null})()),d(2675),d(9463),d(2259),d(5700),d(8706),d(2008),d(3418),d(4423),d(3792),d(2062),d(6910),d(739),d(9572),d(2892),d(9085),d(3851),d(1278),d(9432),d(4864),d(1699),d(7764),d(8344),d(3500),d(2953),d(2712),d(2637),d(1480),d(825),d(1761);var N=(function(){return $=function E(O){var q=O.getOptions,B=O.getCaretPosition,re=O.getCaretPositionEnd,z=O.dispatch;(function(V,te){if(!(V instanceof te))throw new TypeError("Cannot call a class as a function")})(this,E),y(this,"getOptions",void 0),y(this,"getCaretPosition",void 0),y(this,"getCaretPositionEnd",void 0),y(this,"dispatch",void 0),y(this,"maxLengthReached",void 0),y(this,"isStandardButton",(function(V){return V&&!(V[0]==="{"&&V[V.length-1]==="}")})),this.getOptions=q,this.getCaretPosition=B,this.getCaretPositionEnd=re,this.dispatch=z,E.bindMethods(E,this)},K=[{key:"getButtonType",value:function(E){return E.includes("{")&&E.includes("}")&&E!=="{//}"?"functionBtn":"standardBtn"}},{key:"getButtonClass",value:function(E){var O=this.getButtonType(E),q=E.replace("{","").replace("}",""),B="";return O!=="standardBtn"&&(B=" hg-button-".concat(q)),"hg-".concat(O).concat(B)}},{key:"getDefaultDiplay",value:function(){return{"{bksp}":"backspace","{backspace}":"backspace","{enter}":"< enter","{shift}":"shift","{shiftleft}":"shift","{shiftright}":"shift","{alt}":"alt","{s}":"shift","{tab}":"tab","{lock}":"caps","{capslock}":"caps","{accept}":"Submit","{space}":" ","{//}":" ","{esc}":"esc","{escape}":"esc","{f1}":"f1","{f2}":"f2","{f3}":"f3","{f4}":"f4","{f5}":"f5","{f6}":"f6","{f7}":"f7","{f8}":"f8","{f9}":"f9","{f10}":"f10","{f11}":"f11","{f12}":"f12","{numpaddivide}":"/","{numlock}":"lock","{arrowup}":"↑","{arrowleft}":"←","{arrowdown}":"↓","{arrowright}":"→","{prtscr}":"print","{scrolllock}":"scroll","{pause}":"pause","{insert}":"ins","{home}":"home","{pageup}":"up","{delete}":"del","{forwarddelete}":"del","{end}":"end","{pagedown}":"down","{numpadmultiply}":"*","{numpadsubtract}":"-","{numpadadd}":"+","{numpadenter}":"enter","{period}":".","{numpaddecimal}":".","{numpad0}":"0","{numpad1}":"1","{numpad2}":"2","{numpad3}":"3","{numpad4}":"4","{numpad5}":"5","{numpad6}":"6","{numpad7}":"7","{numpad8}":"8","{numpad9}":"9"}}},{key:"getButtonDisplayName",value:function(E,O){return(O=arguments.length>2&&arguments[2]!==void 0&&arguments[2]?Object.assign({},this.getDefaultDiplay(),O):O||this.getDefaultDiplay())[E]||E}},{key:"getUpdatedInput",value:function(E,O,q){var B=arguments.length>3&&arguments[3]!==void 0?arguments[3]:q,re=arguments.length>4&&arguments[4]!==void 0&&arguments[4],z=this.getOptions(),V=[q,B,re],te=O;return(E==="{bksp}"||E==="{backspace}")&&te.length>0?te=this.removeAt.apply(this,[te].concat(V)):(E==="{delete}"||E==="{forwarddelete}")&&te.length>0?te=this.removeForwardsAt.apply(this,[te].concat(V)):E==="{space}"?te=this.addStringAt.apply(this,[te," "].concat(V)):E!=="{tab}"||typeof z.tabCharOnTab=="boolean"&&z.tabCharOnTab===!1?E!=="{enter}"&&E!=="{numpadenter}"||!z.newLineOnEnter?E.includes("numpad")&&Number.isInteger(Number(E[E.length-2]))?te=this.addStringAt.apply(this,[te,E[E.length-2]].concat(V)):E==="{numpaddivide}"?te=this.addStringAt.apply(this,[te,"/"].concat(V)):E==="{numpadmultiply}"?te=this.addStringAt.apply(this,[te,"*"].concat(V)):E==="{numpadsubtract}"?te=this.addStringAt.apply(this,[te,"-"].concat(V)):E==="{numpadadd}"?te=this.addStringAt.apply(this,[te,"+"].concat(V)):E==="{numpaddecimal}"?te=this.addStringAt.apply(this,[te,"."].concat(V)):E==="{"||E==="}"?te=this.addStringAt.apply(this,[te,E].concat(V)):E.includes("{")||E.includes("}")||(te=this.addStringAt.apply(this,[te,E].concat(V))):te=this.addStringAt.apply(this,[te,`
  8323. `].concat(V)):te=this.addStringAt.apply(this,[te," "].concat(V)),z.debug&&console.log("Input will be: "+te),te}},{key:"updateCaretPos",value:function(E){var O=arguments.length>1&&arguments[1]!==void 0&&arguments[1],q=this.updateCaretPosAction(E,O);this.dispatch((function(B){B.setCaretPosition(q)}))}},{key:"updateCaretPosAction",value:function(E){var O=arguments.length>1&&arguments[1]!==void 0&&arguments[1],q=this.getOptions(),B=this.getCaretPosition();return B!=null&&(O?B>0&&(B-=E):B+=E),q.debug&&console.log("Caret at:",B),B}},{key:"addStringAt",value:function(E,O){var q,B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:E.length,re=arguments.length>3&&arguments[3]!==void 0?arguments[3]:E.length,z=arguments.length>4&&arguments[4]!==void 0&&arguments[4];return B||B===0?(q=[E.slice(0,B),O,E.slice(re)].join(""),this.isMaxLengthReached()||z&&this.updateCaretPos(O.length)):q=E+O,q}},{key:"removeAt",value:function(E){var O,q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:E.length,B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:E.length,re=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(q===0&&B===0)return E;if(q===B){var z=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;q&&q>=0?E.substring(q-2,q).match(z)?(O=E.substr(0,q-2)+E.substr(q),re&&this.updateCaretPos(2,!0)):(O=E.substr(0,q-1)+E.substr(q),re&&this.updateCaretPos(1,!0)):E.slice(-2).match(z)?(O=E.slice(0,-2),re&&this.updateCaretPos(2,!0)):(O=E.slice(0,-1),re&&this.updateCaretPos(1,!0))}else O=E.slice(0,q)+E.slice(B),re&&this.dispatch((function(V){V.setCaretPosition(q)}));return O}},{key:"removeForwardsAt",value:function(E){var O,q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:E.length,B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:E.length,re=arguments.length>3&&arguments[3]!==void 0&&arguments[3];return E!=null&&E.length&&q!==null?(q===B?O=E.substring(q,q+2).match(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g)?E.substr(0,q)+E.substr(q+2):E.substr(0,q)+E.substr(q+1):(O=E.slice(0,q)+E.slice(B),re&&this.dispatch((function(z){z.setCaretPosition(q)}))),O):E}},{key:"handleMaxLength",value:function(E,O){var q=this.getOptions(),B=q.maxLength,re=E[q.inputName||"default"],z=O.length-1>=B;if(O.length<=re.length)return!1;if(Number.isInteger(B))return q.debug&&console.log("maxLength (num) reached:",z),z?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if(v(B)==="object"){var V=O.length-1>=B[q.inputName||"default"];return q.debug&&console.log("maxLength (obj) reached:",V),V?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1)}}},{key:"isMaxLengthReached",value:function(){return!!this.maxLengthReached}},{key:"isTouchDevice",value:function(){return"ontouchstart"in window||navigator.maxTouchPoints}},{key:"pointerEventsSupported",value:function(){return!!window.PointerEvent}},{key:"camelCase",value:function(E){return E?E.toLowerCase().trim().split(/[.\-_\s]/g).reduce((function(O,q){return q.length?O+q[0].toUpperCase()+q.slice(1):O})):""}},{key:"chunkArray",value:function(E,O){return f(Array(Math.ceil(E.length/O))).map((function(q,B){return E.slice(O*B,O+O*B)}))}},{key:"escapeRegex",value:function(E){return E.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}},{key:"getRtlOffset",value:function(E,O){var q=E,B=O.indexOf("‫");return B<E&&B!=-1&&q--,O.indexOf("‬")<E&&B!=-1&&q--,q<0?0:q}},{key:"isConstructor",value:function(E){try{Reflect.construct(String,[],E)}catch{return!1}return!0}}],T=[{key:"bindMethods",value:function(E,O){var q,B=(function(z,V){var te=typeof Symbol<"u"&&z[Symbol.iterator]||z["@@iterator"];if(!te){if(Array.isArray(z)||(te=p(z))||V){te&&(z=te);var Q=0,ne=function(){};return{s:ne,n:function(){return Q>=z.length?{done:!0}:{done:!1,value:z[Q++]}},e:function(oe){throw oe},f:ne}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
  8324. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var ie,me=!0,fe=!1;return{s:function(){te=te.call(z)},n:function(){var oe=te.next();return me=oe.done,oe},e:function(oe){fe=!0,ie=oe},f:function(){try{me||te.return==null||te.return()}finally{if(fe)throw ie}}}})(Object.getOwnPropertyNames(E.prototype));try{for(B.s();!(q=B.n()).done;){var re=q.value;re==="constructor"||re==="bindMethods"||(O[re]=O[re].bind(O))}}catch(z){B.e(z)}finally{B.f()}}}],K&&g($.prototype,K),T&&g($,T),Object.defineProperty($,"prototype",{writable:!1}),$;var $,K,T})();y(N,"noop",(function(){}));var A=N;function C($){return C=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(K){return typeof K}:function(K){return K&&typeof Symbol=="function"&&K.constructor===Symbol&&K!==Symbol.prototype?"symbol":typeof K},C($)}function j($,K){for(var T=0;T<K.length;T++){var E=K[T];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty($,R(E.key),E)}}function k($,K,T){return(K=R(K))in $?Object.defineProperty($,K,{value:T,enumerable:!0,configurable:!0,writable:!0}):$[K]=T,$}function R($){var K=(function(T,E){if(C(T)!="object"||!T)return T;var O=T[Symbol.toPrimitive];if(O!==void 0){var q=O.call(T,E);if(C(q)!="object")return q;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(T)})($,"string");return C(K)=="symbol"?K:K+""}var M=(function(){return $=function E(O){var q=this,B=O.dispatch,re=O.getOptions;(function(z,V){if(!(z instanceof V))throw new TypeError("Cannot call a class as a function")})(this,E),k(this,"getOptions",void 0),k(this,"dispatch",void 0),k(this,"isModifierKey",(function(z){return z.altKey||z.ctrlKey||z.shiftKey||["Tab","CapsLock","Esc","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(z.code||z.key||q.keyCodeToKey(z?.keyCode))})),this.dispatch=B,this.getOptions=re,A.bindMethods(E,this)},K=[{key:"handleHighlightKeyDown",value:function(E){var O=this.getOptions();O.physicalKeyboardHighlightPreventDefault&&this.isModifierKey(E)&&(E.preventDefault(),E.stopImmediatePropagation());var q=this.getSimpleKeyboardLayoutKey(E);this.dispatch((function(B){var re,z,V=B.getButtonElement(q),te=B.getButtonElement("{".concat(q,"}"));if(V)re=V,z=q;else{if(!te)return;re=te,z="{".concat(q,"}")}var Q,ne,ie,me,fe=function(I){I.style.background=O.physicalKeyboardHighlightBgColor||"#dadce4",I.style.color=O.physicalKeyboardHighlightTextColor||"black"};if(re)if(Array.isArray(re)){if(re.forEach((function(I){return fe(I)})),O.physicalKeyboardHighlightPress)if(O.physicalKeyboardHighlightPressUsePointerEvents)(Q=re[0])===null||Q===void 0||(ne=Q.onpointerdown)===null||ne===void 0||ne.call(Q,E);else if(O.physicalKeyboardHighlightPressUseClick){var oe;(oe=re[0])===null||oe===void 0||oe.click()}else B.handleButtonClicked(z,E)}else fe(re),O.physicalKeyboardHighlightPress&&(O.physicalKeyboardHighlightPressUsePointerEvents?(ie=re)===null||ie===void 0||(me=ie.onpointerdown)===null||me===void 0||me.call(ie,E):O.physicalKeyboardHighlightPressUseClick?re.click():B.handleButtonClicked(z,E))}))}},{key:"handleHighlightKeyUp",value:function(E){var O=this.getOptions();O.physicalKeyboardHighlightPreventDefault&&this.isModifierKey(E)&&(E.preventDefault(),E.stopImmediatePropagation());var q=this.getSimpleKeyboardLayoutKey(E);this.dispatch((function(B){var re,z,V,te=B.getButtonElement(q)||B.getButtonElement("{".concat(q,"}")),Q=function(ne){ne.removeAttribute&&ne.removeAttribute("style")};te&&(Array.isArray(te)?(te.forEach((function(ne){return Q(ne)})),O.physicalKeyboardHighlightPressUsePointerEvents&&((re=te[0])===null||re===void 0||(z=re.onpointerup)===null||z===void 0||z.call(re,E))):(Q(te),O.physicalKeyboardHighlightPressUsePointerEvents&&(te==null||(V=te.onpointerup)===null||V===void 0||V.call(te,E))))}))}},{key:"getSimpleKeyboardLayoutKey",value:function(E){var O,q="",B=E.code||E.key||this.keyCodeToKey(E?.keyCode);return(q=B!=null&&B.includes("Numpad")||B!=null&&B.includes("Shift")||B!=null&&B.includes("Space")||B!=null&&B.includes("Backspace")||B!=null&&B.includes("Control")||B!=null&&B.includes("Alt")||B!=null&&B.includes("Meta")?E.code||"":E.key||this.keyCodeToKey(E?.keyCode)||"").length>1?(O=q)===null||O===void 0?void 0:O.toLowerCase():q}},{key:"keyCodeToKey",value:function(E){return{8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",91:"Meta",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9",106:"NumpadMultiply",107:"NumpadAdd",109:"NumpadSubtract",110:"NumpadDecimal",111:"NumpadDivide",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",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"}[E]||""}}],K&&j($.prototype,K),T&&j($,T),Object.defineProperty($,"prototype",{writable:!1}),$;var $,K,T})();function D($){return D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(K){return typeof K}:function(K){return K&&typeof Symbol=="function"&&K.constructor===Symbol&&K!==Symbol.prototype?"symbol":typeof K},D($)}function G($,K){for(var T=0;T<K.length;T++){var E=K[T];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty($,W(E.key),E)}}function U($,K,T){return(K=W(K))in $?Object.defineProperty($,K,{value:T,enumerable:!0,configurable:!0,writable:!0}):$[K]=T,$}function W($){var K=(function(T,E){if(D(T)!="object"||!T)return T;var O=T[Symbol.toPrimitive];if(O!==void 0){var q=O.call(T,E);if(D(q)!="object")return q;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(T)})($,"string");return D(K)=="symbol"?K:K+""}var L=(function(){return $=function E(O){var q=O.utilities,B=O.options;(function(re,z){if(!(re instanceof z))throw new TypeError("Cannot call a class as a function")})(this,E),U(this,"utilities",void 0),U(this,"options",void 0),U(this,"candidateBoxElement",void 0),U(this,"pageIndex",0),U(this,"pageSize",void 0),this.utilities=q,this.options=B,A.bindMethods(E,this),this.pageSize=this.utilities.getOptions().layoutCandidatesPageSize||5},K=[{key:"destroy",value:function(){this.candidateBoxElement&&(this.candidateBoxElement.remove(),this.pageIndex=0)}},{key:"show",value:function(E){var O=this,q=E.candidateValue,B=E.targetElement,re=E.onSelect;if(q&&q.length){var z=this.utilities.chunkArray(q.split(" "),this.pageSize);this.renderPage({candidateListPages:z,targetElement:B,pageIndex:this.pageIndex,nbPages:z.length,onItemSelected:function(V,te){re(V,te),O.destroy()}})}}},{key:"renderPage",value:function(E){var O,q=this,B=E.candidateListPages,re=E.targetElement,z=E.pageIndex,V=E.nbPages,te=E.onItemSelected;(O=this.candidateBoxElement)===null||O===void 0||O.remove(),this.candidateBoxElement=document.createElement("div"),this.candidateBoxElement.className="hg-candidate-box";var Q=document.createElement("ul");Q.className="hg-candidate-box-list",B[z].forEach((function(F){var J,xe=document.createElement("li"),he=function(){var le=new(q.options.useTouchEvents?TouchEvent:MouseEvent)("click");return Object.defineProperty(le,"target",{value:xe}),le};xe.className="hg-candidate-box-list-item",xe.innerHTML=((J=q.options.display)===null||J===void 0?void 0:J[F])||F,q.options.useTouchEvents?xe.ontouchstart=function(le){return te(F,le||he())}:xe.onclick=function(){var le=arguments.length>0&&arguments[0]!==void 0?arguments[0]:he();return te(F,le)},Q.appendChild(xe)}));var ne=z>0,ie=document.createElement("div");ie.classList.add("hg-candidate-box-prev"),ne&&ie.classList.add("hg-candidate-box-btn-active");var me=function(){ne&&q.renderPage({candidateListPages:B,targetElement:re,pageIndex:z-1,nbPages:V,onItemSelected:te})};this.options.useTouchEvents?ie.ontouchstart=me:ie.onclick=me,this.candidateBoxElement.appendChild(ie),this.candidateBoxElement.appendChild(Q);var fe=z<V-1,oe=document.createElement("div");oe.classList.add("hg-candidate-box-next"),fe&&oe.classList.add("hg-candidate-box-btn-active");var I=function(){fe&&q.renderPage({candidateListPages:B,targetElement:re,pageIndex:z+1,nbPages:V,onItemSelected:te})};this.options.useTouchEvents?oe.ontouchstart=I:oe.onclick=I,this.candidateBoxElement.appendChild(oe),re.prepend(this.candidateBoxElement)}}],K&&G($.prototype,K),T&&G($,T),Object.defineProperty($,"prototype",{writable:!1}),$;var $,K,T})(),ee=L;function ae($){return(function(K){if(Array.isArray(K))return Y(K)})($)||(function(K){if(typeof Symbol<"u"&&K[Symbol.iterator]!=null||K["@@iterator"]!=null)return Array.from(K)})($)||(function(K,T){if(K){if(typeof K=="string")return Y(K,T);var E={}.toString.call(K).slice(8,-1);return E==="Object"&&K.constructor&&(E=K.constructor.name),E==="Map"||E==="Set"?Array.from(K):E==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(E)?Y(K,T):void 0}})($)||(function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
  8325. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function Y($,K){(K==null||K>$.length)&&(K=$.length);for(var T=0,E=Array(K);T<K;T++)E[T]=$[T];return E}function se($){return se=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(K){return typeof K}:function(K){return K&&typeof Symbol=="function"&&K.constructor===Symbol&&K!==Symbol.prototype?"symbol":typeof K},se($)}function ce($,K){var T=Object.keys($);if(Object.getOwnPropertySymbols){var E=Object.getOwnPropertySymbols($);K&&(E=E.filter((function(O){return Object.getOwnPropertyDescriptor($,O).enumerable}))),T.push.apply(T,E)}return T}function ye($,K){for(var T=0;T<K.length;T++){var E=K[T];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty($,ue(E.key),E)}}function Z($,K,T){return(K=ue(K))in $?Object.defineProperty($,K,{value:T,enumerable:!0,configurable:!0,writable:!0}):$[K]=T,$}function ue($){var K=(function(T,E){if(se(T)!="object"||!T)return T;var O=T[Symbol.toPrimitive];if(O!==void 0){var q=O.call(T,E);if(se(q)!="object")return q;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(T)})($,"string");return se(K)=="symbol"?K:K+""}var pe=(function(){return $=function E(O,q){var B=this;if((function(me,fe){if(!(me instanceof fe))throw new TypeError("Cannot call a class as a function")})(this,E),Z(this,"input",void 0),Z(this,"options",void 0),Z(this,"utilities",void 0),Z(this,"caretPosition",void 0),Z(this,"caretPositionEnd",void 0),Z(this,"keyboardDOM",void 0),Z(this,"keyboardPluginClasses",void 0),Z(this,"keyboardDOMClass",void 0),Z(this,"buttonElements",void 0),Z(this,"currentInstanceName",void 0),Z(this,"allKeyboardInstances",void 0),Z(this,"keyboardInstanceNames",void 0),Z(this,"isFirstKeyboardInstance",void 0),Z(this,"physicalKeyboard",void 0),Z(this,"modules",void 0),Z(this,"activeButtonClass",void 0),Z(this,"holdInteractionTimeout",void 0),Z(this,"holdTimeout",void 0),Z(this,"isMouseHold",void 0),Z(this,"initialized",void 0),Z(this,"candidateBox",void 0),Z(this,"keyboardRowsDOM",void 0),Z(this,"defaultName","default"),Z(this,"activeInputElement",null),Z(this,"handleParams",(function(me,fe){var oe,I,F;if(typeof me=="string")oe=me.split(".").join(""),I=document.querySelector(".".concat(oe)),F=fe;else if(me instanceof HTMLDivElement){if(!me.className)throw console.warn("Any DOM element passed as parameter must have a class."),new Error("KEYBOARD_DOM_CLASS_ERROR");oe=me.className.split(" ")[0],I=me,F=fe}else oe="simple-keyboard",I=document.querySelector(".".concat(oe)),F=me;return{keyboardDOMClass:oe,keyboardDOM:I,options:F}})),Z(this,"getOptions",(function(){return B.options})),Z(this,"getCaretPosition",(function(){return B.caretPosition})),Z(this,"getCaretPositionEnd",(function(){return B.caretPositionEnd})),Z(this,"registerModule",(function(me,fe){B.modules[me]||(B.modules[me]={}),fe(B.modules[me])})),Z(this,"getKeyboardClassString",(function(){for(var me=arguments.length,fe=new Array(me),oe=0;oe<me;oe++)fe[oe]=arguments[oe];return[B.keyboardDOMClass].concat(fe).filter((function(I){return!!I})).join(" ")})),typeof window<"u"){var re=this.handleParams(O,q),z=re.keyboardDOMClass,V=re.keyboardDOM,te=re.options,Q=te===void 0?{}:te;this.utilities=new A({getOptions:this.getOptions,getCaretPosition:this.getCaretPosition,getCaretPositionEnd:this.getCaretPositionEnd,dispatch:this.dispatch}),this.caretPosition=null,this.caretPositionEnd=null,this.keyboardDOM=V,this.options=(function(me){for(var fe=1;fe<arguments.length;fe++){var oe=arguments[fe]!=null?arguments[fe]:{};fe%2?ce(Object(oe),!0).forEach((function(I){Z(me,I,oe[I])})):Object.getOwnPropertyDescriptors?Object.defineProperties(me,Object.getOwnPropertyDescriptors(oe)):ce(Object(oe)).forEach((function(I){Object.defineProperty(me,I,Object.getOwnPropertyDescriptor(oe,I))}))}return me})({layoutName:"default",theme:"hg-theme-default",inputName:"default",preventMouseDownDefault:!1,enableLayoutCandidates:!0,excludeFromLayout:{}},Q),this.keyboardPluginClasses="",A.bindMethods(E,this);var ne=this.options.inputName,ie=ne===void 0?this.defaultName:ne;if(this.input={},this.input[ie]="",this.keyboardDOMClass=z,this.buttonElements={},window.SimpleKeyboardInstances||(window.SimpleKeyboardInstances={}),this.currentInstanceName=this.utilities.camelCase(this.keyboardDOMClass),window.SimpleKeyboardInstances[this.currentInstanceName]=this,this.allKeyboardInstances=window.SimpleKeyboardInstances,this.keyboardInstanceNames=Object.keys(window.SimpleKeyboardInstances),this.isFirstKeyboardInstance=this.keyboardInstanceNames[0]===this.currentInstanceName,this.physicalKeyboard=new M({dispatch:this.dispatch,getOptions:this.getOptions}),this.candidateBox=this.options.enableLayoutCandidates?new ee({utilities:this.utilities,options:this.options}):null,!this.keyboardDOM)throw console.warn('".'.concat(z,'" was not found in the DOM.')),new Error("KEYBOARD_DOM_ERROR");this.render(),this.modules={},this.loadModules()}},K=[{key:"setCaretPosition",value:function(E){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:E;this.caretPosition=E,this.caretPositionEnd=O}},{key:"getInputCandidates",value:function(E){var O=this,q=this.options,B=q.layoutCandidates,re=q.layoutCandidatesCaseSensitiveMatch;if(!B||se(B)!=="object")return{};var z=Object.keys(B).filter((function(Q){var ne=E.substring(0,O.getCaretPositionEnd()||0)||E,ie=new RegExp("".concat(O.utilities.escapeRegex(Q),"$"),re?"g":"gi");return!!ae(ne.matchAll(ie)).length}));if(z.length>1){var V=z.sort((function(Q,ne){return ne.length-Q.length}))[0];return{candidateKey:V,candidateValue:B[V]}}if(z.length){var te=z[0];return{candidateKey:te,candidateValue:B[te]}}return{}}},{key:"showCandidatesBox",value:function(E,O,q){var B=this;this.candidateBox&&this.candidateBox.show({candidateValue:O,targetElement:q,onSelect:function(re,z){var V=B.options,te=V.layoutCandidatesCaseSensitiveMatch,Q=V.disableCandidateNormalization,ne=V.enableLayoutCandidatesKeyPress,ie=re;Q||(ie=re.normalize("NFD")),typeof B.options.beforeInputUpdate=="function"&&B.options.beforeInputUpdate(B);var me=B.getInput(B.options.inputName,!0),fe=B.getCaretPositionEnd()||0,oe=me.substring(0,fe||0)||me,I=new RegExp("".concat(B.utilities.escapeRegex(E),"$"),te?"g":"gi"),F=oe.replace(I,ie),J=me.replace(oe,F),xe=F.length-oe.length,he=(fe||me.length)+xe;he<0&&(he=0),B.setInput(J,B.options.inputName,!0),B.setCaretPosition(he),ne&&typeof B.options.onKeyPress=="function"&&B.options.onKeyPress(re,z),typeof B.options.onChange=="function"&&B.options.onChange(B.getInput(B.options.inputName,!0),z),typeof B.options.onChangeAll=="function"&&B.options.onChangeAll(B.getAllInputs(),z)}})}},{key:"handleButtonClicked",value:function(E,O){var q=this.options,B=q.inputName,re=B===void 0?this.defaultName:B,z=q.debug;if(E!=="{//}"){this.input[re]||(this.input[re]=""),typeof this.options.beforeInputUpdate=="function"&&this.options.beforeInputUpdate(this);var V=this.utilities.getUpdatedInput(E,this.input[re],this.caretPosition,this.caretPositionEnd);if(this.utilities.isStandardButton(E)&&this.activeInputElement&&this.input[re]&&this.input[re]===V&&this.caretPosition===0&&this.caretPositionEnd===V.length)return this.setInput("",this.options.inputName,!0),this.setCaretPosition(0),this.activeInputElement.value="",this.activeInputElement.setSelectionRange(0,0),void this.handleButtonClicked(E,O);if(typeof this.options.onKeyPress=="function"&&this.options.onKeyPress(E,O),this.input[re]!==V&&(!this.options.inputPattern||this.options.inputPattern&&this.inputPatternIsValid(V))){if(this.options.maxLength&&this.utilities.handleMaxLength(this.input,V))return;var te=this.utilities.getUpdatedInput(E,this.input[re],this.caretPosition,this.caretPositionEnd,!0);if(this.setInput(te,this.options.inputName,!0),z&&console.log("Input changed:",this.getAllInputs()),this.options.debug&&console.log("Caret at: ",this.getCaretPosition(),this.getCaretPositionEnd(),"(".concat(this.keyboardDOMClass,")"),O?.type),this.options.syncInstanceInputs&&this.syncInstanceInputs(),typeof this.options.onChange=="function"&&this.options.onChange(this.getInput(this.options.inputName,!0),O),typeof this.options.onChangeAll=="function"&&this.options.onChangeAll(this.getAllInputs(),O),O!=null&&O.target&&this.options.enableLayoutCandidates){var Q,ne=this.getInputCandidates(V),ie=ne.candidateKey,me=ne.candidateValue;ie&&me?this.showCandidatesBox(ie,me,this.keyboardDOM):(Q=this.candidateBox)===null||Q===void 0||Q.destroy()}}this.caretPositionEnd&&this.caretPosition!==this.caretPositionEnd&&(this.setCaretPosition(this.caretPositionEnd,this.caretPositionEnd),this.activeInputElement&&this.activeInputElement.setSelectionRange(this.caretPositionEnd,this.caretPositionEnd),this.options.debug&&console.log("Caret position aligned",this.caretPosition)),z&&console.log("Key pressed:",E)}}},{key:"getMouseHold",value:function(){return this.isMouseHold}},{key:"setMouseHold",value:function(E){this.options.syncInstanceInputs?this.dispatch((function(O){O.isMouseHold=E})):this.isMouseHold=E}},{key:"handleButtonMouseDown",value:function(E,O){var q=this;O&&(this.options.preventMouseDownDefault&&O.preventDefault(),this.options.stopMouseDownPropagation&&O.stopPropagation(),O.target.classList.add(this.activeButtonClass)),this.holdInteractionTimeout&&clearTimeout(this.holdInteractionTimeout),this.holdTimeout&&clearTimeout(this.holdTimeout),this.setMouseHold(!0),this.options.disableButtonHold||(this.holdTimeout=window.setTimeout((function(){(q.getMouseHold()&&(!E.includes("{")&&!E.includes("}")||E==="{delete}"||E==="{backspace}"||E==="{bksp}"||E==="{space}"||E==="{tab}")||E==="{arrowright}"||E==="{arrowleft}"||E==="{arrowup}"||E==="{arrowdown}")&&(q.options.debug&&console.log("Button held:",E),q.handleButtonHold(E)),clearTimeout(q.holdTimeout)}),500))}},{key:"handleButtonMouseUp",value:function(E,O){var q=this;O&&(this.options.preventMouseUpDefault&&O.preventDefault&&O.preventDefault(),this.options.stopMouseUpPropagation&&O.stopPropagation&&O.stopPropagation(),!(O.target===this.keyboardDOM||O.target&&this.keyboardDOM.contains(O.target)||this.candidateBox&&this.candidateBox.candidateBoxElement&&(O.target===this.candidateBox.candidateBoxElement||O.target&&this.candidateBox.candidateBoxElement.contains(O.target)))&&this.candidateBox&&this.candidateBox.destroy()),this.recurseButtons((function(B){B.classList.remove(q.activeButtonClass)})),this.setMouseHold(!1),this.holdInteractionTimeout&&clearTimeout(this.holdInteractionTimeout),E&&typeof this.options.onKeyReleased=="function"&&this.options.onKeyReleased(E,O)}},{key:"handleKeyboardContainerMouseDown",value:function(E){this.options.preventMouseDownDefault&&E.preventDefault()}},{key:"handleButtonHold",value:function(E){var O=this;this.holdInteractionTimeout&&clearTimeout(this.holdInteractionTimeout),this.holdInteractionTimeout=window.setTimeout((function(){O.getMouseHold()?(O.handleButtonClicked(E),O.handleButtonHold(E)):clearTimeout(O.holdInteractionTimeout)}),100)}},{key:"syncInstanceInputs",value:function(){var E=this;this.dispatch((function(O){O.replaceInput(E.input),O.setCaretPosition(E.caretPosition,E.caretPositionEnd)}))}},{key:"clearInput",value:function(){var E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.inputName||this.defaultName;this.input[E]="",this.setCaretPosition(0),this.options.syncInstanceInputs&&this.syncInstanceInputs()}},{key:"getInput",value:function(){var E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.inputName||this.defaultName,O=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return this.options.syncInstanceInputs&&!O&&this.syncInstanceInputs(),this.options.rtl?"‫"+this.input[E].replace("‫","").replace("‬","")+"‬":this.input[E]}},{key:"getAllInputs",value:function(){var E=this,O={};return Object.keys(this.input).forEach((function(q){O[q]=E.getInput(q,!0)})),O}},{key:"setInput",value:function(E){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.inputName||this.defaultName,q=arguments.length>2?arguments[2]:void 0;this.input[O]=E,!q&&this.options.syncInstanceInputs&&this.syncInstanceInputs()}},{key:"replaceInput",value:function(E){this.input=E}},{key:"setOptions",value:function(){var E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},O=this.changedOptions(E);this.options=Object.assign(this.options,E),O.length&&(this.options.debug&&console.log("changedOptions",O),this.onSetOptions(O),this.render())}},{key:"changedOptions",value:function(E){var O=this;return Object.keys(E).filter((function(q){return JSON.stringify(E[q])!==JSON.stringify(O.options[q])}))}},{key:"onSetOptions",value:function(){var E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];E.includes("layoutName")&&this.candidateBox&&this.candidateBox.destroy(),(E.includes("layoutCandidatesPageSize")||E.includes("layoutCandidates"))&&this.candidateBox&&(this.candidateBox.destroy(),this.candidateBox=new ee({utilities:this.utilities,options:this.options}))}},{key:"resetRows",value:function(){this.keyboardRowsDOM&&this.keyboardRowsDOM.remove(),this.keyboardDOM.className=this.keyboardDOMClass,this.keyboardDOM.setAttribute("data-skInstance",this.currentInstanceName),this.buttonElements={}}},{key:"dispatch",value:function(E){if(!window.SimpleKeyboardInstances)throw console.warn("SimpleKeyboardInstances is not defined. Dispatch cannot be called."),new Error("INSTANCES_VAR_ERROR");return Object.keys(window.SimpleKeyboardInstances).forEach((function(O){E(window.SimpleKeyboardInstances[O],O)}))}},{key:"addButtonTheme",value:function(E,O){var q=this;O&&E&&(E.split(" ").forEach((function(B){O.split(" ").forEach((function(re){q.options.buttonTheme||(q.options.buttonTheme=[]);var z=!1;q.options.buttonTheme.map((function(V){if(V!=null&&V.class.split(" ").includes(re)){z=!0;var te=V.buttons.split(" ");te.includes(B)||(z=!0,te.push(B),V.buttons=te.join(" "))}return V})),z||q.options.buttonTheme.push({class:re,buttons:E})}))})),this.render())}},{key:"removeButtonTheme",value:function(E,O){var q=this;if(!E&&!O)return this.options.buttonTheme=[],void this.render();E&&Array.isArray(this.options.buttonTheme)&&this.options.buttonTheme.length&&(E.split(" ").forEach((function(B){var re;(re=q.options)===null||re===void 0||(re=re.buttonTheme)===null||re===void 0||re.map((function(z,V){if(z&&O&&O.includes(z.class)||!O){var te,Q,ne=(te=z)===null||te===void 0?void 0:te.buttons.split(" ").filter((function(ie){return ie!==B}));z&&ne!=null&&ne.length?z.buttons=ne.join(" "):((Q=q.options.buttonTheme)===null||Q===void 0||Q.splice(V,1),z=null)}return z}))})),this.render())}},{key:"getButtonElement",value:function(E){var O,q=this.buttonElements[E];return q&&(O=q.length>1?q:q[0]),O}},{key:"inputPatternIsValid",value:function(E){var O,q=this.options.inputPattern;if((O=q instanceof RegExp?q:q[this.options.inputName||this.defaultName])&&E){var B=O.test(E);return this.options.debug&&console.log('inputPattern ("'.concat(O,'"): ').concat(B?"passed":"did not pass!")),B}return!0}},{key:"setEventListeners",value:function(){if(this.isFirstKeyboardInstance||!this.allKeyboardInstances){this.options.debug&&console.log("Caret handling started (".concat(this.keyboardDOMClass,")"));var E=this.options.physicalKeyboardHighlightPreventDefault,O=E!==void 0&&E;document.addEventListener("keyup",this.handleKeyUp,O),document.addEventListener("keydown",this.handleKeyDown,O),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("touchend",this.handleTouchEnd),this.options.updateCaretOnSelectionChange&&document.addEventListener("selectionchange",this.handleSelectionChange),document.addEventListener("select",this.handleSelect)}}},{key:"handleKeyUp",value:function(E){this.caretEventHandler(E),this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyUp(E)}},{key:"handleKeyDown",value:function(E){this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyDown(E)}},{key:"handleMouseUp",value:function(E){this.caretEventHandler(E)}},{key:"handleTouchEnd",value:function(E){this.caretEventHandler(E)}},{key:"handleSelect",value:function(E){this.caretEventHandler(E)}},{key:"handleSelectionChange",value:function(E){navigator.userAgent.includes("Firefox")||this.caretEventHandler(E)}},{key:"caretEventHandler",value:function(E){var O,q=this;E.target.tagName&&(O=E.target.tagName.toLowerCase()),this.dispatch((function(B){var re=E.target===B.keyboardDOM||E.target&&B.keyboardDOM.contains(E.target);if(q.options.syncInstanceInputs&&Array.isArray(E.path)&&(re=E.path.some((function(te){var Q;return te==null||(Q=te.hasAttribute)===null||Q===void 0?void 0:Q.call(te,"data-skInstance")}))),(O==="textarea"||O==="input"&&["text","search","url","tel","password"].includes(E.target.type))&&!B.options.disableCaretPositioning){var z=E.target.selectionStart,V=E.target.selectionEnd;B.options.rtl&&(z=B.utilities.getRtlOffset(z,B.getInput()),V=B.utilities.getRtlOffset(V,B.getInput())),B.setCaretPosition(z,V),B.activeInputElement=E.target,B.options.debug&&console.log("Caret at: ",B.getCaretPosition(),B.getCaretPositionEnd(),E&&E.target.tagName.toLowerCase(),"(".concat(B.keyboardDOMClass,")"),E?.type)}else!B.options.disableCaretPositioning&&re||E?.type==="selectionchange"||(B.setCaretPosition(null),B.activeInputElement=null,B.options.debug&&console.log('Caret position reset due to "'.concat(E?.type,'" event'),E))}))}},{key:"recurseButtons",value:function(E){var O=this;E&&Object.keys(this.buttonElements).forEach((function(q){return O.buttonElements[q].forEach(E)}))}},{key:"destroy",value:function(){this.options.debug&&console.log("Destroying simple-keyboard instance: ".concat(this.currentInstanceName));var E=this.options.physicalKeyboardHighlightPreventDefault,O=E!==void 0&&E;document.removeEventListener("keyup",this.handleKeyUp,O),document.removeEventListener("keydown",this.handleKeyDown,O),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("touchend",this.handleTouchEnd),document.removeEventListener("select",this.handleSelect),this.options.updateCaretOnSelectionChange&&document.removeEventListener("selectionchange",this.handleSelectionChange),document.onpointerup=null,document.ontouchend=null,document.ontouchcancel=null,document.onmouseup=null,this.recurseButtons((function(q){q&&(q.onpointerdown=null,q.onpointerup=null,q.onpointercancel=null,q.ontouchstart=null,q.ontouchend=null,q.ontouchcancel=null,q.onclick=null,q.onmousedown=null,q.onmouseup=null,q.remove(),q=null)})),this.keyboardDOM.onpointerdown=null,this.keyboardDOM.ontouchstart=null,this.keyboardDOM.onmousedown=null,this.resetRows(),this.candidateBox&&(this.candidateBox.destroy(),this.candidateBox=null),this.activeInputElement=null,this.keyboardDOM.removeAttribute("data-skInstance"),this.keyboardDOM.innerHTML="",window.SimpleKeyboardInstances[this.currentInstanceName]=null,delete window.SimpleKeyboardInstances[this.currentInstanceName],this.initialized=!1}},{key:"getButtonThemeClasses",value:function(E){var O=this.options.buttonTheme,q=[];return Array.isArray(O)&&O.forEach((function(B){if(B&&B.class&&typeof B.class=="string"&&B.buttons&&typeof B.buttons=="string"){var re=B.class.split(" ");B.buttons.split(" ").includes(E)&&(q=[].concat(ae(q),ae(re)))}else console.warn('Incorrect "buttonTheme". Please check the documentation.',B)})),q}},{key:"setDOMButtonAttributes",value:function(E,O){var q=this.options.buttonAttributes;Array.isArray(q)&&q.forEach((function(B){B.attribute&&typeof B.attribute=="string"&&B.value&&typeof B.value=="string"?B.buttons&&typeof B.buttons=="string"?B.buttons.split(" ").includes(E)&&O(B.attribute,B.value):O(B.attribute,B.value):console.warn('Incorrect "buttonAttributes". Please check the documentation.',B)}))}},{key:"onTouchDeviceDetected",value:function(){this.processAutoTouchEvents(),this.disableContextualWindow()}},{key:"disableContextualWindow",value:function(){window.oncontextmenu=function(E){var O;if((O=E.target.classList)!==null&&O!==void 0&&O.contains("hg-button"))return E.preventDefault(),E.stopPropagation(),!1}}},{key:"processAutoTouchEvents",value:function(){this.options.autoUseTouchEvents&&(this.options.useTouchEvents=!0,this.options.debug&&console.log("autoUseTouchEvents: Touch device detected, useTouchEvents enabled."))}},{key:"onInit",value:function(){this.options.debug&&console.log("".concat(this.keyboardDOMClass," Initialized")),this.setEventListeners(),typeof this.options.onInit=="function"&&this.options.onInit(this)}},{key:"beforeFirstRender",value:function(){this.utilities.isTouchDevice()&&this.onTouchDeviceDetected(),typeof this.options.beforeFirstRender=="function"&&this.options.beforeFirstRender(this),this.isFirstKeyboardInstance&&this.utilities.pointerEventsSupported()&&!this.options.useTouchEvents&&!this.options.useMouseEvents&&this.options.debug&&console.log("Using PointerEvents as it is supported by this browser"),this.options.useTouchEvents&&this.options.debug&&console.log("useTouchEvents has been enabled. Only touch events will be used.")}},{key:"beforeRender",value:function(){typeof this.options.beforeRender=="function"&&this.options.beforeRender(this)}},{key:"onRender",value:function(){typeof this.options.onRender=="function"&&this.options.onRender(this)}},{key:"onModulesLoaded",value:function(){typeof this.options.onModulesLoaded=="function"&&this.options.onModulesLoaded(this)}},{key:"loadModules",value:function(){var E=this;Array.isArray(this.options.modules)&&(this.options.modules.forEach((function(O){var q=E.utilities.isConstructor(O)?new O(E):O(E);q.init&&q.init(E)})),this.keyboardPluginClasses="modules-loaded",this.render(),this.onModulesLoaded())}},{key:"getModuleProp",value:function(E,O){return!!this.modules[E]&&this.modules[E][O]}},{key:"getModulesList",value:function(){return Object.keys(this.modules)}},{key:"parseRowDOMContainers",value:function(E,O,q,B){var re=this,z=Array.from(E.children),V=0;return z.length&&q.forEach((function(te,Q){var ne=B[Q];if(!(ne&&ne>te))return!1;var ie=te-V,me=ne-V,fe=document.createElement("div");fe.className+="hg-button-container";var oe="".concat(re.options.layoutName,"-r").concat(O,"c").concat(Q);fe.setAttribute("data-skUID",oe);var I=z.splice(ie,me-ie+1);V+=me-ie,I.forEach((function(F){return fe.appendChild(F)})),z.splice(ie,0,fe),E.innerHTML="",z.forEach((function(F){return E.appendChild(F)})),re.options.debug&&console.log("rowDOMContainer",I,ie,me,V+1)})),E}},{key:"render",value:function(){var E=this;this.resetRows(),this.initialized||this.beforeFirstRender(),this.beforeRender();var O="hg-layout-".concat(this.options.layoutName),q=this.options.layout||{default:["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}","{tab} q w e r t y u i o p [ ] \\","{lock} a s d f g h j k l ; ' {enter}","{shift} z x c v b n m , . / {shift}",".com @ {space}"],shift:["~ ! @ # $ % ^ & * ( ) _ + {bksp}","{tab} Q W E R T Y U I O P { } |",'{lock} A S D F G H J K L : " {enter}',"{shift} Z X C V B N M < > ? {shift}",".com @ {space}"]},B=this.options.useTouchEvents||!1,re=B?"hg-touch-events":"",z=this.options.useMouseEvents||!1,V=this.options.disableRowButtonContainers;this.keyboardDOM.className=this.getKeyboardClassString(this.options.theme,O,this.keyboardPluginClasses,re),this.keyboardDOM.setAttribute("data-skInstance",this.currentInstanceName),this.keyboardRowsDOM=document.createElement("div"),this.keyboardRowsDOM.className="hg-rows",q[this.options.layoutName||this.defaultName].forEach((function(te,Q){var ne=te.split(" ");E.options.excludeFromLayout&&E.options.excludeFromLayout[E.options.layoutName||E.defaultName]&&(ne=ne.filter((function(oe){return E.options.excludeFromLayout&&!E.options.excludeFromLayout[E.options.layoutName||E.defaultName].includes(oe)})));var ie=document.createElement("div");ie.className+="hg-row";var me=[],fe=[];ne.forEach((function(oe,I){var F,J=!V&&typeof oe=="string"&&oe.length>1&&oe.indexOf("[")===0,xe=!V&&typeof oe=="string"&&oe.length>1&&oe.indexOf("]")===oe.length-1;J&&(me.push(I),oe=oe.replace(/\[/g,"")),xe&&(fe.push(I),oe=oe.replace(/\]/g,""));var he=E.utilities.getButtonClass(oe),le=E.utilities.getButtonDisplayName(oe,E.options.display,E.options.mergeDisplay),Ce=E.options.useButtonTag?"button":"div",Ne=document.createElement(Ce);Ne.className+="hg-button ".concat(he),(F=Ne.classList).add.apply(F,ae(E.getButtonThemeClasses(oe))),E.setDOMButtonAttributes(oe,(function(de,we){Ne.setAttribute(de,we)})),E.activeButtonClass="hg-activeButton",!E.utilities.pointerEventsSupported()||B||z?B?(Ne.ontouchstart=function(de){E.handleButtonClicked(oe,de),E.handleButtonMouseDown(oe,de)},Ne.ontouchend=function(de){E.handleButtonMouseUp(oe,de)},Ne.ontouchcancel=function(de){E.handleButtonMouseUp(oe,de)}):(Ne.onclick=function(de){E.setMouseHold(!1),typeof E.options.onKeyReleased=="function"||E.options.useMouseEvents&&E.options.clickOnMouseDown||E.handleButtonClicked(oe,de)},Ne.onmousedown=function(de){(typeof E.options.onKeyReleased=="function"||E.options.useMouseEvents&&E.options.clickOnMouseDown)&&!E.isMouseHold&&E.handleButtonClicked(oe,de),E.handleButtonMouseDown(oe,de)},Ne.onmouseup=function(de){E.handleButtonMouseUp(oe,de)}):(Ne.onpointerdown=function(de){E.handleButtonClicked(oe,de),E.handleButtonMouseDown(oe,de)},Ne.onpointerup=function(de){E.handleButtonMouseUp(oe,de)},Ne.onpointercancel=function(de){E.handleButtonMouseUp(oe,de)}),Ne.setAttribute("data-skBtn",oe);var Ue="".concat(E.options.layoutName,"-r").concat(Q,"b").concat(I);Ne.setAttribute("data-skBtnUID",Ue);var He=document.createElement("span");He.innerHTML=le,Ne.appendChild(He),E.buttonElements[oe]||(E.buttonElements[oe]=[]),E.buttonElements[oe].push(Ne),ie.appendChild(Ne)})),ie=E.parseRowDOMContainers(ie,Q,me,fe),E.keyboardRowsDOM.appendChild(ie)})),this.keyboardDOM.appendChild(this.keyboardRowsDOM),this.onRender(),this.initialized||(this.initialized=!0,!this.utilities.pointerEventsSupported()||B||z?B?(document.ontouchend=function(te){return E.handleButtonMouseUp(void 0,te)},document.ontouchcancel=function(te){return E.handleButtonMouseUp(void 0,te)},this.keyboardDOM.ontouchstart=function(te){return E.handleKeyboardContainerMouseDown(te)}):B||(document.onmouseup=function(te){return E.handleButtonMouseUp(void 0,te)},this.keyboardDOM.onmousedown=function(te){return E.handleKeyboardContainerMouseDown(te)}):(document.onpointerup=function(te){return E.handleButtonMouseUp(void 0,te)},this.keyboardDOM.onpointerdown=function(te){return E.handleKeyboardContainerMouseDown(te)}),this.onInit())}}],K&&ye($.prototype,K),T&&ye($,T),Object.defineProperty($,"prototype",{writable:!1}),$;var $,K,T})(),be=pe,Ee=be;return h})()},442:function(l){l.exports=n}},i={};function s(l){var c=i[l];if(c!==void 0)return c.exports;var u=i[l]={exports:{}};return r[l].call(u.exports,u,u.exports,s),u.exports}s.n=function(l){var c=l&&l.__esModule?function(){return l.default}:function(){return l};return s.d(c,{a:c}),c},s.d=function(l,c){for(var u in c)s.o(c,u)&&!s.o(l,u)&&Object.defineProperty(l,u,{enumerable:!0,get:c[u]})},s.o=function(l,c){return Object.prototype.hasOwnProperty.call(l,c)},s.r=function(l){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(l,"__esModule",{value:!0})};var o={};return(function(){s.r(o),s.d(o,{KeyboardReact:function(){return v},default:function(){return g}}),s(981);var l=s(442),c=s(548),u=s.n(c);function d(y){return d=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},d(y)}function h(y,_){var N=Object.keys(y);if(Object.getOwnPropertySymbols){var A=Object.getOwnPropertySymbols(y);_&&(A=A.filter((function(C){return Object.getOwnPropertyDescriptor(y,C).enumerable}))),N.push.apply(N,A)}return N}function f(y){for(var _=1;_<arguments.length;_++){var N=arguments[_]!=null?arguments[_]:{};_%2?h(Object(N),!0).forEach((function(A){p(y,A,N[A])})):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(N)):h(Object(N)).forEach((function(A){Object.defineProperty(y,A,Object.getOwnPropertyDescriptor(N,A))}))}return y}function p(y,_,N){return(_=(function(A){var C=(function(j,k){if(d(j)!="object"||!j)return j;var R=j[Symbol.toPrimitive];if(R!==void 0){var M=R.call(j,k);if(d(M)!="object")return M;throw new TypeError("@@toPrimitive must return a primitive value.")}return(k==="string"?String:Number)(j)})(A,"string");return d(C)=="symbol"?C:C+""})(_))in y?Object.defineProperty(y,_,{value:N,enumerable:!0,configurable:!0,writable:!0}):y[_]=N,y}var x=function(y){return f(f({},y),{},{keyboardRef:null})},v=function(y){var _=y.baseClass||"react-simple-keyboard",N=l.useRef(null),A=l.useRef(null),C=l.useRef(null),j=l.useRef(y);return l.useEffect((function(){return function(){C.current&&C.current.destroy(),N.current=!1}}),[]),l.useEffect((function(){var k=(function(U){return f(f({},U),{},{theme:"simple-keyboard ".concat(U.theme||"hg-theme-default")})})(y);if(!N.current){N.current=!0,k.debug&&console.log("ReactSimpleKeyboard: Init");var R=A.current,M=".".concat(_);C.current=new(u())(R||M,k),k.keyboardRef&&k.keyboardRef(C.current)}var D=(function(U,W){var L=x(W),ee=x(U);return Object.keys(L).filter((function(ae){return L[ae]!==ee[ae]}))})(j.current,k);if(D.length){var G=C.current;j.current=k,G?.setOptions(k),k.debug&&console.log("ReactSimpleKeyboard - setOptions called due to updated props:",D)}}),[N,_,j,y]),l.createElement("div",{className:_,ref:A})},g=v})(),o})()}))})(w1)),w1.exports}var Xet=Yet();const Qet=Ml(Xet),Zet=new Set(["text","password","email","search","url"]);function XE(t,e){(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set??Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set)?.call(t,e),t.dispatchEvent(new Event("input",{bubbles:!0}))}function Jet(){const[t,e]=w.useState(!1),[n,r]=w.useState(!1),i=w.useRef(!1),[s,o]=w.useState("default"),l=w.useRef(null),c=w.useRef(null),u=w.useRef(null),d=w.useCallback(x=>{if(i.current)return;const v=x.target;if(!v.closest('[data-vkb="false"]')){if(v instanceof HTMLInputElement){if(!Zet.has(v.type))return}else if(!(v instanceof HTMLTextAreaElement))return;l.current=v,e(!0),o("default"),c.current?.setInput?.(l.current.value),setTimeout(()=>{v.scrollIntoView({behavior:"smooth",block:"center"})},100)}},[]),h=w.useCallback(()=>{setTimeout(()=>{const x=document.activeElement;x&&(u.current?.contains(x)||x===l.current)||(e(!1),l.current=null)},150)},[]);w.useEffect(()=>(document.addEventListener("focusin",d),document.addEventListener("focusout",h),()=>{document.removeEventListener("focusin",d),document.removeEventListener("focusout",h)}),[d,h]);const f=w.useCallback(()=>{i.current=!0,r(!0),l.current?.blur(),l.current=null,setTimeout(()=>{e(!1),r(!1),i.current=!1},400)},[]),p=w.useCallback(x=>{const v=l.current;if(v){if(x==="{shift}"){o(g=>g==="default"?"shift":"default");return}if(x==="{lock}"){o(g=>g==="default"?"shift":"default");return}if(x==="{close}"){f();return}x==="{bksp}"?XE(v,v.value.slice(0,-1)):x==="{space}"?XE(v,v.value+" "):(XE(v,v.value+x),s==="shift"&&o("default")),v.focus(),c.current?.setInput?.(v.value)}},[s,f]);return t?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-[9998] bg-transparent",onMouseDown:x=>{x.preventDefault(),x.stopPropagation(),n||f()},onTouchStart:x=>{x.preventDefault(),x.stopPropagation(),n||f()},onClick:x=>{x.preventDefault(),x.stopPropagation()}}),!n&&a.jsx("div",{ref:u,className:"fixed bottom-0 left-0 right-0 z-[9999]",onMouseDown:x=>x.preventDefault(),onTouchStart:x=>{x.target.closest(".hg-button")||x.preventDefault()},children:a.jsx(Qet,{keyboardRef:x=>{c.current=x},layoutName:s,onKeyPress:p,theme:"simple-keyboard vkb-theme",layout:{default:["1 2 3 4 5 6 7 8 9 0 {bksp}","q w e r t y u i o p","{lock} a s d f g h j k l","{shift} z x c v b n m . @","{space} {close}"],shift:["! @ # $ % ^ & * ( ) {bksp}","Q W E R T Y U I O P","{lock} A S D F G H J K L","{shift} Z X C V B N M , _","{space} {close}"]},display:{"{bksp}":"⌫","{close}":"✕ Close","{shift}":"⇧","{lock}":"⇪","{space}":" "}})})]}):null}function ett(){const[t,e]=w.useState(null),[n,r]=w.useState(null),[i,s]=w.useState(!1),[o,l]=w.useState(100),[c,u]=w.useState(0),d=w.useRef(Date.now()),{i18n:h}=Et(),f=Wet(),{data:p}=Je({queryKey:["settings"],queryFn:ge.getSettings});w.useEffect(()=>{p?.language&&p.language!==h.language&&h.changeLanguage(p.language)},[p?.language,h]);const{data:x=[]}=Je({queryKey:["spoolbuddy-devices"],queryFn:()=>ys.getDevices(),refetchInterval:3e4}),v=x[0],g=w.useRef(!1);w.useEffect(()=>{v&&!g.current&&(l(v.display_brightness),u(v.display_blank_timeout),g.current=!0)},[v]),w.useEffect(()=>{const N=document.documentElement,A=N.classList.contains("dark");return N.classList.add("dark"),()=>{A||N.classList.remove("dark")}},[]),w.useEffect(()=>{f.deviceOnline?r(null):r({type:"warning",message:"SpoolBuddy device disconnected"})},[f.deviceOnline]);const y=w.useCallback(()=>{d.current=Date.now(),s(!1)},[]);w.useEffect(()=>(window.addEventListener("pointerdown",y),window.addEventListener("keydown",y),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("keydown",y)}),[y]),w.useEffect(()=>{if(c<=0)return;const N=setInterval(()=>{Date.now()-d.current>=c*1e3&&s(!0)},1e3);return()=>clearInterval(N)},[c]);const _=o<100?{filter:`brightness(${o/100})`}:void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"w-screen h-screen bg-bambu-dark text-white flex flex-col overflow-hidden",style:_,children:[a.jsx(Bet,{selectedPrinterId:t,onPrinterChange:e,deviceOnline:f.deviceOnline}),a.jsx("main",{className:"flex-1 overflow-y-auto",children:a.jsx(uY,{context:{selectedPrinterId:t,setSelectedPrinterId:e,sbState:f,setAlert:r,displayBrightness:o,setDisplayBrightness:l,displayBlankTimeout:c,setDisplayBlankTimeout:u}})}),a.jsx(Vet,{alert:n}),a.jsx($et,{}),a.jsx(Jet,{})]}),i&&a.jsx("div",{className:"fixed inset-0 bg-black z-[9999]",onPointerDown:N=>{N.stopPropagation(),y()}})]})}function _I({color:t,isEmpty:e,size:n=32}){return e?a.jsx("div",{className:"rounded-full border-2 border-dashed border-zinc-500 flex items-center justify-center",style:{width:n,height:n},children:a.jsx("div",{className:"w-2 h-2 rounded-full bg-zinc-600"})}):a.jsxs("svg",{width:n,height:n,viewBox:"0 0 32 32",children:[a.jsx("circle",{cx:"16",cy:"16",r:"14",fill:t,stroke:"white",strokeWidth:"1.5",strokeOpacity:"0.7"}),a.jsx("circle",{cx:"16",cy:"16",r:"11",fill:t,style:{filter:"brightness(0.85)"}})]})}const ttt="spoolbuddy-default-core-weight";function Cse(){try{const t=localStorage.getItem(ttt);if(t){const e=parseInt(t,10);if(e>=0&&e<=500)return e}}catch{}return 250}function ntt({spool:t,scaleWeight:e,onClose:n,onSyncWeight:r,onAssignToAms:i}){const{t:s}=Et(),[o,l]=w.useState(!1),[c,u]=w.useState(!1),d=t.rgba?`#${t.rgba.slice(0,6)}`:"#808080",h=t.core_weight&&t.core_weight>0?t.core_weight:Cse(),f=e!==null?Math.round(Math.max(0,e)):null,p=f!==null?Math.round(Math.max(0,f-h)):null,x=Math.round(t.label_weight||1e3),v=p!==null?Math.min(100,Math.round(p/x*100)):null,g=v!==null?v>50?"#22c55e":v>20?"#eab308":"#ef4444":"#808080",_=Math.max(0,(t.label_weight||0)-(t.weight_used||0))+h,N=f!==null?f-_:null,A=N!==null?Math.abs(N)<=50:null,C=async()=>{if(e!==null){l(!0);try{await ys.updateSpoolWeight(t.id,Math.round(e)),u(!0),r?.(),setTimeout(()=>u(!1),3e3)}catch(j){console.error("Failed to sync weight:",j)}finally{l(!1)}}};return a.jsxs("div",{className:"flex flex-col items-center space-y-4 max-w-md",children:[a.jsxs("div",{className:"flex items-start gap-5",children:[a.jsxs("div",{className:"relative shrink-0",children:[a.jsx(_I,{color:d,isEmpty:!1,size:100}),v!==null&&a.jsxs("div",{className:"absolute -bottom-2 -right-2 px-2 py-0.5 rounded-full text-xs font-bold text-white shadow-lg",style:{backgroundColor:g},children:[v,"%"]})]}),a.jsxs("div",{className:"flex-1 min-w-0 pt-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-zinc-100",children:t.color_name||"Unknown color"}),a.jsxs("p",{className:"text-sm text-zinc-400",children:[t.brand," • ",t.material,t.subtype&&` ${t.subtype}`]}),p!==null&&a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsxs("span",{className:"text-3xl font-bold font-mono text-zinc-100",children:[p,"g"]}),a.jsxs("span",{className:"text-sm text-zinc-500",children:["/ ",x,"g"]})]}),a.jsx("p",{className:"text-xs text-zinc-500 mt-0.5",children:s("spoolbuddy.spool.remaining","Remaining")}),a.jsx("div",{className:"mt-2 max-w-xs",children:a.jsx("div",{className:"h-2 bg-zinc-700 rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${v}%`,backgroundColor:g}})})})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-sm bg-zinc-800 rounded-lg p-4 w-full",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.dashboard.grossWeight","Gross weight")}),a.jsx("span",{className:"font-mono text-zinc-300",children:f!==null?`${f}g`:"—"})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.spool.coreWeight","Core")}),a.jsxs("span",{className:"font-mono text-zinc-300",children:[h,"g"]})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.dashboard.spoolSize","Spool size")}),a.jsxs("span",{className:"font-mono text-zinc-300",children:[x,"g"]})]}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.spool.scaleWeight","Scale")}),f!==null?a.jsxs("span",{className:`flex items-center gap-1 font-mono ${A?"text-green-500":"text-yellow-500"}`,children:[f,"g",A?a.jsx(Zr,{className:"w-3.5 h-3.5"}):a.jsxs(a.Fragment,{children:[a.jsx(Mn,{className:"w-3.5 h-3.5"}),a.jsx("button",{onClick:C,className:"p-1 hover:bg-green-500/20 rounded transition-colors text-green-500",title:s("spoolbuddy.dashboard.syncWeight","Sync Weight"),children:a.jsx(wr,{className:"w-4 h-4"})})]})]}):a.jsx("span",{className:"text-zinc-500",children:"—"})]}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:"text-zinc-500",children:s("spoolbuddy.dashboard.tagId","Tag")}),a.jsx("span",{className:"font-mono text-xs text-zinc-400 truncate max-w-[120px]",title:t.tag_uid||"",children:t.tag_uid?t.tag_uid.slice(-8):"—"})]})]}),a.jsxs("div",{className:"flex gap-2 justify-center",children:[i&&a.jsx("button",{onClick:i,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]",children:s("spoolbuddy.modal.assignToAms","Assign to AMS")}),a.jsx("button",{onClick:C,disabled:e===null||o,className:`px-5 py-2.5 rounded-lg text-sm font-medium transition-colors min-h-[44px] ${c?"bg-green-600/20 text-green-400":i?"bg-zinc-700 text-zinc-300 hover:bg-zinc-600 disabled:opacity-40 disabled:cursor-not-allowed":"bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed"}`,children:o?"...":c?s("spoolbuddy.dashboard.weightSynced","Synced!"):s("spoolbuddy.dashboard.syncWeight","Sync Weight")}),n&&a.jsx("button",{onClick:n,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]",children:s("spoolbuddy.dashboard.close","Close")})]})]})}function rtt({tagUid:t,scaleWeight:e,coreWeight:n,onLinkSpool:r,onAddToInventory:i,onClose:s}){const{t:o}=Et(),l=n??Cse(),c=e!==null?Math.round(Math.max(0,e)):null,u=c!==null?Math.round(Math.max(0,c-l)):null;return a.jsxs("div",{className:"flex flex-col items-center text-center space-y-5",children:[a.jsx("div",{className:"w-20 h-20 rounded-2xl bg-green-500/15 flex items-center justify-center",children:a.jsx("svg",{className:"w-10 h-10 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z"})})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-zinc-100",children:o("spoolbuddy.dashboard.newTag","New Tag Detected")}),a.jsx("p",{className:"text-sm text-zinc-500 font-mono mt-1",children:t})]}),c!==null&&a.jsxs("div",{className:"text-sm text-zinc-400",children:[a.jsxs("span",{className:"font-mono font-semibold",children:[c,"g"]})," ",o("spoolbuddy.dashboard.onScale","on scale"),u!==null&&u>0&&a.jsxs("span",{className:"text-zinc-500",children:[" • ~",u,"g filament"]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[i&&a.jsx("button",{onClick:i,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]",children:o("spoolbuddy.modal.addToInventory","Add to Inventory")}),r&&a.jsxs("button",{onClick:r,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]",children:[a.jsx("svg",{className:"w-4 h-4 inline-block mr-1.5 -mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),o("spoolbuddy.dashboard.linkSpool","Link to Spool")]}),s&&a.jsx("button",{onClick:s,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]",children:o("spoolbuddy.dashboard.close","Close")})]})]})}function att(t){return t?`#${t.slice(0,6)}`:"#808080"}function Ase(t){return!t.tray_type||t.tray_type===""}function itt(t){return t<=3?`AMS ${String.fromCharCode(65+t)}`:t>=128&&t<=135?`AMS HT ${String.fromCharCode(65+t-128)}`:`AMS ${t}`}function stt({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 ott({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 ltt({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 ctt({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 utt({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 dtt({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 Tse({humidity:t,goodThreshold:e=40,fairThreshold:n=60}){let r,i;return t<=e?(r="#22a352",i=stt):t<=n?(r="#d4a017",i=ott):(r="#c62828",i=ltt),a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx(i,{className:"w-3 h-3.5"}),a.jsxs("span",{className:"font-medium tabular-nums text-xs",style:{color:r},children:[t,"%"]})]})}function Mse({temp:t,goodThreshold:e=28,fairThreshold:n=35}){let r,i;return t<=e?(r="#22a352",i=ctt):t<=n?(r="#d4a017",i=utt):(r="#c62828",i=dtt),a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx(i,{className:"w-3 h-3.5"}),a.jsxs("span",{className:"font-medium tabular-nums text-xs",style:{color:r},children:[t,"°C"]})]})}function NI({side:t}){return a.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[9px] font-bold rounded",style:{backgroundColor:"#1a4d2e",color:"#00ae42"},children:t})}function htt({tray:t,slotIndex:e,isActive:n,fillOverride:r,onClick:i}){const s=Ase(t),o=att(t.tray_color),l=t.remain!==null&&t.remain!==void 0&&t.remain>=0?t.remain:null,c=r??l;return a.jsxs("div",{className:`relative flex flex-col items-center p-2.5 rounded-lg transition-all ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer hover:bg-white/5":""}`,onClick:i,children:[a.jsxs("div",{className:"relative w-16 h-16 mb-1",children:[s?a.jsx("div",{className:"w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center",children:a.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-600"})}):a.jsxs("svg",{viewBox:"0 0 56 56",className:"w-full h-full",children:[a.jsx("circle",{cx:"28",cy:"28",r:"26",fill:o}),a.jsx("circle",{cx:"28",cy:"28",r:"20",fill:o,style:{filter:"brightness(0.85)"}}),a.jsx("ellipse",{cx:"20",cy:"20",rx:"6",ry:"4",fill:"white",opacity:"0.3"}),a.jsx("circle",{cx:"28",cy:"28",r:"8",fill:"#2d2d2d"}),a.jsx("circle",{cx:"28",cy:"28",r:"5",fill:"#1a1a1a"})]}),n&&a.jsx("div",{className:"absolute -bottom-1 left-1/2 -translate-x-1/2 w-2.5 h-2.5 bg-bambu-green rounded-full"})]}),a.jsx("span",{className:"text-sm text-white/70 truncate max-w-full",children:s?"Empty":t.tray_type||"Unknown"}),!s&&c!==null&&c>=0&&a.jsx("div",{className:"w-full h-1 bg-bambu-dark-tertiary rounded-full overflow-hidden mt-1",children:a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${c}%`,backgroundColor:c>50?"#22c55e":c>20?"#f59e0b":"#ef4444"}})}),a.jsx("span",{className:"absolute top-1 right-1 text-xs text-white/30",children:e+1})]})}function Pse({unit:t,activeSlot:e,onConfigureSlot:n,isDualNozzle:r,nozzleSide:i,thresholds:s,fillOverrides:o}){const l=t.tray||[],c=t.is_ams_ht,u=c?1:4;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-3",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-white font-medium text-base",children:itt(t.id)}),r&&i&&a.jsx(NI,{side:i})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.temp!=null&&a.jsx(Mse,{temp:t.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair}),t.humidity!=null&&a.jsx(Tse,{humidity:t.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair})]})]}),a.jsx("div",{className:`grid ${c?"grid-cols-1 max-w-[100px] mx-auto":"grid-cols-4"} gap-2`,children:Array.from({length:u}).map((d,h)=>{const f=l[h]||{id:h,tray_color:null,tray_type:"",tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null};return a.jsx(htt,{tray:f,slotIndex:h,isActive:e===h,fillOverride:o?.[`${t.id}-${h}`]??null,onClick:n?()=>n(t.id,h,Ase(f)?null:f):void 0},h)})})]})}function mtt(t){return t<=3?`AMS ${String.fromCharCode(65+t)}`:t>=128&&t<=135?`AMS HT ${String.fromCharCode(65+t-128)}`:`AMS ${t}`}function RK(t){return!t.tray_type||t.tray_type===""}function ftt(t){return t?`#${t.slice(0,6)}`:"#808080"}function ptt({isOpen:t,onClose:e,spool:n,printerId:r}){const{t:i}=Et(),s=Qt(),[o,l]=w.useState(null),[c,u]=w.useState(null);w.useEffect(()=>{t&&(l(null),u(null))},[t]);const d=w.useCallback(G=>{G.key==="Escape"&&e()},[e]);w.useEffect(()=>(t&&document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)),[t,d]);const{data:h}=Je({queryKey:["printerStatus",r],queryFn:()=>ge.getPrinterStatus(r),enabled:t&&r!==null,refetchInterval:5e3}),{data:f}=Je({queryKey:["printer",r],queryFn:()=>ge.getPrinter(r),enabled:t&&r!==null}),p=h?.connected??!1,x=w.useMemo(()=>h?.ams??[],[h?.ams]),v=w.useMemo(()=>x.filter(G=>!G.is_ams_ht),[x]),g=w.useMemo(()=>x.filter(G=>G.is_ams_ht),[x]),y=w.useMemo(()=>[...h?.vt_tray??[]].sort((G,U)=>(G.id??254)-(U.id??254)),[h?.vt_tray]),_=f?.nozzle_count===2||h?.temperatures?.nozzle_2!==void 0,N=w.useRef({});w.useEffect(()=>{h?.ams_extruder_map&&Object.keys(h.ams_extruder_map).length>0&&(N.current=h.ams_extruder_map)},[h?.ams_extruder_map]);const A=h?.ams_extruder_map&&Object.keys(h.ams_extruder_map).length>0?h.ams_extruder_map:N.current,C=w.useCallback(G=>{if(!_)return null;const U=A[String(G)],W=G>=128?G-128:G;return(U!==void 0?U:W)===1?"L":"R"},[_,A]),j=ut({mutationFn:async({amsId:G,trayId:U})=>{if(!r)throw new Error("No printer selected");if(await ge.assignSpool({spool_id:n.id,printer_id:r,ams_id:G,tray_id:U}),n.slicer_filament){const W=n.slicer_filament.includes("_")?n.slicer_filament.split("_")[0]:n.slicer_filament,L=W.startsWith("GF")&&!W.startsWith("GFS")?"GFS"+W.slice(2):W,ee=n.subtype?`${n.material} ${n.subtype}`:n.material;try{await ge.saveSlotPreset(r,G,U,L,ee,"cloud")}catch(ae){console.warn("Failed to save slot preset mapping:",ae)}}},onSuccess:()=>{u("success"),l(i("spoolbuddy.modal.assignSuccess","Assigned!")),s.invalidateQueries({queryKey:["slotPresets"]}),setTimeout(()=>e(),1500)},onError:G=>{u("error"),l(G instanceof Error?G.message:i("spoolbuddy.modal.assignError","Failed to assign spool."))}}),k=j.isPending,R=w.useCallback((G,U)=>{k||(u("info"),l(i("spoolbuddy.modal.assigning","Configuring slot...")),j.mutate({amsId:G,trayId:U}))},[k,j,i]),M=w.useMemo(()=>{const G=[];for(const U of g){const W=U.tray?.[0]||{id:0,tray_color:null,tray_type:"",tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null};G.push({key:`ht-${U.id}`,label:mtt(U.id),amsId:U.id,trayId:0,tray:W,isEmpty:RK(W),nozzleSide:C(U.id)})}for(const U of y){const W=U.id??254;G.push({key:`ext-${W}`,label:_?W===254?i("printers.extL","Ext-L"):i("printers.extR","Ext-R"):i("printers.ext","Ext"),amsId:255,trayId:W-254,tray:U,isEmpty:RK(U),nozzleSide:_?W===254?"L":"R":null})}return G},[g,y,_,i,C]);if(!t)return null;const D=n.rgba?`#${n.rgba.slice(0,6)}`:"#808080";return a.jsxs("div",{className:"fixed inset-0 z-[60] bg-bambu-dark flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-zinc-800 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx("div",{className:"w-7 h-7 rounded-full shrink-0",style:{backgroundColor:D}}),a.jsx("div",{className:"min-w-0",children:a.jsxs("h2",{className:"text-sm font-semibold text-zinc-100 truncate",children:[i("spoolbuddy.modal.assignToAmsTitle","Assign to AMS"),a.jsxs("span",{className:"font-normal text-zinc-500 ml-2",children:[n.color_name||"Unknown"," • ",n.brand," ",n.material,n.subtype&&` ${n.subtype}`]})]})})]}),a.jsx("button",{onClick:e,disabled:k,className:"p-2 rounded-lg text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 transition-colors shrink-0 disabled:opacity-50",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),o&&a.jsxs("div",{className:`mx-5 mt-3 p-3 rounded-lg flex items-center gap-3 border shrink-0 ${c==="info"?"bg-blue-500/10 border-blue-500/40":c==="success"?"bg-green-500/10 border-green-500/40":"bg-red-500/10 border-red-500/40"}`,children:[c==="info"&&a.jsx(lt,{className:"w-4 h-4 text-blue-400 animate-spin shrink-0"}),c==="success"&&a.jsx(xr,{className:"w-4 h-4 text-green-400 shrink-0"}),c==="error"&&a.jsx(ii,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-sm ${c==="info"?"text-blue-300":c==="success"?"text-green-300":"text-red-300"}`,children:o})]}),a.jsx("div",{className:"flex-1 flex flex-col gap-3 p-4 min-h-0",children:!p&&r?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsx("div",{className:"text-center text-white/50",children:a.jsx("p",{className:"text-lg mb-2",children:i("spoolbuddy.ams.printerDisconnected","Printer disconnected")})})}):x.length===0&&y.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center text-white/50",children:[a.jsx(Ga,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),a.jsx("p",{className:"text-lg mb-2",children:i("spoolbuddy.ams.noData","No AMS detected")}),a.jsx("p",{className:"text-sm",children:i("spoolbuddy.ams.connectAms","Connect an AMS to see filament slots")})]})}):a.jsxs(a.Fragment,{children:[v.length>0&&a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 flex-1 min-h-0",children:v.map(G=>a.jsx(Pse,{unit:G,activeSlot:null,onConfigureSlot:(U,W)=>R(G.id,W),isDualNozzle:_,nozzleSide:C(G.id)},G.id))}),M.length>0&&a.jsx("div",{className:"flex gap-2 shrink-0",children:M.map(({key:G,label:U,amsId:W,trayId:L,tray:ee,isEmpty:ae,nozzleSide:Y})=>{const se=ftt(ee.tray_color);return a.jsxs("div",{onClick:()=>R(W,L),className:`bg-bambu-dark-secondary rounded-lg px-3 py-2 cursor-pointer hover:bg-bambu-dark-secondary/80 transition-all flex items-center gap-2 ${k?"opacity-50 pointer-events-none":""}`,children:[a.jsx("div",{className:"relative w-10 h-10 shrink-0",children:ae?a.jsx("div",{className:"w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center",children:a.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-600"})}):a.jsxs("svg",{viewBox:"0 0 56 56",className:"w-full h-full",children:[a.jsx("circle",{cx:"28",cy:"28",r:"26",fill:se}),a.jsx("circle",{cx:"28",cy:"28",r:"20",fill:se,style:{filter:"brightness(0.85)"}}),a.jsx("ellipse",{cx:"20",cy:"20",rx:"6",ry:"4",fill:"white",opacity:"0.3"}),a.jsx("circle",{cx:"28",cy:"28",r:"8",fill:"#2d2d2d"}),a.jsx("circle",{cx:"28",cy:"28",r:"5",fill:"#1a1a1a"})]})}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"text-xs text-white/50 font-medium",children:U}),Y&&a.jsx(NI,{side:Y})]}),a.jsx("div",{className:"text-sm text-white/80 truncate",children:ae?"Empty":ee.tray_type||"?"})]}),!ae&&ee.remain!=null&&ee.remain>=0&&a.jsx("div",{className:"w-1.5 h-8 bg-bambu-dark-tertiary rounded-full overflow-hidden shrink-0 flex flex-col-reverse",children:a.jsx("div",{className:"w-full rounded-full",style:{height:`${ee.remain}%`,backgroundColor:ee.remain>50?"#22c55e":ee.remain>20?"#f59e0b":"#ef4444"}})})]},G)})})]})}),a.jsx("div",{className:"flex justify-end gap-3 px-5 py-3 border-t border-zinc-800 shrink-0",children:a.jsx("button",{onClick:e,disabled:k,className:"px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-800 text-zinc-300 hover:bg-zinc-700 transition-colors min-h-[44px] disabled:opacity-50",children:c==="success"?i("spoolbuddy.dashboard.close","Close"):i("spoolbuddy.modal.cancel","Cancel")})})]})}function gtt({isOpen:t,onClose:e,tagId:n,untaggedSpools:r,onLink:i}){const{t:s}=Et(),[o,l]=w.useState(null),c=w.useCallback(()=>{l(null),e()},[e]),u=w.useCallback(h=>{h.key==="Escape"&&c()},[c]);if(w.useEffect(()=>(t&&(document.addEventListener("keydown",u),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",u),document.body.style.overflow=""}),[t,u]),!t)return null;const d=()=>{o&&(i(o),l(null))};return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 animate-fade-in",onClick:c,children:a.jsxs("div",{className:"bg-zinc-800 rounded-xl shadow-2xl w-full max-w-lg mx-4 animate-slide-up",onClick:h=>h.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-zinc-700",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-base font-semibold text-zinc-100",children:s("spoolbuddy.dashboard.linkTagTitle","Link Tag to Spool")}),a.jsx("p",{className:"text-sm text-zinc-500 font-mono",children:n})]}),a.jsx("button",{onClick:c,className:"p-2 rounded-lg text-zinc-500 hover:text-zinc-300 hover:bg-zinc-700 transition-colors",children:a.jsx(Ut,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"px-5 py-4 space-y-3 max-h-[400px] overflow-y-auto",children:[a.jsx("p",{className:"text-sm text-zinc-400",children:s("spoolbuddy.dashboard.selectSpool","Select a spool to link this tag to:")}),r.length===0?a.jsx("div",{className:"text-center py-8 text-zinc-500",children:s("spoolbuddy.dashboard.noUntagged","No spools without tags found")}):a.jsx("div",{className:"space-y-2",children:r.map(h=>a.jsxs("button",{type:"button",onClick:()=>l(h),className:`w-full flex items-center gap-3 p-3 rounded-lg border-2 transition-all text-left ${o?.id===h.id?"border-green-500 bg-green-500/10":"border-zinc-700 hover:border-green-500/50 hover:bg-zinc-700/50"}`,children:[a.jsx(_I,{color:h.rgba?`#${h.rgba.slice(0,6)}`:"#808080",isEmpty:!1,size:40}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"font-medium text-zinc-100 truncate",children:h.color_name||"Unknown color"}),a.jsxs("div",{className:"text-sm text-zinc-400 truncate",children:[h.brand," • ",h.material,h.subtype&&` ${h.subtype}`]})]}),a.jsxs("div",{className:"text-sm font-mono text-zinc-500",children:[Math.max(0,h.label_weight-h.weight_used),"g"]})]},h.id))})]}),a.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-zinc-700",children:[a.jsx("button",{onClick:c,className:"px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]",children:s("common.cancel","Cancel")}),a.jsx("button",{onClick:d,disabled:!o,className:"px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors min-h-[44px]",children:s("spoolbuddy.dashboard.linkTag","Link Tag")})]})]})})}const FK=["#00AE42","#FF6B35","#3B82F6","#EF4444","#A855F7","#FBBF24","#14B8A6","#EC4899","#F97316","#22C55E"];function btt(){const{t}=Et(),[e,n]=w.useState(0);w.useEffect(()=>{const i=setInterval(()=>{n(s=>(s+1)%FK.length)},2e3);return()=>clearInterval(i)},[]);const r=FK[e];return a.jsxs("div",{className:"flex flex-col items-center text-center",children:[a.jsxs("div",{className:"relative mb-6 flex items-center justify-center",style:{width:160,height:160},children:[a.jsx("div",{className:"absolute w-24 h-24 rounded-full border-2 border-green-500/30 animate-ping",style:{animationDuration:"2.5s"}}),a.jsx("div",{className:"absolute w-32 h-32 rounded-full border border-green-500/20 animate-ping",style:{animationDuration:"2.5s",animationDelay:"0.4s"}}),a.jsx("div",{className:"absolute w-40 h-40 rounded-full border border-green-500/10 animate-ping",style:{animationDuration:"2.5s",animationDelay:"0.8s"}}),a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"absolute -inset-4 rounded-full blur-2xl opacity-30 transition-colors duration-1000",style:{backgroundColor:r}}),a.jsx("div",{className:"transition-all duration-1000",children:a.jsx(_I,{color:r,isEmpty:!1,size:100})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xl font-medium text-zinc-300",children:t("spoolbuddy.dashboard.readyToScan","Ready to scan")}),a.jsx("p",{className:"text-sm text-zinc-500",children:t("spoolbuddy.dashboard.idleMessage","Place a spool on the scale to identify it")})]}),a.jsxs("div",{className:"mt-6 flex items-center gap-2 text-sm text-zinc-600",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("span",{children:t("spoolbuddy.dashboard.nfcHint","NFC tag will be read automatically")})]})]})}function xtt(){const{t}=Et();return a.jsxs("div",{className:"flex flex-col items-center text-center",children:[a.jsx("div",{className:"relative mb-6 flex items-center justify-center",style:{width:160,height:160},children:a.jsx("div",{className:"w-24 h-24 rounded-full bg-zinc-800 flex items-center justify-center",children:a.jsx("svg",{className:"w-12 h-12 text-zinc-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M18.364 5.636a9 9 0 010 12.728m0 0l-12.728-12.728m12.728 12.728L5.636 5.636m12.728 0a9 9 0 00-12.728 0m0 12.728a9 9 0 010-12.728"})})})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-lg font-medium text-zinc-500",children:t("spoolbuddy.status.deviceOffline","Device Offline")}),a.jsx("p",{className:"text-sm text-zinc-600",children:t("spoolbuddy.status.connectDisplay","Connect the SpoolBuddy display to scan spools")})]}),a.jsxs("div",{className:"mt-6 flex items-center gap-2 text-xs text-zinc-600",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.14 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0"})}),a.jsx("span",{children:t("spoolbuddy.status.waitingConnection","Waiting for device connection...")})]})]})}function ytt(){const{sbState:t,selectedPrinterId:e}=gv(),{t:n}=Et(),{data:r=[],refetch:i}=Je({queryKey:["inventory-spools"],queryFn:()=>ge.getSpools(!1)}),{data:s=[]}=Je({queryKey:["printers"],queryFn:()=>ge.getPrinters()}),o=Qb({queries:s.map(Z=>({queryKey:["printerStatus",Z.id],queryFn:()=>ge.getPrinterStatus(Z.id),refetchInterval:1e4}))}),[l,c]=w.useState(null),[u,d]=w.useState(null),[h,f]=w.useState(null),[p,x]=w.useState(!1),[v,g]=w.useState(!1),[y,_]=w.useState(!1),[N,A]=w.useState(!1),C=t.matchedSpool?.tag_uid??t.unknownTagUid??null,j=t.weight,k=t.weightStable,R=w.useRef(null);j===null?R.current=null:(R.current===null||Math.abs(j-R.current)>=3||k)&&(R.current=j);const D=R.current,G=w.useMemo(()=>l?r.find(Z=>Z.tag_uid===l)??null:null,[l,r]),U=w.useMemo(()=>r.filter(Z=>!Z.tag_uid&&!Z.archived_at),[r]);w.useEffect(()=>{if(C){const Z=h===C;(l!==null&&l!==C||!Z&&l!==C)&&(c(C),d(null),f(null)),!Z&&j!==null&&k&&d(Math.round(Math.max(0,j)))}else h&&(c(null),f(null),d(null))},[C,j,k,l,h]);const W=()=>{f(l)},L=async Z=>{if(l)try{await ge.linkTagToSpool(Z.id,{tag_uid:l,tag_type:"generic",data_origin:"nfc_link"}),x(!1),i()}catch(ue){console.error("Failed to link tag:",ue)}},ee=async()=>{if(l){A(!0);try{const Z=Y??u;await ge.createSpool({material:"PLA",subtype:null,color_name:null,rgba:null,brand:null,label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:null,slicer_filament_name:null,nozzle_temp_min:null,nozzle_temp_max:null,note:null,added_full:null,last_used:null,encode_time:null,tag_uid:l,tray_uuid:null,data_origin:"spoolbuddy",tag_type:"generic",cost_per_kg:null,last_scale_weight:Z,last_weighed_at:Z!==null?new Date().toISOString():null}),_(!1),i()}catch(Z){console.error("Failed to quick-add spool:",Z)}finally{A(!1)}}},Y=j!==null&&(C===l||C===null&&l!==null)?j:null,se=r.length,ce=new Set(r.map(Z=>Z.material)).size,ye=new Set(r.filter(Z=>Z.brand).map(Z=>Z.brand)).size;return a.jsxs("div",{className:"h-full flex flex-col p-4",children:[a.jsxs("div",{className:"flex items-center gap-6 px-4 py-1.5 bg-zinc-800/50 rounded-xl border border-zinc-700/50 mb-3 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xl font-bold text-zinc-100",children:se}),a.jsx("span",{className:"text-sm text-zinc-500",children:n("spoolbuddy.inventory.spools","Spools")})]}),a.jsx("div",{className:"w-px h-5 bg-zinc-700"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xl font-bold text-zinc-100",children:ce}),a.jsx("span",{className:"text-sm text-zinc-500",children:n("spoolbuddy.spool.material","Materials")})]}),a.jsx("div",{className:"w-px h-5 bg-zinc-700"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xl font-bold text-zinc-100",children:ye}),a.jsx("span",{className:"text-sm text-zinc-500",children:n("spoolbuddy.spool.brand","Brands")})]})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-5/12 flex flex-col min-h-0",children:[a.jsxs("div",{className:"border border-dashed border-zinc-700/50 rounded-xl p-4",children:[a.jsx("h2",{className:"text-sm font-semibold text-zinc-400 uppercase tracking-wide mb-3",children:n("spoolbuddy.dashboard.device","Device")}),a.jsxs("div",{className:"space-y-2.5",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.deviceOnline?"bg-green-500 animate-pulse":"bg-red-500"}`}),a.jsx("span",{className:"text-base text-zinc-400",children:t.deviceOnline?n("spoolbuddy.status.online","Online"):n("spoolbuddy.status.offline","Disconnected")})]}),a.jsxs("div",{className:"flex items-center justify-between p-3 bg-zinc-800/50 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("svg",{className:`w-4 h-4 ${t.deviceOnline?"text-green-500":"text-zinc-500"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3"})}),a.jsx("span",{className:"text-sm text-zinc-500",children:n("spoolbuddy.spool.scaleWeight","Scale")})]}),a.jsx("span",{className:"text-lg font-mono font-semibold text-zinc-100",children:D!==null?`${Math.abs(D)<=20?0:Math.round(Math.max(0,D))}g`:"—"})]}),a.jsxs("div",{className:"flex items-center justify-between p-3 bg-zinc-800/50 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("svg",{className:`w-4 h-4 ${t.deviceOnline?"text-green-500":"text-zinc-500"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z"})}),a.jsx("span",{className:"text-sm text-zinc-500",children:"NFC"})]}),a.jsx("span",{className:`text-sm font-medium ${C?"text-green-500":"text-zinc-500"}`,children:C?n("spoolbuddy.dashboard.tagDetected","Tag detected"):n("spoolbuddy.dashboard.noTag","No tag")})]})]})]}),s.length>0&&a.jsxs("div",{className:"mt-3 border border-dashed border-zinc-700/50 rounded-xl p-4",children:[a.jsx("h2",{className:"text-sm font-semibold text-zinc-400 uppercase tracking-wide mb-2.5",children:n("spoolbuddy.dashboard.printers","Printers")}),a.jsx("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:s.map((Z,ue)=>{const pe=o[ue]?.data?.connected??!1;return a.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 bg-zinc-800/50 rounded-lg",title:`${Z.name} — ${pe?"Online":"Offline"}`,children:[a.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${pe?"bg-green-500":"bg-zinc-600"}`}),a.jsx("span",{className:"text-xs text-zinc-400 truncate max-w-[100px]",children:Z.name})]},Z.id)})})]})]}),a.jsx("div",{className:"w-7/12 min-h-0",children:a.jsxs("div",{className:"border border-dashed border-zinc-700/50 rounded-xl p-6 h-full flex flex-col",children:[a.jsx("h2",{className:"text-sm font-semibold text-zinc-400 uppercase tracking-wide mb-4 shrink-0",children:n("spoolbuddy.dashboard.currentSpool","Current Spool")}),a.jsx("div",{className:"flex-1 flex items-center justify-center min-h-0",children:t.deviceOnline?G&&l&&h!==l?a.jsx(ntt,{spool:{id:G.id,tag_uid:l,material:G.material,subtype:G.subtype,color_name:G.color_name,rgba:G.rgba,brand:G.brand,label_weight:G.label_weight,core_weight:G.core_weight,weight_used:G.weight_used},scaleWeight:Y??u,onSyncWeight:()=>i(),onAssignToAms:()=>g(!0),onClose:W}):l&&!G&&h!==l?a.jsx(rtt,{tagUid:l,scaleWeight:Y??u,onLinkSpool:U.length>0?()=>x(!0):void 0,onAddToInventory:()=>_(!0),onClose:W}):a.jsx(btt,{}):a.jsx(xtt,{})})]})})]}),G&&l&&a.jsx(ptt,{isOpen:v,onClose:()=>g(!1),spool:G,printerId:e}),l&&a.jsx(gtt,{isOpen:p,onClose:()=>x(!1),tagId:l,untaggedSpools:U,onLink:L}),y&&l&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:a.jsxs("div",{className:"bg-zinc-800 rounded-2xl p-6 mx-4 max-w-sm w-full border border-zinc-700",children:[a.jsx("h3",{className:"text-lg font-semibold text-zinc-100 mb-3",children:n("spoolbuddy.modal.addToInventory","Add to Inventory")}),a.jsxs("div",{className:"flex gap-2.5 p-3 bg-amber-500/10 border border-amber-500/20 rounded-lg mb-4",children:[a.jsx("svg",{className:"w-5 h-5 text-amber-500 shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),a.jsx("p",{className:"text-sm text-amber-200/80",children:n("spoolbuddy.modal.quickAddHint",'For best results, add the spool in the Bambuddy web interface first (with material, color, brand), then use "Link to Spool" here to assign the NFC tag.')})]}),a.jsx("p",{className:"text-sm text-zinc-400 mb-1",children:n("spoolbuddy.modal.quickAddDesc","This will create a basic PLA spool entry with this NFC tag. You can edit the details later in Bambuddy.")}),a.jsx("p",{className:"text-xs text-zinc-500 font-mono mb-5",children:l}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx("button",{onClick:()=>_(!1),className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]",children:n("common.cancel","Cancel")}),a.jsx("button",{onClick:ee,disabled:N,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-50 transition-colors min-h-[44px]",children:N?n("common.saving","Saving..."):n("spoolbuddy.modal.addAnyway","Add Anyway")})]})]})})]})}function LK(t){return t<=3?`AMS ${String.fromCharCode(65+t)}`:t>=128&&t<=135?`AMS HT ${String.fromCharCode(65+t-128)}`:`AMS ${t}`}function vtt(t){return t?{O1D:"H2D",O1E:"H2D Pro",O2D:"H2D Pro",O1C:"H2C",O1C2:"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"}[t]||t:""}function QE(t){return!t.tray_type||t.tray_type===""}function wtt(t){return t?`#${t.slice(0,6)}`:"#808080"}function Stt(){const{selectedPrinterId:t,setAlert:e}=gv(),{t:n}=Et(),r=Qt(),{data:i}=Je({queryKey:["printerStatus",t],queryFn:()=>ge.getPrinterStatus(t),enabled:t!==null,staleTime:30*1e3}),{data:s}=Je({queryKey:["printer",t],queryFn:()=>ge.getPrinter(t),enabled:t!==null,staleTime:60*1e3}),{data:o}=Je({queryKey:["slotPresets",t],queryFn:()=>ge.getSlotPresets(t),enabled:t!==null,staleTime:120*1e3}),{data:l}=Je({queryKey:["settings"],queryFn:()=>ge.getSettings(),staleTime:300*1e3}),{data:c}=Je({queryKey:["spool-assignments",t],queryFn:()=>ge.getAssignments(t),enabled:t!==null,staleTime:30*1e3}),u=w.useMemo(()=>{const G={};if(!c)return G;for(const U of c){const W=U.spool;if(W&&W.label_weight>0&&W.weight_used!=null){const L=Math.round(Math.max(0,W.label_weight-W.weight_used)/W.label_weight*100);G[`${U.ams_id}-${U.tray_id}`]=L}}return G},[c]),d=i?.connected??!1,h=w.useMemo(()=>i?.ams??[],[i?.ams]),f=w.useMemo(()=>h.filter(G=>!G.is_ams_ht),[h]),p=w.useMemo(()=>h.filter(G=>G.is_ams_ht),[h]),x=i?.tray_now??255,v=s?.nozzle_count===2||i?.temperatures?.nozzle_2!==void 0,g=w.useMemo(()=>[...i?.vt_tray??[]].sort((G,U)=>(G.id??254)-(U.id??254)),[i?.vt_tray]),y=l?{humidityGood:Number(l.ams_humidity_good)||40,humidityFair:Number(l.ams_humidity_fair)||60,tempGood:Number(l.ams_temp_good)||28,tempFair:Number(l.ams_temp_fair)||35}:void 0,_=w.useRef({});w.useEffect(()=>{i?.ams_extruder_map&&Object.keys(i.ams_extruder_map).length>0&&(_.current=i.ams_extruder_map)},[i?.ams_extruder_map]);const N=i?.ams_extruder_map&&Object.keys(i.ams_extruder_map).length>0?i.ams_extruder_map:_.current,A=w.useCallback(G=>{if(!v)return null;const U=N[String(G)],W=G>=128?G-128:G;return(U!==void 0?U:W)===1?"L":"R"},[v,N]),[C,j]=w.useState(null),k=w.useCallback(G=>{if(x===255||x===254)return null;if(G<=3&&Math.floor(x/4)===G)return x%4;if(G>=128&&G<=135){const U=G-128;if(x===16+U)return 0}return null},[x]),R=w.useCallback((G,U,W)=>{const L=G>=128?(G-128)*4+U+64:G*4+U,ee=o?.[L],ae=N[String(G)],Y=G>=128?G-128:G,se=ae!==void 0?ae:Y;j({amsId:G,trayId:U,trayCount:W&&G>=128?1:4,trayType:W?.tray_type||void 0,trayColor:W?.tray_color||void 0,traySubBrands:W?.tray_sub_brands||void 0,trayInfoIdx:W?.tray_info_idx||void 0,extruderId:v?se:void 0,caliIdx:W?.cali_idx,savedPresetId:ee?.preset_id})},[o,N,v]),M=w.useCallback(G=>{const U=G.id??254,W=U-254,L=o?.[1020+W];j({amsId:255,trayId:W,trayCount:1,trayType:G.tray_type||void 0,trayColor:G.tray_color||void 0,traySubBrands:G.tray_sub_brands||void 0,trayInfoIdx:G.tray_info_idx||void 0,extruderId:v?U===254?1:0:void 0,caliIdx:G.cali_idx,savedPresetId:L?.preset_id})},[o,v]);w.useEffect(()=>{if(!d&&t){e({type:"warning",message:n("spoolbuddy.ams.printerDisconnected","Printer disconnected")});return}for(const G of h)for(const U of G.tray||[])if(U.remain!==null&&U.remain>=0&&U.remain<15&&U.tray_type){e({type:"warning",message:`Low Filament: ${U.tray_type} (${LK(G.id)}) - ${U.remain}% remaining`});return}e(null)},[h,d,t,e,n]);const D=w.useMemo(()=>{const G=[];for(const U of p){const W=U.tray?.[0]||{id:0,tray_color:null,tray_type:"",tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null},L=u[`${U.id}-0`]??null,ee=W.remain!=null&&W.remain>=0?W.remain:null;G.push({key:`ht-${U.id}`,label:LK(U.id),tray:W,isEmpty:QE(W),isActive:k(U.id)===0,temp:U.temp,humidity:U.humidity,nozzleSide:A(U.id),effectiveFill:L??ee,onClick:()=>R(U.id,0,QE(W)?null:W)})}for(const U of g){const W=U.id??254,L=x===255?!1:v&&x===254?W===254&&i?.active_extruder===1||W===255&&i?.active_extruder===0:x===W,ee=W-254,ae=u[`255-${ee}`]??null,Y=U.remain!=null&&U.remain>=0?U.remain:null;G.push({key:`ext-${W}`,label:v?W===254?n("printers.extL","Ext-L"):n("printers.extR","Ext-R"):n("printers.ext","Ext"),tray:U,isEmpty:QE(U),isActive:L,nozzleSide:null,effectiveFill:ae??Y,onClick:()=>M(U)})}return G},[p,g,v,x,i?.active_extruder,n,k,A,R,M,u]);return a.jsxs("div",{className:"h-full flex flex-col p-4",children:[a.jsx("div",{className:"flex-1 min-h-0",children:t?d?h.length===0&&g.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center text-white/50",children:[a.jsx(Ga,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),a.jsx("p",{className:"text-lg mb-2",children:n("spoolbuddy.ams.noData","No AMS detected")}),a.jsx("p",{className:"text-sm",children:n("spoolbuddy.ams.connectAms","Connect an AMS to see filament slots")})]})}):a.jsxs("div",{className:"flex flex-col gap-3 h-full",children:[a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:f.map(G=>a.jsx(Pse,{unit:G,activeSlot:k(G.id),onConfigureSlot:R,isDualNozzle:v,nozzleSide:A(G.id),thresholds:y,fillOverrides:u},G.id))}),D.length>0&&a.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:D.map(({key:G,label:U,tray:W,isEmpty:L,isActive:ee,temp:ae,humidity:Y,nozzleSide:se,effectiveFill:ce,onClick:ye})=>{const Z=wtt(W.tray_color);return a.jsxs("div",{className:`bg-bambu-dark-secondary rounded-lg px-3 py-2 cursor-pointer hover:bg-bambu-dark-secondary/80 transition-all flex items-center gap-3 ${ee?"ring-2 ring-bambu-green":""}`,onClick:ye,children:[a.jsxs("div",{className:"relative w-10 h-10 flex-shrink-0",children:[L?a.jsx("div",{className:"w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center",children:a.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-600"})}):a.jsxs("svg",{viewBox:"0 0 56 56",className:"w-full h-full",children:[a.jsx("circle",{cx:"28",cy:"28",r:"26",fill:Z}),a.jsx("circle",{cx:"28",cy:"28",r:"20",fill:Z,style:{filter:"brightness(0.85)"}}),a.jsx("ellipse",{cx:"20",cy:"20",rx:"6",ry:"4",fill:"white",opacity:"0.3"}),a.jsx("circle",{cx:"28",cy:"28",r:"8",fill:"#2d2d2d"}),a.jsx("circle",{cx:"28",cy:"28",r:"5",fill:"#1a1a1a"})]}),ee&&a.jsx("div",{className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1.5 h-1.5 bg-bambu-green rounded-full"})]}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"text-xs text-white/50 font-medium truncate",children:U}),se&&a.jsx(NI,{side:se})]}),a.jsx("div",{className:"text-sm text-white/80 truncate",children:L?"Empty":W.tray_type||"?"}),(ae!=null||Y!=null)&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[ae!=null&&a.jsx(Mse,{temp:ae,goodThreshold:y?.tempGood,fairThreshold:y?.tempFair}),Y!=null&&a.jsx(Tse,{humidity:Y,goodThreshold:y?.humidityGood,fairThreshold:y?.humidityFair})]})]}),!L&&ce!=null&&ce>=0&&a.jsx("div",{className:"w-1.5 h-8 bg-bambu-dark-tertiary rounded-full overflow-hidden flex-shrink-0 flex flex-col-reverse",children:a.jsx("div",{className:"w-full rounded-full",style:{height:`${ce}%`,backgroundColor:ce>50?"#22c55e":ce>20?"#f59e0b":"#ef4444"}})})]},G)})})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:a.jsx("div",{className:"text-center text-white/50",children:a.jsx("p",{className:"text-lg mb-2",children:n("spoolbuddy.ams.printerDisconnected","Printer disconnected")})})}):a.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center text-white/50",children:[a.jsx("p",{className:"text-lg mb-2",children:n("spoolbuddy.ams.noPrinter","No printer selected")}),a.jsx("p",{className:"text-sm",children:n("spoolbuddy.ams.selectPrinter","Select a printer from the top bar")})]})})}),C&&t&&a.jsx(One,{isOpen:!!C,onClose:()=>j(null),printerId:t,slotInfo:C,printerModel:vtt(s?.model??null)||void 0,fullScreen:!0,onSuccess:()=>{r.invalidateQueries({queryKey:["slotPresets",t]}),r.invalidateQueries({queryKey:["printerStatus",t]})}})]})}function _tt(t){if(t<60)return`${t}s`;if(t<3600)return`${Math.floor(t/60)}m`;const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return`${e}h ${n}m`}function Ntt(t){if(!t)return"-";try{const e=new Date(t);return e.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}catch{return"-"}}const ktt=[{label:"Off",value:0},{label:"1m",value:60},{label:"2m",value:120},{label:"5m",value:300},{label:"10m",value:600},{label:"30m",value:1800}];function Ctt({device:t}){const{t:e}=Et();return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsx("div",{className:"flex items-center gap-3 mb-2",children:a.jsx("img",{src:"/img/spoolbuddy_logo_dark_small.png",alt:"SpoolBuddy",className:"h-7 w-auto"})}),a.jsx("p",{className:"text-xs text-zinc-500 mb-1",children:"Part of Bambuddy"}),a.jsx("span",{className:"text-xs text-zinc-500",children:"github.com/maziggy/bambuddy"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-3",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-300 mb-2",children:e("spoolbuddy.settings.nfcReader","NFC Reader")}),a.jsxs("div",{className:"space-y-1.5 text-xs",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.type","Type")}),a.jsx("span",{className:"text-zinc-300 font-mono",children:t.nfc_reader_type||"N/A"})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.connection","Connection")}),a.jsx("span",{className:"text-zinc-300 font-mono",children:t.nfc_connection||"N/A"})]}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.status.status","Status")}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${t.nfc_ok?"bg-green-500":t.nfc_reader_type?"bg-red-500":"bg-zinc-600"}`}),a.jsx("span",{className:t.nfc_ok?"text-green-400":t.nfc_reader_type?"text-red-400":"text-zinc-500",children:t.nfc_ok?e("spoolbuddy.status.nfcReady","Ready"):t.nfc_reader_type?e("common.error","Error"):e("spoolbuddy.settings.notConnected","N/A")})]})]})]})]}),a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-3",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-300 mb-2",children:e("spoolbuddy.settings.deviceInfo","Device Info")}),a.jsxs("div",{className:"space-y-1.5 text-xs",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.hostname","Host")}),a.jsx("span",{className:"text-zinc-300 truncate ml-2",children:t.hostname})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:"IP"}),a.jsx("span",{className:"text-zinc-300",children:t.ip_address})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.uptime","Uptime")}),a.jsx("span",{className:"text-zinc-300",children:_tt(t.uptime_s)})]}),a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.status.status","Status")}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${t.online?"bg-green-500":"bg-zinc-600"}`}),a.jsx("span",{className:t.online?"text-green-400":"text-zinc-500",children:t.online?e("spoolbuddy.status.online","Online"):e("spoolbuddy.status.offline","Offline")})]})]})]})]})]}),a.jsxs("div",{className:"bg-zinc-800 rounded-lg px-3 py-2 flex justify-between items-center text-xs",children:[a.jsx("span",{className:"text-zinc-500",children:"Device ID"}),a.jsx("span",{className:"text-zinc-400 font-mono",children:t.device_id})]})]})}function Att({device:t,onBrightnessChange:e,onBlankTimeoutChange:n}){const{t:r}=Et(),[i,s]=w.useState(t.display_brightness),[o,l]=w.useState(t.display_blank_timeout),[c,u]=w.useState(!1),d=w.useRef(void 0),h=w.useRef(void 0);w.useEffect(()=>{s(t.display_brightness),l(t.display_blank_timeout)},[t.display_brightness,t.display_blank_timeout]);const f=w.useCallback(()=>{u(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>u(!1),1500)},[]),p=w.useCallback((g,y)=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{ys.updateDisplay(t.device_id,g,y).then(()=>f()).catch(_=>console.error("Failed to update display:",_))},300)},[t.device_id,f]),x=g=>{s(g),e(g),p(g,o)},v=g=>{l(g),n(g),p(i,g)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-300",children:r("spoolbuddy.settings.brightness","Brightness")}),c&&a.jsxs("span",{className:"text-xs text-green-400 flex items-center gap-1 animate-pulse",children:[a.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),r("spoolbuddy.settings.saved","Saved")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("svg",{className:"w-4 h-4 text-zinc-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}),a.jsx("input",{type:"range",min:0,max:100,value:i,onChange:g=>x(parseInt(g.target.value)),className:"flex-1 h-2 bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-sm font-mono text-zinc-400 w-10 text-right",children:[i,"%"]})]}),!t.has_backlight&&a.jsx("p",{className:"text-xs text-zinc-600 mt-2",children:r("spoolbuddy.settings.noBacklight","No DSI backlight detected. Brightness control requires a DSI display.")})]}),a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-300 mb-1",children:r("spoolbuddy.settings.screenBlank","Screen Blank Timeout")}),a.jsx("p",{className:"text-xs text-zinc-500 mb-3",children:r("spoolbuddy.settings.screenBlankDesc","Screen turns off after inactivity. Touch to wake.")}),a.jsx("div",{className:"grid grid-cols-3 gap-2",children:ktt.map(g=>a.jsx("button",{onClick:()=>v(g.value),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors min-h-[40px] ${o===g.value?"bg-green-600 text-white":"bg-zinc-700 text-zinc-300 hover:bg-zinc-600"}`,children:g.label},g.value))})]}),a.jsx("p",{className:"text-xs text-zinc-600 text-center",children:r("spoolbuddy.settings.displayNote","Brightness is applied as a software filter.")})]})}function Ttt({step:t,labels:e}){return a.jsxs("div",{className:"flex flex-col items-center w-16 shrink-0 pt-1",children:[a.jsx("div",{className:`flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold ${t==="tare"?"bg-green-600 text-white":"bg-green-600/20 text-green-400"}`,children:t==="weight"?a.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):"1"}),a.jsx("span",{className:`text-[10px] mt-0.5 ${t==="tare"?"text-green-400 font-medium":"text-green-400/60"}`,children:e.tare}),a.jsx("div",{className:`w-px h-5 my-1 ${t==="weight"?"bg-green-600/40":"bg-zinc-700"}`}),a.jsx("div",{className:`flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold ${t==="weight"?"bg-green-600 text-white":"bg-zinc-700 text-zinc-500"}`,children:"2"}),a.jsx("span",{className:`text-[10px] mt-0.5 ${t==="weight"?"text-green-400 font-medium":"text-zinc-600"}`,children:e.weight})]})}function Mtt({device:t,weight:e,weightStable:n,rawAdc:r}){const{t:i}=Et(),[s,o]=w.useState("idle"),[l,c]=w.useState("500"),[u,d]=w.useState(null),[h,f]=w.useState(!1),[p,x]=w.useState(null),v=_=>{_==="backspace"?c(N=>N.slice(0,-1)||""):_==="."&&!l.includes(".")?c(N=>N+"."):_>="0"&&_<="9"&&c(N=>N==="0"?_:N+_)},g=async()=>{f(!0),x(null);try{await ys.tare(t.device_id),x({type:"ok",msg:i("spoolbuddy.settings.tareSet","Tare command sent. Waiting for device...")})}catch{x({type:"error",msg:i("spoolbuddy.settings.tareFailed","Failed to send tare command")})}finally{f(!1)}},y=async()=>{if(s==="tare"){f(!0),x(null);try{d(r),await ys.tare(t.device_id),x({type:"ok",msg:i("spoolbuddy.settings.zeroSet","Zero point set. Place known weight on scale.")}),o("weight")}catch{x({type:"error",msg:i("spoolbuddy.settings.tareFailed","Failed to send tare command")})}finally{f(!1)}}else if(s==="weight"){const _=parseFloat(l);if(r===null||!_||_<=0)return;f(!0),x(null);try{await ys.setCalibrationFactor(t.device_id,_,r,u??void 0),x({type:"ok",msg:i("spoolbuddy.settings.calibrationDone","Calibration complete!")}),o("idle")}catch{x({type:"error",msg:i("spoolbuddy.settings.calibrationFailed","Calibration failed")})}finally{f(!1)}}};return s==="idle"?a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-3 mb-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${n?"bg-green-500":"bg-amber-500 animate-pulse"}`}),a.jsx("span",{className:"text-lg font-mono text-zinc-200",children:e!==null?`${e.toFixed(1)} g`:"-- g"})]}),a.jsxs("div",{className:"text-xs text-zinc-500 text-right",children:[a.jsxs("span",{children:[i("spoolbuddy.settings.tareOffset","Tare"),": ",t.tare_offset]}),a.jsx("span",{className:"mx-1.5",children:"·"}),a.jsxs("span",{children:[i("spoolbuddy.settings.calFactor","Factor"),": ",t.calibration_factor.toFixed(2)]})]})]}),t.last_calibrated_at&&a.jsxs("div",{className:"text-xs text-zinc-600 mt-1",children:[i("spoolbuddy.settings.lastCalibrated","Last calibrated"),": ",Ntt(t.last_calibrated_at)]})]}),p&&a.jsx("div",{className:`rounded-lg px-3 py-2 mb-3 text-sm ${p.type==="ok"?"bg-green-900/30 text-green-300 border border-green-800":"bg-red-900/30 text-red-300 border border-red-800"}`,children:p.msg}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:g,disabled:h,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-200 hover:bg-zinc-600 disabled:opacity-40 transition-colors min-h-[44px] flex items-center justify-center gap-2",children:[h&&a.jsxs("svg",{className:"w-4 h-4 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),i("spoolbuddy.weight.tare","Tare")]}),a.jsx("button",{onClick:()=>{o("tare"),x(null)},className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]",children:i("spoolbuddy.weight.calibrate","Calibrate")})]})]}):a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Ttt,{step:s,labels:{tare:i("spoolbuddy.weight.tare","Tare"),weight:i("spoolbuddy.settings.knownWeight","Known weight")}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 rounded-lg px-3 py-1.5 mb-1.5",children:[a.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${n?"bg-green-500":"bg-amber-500 animate-pulse"}`}),a.jsx("span",{className:"text-sm font-mono text-zinc-200",children:e!==null?`${e.toFixed(1)} g`:"-- g"}),a.jsx("span",{className:`text-xs ml-auto ${n?"text-green-400":"text-amber-400"}`,children:n?i("spoolbuddy.settings.stable","Stable"):i("spoolbuddy.settings.settling","Settling...")})]}),p&&a.jsx("div",{className:`rounded-lg px-3 py-1.5 mb-1.5 text-xs ${p.type==="ok"?"bg-green-900/30 text-green-300 border border-green-800":"bg-red-900/30 text-red-300 border border-red-800"}`,children:p.msg}),s==="tare"?a.jsx("p",{className:"text-sm text-zinc-300 mb-3",children:i("spoolbuddy.settings.calStep1","Remove all items from the scale and press Set Zero.")}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:"text-xs text-zinc-400 shrink-0",children:i("spoolbuddy.settings.knownWeight","Known weight")}),a.jsxs("div",{className:"flex-1 bg-zinc-900 border border-zinc-600 rounded px-3 py-1 text-right text-lg font-mono text-zinc-100",children:[l||"0",a.jsx("span",{className:"text-zinc-500 ml-1",children:"g"})]})]}),a.jsx("div",{className:"grid grid-cols-4 gap-1 mb-1.5",children:["7","8","9","backspace","4","5","6",".","1","2","3","0"].map(_=>a.jsx("button",{onClick:()=>v(_),className:`rounded text-lg font-medium transition-colors h-[48px] active:scale-95 ${_==="backspace"?"bg-zinc-700 text-zinc-300 hover:bg-zinc-600":"bg-zinc-800 text-zinc-100 hover:bg-zinc-700 border border-zinc-700"}`,children:_==="backspace"?"⌫":_},_))})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>{o("idle"),x(null)},className:"flex-1 px-4 py-2 rounded-lg text-sm bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors h-[40px]",children:i("common.cancel","Cancel")}),a.jsxs("button",{onClick:y,disabled:h,className:"flex-1 px-4 py-2 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 transition-colors h-[40px] flex items-center justify-center gap-2",children:[h&&a.jsxs("svg",{className:"w-4 h-4 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s==="tare"?i("spoolbuddy.settings.setZero","Set Zero"):i("spoolbuddy.settings.calibrateNow","Calibrate")]})]})]})]})}function Ptt({device:t}){const{t:e}=Et(),[n,r]=w.useState(!1),[i,s]=w.useState(null),[o,l]=w.useState(null),[c,u]=w.useState(()=>{try{return localStorage.getItem("spoolbuddy-include-beta")==="true"}catch{return!1}}),d=()=>{const p=!c;u(p);try{localStorage.setItem("spoolbuddy-include-beta",String(p))}catch{}s(null),l(null)},h=async()=>{r(!0),s(null),l(null);try{const p=await ys.checkDaemonUpdate(t.device_id,c);s(p)}catch(p){l(p instanceof Error?p.message:"Failed to check for updates")}finally{r(!1)}},f=t.firmware_version||(i?.current_version&&i.current_version!=="0.0.0"?i.current_version:null);return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-300 mb-3",children:e("spoolbuddy.settings.daemonVersion","Daemon Version")}),a.jsxs("div",{className:"flex justify-between items-center text-sm",children:[a.jsx("span",{className:"text-zinc-500",children:e("spoolbuddy.settings.currentVersion","Current")}),a.jsx("span",{className:"text-zinc-200 font-mono",children:f||a.jsx("span",{className:"text-zinc-500 italic",children:e("spoolbuddy.settings.versionPending","Waiting for daemon...")})})]})]}),a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 space-y-3",children:[a.jsxs("button",{onClick:h,disabled:n,className:"w-full px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-200 hover:bg-zinc-600 disabled:opacity-40 transition-colors min-h-[44px] flex items-center justify-center gap-2",children:[n&&a.jsxs("svg",{className:"w-4 h-4 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),n?e("spoolbuddy.settings.checking","Checking..."):e("spoolbuddy.settings.checkUpdates","Check for Updates")]}),o&&a.jsx("div",{className:"rounded-lg p-3 text-sm bg-red-900/30 border border-red-800",children:a.jsx("p",{className:"text-red-300",children:o})}),i&&a.jsx("div",{className:`rounded-lg p-3 text-sm ${i.update_available?"bg-green-900/30 border border-green-800":"bg-zinc-700/50"}`,children:i.update_available?a.jsxs("div",{className:"space-y-1",children:[a.jsxs("p",{className:"text-green-300 font-medium",children:[e("spoolbuddy.settings.updateAvailable","Update available"),": v",i.latest_version]}),a.jsx("p",{className:"text-xs text-zinc-400",children:e("spoolbuddy.settings.updateInstructions","Update via SSH: run the SpoolBuddy install script to upgrade.")})]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("svg",{className:"w-4 h-4 text-green-400 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),a.jsx("p",{className:"text-zinc-300",children:e("spoolbuddy.settings.upToDate","Up to date")})]})}),a.jsxs("div",{className:"flex items-center justify-between pt-1",children:[a.jsx("span",{className:"text-xs text-zinc-500",children:e("spoolbuddy.settings.includeBeta","Include beta versions")}),a.jsx("button",{onClick:d,className:`relative w-10 h-5 rounded-full transition-colors ${c?"bg-green-600":"bg-zinc-600"}`,children:a.jsx("div",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-transform ${c?"translate-x-5":"translate-x-0.5"}`})})]})]})]})}function jtt(){const{sbState:t,setDisplayBrightness:e,setDisplayBlankTimeout:n}=gv(),{t:r}=Et(),[i,s]=w.useState("device"),{data:o=[]}=Je({queryKey:["spoolbuddy-devices"],queryFn:()=>ys.getDevices(),refetchInterval:1e4}),l=t.deviceId?o.find(u=>u.device_id===t.deviceId)??o[0]:o[0],c=[{id:"device",label:r("spoolbuddy.settings.tabDevice","Device")},{id:"display",label:r("spoolbuddy.settings.tabDisplay","Display")},{id:"scale",label:r("spoolbuddy.settings.tabScale","Scale")},{id:"updates",label:r("spoolbuddy.settings.tabUpdates","Updates")}];return a.jsxs("div",{className:"h-full flex flex-col p-4",children:[a.jsx("h1",{className:"text-xl font-semibold text-zinc-100 mb-3",children:r("spoolbuddy.nav.settings","Settings")}),a.jsx("div",{className:"flex gap-1 bg-zinc-800/50 rounded-lg p-1 mb-4",children:c.map(u=>a.jsx("button",{onClick:()=>s(u.id),className:`flex-1 px-2 py-2 rounded-md text-sm font-medium transition-colors min-h-[36px] ${i===u.id?"bg-zinc-700 text-zinc-100":"text-zinc-500 hover:text-zinc-300"}`,children:u.label},u.id))}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:l?a.jsxs(a.Fragment,{children:[i==="device"&&a.jsx(Ctt,{device:l}),i==="display"&&a.jsx(Att,{device:l,onBrightnessChange:e,onBlankTimeoutChange:n}),i==="scale"&&a.jsx(Mtt,{device:l,weight:t.weight,weightStable:t.weightStable,rawAdc:t.rawAdc}),i==="updates"&&a.jsx(Ptt,{device:l})]}):a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsx("div",{className:"text-center text-zinc-500",children:a.jsx("p",{className:"text-sm",children:r("spoolbuddy.settings.noDevice","No SpoolBuddy device found")})})})})]})}function Ett({device:t,weight:e,weightStable:n,rawAdc:r}){const{t:i}=Et(),[s,o]=w.useState(!1),[l,c]=w.useState("idle"),[u,d]=w.useState("500"),[h,f]=w.useState(null),[p,x]=w.useState(!1),v=N=>{N==="backspace"?d(A=>A.slice(0,-1)||""):N==="."&&!u.includes(".")?d(A=>A+"."):N>="0"&&N<="9"&&d(A=>A==="0"?N:A+N)},g=async()=>{x(!0);try{await ys.tare(t.device_id)}catch(N){console.error("Failed to tare:",N)}finally{x(!1)}},y=()=>{c("tare")},_=async()=>{if(l==="tare"){o(!0);try{f(r),await ys.tare(t.device_id),c("weight")}catch(N){console.error("Failed to tare:",N)}finally{o(!1)}}else if(l==="weight"){const N=parseFloat(u);if(r===null||!N||N<=0)return;o(!0);try{await ys.setCalibrationFactor(t.device_id,N,r,h??void 0),c("idle")}catch(A){console.error("Failed to calibrate:",A)}finally{o(!1)}}};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-zinc-400",children:i("spoolbuddy.settings.currentWeight","Current weight")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${n?"bg-green-500":"bg-amber-500 animate-pulse"}`}),a.jsx("span",{className:"text-lg font-mono text-zinc-200",children:e!==null?`${e.toFixed(1)} g`:"-- g"})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-3 text-xs",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:i("spoolbuddy.settings.tareOffset","Tare offset")}),a.jsx("span",{className:"text-zinc-400 font-mono",children:t.tare_offset})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-zinc-500",children:i("spoolbuddy.settings.calFactor","Cal. factor")}),a.jsx("span",{className:"text-zinc-400 font-mono",children:t.calibration_factor.toFixed(2)})]})]})]}),l==="idle"?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:g,disabled:p,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-200 hover:bg-zinc-600 disabled:opacity-40 transition-colors min-h-[44px]",children:p?"...":i("spoolbuddy.weight.tare","Tare")}),a.jsx("button",{onClick:y,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]",children:i("spoolbuddy.weight.calibrate","Calibrate")})]}):a.jsxs("div",{className:"bg-zinc-800 border border-zinc-700 rounded-lg p-3 space-y-2",children:[a.jsx("div",{className:"text-sm font-medium text-zinc-200",children:l==="tare"?i("spoolbuddy.settings.calStep1","Step 1: Remove all items from the scale"):i("spoolbuddy.settings.calStep2","Step 2: Place known weight on scale")}),l==="weight"&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-zinc-400",children:i("spoolbuddy.settings.knownWeight","Known weight (g)")}),a.jsxs("div",{className:"flex-1 bg-zinc-900 border border-zinc-600 rounded px-3 py-1.5 text-right text-base font-mono text-zinc-100",children:[u||"0",a.jsx("span",{className:"text-zinc-500 ml-1",children:"g"})]})]}),a.jsx("div",{className:"grid grid-cols-4 gap-1",children:["7","8","9","backspace","4","5","6",".","1","2","3","0"].map(N=>a.jsx("button",{onClick:()=>v(N),className:`py-2 rounded text-sm font-medium transition-colors min-h-[36px] ${N==="backspace"?"bg-zinc-700 text-zinc-300 hover:bg-zinc-600":"bg-zinc-800 text-zinc-100 hover:bg-zinc-700 border border-zinc-700"}`,children:N==="backspace"?"⌫":N},N))})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>c("idle"),className:"flex-1 px-4 py-2 rounded-lg text-sm bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[40px]",children:i("common.cancel","Cancel")}),a.jsx("button",{onClick:_,disabled:s,className:"flex-1 px-4 py-2 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 transition-colors min-h-[40px]",children:s?"...":l==="tare"?i("spoolbuddy.settings.setZero","Set Zero"):i("spoolbuddy.settings.calibrateNow","Calibrate")})]})]})]})}function Dtt(){const{sbState:t}=gv(),{t:e}=Et(),n=jl(),{data:r=[]}=Je({queryKey:["spoolbuddy-devices"],queryFn:()=>ys.getDevices(),refetchInterval:1e4}),i=t.deviceId?r.find(s=>s.device_id===t.deviceId)??r[0]:r[0];return a.jsxs("div",{className:"h-full flex flex-col p-4",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("button",{onClick:()=>n("/spoolbuddy/settings"),className:"p-1.5 rounded-lg text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800 transition-colors",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),a.jsx("h1",{className:"text-xl font-semibold text-zinc-100",children:e("spoolbuddy.settings.scaleCalibration","Scale Calibration")})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:i?a.jsx(Ett,{device:i,weight:t.weight,weightStable:t.weightStable,rawAdc:t.rawAdc}):a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsx("div",{className:"text-center text-zinc-500",children:a.jsx("p",{className:"text-sm",children:e("spoolbuddy.settings.noDevice","No SpoolBuddy device found")})})})})]})}const Rtt=["PLA","PETG","ABS","ASA","TPU","PA","PC","PVA","HIPS"];function Ftt(){const{t}=Et(),{sbState:e}=gv(),[n,r]=w.useState("existing"),[i,s]=w.useState(null),[o,l]=w.useState(""),[c,u]=w.useState("idle"),[d,h]=w.useState(""),[f,p]=w.useState(!1),[x,v]=w.useState(null),[g,y]=w.useState("PLA"),[_,N]=w.useState(""),[A,C]=w.useState("#00AE42"),[j,k]=w.useState(""),[R,M]=w.useState(1e3),[D,G]=w.useState(!1),{data:U=[],refetch:W}=Je({queryKey:["inventory-spools"],queryFn:()=>ge.getSpools(!1),refetchInterval:1e4}),{data:L=[]}=Je({queryKey:["spoolbuddy-devices"],queryFn:()=>ys.getDevices(),refetchInterval:5e3}),ee=L[0],ae=e.deviceOnline,Y=w.useMemo(()=>{let K;if(n==="existing")K=U.filter(T=>!T.tag_uid&&!T.archived_at);else if(n==="replace")K=U.filter(T=>T.tag_uid&&!T.archived_at);else return[];if(o){const T=o.toLowerCase();K=K.filter(E=>E.material?.toLowerCase().includes(T)||E.color_name?.toLowerCase().includes(T)||E.brand?.toLowerCase().includes(T)||E.subtype?.toLowerCase().includes(T))}return K},[U,n,o]),se=w.useCallback(K=>{const T=K.detail;(T.sak??T.data?.sak)===0&&(p(!0),v(T.tag_uid??T.data?.tag_uid??null))},[]),ce=w.useCallback(K=>{const T=K.detail;p(!0),v(T.tag_uid??T.data?.tag_uid??null)},[]),ye=w.useCallback(()=>{p(!1),v(null)},[]),Z=w.useCallback(K=>{const T=K.detail;(T.spool_id===i?.id||T.data?.spool_id===i?.id)&&(u("success"),h(t("spoolbuddy.writeTag.writeSuccess","Tag written successfully!")),W(),setTimeout(()=>{u("idle"),s(null),h("")},5e3))},[i,t,W]),ue=w.useCallback(K=>{const T=K.detail;(T.spool_id===i?.id||T.data?.spool_id===i?.id)&&(u("error"),h(T.message??T.data?.message??t("spoolbuddy.writeTag.writeFailed","Write failed")))},[i,t]);w.useEffect(()=>(window.addEventListener("spoolbuddy-unknown-tag",se),window.addEventListener("spoolbuddy-tag-matched",ce),window.addEventListener("spoolbuddy-tag-removed",ye),window.addEventListener("spoolbuddy-tag-written",Z),window.addEventListener("spoolbuddy-tag-write-failed",ue),()=>{window.removeEventListener("spoolbuddy-unknown-tag",se),window.removeEventListener("spoolbuddy-tag-matched",ce),window.removeEventListener("spoolbuddy-tag-removed",ye),window.removeEventListener("spoolbuddy-tag-written",Z),window.removeEventListener("spoolbuddy-tag-write-failed",ue)}),[se,ce,ye,Z,ue]),w.useEffect(()=>{s(null),u("idle"),h(""),l("")},[n]);const pe=async()=>{if(!(!i||!ee)){u("writing"),h(t("spoolbuddy.writeTag.waiting","Waiting for SpoolBuddy..."));try{await ys.writeTag(ee.device_id,i.id)}catch{u("error"),h(t("spoolbuddy.writeTag.queueFailed","Failed to queue write command"))}}},be=async()=>{if(ee){try{await ys.cancelWrite(ee.device_id)}catch{}u("idle"),h("")}},Ee=async()=>{G(!0);try{const K=A.replace("#","")+"FF",T=await ge.createSpool({material:g,subtype:null,color_name:_||null,rgba:K,brand:j||null,label_weight:R,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:null,slicer_filament_name:null,nozzle_temp_min:null,nozzle_temp_max:null,note:null,added_full:!0,last_used:null,encode_time:null,tag_uid:null,tray_uuid:null,data_origin:null,tag_type:null,cost_per_kg:null,last_scale_weight:null,last_weighed_at:null});s(T),W()}catch{h(t("spoolbuddy.writeTag.createFailed","Failed to create spool")),u("error")}finally{G(!1)}},$=i&&ae&&c!=="writing"&&c!=="success";return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex border-b border-bambu-dark-tertiary shrink-0",children:[{key:"existing",label:t("spoolbuddy.writeTag.tabExisting","Existing Spool")},{key:"new",label:t("spoolbuddy.writeTag.tabNew","New Spool")},{key:"replace",label:t("spoolbuddy.writeTag.tabReplace","Replace Tag")}].map(K=>a.jsx("button",{onClick:()=>r(K.key),className:`flex-1 py-3 text-sm font-medium transition-colors ${n===K.key?"text-bambu-green border-b-2 border-bambu-green bg-bambu-dark":"text-zinc-400 hover:text-zinc-200 hover:bg-bambu-dark-tertiary"}`,children:K.label},K.key))}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx("div",{className:"flex-1 flex flex-col overflow-hidden border-r border-bambu-dark-tertiary",children:n==="new"?a.jsx(Ott,{material:g,setMaterial:y,colorName:_,setColorName:N,colorHex:A,setColorHex:C,brand:j,setBrand:k,weight:R,setWeight:M,creating:D,onSubmit:Ee,selectedSpool:i,t}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"p-3 shrink-0",children:a.jsx("input",{type:"text",value:o,onChange:K=>l(K.target.value),placeholder:t("spoolbuddy.writeTag.searchPlaceholder","Search by material, color, brand..."),className:"w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-bambu-green"})}),a.jsx("div",{className:"flex-1 overflow-y-auto px-3 pb-3 space-y-2",children:Y.length===0?a.jsx("div",{className:"text-center text-zinc-500 py-8 text-sm",children:n==="existing"?t("spoolbuddy.writeTag.noUntaggedSpools","No spools without tags"):t("spoolbuddy.writeTag.noTaggedSpools","No spools with tags")}):Y.map(K=>a.jsx(Ltt,{spool:K,selected:i?.id===K.id,showTag:n==="replace",onClick:()=>{s(K),u("idle"),h("")}},K.id))})]})}),a.jsx("div",{className:"w-[340px] flex flex-col items-center justify-center p-6 shrink-0",children:a.jsx(Itt,{writeStatus:c,writeMessage:d,selectedSpool:i,tagOnReader:f,tagUid:x,deviceOnline:ae,canWrite:!!$,isReplace:n==="replace",onWrite:pe,onCancel:be,onRetry:()=>{u("idle"),h("")},t})})]})]})}function Ltt({spool:t,selected:e,showTag:n,onClick:r}){const i=t.rgba?`#${t.rgba.slice(0,6)}`:"#666",s=Math.max(0,t.label_weight-t.weight_used),o=t.label_weight>0?Math.round(s/t.label_weight*100):0;return a.jsxs("button",{onClick:r,className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${e?"bg-bambu-green/15 border border-bambu-green/50":"bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[a.jsx("div",{className:"w-8 h-8 rounded-full shrink-0 border border-white/10",style:{backgroundColor:i}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("span",{className:"text-sm font-medium text-white truncate",children:[t.brand?`${t.brand} `:"",t.material,t.subtype?` ${t.subtype}`:""]})}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-400",children:[t.color_name&&a.jsx("span",{children:t.color_name}),a.jsxs("span",{children:[s,"g / ",t.label_weight,"g (",o,"%)"]})]}),n&&t.tag_uid&&a.jsx("div",{className:"text-xs text-zinc-500 mt-0.5 font-mono",children:t.tag_uid})]}),e&&a.jsx("svg",{className:"w-5 h-5 text-bambu-green shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:a.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})]})}function Ott({material:t,setMaterial:e,colorName:n,setColorName:r,colorHex:i,setColorHex:s,brand:o,setBrand:l,weight:c,setWeight:u,creating:d,onSubmit:h,selectedSpool:f,t:p}){return f?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-6 text-center",children:[a.jsx("div",{className:"w-12 h-12 rounded-full mb-4 border border-white/10",style:{backgroundColor:f.rgba?`#${f.rgba.slice(0,6)}`:"#666"}}),a.jsxs("p",{className:"text-white font-medium",children:[f.brand?`${f.brand} `:"",f.material]}),f.color_name&&a.jsx("p",{className:"text-zinc-400 text-sm",children:f.color_name}),a.jsxs("p",{className:"text-zinc-500 text-xs mt-1",children:[f.label_weight,"g"]}),a.jsx("p",{className:"text-bambu-green text-sm mt-4",children:p("spoolbuddy.writeTag.spoolCreated","Spool created! Ready to write.")})]}):a.jsxs("div",{className:"p-4 space-y-4 overflow-y-auto",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:p("spoolbuddy.writeTag.material","Material")}),a.jsx("select",{value:t,onChange:x=>e(x.target.value),className:"w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green",children:Rtt.map(x=>a.jsx("option",{value:x,children:x},x))})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:p("spoolbuddy.writeTag.colorName","Color Name")}),a.jsx("input",{type:"text",value:n,onChange:x=>r(x.target.value),placeholder:"Jade White",className:"w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:p("spoolbuddy.writeTag.color","Color")}),a.jsx("input",{type:"color",value:i,onChange:x=>s(x.target.value),className:"w-10 h-9 bg-transparent border border-bambu-dark-tertiary rounded cursor-pointer"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:p("spoolbuddy.writeTag.brand","Brand")}),a.jsx("input",{type:"text",value:o,onChange:x=>l(x.target.value),placeholder:"Polymaker",className:"w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-zinc-400 mb-1",children:p("spoolbuddy.writeTag.weight","Weight (g)")}),a.jsx("input",{type:"number",value:c,onChange:x=>u(parseInt(x.target.value)||0),min:0,max:1e4,className:"w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green"})]}),a.jsx("button",{onClick:h,disabled:d||!t,className:"w-full py-2.5 bg-bambu-green hover:bg-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium rounded transition-colors",children:d?p("spoolbuddy.writeTag.creating","Creating..."):p("spoolbuddy.writeTag.createSpool","Create Spool")})]})}function Itt({writeStatus:t,writeMessage:e,selectedSpool:n,tagOnReader:r,tagUid:i,deviceOnline:s,canWrite:o,isReplace:l,onWrite:c,onCancel:u,onRetry:d,t:h}){if(t==="success")return a.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[a.jsx("div",{className:"w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center",children:a.jsx("svg",{className:"w-8 h-8 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),a.jsx("p",{className:"text-green-400 font-medium",children:e}),n&&a.jsxs("p",{className:"text-zinc-400 text-sm",children:[n.brand?`${n.brand} `:"",n.material,n.color_name?` - ${n.color_name}`:""]})]});if(t==="error")return a.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[a.jsx("div",{className:"w-16 h-16 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx("svg",{className:"w-8 h-8 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),a.jsx("p",{className:"text-red-400 font-medium",children:e}),a.jsx("button",{onClick:d,className:"px-4 py-2 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary text-white text-sm rounded transition-colors",children:h("spoolbuddy.writeTag.tryAgain","Try Again")})]});if(t==="writing")return a.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[a.jsxs("div",{className:"relative w-16 h-16",children:[a.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-bambu-green/30 animate-ping"}),a.jsx("div",{className:"absolute inset-2 rounded-full border-2 border-bambu-green/50 animate-pulse"}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsx(Fy,{className:"w-8 h-8 text-bambu-green"})})]}),a.jsx("p",{className:"text-bambu-green font-medium",children:h("spoolbuddy.writeTag.writing","Writing tag...")}),a.jsx("p",{className:"text-zinc-500 text-xs",children:e}),a.jsx("button",{onClick:u,className:"px-4 py-2 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary text-zinc-400 text-sm rounded transition-colors",children:h("spoolbuddy.writeTag.cancel","Cancel")})]});if(!s)return a.jsxs("div",{className:"flex flex-col items-center text-center space-y-3",children:[a.jsx(Fy,{className:"w-12 h-12 text-zinc-600"}),a.jsx("p",{className:"text-zinc-500 text-sm",children:h("spoolbuddy.writeTag.deviceOffline","SpoolBuddy is offline")})]});if(!n)return a.jsxs("div",{className:"flex flex-col items-center text-center space-y-3",children:[a.jsx(Fy,{className:"w-12 h-12 text-zinc-600"}),a.jsx("p",{className:"text-zinc-400 text-sm",children:h("spoolbuddy.writeTag.selectSpool","Select a spool, then place a blank NTAG on the reader")})]});const f=n.rgba?`#${n.rgba.slice(0,6)}`:"#666";return a.jsxs("div",{className:"flex flex-col items-center text-center space-y-4 w-full",children:[a.jsx("div",{className:"relative w-16 h-16",children:r?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"absolute inset-0 rounded-full bg-bambu-green/10"}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsx(Fy,{className:"w-8 h-8 text-bambu-green"})})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-zinc-600 animate-pulse"}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsx(Fy,{className:"w-8 h-8 text-zinc-500"})})]})}),r?a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-bambu-green text-sm font-medium",children:h("spoolbuddy.writeTag.tagReady","Tag detected — ready to write")}),i&&a.jsx("p",{className:"text-zinc-500 text-xs font-mono",children:i})]}):a.jsx("p",{className:"text-zinc-400 text-sm",children:h("spoolbuddy.writeTag.placeTag","Place an NTAG on the reader")}),a.jsxs("div",{className:"w-full bg-bambu-dark-secondary rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-full border border-white/10 shrink-0",style:{backgroundColor:f}}),a.jsxs("div",{className:"text-left min-w-0",children:[a.jsxs("p",{className:"text-white text-sm font-medium truncate",children:[n.brand?`${n.brand} `:"",n.material]}),n.color_name&&a.jsx("p",{className:"text-zinc-400 text-xs",children:n.color_name})]})]}),a.jsxs("div",{className:"text-xs text-zinc-500",children:[n.label_weight,"g"]})]}),l&&n.tag_uid&&a.jsx("p",{className:"text-yellow-500/80 text-xs",children:h("spoolbuddy.writeTag.replaceWarning","Old tag will be unlinked. New tag will replace it.")}),a.jsx("button",{onClick:c,disabled:!o,className:"w-full py-3 bg-bambu-green hover:bg-bambu-green/80 disabled:opacity-40 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors text-sm",children:l?h("spoolbuddy.writeTag.replaceTag","Replace Tag"):h("spoolbuddy.writeTag.writeTag","Write Tag")})]})}function Fy({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.288 15.038a5.25 5.25 0 017.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0"}),a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12.53 18.22l-.53.53-.53-.53a.75.75 0 011.06 0z"})]})}const ztt=new qde({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function OK({children:t}){return Uet(),a.jsx(a.Fragment,{children:t})}function IK({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(gb,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function ZE({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(gb,{to:"/",replace:!0}):a.jsx(gb,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function Utt({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(gb,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function Btt(){return a.jsx(Uge,{children:a.jsx(Kge,{children:a.jsx(Gde,{client:ztt,children:a.jsx(Gge,{children:a.jsx(dde,{children:a.jsxs(Uue,{children:[a.jsx(Mr,{path:"/setup",element:a.jsx(Utt,{children:a.jsx(zet,{})})}),a.jsx(Mr,{path:"/login",element:a.jsx(Iet,{})}),a.jsx(Mr,{path:"/camera/:printerId",element:a.jsx(KJe,{})}),a.jsx(Mr,{path:"/overlay/:printerId",element:a.jsx(ZJe,{})}),a.jsxs(Mr,{element:a.jsx(IK,{children:a.jsx(OK,{children:a.jsx(ett,{})})}),children:[a.jsx(Mr,{path:"spoolbuddy",element:a.jsx(ytt,{})}),a.jsx(Mr,{path:"spoolbuddy/ams",element:a.jsx(Stt,{})}),a.jsx(Mr,{path:"spoolbuddy/write-tag",element:a.jsx(Ftt,{})}),a.jsx(Mr,{path:"spoolbuddy/settings",element:a.jsx(jtt,{})}),a.jsx(Mr,{path:"spoolbuddy/calibration",element:a.jsx(Dtt,{})})]}),a.jsxs(Mr,{element:a.jsx(IK,{children:a.jsx(OK,{children:a.jsx(nbe,{})})}),children:[a.jsx(Mr,{index:!0,element:a.jsx($$e,{})}),a.jsx(Mr,{path:"archives",element:a.jsx(PXe,{})}),a.jsx(Mr,{path:"queue",element:a.jsx(fZe,{})}),a.jsx(Mr,{path:"stats",element:a.jsx(EZe,{})}),a.jsx(Mr,{path:"profiles",element:a.jsx(_Je,{})}),a.jsx(Mr,{path:"maintenance",element:a.jsx(TJe,{})}),a.jsx(Mr,{path:"projects",element:a.jsx(PJe,{})}),a.jsx(Mr,{path:"projects/:id",element:a.jsx(OJe,{})}),a.jsx(Mr,{path:"inventory",element:a.jsx(Pet,{})}),a.jsx(Mr,{path:"files",element:a.jsx(VJe,{})}),a.jsx(Mr,{path:"settings",element:a.jsx(ZE,{children:a.jsx(cJe,{})})}),a.jsx(Mr,{path:"groups/new",element:a.jsx(ZE,{children:a.jsx(kK,{})})}),a.jsx(Mr,{path:"groups/:id/edit",element:a.jsx(ZE,{children:a.jsx(kK,{})})}),a.jsx(Mr,{path:"users",element:a.jsx(gb,{to:"/settings?tab=users",replace:!0})}),a.jsx(Mr,{path:"groups",element:a.jsx(gb,{to:"/settings?tab=users",replace:!0})}),a.jsx(Mr,{path:"system",element:a.jsx(Oet,{})}),a.jsx(Mr,{path:"external/:id",element:a.jsx(JJe,{})})]})]})})})})})})}Lle.createRoot(document.getElementById("root")).render(a.jsx(w.StrictMode,{children:a.jsx(Btt,{})}));